Bladeren bron

debug jsonp_datas_function

huanggang 7 jaren geleden
bovenliggende
commit
b12f64bbeb

+ 1 - 0
README 2.md

@@ -0,0 +1 @@
+#panda_h5

File diff suppressed because it is too large
+ 1 - 1
dist/mshop/js/app.c8574dfdcdbfaa15a644.js


+ 20 - 13
src/App.vue

@@ -13,21 +13,28 @@
         created(){
             let _self = this;
             this.$store.commit('updateLoadingStatus', {isLoading: true});
-            this.$http.jsonp(Api.member_info_get()).then(function (res)
+            this.$http.jsonp(Api.memberInfo(),{_timeout:5000}).then(function (res)
             {
-                if (res.body.code !== 10014)
-                {
-                    _self.$store.commit('updateLogIn');
-                    _self.$store.commit('updateUser', {
-                        'name': res.body.datas.member_nickname,
-                        'image': res.body.datas.member_avatar
-                    });
-                    _self.$http.jsonp(Api.user_bonus()).then(function (res) {
-                        _self.$store.commit('updateUser_bonus', {'array': res.body.datas.bonus_rate});
-                    });
-                    this.$store.commit('updateLoadingStatus', {isLoading: false});
+                if (res.body.code != 200) {
+                    return;
                 }
-            });
+                _self.$store.commit('updateLogIn');
+                _self.$store.commit('updateUser', {
+                    'name': res.body.datas.member_nickname,
+                    'image': res.body.datas.member_avatar
+                });
+                _self.$http.jsonp(Api.userBonus()).then(function (res) {
+                    _self.$store.commit('updateUser_bonus', {'array': res.body.datas.bonus_rate});
+                });
+                this.$store.commit('updateLoadingStatus', {isLoading: false});
+
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
+            })
+        });
         },
         name: 'app',
         components: {

+ 29 - 8
src/components/address/add_address.vue

@@ -24,10 +24,25 @@
         created(){
             this.$store.commit('updateLoadingStatus', {isLoading: true});
             let _self = this;
-            this.$http.jsonp(Api.get_address()).then(function (res) {
+            this.$http.jsonp(Api.get_address(),{_timeout:5000}).then(function (res) {
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 _self.datas = res.body.datas;
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
-            });
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
+            })
+        });
         },
         data () {
             return {
@@ -101,14 +116,14 @@
                     return;
                 }
                 let _self = this;
-                let area = this.$http.jsonp(Api.add_address(this.user_name, this.area[this.area.length - 1], this.address, this.mobile)).then(function (res) {
+                let area = this.$http.jsonp(Api.add_address(this.user_name, this.area[this.area.length - 1], this.address, this.mobile),{_timeout:5000}).then(function (res) {
                     this.$store.commit('updateLoadingStatus', {isLoading: true});
-                    if(res.status !== 200 || res.body.code !== 200) {
-                        _self.$vux.toast.show({
+                    if (res.body.code != 200) {
+                        this.$vux.toast.show({
                             type: 'text',
-                            text: "网络错误",
+                            text: res.body.message,
                             position: 'middle',
-                            width: '400px'
+                            width: '600px'
                         });
                     }
                     else{
@@ -123,7 +138,13 @@
                         this.$store.commit('updateLoadingStatus', {isLoading: false});
                         this.$router.go(-1);
                     });
-                });
+                },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
+                    })
+            });
             }
         }
     }

+ 17 - 2
src/components/address/addressList.vue

