xiaohuangmao il y a 4 ans
Parent
commit
fb38b9f546
6 fichiers modifiés avec 95 ajouts et 2 suppressions
  1. 2 1
      app.json
  2. 78 0
      pages/auth/auth.js
  3. 5 0
      pages/auth/auth.json
  4. 2 0
      pages/auth/auth.wxml
  5. 1 0
      pages/auth/auth.wxss
  6. 7 1
      pages/postage/postage.js

+ 2 - 1
app.json

@@ -24,7 +24,8 @@
     "pages/fcode/fcode",
     "pages/login/login",
     "pages/shareBonus/shareBonus",
-    "pages/handOutBonus/handOutBonus"
+    "pages/handOutBonus/handOutBonus",
+    "pages/auth/auth"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 78 - 0
pages/auth/auth.js

@@ -0,0 +1,78 @@
+// pages/auth.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    userInfo: {}
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  getAuth(e) {
+    let { userInfo } = e.detail
+    if (userInfo) {
+      this.setData({
+        userInfo
+      })
+      wx.reLaunch({
+        url: '/pages/index/index'
+      });
+    }
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
pages/auth/auth.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "auth": "../components/auth/auth"
+  }
+}

+ 2 - 0
pages/auth/auth.wxml

@@ -0,0 +1,2 @@
+<!--pages/auth.wxml-->
+<auth wx:if="{{!userInfo}}" bind:getAuth="getAuth"></auth>

+ 1 - 0
pages/auth/auth.wxss

@@ -0,0 +1 @@
+/* pages/auth.wxss */

+ 7 - 1
pages/postage/postage.js

@@ -67,6 +67,7 @@ Page({
       fromSource: app.globalData.fromSource,
       // card_no: this.data.tabsData[0].card_no
     });
+
     getReq({
       act: 'index',
       op: 'card_goods',
@@ -79,9 +80,11 @@ Page({
       if (res.code == 200) {
         if(res.datas && res.datas.goods){
           const datas = res.datas
-          const { tips = '', goods = [], cards = [], } = datas
+          const { tips = '', goods = [], cards = [], } = datas || {}
           const sinopec = this.getValueBykey('sinopec', cards)
           const petrochina = this.getValueBykey('petrochina', cards)
+          console.log('sinopec',sinopec)
+          console.log('petrochina',petrochina)
           this.setData({ tips, goods, cards, sinopec, petrochina, card_no: sinopec.card_no, goods_id: datas.goods[0].goods_id });
         }
       } else {
@@ -91,6 +94,9 @@ Page({
   },
   // 通过键取值
   getValueBykey(key = '', data = []){
+    if(!data.length){
+      return {}
+    }
     return data.filter(val => val.card_type === key)[0]
   },