huanggang 7 年 前
コミット
c1f8ead574

+ 4 - 2
app.js

@@ -1,6 +1,7 @@
 //app.js
 //app.js
 App({
 App({
   onLaunch: function () {
   onLaunch: function () {
+    console.log();
     // 登录
     // 登录
     wx.login({
     wx.login({
       success: res => {
       success: res => {
@@ -111,8 +112,9 @@ App({
       openid:'',
       openid:'',
       unionid:''
       unionid:''
     },
     },
-    userInfo: {},
-    defaultAddress: null
+    userInfo: null,
+    defaultAddress: null,
+    backLogin:false
   },
   },
   checkDefaultAddress(address) {
   checkDefaultAddress(address) {
     this.globalData.defaultAddress = address
     this.globalData.defaultAddress = address

+ 2 - 1
app.json

@@ -15,7 +15,8 @@
     "pages/address/address",
     "pages/address/address",
     "pages/addAddress/addAddress",
     "pages/addAddress/addAddress",
     "pages/orderPaySn/orderPaySn",
     "pages/orderPaySn/orderPaySn",
-    "pages/fcode/fcode"
+    "pages/fcode/fcode",
+    "pages/login/login"
   ],
   ],
   "window": {
   "window": {
     "backgroundTextStyle": "dark",
     "backgroundTextStyle": "dark",

BIN
image/empty_cart.png


+ 1 - 1
pages/components/blocks/goods_item/goods_item.wxml

@@ -19,7 +19,7 @@
       </view>
       </view>
       <view class='deduction'>
       <view class='deduction'>
         <view class="original_price">天猫价{{goods.goods_price}}</view>
         <view class="original_price">天猫价{{goods.goods_price}}</view>
-        <text class="discount">红包抵{{(((goods.goods_price)*1000 - (goods.bonus_price)*1000))/1000}}元</text>
+        <text class="discount">红包抵{{(((goods.goods_price)*10000 - (goods.bonus_price)*10000))/10000}}元</text>
       </view>
       </view>
     </view>
     </view>
     <view class="goods_price" wx:if="{{goods.act_type == 1}}">
     <view class="goods_price" wx:if="{{goods.act_type == 1}}">

+ 12 - 2
pages/details/details.js

@@ -1,5 +1,6 @@
 // pages/details/details.js
 // pages/details/details.js
-const getReq = require('./../../config.js').getReq
+const getReq = require('./../../config.js').getReq;
+const app = getApp();
 
 
 Page({
 Page({
 
 
@@ -27,6 +28,7 @@ Page({
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
+    console.log(app);
     let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
     let webViewUrl = `https://passport.lrlz.com/mobile/index.php?act=goods_common&op=detail&goods_id=${options.goods_id}&client_type=ios`
     this.setData({
     this.setData({
       webViewUrl
       webViewUrl
@@ -128,6 +130,12 @@ Page({
     }
     }
   },
   },
   checkSubmit() {
   checkSubmit() {
+    if (!app.globalData.userInfo) {
+      wx.navigateTo({
+        url: '/pages/login/login'
+      });
+      return;
+    }
     let cartOrBuy = this.data.cartOrBuy
     let cartOrBuy = this.data.cartOrBuy
     this.setData({
     this.setData({
       animation_flag: false
       animation_flag: false
@@ -217,7 +225,9 @@ Page({
    * 生命周期函数--监听页面显示
    * 生命周期函数--监听页面显示
    */
    */
   onShow: function () {
   onShow: function () {
-
+    if (app.globalData.backLogin) {
+      this.getDatas(this.data.getOneSummary.goods_id);
+    } 
   },
   },
 
 
   /**
   /**

+ 17 - 4
pages/index/index.js

@@ -1,14 +1,27 @@
-
+let app = getApp();
 const getReq = require('./../../config.js').getReq;
 const getReq = require('./../../config.js').getReq;
 
 
 Page({
 Page({
   data: {
   data: {
     tabs: [],
     tabs: [],
-    special_datas:{},
-    summery:[]
+    special_datas: {},
+    summery: []
+  },
+
+  onShow: function() {
+    if (app.globalData.backLogin) {
+      app.globalData.backLogin = false;
+      wx.reLaunch({
+        url: "/pages/index/index"
+      });
+    }
   },
   },
 
 
   onLoad: function () {
   onLoad: function () {
+    this.req_tabs();
+  },
+
+  req_tabs(){
     let self = this
     let self = this
     getReq({
     getReq({
       act: 'index',
       act: 'index',
@@ -46,7 +59,7 @@ Page({
       if (res.code == 200) {
       if (res.code == 200) {
         self.setData({
         self.setData({
           special_datas: res.datas,
           special_datas: res.datas,
-          summery:res.datas.summary
+          summery: res.datas.summary
         });
         });
       }
       }
       setTimeout(function () {
       setTimeout(function () {

+ 93 - 0
pages/login/login.js

@@ -0,0 +1,93 @@
+// pages/login/login.js
+let app = getApp();
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  },
+  userInfoHandler(e){
+    console.log(app);
+    if (e.detail.errMsg == "getUserInfo:ok") {
+      app.globalData.userInfo = e.detail.userInfo;
+      app.globalData.userInfo.nickname = e.detail.userInfo.nickName;
+      let userInfo = Object.assign({}, app.globalData.userId, app.globalData.userInfo);
+      wx.request({
+        url: 'https://passport.lrlz.com/mobile/index.php?act=login&op=wxauthor&client_type=ios',
+        method: 'GET',
+        data: {
+          user_info: userInfo
+        },
+        success: function (res) {
+          wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+          if (res.statusCode == 200) {
+            app.globalData.backLogin = true;
+            wx.navigateBack(-2);
+          }
+          else {
+
+          }
+        }
+      })
+    }
+    
+  }
+})

+ 3 - 0
pages/login/login.json

@@ -0,0 +1,3 @@
+{
+  "navigationBarTitleText": "授权"
+}

+ 7 - 0
pages/login/login.wxml

@@ -0,0 +1,7 @@
+<view class='flex_center' style='margin-top:200rpx;'>
+  <image style='width:150rpx;' mode='widthFix' src="../../image/mine_logo_icon.png"></image>
+</view>
+<view style='font-size:30rpx;'>
+  <view class='flex_center' style='margin-top:20rpx;'>需要你的授权才可以使用哦!</view>
+</view>
+<button  style='margin-top:80rpx;width:60%;' type="primary" open-type="getUserInfo" bindgetuserinfo="userInfoHandler">立即授权</button>

+ 1 - 0
pages/login/login.wxss

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

+ 31 - 5
pages/person/person.js

@@ -12,14 +12,20 @@ Page({
       avatarUrl:''
       avatarUrl:''
     },
     },
     bonus_rate:[],
     bonus_rate:[],
-    bonus_list_show:false
+    bonus_list_show:false,
+    login_count:1
   },
   },
 
 
   /**
   /**
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
-  
+    // if (!app.globalData.userInfo) {
+    //   wx.navigateTo({
+    //     url: '/pages/login/login'
+    //   });
+    //   return;
+    // }
   },
   },
 
 
   /**
   /**
@@ -33,9 +39,29 @@ Page({
    * 生命周期函数--监听页面显示
    * 生命周期函数--监听页面显示
    */
    */
   onShow: function () {
   onShow: function () {
-    const userInfo = app.globalData.userInfo;
-    const nickName = userInfo.nickName;
-    const avatarUrl = userInfo.avatarUrl;
+    const count = this.data.login_count;
+      if (!app.globalData.userInfo && count <= 2) {
+        this.setData({
+          login_count: this.data.login_count+1
+        })
+        wx.navigateTo({
+          url: '/pages/login/login'
+        });
+        return;
+      }
+      if (!app.globalData.userInfo && count > 2) {
+        this.setData({
+          login_count: 1
+        })
+        wx.switchTab({
+          url: '/pages/index/index'
+        });
+        return;
+      }
+    
+    const userInfo = app.globalData.userInfo || null;
+    const nickName = userInfo.nickName || '';
+    const avatarUrl = userInfo.avatarUrl || '';
     let self = this
     let self = this
     getReq({
     getReq({
       act: 'cart',
       act: 'cart',

+ 4 - 2
pages/person/person.wxml

@@ -4,8 +4,10 @@
      <text class='person_name'>{{userInfo.nickName}}</text>
      <text class='person_name'>{{userInfo.nickName}}</text>
   </block>
   </block>
   <block wx:else>
   <block wx:else>
-     <image mode='widthFix' src="../../image/mine_logo_icon.png" class='person_avatar_image'></image>
-     <text class='person_name'>请登录</text>
+    <navigator url='/pages/login/login'>
+        <image mode='widthFix' src="../../image/mine_logo_icon.png" class='person_avatar_image'></image>
+        <text class='person_name'>请登录</text>
+    </navigator>
   </block>
   </block>
 </view>
 </view>
 
 

+ 5 - 0
pages/shopCart/shopCart.js

@@ -267,5 +267,10 @@ Page({
     wx.navigateTo({
     wx.navigateTo({
       url: `/pages/confirmOrder/confirmOrder?iscart=1&cart_id=${cart_list}`
       url: `/pages/confirmOrder/confirmOrder?iscart=1&cart_id=${cart_list}`
     })
     })
+  },
+  skip_index(){
+    wx.switchTab({
+      url:"/pages/index/index"
+    })
   }
   }
 })
 })

+ 11 - 1
pages/shopCart/shopCart.wxml

@@ -6,7 +6,17 @@
     </view>
     </view>
   </block>
   </block>
 </view>
 </view>
-
+<view style='background:#fff;' wx:if="{{summary.length <= 0}}">
+  <view class='flex_center'>
+    <image style='width:200rpx;' mode='widthFix' src='../../image/empty_cart.png'></image>
+  </view>
+  <view  class='flex_center'>
+    <text style='font-size:26rpx;color:#a1a1a1;'>您的购物车没有商品哦!</text>
+  </view>
+  <view class='flex_center'>
+    <button size='mini' bindtap='skip_index'  style='margin:20rpx 0;' type='warn'>去逛逛</button>
+  </view>
+</view>
 <view class='cart_list'>
 <view class='cart_list'>
   <block wx:for="{{summary}}" wx:key="{{index}}">
   <block wx:for="{{summary}}" wx:key="{{index}}">
     <view class='cart_item'>
     <view class='cart_item'>