activity.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. import request from '../utils/request.js'
  2. class activity extends request {
  3. static async getActivityList(nextPage,pageSize,status) {
  4. let params = {
  5. nextPage:nextPage,
  6. pageSize:pageSize,
  7. condition:{
  8. statusList:[status],
  9. source:"FREE_MINI_APP",
  10. }
  11. };
  12. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-list`, params)
  13. return res.data
  14. }
  15. /**
  16. * 获取活动详情
  17. * @param {*} activityId 活动id
  18. */
  19. static async getActivityDetail(activityId) {
  20. let params = {
  21. activityId:activityId
  22. };
  23. const res = await this.getRequest(`${this.BASE_URL}open/activity/get`, params)
  24. return res.data
  25. }
  26. /**
  27. * 领券
  28. * @param {*} activityId
  29. * @param {*} memberMobile
  30. * @param {*} number
  31. * @param {*} shopId
  32. */
  33. static async createOrder(activityId,memberMobile,num=1,shopId='') {
  34. let params = {
  35. activityId:activityId,
  36. memberMobile:memberMobile,
  37. num:num,
  38. shopId:shopId
  39. };
  40. console.log('参数');
  41. console.log(params);
  42. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-order`, params)
  43. return res.data
  44. }
  45. /**
  46. * 分享活动的分享码
  47. * @param {*} activityId
  48. * @param {*} mobile
  49. */
  50. static async createShareActivityCode(activityId,mobile) {
  51. let params = {
  52. activityId:activityId,
  53. mobile:mobile
  54. // mobile:13205528979
  55. };
  56. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-share-activity-code`, params)
  57. return res.data
  58. }
  59. //根据codeId 获取 分享活动的详细信息
  60. static async getShareActivityCode(codeId) {
  61. let params = {
  62. codeId:codeId,
  63. };
  64. console.log(params)
  65. const res = await this.postRequest(`${this.BASE_URL}open/activity/get-share-activity-code`, params)
  66. return res.data
  67. }
  68. static async getSessionKeyFromApi(code) {
  69. let params = {
  70. appCode:getApp().globalData.appCode,
  71. sessionCode:code
  72. };
  73. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/wx-login`, params)
  74. return res.data
  75. }
  76. /**
  77. * 解锁手机号
  78. * @param {*} orderSn
  79. */
  80. static async getAuthMobile(params) {
  81. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/auth-mobile`, params)
  82. return res.data
  83. }
  84. /**
  85. * 保存用户信息
  86. * @param {*} openId
  87. * @param {*} mobile
  88. */
  89. static async saveUser(openId,mobile) {
  90. let params = {
  91. openid:openId,
  92. mobile:mobile,
  93. source:'FREE_MINI_APP'
  94. };
  95. const res = await this.postRequest(`${this.BASE_URL}open/activity/save-user`, params)
  96. return res.data
  97. }
  98. /**
  99. * 设置手机缓存
  100. * @param {*} mobile
  101. */
  102. static setMobileCache(mobile) {
  103. let data = {
  104. mobile:mobile,
  105. }
  106. wx.setStorageSync('userInfo',data);
  107. }
  108. static getMobileCache() {
  109. let userInfo = wx.getStorageSync('userInfo');
  110. if(userInfo) {
  111. return userInfo.mobile;
  112. }
  113. return '';
  114. }
  115. static getSessionKey() {
  116. return wx.getStorageSync('loginInfo').sessionKey;
  117. }
  118. /**
  119. * 获取用户openid
  120. */
  121. static getOpenId() {
  122. return wx.getStorageSync('loginInfo').openId;
  123. }
  124. }
  125. export default activity