stanley-king пре 4 година
родитељ
комит
4a9f2346ff
3 измењених фајлова са 30 додато и 26 уклоњено
  1. 4 4
      app.json
  2. 2 2
      config.js
  3. 24 20
      pages/phoneCharges/phoneCharges.js

+ 4 - 4
app.json

@@ -1,8 +1,5 @@
 {
   "pages": [
-    "pages/phoneCharges/phoneCharges",
-    "pages/invitees/invitees",
-    "pages/myhome/myhome",
     "pages/index/index",
     "pages/postage/postage",
     "pages/postageDetail/postageDetail",
@@ -26,7 +23,10 @@
     "pages/login/login",
     "pages/shareBonus/shareBonus",
     "pages/handOutBonus/handOutBonus",
-    "pages/auth/auth"
+	"pages/auth/auth",
+	"pages/phoneCharges/phoneCharges",
+	"pages/invitees/invitees",
+	"pages/myhome/myhome"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 2 - 2
config.js

@@ -1,7 +1,7 @@
 // let api = "https://passport.lrlz.com/mobile/index.php";
 // let api = "http://www.xyzshops.cn/mobile/index.php";
-// let api = "http://192.168.1.200/mobile/index.php";
-let api = "https://www.xyzshops.cn/mobile/index.php";
+let api = "http://192.168.1.200/mobile/index.php";
+// let api = "https://www.xyzshops.cn/mobile/index.php";
 
 function getReq(app,data, callback, method)
 {

+ 24 - 20
pages/phoneCharges/phoneCharges.js

@@ -14,9 +14,8 @@ Page({
     tips:'',  //顶部tips
     goods:[], //挡位数据
     goods_id:'', //当前选中挡位的goods_id
-    card_type: '', //油卡类型 (中石化/中石油)
-    card_no: '', //油卡号
-    firstLoad: true,
+    card_type: 'phone',
+    card_no: '',
     fromSource: ''
   },
 
@@ -56,19 +55,20 @@ Page({
     getReq(app,{
       act: 'index',
       op: 'card_goods',
-      page_type: 'oil',
+      page_type: 'mobile',
       from: fromSource
-    }, function (res) {
-      self.setData({
-        firstLoad: false
-      });
+    }, 
+    function (res) {
       if (res.code == 200) {
         if(res.datas && res.datas.goods){
           var datas = res.datas
+          var card = self.findCard(res.datas.cards,'phone')
+          console.log('card no:',card.card_no)
           self.setData({
             tips: datas.tips,
             goods: datas.goods,
-            goods_id: datas.goods[0].goods_id
+            goods_id: datas.goods[0].goods_id,
+            card_no: card.card_no
           });
         }
       }else {
@@ -80,7 +80,14 @@ Page({
       }
     })
   },
-
+  findCard(cards,card_type) {
+    for (const card of cards) {
+      if (card.card_type == card_type) {
+        return card;
+      }      
+    }
+    return {};
+  },
   // 立即充值
   handlerRecharge()
   {
@@ -89,12 +96,12 @@ Page({
     //   title: `goods_id: ${this.data.goods_id}, card_no: ${this.data.card_no}`,
     //   duration: 2000
     // })
-    const { goods_id, card_no } = this.data
+    const { goods_id, card_no, card_type } = this.data
     if(!card_no){
       app.showToast('卡号不能为空')
       return
     }
-    buyVGoods(app,goods_id,1,{ card_no }, (res) => {
+    buyVGoods(app, goods_id, 1, { card_no, card_type}, (res) => {
     }, (err) => {
     })
   },
@@ -110,15 +117,12 @@ Page({
    * 生命周期函数--监听页面显示
    */
   onShow: function () {
-    if(!this.data.firstLoad) {
-      const record = app.globalData.record || {}
-      console.log('record',record)
-      const { card_no = '' } = record
-      app.setFromSource(this.data.fromSource)
-      if (record) {
-        this.setData({ card_no })
-      }
+    const record = app.globalData.record || {}
+    const { card_no = '' } = record
+    if (card_no) {
+      this.setData({ card_no })
     }
+    app.setFromSource(this.data.fromSource)
   },
 
   /**