activity.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 {*} mobile
  30. */
  31. static async createShareActivityCode(activityId,mobile) {
  32. let params = {
  33. activityId:activityId,
  34. mobile:mobile
  35. // mobile:13205528979
  36. };
  37. const res = await this.postRequest(`${this.BASE_URL}open/activity/create-share-activity-code`, params)
  38. return res.data
  39. }
  40. static async getSessionKeyFromApi(code) {
  41. let params = {
  42. appCode:getApp().globalData.appCode,
  43. sessionCode:code
  44. };
  45. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/wx-login`, params)
  46. return res.data
  47. }
  48. /**
  49. * 解锁手机号
  50. * @param {*} orderSn
  51. */
  52. static async getAuthMobile(params) {
  53. const res = await this.postRequest(`${this.BASE_URL}open/wxapp/auth-mobile`, params)
  54. return res.data
  55. }
  56. /**
  57. * 保存用户信息
  58. * @param {*} openId
  59. * @param {*} mobile
  60. */
  61. static async saveUser(openId,mobile) {
  62. let params = {
  63. openid:openId,
  64. mobile:mobile,
  65. source:'FREE_MINI_APP'
  66. };
  67. const res = await this.postRequest(`${this.BASE_URL}open/activity/save-user`, params)
  68. return res.data
  69. }
  70. /**
  71. * 设置手机缓存
  72. * @param {*} mobile
  73. */
  74. static setMobileCache(mobile) {
  75. let data = {
  76. mobile:mobile,
  77. }
  78. wx.setStorageSync('userInfo',data);
  79. }
  80. static getMobileCache() {
  81. let userInfo = wx.getStorageSync('userInfo');
  82. if(userInfo) {
  83. return userInfo.mobile;
  84. }
  85. return '';
  86. }
  87. static getSessionKey() {
  88. return wx.getStorageSync('loginInfo').sessionKey;
  89. }
  90. /**
  91. * 获取用户openid
  92. */
  93. static getOpenId() {
  94. return wx.getStorageSync('loginInfo').openId;
  95. }
  96. }
  97. export default activity