zhashaonan 6 年之前
父節點
當前提交
05fda899e1

+ 62 - 84
app.js

@@ -2,8 +2,7 @@
 const api = require('./config.js');
 
 App({
-  host:api.host,
-
+  host: api.host,
   onLaunch: function () {
     let self = this;
     // 登录
@@ -11,100 +10,79 @@ App({
       success: res => {
         wx.request({
           url: self.host,
-          data:{
-            act:"login",
-            op:"ministart",
+          data: {
+            act: "login",
+            op: "ministart",
             code: res.code,
-            client_type:"mini"
+            client_type: "mini"
           },
-          success:function(res){
+          success: function (res) {
             self.globalData.userId.openid = res.data.datas.openid;
             self.globalData.userId.unionid = res.data.datas.unionid;
             // 获取用户信息
             wx.getSetting({
               success: res => {
                 if (res.authSetting['scope.userInfo']) {
-                    wx.getUserInfo({
-                      success: res => {
-                        self.globalData.userInfo = res.userInfo;
-                        self.globalData.userInfo.nickname = res.userInfo.nickName;
-                        let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
-                        wx.request({
-                          url: self.host,
-                          method: 'GET',
-                          data: {
-                            user_info: userInfo,
-                            act: "login",
-                            op: "wxauthen",
-                            // op: "wxauthor",
-                            client_type: "mini"
-                          },
-                          success: function (res) {
-                            // console.log(res.data.datas.HPHPSESSID);
-                            wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
-                            if (res.statusCode == 200) {
-                              let current_url = "/" + getCurrentPages()[0].route;
-                              wx.reLaunch({
-                                url: current_url
-                              });
+                  wx.getUserInfo({
+                    success: res => {
+                      self.globalData.userInfo = res.userInfo;
+                      self.globalData.userInfo.nickname = res.userInfo.nickName;
+                      let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
+                      wx.request({
+                        url: self.host,
+                        method: 'GET',
+                        data: {
+                          user_info: userInfo,
+                          act: "login",
+                          op: "wxauthen",
+                          client_type: "mini"
+                        },
+                        success: function (res) {
+                          wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
+                          if (res.statusCode == 200) {
+                            let len = getCurrentPages().length
+                            let currentPage = getCurrentPages()[len - 1]
+                            let params = ''
+                            if (currentPage.options) {
+                              for (let k in currentPage.options) {
+                                params = params + k + '=' + currentPage.options[k] + '&'
+                              }
+                              params = params.slice(0, params.length - 1)
                             }
-                            else {
-
+                            let current_url = "/" + currentPage['route']
+                            if (params) {
+                              current_url = current_url + '?' + params
                             }
+                            console.log('current_url:', current_url);
+                            wx.reLaunch({
+                              url: current_url
+                            });
                           }
-                        })
-                        // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-                        // 所以此处加入 callback 以防止这种情况
-                        if (this.userInfoReadyCallback) {
-                          this.userInfoReadyCallback(res)
-                        }
-                      }
-                    })
-                }
-                else {
-                  wx.authorize({
-                    scope: 'scope.userInfo',
-                    success: function (res) {
-                      wx.getUserInfo({
-                        success: res => {
-                          // 可以将 res 发送给后台解码出 unionId
-                          self.globalData.userInfo = res.userInfo;
-                          self.globalData.userInfo.nickname = res.userInfo.nickName;
-                          let userInfo = Object.assign({}, self.globalData.userId, self.globalData.userInfo);
-                          // console.log(userInfo);
-                          wx.request({
-                            url: self.host,
-                            method: 'GET',
-                            data: {
-                              user_info: userInfo,
-                              act: "login",
-                              op: "wxauthen",
-                              // op: "wxauthor",
-                              client_type: "mini"
-                            },
-                            success: function (res) {
-                              // console.log(res.data.datas.HPHPSESSID)
-                              wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
-                              if (res.statusCode == 200) {
-                                let current_url = "/" + getCurrentPages()[0].route;
-                                wx.reLaunch({
-                                  url: current_url
-                                });
-                              }
-                              else {
+                          else {
 
-                              }
-                            }
-                          })
-                          // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-                          // 所以此处加入 callback 以防止这种情况
-                          if (this.userInfoReadyCallback) {
-                            this.userInfoReadyCallback(res)
                           }
                         }
                       })
+                      // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                      // 所以此处加入 callback 以防止这种情况
+                      if (this.userInfoReadyCallback) {
+                        this.userInfoReadyCallback(res)
+                      }
                     }
-                  });
+                  })
+                }
+                else {
+                  
+                  let len = getCurrentPages().length
+                  let currentPage = getCurrentPages()[len - 1].route
+                  console.log('currentPage:', getCurrentPages()[len - 1]);
+                  if(currentPage.indexOf('shareBonus/shareBonus') != -1) {
+                    wx.navigateTo({
+                      url: `/pages/login/login`
+                    });
+                    return;
+                  }
+                  return;
                 }
               }
             })
@@ -115,14 +93,14 @@ App({
     })
   },
   globalData: {
-    userId:{
-      openid:'',
-      unionid:''
+    userId: {
+      openid: '',
+      unionid: ''
     },
     userInfo: null,
     defaultAddress: null,
     fcodeErr: '',
-    backLogin:false,
+    backLogin: false,
     arrayTree: [],
     fromSource: ''
   },

+ 0 - 1
config.js

@@ -3,7 +3,6 @@ let api = "https://passport.lrlz.com/mobile/index.php";
 // let api = "http://a.lrlz.com/mobile/index.php";
 function getReq(data, callback, method) {
   let options = {
-    // client_type: 'ios'
     client_type: 'mini'
   }
   data = Object.assign({}, options, data);

+ 1 - 0
pages/components/blocks/goods_item/goods_item.js

@@ -29,6 +29,7 @@ Component({
         goods_promotion_price: parseFloat(getSummeryGoods.goods_promotion_price)
       }
     )
+    // console.log('goods:', goods);
     this.setData({
       goods
     })

+ 4 - 0
pages/components/blocks/goods_item/goods_item.wxml

@@ -5,6 +5,10 @@
       <view class='goods_desc one_line_hidden'>
         <text>{{goods.goods_jingle}}</text>
       </view>
+      <view class="badge sq" wx:if="{{goods['goods_storage'] <= 0}}"><view>已经</view><view>售罄</view></view>
+      <view class="badge qg" wx:elif="{{goods['act_type'] == 1}}"><view>抢购</view><view>特价</view></view>          
+      <view class="badge new" wx:elif="{{goods['is_new'] && goods['act_type'] == 0}}"><view>熊猫</view><view>新品</view></view>
+      <view class="badge tj" wx:elif="{{goods['act_type'] == 2}}"><view>限时</view><view>特价</view></view>
     </view>
     <view class='goods_box'>
       <view class='goods_name one_line_hidden'>{{goods.goods_mobile_name}}</view>

+ 27 - 0
pages/components/blocks/goods_item/goods_item.wxss

@@ -157,4 +157,31 @@
 .align_center {
   display: flex;
   align-items: center;
+}
+.badge {
+  box-sizing: border-box;
+  position: absolute;
+  top: 18rpx;
+  left: 18rpx;
+  border-radius: 100rpx;
+  padding-top: 12rpx;
+  color: #fff;
+  font-size: 17rpx;
+  width: 60rpx;
+  height: 60rpx;
+  text-align: center;
+  line-height: 19rpx;
+  letter-spacing: 2rpx;  
+}
+.badge.sq {
+  background: #9B9B9B;
+}
+.badge.qg {
+  background: #FF4E4E;
+}
+.badge.new {
+  background: #000000;
+}
+.badge.tj {
+  background: #FF4E4E;
 }

+ 1 - 3
pages/components/blocks/tabs/tabs.wxss

@@ -5,8 +5,6 @@
   top: 80rpx;
   left: 0;
   z-index: 10;
-  /* background: #fff; */
-  /* box-shadow: 0 0 3rpx #fff; */
 }
 .scroll-view-item{
   height: 300rpx;
@@ -17,7 +15,7 @@
   padding: 10rpx 28rpx;
   height: 40rpx;
   font-size: 28rpx;
-  color: #666;
+  color: #777777;
   background: #2b2b2b;
 }
 .scroll-view-item_H:after {

+ 7 - 1
pages/details/details.js

@@ -10,6 +10,7 @@ Page({
    * 页面的初始数据
    */
   data: {
+    canIUse: wx.canIUse('button.open-type.getUserInfo'),
     imgUrls: [],
     datas: {},
     goodsIdMap: '',
@@ -61,9 +62,14 @@ Page({
       var str = res.split(/<[\/]?body>/gi)[1];
       WxParse.wxParse('article', 'html', str, that);
     });
-
+  },
+  shareBonus() {
+    wx.navigateTo({
+      url: `/pages/shareBonus/shareBonus?type_sn=58841537878020836581&relay_id=111`
+    })
   },
   getDatas(goods_id) {
+
     let fromSource = recordSource(app, `act=goods_common&op=index&goods_id=${goods_id}&client_type=mini`)
     wx.showLoading({
       title: '加载中',

+ 1 - 2
pages/details/details.wxml

@@ -6,7 +6,7 @@
     <image wx:for="{{imgUrls}}" wx:for-index="idx" wx:key="idx" class="imageHeight" src="{{item}}" bindload="swiperImgLoad"></image>
   </view>
 <view class="bacfff" wx:if="{{show}}">
-  <view class="pos_rel" >
+  <view class="pos_rel">
     <swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-color="#E8E8E8"
       circular="true" indicator-active-color="##2B2B2B" style="height:750rpx">
       <block wx:for="{{imgUrls}}" wx:for-index="idx" wx:key="idx" >
@@ -38,7 +38,6 @@
   </view>
 
   <view class="place-bacd9"></view>
-
   <view class="ensure_desc" bindtap='isExplain_flag' data-flag="true">
     <view class="stamps_list">
       <view class="n_stamps_item" wx:if="{{getOneSummary.brand_country_logo}}">

+ 2 - 6
pages/login/login.js

@@ -14,6 +14,7 @@ Page({
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
+    console.log('loginoptions:', options);
     let url = options.url || ''
     this.setData({
       url
@@ -74,7 +75,6 @@ Page({
           user_info: userInfo,
           act: "login",
           op: "wxauthen",
-          // op: "wxauthor",
           client_type: "mini"
         },
         success: function (res) {
@@ -83,12 +83,8 @@ Page({
             app.globalData.backLogin = true;
             let len = getCurrentPages().length
             let prev = getCurrentPages()[len - 2]
-            if (prev['route'].indexOf('/shareBonus/shareBonus') != -1) {
+            if (prev['route'].indexOf('shareBonus/shareBonus') != -1) {
               let { type_sn, relay_id } = prev.options
-              // wx.redirectTo({
-              //   url: `/pages/shareBonus/shareBonus?type_sn=${type_sn}&relay_id=${relay_id}`
-              // })
-
               wx.reLaunch({
                 url: `/pages/shareBonus/shareBonus?type_sn=${type_sn}&relay_id=${relay_id}`
               })

+ 1 - 2
pages/person/person.js

@@ -159,8 +159,7 @@ Page({
   },
   shareBonus() {
     wx.navigateTo({
-      url: `/pages/shareBonus/shareBonus?type_sn=16971536647075199285`
-      // url: `/pages/shareBonus/shareBonus?type_sn=21991536583136231606`
+      url: `/pages/shareBonus/shareBonus?type_sn=58841537878020836581`
     })
   },
   /**

+ 17 - 11
pages/shareBonus/shareBonus.js

@@ -20,28 +20,35 @@ Page({
     message_flag: false,
     input_msg: '',
     result_msg: '留言',
-    summarys: false
+    summarys: false,
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad: function (options) {
-    
-    if (!app.globalData.userInfo) {
-      wx.navigateTo({
-        url: `/pages/login/login`
-      });
-      return;
+    let self = this
+    app.userInfoReadyCallback = res => {
+      console.log('res:', res);
+      if (app.globalData.userInfo) {
+        self.init(options)
+      }
     }
+
+    if (app.globalData.userInfo) {
+      self.init(options)
+    }
+  },
+  init(options) {
+    let self = this
     let { type_sn, relay_id = '' } = options
     let params = {
       act: 'bonusex',
       op: 'open',
       type_sn
     }
-    this.getDatas(params)
-    this.setData({
+    self.getDatas(params)
+    self.setData({
       type_sn,
       relay_id
     })
@@ -64,7 +71,6 @@ Page({
   },
   getDatas(params) {
     let self = this
-
     getReq(params, function (res) {
       if (res.code == 200) {
         let { type_info, bonus_state } = res.datas
@@ -92,7 +98,7 @@ Page({
 
           let sender_head_src = self.senderHead(relayer_id, sender_id, avatars)
           let reveive_info = self.receiveInfo(type_info) // 展示领取信息
-          if(summarys) {
+          if (summarys) {
             summarys = summarys.map(item => {
               item['goods_lowest_price'] = parseFloat(item['goods_lowest_price'])
               item['goods_price'] = parseFloat(item['goods_price'])