hwq 1 yıl önce
ebeveyn
işleme
a491069623
2 değiştirilmiş dosya ile 775 ekleme ve 665 silme
  1. 389 320
      pages/money/pay.vue
  2. 386 345
      pages/product/search.vue

+ 389 - 320
pages/money/pay.vue

@@ -11,13 +11,17 @@
 					<text class="tit">微信支付</text>
 					<text>推荐使用微信支付</text>
 				</view>
-				<label class="radio"><radio value="" color="#5dbc7c" :checked="payType == 1"></radio></label>
+				<label class="radio">
+					<radio value="" color="#5dbc7c" :checked="payType == 1"></radio>
+				</label>
 			</view>
 			<!-- #ifdef APP-PLUS -->
 			<view class="type-item b-b" @click="changePayType(2)">
 				<text class="icon iconfont iconzhifubao"></text>
 				<view class="con"><text class="tit">支付宝支付</text></view>
-				<label class="radio"><radio value="" color="#5dbc7c" :checked="payType == 2"></radio></label>
+				<label class="radio">
+					<radio value="" color="#5dbc7c" :checked="payType == 2"></radio>
+				</label>
 			</view>
 			<!-- #endif -->
 			<view class="type-item" @click="changePayType(3)">
@@ -26,7 +30,19 @@
 					<text class="tit">余额支付</text>
 					<text>可用余额 ¥{{ now_money }}</text>
 				</view>
-				<label class="radio"><radio value="" color="#5dbc7c" :checked="payType == 3"></radio></label>
+				<label class="radio">
+					<radio value="" color="#5dbc7c" :checked="payType == 3"></radio>
+				</label>
+			</view>
+			<view class="type-item" @click="changePayType(4)">
+				<text class="icon iconfont iconyue"></text>
+				<view class="con">
+					<text class="tit">佣金支付</text>
+					<text>可用佣金 ¥{{ breake }}</text>
+				</view>
+				<label class="radio">
+					<radio value="" color="#5dbc7c" :checked="payType == 4"></radio>
+				</label>
 			</view>
 		</view>
 		<text class="mix-btn" :class="{ clickbg: payLoding }" @click="!payLoding ? confirm() : ''">确认支付</text>
@@ -34,350 +50,403 @@
 </template>
 
 <script>
