This commit is contained in:
唐明明
2021-10-29 14:28:17 +08:00
4 changed files with 268 additions and 124 deletions

View File

@@ -1,4 +1,3 @@
/** /**
* Web唐明明 * Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。 * 匆匆数载恍如梦,岁月迢迢华发增。
@@ -6,7 +5,9 @@
* moduleName: 订单 * moduleName: 订单
*/ */
import { request } from '../index' import {
request
} from '../index'
// 创建,确认订单 // 创建,确认订单
const buy = (data, method) => { const buy = (data, method) => {
@@ -33,6 +34,15 @@ const wxPay = (data) => {
}) })
} }
//支付宝支付
const aliPay = (data) => {
return request({
url: 'mall/pay/' + data.order_no + '/alipay',
data: data,
method: 'get'
})
}
// EB支付 // EB支付
const ebPay = (data) => { const ebPay = (data) => {
return request({ return request({
@@ -43,5 +53,6 @@ export {
buy, buy,
eb, eb,
wxPay, wxPay,
aliPay,
ebPay ebPay
} }

View File

@@ -48,6 +48,17 @@
<u-icon v-if="selectTypeId!== '2'" name="checkmark-circle" color="#f7f7f7" size="50"></u-icon> <u-icon v-if="selectTypeId!== '2'" name="checkmark-circle" color="#f7f7f7" size="50"></u-icon>
<u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon> <u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon>
</view> </view>
<view class="pay-select-item" @click="selectPay('3')">
<view class="pay-left">
<u-icon class="wx-icon" name="zhifubao" color="#fff" size="40"></u-icon>
<view class="pay-wx-title">
支付宝支付
<span>推荐支付宝用户使用</span>
</view>
</view>
<u-icon v-if="selectTypeId!== '3'" name="checkmark-circle" color="#f7f7f7" size="50"></u-icon>
<u-icon v-else name="checkmark-circle-fill" color="#8b64fd" size="50"></u-icon>
</view>
<!-- <view class="pay-select-item" @click="selectPay('1')"> <!-- <view class="pay-select-item" @click="selectPay('1')">
<view class="pay-left"> <view class="pay-left">
<u-icon class="wx-icon" name="integral-fill" color="#fff" size="40"></u-icon> <u-icon class="wx-icon" name="integral-fill" color="#fff" size="40"></u-icon>
@@ -98,6 +109,7 @@
} from '@/apis/interfaces/goods' } from '@/apis/interfaces/goods'
import { import {
wxPay, wxPay,
aliPay,
ebPay ebPay
} from '@/apis/interfaces/order' } from '@/apis/interfaces/order'
export default { export default {
@@ -177,6 +189,12 @@
order_no: this.order_no, order_no: this.order_no,
type: 'app' type: 'app'
} }
} else if (this.selectTypeId === '3') {
apiUrl = aliPay
data = {
order_no: this.order_no,
type: 'app'
}
} else { } else {
apiUrl = ebPay apiUrl = ebPay
data = { data = {
@@ -184,6 +202,9 @@
} }
} }
apiUrl(data).then(res => { apiUrl(data).then(res => {
console.log(res)
debugger;
// 微信支付
if (this.selectTypeId === '2') { if (this.selectTypeId === '2') {
if (typeof res === 'string') { if (typeof res === 'string') {
let payInfo = JSON.parse(res) let payInfo = JSON.parse(res)
@@ -234,6 +255,56 @@
}, 3000); }, 3000);
} }
} }
// 支付宝支付
else if (this.selectTypeId === '3') {
if (typeof res === 'string') {
uni.requestPayment({
provider: "alipay",
orderInfo: res,
success: res => {
uni.showToast({
title: '支付成功',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
uni.reLaunch({
url: '/pages/goods/payStatus?success=true'
})
this.canPay = true
}, 3000);
},
fail: (err) => {
uni.showToast({
title: '支付失败',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
uni.reLaunch({
url: '/pages/goods/payStatus?success=false'
})
this.canPay = true
}, 3000);
}
})
} else {
uni.showToast({
title: '创建订单成功',
duration: 3000,
mask: true,
icon: 'none'
})
setTimeout(() => {
this.canPay = true
uni.reLaunch({
url: '/pages/goods/payStatus?success=true'
})
}, 3000);
}
}
}).catch(err => { }).catch(err => {
uni.showToast({ uni.showToast({
title: err.message, title: err.message,
@@ -276,6 +347,8 @@
} }
} else if (id === '2') { } else if (id === '2') {
this.selectTypeId = id this.selectTypeId = id
} else if (id === '3') {
this.selectTypeId = id
} }
}, },

View File

@@ -1,6 +1,7 @@
<template> <template>
<view class="PayStatus"> <view class="PayStatus">
<image class="payStatusImg" :src="success?'/static/imgs/paySuccess.png':'/static/imgs/payFail.png'" mode="widthFix" /> <image class="payStatusImg" :src="success?'/static/imgs/paySuccess.png':'/static/imgs/payFail.png'"
mode="widthFix" />
<view class="payTitle">{{success?'支付成功':'支付失败'}}</view> <view class="payTitle">{{success?'支付成功':'支付失败'}}</view>
<view class="payDes">{{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}}</view> <view class="payDes">{{success?'您已支付完成,订单稍后配送':'吼吼,您的支付未完成'}}</view>
<view class="payBackCheck"> <view class="payBackCheck">

File diff suppressed because one or more lines are too long