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

+ 0 - 7
mobile-code/src/api/order/index.js

@@ -48,13 +48,6 @@ export const wxPay = data => {
 	return https.post('/order/wx-pay', data)
 }
 
-/** *
- * 快捷下单-微信余额支付宝 m
- */
-export const fastPay = data => {
-	return https.post('/order/fast-pay', data)
-}
-
 // =====================  B 端 ========================
 
 /** *

+ 7 - 0
mobile-code/src/api/pay/index.js

@@ -9,3 +9,10 @@ import https from '@/plugins/luch-request_0.0.7/request'
 export const pay = data => {
 	return https.post('/pay/get-params', data)
 }
+
+/** *
+ * 快捷下单-微信余额支付宝 m
+ */
+export const fastPay = data => {
+	return https.post('/order/fast-pay', data)
+}

+ 6 - 0
mobile-code/src/pages/callback/index.vue

@@ -4,18 +4,21 @@
 		<div class="callback-wrap">
 			<div class="callback-blo">
 				<!-- 使用icon -->
+				<!-- 待支付 -->
 				<block v-if="pagestatus == 1 || pagestatus == 2">
 					<div class="icon">
 						<i class="iconfont icondaizhifu"></i>
 					</div>
 				</block>
 				<!-- 使用图片 -->
+				<!-- 支付成功 -->
 				<block v-else>
 					<div class="status-img">
 						<img src="../../static/images/callback/success.png" alt mode="widthFix" />
 					</div>
 				</block>
 				<div class="status-text app-size-36 app-bold">{{ pageTit }}</div>
+				<!-- 待支付 -->
 				<block v-if="pagestatus == 1 || pagestatus == 2">
 					<div class="price">
 						<span>¥</span>
@@ -24,16 +27,19 @@
 					<div class="surplus app-color-3" v-if="!$util.isEmpty(shopUser)">剩余¥{{ shopUser.userAsset.balance }}</div>
 					<div class="order-num app-color-3">订单号: {{ option.orderSn }}</div>
 				</block>
+				<!-- 待支付 - 订单支付成功 -->
 				<block v-else-if="pagestatus == 3 && payDiscountPrice">
 					<div>
 						<span class="app-color-2">使用优惠券为您</span>
 						<span class="app-price">节省 {{ payDiscountPrice }}元</span>
 					</div>
 				</block>
+				<!-- 评价成功 -->
 				<block v-else-if="pagestatus == 4">
 					<div class="app-color-2">谢谢您,我还会继续努力么么哒~</div>
 				</block>
 				<!-- 一个主按钮 -->
+				<!-- 待支付 -->
 				<block v-if="pagestatus == 1 || pagestatus == 2">
 					<div class="call-one-btn">
 						<button v-if="isYeBtnShow" class="button-com red pay-ye" @click="balancePayFn">余额支付</button>

+ 18 - 9
mobile-code/src/pages/order/detail.vue

@@ -82,18 +82,23 @@
 				</div>
 			</div>
 			<!-- 优惠信息 -->
-			<div class="module-com coupon-wrap" v-if="data.discountAmount && data.discountAmount != '0.00'">
-				<div class="module-tit">优惠信息</div>
-				<div class="module-det">
-					<block v-if="false">
-						<app-coupon :discountArr="['member', 'coupon']" />
-					</block>
-					<block>
+			<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-tit">优惠信息</div>
+					<div class="module-det">
+						<app-coupon-sel ref="couponSel" :price="data.prePrice * data.goodsNum" :discountArr="['member', 'coupon']" />
+					</div>
+				</div>
+			</block>
+			<block v-else>
+				<div class="module-com coupon-wrap" v-if="data.discountAmount && data.discountAmount != '0.00'">
+					<div class="module-tit">优惠信息</div>
+					<div class="module-det">
 						<div class="app-color-3">{{ data.discountType == 0 ? '使用优惠券' : data.discountType == 1 ? '会员打折' : '付款随机优惠' }}</div>
 						<div class="app-price">-¥{{ data.discountAmount }}</div>
-					</block>
+					</div>
 				</div>
-			</div>
+			</block>
 		</div>
 		<!-- 按钮 -->
 		<div class="page-btn app-footer">
@@ -118,10 +123,12 @@
 </template>
 
 <script>
+import { mapGetters } from 'vuex'
 import ListModule from '@/components/module/app-order-list'
 import AppCoupon from '@/components/app-coupon-sel'
 // api
 import { getDetail } from '@/api/order'
+import { getShopUser } from '@/utils/auth'
 // image
 import waitDeliveryImg from '../../static/images/order/wait-delivery.png'
 import waitPayImg from '../../static/images/order/wait-pay.png'
