huanggang 7 anni fa
parent
commit
130517d0ba

+ 2 - 1
app.json

@@ -9,7 +9,8 @@
     "pages/webView/webView",
     "pages/special/special",
     "pages/brand/brand",
-    "pages/comments/comments"
+    "pages/comments/comments",
+    "pages/search/search"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 3 - 0
app.wxss

@@ -3,6 +3,9 @@
 body {
   font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", 微软雅黑, Arial, sans-serif;
 }
+page {
+  background-color: #f9f9f9;
+}
 
 .container {
   height: 100%;

+ 1 - 0
pages/brand/brand.js

@@ -43,6 +43,7 @@ Page({
       curpage
     }, function (res) {
       if (res.code == 200) {
+        console.log(res);
         self.setData({
           special_datas: res.datas,
           summery: res.datas.summary,

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

@@ -1,12 +1,12 @@
 <view wx:key="item"  wx:for="{{special_datas.special_list}}">
     <carousel wx:if="{{item.item_type == 'adv_list'}}" image_list="{{item.items}}" scale="{{item.scale}}"></carousel>
     <divider wx:if="{{item.item_type == 'divider'}}" items="{{item}}"></divider> 
-    <homeThree wx:if="{{item.item_type == 'home3'}}" items="{{item.items}}"></homeThree> 
+    <homeThree wx:if="{{item.item_type == 'home3'}}" specialData="{{item}}" items="{{item.items}}"></homeThree> 
     <homeOne wx:if="{{item.item_type == 'home1'}}" items="{{item.items}}" ></homeOne>
     <homeOne wx:if="{{item.item_type == 'home5'}}" items="{{item.items}}"></homeOne>
     <homeTwo wx:if="{{item.item_type == 'home2'}}" items="{{item.items}}"></homeTwo>
     <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>
+    <home_goods wx:if="{{item.item_type == 'home_goods'}}" specialData="{{item.item_title}}" summery="{{summery}}" goods_items="{{item.items}}"></home_goods>
     <homeGrid wx:if="{{item.item_type == 'home_grid'}}" items="{{item.items}}"></homeGrid>
-    <homeWords wx:if="{{item.item_type == 'homewords'}}" items="{{item.items}}"></homeWords>    
+    <homeWords wx:if="{{item.item_type == 'homewords'}}" specialData="{{item.item_title}}" items="{{item.items}}"></homeWords>    
 </view>

+ 3 - 0
pages/components/blocks/home3/homeThree.js

@@ -6,6 +6,9 @@ Component({
   properties: {
     items: {
       type: Array
+    },
+    specialData:{
+      type: Object
     }
   },
 

+ 1 - 1
pages/components/blocks/home3/homeThree.wxml

@@ -1,5 +1,5 @@
 <!--components/blocks/home3/home3.wxml-->
- <view class="home_three_item" style="height:{{(items[0].height/1080*750)+'rpx'}}"> 
+ <view class="home_three_item" style="height:{{(items[0].height/1080*750)+'rpx'}};background-image:url('{{specialData.bg_data?specialData.bg_data:''}}');background-size:100% 100%;"> 
     <block wx:key="{{item}}" wx:for="{{items}}">
       <blockItem item_data="{{item}}"></blockItem>
     </block>

+ 3 - 0
pages/components/blocks/home_goods/home_goods.js

@@ -9,6 +9,9 @@ Component({
     },
     summery:{
       type:Array
+    },
+    specialData:{
+      type:String
     }
   },
 

+ 3 - 0
pages/components/blocks/home_goods/home_goods.wxml

@@ -1,3 +1,6 @@
+ <view>
+    <text class='special_label' wx:if="{{specialData}}">{{specialData}}</text> 
+</view> 
 <view class='home_goods'>
   <block wx:key="{{index}}" wx:for="{{goods_items}}">
     <goods_item summery="{{summery}}" goods_item="{{item}}"></goods_item>

+ 5 - 0
pages/components/blocks/home_goods/home_goods.wxss

@@ -6,4 +6,9 @@
   flex: 1;
   flex-wrap:wrap;
   margin-top: -6rpx;
+}
+.special_label {
+  font-size: 24rpx;
+  padding-left: 20rpx;
+  color: #959595;
 }

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

@@ -6,6 +6,9 @@ Component({
   properties: {
     items: {
       type: Array
+    },
+    specialData:{
+      type:String
     }
   },
 

+ 4 - 1
pages/components/blocks/home_words/homeWords.wxml

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

+ 13 - 8
pages/components/blocks/home_words/homeWords.wxss

@@ -1,11 +1,16 @@
 .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;
+  display:inline-block;
+  padding:10rpx;
+  background:#fff;
+  border-radius:5px;
+  font-size:24rpx;
+  text-align:center;
+  margin-right:19rpx;
+  margin-bottom: 10rpx;
+}
+.special_label {
+  font-size: 24rpx;
+  padding-left: 20rpx;
+  color: #959595;
 }

+ 5 - 1
pages/components/blocks/search/search.js

@@ -18,6 +18,10 @@ Component({
    * 组件的方法列表
    */
   methods: {
-
+    skipSearch(){
+      wx.navigateTo({
+        url: '/pages/search/search',
+      })
+    }
   }
 })

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

@@ -1,3 +1,3 @@
-<view class='search_box'>
+<view class='search_box' bindtap='skipSearch'>
   <text>搜索商品 品牌 功效 规格</text>
 </view>

+ 16 - 10
pages/components/blocks/search/search.wxss

@@ -1,16 +1,22 @@
 .search_box {
+  position: fixed;
+  top: 0;
+  left: 0;
+  width: 100%;
   font-size: 24rpx;
+  padding-top: 10rpx;
+  z-index: 10;
+  background: #ffffff;
 }
 .search_box text {
   width:720rpx;
-height:70rpx;
-line-height:70rpx;
-background:#f7f7f7;
-display:inline-block;
-border-radius:5rpx;
-color:#999999;
-padding-left:36rpx;
-box-sizing:border-box;
-margin-left:15rpx;
-
+  height:70rpx;
+  line-height:70rpx;
+  background:#f7f7f7;
+  display:inline-block;
+  border-radius:5rpx;
+  color:#999999;
+  padding-left:36rpx;
+  box-sizing:border-box;
+  margin-left:15rpx;
 }

+ 75 - 0
pages/components/blocks/search_box/search_box.js

@@ -0,0 +1,75 @@
+// pages/components/blocks/search_box/search_box.js
+const getReq = require('../../../../config.js').getReq;
+Component({
+  /**
+   * 组件的属性列表
+   */
+  properties: {
+
+  },
+
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    inputVal:'',
+    searchItems:[]
+  },
+
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    skip_target(e){
+      let word = e.target.dataset.word;
+      wx.navigateTo({
+        url: `/pages/brand/brand?keyword=${word}&title=${word}`,
+      })
+    },
+    search_btn(){
+      let inputVal = this.data.inputVal;
+      if (!inputVal) {
+        return;
+      } 
+      wx.navigateTo({
+        url: `/pages/brand/brand?keyword=${inputVal}&title=${inputVal}`,
+      })
+    },
+    input(e){
+      let self = this;
+      let val = e.detail.value; 
+      this.setData({
+        inputVal: val
+      });
+      if (val == "") {
+        clearTimeout(this.search);
+        self.setData({
+          searchItems: []
+        })
+        return;
+      }
+      clearTimeout(this.search);
+      this.search = setTimeout(function(){  
+          getReq({
+            act: 'search',
+            op: 'suggest_words',
+            keyword: val
+          }, function (res) {
+            if (res.code == 200) {
+              if(res.datas.words == null) {
+                self.setData({
+                  searchItems:[]
+                })
+              }
+              else {
+                self.setData({
+                  searchItems: res.datas.words
+                });
+              }
+            }
+          })
+      },300);
+      
+    }
+  }
+})

+ 4 - 0
pages/components/blocks/search_box/search_box.json

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

+ 11 - 0
pages/components/blocks/search_box/search_box.wxml

@@ -0,0 +1,11 @@
+<!--pages/components/blocks/search_box/search_box.wxml-->
+<view class='search_box'>
+    <input placeholder='搜索商品 品牌 功效 规格...' class='search_input' focus auto-focus bindinput="input"></input>
+    <text class='search_btn' bindtap='search_btn'>搜索</text>
+</view>
+<view class='flex_clear'></view>
+<scroll-view scroll-y wx:if="{{searchItems.length > 0}}" class='search_list'>
+  <block wx:key="{{index}}" wx:for="{{searchItems}}">
+    <view class='search_item' data-word="{{item}}" bindtap='skip_target'>{{item}}</view>
+  </block> 
+</scroll-view>

+ 73 - 0
pages/components/blocks/search_box/search_box.wxss

@@ -0,0 +1,73 @@
+.search_box {
+  position: fixed;
+  left: 0;
+  top: 0;
+  width: 100%;
+  height: 86rpx;
+  background: #ffffff;
+  box-sizing: border-box;
+  padding: 18rpx 0 18rpx 18rpx;
+  z-index: 10;
+}
+.search_box::after {
+  content: "";
+  position: absolute;
+  bottom: 0;
+  left: 0;
+  right: 0;
+  background: #c7c7c7;
+  height: 2rpx;
+  transform: scaleY(0.5);
+  -webkit-transform: scaleY(0.5);
+}
+.search_input {
+  display: inline-block;
+  width: 610rpx;
+  height: 55rpx;
+  line-height: 55rpx;
+  background: #f9f9f9;
+  font-size: 24rpx;
+  border-radius: 5rpx;
+  padding-left: 20rpx;
+  vertical-align:middle;
+}
+.flex_clear {
+  height: 86rpx;
+}
+.search_btn {
+  display:inline-block;
+  width:106rpx;
+  height:64rpx;
+  font-size:28rpx;
+  text-align:center;
+}
+.search_list {
+  width: 100%;
+  height: 100%;
+  position: fixed;
+  top: 86rpx;
+  left: 0;
+  z-index: 10;
+  background: #ffffff;
+  font-size: 28rpx;
+  overflow: scroll;
+}
+.search_item {
+  position: relative;
+  width: 715rpx;
+  height: 78rpx;
+  line-height: 78rpx;
+  margin-left: 35rpx; 
+}
+.search_item::after {
+  content: "";
+  position: absolute;
+  left: 0;
+  right: 0;
+  bottom: 0;
+  height: 2rpx;
+  width: 100%;
+  background:#c7c7c7; 
+  transform: scaleY(0.5);
+  -webkit-transform: scaleY(0.5);
+}

+ 2 - 2
pages/components/blocks/tabs/tabs.wxml

@@ -1,7 +1,7 @@
 
-<view class="scroll-view_H">
+<view>
   <searchBox></searchBox>
-  <scroll-view scroll-x="true" style="width: 100%">
+  <scroll-view class="scroll-view_H" scroll-x="true" style="width: 100%">
     <view 
       wx:for="{{tabs}}" 
       wx:key="tabsIndex" 

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

@@ -2,7 +2,7 @@
 .scroll-view_H{
   white-space: nowrap;
   position: fixed;
-  top: 0;
+  top: 78rpx;
   left: 0;
   z-index: 10;
   background: #fff;

+ 0 - 3
pages/index/index.js

@@ -46,7 +46,6 @@ Page({
       curpage: 1
     }, function (res) {
       if (res.code == 200) {
-        console.log(res)
         self.setData({
           special_datas: res.datas,
           summery:res.datas.summary
@@ -57,6 +56,4 @@ Page({
       }, 1000)
     })
   }
-
-
 })

+ 1 - 1
pages/index/index.wxss

@@ -20,5 +20,5 @@
   margin-top: 200px;
 }
 .clear_fixed {
-  height: 142rpx;
+  height: 152rpx;
 }

+ 1 - 2
pages/person/person.wxml

@@ -1,2 +1 @@
-<!--pages/person/person.wxml-->
-<text>pages/person/person.wxml</text>
+

+ 89 - 0
pages/search/search.js

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

+ 6 - 0
pages/search/search.json

@@ -0,0 +1,6 @@
+{
+  "usingComponents": {
+    "blockList": "../components/blockList/blockList",
+    "searchBox":"../components/blocks/search_box/search_box"
+  }
+}

+ 4 - 0
pages/search/search.wxml

@@ -0,0 +1,4 @@
+<view style='background:#f9f9f9;'>
+  <searchBox></searchBox>
+  <blockList summery="{{summery}}" special_datas="{{special_datas}}"> </blockList>
+</view>

+ 1 - 0
pages/search/search.wxss

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

+ 29 - 4
pages/shopCart/shopCart.js

@@ -1,11 +1,36 @@
-//logs.js
-const util = require('../../utils/util.js')
-
+const getReq = require('./../../config.js').getReq;
 Page({
   data: {
-    logs: []
+    free_info:{
+      type:Array
+    },
+    summary:{
+      type:Array
+    },
+    cart_list:{
+      type:Array
+    }
   },
   onLoad: function () {
     
+  },
+  onShow:function(){
+    let self = this;
+    getReq({
+      act: 'cart',
+      op: 'list'
+    }, function (res) {
+      console.log(res);
+      if (res.code == 200) {
+        let free_info = res.datas.free_info;
+        let summary = res.datas.summary;
+        let cart_list = res.datas.cart_list;
+        self.setData({
+          free_info,
+          summary,
+          cart_list
+        });
+      }
+    })
   }
 })

+ 52 - 0
pages/shopCart/shopCart.wxml

@@ -1 +1,53 @@
+<view class='cell_box' wx:if="{{free_info.length}}">
+  <block wx:for="{{free_info}}" wx:key="{{index}}">
+    <view class='cell_item'>
+      <text class='cell_item_title'>{{item.title}}</text>
+      <text class='cell_item_value'>{{item.value}}</text>
+    </view>
+  </block>
+</view>
 
+<view class='cart_list'>
+  <block wx:for="{{summary}}" wx:key="{{index}}">
+    <view class='cart_item'>
+      <view class='check_btn'>
+        <view class="icon_empty"></view>
+      </view>
+      <view class='goods_image'>
+        <image mode='scaleToFill' src="{{item.goods_image_url}}"></image>
+      </view>
+      <view class='goods_content'>
+        <view class='goods_name'>{{item.goods_mobile_name}}</view>
+        <view class='goods_spec'>{{item.goods_spec}}</view>
+        <view class='goods_price'>
+          <text class="bonus_price">¥{{item.bonus_price}}</text>
+          <text class="original_price">天猫价{{item.goods_price}}</text>
+        </view>
+        <view class='num_handle'>
+          <text class='handle_btn'>-</text>
+          <block>
+            <text class='num'>{{cart_list[index]['goods_num']}}</text>
+          </block>
+          <text class='handle_btn'>+</text>
+        </view>
+      </view>
+    </view>
+  </block>
+
+</view>
+
+<view class="handle_fixed">
+  <view class="all_check_btn">
+    <view class="icon_empty"></view>
+    <text>全选</text>
+  </view>
+  <view style='float:right'>
+    <view class='cope'>
+      <text class='bonus_price'>应付:¥50.00</text>
+      <text class="original_price">¥88</text>
+    </view>
+    <view class='settlement_btn'>
+      <text>结算</text>
+    </view>
+  </view>
+</view>

+ 152 - 0
pages/shopCart/shopCart.wxss

@@ -0,0 +1,152 @@
+.cell_box {
+  background: #ffffff;
+  margin-bottom: 8rpx;
+}
+.cell_item {
+    overflow: hidden;
+    padding-left: 25rpx;
+    text-overflow: ellipsis;
+    white-space: nowrap;
+    width: 100%;
+    height: 62rpx;
+    line-height: 62rpx;
+    position: relative;
+    box-sizing: border-box;
+}
+.cell_item::after {
+  content: "";
+  position: absolute;
+  bottom: 0;
+  right: 0;
+  height: 3rpx;
+  width: 725rpx; 
+  background: #f9f9f9;
+}
+
+.cell_item_title,.cell_item_value {
+  display: inline-block;
+  font-size: 22rpx;
+}
+.cell_item_title {
+    color: #f57d86;
+    border: 1px solid #f57d86;
+    border-radius: 10rpx;
+    padding: 8rpx;
+    margin-right: 24rpx;
+    line-height: 1;
+}
+.handle_fixed {
+  position: fixed;
+  bottom: 0;
+  left: 0;
+  width: 100%;
+  height: 88rpx;
+  line-height: 88rpx;
+  background: #ffffff;
+}
+.handle_fixed::after {
+  content: "";
+  position: absolute;
+  top: 0;
+  right: 0;
+  left: 0;
+  height: 3rpx;
+  background: #f7f7f7;
+}
+.handle_fixed {
+  font-size: 24rpx;
+}
+.all_check_btn,.cope,.settlement_btn {
+  display: inline-block;
+}
+.all_check_btn {
+  margin-left: 23rpx;
+}
+.icon_empty {
+  display: inline-block;
+  width: 25rpx;
+  height: 25rpx;
+  border: 2rpx solid #eaeaea;
+  border-radius: 50rpx;
+  vertical-align: middle;
+  margin-right: 22rpx;
+}
+.settlement_btn {
+  width: 146rpx;
+  font-size: 30rpx;
+  color: #ffffff;
+  background: #ff4e4e;
+  text-align: center;
+}
+.original_price {
+  font-size: 20rpx;
+  color: #929292;
+  position: relative;
+}
+.original_price::after {
+  content: "";
+  position: absolute;
+  top: 15rpx;
+  right: 0;
+  left: 0;
+  height: 3rpx;
+  background: #929292;
+}
+.bonus_price {
+  font-size: 26rpx;
+  color: #ff4e4e;
+}
+.original_price {
+  margin:0 10rpx; 
+}
+.cart_item {
+  background: #ffffff;
+  margin-bottom: 8rpx;
+  position: relative;
+  padding: 20rpx 0;
+  display: flex;
+  flex: 1;
+}
+.goods_image image {
+  width: 160rpx;
+  height: 160rpx;
+  border: 2rpx solid #c7c7c7;
+  vertical-align: middle;
+  margin-right: 17rpx;
+}
+.check_btn {
+  width: 72rpx;
+  text-align: center;
+  display: flex;
+  justify-content: center;
+  align-items:center;
+}
+.check_btn .icon_empty {
+  margin-right: 0;
+}
+.goods_name {
+  font-size: 24rpx;
+}
+.goods_spec{
+  font-size: 22rpx;
+  color: #929292;
+  margin-bottom: 48rpx;
+}
+.num_handle {
+  position: absolute;
+  bottom: 13rpx;
+  right: 0;
+}
+.handle_btn {
+    color: #ff4e4e;
+    display: inline-block;
+    width: 60rpx;
+    text-align: center;
+    font-size: 40rpx;
+}
+.num {
+    font-size: 24rpx;
+    display: inline-block;
+    width: 40rpx;
+    text-align: center;
+}

+ 6 - 1
project.config.json

@@ -30,7 +30,7 @@
 			"list": []
 		},
 		"miniprogram": {
-			"current": -1,
+			"current": 2,
 			"list": [
 				{
 					"id": 0,
@@ -43,6 +43,11 @@
 					"name": "comments",
 					"pathName": "pages/comments/comments",
 					"query": ""
+				},
+				{
+					"id": -1,
+					"name": "shopcart",
+					"pathName": "pages/shopCart/shopCart"
 				}
 			]
 		}