activity.js 1.7 KB

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