Sfoglia il codice sorgente

1.修复微信登录过期bug
2.修复转发详情页,返回后下拉刷新首页总是自动跳转详情页bug
3.优化立即购买按钮交互效果,防止重复点击

wangxin 6 anni fa
parent
commit
5d333ed88f
3 ha cambiato i file con 36 aggiunte e 20 eliminazioni
  1. 5 0
      template/carts/index.js
  2. 27 20
      template/home/index.js
  3. 4 0
      template/view/index.js

+ 5 - 0
template/carts/index.js

@@ -124,7 +124,9 @@ Page({
     var addrObj = that.data.addrObj;
     if (!addrObj){
       app.toast('请选择收货地址');
+      return ;
     }
+    app.showLoading();
     app.request('product.api.buy',{
       product_id: that.product_ids,
       num: that.product_num,
@@ -160,6 +162,9 @@ Page({
       },
       fail: function(res){
         app.toast('支付失败!');
+      },
+      complete: function (res) {
+        app.hideLoading();
       }
     })
   },

+ 27 - 20
template/home/index.js

@@ -2,10 +2,14 @@ const app = getApp();
 
 Page({
   cashdialog: null,
+  isOpenView: false,
   pid: '',
   pg: 1,
   data: {
     isShowNull: false
+  },
+  onReady: function(){
+
   },
   onLoad: function (options) {
     //产品详情路径附带参数,用于来源分享的参数scene=encodeURIComponent(uid, product_id)
@@ -15,35 +19,35 @@ Page({
       let uid = arr[0];
       this.pid = arr[1];
       app.saveInviteUid(uid);
-    }
-    
-    if (app.isLogin()){
-      this.getHomeData(this);
+      //跳转详情页
+      this.isOpenView = true;
     }else{
-      var that = this;
-      wx.login({
-        success: function (res) {
-          if (res.code) {
-            app.request("passport.applet.bind", {
-              code: res.code
-            }, {
-                success: function (data, res) {
-                  that.getHomeData(that);
+      this.isOpenView = false;
+    }
+
+    var that = this;
+    wx.login({
+      success: function (res) {
+        if (res.code) {
+          app.request("passport.applet.bind", {
+            code: res.code
+          }, {
+              success: function (data, res) {
+                that.getHomeData(that);
+                if (that.isOpenView){
+                  app.location('view/index?id=' + that.pid);
                 }
-              })
-          }
+              }
+            })
         }
-      })
-    }
+      }
+    })
   },
 
   /**
    * 获取首页数据
    */
   getHomeData: function(that){
-    if(that.pid != ''){
-      app.location('view/index?id=' + that.pid);
-    }
     if (that.pg == 1) {
       app.showLoading();
     }
@@ -65,6 +69,9 @@ Page({
             app.set(that, 'isShowNull', true);
           }
           app.hideLoading();
+        },
+        complete: function(res){
+          app.hideLoading();
         }
       });
   },

+ 4 - 0
template/view/index.js

@@ -32,11 +32,15 @@ Page({
    */
   doBuy: function(e){
     var that = this;
+    app.showLoading();
     app.isAuth('scope.userInfo', function (res) {
       if (res) {
         app.request('product.api.addCarts', { product_id: that.pid, num: 1 }, {
           success: function (data, res) {
             app.location('carts/index?id=' + that.pid);
+          },
+          complete: function (res) {
+            app.hideLoading();
           }
         })
       } else {