-import { balance } from '@/api/wallet.js';
-import { createOrderkey,computedOrderkey,orderPay } from '@/api/order.js';
-import { mapState } from 'vuex';
-// #ifdef H5
-import weichatObj from '@/plugin/jweixin-module/index.js';
-// #endif
-export default {
-	data() {
-		return {
-			payType: 1, //支付类型
-			// #ifdef H5
-			payName: 'weixin',
-			// #endif
-			// #ifdef MP-WEIXIN
-			payName: 'weixin',
-			// #endif
-			orderInfo: {},
-			money: 0.0, //订单金额
-			now_money: 0.0, //余额
-			orderKey: '',
-			orderId: '', //保存订单id
-			payLoding: false, //判断是否支付中
-			type: '', //判断是否从订单中进入
-			// #ifdef H5
-			froms: '', //保存h5中数据来源对象
-			// #endif
-			pinkid: '' //保存拼团商品id
-		};
-	},
-	computed: {
-		// #ifdef H5
-		...mapState(['weichatObj']),
-		// #endif
-		...mapState('user',['userInfo'])
-	},
-	onLoad(options) {
-		if (options.type == 1) {
-			this.type = 1;
-			this.orderId = options.ordid;
-			this.money = options.money;
-		} else {
-			this.orderKey = options.key;
-			let prepage = this.$api.prePage();
-			computedOrderkey({
-				orderkey: this.orderKey,
-				couponId: prepage.couponChecked.id, //优惠券编号
-				addressId: prepage.addressData.id, //地址编号
-				useIntegral: prepage.checkedPoints ? 1 : 0
-			}).then(({ data }) => {
-				// 获取支付金额
-				this.money = data.result.pay_price;
-			});
-		}
-		// 保存pinkid
-		if (options.pinkid) {
-			this.pinkid = options.pinkid;
-		}
-		// 载入余额
-		balance({}).then(({ data }) => {
-			// 获取余额
-			this.now_money = data.now_money;
-		});
-	},
-	methods: {
-		//选择支付方式
-		changePayType(type) {
-			this.payType = type;
-			if (this.payType == 1) {
-				this.payName = 'weixin';
-			}
-			if (this.payType == 2) {
-				this.payName = 'ali';
-			}
-			if (this.payType == 3) {
-				this.payName = 'yue';
-			}
-		},
-		// 支付金额
-		orderMoneyPay() {
-			let obj = this;
-			console.log('支付金额')
-			orderPay({
-				uni: obj.orderId,
+	import {
+		getUserInfo
+	} from '@/api/user.js'
+	import {
+		createOrderkey,
+		computedOrderkey,
+		orderPay
+	} from '@/api/order.js';
+	import {
+		mapState
+	} from 'vuex';
+	// #ifdef H5
+	import weichatObj from '@/plugin/jweixin-module/index.js';
+	// #endif
+	export default {
+		data() {
+			return {
+				payType: 1, //支付类型
 				// #ifdef H5
-				from: obj.froms ? 'weixin' : 'H5', //来源
+				payName: 'weixin',
 				// #endif
 				// #ifdef MP-WEIXIN
-				from: 'routine', //来源
+				payName: 'weixin',
 				// #endif
-				// #ifdef APP-PLUS
-				from: 'app', //来源
+				orderInfo: {},
+				money: 0.0, //订单金额
+				now_money: 0.0, //余额
+				breake: 0.0, //佣金
+				orderKey: '',
+				orderId: '', //保存订单id
+				payLoding: false, //判断是否支付中
+				type: '', //判断是否从订单中进入
+				// #ifdef H5
+				froms: '', //保存h5中数据来源对象
 				// #endif
-				paytype: obj.payName //支付类型  weixin-微信 yue-余额
-			})
-				.then(e => {
-					console.log(obj.payName,'支付类型')
-					console.log(e,'支付金额')
-					// 判断是否为余额支付
-					if (obj.payName == 'yue' && e.data.status == 'SUCCESS') {
-						if (e.status == 200) {
-							obj.paySuccessTo();
-						} else {
-							obj.$api.msg(msg);
-						}
-					}
-					if (obj.payName == 'weixin' || obj.payName == 'routine') {
-						let da = e.data.result.jsConfig;
-						let data = {
-							// #ifdef H5
-							timestamp: da.timestamp,
-							// #endif
-							// #ifdef MP
-							timeStamp: da.timestamp,
-							// #endif
-							nonceStr: da.nonceStr,
-							package: da.package,
-							signType: da.signType,
-							paySign: da.paySign,
-							success: function(res) {
-								obj.paySuccessTo();
-							},
-							fail: () => {
-								
-								uni.navigateTo({
-									url: '/pages/order/order?state=0'
-								});
-							}
-						};
-						// #ifdef H5
-						if(obj.payName == 'weixin'){
-						weichatObj.chooseWXPay(data);
-						}
-						// #endif
-						// #ifdef MP-WEIXIN
-						if(obj.payName == 'weixin' || obj.payName == 'routine' ){
-							console.log('开始支付')
-							wx.requestPayment(data);
-						}
-						// #endif
-					}
-					uni.hideLoading();
-					obj.payLoding = false;
-				})
-				.catch(e => {
-					// 支付完成
-					uni.hideLoading();
-					obj.payLoding = false;
-					console.log(e);
-				});
-		},
-		// 支付成功跳转
-		paySuccessTo() {
-			let obj = this
-			uni.hideLoading();
-			uni.redirectTo({
-				url: '/pages/money/paySuccess?orderid=' + this.orderId
-			});
-			
+				pinkid: '' //保存拼团商品id
+			};
 		},
-		//确认支付
-		confirm: async function() {
-			let obj = this;
-			// 判断是否余额不足
-			if (obj.payName == 'yue' && +obj.now_money < obj.money) {
-				uni.showModal({
-					title: '提示',
-					content: '账户余额不足!',
-					showCancel: false,
-					success: res => {},
-					fail: () => {},
-					complete: () => {}
-				});
-				return;
-			}
-			uni.showLoading({
-				title: '支付中',
-				mask: true
-			})
-			
-			// 支付中
-			obj.payLoding = true;
+		computed: {
 			// #ifdef H5
-			// 获取当前是否为微信浏览器
-			obj.froms = uni.getStorageSync('weichatBrowser') || '';
+			...mapState(['weichatObj']),
 			// #endif
-			// 判断是否为未支付订单中跳转进入
-			if (obj.type != 1) {
-				// 初次生成订单
-				obj.firstCreateOrder();
+			...mapState('user', ['userInfo'])
+		},
+		onLoad(options) {
+			if (options.type == 1) {
+				this.type = 1;
+				this.orderId = options.ordid;
+				this.money = options.money;
 			} else {
-				// 已经生成订单未支付
-				obj.orderMoneyPay();
+				this.orderKey = options.key;
+				let prepage = this.$api.prePage();
+				computedOrderkey({
+					orderkey: this.orderKey,
+					couponId: prepage.couponChecked.id, //优惠券编号
+					addressId: prepage.addressData.id, //地址编号
+					useIntegral: prepage.checkedPoints ? 1 : 0
+				}).then(({
+					data
+				}) => {
+					// 获取支付金额
+					this.money = data.result.pay_price;
+				});
+			}
+			// 保存pinkid
+			if (options.pinkid) {
+				this.pinkid = options.pinkid;
 			}
+			// 载入余额
+			getUserInfo({}).then(({
+				data
+			}) => {
+				// 获取余额
+				this.now_money = data.now_money;
+				this.breake = data.brokerage_price
+			});
 		},
-		// 初次订单创建
-		firstCreateOrder() {
-			let obj = this;
-			// 获取下单页面数据
-			let prepage = obj.$api.prePage();
+		methods: {
+			//选择支付方式
+			changePayType(type) {
+				this.payType = type;
+				if (this.payType == 1) {
+					this.payName = 'weixin';
+				}
+				if (this.payType == 2) {
+					this.payName = 'ali';
+				}
+				if (this.payType == 3) {
+					this.payName = 'yue';
+				}
+				if (this.payType == 4) {
+					this.payName = 'brokerage';
+				}
+			},
+			// 支付金额
+			orderMoneyPay() {
+				let obj = this;
+				console.log('支付金额')
+				orderPay({
+						uni: obj.orderId,
+						// #ifdef H5
+						from: obj.froms ? 'weixin' : 'H5', //来源
+						// #endif
+						// #ifdef MP-WEIXIN
+						from: 'routine', //来源
+						// #endif
+						// #ifdef APP-PLUS
+						from: 'app', //来源
+						// #endif
+						paytype: obj.payName //支付类型  weixin-微信 yue-余额
+					})
+					.then(e => {
+						console.log(obj.payName, '支付类型')
+						console.log(e, '支付金额')
+						// 判断是否为余额支付
+						if (obj.payName == 'yue' && e.data.status == 'SUCCESS') {
+							if (e.status == 200) {
+								obj.paySuccessTo();
+							} else {
+								obj.$api.msg(msg);
+							}
+						}
+						if (obj.payName == 'brokerage' && e.data.status == 'SUCCESS') {
+							if (e.status == 200) {
+								obj.paySuccessTo();
+							} else {
+								obj.$api.msg(msg);
+							}
+						}
+						if (obj.payName == 'weixin' || obj.payName == 'routine') {
+							let da = e.data.result.jsConfig;
+							let data = {
+								// #ifdef H5
+								timestamp: da.timestamp,
+								// #endif
+								// #ifdef MP
+								timeStamp: da.timestamp,
+								// #endif
+								nonceStr: da.nonceStr,
+								package: da.package,
+								signType: da.signType,
+								paySign: da.paySign,
+								success: function(res) {
+									obj.paySuccessTo();
+								},
+								fail: () => {
 
-			let data = {
-				real_name: prepage.addressData.real_name, //联系人名称
-				phone: prepage.addressData.phone, //联系人号码
-				couponId: prepage.couponChecked.id, //优惠券编号
-				addressId: prepage.addressData.id, //支付地址id
-				useIntegral: prepage.checkedPoints ? 1 : 0, //是否积分抵扣1为是0为否
-				payType: obj.payName, //支付类型  weixin-微信 yue-余额
-				mark: prepage.desc, //备注
-				// #ifdef H5
-				from: obj.froms ? 'weixin' : 'H5', //来源
-				// #endif
-				// #ifdef MP-WEIXIN
-				from: 'routine', //来源
-				// #endif
-				// #ifdef APP-PLUS
-				from: 'app', //来源
-				// #endif
-				shipping_type: 1 //提货方式 1 快递 2自提
-			};
-			// 判断是否拼团商品
-			if (obj.pinkid) {
-				data.pinkId = obj.pinkid;
-			}
-			// 生成订单
-			createOrderkey(data, obj.orderKey)
-				.then(({ data, status, msg }) => {
-					console.log('生成订单')
-					// 判断是否支付失败
-					if (data.status == 'ORDER_EXIST') {
-						uni.showModal({
-							title: '提示',
-							content: msg,
-							showCancel: false
-						});
+									uni.navigateTo({
+										url: '/pages/order/order?state=0'
+									});
+								}
+							};
+							// #ifdef H5
+							if (obj.payName == 'weixin') {
+								weichatObj.chooseWXPay(data);
+							}
+							// #endif
+							// #ifdef MP-WEIXIN
+							if (obj.payName == 'weixin' || obj.payName == 'routine') {
+								console.log('开始支付')
+								wx.requestPayment(data);
+							}
+							// #endif
+						}
+						uni.hideLoading();
+						obj.payLoding = false;
+					})
+					.catch(e => {
+						// 支付完成
 						uni.hideLoading();
 						obj.payLoding = false;
-						return;
-					}
-					// 保存订单号
-					obj.orderId = data.result.orderId;
-					// 判断是否为余额支付
-					if (obj.payName == 'yue') {
-						if (status == 200 && data.status == 'SUCCESS') {
-							obj.paySuccessTo();
+						console.log(e);
+					});
+			},
+			// 支付成功跳转
+			paySuccessTo() {
+				let obj = this
+				uni.hideLoading();
+				uni.redirectTo({
+					url: '/pages/money/paySuccess?orderid=' + this.orderId
+				});
+
+			},
+			//确认支付
+			confirm: async function() {
+				let obj = this;
+				// 判断是否余额不足
+				if (obj.payName == 'yue' && +obj.now_money < obj.money) {
+					uni.showModal({
+						title: '提示',
+						content: '账户余额不足!',
+						showCancel: false,
+						success: res => {},
+						fail: () => {},
+						complete: () => {}
+					});
+					return;
+				}
+				if (obj.payName == 'brokerage' && +obj.breake < obj.money) {
+					uni.showModal({
+						title: '提示',
+						content: '账户余额不足!',
+						showCancel: false,
+						success: res => {},
+						fail: () => {},
+						complete: () => {}
+					});
+					return;
+				}
+				uni.showLoading({
+					title: '支付中',
+					mask: true
+				})
+
+				// 支付中
+				obj.payLoding = true;
+				// #ifdef H5
+				// 获取当前是否为微信浏览器
+				obj.froms = uni.getStorageSync('weichatBrowser') || '';
+				// #endif
+				// 判断是否为未支付订单中跳转进入
+				if (obj.type != 1) {
+					// 初次生成订单
+					obj.firstCreateOrder();
+				} else {
+					// 已经生成订单未支付
+					obj.orderMoneyPay();
+				}
+			},
+			// 初次订单创建
+			firstCreateOrder() {
+				let obj = this;
+				// 获取下单页面数据
+				let prepage = obj.$api.prePage();
+
+				let data = {
+					real_name: prepage.addressData.real_name, //联系人名称
+					phone: prepage.addressData.phone, //联系人号码
+					couponId: prepage.couponChecked.id, //优惠券编号
+					addressId: prepage.addressData.id, //支付地址id
+					useIntegral: prepage.checkedPoints ? 1 : 0, //是否积分抵扣1为是0为否
+					payType: obj.payName, //支付类型  weixin-微信 yue-余额
+					mark: prepage.desc, //备注
+					// #ifdef H5
+					from: obj.froms ? 'weixin' : 'H5', //来源
+					// #endif
+					// #ifdef MP-WEIXIN
+					from: 'routine', //来源
+					// #endif
+					// #ifdef APP-PLUS
+					from: 'app', //来源
+					// #endif
+					shipping_type: 1 //提货方式 1 快递 2自提
+				};
+				// 判断是否拼团商品
+				if (obj.pinkid) {
+					data.pinkId = obj.pinkid;
+				}
+				// 生成订单
+				createOrderkey(data, obj.orderKey)
+					.then(({
+						data,
+						status,
+						msg
+					}) => {
+						console.log('生成订单')
+						// 判断是否支付失败
+						if (data.status == 'ORDER_EXIST') {
+							uni.showModal({
+								title: '提示',
+								content: msg,
+								showCancel: false
+							});
+							uni.hideLoading();
+							obj.payLoding = false;
+							return;
+						}
+						// 保存订单号
+						obj.orderId = data.result.orderId;
+						// 判断是否为余额支付
+						if (obj.payName == 'yue') {
+							if (status == 200 && data.status == 'SUCCESS') {
+								obj.paySuccessTo();
+							} else {
+								obj.$api.msg(msg);
+							}
+						} else if (obj.payName == 'brokerage') {
+							if (status == 200 && data.status == 'SUCCESS') {
+								obj.paySuccessTo();
+							} else {
+								obj.$api.msg(msg);
+							}
 						} else {
-							obj.$api.msg(msg);
+							// 立即支付
+							obj.orderMoneyPay();
 						}
-					} else {
-						// 立即支付
-						obj.orderMoneyPay();
-					}
-				})
-				.catch(e => {
-					uni.hideLoading();
-					obj.payLoding = false;
-					console.log(e);
-				});
+					})
+					.catch(e => {
+						uni.hideLoading();
+						obj.payLoding = false;
+						console.log(e);
+					});
+			}
 		}
-	}
-};
+	};
 </script>
 
 <style lang="scss">
-.app {
-	width: 100%;
-}
-
-.price-box {
-	background-color: #fff;
-	height: 265upx;
-	display: flex;
-	flex-direction: column;
-	justify-content: center;
-	align-items: center;
-	font-size: 28upx;
-	color: #909399;
-
-	.price {
-		font-size: 50upx;
-		color: #303133;
-		margin-top: 12upx;
-		&:before {
-			content: '¥';
-			font-size: 40upx;
-		}
+	.app {
+		width: 100%;
 	}
-}
 
-.pay-type-list {
-	margin-top: 20upx;
-	background-color: #fff;
-	padding-left: 60upx;
-	.type-item {
-		height: 120upx;
-		padding: 20upx 0;
+	.price-box {
+		background-color: #fff;
+		height: 265upx;
 		display: flex;
-		justify-content: space-between;
+		flex-direction: column;
+		justify-content: center;
 		align-items: center;
-		padding-right: 60upx;
-		font-size: 30upx;
-		position: relative;
-	}
+		font-size: 28upx;
+		color: #909399;
 
-	.icon {
-		width: 100upx;
-		font-size: 52upx;
-	}
-	.iconyue {
-		color: #fe8e2e;
-	}
-	.iconweixin {
-		color: #36cb59;
-	}
-	.iconzhifubao {
-		color: #01aaef;
+		.price {
+			font-size: 50upx;
+			color: #303133;
+			margin-top: 12upx;
+
+			&:before {
+				content: '¥';
+				font-size: 40upx;
+			}
+		}
 	}
-	.tit {
-		font-size: $font-lg;
-		color: $font-color-dark;
-		margin-bottom: 4upx;
+
+	.pay-type-list {
+		margin-top: 20upx;
+		background-color: #fff;
+		padding-left: 60upx;
+
+		.type-item {
+			height: 120upx;
+			padding: 20upx 0;
+			display: flex;
+			justify-content: space-between;
+			align-items: center;
+			padding-right: 60upx;
+			font-size: 30upx;
+			position: relative;
+		}
+
+		.icon {
+			width: 100upx;
+			font-size: 52upx;
+		}
+
+		.iconyue {
+			color: #fe8e2e;
+		}
+
+		.iconweixin {
+			color: #36cb59;
+		}
+
+		.iconzhifubao {
+			color: #01aaef;
+		}
+
+		.tit {
+			font-size: $font-lg;
+			color: $font-color-dark;
+			margin-bottom: 4upx;
+		}
+
+		.con {
+			flex: 1;
+			display: flex;
+			flex-direction: column;
+			font-size: $font-sm;
+			color: $font-color-light;
+		}
 	}
-	.con {
-		flex: 1;
+
+	.mix-btn {
 		display: flex;
-		flex-direction: column;
-		font-size: $font-sm;
-		color: $font-color-light;
+		align-items: center;
+		justify-content: center;
+		width: 630upx;
+		height: 80upx;
+		margin: 80upx auto 30upx;
+		font-size: $font-lg;
+		color: #fff;
+		background-color: $base-color;
+		border-radius: 10upx;
+		/* box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4); */
 	}
-}
-.mix-btn {
-	display: flex;
-	align-items: center;
-	justify-content: center;
-	width: 630upx;
-	height: 80upx;
-	margin: 80upx auto 30upx;
-	font-size: $font-lg;
-	color: #fff;
-	background-color: $base-color;
-	border-radius: 10upx;
-	/* box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4); */
-}
 
-.clickbg {
-	background-color: $color-gray !important;
-}
-</style>
+	.clickbg {
+		background-color: $color-gray !important;
+	}
+</style>

+ 386 - 345
pages/product/search.vue

@@ -26,23 +26,30 @@
 					<view class="nav-item" :class="{ current: searchType === 1 }" @click="sortTab(1)">
 						<text>销量优先</text>
 						<view class="p-box">
-							<text :class="{ active: searchType === 1 && numberOrder === 1 }" class="iconfont iconfold"></text>
-							<text :class="{ active: searchType === 1 && numberOrder === 2 }" class="iconfont iconfold xia"></text>
+							<text :class="{ active: searchType === 1 && numberOrder === 1 }"
+								class="iconfont iconfold"></text>
+							<text :class="{ active: searchType === 1 && numberOrder === 2 }"
+								class="iconfont iconfold xia"></text>
 						</view>
 					</view>
 					<view class="nav-item" :class="{ current: searchType === 2 }" @click="sortTab(2)">
 						<text>价格</text>
 						<view class="p-box">
-							<text :class="{ active: searchType === 2 && priceOrder === 1 }" class="iconfont iconfold"></text>
-							<text :class="{ active: searchType === 2 && priceOrder === 2 }" class="iconfont iconfold xia"></text>
+							<text :class="{ active: searchType === 2 && priceOrder === 1 }"
+								class="iconfont iconfold"></text>
+							<text :class="{ active: searchType === 2 && priceOrder === 2 }"
+								class="iconfont iconfold xia"></text>
 						</view>
 					</view>
 					<view class="nav-item" :class="{ current: newOrder == 1 }" @click="newGoodsTab()">新品</view>
 				</view>
 				<scroll-view scroll-y class="cate-list" @scrolltolower='getProducts'>
 					<view class="guess-section">
-						<view v-for="(item, index) in goodsList" :key="index" class="guess-item" @click="navToDetailPage(item)">
-							<view class="image-wrapper"><image :src="item.image" mode="aspectFill"></image></view>
+						<view v-for="(item, index) in goodsList" :key="index" class="guess-item"
+							@click="navToDetailPage(item)">
+							<view class="image-wrapper">
+								<image :src="item.image" mode="aspectFill"></image>
+							</view>
 							<text class="title clamp margin-c-20">{{ item.store_name }}</text>
 							<view class="cmy-hr"></view>
 							<view class="price margin-c-20 flex">
@@ -64,389 +71,423 @@
 </template>
 
 <script>
-import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
-import { searchKeyword, getProducts } from '@/api/product.js';
-export default {
-	components: {
-		uniLoadMore
-	},
-	data() {
-		return {
-			arrlist: [], //热门关键词
-			keyword: '', //关键字
-			list: [], //搜索内容
-			tabCurrentIndex: 0, //切换
-			goodsList: [],
-			limit: 6, //每次加载数据条数
-			page: 1, //当前页数
-			loadingType: 'more', //加载更多状态
-			numberOrder: 1, //1 销量从低到高 2销量从高到低
-			priceOrder: 1, //1 价格从低到高 2价格从高到低
-			newOrder: 0, //0 不是新品 1是新品
-			searchType: 0 //0为默认查询 1为销量 2 为价格
-		};
-	},
-	// #ifndef MP
-	//点击导航栏 buttons 时触发
-	onNavigationBarButtonTap(e) {
-		const index = e.index;
-		if (index === 0) {
+	import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
+	import {
+		searchKeyword,
+		getProducts
+	} from '@/api/product.js';
+	export default {
+		components: {
+			uniLoadMore
+		},
+		data() {
+			return {
+				arrlist: [], //热门关键词
+				keyword: '', //关键字
+				list: [], //搜索内容
+				tabCurrentIndex: 0, //切换
+				goodsList: [],
+				limit: 6, //每次加载数据条数
+				page: 1, //当前页数
+				loadingType: 'more', //加载更多状态
+				numberOrder: 1, //1 销量从低到高 2销量从高到低
+				priceOrder: 1, //1 价格从低到高 2价格从高到低
+				newOrder: 0, //0 不是新品 1是新品
+				searchType: 0 //0为默认查询 1为销量 2 为价格
+			};
+		},
+		// #ifndef MP
+		//点击导航栏 buttons 时触发
+		onNavigationBarButtonTap(e) {
+			const index = e.index;
+			if (index === 0) {
+				this.navTo();
+			}
+		},
+		// 点击键盘搜索事件
+		onNavigationBarSearchInputConfirmed(e) {
 			this.navTo();
-		}
-	},
-	// 点击键盘搜索事件
-	onNavigationBarSearchInputConfirmed(e) {
-		this.navTo();
-	},
-	// 搜索栏内容变化事件
-	onNavigationBarSearchInputChanged(e) {
-		this.keyword = e.text;
-	},
-	// #endif
-	onLoad() {
-		this.loadData();
-	},
-	//下拉刷新
+		},
+		// 搜索栏内容变化事件
+		onNavigationBarSearchInputChanged(e) {
+			this.keyword = e.text;
+		},
+		// #endif
+		onLoad() {
+			this.loadData();
+		},
+		//下拉刷新
 		onPullDownRefresh() {
 			this.page = 1
 			this.getProducts('refresh');
 		},
-	methods: {
-		// 加载商品
-		async getProducts(type, loading) {
-			let obj = this;
-			// 判断是否为加载数据
-			if (type !== 'refresh') {
-				//没有更多数据直接跳出方法
-				if (obj.loadingType === 'nomore') {
-					return;
+		methods: {
+			// 加载商品
+			async getProducts(type, loading) {
+				let obj = this;
+				// 判断是否为加载数据
+				if (type !== 'refresh') {
+					//没有更多数据直接跳出方法
+					if (obj.loadingType === 'nomore') {
+						return;
+					} else {
+						// 设置当前为数据载入中
+						obj.loadingType = 'loading';
+					}
 				} else {
-					// 设置当前为数据载入中
-					obj.loadingType = 'loading';
+					//当重新加载数据时更新状态为可继续添加数据
+					obj.loadingType = 'more';
 				}
-			} else {
-				//当重新加载数据时更新状态为可继续添加数据
-				obj.loadingType = 'more';
-			}
-			let data = {
-				page: obj.page,
-				limit: obj.limit,
-				news: obj.newOrder,
-				keyword: this.keyword
-			};
-			// 判断是否为销售数量排序
-			if (this.searchType === 1) {
-				data.salesOrder = obj.numberOrder === 1 ? 'asc' : 'desc';
-			}
-			// 判断是否为金额排序
-			if (this.searchType === 2) {
-				data.priceOrder = obj.priceOrder === 1 ? 'asc' : 'desc';
-			}
-			getProducts(data).then(e => {
-				if (type === 'refresh') {
-					obj.goodsList = [];
+				let data = {
+					page: obj.page,
+					limit: obj.limit,
+					news: obj.newOrder,
+					keyword: this.keyword,
+					store_region: 1
+				};
+				// 判断是否为销售数量排序
+				if (this.searchType === 1) {
+					data.salesOrder = obj.numberOrder === 1 ? 'asc' : 'desc';
 				}
-				obj.goodsList = obj.goodsList.concat(e.data);
-				//判断是否还有下一页,有是more  没有是nomore
-				if (obj.limit == e.data.length) {
-					obj.page++;
-					obj.loadingType = 'more';
-				} else {
-					obj.loadingType = 'nomore';
+				// 判断是否为金额排序
+				if (this.searchType === 2) {
+					data.priceOrder = obj.priceOrder === 1 ? 'asc' : 'desc';
 				}
-				// 判断是否为刷新数据
-				if (type === 'refresh') {
-					// 判断是否为点击搜索按钮跳转加载
-					if (loading == 1) {
-						uni.hideLoading();
+				getProducts(data).then(e => {
+					if (type === 'refresh') {
+						obj.goodsList = [];
+					}
+					obj.goodsList = obj.goodsList.concat(e.data);
+					//判断是否还有下一页,有是more  没有是nomore
+					if (obj.limit == e.data.length) {
+						obj.page++;
+						obj.loadingType = 'more';
 					} else {
-						uni.stopPullDownRefresh();
+						obj.loadingType = 'nomore';
+					}
+					// 判断是否为刷新数据
+					if (type === 'refresh') {
+						// 判断是否为点击搜索按钮跳转加载
+						if (loading == 1) {
+							uni.hideLoading();
+						} else {
+							uni.stopPullDownRefresh();
+						}
 					}
+				});
+			},
+			// 点击关键词触发事件
+			clickHotText(e) {
+				this.keyword = e;
+				this.navTo();
+			},
+			// 加载搜索关键字
+			async loadData() {
+				searchKeyword({})
+					.then(e => {
+						this.list = e.data;
+					})
+					.catch(e => {
+						console.log(e);
+					});
+			},
+			// 点击触发搜索事件
+			navTo() {
+				this.tabCurrentIndex = 1;
+				this.infoData()
+			},
+			// 默认搜索
+			defaultSearch() {
+				// 初始化查询
+				this.numberOrder = '';
+				this.priceOrder = '';
+				this.newOrder = 0;
+				this.searchType = 0;
+				this.infoData();
+			},
+			// 是否为新品
+			newGoodsTab() {
+				this.newOrder = this.newOrder === 1 ? 0 : 1;
+				this.infoData();
+			},
+			// 排序
+			sortTab(nub) {
+				this.searchType = nub;
+				if (this.searchType === 1) {
+					this.numberOrder = this.numberOrder === 1 ? 2 : 1;
 				}
-			});
-		},
-		// 点击关键词触发事件
-		clickHotText(e) {
-			this.keyword = e;
-			this.navTo();
-		},
-		// 加载搜索关键字
-		async loadData() {
-			searchKeyword({})
-				.then(e => {
-					this.list = e.data;
-				})
-				.catch(e => {
-					console.log(e);
+				if (this.searchType === 2) {
+					this.priceOrder = this.priceOrder === 1 ? 2 : 1;
+				}
+				this.infoData();
+			},
+			// 查询切换后初始化
+			infoData() {
+				// 初始化页数
+				this.page = 1;
+				// 初始化数组
+				uni.pageScrollTo({
+					duration: 300,
+					scrollTop: 0
+				});
+				// 加载数据
+				this.getProducts('refresh', 1);
+				uni.showLoading({
+					title: '正在加载'
+				});
+			},
+			navToDetailPage(item) {
+				//测试数据没有写id,用title代替
+				let id = item.id;
+				uni.navigateTo({
+					url: '/pages/product/product?id=' + id
 				});
-		},
-		// 点击触发搜索事件
-		navTo() {
-			this.tabCurrentIndex = 1;
-			this.infoData()
-		},
-		// 默认搜索
-		defaultSearch() {
-			// 初始化查询
-			this.numberOrder = '';
-			this.priceOrder = '';
-			this.newOrder = 0;
-			this.searchType = 0;
-			this.infoData();
-		},
-		// 是否为新品
-		newGoodsTab() {
-			this.newOrder = this.newOrder === 1 ? 0 : 1;
-			this.infoData();
-		},
-		// 排序
-		sortTab(nub) {
-			this.searchType = nub;
-			if (this.searchType === 1) {
-				this.numberOrder = this.numberOrder === 1 ? 2 : 1;
-			}
-			if (this.searchType === 2) {
-				this.priceOrder = this.priceOrder === 1 ? 2 : 1;
 			}
-			this.infoData();
-		},
-		// 查询切换后初始化
-		infoData() {
-			// 初始化页数
-			this.page = 1;
-			// 初始化数组
-			uni.pageScrollTo({
-				duration: 300,
-				scrollTop: 0
-			});
-			// 加载数据
-			this.getProducts('refresh', 1);
-			uni.showLoading({
-				title: '正在加载'
-			});
-		},
-		navToDetailPage(item) {
-			//测试数据没有写id,用title代替
-			let id = item.id;
-			uni.navigateTo({
-				url: '/pages/product/product?id=' + id
-			});
 		}
-	}
-};
+	};
 </script>
 
 <style lang="scss">
-page,
-.content {
-	height: 100%;
-	background-color: $page-color-base;
-}
-/* #ifdef MP || APP-PLUS */
-.vheight{
-	height: var(--status-bar-height);
-	background-color: #FFFFFF;
-}
-.input-box {
-	padding: 25rpx;
-	background-color: #ffffff;
-	height: 44px;
-	.iconsearch {
-		font-size: 50rpx;
-	}
-	.input-content {
-		border-radius: 99rpx;
-		flex-grow: 1;
-		padding: 10rpx 30rpx;
-		background-color: rgba(231, 231, 231, 0.7);
-		.input {
-			flex-grow: 1;
-			input {
-				font-size: $font-lg;
-			}
-		}
-	}
-	.input-button {
-		padding-left: 20rpx;
-		font-size: $font-lg;
+	page,
+	.content {
 		height: 100%;
+		background-color: $page-color-base;
 	}
-}
-/* #endif */
 
-.swiper-box {
-	/* #ifndef MP */
-	height: 100%;
-	/* #endif */
-	/* #ifdef MP */
-	height: calc(100% - 44px);
-	/* #endif */
-	.search-hot {
+	/* #ifdef MP || APP-PLUS */
+	.vheight {
+		height: var(--status-bar-height);
+		background-color: #FFFFFF;
+	}
+
+	.input-box {
 		padding: 25rpx;
-		.title {
-			font-size: $font-lg;
-			color: $font-color-light;
+		background-color: #ffffff;
+		height: 44px;
+
+		.iconsearch {
+			font-size: 50rpx;
 		}
-		.hot-list {
-			display: flex;
-			flex-wrap: wrap;
-			margin-top: 30rpx;
-			.list-item {
-				padding: 10rpx 20rpx;
-				border: 1px solid $border-color-dark;
-				color: $font-color-dark;
-				font-size: $font-base;
-				margin-right: 20rpx;
-				margin-bottom: 20rpx;
+
+		.input-content {
+			border-radius: 99rpx;
+			flex-grow: 1;
+			padding: 10rpx 30rpx;
+			background-color: rgba(231, 231, 231, 0.7);
+
+			.input {
+				flex-grow: 1;
+
+				input {
+					font-size: $font-lg;
+				}
 			}
 		}
-	}
-}
-
-// 订单
-%icon {
-	margin-right: 10rpx;
-	display: inline-block;
-	padding: 2rpx 10rpx;
-	border: 1rpx solid $color-yellow;
-	color: $color-yellow;
-	line-height: 1;
-	font-size: $font-base;
-	border-radius: 10rpx;
-}
-.guess-section {
-	display: flex;
-	flex-wrap: wrap;
-	.guess-item {
-		overflow: hidden;
-		display: flex;
-		flex-direction: column;
-		width: 48%;
-		margin-bottom: 4%;
-		border-radius: $border-radius-sm;
-		background-color: white;
-		box-shadow: $box-shadow;
-		&:nth-child(2n + 1) {
-			margin-right: 4%;
-		}
-	}
-	.image-wrapper {
-		width: 100%;
-		height: 330rpx;
-		border-radius: 3px;
-		overflow: hidden;
-		image {
-			width: 100%;
+
+		.input-button {
+			padding-left: 20rpx;
+			font-size: $font-lg;
 			height: 100%;
-			opacity: 1;
 		}
 	}
-	.title {
-		font-size: $font-base;
-		color: $font-color-dark;
-		font-weight: bold;
-		line-height: 80rpx;
-	}
-	.price {
-		font-size: $font-lg;
-		color: $font-color-base;
-		font-weight: bold;
-		line-height: 1;
-		line-height: 80rpx;
-	}
 
-	.icon {
-		@extend %icon;
+	/* #endif */
+
+	.swiper-box {
+		/* #ifndef MP */
+		height: 100%;
+		/* #endif */
+		/* #ifdef MP */
+		height: calc(100% - 44px);
+
+		/* #endif */
+		.search-hot {
+			padding: 25rpx;
+
+			.title {
+				font-size: $font-lg;
+				color: $font-color-light;
+			}
+
+			.hot-list {
+				display: flex;
+				flex-wrap: wrap;
+				margin-top: 30rpx;
+
+				.list-item {
+					padding: 10rpx 20rpx;
+					border: 1px solid $border-color-dark;
+					color: $font-color-dark;
+					font-size: $font-base;
+					margin-right: 20rpx;
+					margin-bottom: 20rpx;
+				}
+			}
+		}
 	}
 
-	.detail {
+	// 订单
+	%icon {
+		margin-right: 10rpx;
+		display: inline-block;
+		padding: 2rpx 10rpx;
+		border: 1rpx solid $color-yellow;
+		color: $color-yellow;
 		line-height: 1;
+		font-size: $font-base;
+		border-radius: 10rpx;
 	}
-	.tip {
-		color: white;
-		background-color: $color-yellow;
-		line-height: 1.5;
-		font-size: $font-sm;
-		padding-left: 20rpx;
-	}
-}
-
-.navbar {
-	position: absolute;
-	top: 0;
-	left: 0;
-	display: flex;
-	width: 100%;
-	height: 40px;
-	background: #fff;
-	box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
-	z-index: 10;
-	.nav-item {
-		flex: 1;
+
+	.guess-section {
 		display: flex;
-		justify-content: center;
-		align-items: center;
-		height: 100%;
-		font-size: 30rpx;
-		color: $font-color-dark;
-		position: relative;
-		&.current {
-			color: $base-color;
-			&:after {
-				content: '';
-				position: absolute;
-				left: 50%;
-				bottom: 0;
-				transform: translateX(-50%);
-				width: 120rpx;
-				height: 0;
-				border-bottom: 4rpx solid $base-color;
+		flex-wrap: wrap;
+
+		.guess-item {
+			overflow: hidden;
+			display: flex;
+			flex-direction: column;
+			width: 48%;
+			margin-bottom: 4%;
+			border-radius: $border-radius-sm;
+			background-color: white;
+			box-shadow: $box-shadow;
+
+			&:nth-child(2n + 1) {
+				margin-right: 4%;
 			}
 		}
+
+		.image-wrapper {
+			width: 100%;
+			height: 330rpx;
+			border-radius: 3px;
+			overflow: hidden;
+
+			image {
+				width: 100%;
+				height: 100%;
+				opacity: 1;
+			}
+		}
+
+		.title {
+			font-size: $font-base;
+			color: $font-color-dark;
+			font-weight: bold;
+			line-height: 80rpx;
+		}
+
+		.price {
+			font-size: $font-lg;
+			color: $font-color-base;
+			font-weight: bold;
+			line-height: 1;
+			line-height: 80rpx;
+		}
+
+		.icon {
+			@extend %icon;
+		}
+
+		.detail {
+			line-height: 1;
+		}
+
+		.tip {
+			color: white;
+			background-color: $color-yellow;
+			line-height: 1.5;
+			font-size: $font-sm;
+			padding-left: 20rpx;
+		}
 	}
-	.p-box {
+
+	.navbar {
+		position: absolute;
+		top: 0;
+		left: 0;
 		display: flex;
-		flex-direction: column;
-		.iconfont {
+		width: 100%;
+		height: 40px;
+		background: #fff;
+		box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
+		z-index: 10;
+
+		.nav-item {
+			flex: 1;
 			display: flex;
-			align-items: center;
 			justify-content: center;
-			width: 30rpx;
-			height: 14rpx;
-			line-height: 1;
-			margin-left: 4rpx;
-			font-size: 26rpx;
-			color: #888;
-			&.active {
+			align-items: center;
+			height: 100%;
+			font-size: 30rpx;
+			color: $font-color-dark;
+			position: relative;
+
+			&.current {
 				color: $base-color;
+
+				&:after {
+					content: '';
+					position: absolute;
+					left: 50%;
+					bottom: 0;
+					transform: translateX(-50%);
+					width: 120rpx;
+					height: 0;
+					border-bottom: 4rpx solid $base-color;
+				}
 			}
 		}
-		.xia {
-			transform: scaleY(-1);
+
+		.p-box {
+			display: flex;
+			flex-direction: column;
+
+			.iconfont {
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				width: 30rpx;
+				height: 14rpx;
+				line-height: 1;
+				margin-left: 4rpx;
+				font-size: 26rpx;
+				color: #888;
+
+				&.active {
+					color: $base-color;
+				}
+			}
+
+			.xia {
+				transform: scaleY(-1);
+			}
+		}
+
+		.cate-item {
+			display: flex;
+			justify-content: center;
+			align-items: center;
+			height: 100%;
+			width: 80rpx;
+			position: relative;
+			font-size: 44rpx;
+
+			&:after {
+				content: '';
+				position: absolute;
+				left: 0;
+				top: 50%;
+				transform: translateY(-50%);
+				border-left: 1px solid #ddd;
+				width: 0;
+				height: 36rpx;
+			}
 		}
 	}
-	.cate-item {
-		display: flex;
-		justify-content: center;
-		align-items: center;
+
+	.cate-list {
 		height: 100%;
-		width: 80rpx;
-		position: relative;
-		font-size: 44rpx;
-		&:after {
-			content: '';
-			position: absolute;
-			left: 0;
-			top: 50%;
-			transform: translateY(-50%);
-			border-left: 1px solid #ddd;
-			width: 0;
-			height: 36rpx;
-		}
+		padding-top: 40px;
 	}
-}
-.cate-list {
-	height: 100%;
-	padding-top: 40px;
-}
-</style>
+</style>