activity.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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 {*} activityId 活动id
  31. */
  32. static async getActivityDetail(activityId) {
  33. let params = {
  34. activityId:activityId
  35. };
  36. const res = await this.getRequest(`${this.BASE_URL}open/activity/get`, params)
  37. return res.data
  38. }
  39. /**
  40. * 领券
  41. * @param {*} activityId
  42. * @param {*} memberMobile
  43. * @param {*} number
  44. * @param {*} shopId
  45. */
  46. static async createOrder(activityId,memberMobile,num=1,shopId='') {
  47. let params = {
  48. activityId:activityId,
  49. memberMobile:memberMobile,
  50. num:num,
  51. shopId:shopId
  52. };
  53. console.log('参数');
  54. console.log(params);
  55. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-order`, params)
  56. return res.data
  57. }
  58. /**
  59. * 分享活动的分享码
  60. * @param {*} activityId
  61. * @param {*} mobile
  62. */
  63. static async createShareActivityCode(activityId,mobile) {
  64. let params = {
  65. activityId:activityId,
  66. mobile:mobile
  67. // activityId:'Bg5740r78w',
  68. // mobile:13205528979
  69. };
  70. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-share-activity-code`, params)
  71. return res.data
  72. }
  73. //根据codeId 获取 分享活动的详细信息
  74. static async getShareActivityCode(codeId) {
  75. let params = {
  76. codeId:codeId,
  77. };
  78. console.log(params)
  79. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-share-activity-code`, params)
  80. return res.data
  81. }
  82. /**
  83. * 获取我的券列表
  84. * @param {*} nextPage
  85. * @param {*} pageSize
  86. * @param {*} mobile
  87. */
  88. static async getSnListMember(nextPage,pageSize,mobile) {
  89. let params = {
  90. nextPage:nextPage,
  91. pageSize:pageSize,
  92. condition:{
  93. mobile:mobile
  94. }
  95. };
  96. const res = await this.postRequest(`${this.BASE_URL}open/activity/sn-list-member`, params)
  97. return res.data
  98. }
  99. //绑定券与codeId之间的关系
  100. static async bindShareCode(orderSn,codeId) {
  101. let params = {
  102. orderSn:orderSn,
  103. codeId:codeId
  104. };
  105. const res = await this.postRequest(`${this.BASE_URL}open/activity/bind-share-code`, params)
  106. return res.data
  107. }
  108. static async getSessionKeyFromApi(code) {
  109. let params = {
  110. appCode:getApp().globalData.appCode,
  111. sessionCode:code
  112. };
  113. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/wx-login`, params)
  114. return res.data
  115. }
  116. /**
  117. * 解锁手机号
  118. * @param {*} orderSn
  119. */
  120. static async getAuthMobile(params) {
  121. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/auth-mobile`, params)
  122. return res.data
  123. }
  124. /**
  125. * 保存用户信息
  126. * @param {*} openId
  127. * @param {*} mobile
  128. */
  129. static async saveUser(openId,mobile) {
  130. let params = {
  131. openid:openId,
  132. mobile:mobile,
  133. source:'FREE_MINI_APP'
  134. };
  135. const res = await this.postRequest(`${this.BASE_URL}open/activity/save-user`, params)
  136. return res.data
  137. }
  138. /**
  139. * 设置手机缓存
  140. * @param {*} mobile
  141. */
  142. static setMobileCache(mobile) {
  143. let data = {
  144. mobile:mobile,
  145. }
  146. wx.setStorageSync('userInfo',data);
  147. }
  148. static getMobileCache() {
  149. let userInfo = wx.getStorageSync('userInfo');
  150. if(userInfo) {
  151. return userInfo.mobile;
  152. }
  153. return '';
  154. }
  155. static getSessionKey() {
  156. return wx.getStorageSync('loginInfo').sessionKey;
  157. }
  158. /**
  159. * 获取用户openid
  160. */
  161. static getOpenId() {
  162. return wx.getStorageSync('loginInfo').openId;
  163. }
  164. }
  165. export default activity