@@ -5,10 +5,25 @@
     export default {
         created(){
             let _self = this;
-            this.$http.jsonp(Api.addressList()).then(function (res) {
+            this.$http.jsonp(Api.addressList(),{_timeout:5000}).then(function (res) {
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 _self.datas = res.body.datas.address_list;
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
-            });
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
+            })
+        });
             if(!this.$store.state.isLogIn) {
                 this.$vux.toast.show({
                     type:'text',

+ 11 - 2
src/components/blocks/block_list.vue

@@ -48,8 +48,17 @@
                 this.$store.commit('updateLoadingStatus', {isLoading: true});
                 let _self = this;
                 this.isload = true;
-                this.$http.jsonp(this.datasLink+'&curpage='+this.curpage).then(function (res) {
+                this.$http.jsonp(this.datasLink+'&curpage='+this.curpage,{_timeout:5000}).then(function (res) {
                     this.isload = false;
+                    if (res.body.code != 200) {
+                        this.$vux.toast.show({
+                            type: 'text',
+                            text: res.body.message,
+                            position: 'middle',
+                            width: '600px'
+                        });
+                        return;
+                    }
                     window.removeEventListener('scroll',_self.loadMoreCallback);
                     let body = JSON.parse(res.bodyText);
                     _self.hasmore = body.datas['mobile_page'].hasmore;
@@ -65,7 +74,7 @@
                     _self.proxy.setTag("BRAND_ID", this.brand_id);
                     _self.proxy.setTag("WORDS", this.keyword);
                     this.$store.commit('updateLoadingStatus', {isLoading: false});
-                }, res => {
+                }, (err) => {
                     this.$vux.toast.show({
                         type: 'text',
                         text: "网络错误",

+ 15 - 3
src/components/confirm_order/confirm_order.vue

@@ -118,7 +118,7 @@
             let goods_num = this.$route.query['num'];
             let iscart = this.$route.query["iscart"];
             let cart_id = this.$route.query["cart_id"] ? this.$route.query["cart_id"] : '';
-            this.$http.jsonp(Api.step_first(iscart, cart_id, goods_id, goods_num)).then(function (res) {
+            this.$http.jsonp(Api.step_first(iscart, cart_id, goods_id, goods_num),{_timeout:5000}).then(function (res) {
                 if (res.body.datas == null && res.body.code !== '200') {
                     this.$vux.toast.show({
                         type: 'warn',
@@ -133,7 +133,13 @@
                     this.proxy.addData(res.body.datas);
                     this.$store.commit('updateLoadingStatus', {isLoading: false});
                 }
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
             })
+        })
         },
         beforeDestroy(){
             this.$store.commit('update_address', {
@@ -191,7 +197,7 @@
                 let offpay_hash_batch = this.datas['payinfo'].offpay_hash_batch;
                 let address_id = this.store_address ? this.store_address.aid : this.datas['address'].address_id;
                 console.log(address_id);
-                this.$http.jsonp(Api.step_second(cart_id, goods_id, goods_num, address_id, 0, vat_hash, offpay_hash, offpay_hash_batch)).then(function (res) {
+                this.$http.jsonp(Api.step_second(cart_id, goods_id, goods_num, address_id, 0, vat_hash, offpay_hash, offpay_hash_batch),{_timeout:5000}).then(function (res) {
                     if (res.status == 200 && res.body.code == 200) {
                         let param = res.body.datas.param.data;
                         WeixinJSBridge.invoke(
@@ -222,7 +228,13 @@
                             position: 'middle'
                         });
                     }
-                });
+                },(err) => {
+                    this.$vux.toast.show({
+                    type: 'text',
+                    text: "网络错误",
+                    position: 'middle'
+                })
+            });
             }
         },
         components: {

+ 24 - 3
src/components/goods/goods_detail.vue

@@ -118,7 +118,16 @@
         created(){
             this.$store.commit('updateLoadingStatus', {isLoading: true});
             let goods_id = this.$route.query["goods_id"];
-            this.$http.jsonp(Api.goodsDetail(goods_id)).then(function(res){
+            this.$http.jsonp(Api.goodsDetail(goods_id),{_timeout:5000}).then(function(res){
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 this.datas = res.body['datas'];
                 this.summary = res.body['datas'].summary;
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
@@ -130,7 +139,13 @@
                         link:window.location.href,
                         imgUrl:this.getOneSummary['goods_image_url']
                     });
-            });
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
+            })
+        });
         },
         mounted(){
                 document.body.scrollTop = 0;
@@ -196,7 +211,7 @@
             check_submit(quantity,goods_id){
                 this.$store.commit('updateLoadingStatus', {isLoading: true});
                 if(this.isCart) {
-                    this.$http.jsonp(Api.shopping_cart_add(quantity,goods_id)).then(function(res){
+                    this.$http.jsonp(Api.shoppingCartAdd(quantity,goods_id),{_timeout:5000}).then(function(res){
                         this.$store.commit('updateLoadingStatus', {isLoading: false});
                         if(res.body.code == 200) {
                             this.openBuyPopup(false);
@@ -214,7 +229,13 @@
                                 position:'middle'
                             })
                         }
+                    },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
                     })
+                })
                 }
                 else {
                     this.$router.push({path:'/confirm_order',query:{goods_id:goods_id,iscart:0,num:this.goodsNumber}})

+ 26 - 8
src/components/login/login.vue

@@ -53,21 +53,27 @@
                 }
                 else {
                     this.$store.commit('updateLoadingStatus', {isLoading: true});
-                    this.$http.jsonp(Api.logInWeb(mobile,code)).then(function(res)
+                    this.$http.jsonp(Api.login(mobile,code),{_timeout:5000}).then(function(res)
                     {
                        if(res.body.code == 200)
                        {
-                           this.$http.jsonp(Api.member_info_get()).then(function(res){
+                           this.$http.jsonp(Api.memberInfo(),{_timeout:5000}).then(function(res){
                                if(res.body.code !== 10014) {
                                    this.$store.commit('updateLogIn');
                                    this.$store.commit('updateUser',{'name':res.body.datas.member_nickname,'image':res.body.datas.member_avatar});
-                                   this.$http.jsonp(Api.user_bonus()).then(function(res){
+                                   this.$http.jsonp(Api.userBonus()).then(function(res){
                                        this.$store.commit('updateUser_bonus',{'array':res.body.datas.bonus_rate});
                                    });
                                    this.$store.commit('updateLoadingStatus', {isLoading: false});
                                    this.$router.push('/');
                                }
-                           });
+                           },(err) => {
+                               this.$vux.toast.show({
+                               type: 'text',
+                               text: "网络错误",
+                               position: 'middle'
+                           })
+                       });
                        }
                        else {
                            this.$store.commit('updateLoadingStatus', {isLoading: false});
@@ -77,7 +83,13 @@
                                position:'middle'
                            })
                        }
-                    });
+                    },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
+                    })
+                });
                 }
             },
             getCode(){
@@ -100,15 +112,21 @@
                             _self.isCount = false;
                         }
                     },1000);
