huanggang %!s(int64=7) %!d(string=hai) anos
pai
achega
e15129b5c3

+ 38 - 79
app.js

@@ -1,12 +1,6 @@
 //app.js
 App({
   onLaunch: function () {
-    wx.showLoading({
-      title:'加载中'
-    });
-  
-
-
     // 登录
     wx.login({
       success: res => {
@@ -27,76 +21,41 @@ App({
       success: res => {
         let self = this;
         if (res.authSetting['scope.userInfo']) {
-          // // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
-          // wx.getUserInfo({
-          //   success: res => {
-          //     // 可以将 res 发送给后台解码出 unionId
-          //     self.globalData.userInfo = res.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) {
-          //           wx.switchTab({
-          //             url: '/pages/index/index'
-          //           })
-          //         }
-          //         else {
-
-          //         }
-          //       }
-          //     })
-          //     // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-          //     // 所以此处加入 callback 以防止这种情况
-          //     if (this.userInfoReadyCallback) {
-          //       this.userInfoReadyCallback(res)
-          //     }
-          //   }
-          // })
-          // 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);
-          //         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) {
-          //               wx.switchTab({
-          //                 url: '/pages/index/index'
-          //               })
-          //             }
-          //             else {
+          let local_session_id = wx.getStorageSync('session_id');
+          if (local_session_id == '') {
+            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);
+                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) {
+                      let current_url = "/" + getCurrentPages()[0].route;
+                      wx.reLaunch({
+                        url: current_url
+                      });
+                    }
+                    else {
 
-          //             }
-          //           }
-          //         })
-          //         // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-          //         // 所以此处加入 callback 以防止这种情况
-          //         if (this.userInfoReadyCallback) {
-          //           this.userInfoReadyCallback(res)
-          //         }
-          //       }
-          //     })
-          //   }
-          // });
-          // wx.switchTab({
-          //   url: '/pages/index/index'
-          // })
+                    }
+                  }
+                })
+                // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+                // 所以此处加入 callback 以防止这种情况
+                if (this.userInfoReadyCallback) {
+                  this.userInfoReadyCallback(res)
+                }
+              }
+            })
+          }
         }
         else {
           wx.authorize({
@@ -104,7 +63,6 @@ App({
             success:function(res){
               wx.getUserInfo({
                 success: res => {
-                
                   // 可以将 res 发送给后台解码出 unionId
                   self.globalData.userInfo = res.userInfo;
                   self.globalData.userInfo.nickname = res.userInfo.nickName;
@@ -118,9 +76,10 @@ App({
                     success:function(res){
                       wx.setStorageSync('session_id', res.data.datas.HPHPSESSID);
                       if (res.statusCode == 200) {
-                        wx.switchTab({
-                          url: '/pages/index/index'
-                        })
+                        let current_url = "/" + getCurrentPages()[0].route;
+                        wx.reLaunch({
+                          url: current_url
+                        });
                       }
                       else {
 

+ 69 - 8
pages/brand/brand.js

@@ -6,7 +6,12 @@ Page({
    */
   data: {
     special_datas: {},
-    summery: []
+    summery: [],
+    hasmore:false,
+    curpage:1,
+    brand_id : '',
+    hot_id:'',
+    keyword:''
   },
 
   /**
@@ -16,20 +21,34 @@ Page({
     wx.setNavigationBarTitle({
       title: options.title ? options.title : "熊猫美妆"
     })
-    // console.log(options);
-    const brand_id = options.brand_id;
-    var self = this;
+    wx.showLoading({
+      title: '加载中',
+    });
+    const brand_id = options.brand_id ? options.brand_id : '';
+    const hot_id = options.hot_id ? options.hot_id : '';
+    const keyword = options.keyword ? options.keyword : '';
+    const curpage = this.data.curpage;
+    this.setData({
+      hot_id,
+      brand_id,
+      keyword
+    })
+    let self = this;
     getReq({
       act: 'search',
       op: 'index',
-      brand_id
+      brand_id,
+      hot_id,
+      keyword,
+      curpage
     }, function (res) {
-      console.log(res);
       if (res.code == 200) {
         self.setData({
           special_datas: res.datas,
-          summery: res.datas.summary
+          summery: res.datas.summary,
+          hasmore: res.datas.mobile_page.hasmore
         });
+        wx.hideLoading();
       }
     })
   },
@@ -73,7 +92,49 @@ Page({
    * 页面上拉触底事件的处理函数
    */
   onReachBottom: function () {
-
+      if(this.data.hasmore) {
+        wx.showLoading({
+          title: '加载中',
+        });
+        let self = this;
+        getReq({
+          act: 'search',
+          op: 'index',
+          brand_id: this.data.brand_id,
+          hot_id: this.data.hot_id,
+          keyword: this.data.keyword,
+          curpage: this.data.curpage+1
+        }, function (res) {
+          if (res.code == 200) {
+            let newDatas = res.datas;
+            let newSummery = res.datas.summary;
+            let oldDatas = self.data.special_datas;
+            let oldSummery = self.data.summery;
+            
+            let buildDatas = (function(){
+              let buildDatas = {};
+              for (let i in oldDatas) {
+                if (oldDatas[i] instanceof Array) {
+                  buildDatas[i] = oldDatas[i].concat(newDatas[i]);
+                }
+              }
+              return buildDatas;
+            })();
+            let buildSummery = (function(){
+              let buildDatas = [];
+              buildDatas = oldSummery.concat(newSummery);
+              return buildDatas;
+            })();
+            self.setData({
+              curpage: self.data.curpage+1,
+              special_datas: buildDatas,
+              summery: buildSummery,
+              hasmore: res.datas.mobile_page.hasmore
+            });
+            wx.hideLoading();
+          }
+        })
+      }
   },
 
   /**

+ 1 - 1
pages/brand/brand.wxml

@@ -1,4 +1,4 @@
 <!--pages/special/special.wxml-->
-<view>
+<view class='brand_special'>
   <blockList summery="{{summery}}" special_datas="{{special_datas}}"> </blockList>
 </view>

+ 3 - 1
pages/brand/brand.wxss

@@ -1 +1,3 @@
-/* pages/brand/brand.wxss */
+.brand_special {
+  background: #f9f9f9;
+}

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

@@ -45,13 +45,13 @@ Component({
         }
         case "goods":{
           wx.navigateTo({
-            url: `/pages/details/details?goods_id=${target_data}`
+            url: `/pages/details/details?goods_id=${target_data}&title=商品详情`
           })
           break;
         }
         case "brand":{
           wx.navigateTo({
-            url: `/pages/brand/brand?brand_id=${target_data}`
+            url: `/pages/brand/brand?brand_id=${target_data}&title=${title}`
           })
           break;
         }

+ 4 - 1
pages/components/blockItem/blockItem.wxml

@@ -1,4 +1,7 @@
-<block wx:if="{{item_data.show_type == 'image'}}">
+<block wx:if="{{item_data.show_type == 'image' || item_data.type == 'image'}}">
   <image bindtap="navigator" data-title="{{item_data.title}}" data-target="{{item_data.data}}" data-type="{{item_data.type}}" mode="scaleToFill" src="{{item_data.image}}" style="width:{{(item_data.width/1080*750)+'rpx'}}; height:{{(item_data.height/1080*750)+'rpx'}}"></image>
 </block>
 
+<block wx:elif="{{item_data.show_type == 'brand'|| item_data.type == 'brand'}}">
+    <image src="{{item_data.image}}" mode='widthFix' style='min-height:250rpx;' data-title="{{item_data.title}}"></image>
+</block>

+ 0 - 1
pages/components/blockItem/blockItem.wxss

@@ -1 +0,0 @@
-/* pages/components/blockItem/blockItem.wxss */

+ 2 - 1
pages/components/blockList/blockList.json

@@ -7,6 +7,7 @@
     "divider":"../blocks/divider/divider",
     "horizon":"../blocks/horizon/horizon",
     "home_goods": "../blocks/home_goods/home_goods",
-    "homeGrid": "../blocks/homeGrid/homeGrid"
+    "homeGrid": "../blocks/homeGrid/homeGrid",
+    "homeWords":"../blocks/home_words/homeWords"
   }
 }

+ 3 - 3
pages/components/blockList/blockList.wxml

@@ -3,8 +3,8 @@
     <divider wx:if="{{item.item_type == 'divider'}}" items="{{item}}"></divider> 
     <homeThree wx:if="{{item.item_type == 'home3'}}" items="{{item.items}}"></homeThree> 
     <homeOne wx:if="{{item.item_type == 'home1'}}" items="{{item.items}}" ></homeOne>
-    <horizon wx:if="{{item.item_type == 'horizon'}}" items="{{item.items}}"></horizon>
-    <horizon wx:if="{{item.item_type == 'horizon_goods'}}" items="{{item.items}}"></horizon>
+    <horizon wx:if="{{item.item_type == 'horizon' || item.item_type == 'horizon_goods'}}" items="{{item.items}}"></horizon>
     <home_goods wx:if="{{item.item_type == 'home_goods'}}" summery="{{summery}}" goods_items="{{item.items}}"></home_goods>
-    <homeGrid wx:if="{{item.item_type == 'home_grid'}}" items="{{item.items}}"></homeGrid>   
+    <homeGrid wx:if="{{item.item_type == 'home_grid'}}" items="{{item.items}}"></homeGrid>
+    <homeWords wx:if="{{item.item_type == 'homewords'}}" items="{{item.items}}"></homeWords>    
 </view>

+ 4 - 0
pages/components/blocks/effect/effect.js

@@ -7,6 +7,10 @@ Component({
     function_items: Array
   },
 
+  ready(){
+    // console.log(this.properties.function_items)
+  },
+
   /**
    * 组件的初始数据
    */

+ 18 - 14
pages/components/blocks/effect/effect.wxml

@@ -1,22 +1,26 @@
 <!--pages/components/blocks/effect/effect.wxml-->
 <view class="function_list">
-  <view class="function_items" wx:key="index" wx:for-index="index" wx:for="{{function_items}}">      
+  <view class="function_items" wx:key="index" wx:for-index="index" wx:for="{{function_items}}">
     <view class="function_masker_box">
-      <image class="function_img" src="{{item.img}}" mode="widthFix"></image>
-      <view class="m_title">
-        <view>
-          <text class="function_rounds"></text>
-          <text>{{item.name}}</text>
-          <text class="function_rounds"></text>
+      <navigator url="/pages/brand/brand?keyword={{item.name}}&title={{item.name}}">
+        <image class="function_img" src="{{item.img}}" mode="widthFix"></image>
+        <view class="m_title">
+          <view>
+            <text class="function_rounds"></text>
+            <text>{{item.name}}</text>
+            <text class="function_rounds"></text>
+          </view>
+          <view class="look_btn">查看全部</view>
         </view>
-        <view class="look_btn">查看全部</view>
-      </view> 
-    </view> 
+      </navigator>
+    </view>
     <view class="function_item_container">
       <view class="function_item" wx:key="index" wx:for-index="index" wx:for="{{item.subitem}}">
-        <image class="subitem_img" src="{{item.img}}" mode="widthFix"></image>
-        <view class="subitem_title">{{item.name}}</view>
+        <navigator url="/pages/brand/brand?keyword={{item.name}}&title={{item.name}}">
+          <image class="subitem_img" src="{{item.img}}" mode="widthFix"></image>
+          <view class="subitem_title">{{item.name}}</view>
+        </navigator>
       </view>
-    </view>  
+    </view>
   </view>
-</view>
+</view>

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

@@ -18,7 +18,7 @@ Component({
     let summery = this.properties.summery;
     let getSummeryGoods = proxy.getSummeryGoods(goods_id, summery);
     this.setData({
-      goods: getSummeryGoods
+        goods: getSummeryGoods
     }) 
   },
 

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

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

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

@@ -22,7 +22,7 @@
     -webkit-line-clamp: 2;
     overflow: hidden;
     color: #7e7e7e;
-    min-height: 62rpx;
+    min-height: 64rpx;
 }
 .goods_item .goods_box {
   padding: 12rpx;

+ 6 - 4
pages/components/blocks/homeGrid/homeGrid.wxml

@@ -1,8 +1,10 @@
 <!--pages/components/blocks/homeGrid/homeGrid.wxml-->
 <view class="home_grid">
-   <navigator url="/pages/details/details?goods_id=6143" hover-class="navigator-hover" wx:key="{{item}}" wx:for="{{items}}"> 
-    <view class="home_grid_item">
-      <image class="home_grid_img" src="{{item.image}}"></image>
-    </view>
+  <block wx:key="{{item}}" wx:for="{{items}}">
+    <navigator url="/pages/brand/brand?brand_id={{item.data}}&title={{item.title}}"> 
+        <view class="home_grid_item">
+            <image class="home_grid_img" src="{{item.image}}"></image>
+        </view>
    </navigator> 
+  </block>
 </view>

+ 30 - 0
pages/components/blocks/home_words/homeWords.js

@@ -0,0 +1,30 @@
+// pages/components/blocks/home_words/homeWords.js
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+    items: {
+      type: Array
+    }
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    navigator(e){
+      const title = e.target.dataset.title;
+      wx.navigateTo({
+        url: `/pages/brand/brand?keyword=${title}&title=${title}`,
+      })
+    }
+  }
+})

+ 6 - 0
pages/components/blocks/home_words/homeWords.json

@@ -0,0 +1,6 @@
+{
+  "component": true,
+  "usingComponents": {
+   
+  }
+}

+ 6 - 0
pages/components/blocks/home_words/homeWords.wxml

@@ -0,0 +1,6 @@
+<!--pages/components/blocks/home_words/homeWords.wxml-->
+<view style="padding-left:11rpx;margin-bottom:6rpx;">
+  <block wx:key="{{item}}" wx:for="{{items}}">
+      <view class='category_btn' data-title="{{item.title}}" bindtap="navigator">{{item.title}}</view>
+  </block>
+</view>

+ 11 - 0
pages/components/blocks/home_words/homeWords.wxss

@@ -0,0 +1,11 @@
+.category_btn {
+  width:20%;
+display:inline-block;
+padding:10rpx;
+background:#fff;
+border-radius:5px;
+font-size:24rpx;
+text-align:center;
+margin-right:19rpx;
+margin-bottom: 10rpx;
+}

+ 3 - 4
pages/components/blocks/horizon/horizon.wxml

@@ -1,10 +1,9 @@
-<!--components/blocks/horizon/horizon.wxml-->
 <view>
     <scroll-view scroll-x="true" style="white-space: nowrap;">
         <block wx:key="{{item}}" wx:for="{{items}}">
-        <view style="display:inline-block;width:{{(item.width/1080*750)+'rpx'}}; height:{{(item.height/1080*750)+'rpx'}}">
-          <blockItem item_data="{{item}}"></blockItem>
-        </view>
+            <view style="display:inline-block;width:{{(item.width/1080*750)+'rpx'}}; height:{{(item.height/1080*750)+'rpx'}}">
+              <blockItem item_data="{{item}}"></blockItem>
+            </view>
         </block>
     </scroll-view>
 </view>

+ 0 - 2
pages/discover/discover.js

@@ -26,7 +26,6 @@ Page({
       op: 'home'
     }, function (res) {
       if (res.code == 200) {
-        console.log(res)
         self.setData({
           special_datas: res.datas
         })
@@ -56,7 +55,6 @@ Page({
       op: 'index'
     }, function (res) {
       if (res.code == 200) {
-        console.log(res.datas.items)
         self.setData({
           function_items: res.datas.items
         })     

+ 9 - 2
pages/index/index.js

@@ -26,10 +26,17 @@ Page({
     })
   },
   onMyEvent: function (e) {
-    this.getDatas(e.detail.special_id)
+    this.setData({
+      special_datas: {},
+      summery: []
+    });
+    this.getDatas(e.detail.item.special_id)
   },
 
   getDatas(special_id) {
+    wx.showLoading({
+      title: '加载中'
+    });
     var self = this;
     getReq({
       act: 'special',
@@ -47,7 +54,7 @@ Page({
       }
       setTimeout(function () {
         wx.hideLoading()
-      }, 2000)
+      }, 1000)
     })
   }