huanggang преди 7 години
родител
ревизия
454e9ec5df

+ 42 - 39
app.js

@@ -1,10 +1,10 @@
 //app.js
 App({
   onLaunch: function () {
-    // 展示本地存储能力
-    var logs = wx.getStorageSync('logs') || []
-    logs.unshift(Date.now())
-    wx.setStorageSync('logs', logs)
+    wx.showLoading({
+      title:'加载中'
+    });
+  
 
 
     // 登录
@@ -57,43 +57,46 @@ App({
           //     }
           //   }
           // })
-          wx.authorize({
-            scope: 'scope.userInfo',
-            success: function (res) {
-              wx.getUserInfo({
-                success: 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 {
+          //         // 可以将 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 {
 
-                      }
-                    }
-                  })
-                  // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
-                  // 所以此处加入 callback 以防止这种情况
-                  if (this.userInfoReadyCallback) {
-                    this.userInfoReadyCallback(res)
-                  }
-                }
-              })
-            }
-          });
+          //             }
+          //           }
+          //         })
+          //         // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
+          //         // 所以此处加入 callback 以防止这种情况
+          //         if (this.userInfoReadyCallback) {
+          //           this.userInfoReadyCallback(res)
+          //         }
+          //       }
+          //     })
+          //   }
+          // });
+          // wx.switchTab({
+          //   url: '/pages/index/index'
+          // })
         }
         else {
           wx.authorize({

+ 5 - 2
app.json

@@ -1,11 +1,14 @@
 {
   "pages": [
-    "pages/login/login",
     "pages/index/index",
+    "pages/login/login",
     "pages/discover/discover",
     "pages/shopCart/shopCart",
     "pages/person/person",
-    "pages/details/details"
+    "pages/details/details",
+    "pages/webView/webView",
+    "pages/special/special",
+    "pages/brand/brand"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 85 - 0
pages/brand/brand.js

@@ -0,0 +1,85 @@
+const getReq = require('./../../config.js').getReq;
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    special_datas: {},
+    summery: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    wx.setNavigationBarTitle({
+      title: options.title ? options.title : "熊猫美妆"
+    })
+    // console.log(options);
+    const brand_id = options.brand_id;
+    var self = this;
+    getReq({
+      act: 'search',
+      op: 'index',
+      brand_id
+    }, function (res) {
+      console.log(res);
+      if (res.code == 200) {
+        self.setData({
+          special_datas: res.datas,
+          summery: res.datas.summary
+        });
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 5 - 0
pages/brand/brand.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "blockList": "../components/blockList/blockList"
+  }
+}

+ 4 - 0
pages/brand/brand.wxml

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

+ 1 - 0
pages/brand/brand.wxss

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

+ 35 - 1
pages/components/blockItem/blockItem.js

@@ -25,6 +25,40 @@ Component({
    * 组件的方法列表
    */
   methods: {
-
+    navigator(e){
+      const type = e.target.dataset.type;
+      const target_data = e.target.dataset.target;
+      const title = e.target.dataset.title;
+      if(!type)return;
+      switch(type){
+        case "url":{
+          wx.navigateTo({
+            url: `/pages/webView/webView?url=${target_data}&title=${title}`
+          })
+          break;
+        }
+        case "special":{
+          wx.navigateTo({
+            url: `/pages/special/special?special_id=${target_data}&title=${title}`
+          })
+          break;
+        }
+        case "goods":{
+          wx.navigateTo({
+            url: `/pages/details/details?goods_id=${target_data}`
+          })
+          break;
+        }
+        case "brand":{
+          wx.navigateTo({
+            url: `/pages/brand/brand?brand_id=${target_data}`
+          })
+          break;
+        }
+        default: {
+          console.log(type+'类型找不到');
+        }
+      }
+    }
   }
 })

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

@@ -1,4 +1,4 @@
 <block wx:if="{{item_data.show_type == 'image'}}">
-  <image mode="scaleToFill" src="{{item_data.image}}" style="width:{{(item_data.width/1080*750)+'rpx'}}; height:{{(item_data.height/1080*750)+'rpx'}}"></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>
 

+ 1 - 0
pages/components/blockList/blockList.wxml

@@ -4,6 +4,7 @@
     <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>
     <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>   
 </view>

+ 3 - 1
pages/components/blocks/horizon/horizon.json

@@ -1,4 +1,6 @@
 {
   "component": true,
-  "usingComponents": {}
+  "usingComponents": {
+    "blockItem": "../../blockItem/blockItem"
+  }
 }

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

@@ -3,7 +3,7 @@
     <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'}}">
-          <image src="{{item.show_data}}"></image>
+          <blockItem item_data="{{item}}"></blockItem>
         </view>
         </block>
     </scroll-view>

+ 3 - 1
pages/index/index.js

@@ -31,7 +31,6 @@ Page({
 
   getDatas(special_id) {
     var self = this;
-    var apps = app;
     getReq({
       act: 'special',
       op: 'index',
@@ -46,6 +45,9 @@ Page({
           summery:res.datas.summary
         });
       }
+      setTimeout(function () {
+        wx.hideLoading()
+      }, 2000)
     })
   }
 

+ 2 - 2
pages/index/index.wxml

@@ -1,6 +1,6 @@
 <!--index.wxml-->
-<view class="">
+<view>
   <tabs tabs="{{tabs}}" bind:myevent="onMyEvent"></tabs>
   <view class='clear_fixed'></view> 
-   <blockList summery="{{summery}}" special_datas="{{special_datas}}"> </blockList> 
+  <blockList summery="{{summery}}" special_datas="{{special_datas}}"> </blockList> 
 </view>

+ 88 - 0
pages/special/special.js

@@ -0,0 +1,88 @@
+// pages/special/special.js
+const getReq = require('./../../config.js').getReq;
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    special_datas: {},
+    summery: []
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    wx.setNavigationBarTitle({
+      title: options.title ? options.title : "熊猫美妆"
+    })
+    // console.log(options);
+    const special_id = options.special_id;
+    var self = this;
+    getReq({
+      act: 'special',
+      op: 'index',
+      special_id,
+      page: 10,
+      curpage: 1
+    }, function (res) {
+      console.log(res);
+      if (res.code == 200) {
+        self.setData({
+          special_datas: res.datas,
+          summery: res.datas.summary
+        });
+      }
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 5 - 0
pages/special/special.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "blockList": "../components/blockList/blockList"
+  }
+}

+ 4 - 0
pages/special/special.wxml

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

+ 1 - 0
pages/special/special.wxss

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

+ 69 - 0
pages/webView/webView.js

@@ -0,0 +1,69 @@
+// pages/web-view/webView.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    webViewUrl:''
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+    
+    this.setData({
+      webViewUrl: options.url
+    })
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+  
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+  
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+  
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+  
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+  
+  }
+})

+ 1 - 0
pages/webView/webView.json

@@ -0,0 +1 @@
+{}

+ 1 - 0
pages/webView/webView.wxml

@@ -0,0 +1 @@
+<web-view src="{{webViewUrl}}"></web-view>

+ 1 - 0
pages/webView/webView.wxss

@@ -0,0 +1 @@
+/* pages/web-view/webView.wxss */