activity.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. import request from '../utils/request.js'
  2. class activity extends request {
  3. /**
  4. * 获取活动列表
  5. * @param {*} nextPage
  6. * @param {*} pageSize
  7. * @param {*} status
  8. */
  9. static async getActivityList(nextPage,pageSize,status) {
  10. let params = {
  11. nextPage:nextPage,
  12. pageSize:pageSize,
  13. condition:{
  14. statusList:[status],
  15. source:"FREE_MINI_APP",
  16. }
  17. };
  18. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-list`, params)
  19. return res.data
  20. }
  21. static async isShareByMobile(mobile) {
  22. let params = {
  23. mobile:mobile
  24. };
  25. const res = await this.postRequest(`${this.BASE_URL}open/activity/is-share-by-mobile`, params)
  26. return res.data
  27. }
  28. /**
  29. * 获取支付参数
  30. * @param {*} orderSn
  31. */
  32. static async getOrderParams(orderSn,activityName='') {
  33. let params = {
  34. orderSn:orderSn,
  35. source:"FREE_MINI_APP",
  36. thirdPartyName:activityName,
  37. openId:wx.getStorageSync('loginInfo').openId,
  38. payCode:'',
  39. };
  40. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-order-params`, params)
  41. return res.data
  42. }
  43. /**
  44. * 获取活动详情
  45. * @param {*} activityId 活动id
  46. */
  47. static async getActivityDetail(activityId) {
  48. let params = {
  49. activityId:activityId
  50. };
  51. const res = await this.getRequest(`${this.BASE_URL}open/activity/get`, params)
  52. return res.data
  53. }
  54. /**
  55. * 领券
  56. * @param {*} activityId
  57. * @param {*} memberMobile
  58. * @param {*} number
  59. * @param {*} shopId
  60. */
  61. static async createOrder(activityId,memberMobile,num=1,shopId='') {
  62. let params = {
  63. activityId:activityId,
  64. memberMobile:memberMobile,
  65. num:num,
  66. shopId:shopId
  67. };
  68. console.log('参数');
  69. console.log(params);
  70. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-order`, params)
  71. return res.data
  72. }
  73. /**
  74. * 分享活动的分享码
  75. * @param {*} activityId
  76. * @param {*} mobile
  77. */
  78. static async createShareActivityCode(activityId,mobile) {
  79. let params = {
  80. activityId:activityId,
  81. mobile:mobile
  82. // activityId:'Bg5740r78w',
  83. // mobile:13205528979
  84. };
  85. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-share-activity-code`, params)
  86. return res.data
  87. }
  88. //根据codeId 获取 分享活动的详细信息
  89. static async getShareActivityCode(codeId) {
  90. let params = {
  91. codeId:codeId,
  92. };
  93. console.log(params)
  94. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-share-activity-code`, params)
  95. return res.data
  96. }
  97. /**
  98. * 获取我的券列表
  99. * @param {*} nextPage
  100. * @param {*} pageSize
  101. * @param {*} mobile
  102. */
  103. static async getSnListMember(nextPage,pageSize,mobile) {
  104. let params = {
  105. nextPage:nextPage,
  106. pageSize:pageSize,
  107. condition:{
  108. mobile:mobile
  109. }
  110. };
  111. const res = await this.postRequest(`${this.BASE_URL}open/activity/sn-list-member`, params)
  112. return res.data
  113. }
  114. //绑定券与codeId之间的关系
  115. static async bindShareCode(orderSn,codeId) {
  116. let params = {
  117. orderSn:orderSn,
  118. codeId:codeId
  119. };
  120. const res = await this.postRequest(`${this.BASE_URL}open/activity/bind-share-code`, params)
  121. return res.data
  122. }
  123. static async getSessionKeyFromApi(code) {
  124. let params = {
  125. appCode:getApp().globalData.appCode,
  126. sessionCode:code
  127. };
  128. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/wx-login`, params)
  129. return res.data
  130. }
  131. /**
  132. * 解锁手机号
  133. * @param {*} orderSn
  134. */
  135. static async getAuthMobile(params) {
  136. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/auth-mobile`, params)
  137. return res.data
  138. }
  139. /**
  140. * 解锁手机号 新接口
  141. * @param {*} orderSn
  142. */
  143. static async getAuthMobileNew(params) {
  144. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/auth-mobile-new`, params)
  145. return res.data
  146. }
  147. /**
  148. * 保存用户信息
  149. * @param {*} openId
  150. * @param {*} mobile
  151. */
  152. static async saveUser(openId,mobile,headerImg="",nickName="") {
  153. let params = {
  154. openid:openId,
  155. mobile:mobile,
  156. source:'FREE_MINI_APP'
  157. };
  158. if(headerImg){
  159. params.headerImg = headerImg;
  160. }
  161. if(nickName){
  162. params.nickName = nickName;
  163. }
  164. const res = await this.postRequest(`${this.BASE_URL}open/activity/save-user`, params)
  165. return res.data
  166. }
  167. static async getUserInfo(mobile) {
  168. let params = {
  169. mobile:mobile,
  170. source:'FREE_MINI_APP'
  171. };
  172. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-user`, params)
  173. return res.data
  174. }
  175. /**
  176. * 设置手机缓存
  177. * @param {*} mobile
  178. */
  179. static setMobileCache(mobile) {
  180. let data = {
  181. mobile:mobile,
  182. }
  183. wx.setStorageSync('userInfo',data);
  184. }
  185. static getMobileCache() {
  186. let userInfo = wx.getStorageSync('userInfo');
  187. if(userInfo) {
  188. return userInfo.mobile;
  189. }
  190. return '';
  191. }
  192. // static getSessionKey() {
  193. // return wx.getStorageSync('loginInfo').sessionKey;
  194. // }
  195. /**
  196. * 获取用户openid
  197. */
  198. static getOpenId() {
  199. return wx.getStorageSync('loginInfo').openId;
  200. }
  201. /**
  202. * 卡券详情数据
  203. */
  204. static getCouponDetailData(params) {
  205. return this.postRequest(`${this.BASE_URL}open/coupon/get-coupon-data`, params);
  206. }
  207. static getFoodListByCoupon(params) {
  208. return this.postRequest(`${this.BASE_URL}open/coupon/get-food-list-by-coupon`, params);
  209. }
  210. static getStoreListByCoupon(params) {
  211. return this.postRequest(`${this.BASE_URL}open/coupon/get-store-list-by-coupon`, params);
  212. }
  213. }
  214. export default activity