zhashaonan 7 jaren geleden
bovenliggende
commit
080a755413
1 gewijzigde bestanden met toevoegingen van 12 en 3 verwijderingen
  1. 12 3
      pages/index/index.js

+ 12 - 3
pages/index/index.js

@@ -1,5 +1,6 @@
 //index.js
 //获取应用实例
+const getReq = require('./../../config.js').getReq
 const app = getApp()
 
 Page({
@@ -10,18 +11,26 @@ Page({
     canIUse: wx.canIUse('button.open-type.getUserInfo')
   },
   //事件处理函数
-  bindViewTap: function() {
+  bindViewTap: function () {
     wx.navigateTo({
       url: '../logs/logs'
     })
   },
   onLoad: function () {
+    getReq({
+      goods_id: '4565',
+      act: 'goods_common',
+      op: 'index',
+    }, function (res) {
+      console.log(res)
+    })
+
     if (app.globalData.userInfo) {
       this.setData({
         userInfo: app.globalData.userInfo,
         hasUserInfo: true
       })
-    } else if (this.data.canIUse){
+    } else if (this.data.canIUse) {
       // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
       // 所以此处加入 callback 以防止这种情况
       app.userInfoReadyCallback = res => {
@@ -43,7 +52,7 @@ Page({
       })
     }
   },
-  getUserInfo: function(e) {
+  getUserInfo: function (e) {
     console.log(e)
     app.globalData.userInfo = e.detail.userInfo
     this.setData({