activity.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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 {*} openId
  142. * @param {*} mobile
  143. */
  144. static async saveUser(openId,mobile) {
  145. let params = {
  146. openid:openId,
  147. mobile:mobile,
  148. source:'FREE_MINI_APP'
  149. };
  150. const res = await this.postRequest(`${this.BASE_URL}open/activity/save-user`, params)
  151. return res.data
  152. }
  153. /**
  154. * 设置手机缓存
  155. * @param {*} mobile
  156. */
  157. static setMobileCache(mobile) {
  158. let data = {
  159. mobile:mobile,
  160. }
  161. wx.setStorageSync('userInfo',data);
  162. }
  163. static getMobileCache() {
  164. let userInfo = wx.getStorageSync('userInfo');
  165. if(userInfo) {
  166. return userInfo.mobile;
  167. }
  168. return '';
  169. }
  170. static getSessionKey() {
  171. return wx.getStorageSync('loginInfo').sessionKey;
  172. }
  173. /**
  174. * 获取用户openid
  175. */
  176. static getOpenId() {
  177. return wx.getStorageSync('loginInfo').openId;
  178. }
  179. /**
  180. * 卡券详情数据
  181. */
  182. static getCouponDetailData(params) {
  183. return this.postRequest(`${this.BASE_URL}open/coupon/get-coupon-data`, params);
  184. }
  185. static getFoodListByCoupon(params) {
  186. return this.postRequest(`${this.BASE_URL}open/coupon/get-food-list-by-coupon`, params);
  187. }
  188. static getStoreListByCoupon(params) {
  189. return this.postRequest(`${this.BASE_URL}open/coupon/get-store-list-by-coupon`, params);
  190. }
  191. }
  192. export default activity