-                    this.$http.jsonp(Api.getCode(mobile)).then(function(res){
-                        if(!res.body.code == 200) {
+                    this.$http.jsonp(Api.getCode(mobile),{_timeout:5000}).then(function(res){
+                        if(res.body.code != 200) {
                             this.$vux.toast.show({
                                 type:'text',
                                 text: res.body.message,
                                 position:'middle'
                             })
                         }
-                    });
+                    },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
+                    })
+                });
                 }
             }
         }

+ 16 - 1
src/components/main/discovery/functionList.vue

@@ -37,10 +37,25 @@
         created(){
             let _self = this;
             this.$store.commit('updateLoadingStatus', {isLoading: true});
-            this.$http.jsonp(Api.functionList()).then(function(res){
+            this.$http.jsonp(Api.functionList(),{_timeout:5000}).then(function(res){
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 _self.datas = res.body.datas["items"];
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
             })
+        })
         },
         mounted(){
             this.$store.commit('updateLoadingStatus', {isLoading: false});

+ 16 - 1
src/components/main/home/homeTabs.vue

@@ -9,9 +9,24 @@
             let arr = this.$route.path.split("\/");
             this.current_id = arr [arr.length - 1];
 
-            this.$http.jsonp(Api.homeTabs(),).then(function (res) {
+            this.$http.jsonp(Api.homeTabs(),{_timeout:5000}).then(function (res) {
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 _self.tabs = res.body.datas.tabs;
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
             })
+        })
         },
         data(){
             return {

+ 30 - 3
src/components/main/shop-car/shopping_cart.vue

@@ -86,11 +86,26 @@
     export default {
         created(){
             this.$store.commit('updateLoadingStatus', {isLoading: true});
-            this.$http.jsonp(Api.shoppingCart()).then(function (res) {
+            this.$http.jsonp(Api.shoppingCart(),{_timeout:5000}).then(function (res) {
+                if (res.body.code != 200) {
+                    this.$vux.toast.show({
+                        type: 'text',
+                        text: res.body.message,
+                        position: 'middle',
+                        width: '600px'
+                    });
+                    return;
+                }
                 this.proxy.addData(res.body.datas);
                 this.cart_l_items = this.cart_items();
                 this.$store.commit('updateLoadingStatus', {isLoading: false});
+            },(err) => {
+                this.$vux.toast.show({
+                type: 'text',
+                text: "网络错误",
+                position: 'middle'
             })
+        })
         },
         data(){
             return {
@@ -144,7 +159,7 @@
                     quantity = 1;
                 }
                 let _self = this;
-                this.$http.jsonp(Api.shopping_cart_edit(quantity, cart_id)).then(function (res) {
+                this.$http.jsonp(Api.shoppingCartEdit(quantity, cart_id),{_timeout:5000}).then(function (res) {
 
                     if (res.body.code == 200) {
                         _self.proxy.getCart(cart.cart_id).goods_num = res.body.datas.goods_num;
@@ -157,11 +172,17 @@
                             position: 'middle'
                         })
                     }
+                },(err) => {
+                    this.$vux.toast.show({
+                    type: 'text',
+                    text: "网络错误",
+                    position: 'middle'
                 })
+            })
             },
             del_cart(cart){
                 let _self = this;
-                this.$http.jsonp(Api.shopping_cart_edit(0, cart.cart_id)).then(function (res) {
+                this.$http.jsonp(Api.shoppingCartEdit(0, cart.cart_id),{_timeout:5000}).then(function (res) {
                     if (res.body.message == '成功') {
                         let cart_item = cart;
                         let cart_id = cart_item.cart_id;
@@ -180,7 +201,13 @@
                             position: 'middle'
                         })
                     }
+                },(err) => {
+                    this.$vux.toast.show({
+                    type: 'text',
+                    text: "网络错误",
+                    position: 'middle'
                 })
+            })
             },
             cart_select(cart){
                 if (cart.active == 'circle') {

+ 48 - 3
src/components/order/list/OrderList.vue

@@ -33,11 +33,26 @@
             let _self = this;
             if (_self.page.isUpdate) {
                 this.$store.commit('updateLoadingStatus', {isLoading: true});
-                this.$http.jsonp(Api.orderList(), {params: {state_type: getParamState(_self.page.state)}}).then(function (res) {
+                this.$http.jsonp(Api.orderList(), {params: {state_type: getParamState(_self.page.state)}},{_timeout:5000}).then(function (res) {
+                    if (res.body.code != 200) {
+                        this.$vux.toast.show({
+                            type: 'text',
+                            text: res.body.message,
+                            position: 'middle',
+                            width: '600px'
+                        });
+                        return;
+                    }
                     _self.datas = res.body.datas;
                     _self.page.isUpdate = false;
                     this.$store.commit('updateLoadingStatus', {isLoading: false});
+                },(err) => {
+                    this.$vux.toast.show({
+                    type: 'text',
+                    text: "网络错误",
+                    position: 'middle'
                 })
+            })
             }
             let ui;
             if (!_self.datas || (this.datas.hasOwnProperty("orders") && this.datas.orders.length === 0)) {
@@ -86,28 +101,58 @@
                 //退款
                 let refundOrder = (order_sn) => {
                     this.$store.commit('updateLoadingStatus', {isLoading: true});
-                    this.$http.jsonp(Api.refundOrder(), {
+                    this.$http.jsonp(Api.refundOrder(),{_timeout:5000},{
                         params: {
                             order_sn: order_sn,
                         }
                     }).then(function (res) {
+                        if (res.body.code != 200) {
+                            this.$vux.toast.show({
+                                type: 'text',
+                                text: res.body.message,
+                                position: 'middle',
+                                width: '600px'
+                            });
+                            return;
+                        }
                         _self.$store.commit("updateOrderState", {action: res.body.datas, action_id: new Date()});
                         this.$store.commit('updateLoadingStatus', {isLoading: false});
+                    },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
                     })
+                })
                 }
 
                 //通知服务器改变状态
                 let changeState = (action, order_id) => {
                     this.$store.commit('updateLoadingStatus', {isLoading: true});
-                    this.$http.jsonp(Api.changeOrderState(), {
+                    this.$http.jsonp(Api.changeOrderState(),{_timeout:5000},{
                         params: {
                             act_type: action,
                             order_id: order_id
                         }
                     }).then(function (res) {
+                        if (res.body.code != 200) {
+                            this.$vux.toast.show({
+                                type: 'text',
+                                text: res.body.message,
+                                position: 'middle',
+                                width: '600px'
+                            });
+                            return;
+                        }
                         _self.$store.commit("updateOrderState", {action: res.body.datas, action_id: new Date()});
                         this.$store.commit('updateLoadingStatus', {isLoading: false});
+                    },(err) => {
+                        this.$vux.toast.show({
+                        type: 'text',
+                        text: "网络错误",
+                        position: 'middle'
                     })
+                })
                 }
                 //处理服务器返回的状态
                 let global_state = _self.$store.state.changeState;

+ 17 - 1
src/components/other/search.vue

@@ -12,7 +12,16 @@
                 if(!value) return;
                 this.value = value;
                 this.$store.commit('updateLoadingStatus', {isLoading: true});
-                this.$http.jsonp(api.search()+'&keyword='+value).then(function(res){
+                this.$http.jsonp(api.search()+'&keyword='+value,{_timeout:5000}).then(function(res){
+                    if (res.body.code != 200) {
+                        this.$vux.toast.show({
+                            type: 'text',
+                            text: res.body.message,
+                            position: 'middle',
+                            width: '600px'
+                        });
+                        return;
+                    }
                     let i=0;
                     if(res.body.datas.words !== null) {
                         res.body.datas.words.map(function(word){
@@ -25,7 +34,14 @@
                         this.results = ret;
                     }
                     this.$store.commit('updateLoadingStatus', {isLoading: false});
+                },(err) => {
+                    this.$vux.toast.show({
+                    type: 'text',
+                    text: "网络错误",
+                    position: 'middle'
                 })
+                }
+            )
             },
             go(item) {
                 let action = Actions.getFilterBlockListPath(item.title, "", "", "", item.title);

+ 3 - 0
src/lib/Exception.js

@@ -0,0 +1,3 @@
+// class Exception{
+//     static
+// }

+ 6 - 6
src/lib/api.js

@@ -1,7 +1,7 @@
 class Api {
 
     static host() {
-        return "http://a.lrlz.com";
+        return "http://p.lrlz.com";
     }
 
     static special(special_id) {
@@ -32,7 +32,7 @@ class Api {
         return this.host() + `/mobile/index.php?act=goods&op=detail&goods_id=${goods_id}&client_type=ajax`
     }
 
-    static member_info_get() {
+    static memberInfo() {
         return this.host() + '/mobile/index.php?act=member_info&op=get&client_type=ajax'
     }
 
@@ -56,15 +56,15 @@ class Api {
         return this.host() + '/mobile/index.php?act=member_order&op=search_deliver&order_id=' + order_id
     }
 
-    static shopping_cart_edit(quantity, cart_id) {
+    static shoppingCartEdit(quantity, cart_id) {
         return this.host() + `/mobile/index.php?quantity=${quantity}&act=cart&op=edit&cart_id=${cart_id}&client_type=ajax`
     }
 
-    static shopping_cart_add(quantity, goods_id) {
+    static shoppingCartAdd(quantity, goods_id) {
         return this.host() + `/mobile/index.php?quantity=${quantity}&act=cart&goods_id=${goods_id}&op=addex&client_type=ajax`
     }
 
-    static user_bonus() {
+    static userBonus() {
         return this.host() + '/mobile/index.php?act=cart&op=rate_money&client_type=ajax'
     }
 
@@ -76,7 +76,7 @@ class Api {
         return this.host() + "/mobile/index.php?act=index&op=tabs&client_type=ajax"
     }
 
-    static logInWeb(mobile, code) {
+    static login(mobile, code) {
         return this.host() + `/mobile/index.php?act=login&op=bind_mobile&client_type=ajax&mobile=${mobile}&code=${code}`;
     }
 

+ 19 - 0
src/main.js

@@ -82,6 +82,25 @@ const store = new Vuex.Store({
         }
     }
 });
+//超时处理
+Vue.http.interceptors.push((request, next) => {
+    let timeout;
+// 這裡改用 _timeout
+if (request._timeout) {
+    timeout = setTimeout(() => {
+            //自定义响应体 status:408,statustext:"请求超时",并返回给下下边的next
+            next(request.respondWith(request.body, {
+            status: 408,
+            statusText: '请求超时'
+        }));
+
+}, request._timeout);
+}
+next((response) => {
+return response;
+})
+});
+
 
 const scrollBehavior = (to, from, savedPosition) => {
     if (savedPosition) {