stanley-king 4 jaren geleden
bovenliggende
commit
db4e0b40c1

+ 14 - 16
config.js

@@ -3,9 +3,7 @@
 let api = "http://192.168.1.200/mobile/index.php";
 // let api = "https://www.xyzshops.cn/mobile/index.php";
 
-let app = getApp();
-
-function getReq(data, callback, method)
+function getReq(app,data, callback, method)
 {
   let options = { 
     client_type: 'mini'
@@ -15,7 +13,7 @@ function getReq(data, callback, method)
   let session_id = wx.getStorageSync('session_id');
   if (!session_id && data['op'] != 'ministart') {
     setTimeout(() => {
-      getReq(data, callback, method)
+      getReq(app,data, callback, method)
     }, 0);
     return;
   }
@@ -23,10 +21,11 @@ function getReq(data, callback, method)
   if(act.indexOf('member_') == 0)
   {
     console.log(act + ' must check login status.')
-    if(!app.globalData.userInfo) {
+    if (app != null && !app.globalData.userInfo) {
       wx.navigateTo({
         url: '/pages/auth/auth',
       })
+      return;
     }
   } 
   else {
@@ -52,15 +51,14 @@ function getReq(data, callback, method)
     header,
     success(res) 
     {
-      // if(res.data.code == 10014) {
-      //   wx.navigateTo({
-      //     url: '/pages/auth/auth',
-      //   })
-      // }
-      // else {
-      //   callback(res.data)
-      // }
-      callback(res.data)
+      if(res.data.code == 10014) {
+        wx.navigateTo({
+          url: '/pages/auth/auth',
+        })
+      }
+      else {
+        callback(res.data)
+      }
     },
     fail() 
     {
@@ -82,7 +80,7 @@ function getReq(data, callback, method)
   })
 }
 
-function buyVGoods(goods_id,goods_num, other, successCallback, failCallback) 
+function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback) 
 {
   let ifcart = 0 ; 
   let cartids = goods_id + '|' + goods_num;
@@ -99,7 +97,7 @@ function buyVGoods(goods_id,goods_num, other, successCallback, failCallback)
   console.table(params)
 
   params = Object.assign({}, params);
-  getReq(params, function (res) {
+  getReq(app,params, function (res) {
     wx.hideLoading()
     if (res.code == 200) {
       let param = res.datas.param.data

+ 4 - 4
pages/addAddress/addAddress.js

@@ -81,7 +81,7 @@ Page({
   },
   getDatas() {
     var self = this
-    getReq({
+    getReq(app,{
       act: 'app_update',
       op: 'area',
       curpage: 1
@@ -202,7 +202,7 @@ Page({
   },
   addArress(name, address, phone, area_info) {
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'member_address',
       op: 'address_add',
       area_info,
@@ -240,7 +240,7 @@ Page({
       address,
       mob_phone,
     }
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       if (res.code == 200) {
         self.setDefault(res, true_name, mob_phone, area_info, address, address_id, area_id, city_id)
       }
@@ -267,7 +267,7 @@ Page({
       is_default,
       address_id
     }
-    getReq(params, function (response) {
+    getReq(app,params, function (response) {
       wx.hideLoading()
       if (response.code == 200) {
         wx.navigateBack()

+ 2 - 2
pages/address/address.js

@@ -30,7 +30,7 @@ Page({
       title: '加载中',
     })
     var self = this
-    getReq({
+    getReq(app,{
       act: 'member_address',
       op: 'address_list'
     }, function (res) {
@@ -99,7 +99,7 @@ Page({
       cancelText: "取消",
       success: function(res) {
         if (res.confirm) {
-          getReq({
+          getReq(app,{
             act: 'member_address',
             op: 'address_del',
             address_id

+ 2 - 2
pages/brand/brand.js

@@ -43,7 +43,7 @@ Page({
     let self = this;
 
     
-    getReq({
+    getReq(app,{
       act: 'search',
       op: 'index',
       brand_id,
@@ -132,7 +132,7 @@ Page({
           title: '加载中',
         });
         let self = this;
-        getReq({
+        getReq(app,{
           act: 'search',
           op: 'index',
           brand_id: this.data.brand_id,

+ 1 - 1
pages/comments/comments.js

@@ -41,7 +41,7 @@ Page({
       title: '加载中'
     })
     var self = this
-    getReq({
+    getReq(app,{
       act: 'goods_common',
       op: 'comments',
       goods_commonid: common_id,

+ 1 - 1
pages/components/auth/auth.js

@@ -61,7 +61,7 @@ Component({
       }
 
       let self = this;
-      getReq(params, function (res) {
+      getReq(app,params, function (res) {
         if (res.code == 200) {
           let datas = res.datas;
           if (datas.hasmobile == false) {

+ 1 - 1
pages/components/blockItem/blockItem.js

@@ -141,7 +141,7 @@ Component({
           if(prefix == 'xyzshop://www.xyzshops.com/DirectBuyVGoods') {
             let goods_id = params['goods_id'];
             let num = params['num'];
-            buyVGoods(goods_id,num);
+            buyVGoods(app,goods_id,num);
           }
           else if(prefix == 'xyzshop://www.xyzshops.com/NavigatePage')
             switch(params.page){

+ 1 - 1
pages/components/blocks/search_box/search_box.js

@@ -47,7 +47,7 @@ Component({
       }
       clearTimeout(this.search);
       this.search = setTimeout(function(){  
-          getReq({
+        getReq(app,{
             act: 'search',
             op: 'suggest_words',
             keyword: val

+ 3 - 3
pages/confirmOrder/confirmOrder.js

@@ -69,7 +69,7 @@ Page({
       fromSource: app.globalData.fromSource
     })
 
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       wx.hideLoading()
       if (res.code == 200) {
         let datas = res.datas
@@ -161,7 +161,7 @@ Page({
     params = Object.assign({}, options, params);
 
 
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       wx.hideLoading()
       if (res.code == 200) {
         let param = res.datas.param.data
@@ -237,7 +237,7 @@ Page({
         area_id,
         freight_hash
       }
-      getReq(params, function(res) {
+      getReq(app,params, function(res) {
         if (res.code == 200) {
            let { freight } = res.datas
            let prev_freight = self.data.freight

+ 2 - 2
pages/confirmVOrder/confirmVOrder.js

@@ -69,7 +69,7 @@ Page({
     // this.setData({
     //   fromSource: app.globalData.fromSource
     // }),
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       wx.hideLoading()
       if (res.code == 200) {
         let datas = res.datas
@@ -114,7 +114,7 @@ Page({
       invoice_id: 0
     }
     params = Object.assign({}, params);
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       wx.hideLoading()
       if (res.code == 200) {
         let param = res.datas.param.data

+ 4 - 4
pages/details/details.js

@@ -54,7 +54,7 @@ Page({
     })
     this.getDatas(options.goods_id)
     var that = this;
-    getReq({
+    getReq(app,{
       act: 'goods_common',
       op: 'detail',
       goods_id: options.goods_id
@@ -71,7 +71,7 @@ Page({
       title: '加载中',
     })
     var self = this
-    getReq({
+    getReq(app,{
       act: 'goods_common',
       op: 'index',
       goods_id,
@@ -234,7 +234,7 @@ Page({
       wx.showLoading({
         title: '加载中',
       })
-      getReq({
+      getReq(app,{
         act: 'cart',
         op: 'addex',
         quantity: this.data.goodsNumber,
@@ -404,7 +404,7 @@ Page({
       return;
     }
     let bl_id =  e.currentTarget.dataset.blid
-    getReq({
+    getReq(app,{
       act: 'cart',
       op: 'addex',
       quantity: 1,

+ 2 - 2
pages/discover/discover.js

@@ -24,7 +24,7 @@ Page({
       title: '加载中',
     })
     var self = this
-    getReq({
+    getReq(app,{
       act: 'brand',
       op: 'home'
     }, function (res) {
@@ -54,7 +54,7 @@ Page({
   },
   getFunctions() {
     var self = this
-    getReq({
+    getReq(app,{
       act: 'category',
       op: 'index'
     }, function (res) {

+ 1 - 1
pages/fcode/fcode.js

@@ -26,7 +26,7 @@ Page({
     this.setData({
       fromSource: app.globalData.fromSource
     })
-    getReq({
+    getReq(app,{
       act: 'member_fcode',
       op: 'list',
       from: fromSource

+ 2 - 2
pages/handOutBonus/handOutBonus.js

@@ -53,7 +53,7 @@ Page({
       act: 'member_bonus',
       op: 'predepositex'
     }
-    getReq(params, res => {
+    getReq(app,params, res => {
       if (res.code == 200) {
         let { datas } = res  
         let tempBless = datas['send_bless']
@@ -221,7 +221,7 @@ Page({
       }
       params = Object.assign({}, params, data)
     }
-    getReq(params, res => {
+    getReq(app,params, res => {
       if (res.code == 200) {
         let { title, path } = res.datas
         this.setData({

+ 5 - 3
pages/index/index.js

@@ -1,9 +1,10 @@
-let app = getApp();
+
 import recordSource from '../../utils/recordSource';
 import bonusUp from '../../utils/bonusUp';
 const getReq = require('../../config.js').getReq;
 const getTypeSn = require('../../utils/util.js').getTypeSn;
 
+let app = getApp();
 Page({
   data: {
     tabs: [],
@@ -58,7 +59,7 @@ Page({
     });
     let self = this;
     console.log('fromSource =' + fromSource)
-    getReq({
+    getReq(app,{
       act: 'special',
       op: 'index',
       special_id: special_id,
@@ -67,6 +68,7 @@ Page({
       from: fromSource
     }, function (res) {
       if (res.code == 200) {
+        console.log(res)
         let prop_special = res.datas.special_list;
         let sent_down_special = prop_special.splice(0, 8);
         self.setData({
@@ -85,7 +87,7 @@ Page({
   },
   req_tabs() {
     let self = this
-    getReq({
+    getReq(app,{
       act: 'index',
       op: 'tabs'
     }, function (res) {

+ 1 - 1
pages/login/login.js

@@ -80,7 +80,7 @@ Page({
           act: "login",
           op: "wxauthen"
       }
-      getReq(params, function (res) {
+      getReq(app,params, function (res) {
         if (res.code == 200) {
           app.globalData.backLogin = true;
           wx.navigateBack();

+ 1 - 1
pages/myhome/myhome.js

@@ -47,7 +47,7 @@ Page({
       userInfo: app.globalData.userInfo
     })
 
-    getReq({
+    getReq(app,{
         act: 'member_info',
         op: 'index',
         page_type: 'oil'

+ 2 - 2
pages/orderPaySn/orderPaySn.js

@@ -36,7 +36,7 @@ Page({
     wx.showLoading({
       title: '加载中',
     })
-    getReq({
+    getReq(app,{
       act: 'member_order',
       op: 'pay_info',
       pay_sn: pay_sn,
@@ -97,7 +97,7 @@ Page({
       pay_sn: this.data['order_info']['pay_sn'],
       payment: 'minipay'
     }
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       if (res.code == 200) {
         let param = res.datas.param.data;
         wx.requestPayment({

+ 2 - 2
pages/order_tabs/orderTabs.js

@@ -111,7 +111,7 @@ Page({
       });
     }
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'member_vorder',
       op: 'list',
       page: 15,
@@ -249,7 +249,7 @@ Page({
   },
   change_order_state(action, order_id, index) {
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'member_vorder',
       op: 'change_state',
       act_type: action,

+ 2 - 2
pages/order_tabsec/orderTabs.js

@@ -111,7 +111,7 @@ Page({
       });
     }
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'member_order',
       op: 'list',
       page: 15,
@@ -249,7 +249,7 @@ Page({
   },
   change_order_state(action, order_id, index) {
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'member_order',
       op: 'change_state',
       act_type: action,

+ 4 - 4
pages/person/person.js

@@ -84,7 +84,7 @@ Page({
     const nickName = userInfo.nickName || '';
     const avatarUrl = userInfo.avatarUrl || '../../image/mine_logo_icon.png';
     let self = this
-    getReq({
+    getReq(app,{
       act: 'cart',
       op: 'rate_money'
     }, function (res) {
@@ -97,7 +97,7 @@ Page({
       }
     })
 
-    getReq({
+    getReq(app,{
       act: 'member_info',
       op: 'get'
     }, function (res) {
@@ -108,7 +108,7 @@ Page({
         })
       }
     })
-    getReq({
+    getReq(app,{
       act: 'member_order',
       op: 'orderCountState',
       from: fromSource
@@ -162,7 +162,7 @@ Page({
   },
   getBonusTotal() {
     let self = this
-    getReq({
+    getReq(app,{
       act: 'member_bonus',
       op: 'predepositex'
     }, function (res) {

+ 2 - 2
pages/phoneCharges/phoneCharges.js

@@ -53,7 +53,7 @@ Page({
       fromSource: app.globalData.fromSource,
     });
     var self = this;
-    getReq({
+    getReq(app,{
       act: 'index',
       op: 'card_goods',
       page_type: 'oil',
@@ -94,7 +94,7 @@ Page({
       app.showToast('卡号不能为空')
       return
     }
-    buyVGoods(goods_id,1,{ card_no }, (res) => {
+    buyVGoods(app,goods_id,1,{ card_no }, (res) => {
       // console.log('res',res)  成功回调
     }, (err) => {
       // 失败回调

+ 2 - 2
pages/postage/postage.js

@@ -75,7 +75,7 @@ Page({
       // card_no: this.data.tabsData[0].card_no
     });
 
-    getReq({
+    getReq(app,{
       act: 'index',
       op: 'card_goods',
       page_type: 'oil',
@@ -107,7 +107,7 @@ Page({
       app.showToast('卡号不能为空')
       return
     }
-    buyVGoods(goods_id,1,{ card_no,card_type }, (res) => {
+    buyVGoods(app,goods_id,1,{ card_no,card_type }, (res) => {
       console.table({card_no,card_type})
       // console.log('res',res)  成功回调
     }, (err) => {

+ 1 - 1
pages/postageDetail/postageDetail.js

@@ -54,7 +54,7 @@ Page({
     if(this.data.isEdit){
       params = { topcard_id, ...params, op: 'card_edit' }
     }
-    getReq(params ,res => {
+    getReq(app,params ,res => {
       wx.hideLoading()
       if (res.code == 200) {
         wx.navigateBack()

+ 2 - 2
pages/postageManage/postageManage.js

@@ -41,7 +41,7 @@ Page({
       card_type: this.data.card_type  //petrochina -> 中石油; sinopec -> 中石化; phone-> 手机卡; 不填的时候,返回所有
     }
 
-    getReq(params, res => {
+    getReq(app,params, res => {
       wx.hideLoading()
       if (res.code == 200) {
         let list = res.datas.card_list
@@ -81,7 +81,7 @@ Page({
       cancelText: "取消",
       success: res => {
         if (res.confirm) {
-          getReq({
+          getReq(app,{
             act: 'member_card',
             op: 'card_del',
             topcard_id

+ 1 - 1
pages/search/search.js

@@ -29,7 +29,7 @@ Page({
     this.setData({
       fromSource: app.globalData.fromSource
     })
-    getReq({
+    getReq(app,{
       act: 'search',
       op: 'history',
       curpage: 1,

+ 2 - 2
pages/shareBonus/shareBonus.js

@@ -81,7 +81,7 @@ Page({
   },
   getDatas(params) {
     let self = this
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       if (res.code == 200) {
         let { type_info, bonus_state } = res.datas
         if (bonus_state == 'unstart') {
@@ -333,7 +333,7 @@ Page({
       comment: result_msg,
       bonus_sn: this.data.mine_bonus['bonus_sn']
     }
-    getReq(params, function (res) {
+    getReq(app,params, function (res) {
       if (res.code == 200) {
         self.setData({
           message_flag: false,

+ 5 - 5
pages/shopCart/shopCart.js

@@ -60,7 +60,7 @@ Page({
   },
   getFavorite() {
     let self = this
-    getReq({
+    getReq(app,{
       act: 'member_bonus',
       op: 'match_goodsex',
       curpage: 1
@@ -105,7 +105,7 @@ Page({
     else {
       app.setFromSource(this.data.fromSource)
     }
-    getReq({
+    getReq(app,{
       act: 'cart',
       op: 'list',
       minest_cartid: self.data.curpage,
@@ -206,7 +206,7 @@ Page({
   },
   req_goods_num(cart_id, quantity, callback) {
     let self = this;
-    getReq({
+    getReq(app,{
       act: 'cart',
       op: 'edit',
       cart_id,
@@ -309,7 +309,7 @@ Page({
       })
     }
     let carts = cart_item.join(",");
-    getReq({
+    getReq(app,{
       act: 'member_buy',
       op: 'calc_cash',
       ifcart: 1,
@@ -331,7 +331,7 @@ Page({
     let hasmore = this.data.hasmore;
     if (hasmore) {
       let req_curpage = this.data.curpage;
-      getReq({
+      getReq(app,{
         act: 'cart',
         op: 'list',
         minest_cartid: req_curpage

+ 1 - 1
pages/special/special.js

@@ -31,7 +31,7 @@ Page({
       fromSource: app.globalData.fromSource
     });
     var self = this;
-    getReq({
+    getReq(app,{
       act: 'special',
       op: 'index',
       special_id,

+ 2 - 2
utils/WxAuthor.js

@@ -20,7 +20,7 @@ export default class WxAuthor {
       op: "ministart",
       code
     }
-    getReq(params, res => {
+    getReq(this.target,params, res => {
       if (res.code == 200) {
         let { openid, unionid, HPHPSESSID } = res.datas
         wx.setStorageSync('session_id', HPHPSESSID);
@@ -74,7 +74,7 @@ export default class WxAuthor {
       act: "login",
       op: "wxauthen"
     }
-    getReq(params, res => {
+    getReq(this.target,params, res => {
       if (res.code == 200) {
         let url = this.getUrl()
         wx.reLaunch({

+ 1 - 1
utils/bonusUp.js

@@ -6,7 +6,7 @@ function bonusUp(callback) {
     act: 'member_bonus',
     op: 'topup'
   }
-  getReq(params, res => {
+  getReq(null,params, res => {
     if (res.code == 200) {
       let { datas } = res
       let { count, total_amount } = datas