소스 검색

特惠商品和购物车

junyuanz 4 년 전
부모
커밋
7568295ce2

+ 23 - 12
pages/cart/cart.js

@@ -47,11 +47,12 @@ Page({
   	// this.getCartList();
   },
   onShow: function () {
+	 var that = this;
   	this.getCartList();
   	this.setData({submitlock: false});
   	this.setData({selectedall: false});
 	setTimeout(function(){
-		this.getCartListAndSelected();
+		that.getCartListAndSelected();
 	},50);
   },
   getCartList:function(){
@@ -156,7 +157,7 @@ Page({
 				      that.getCartList();
 					  that.setData({submitlock: false});
 					  that.setData({selectedall: false});
-					  that.getCartListAndSelected();
+					  // that.getCartListAndSelected();
 				    }
 				    _request.$post(url, params, success);
 		      } else if (sm.cancel) {
@@ -187,7 +188,7 @@ Page({
 				      that.getCartList();
 					  that.setData({submitlock: false});
 					  that.setData({selectedall: false});
-					  that.getCartListAndSelected();
+					  // that.getCartListAndSelected();
 				    }
 				    _request.$post(url, params, success);
 		      } else if (sm.cancel) {
@@ -231,7 +232,7 @@ Page({
       }
     }
     _request.$post(url, params, success);
-    this.getCartList();
+ //    this.getCartList();
 	that.setData({submitlock: false});
 	that.setData({selectedall: false});
 	that.getCartListAndSelected();
@@ -248,11 +249,21 @@ Page({
 		  ['cartList[' + index + '].IsBuy']: !bool
 		})
 	}else{
-		wx.showToast({
-		  title: '当前商品秒杀已结束或尚未开始~',
-		  icon: 'none',
-		  duration: 2000
-		})
+		
+		if(Date.parse(Date.parse(new Date()) / 1000 > this.data.cartList[index].seckill_end)){
+			wx.showToast({
+			  title: '当前商品秒杀已结束~',
+			  icon: 'none',
+			  duration: 2000
+			})
+		}else{
+			wx.showToast({
+			  title: '当前商品秒杀尚未开始~',
+			  icon: 'none',
+			  duration: 2000
+			})
+		}
+		
 	}
     
   	this.checkSelected();
@@ -322,7 +333,7 @@ Page({
       	that.getCartList();
 		that.setData({submitlock: false});
 		that.setData({selectedall: false});
-		that.getCartListAndSelected();
+		// that.getCartListAndSelected();
       }
     }
     _request.$post(url, params, success);
@@ -404,7 +415,7 @@ Page({
 				      that.getCartList();
 					  that.setData({submitlock: false});
 					  that.setData({selectedall: false});
-					  that.getCartListAndSelected();
+					  // that.getCartListAndSelected();
 				    }
 				    _request.$post(url, params, success);
 		      } else if (sm.cancel) {
@@ -506,7 +517,7 @@ Page({
 						  that.getCartList();
 						  that.setData({submitlock: false});
 						  that.setData({selectedall: false});
-						  that.getCartListAndSelected();
+						  // that.getCartListAndSelected();
 						}
 						_request.$post(url, params, success);
 					}

+ 1 - 1
pages/cart/cart.wxml

@@ -60,7 +60,7 @@
 						        <image src="{{item.cover}}" />
 						      </view>
 						      <view class="cartlist_info">
-						        <view class="cartlist_title">{{item.product_name}} <span wx:if="{{item.color_name || item.size_name}}">|</span> {{item.color_name}} {{item.size_name}}</view>
+						        <view class="cartlist_title"><i wx:if="{{item.pv < item.original_price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{item.product_name}} <span wx:if="{{item.color_name || item.size_name}}">|</span> {{item.color_name}} {{item.size_name}}</view>
 						        
 								<view class="project-pack-list" wx:if="{{item.package}}">
 									<view wx:for="{{item.package_list}}" wx:for-item="pack" wx:for-index="ind">

+ 10 - 4
pages/home/home.wxml

@@ -29,7 +29,7 @@
         </navigator>-->
         <view wx:key="{{index}}" bindtap="toviewfunc" data-val="{{item}}" wx:for="{{iconslist}}" class="item-box">
           <image src="{{item.cover}}" class="item-index" />
-          <view class="item-name">{{item.name}}</view>
+          <view class="item-name"><i wx:if="{{item.pv < item.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{item.name}}</view>
         </view>
       <!-- <view bindtap="tocentcart" class="item-box">
         <image src="http://fohow.oss-cn-shenzhen.aliyuncs.com/navigation_icons/cent.png" class="item-index" />
@@ -378,7 +378,10 @@
         <view wx:if="{{!item.video_state}}" bindtap="toProject" data-val="{{item.id}}">
 			<view class="project-pack" wx:if="{{item.package}}">
 				<view class="project-left-pack">
-					<view class="project-title ellipsisLn" style="height: 48rpx;">{{item.name}}</view>
+					<view class="project-title ellipsisLn" style="height: 48rpx;">
+						<i wx:if="{{item.pv < item.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>
+						{{item.name}}
+					</view>
 
 					<view class="project-pack-list">
 						<view wx:for="{{item.package_list}}" wx:for-item="pack" wx:for-index="ind">
@@ -403,7 +406,10 @@
 			</view>
 			<view  class="project" wx:else>
 				<view class="project-left">
-					<view class="project-title ellipsisLn">{{item.name}}</view>
+					<view class="project-title ellipsisLn">
+						<i wx:if="{{item.pv < item.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>
+						{{item.name}}
+					</view>
 				
 					<view class="project-count">已售{{item.sold_count}}件</view>
 					<image wx:if="{{item.seckill_state === 'seckill'}}" src="http://fohow.oss-cn-shenzhen.aliyuncs.com/xcx/image/icon/miaosha.png" class="project-miaosha-img"/>
@@ -433,7 +439,7 @@
           <video class="project-video" custom-cache="{{false}}" bindtap='videoTap' data-index="{{index}}"  id='video{{index}}' show-fullscreen-btn="{{false}}" enable-progress-gesture="{{false}}" src="{{item.video_url}}" controls="{{false}}" show-center-play-btn='{{false}}'>
           	<cover-image class="playImg" src="../../images/footer/play.png"  wx:if="{{!item.video_play}}"></cover-image>
           </video>
-          <view class="project-title ellipsisLn">{{item.name}}</view>
+          <view class="project-title ellipsisLn"><i wx:if="{{item.pv < item.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{item.name}}</view>
           <view class="project-price" style="color: #999;text-decoration: line-through;font-size: 23rpx;">零售价:<currency symbol="¥" value="{{item.user_sale_price}}" /><!-- <currency symbol="¥" value="{{item.price}}" wx:if="{{balance === 0 || balance < item.price}}"></currency><text wx:if="{{balance !== 0 && balance >= item.price}}" class="project-point">{{item.price}}提货券</text> --></view>
           <view class="project-price" style="float: left;font-size:35rpx;"><currency symbol="¥" value="{{item.price}}" /><!-- <currency symbol="¥" value="{{item.price}}" wx:if="{{balance === 0 || balance < item.price}}"></currency><text wx:if="{{balance !== 0 && balance >= item.price}}" class="project-point">{{item.price}}提货券</text> --></view>
           <view class="project-count">已售{{item.sold_count}}件</view>

+ 1 - 1
pages/pay/pay.wxml

@@ -228,7 +228,7 @@
 	  </view>
 	  
 	  <view wx:if="{{useBalance || payData.coupon_price>0}}" style="padding:15rpx;text-align:right">
-	  	订单总金额 <text style="color:#F00">{{(payData.total_price + payData.freight) / 100}}</text>
+	  	订单总金额 <text style="color:#F00">{{receivetype == 0 ? ((payData.total_price + payData.freight) / 100) : (payData.total_price / 100)}}</text>
 	  </view>
 	  
 	  <view wx:if="{{useBalance || payData.coupon_price>0}}" style="padding:15rpx;text-align:right">

+ 3 - 3
pages/projects/project-detail/project-detail.wxml

@@ -28,7 +28,7 @@
       <view><image src="http://fohow.oss-cn-shenzhen.aliyuncs.com/neverse/otherskill.png" class="seckill-img" /></view>
     </view>
     
-    <text class="detail-width detail-title">{{project.name}}</text>
+    <h3 class="detail-width detail-title"><i wx:if="{{project.pv < project.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{project.name}}</h3>
     <button open-type="share" class="sharebtn" wx:if="{{readOnly != 1}}"><image src="../../../images/footer/share.png" /><text>分享</text></button>
     <!--<view class="detail-width">
       <text class="detail-normal detail-mr">价格</text>
@@ -219,7 +219,7 @@
         <image class="dialog-img" src="{{project.pics[0].img}}"></image>
         
         <view class="dialog-info" style="margin-top: 20rpx;">
-          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;">{{project.name}}</h6>
+          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;"><i wx:if="{{project.pv < project.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{project.name}}</h6>
           <view class="dialog-word dialog-black" style="margin-top: 15rpx;color: #999;">库存{{project.left_count}}件   <text wx:if="{{project.have_size && (sname || cname)}}">(已选:{{cname}} {{sname}})</text></view>
           <view class="dialog-word dialog-red" style="font-size: 35rpx;margin-top: 25rpx;">
             <!-- {{project.price}}提货券 -->
@@ -270,7 +270,7 @@
       <view class="dialog-content">
         <image class="dialog-img" src="{{project.pics[0].img}}"></image>
         <view class="dialog-info" style="margin-top: 20rpx;">
-          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;">{{project.name}}</h6>
+          <h6 style="font-size: 35rpx;font-weight: bold;color: #666;"><i wx:if="{{project.pv < project.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{project.name}}</h6>
           <view class="dialog-word dialog-black" style="margin-top: 15rpx;color: #999;">库存{{project.left_count}}件   <text wx:if="{{project.have_size && (sname || cname)}}">(已选:{{cname}} {{sname}})</text></view>
           <view class="dialog-word dialog-red" style="font-size: 35rpx;margin-top: 25rpx;">
             <!-- {{project.price}}提货券 -->

+ 23 - 4
pages/projects/project-search/project-search.js

@@ -2,7 +2,7 @@ var _request = require('../../../utils/request.js')
 Page({
   data: {
     projects_page: 1,
-    projects_per_page: 5,
+    projects_per_page: 1000,
     projects_more: true,
     projects_change: false,
     projects: [],
@@ -97,8 +97,8 @@ Page({
     var url = 'v1/cat/' + id + '/products'
 	if(that.data.searchword){
 		var params = {
-		  // page: this.data.projects_page,
-		  // per_page: this.data.projects_per_page,
+		  page: this.data.projects_page,
+		  per_page: this.data.projects_per_page,
 		  words:that.data.searchword
 		}
 	}else{
@@ -170,5 +170,24 @@ Page({
       // path: '/pages/start/start?url=pages/projects/projects',
       sc: 'xcx_products'
     })
-  }
+  },
+  bindword: function (e) {
+  	  var word = e.detail.value;
+  	  
+    this.setData({
+      searchword: word
+    })
+  },
+  tosearch:function(){
+	  if(this.data.searchword == ''){
+		  wx.showToast({
+		    title: '请输入搜索关键字',
+		    icon: 'none',
+		    duration: 2000
+		  })
+		  return false;
+	  }
+	  this.setData({projects:[]})
+  	  this.getProjects();
+  },
 })

+ 10 - 1
pages/projects/project-search/project-search.wxml

@@ -1,4 +1,12 @@
 <view class="bg">
+	<view class="searchbox">
+		<view class="searchtxt">
+			<input type="text" value="{{searchword}}" bindinput="bindword"/>
+			<button bindtap="tosearch">搜索</button>
+		</view>
+	</view>
+	
+	
   <view class="projects">
     <view class="projectbg">
       <!-- <view class="scrollview" wx:if="{{vershow}}">
@@ -8,6 +16,7 @@
           </block>
          </scroll-view>
       </view> -->
+	  
       <view class="project" wx:key="{{index}}" wx:for="{{projects}}"  data-val="{{item.id}}" bindtap="toProject">
         <view class="project-left">
           <view class="project-title ellipsisLn">{{item.name}}</view>
@@ -34,7 +43,7 @@
         <view class="clean"></view>
       </view>
       
-	  <view wx:if="{{projects.length == 0}}" style="text-align: center;color:#999">无相关内容</view>
+	  <view wx:if="{{projects.length == 0}}" style="text-align: center;color:#999">您搜索的商品不存在</view>
       <view><text wx:if="{{projects_more}}" style="text-align: center;padding: 10px;color: #999;display: block;margin-bottom: 15px;">正在努力加载...</text></view>
     </view>
   </view>

+ 39 - 1
pages/projects/project-search/project-search.wxss

@@ -4,7 +4,7 @@
   background-color: #fff;
 }
 .projects {
-  padding-top: 25rpx;
+  padding-top: 130rpx;
 }
 .projectbg {
   background-color: #fff;
@@ -141,4 +141,42 @@
   font-size: 20rpx;
   text-align: center;
   line-height: 38rpx;
+}
+
+
+
+.searchbox{
+	background: #eab86a;
+	    padding: 15rpx;
+	    position: fixed;
+	    width: 100%;
+	    z-index: 99;
+	    left: 0;
+	    box-sizing: border-box;
+}
+.searchtxt{
+	 background: #fff;
+	 padding: 10rpx 15rpx;
+	 border-radius: 45rpx;   
+	    
+}
+.searchtxt input{
+padding-left: 55rpx;
+    width: 80%;
+    display: inline-block;
+    line-height: 35rpx;
+    vertical-align: middle;
+    box-sizing: border-box;
+}
+.searchtxt button{
+	width: 20%;
+	    display: inline-block;
+	    font-size: 30rpx;
+	    line-height: 20rpx;
+	    padding: 20rpx 15rpx;
+	    background: #eab86a;
+	    border-radius: 45rpx;
+	    vertical-align: middle;
+	    color: #FFF;
+	    box-sizing: border-box;
 }

+ 33 - 2
pages/projects/projects.js

@@ -12,9 +12,21 @@ Page({
     navScrollLeft: 0,
     balance: 0,
     todaysend: Date.parse(new Date()) / 1000,
-	searchword:''
+	searchword:'',
+	
+	statusBarHeight:20,
+	navBarHeight:45,
+	windowWidth:375,
+	word:''
   },
   onLoad: function (options) {
+	  const info = wx.getSystemInfoSync();
+	  console.log('info',info);
+	  this.setData({
+	  		statusBarHeight:info.statusBarHeight
+	  })
+	  
+	  this.getData()
     this.getBalanceInfo()
     this.setData({
       vershow: getApp().globalData.vershow,
@@ -74,6 +86,19 @@ Page({
       this.getProjects()
     }
   },
+  getData: function () {
+    var that = this
+    var url = 'v1/product/commend_words'
+  	var params = {}
+    var success = function (res) {
+      console.log('res',res.data.list);
+  	  that.setData({
+  		  word:res.data.list[0].title
+  	  })
+  	  
+    }
+    _request.$get(url, params, success)
+  },
   getType: function () {
     var that = this
     var url = 'v1/product/cats'
@@ -167,5 +192,11 @@ Page({
       // path: '/pages/start/start?url=pages/projects/projects',
       sc: 'xcx_products'
     })
-  }
+  },
+  tosearch: function (val) {
+    var id = val.currentTarget.dataset.val;
+    wx.navigateTo({
+      url: '/pages/search/search'
+    })
+  },
 })

+ 2 - 1
pages/projects/projects.json

@@ -6,5 +6,6 @@
   },
   "enablePullDownRefresh": true,
   "backgroundColor": "#f2f4f6",
-  "backgroundTextStyle": "dark"
+  "backgroundTextStyle": "dark",
+  "navigationStyle": "custom"
 }

+ 12 - 3
pages/projects/projects.wxml

@@ -1,7 +1,16 @@
 <view class="bg">
-  <view class="projects">
+	<!-- 顶部导航 -->
+	<view class="navbox" style="block;height: {{statusBarHeight + 45}}px;">
+		<view class="navbar" style="top:{{statusBarHeight}}px" bindtap="tosearch">
+			<view class="page__hd">
+				<image src="http://fohow.oss-cn-shenzhen.aliyuncs.com/xcx/search.png"></image>
+				<view class="page__desc">{{word}}</view>
+			</view>
+		</view>
+	</view>
+  <view class="projects" style="padding-top:{{(statusBarHeight + 45) + 50}}px;">
     <view class="projectbg">
-      <view class="scrollview" wx:if="{{vershow}}">
+      <view class="scrollview" wx:if="{{vershow}}" style="top:{{statusBarHeight + 45}}px;">
          <scroll-view scroll-x="true" class="nav" scroll-left="{{navScrollLeft}}" scroll-with-animation="{{true}}">
           <block wx:for="{{navData}}" wx:for-index="idx" wx:for-item="navItem" wx:key="idx">
               <view class="nav-item {{currentTab == idx ?'active':''}}"  data-current="{{idx}}" bindtap="switchNav">{{navItem.name}}</view>
@@ -10,7 +19,7 @@
       </view>
       <view class="project" wx:key="{{index}}" wx:for="{{projects}}"  data-val="{{item.id}}" bindtap="toProject">
         <view class="project-left">
-          <view class="project-title ellipsisLn">{{item.name}}</view>
+          <view class="project-title ellipsisLn"><i wx:if="{{item.pv < item.price}}" style="display: inline-block;background: #F44336;color: #fff;padding: 0px 5px;font-size: 11px;line-height: 35rpx;margin-right: 10rpx;vertical-align: middle;">特惠</i>{{item.name}}</view>
           <view class="project-count">已售{{item.sold_count}}件</view>
           <view class="project-price" style="padding-top:25rpx">
             <image wx:if="{{item.seckill_state === 'seckill'}}" src="http://fohow.oss-cn-shenzhen.aliyuncs.com/xcx/image/icon/miaosha.png" class="project-miaosha-img"/>

+ 37 - 0
pages/projects/projects.wxss

@@ -141,4 +141,41 @@
   font-size: 20rpx;
   text-align: center;
   line-height: 38rpx;
+}
+
+
+.navbar{
+	position: absolute;
+	    /* top: 50rpx; */
+	    z-index: 999;
+	    background: rgba(255,255,255,0.75);
+	    left: 15rpx;
+	    width: 70%;
+	    border-radius: 45rpx;
+			margin-top: 14rpx;
+}
+.page__hd{padding: 6rpx 35rpx;}
+.page__hd image{
+	width: 30rpx;
+	    height: 30rpx;
+	    display: inline-block;
+	    vertical-align: middle;
+}
+.page__title{    float: left;}
+.page__desc{
+	    display: inline-block;
+	    padding-left: 20rpx;
+	    color: #666;
+	        font-size: 28rpx;
+}
+
+.navbox{
+	background: #eab86a;
+	    overflow: hidden;
+	    display: block;
+	    position: fixed;
+	    top: 0;
+	    left: 0;
+	    width: 100%;
+	    z-index: 999;
 }

+ 1 - 1
pages/search/search.wxml

@@ -1,7 +1,7 @@
 <view class="bg">
 	<view class="searchbox">
 		<view class="searchtxt">
-			<input type="text" placeholder="{{wordlist[0].title}}" auto-focus bindinput="bindword"/>
+			<input type="text" placeholder="{{wordlist[0].title}}" value="{{searchword}}" auto-focus bindinput="bindword"/>
 			<button bindtap="tosearch">搜索</button>
 		</view>
 	</view>