Jelajahi Sumber

活动页加登录回调

bayi 2 tahun lalu
induk
melakukan
cc6562d3f6
2 mengubah file dengan 31 tambahan dan 17 penghapusan
  1. 26 12
      pages/activity/index.js
  2. 5 5
      utils/request.js

+ 26 - 12
pages/activity/index.js

@@ -9,7 +9,7 @@ import {
 } from '~/store/index'
 Page({
   data: {
-    activityList: true,
+    activityList: false,
     bannerList: []
   },
   onShow() {
@@ -17,17 +17,22 @@ Page({
       this.getTabBar().setData({
         selected: 1
       })
-      this.storeBindings = createStoreBindings(this, {
-        store,
-        fields: {
-          userInfo: 'userInfo'
-        },
-      })
-      this.storeBindings.updateStoreBindings()
-      this.setData({
-        activityList: true
-      })
-      this.getBannerList()
+      this.getLocUserInfo()
+      if (Object.keys(this.data.userInfo).length > 0) {
+        this.getBannerList()
+        this.setData({
+          activityList: true
+        })
+      } else {
+        getApp().callBack = (res) => {
+          this.getLocUserInfo()
+          this.getBannerList()
+          this.setData({
+            activityList: true
+          })
+        }
+      }
+
     }
   },
   onHide() {
@@ -47,6 +52,15 @@ Page({
     this.selectComponent('#activityList').getActivities()
     this.getBannerList()
   },
+  async getLocUserInfo() {
+    this.storeBindings = createStoreBindings(this, {
+      store,
+      fields: {
+        userInfo: 'userInfo'
+      },
+    })
+    this.storeBindings.updateStoreBindings()
+  },
   onUnload() {
     this.storeBindings.destroyStoreBindings()
   },

+ 5 - 5
utils/request.js

@@ -6,13 +6,13 @@ const {
     envVersion
   }
 } = wx.getAccountInfoSync();
-// if (envVersion == 'develop') {
+if (envVersion == 'develop') {
   baseUrl = 'https://reader-api.efunbox.cn/wx'
   oldUrl = 'https://reader-api.efunbox.cn'
-// } else {
-//   baseUrl = 'https://reader-api.ai160.com/wx'
-//   oldUrl = 'https://reader-api.ai160.com'
-// }
+} else {
+  baseUrl = 'https://reader-api.ai160.com/wx'
+  oldUrl = 'https://reader-api.ai160.com'
+}
 
 function request(url, method, data, oldBaseUrl = false) {
   let header = {