activity.js 2.0 KB

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