@@ -139,6 +146,7 @@ export default {
 		}
 	},
 	computed: {
+		...mapGetters({ shopUser: 'getShopUser' }),
 		statusImg() {
 			let img = ''
 			if (this.data.status == 0) {
@@ -159,6 +167,7 @@ export default {
 	methods: {
 		init() {
 			this._getDet()
+			getShopUser()
 		},
 		_getDet() {
 			let form = {}

+ 86 - 20
mobile-code/src/pages/pay/index.vue

@@ -9,26 +9,39 @@
 				<div class="logo-img">
 					<img src="../../static/images/user/attr-default.png" alt mode="widthFix" />
 				</div>
-				<div class="app-size-30">国兰花尚</div>
+				<div class="app-size-30">{{ shopUser.userName }}</div>
 			</div>
 			<div class="pay-input-wrap">
-				<pay-input-module :focus="inpFocus" :num="amount" @focusFn="focusFn" @blurFn="blurFn" @clickKey="clickKeyFn" />
+				<pay-input-module :focus="inpFocus" :num="form.prePrice" @focusFn="focusFn" @blurFn="blurFn" @clickKey="clickKeyFn" />
 				<div class="balance">
 					<span>账户余额 ¥</span>
-					<span class="app-size-30">2872.09</span>
+					<span class="app-size-30">{{ shopUser.userAsset.balance }}</span>
 				</div>
 				<!-- 按钮 -->
 				<div class="btn-wrap">
-					<button class="button-com red" @click="_pay">余额支付</button>
-					<button class="button-com green" @click="_pay">微信支付</button>
+					<button class="button-com red" @click="balancePayFn">余额支付</button>
+					<button class="button-com green" @click="wexinPayFn">微信支付</button>
 				</div>
 			</div>
 		</block>
 		<!-- 我要配送 -->
 		<block v-else>
-			<app-delivery-module />
+			<app-delivery-module ref="appDelivery" />
 		</block>
 		<!-- <button @click="_pay">提交</button> -->
+		<!-- 支付密码弹窗 -->
+		<modal-module :show="passwordModal" @cancel="modalCancel" @click="passwordModalClick" :maskClosable="false" title="支付密码" padding="30rpx 30rpx">
+			<template v-slot:content>
+				<div class="app-modal-input-wrap">
+					<div class="inp-list-line">
+						<!-- <div class="line-label">支付密码</div> -->
+						<div class="line-input">
+							<input type="password" v-model="form.payPassword" :adjust-position="false" class="inp-input" />
+						</div>
+					</div>
+				</div>
+			</template>
+		</modal-module>
 	</div>
 </template>
 
@@ -36,11 +49,13 @@
 import AppTabs from '@/components/plugin/tabs'
 import PayInputModule from './components/pay-input'
 import AppDeliveryModule from '@/components/app-delivery'
-import { getMiniAppUrl } from '@/utils/common'
+// import { getMiniAppUrl } from '@/utils/common'
 import { getCheckLogin } from '@/utils/auth'
 import wexinPay from '@/utils/pay/wxPay'
-import { pay } from '@/api/pay'
+// api
+import { fastPay } from '@/api/pay'
 import { oauth } from '@/api/login'
+import { getShopUser } from '@/utils/auth'
 export default {
 	name: 'pay',
 	components: {
@@ -51,8 +66,6 @@ export default {
 	data() {
 		return {
 			constant: this.$constant,
-			option: '',
-			amount: '',
 			inpFocus: false,
 			// tab
 			tabIndex: 0,
@@ -63,34 +76,57 @@ export default {
 				{
 					name: '我要配送'
 				}
-			]
+			],
+			// 初始form
+			form: {
+				prePrice: '',
+				payWay: 0 // 0微信 1支付宝 2余额
+			},
+			// 支付相关 ============
+			passwordModal: false,
+			modalForm: {
+				payPassword: ''
+			},
+			appendFrm: {
+				anonymity: '0', // 是否匿名 0不 1要
+				sendDistance: '', // 配送距离,根据腾讯js进行计算
+				// goodsId: '', // 【商城下单特有字段】商品id
+				// goodsStyleId: '', // 【商城下单特有字段】商品款式id
+				// goodsNum: '', // 【商城下单特有字段】商品数量
+				// couponId: '0', // 优惠券id,默认0没有使用优惠券
+				receiveLat: '', // 收花人纬度
+				receiveLong: '' // 收花人经度
+			}
 		}
 	},
+	computed: {
+		...mapGetters({ shopUser: 'getShopUser' })
+	},
 	onLoad(option) {
 		this.option = this.$util.isEmpty(option) || {
 			account: 12358,
 			shopId: 15680
 		}
-		// this.init()
+		this.init()
 	},
 	methods: {
 		init() {
-			getCheckLogin()
+			// getCheckLogin().then(res => {})
+			getShopUser()
 		},
 		_pay() {
-			if (!this.amount) {
+			if (!this.form.prePrice) {
 				this.$msg('请先输入金额!')
 				return false
 			}
 			let params = {
-				prePrice: this.amount,
-				sourceType: 1,
-				shopId: 15680
+				needSend: this.tabIndex == 0 ? '1' : '0',
+				prePrice: this.amount
+				// sourceType: 1,
+				// shopId: 15680
 			}
-			pay(params).then(res => {
-				console.log(res)
+			fastPay(params).then(res => {
 				wexinPay(res.data, this.paySuccess, this.payFail)
-				console.log(wexinPay)
 				// window.location.href = res.data.pay_button.mweb_url
 			})
 		},
@@ -110,9 +146,39 @@ export default {
 		clickKeyFn(val) {
 			this.amount = val
 		},
+		// 微信支付
+		wexinPayFn() {
+			this.form.payWay = 0
+			this._pay()
+		},
+		// 余额支付
+		balancePayFn() {
+			this.form.payWay = 2
+			this.passwordModal = true
+		},
+		passwordModalClick(e) {
+			if (e.index === 0) {
+				this.modalCancel()
+			} else {
+				this._pay()
+			}
+		},
+		modalCancel() {
+			this.passwordModal = false
+			this.modalForm.payPassword = ''
+		},
 		// 支付成功
 		paySuccess() {
 			alert('支付成功!')
+			this.$util.pageTo({
+				url: '/pages/callback/index',
+				type: 2,
+				query: {
+					pagestatus: 3
+					// orderSn: this.option.orderSn,
+					// payDiscountPrice: res.data.discountAmount
+				}
+			})
 		},
 		payFail() {
 			alert('支付失败!')