liujd 6 лет назад
Родитель
Сommit
1c0e32332a

+ 150 - 145
mobile-code/src/pages/order/buy.vue

@@ -34,7 +34,7 @@
 				</div>
 			</div>
 			<!-- 可选优惠 -->
-			<div class="module-com discount-wrap" v-if="!$util.isEmpty(shopUser) && shopUser.userAsset.member && shopUser.userAsset.getCouponNum">
+			<div class="module-com discount-wrap" v-if="!$util.isEmpty(discountArr)">
 				<div class="module-tit">可选优惠</div>
 				<div class="module-det">
 					<app-coupon-sel ref="couponSel" :price="goodsInfo.price * option.goodsNum" :discountArr="['member', 'coupon']" />
@@ -45,7 +45,7 @@
 			<!-- <div class="none-name-delivery flex-center">
 				<checkbox class="ljd-checkbox" @change="anonymityChange"></checkbox>
 				<span class="none-name-text">匿名派送</span>
-			</div> -->
+			</div>-->
 
 			<app-trademark />
 			<!-- 按钮 -->
@@ -77,159 +77,164 @@
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
-import AppTabs from '@/components/plugin/tabs'
-import TuiListCell from '@/components/plugin/list-cell'
-import AppDeliveryModule from '@/components/app-delivery'
-import AppTrademark from '@/components/module/app-trademark'
-import AppListModule from '@/components/module/app-order-list'
-import AppCouponSel from '@/components/app-coupon-sel'
-import AlertModule from '@/components/plugin/alert'
-const form = require('@/utils/formValidation.js')
-// api
-import { getShopUser } from '@/utils/auth'
-import { getOrderShop } from '@/utils/config'
-import { createOrder } from '@/api/order'
-export default {
-	name: 'order-buy',
-	components: {
-		AppTabs,
-		AppDeliveryModule,
-		TuiListCell,
-		AppListModule,
-		AppCouponSel,
-		AppTrademark,
-		AlertModule
-	},
-	data() {
-		return {
-			goodsInfo: {},
-			tabIndex: 0,
-			tabs: [
-				{
-					name: '配送'
+	import { mapGetters } from 'vuex'
+	import AppTabs from '@/components/plugin/tabs'
+	import TuiListCell from '@/components/plugin/list-cell'
+	import AppDeliveryModule from '@/components/app-delivery'
+	import AppTrademark from '@/components/module/app-trademark'
+	import AppListModule from '@/components/module/app-order-list'
+	import AppCouponSel from '@/components/app-coupon-sel'
+	import AlertModule from '@/components/plugin/alert'
+	const form = require('@/utils/formValidation.js')
+	// api
+	import { getShopUser } from '@/utils/auth'
+	import { getOrderShop } from '@/utils/config'
+	import { createOrder } from '@/api/order'
+	export default {
+		name: 'order-buy',
+		components: {
+			AppTabs,
+			AppDeliveryModule,
+			TuiListCell,
+			AppListModule,
+			AppCouponSel,
+			AppTrademark,
+			AlertModule
+		},
+		data() {
+			return {
+				goodsInfo: {},
+				tabIndex: 0,
+				tabs: [
+					{
+						name: '配送'
+					},
+					{
+						name: '我要自提'
+					}
+				],
+				showAlert: false,
+				// form
+				// 初始form
+				form: {
+					anonymity: '0', // 是否匿名 0不 1要
+					sendDistance: '', // 配送距离,根据腾讯js进行计算
+					goodsId: '', // 【商城下单特有字段】商品id
+					goodsStyleId: '', // 【商城下单特有字段】商品款式id
+					goodsNum: '', // 【商城下单特有字段】商品数量
+					couponId: '0', // 优惠券id,默认0没有使用优惠券
+					receiveLat: '', // 收花人纬度
+					receiveLong: '' // 收花人经度
 				},
-				{
-					name: '我要自提'
-				}
-			],
-			showAlert: false,
-			// form
-			// 初始form
-			form: {
-				anonymity: '0', // 是否匿名 0不 1要
-				sendDistance: '', // 配送距离,根据腾讯js进行计算
-				goodsId: '', // 【商城下单特有字段】商品id
-				goodsStyleId: '', // 【商城下单特有字段】商品款式id
-				goodsNum: '', // 【商城下单特有字段】商品数量
-				couponId: '0', // 优惠券id,默认0没有使用优惠券
-				receiveLat: '', // 收花人纬度
-				receiveLong: '' // 收花人经度
-			},
-			// 自提form
-			mentionForm: {
-				bookMobile: ''
+				// 自提form
+				mentionForm: {
+					bookMobile: ''
+				},
+				discountArr: false
 			}
-		}
-	},
-	computed: {
-		...mapGetters({ orderShop: 'getOrderShop' }),
-		...mapGetters({ shopUser: 'getShopUser' }),
-		// 计算总金额
-		totalPrice() {
-			let totalPrice = this.goodsInfo.price * this.option.goodsNum
-			let discountMember = this.$util.isEmpty(this.shopUser) ? this.shopUser.userAsset.discount * totalPrice : 1 * totalPrice
-			discountMember = discountMember / 10
-			return discountMember.toFixed(2)
-		}
-	},
-	onLoad(option) {
-		// this.init()
-	},
-	methods: {
-		init() {
-			let goodsInfo = uni.getStorageSync('buyGoodsDetil')
-			// if (this.$util.isEmpty(goodsInfo)) {
-			// 	this.$util.pageTo({
-			// 		url: `/pages/goods/detail`,
-			// 		query: {
-			// 			id: this.option.goodsId
-			// 		}
-			// 	})
-			// 	return false
-			// }
-			getOrderShop()
-			getShopUser()
-			goodsInfo.buyNum = this.option.goodsNum
-			this.goodsInfo = goodsInfo
-			// 初始化上个页面带入的值
-			Object.keys(this.form).forEach((i, index) => {
-				this.form[i] = this.option[i]
-			})
 		},
-		// api
-		// 生成订单
-		createOrderFn() {
-			let addForm = {}
-			let form = this.tabIndex == 0 ? this.$refs.appDelivery.form : this.mentionForm
-			let region = this.tabIndex == 0 ? this.$refs.appDelivery.region : {}
-			if (this.$refs.couponSel) {
-				addForm.couponId = this.$refs.couponSel.couponId
+		computed: {
+			...mapGetters({ orderShop: 'getOrderShop' }),
+			...mapGetters({ shopUser: 'getShopUser' }),
+			// 计算总金额
+			totalPrice() {
+				let totalPrice = this.goodsInfo.price * this.option.goodsNum
+				let discountMember = this.$util.isEmpty(this.shopUser) ? this.shopUser.userAsset.discount * totalPrice : 1 * totalPrice
+				discountMember = discountMember / 10
+				return discountMember.toFixed(2)
 			}
-			createOrder({
-				needSend: this.tabIndex == 0 ? '1' : '0',
-				...form,
-				...this.form,
-				...addForm,
-				...region
-			}).then(res => {
-				uni.removeStorageSync('buyGoodsDetil')
-				this.$util.pageTo({
-					url: '/pages/callback/index',
-					query: {
-						pagestatus: 1,
-						...res.data
-					}
-				})
-			})
-		},
-		// operate
-		confirmFn() {
-			console.log(this.$refs.appDelivery)
-			this.createOrderFn()
-		},
-		tabChange(e) {
-			this.tabIndex = e.index
-		},
-		hideAlert() {
-			this.showAlert = false
 		},
-		anonymityChange(e) {
-			this.form.anonymity = this.form.anonymity == 1 ? 0 : 1
+		onLoad(option) {
+			// this.init()
 		},
-		// 表单验证
-		formSubmit(e) {
-			console.log(e)
-			// 表单规则
-			let rules = [
-				// {
-				// 	name: 'receiveUserName',
-				// 	rule: ['required'],
-				// 	msg: ['请输入姓名']
+		methods: {
+			init() {
+				let goodsInfo = uni.getStorageSync('buyGoodsDetil')
+				// if (this.$util.isEmpty(goodsInfo)) {
+				// 	this.$util.pageTo({
+				// 		url: `/pages/goods/detail`,
+				// 		query: {
+				// 			id: this.option.goodsId
+				// 		}
+				// 	})
+				// 	return false
 				// }
-			]
-			// 进行表单检查
-			let formData = e.detail.value
-			let checkRes = form.validation(formData, rules)
-			// 验证通过!
-			if (!checkRes) {
-				this.confirmFn()
-			} else {
-				this.$msg(checkRes)
+				getOrderShop().then(() => {
+					this.$refs.couponSel._getUserDiscount().then(status => {
+						this.discountArr = status
+					})
+				})
+				getShopUser()
+				goodsInfo.buyNum = this.option.goodsNum
+				this.goodsInfo = goodsInfo
+				// 初始化上个页面带入的值
+				Object.keys(this.form).forEach((i, index) => {
+					this.form[i] = this.option[i]
+				})
+			},
+			// api
+			// 生成订单
+			createOrderFn() {
+				let addForm = {}
+				let form = this.tabIndex == 0 ? this.$refs.appDelivery.form : this.mentionForm
+				let region = this.tabIndex == 0 ? this.$refs.appDelivery.region : {}
+				if (this.$refs.couponSel) {
+					addForm.couponId = this.$refs.couponSel.couponId
+				}
+				createOrder({
+					needSend: this.tabIndex == 0 ? '1' : '0',
+					...form,
+					...this.form,
+					...addForm,
+					...region
+				}).then(res => {
+					uni.removeStorageSync('buyGoodsDetil')
+					this.$util.pageTo({
+						url: '/pages/callback/index',
+						query: {
+							pagestatus: 1,
+							...res.data
+						}
+					})
+				})
+			},
+			// operate
+			confirmFn() {
+				console.log(this.$refs.appDelivery)
+				this.createOrderFn()
+			},
+			tabChange(e) {
+				this.tabIndex = e.index
+			},
+			hideAlert() {
+				this.showAlert = false
+			},
+			anonymityChange(e) {
+				this.form.anonymity = this.form.anonymity == 1 ? 0 : 1
+			},
+			// 表单验证
+			formSubmit(e) {
+				console.log(e)
+				// 表单规则
+				let rules = [
+					// {
+					// 	name: 'receiveUserName',
+					// 	rule: ['required'],
+					// 	msg: ['请输入姓名']
+					// }
+				]
+				// 进行表单检查
+				let formData = e.detail.value
+				let checkRes = form.validation(formData, rules)
+				// 验证通过!
+				if (!checkRes) {
+					this.confirmFn()
+				} else {
+					this.$msg(checkRes)
+				}
 			}
 		}
 	}
-}
 </script>
 
 <style lang='scss' scoped>

+ 78 - 73
mobile-code/src/pages/order/detail.vue

@@ -83,7 +83,7 @@
 			</div>
 			<!-- 优惠信息 -->
 			<block v-if="data.status == 0">
-				<div class="module-com coupon-wrap" v-if="!$util.isEmpty(shopUser) && shopUser.userAsset.member && shopUser.userAsset.getCouponNum">
+				<div class="module-com coupon-wrap" v-if="!$util.isEmpty(discountArr)">
 					<div class="module-tit">优惠信息</div>
 					<div class="module-det">
 						<app-coupon-sel ref="couponSel" :price="data.prePrice * data.goodsNum" :discountArr="['member', 'coupon']" />
@@ -123,86 +123,91 @@
 </template>
 
 <script>
-import { mapGetters } from 'vuex'
-import ListModule from '@/components/module/app-order-list'
-import AppCouponSel from '@/components/app-coupon-sel'
-// api
-import { getDetail } from '@/api/order'
-import { getShopUser } from '@/utils/auth'
-export default {
-	name: 'order-detail',
-	components: {
-		ListModule,
-		AppCouponSel
-	},
-	data() {
-		return {
-			constant: this.$constant,
-			data: {}
-		}
-	},
-	computed: {
-		...mapGetters({ shopUser: 'getShopUser' }),
-		statusImg() {
-			let img = ''
-			if (this.data.status == 0) {
-				img = `${this.$constant.imgUrl}/retail/order/wait-pay.png`
-			} else if (this.data.status == 1) {
-				img = `${this.$constant.imgUrl}/retail/order/wait-delivery.png`
-			} else if (this.data.status == 2) {
-				img = `${this.$constant.imgUrl}/retail/order/in-delivery.png`
-			} else if (this.data.status == 5) {
-				img = `${this.$constant.imgUrl}/retail/order/order-confirm.png`
-			}
-			return img
-		}
-	},
-	onLoad() {
-		// this.init()
-	},
-	methods: {
-		init() {
-			this._getDet()
-			getShopUser()
+	import { mapGetters } from 'vuex'
+	import ListModule from '@/components/module/app-order-list'
+	import AppCouponSel from '@/components/app-coupon-sel'
+	// api
+	import { getDetail } from '@/api/order'
+	import { getShopUser } from '@/utils/auth'
+	export default {
+		name: 'order-detail',
+		components: {
+			ListModule,
+			AppCouponSel
 		},
-		_getDet() {
-			let form = {}
-			if (this.option.id) {
-				form.id = this.option.id
-			} else if (this.option.orderSn) {
-				form.orderSn = this.option.orderSn
+		data() {
+			return {
+				constant: this.$constant,
+				data: {},
+				discountArr: false
 			}
-			return getDetail(form).then(res => {
-				this.data = res.data
-			})
 		},
-		// operate
-		payFn() {
-			let data = {
-				orderSn: this.data.orderSn,
-				totalPrice: this.data.prePrice,
-				couponId: 0
-			}
-			this.$util.pageTo({
-				url: '/pages/callback/index',
-				query: {
-					pagestatus: 1,
-					id: this.data.id,
-					...data
+		computed: {
+			...mapGetters({ shopUser: 'getShopUser' }),
+			statusImg() {
+				let img = ''
+				if (this.data.status == 0) {
+					img = `${this.$constant.imgUrl}/retail/order/wait-pay.png`
+				} else if (this.data.status == 1) {
+					img = `${this.$constant.imgUrl}/retail/order/wait-delivery.png`
+				} else if (this.data.status == 2) {
+					img = `${this.$constant.imgUrl}/retail/order/in-delivery.png`
+				} else if (this.data.status == 5) {
+					img = `${this.$constant.imgUrl}/retail/order/order-confirm.png`
 				}
-			})
+				return img
+			}
 		},
-		evealFn() {
-			uni.setStorageSync('orderDetialComment', this.data)
-			this.$util.pageTo({
-				url: '/pages/order/comment',
-				query: {
-					id: this.data.id
+		onLoad() {
+			// this.init()
+		},
+		methods: {
+			init() {
+				this._getDet()
+				getShopUser().then(res => {
+					this.$refs.couponSel._getUserDiscount().then(status => {
+						this.discountArr = status
+					})
+				})
+			},
+			_getDet() {
+				let form = {}
+				if (this.option.id) {
+					form.id = this.option.id
+				} else if (this.option.orderSn) {
+					form.orderSn = this.option.orderSn
+				}
+				return getDetail(form).then(res => {
+					this.data = res.data
+				})
+			},
+			// operate
+			payFn() {
+				let data = {
+					orderSn: this.data.orderSn,
+					totalPrice: this.data.prePrice,
+					couponId: 0
 				}
-			})
+				this.$util.pageTo({
+					url: '/pages/callback/index',
+					query: {
+						pagestatus: 1,
+						id: this.data.id,
+						...data
+					}
+				})
+			},
+			evealFn() {
+				uni.setStorageSync('orderDetialComment', this.data)
+				this.$util.pageTo({
+					url: '/pages/order/comment',
+					query: {
+						id: this.data.id
+					}
+				})
+			}
 		}
 	}
-}
 </script>
 
 <style lang="scss" scoped>

+ 2 - 2
mobile-code/src/pages/pay/index.vue

@@ -199,8 +199,8 @@
 						title: `您正在向【${res.shop.merchantName}】付款`
 					})
 
-					this.$refs.couponSel._getUserDiscount().then(res => {
-						this.discountArr = res
+					this.$refs.couponSel._getUserDiscount().then(status => {
+						this.discountArr = status
 					})
 				})
 				if (isLogin()) {