Преглед на файлове

【Add】增加允许分享,SKU列表过长缺陷修复

liuxiangxin преди 7 месеца
родител
ревизия
fe7cbae3b3
променени са 7 файла, в които са добавени 118 реда и са изтрити 33 реда
  1. 2 2
      App.vue
  2. 38 5
      pages/index/index.vue
  3. 57 19
      pages/product/index.vue
  4. 7 0
      pages/score/clockin.vue
  5. 7 1
      pages/score/index.vue
  6. 2 1
      pages/user/info.vue
  7. 5 5
      utils/checkaccess.js

+ 2 - 2
App.vue

@@ -1,7 +1,7 @@
 <script>
 	export default {
-		onLaunch: function() {
-			console.log('App Launch')
+		onLaunch: function(param) {
+			console.log(param);
 		},
 		onShow: function() {
 			// #ifdef MP

+ 38 - 5
pages/index/index.vue

@@ -30,11 +30,13 @@
 		</view>
 		<view class="search_fixed" >
 			<view class="search_box">
+				<view class="city_name" v-if="!toSelectedCity">{{cityName}}</view>
+				<navigator url="/pages/user/info" v-if="toSelectedCity" class="city_name uncheck">选城市</navigator>
 				<input class="search_input" type="text" v-model="requestParam.name" @input="searchChange" placeholder="请输入产品名称搜索" />
 				<button class="search_btn" @click.stop="searchOpen()"  data-eventsync="true"> 搜索</button>
 			</view>
 		</view>
-		<view class="to_bottom" v-if="isLast"> -----到底啦-----</view>
+		<view class="to_bottom" v-if="isLast"> -----{{ !productList.length && toSelectedCity?'请选择您的城市':'到底啦'}}-----</view>
 	</view>
 </template>
 
@@ -57,14 +59,30 @@
 				isReqing:false,
 				// 是否显示价格
 				isShowPrice:false,
+				// 城市名称
+				cityName:"选城市",
+				// 选择城市
+				toSelectedCity:false,
 			}
 		},
 		onLoad() {
-			
+			// #ifdef MP-WEIXIN
+			//分享按钮
+			uni.showShareMenu({
+				withShareTicket: true,
+				menus: ['shareAppMessage', 'shareTimeline']
+			})
+			// #endif
 		},
 		onShow() {
 			// 是否显示价格
 			this.isShowPrice 		= this.$checkAccess.checkShowPrice();
+			// 城市名
+			this.cityName			= this.$checkAccess.getCity();
+			// 选城市
+			this.cityName			= this.cityName ? this.cityName : "选城市",
+			// 登录并且未选择城市,才可以选择城市
+			this.toSelectedCity 	= !this.$checkAccess.getCity() ? true : false;
 			// 没有数据的话,或者请求中,不允许刷新
 			if( this.isReqing )		return ;
 			// 获取列表
@@ -198,17 +216,32 @@
 			height: 60rpx;
 			display: block;
 			position: relative;
+			.city_name{
+				float: left;
+				width: 80rpx;
+				height: 60rpx;
+				display: block;
+				font-size: 24rpx;
+				overflow: hidden;
+				margin-left: 35rpx;
+				line-height: 60rpx;
+				white-space: nowrap;
+				text-overflow: ellipsis;
+			}
+			.city_name.uncheck{
+				color: #E03519;
+			}
 			.search_input{
 				z-index: 0;
-				width: 590rpx;
+				float: left;
+				width: 510rpx;
 				height: 56rpx;
 				display: block;
 				font-size: 24rpx;
+				padding-left: 20rpx;
 				position: relative;
 				border-top-left-radius: 40rpx;
 				border-bottom-left-radius: 40rpx;
-				padding-left: 20rpx;
-				margin-left: 35rpx;
 				border: 2rpx solid #dddddd;
 			}
 			.search_btn{

+ 57 - 19
pages/product/index.vue

@@ -83,9 +83,11 @@
 					<view class="product_attr" v-for="(spec,spec_index) in productInfo.product_attr" :key="spec_index">
 						<view class="spec_name">{{ spec.spec_name }}</view>
 						<view class="arrt_list">
-							<view class="arrt_option" :class="option.active?'active':''" v-for="(option,attr_index) in spec.attr_list" :key="attr_index" @click="attrChange(spec_index,attr_index)">
-								{{option.name}}
-							</view>
+							<scroll-view scroll-y="true" class="scroll_y" >
+								<view class="arrt_option" :class="option.active?'active':''" v-for="(option,attr_index) in spec.attr_list" :key="attr_index" @click="attrChange(spec_index,attr_index)">
+									{{option.name}}
+								</view>
+							</scroll-view>
 						</view>
 					</view>
 				</view>
@@ -244,7 +246,14 @@
 			uni.$on('addr_list_change',function(data){
 				// 地址列表
 				that.addrList = data.list;
+			});
+			// #ifdef MP-WEIXIN
+			//分享按钮
+			uni.showShareMenu({
+				withShareTicket: true,
+				menus: ['shareAppMessage', 'shareTimeline']
 			})
+			// #endif
 		},
 		onShow() {
 			// 没有添加客服就不显示
@@ -351,6 +360,15 @@
 					})
 					return;
 				}
+				// 如果大于库存设置为库存
+				if( this.productInfo.stock < this.quantity ) {
+					this.quantity   = this.productInfo.stock;
+					uni.showToast({
+						title:"库存不足",
+						icon:"none"
+					})
+					return;
+				}
 				// 地址未填
 				if( !this.checkedAddr.id ) {
 					uni.showToast({
@@ -396,7 +414,7 @@
 					})
 					return;
 				}
-				// 如果大于库存设置为库存
+				// 如果库存不足
 				if( this.productInfo.stock < 1 ) {
 					uni.showToast({
 						title:"库存不足",
@@ -404,6 +422,15 @@
 					})
 					return;
 				}
+				// 如果大于库存设置为库存
+				if( this.productInfo.stock < this.quantity ) {
+					this.quantity   = this.productInfo.stock;
+					uni.showToast({
+						title:"库存不足",
+						icon:"none"
+					})
+					return;
+				}
 				// 商品信息
 				let data = {product_id:this.productInfo.id,buy_num:this.quantity,skuid:this.sku_id};
 				// 请求接口
@@ -721,7 +748,7 @@
 						// 设置有SKU
 						haveSku	= 1;
 						// 获取当前匹配到的SKU的状态
-						 currentSKUStatus = this.productInfo.product_sku[i].status;
+						currentSKUStatus = this.productInfo.product_sku[i].status;
 						// 如果商品已经下架(status等于1),则恢复当前规格下所有属性原来的active状态
 						if(currentSKUStatus === 1){
 							uni.showToast({title:"该规格已下架",icon:"none"});
@@ -730,6 +757,14 @@
 							}
 							continue;
 						}
+						// 如果商品没有库存
+						if( this.productInfo.product_sku[i].stock <= 0 ){
+							uni.showToast({title:"该规格库存不足",icon:"none"});
+							for (let k in originalActiveStates) {
+								this.productInfo.product_attr[spec_index].attr_list[k].active = originalActiveStates[k];
+							}
+							continue;
+						}
 						// 产品价格修改
 						this.productInfo.price = this.productInfo.product_sku[i].price;
 						// 产品规格修改
@@ -1148,20 +1183,23 @@
 					.arrt_list{
 						display: block;
 						overflow: hidden;
-						.arrt_option{
-							float: left;
-							height: 40rpx;
-							font-size: 28rpx;
-							line-height: 40rpx;
-							text-align: center;
-							border-radius: 6rpx;
-							padding: 10rpx 30rpx;
-							margin: 20rpx;
-							background-color: #EEEEEE;
-						}
-						.arrt_option.active {
-						  color: #FFFFFF;
-						  background-color: #fE6000;
+						.scroll_y{
+							height: 240rpx;
+							.arrt_option{
+								float: left;
+								height: 40rpx;
+								font-size: 28rpx;
+								line-height: 40rpx;
+								text-align: center;
+								border-radius: 6rpx;
+								padding: 10rpx 30rpx;
+								margin: 20rpx;
+								background-color: #EEEEEE;
+							}
+							.arrt_option.active {
+							  color: #FFFFFF;
+							  background-color: #fE6000;
+							}
 						}
 					}
 				}

+ 7 - 0
pages/score/clockin.vue

@@ -73,6 +73,13 @@
 			let menuButtonInfo = uni.getMenuButtonBoundingClientRect();
 			this.status_bar_style = {height:(menuButtonInfo.height)+"px","padding-top":menuButtonInfo.top+"px"};
 			// #endif
+			// #ifdef MP-WEIXIN
+			//分享按钮
+			uni.showShareMenu({
+				withShareTicket: true,
+				menus: ['shareAppMessage', 'shareTimeline']
+			})
+			// #endif
 		},
 		onShow() {
 			// 请求打卡列表

+ 7 - 1
pages/score/index.vue

@@ -43,7 +43,13 @@
 			}
 		},
 		onLoad() {
-			
+			// #ifdef MP-WEIXIN
+			//分享按钮
+			uni.showShareMenu({
+				withShareTicket: true,
+				menus: ['shareAppMessage', 'shareTimeline']
+			})
+			// #endif
 		},
 		onShow() {
 			// 没有数据的话,或者请求中,不允许刷新

+ 2 - 1
pages/user/info.vue

@@ -83,7 +83,8 @@
 				this.cityArray.splice(1,1,getMyCity(this.cityValue[0]));
 			},
 			cityFinish(e){
-				this.requestParam.city_id 		= this.cityArray[1][this.cityValue[1]];
+				this.requestParam.province 	= this.cityArray[0][this.cityValue[0]];
+				this.requestParam.city 		= this.cityArray[1][this.cityValue[1]];
 			},
 		}
 	}

+ 5 - 5
utils/checkaccess.js

@@ -52,15 +52,15 @@ const checkShowPrice	= ()=>{
 }
 
 // 检查城市ID
-const checkCity	= ()=>{
+const getCity	= ()=>{
 	// 获取登录标识
 	let userInfo   	= uni.getStorageSync('userInfo');
 	// 如果不存在的话
-	if( !userInfo )	return false;
+	if( !userInfo )	return '';
 	// 资质ID不存在的话
-	if( !userInfo.city_id ) return false;
+	if( !userInfo.city_id ) return '';
 	// 登录成功
-	return true;
+	return userInfo.city_id;
 }
 
 // 是否要求填写城市
@@ -104,4 +104,4 @@ const getFollowQrcode	= ()=>{
 }
 
 
-export default {checkLogin:checkLogin,alterLogin:alterLogin,checkShowPrice:checkShowPrice,alertCity:alertCity,getFollowQrcode:getFollowQrcode}
+export default {checkLogin:checkLogin,alterLogin:alterLogin,checkShowPrice:checkShowPrice,alertCity:alertCity,getFollowQrcode:getFollowQrcode,getCity:getCity}