|
|
|
@ -28,6 +28,8 @@ |
|
|
|
<view v-if="supplierOrder.status == supplierOrderStatusEnum.WAIT_CLIENT_PAY" class="button-item" @click="confirmWxPay(supplierOrder.mallSupplierId)"> |
|
|
|
去付款 |
|
|
|
</view> |
|
|
|
<!-- 微信支付服务商待付款 --> |
|
|
|
<view v-if="supplierOrder.status == supplierOrderStatusEnum.WX_PAY_SUPPLIER" class="button-item" @click="makeWxpay()">去付款</view> |
|
|
|
<!-- 待收货展示 --> |
|
|
|
<view v-else-if="supplierOrder.status == supplierOrderStatusEnum.WAIT_RECEIVE" class="button-item" @click="confirmReceive(supplierOrder)"> |
|
|
|
确认收货 |
|
|
|
@ -154,9 +156,19 @@ |
|
|
|
|
|
|
|
<script> |
|
|
|
import { go2, back, uploadImage } from '@/utils/hook.js' |
|
|
|
import { getClientOrderInfo, clientUploadVoucher, clientDeleteVoucher, clientConfirmOrder, getReciptCode } from '@/apis/orderApi.js' |
|
|
|
import { transformFileToImg, getFeisuanUrl } from '@/apis/commonApi.js' |
|
|
|
import { orderStatusEnum, supplierOrderStatusMap, supplierOrderStatusEnum, paymentMethodMap, paymentMethodEnum, invoiceStatusMap } from '@/enums/index.js' |
|
|
|
import { getClientOrderInfo, clientUploadVoucher, clientDeleteVoucher, clientConfirmOrder, getReciptCode, makeSupplierPay } from '@/apis/orderApi.js' |
|
|
|
import { transformFileToImg, getFeisuanUrl, getOpenId } from '@/apis/commonApi.js' |
|
|
|
import { |
|
|
|
orderStatusEnum, |
|
|
|
supplierOrderStatusMap, |
|
|
|
supplierOrderStatusEnum, |
|
|
|
paymentMethodMap, |
|
|
|
paymentMethodEnum, |
|
|
|
invoiceStatusMap, |
|
|
|
ORDER_URL, |
|
|
|
QN_APPID, |
|
|
|
WX_APPID |
|
|
|
} from '@/enums/index.js' |
|
|
|
const statusImg = { |
|
|
|
[orderStatusEnum.WAIT_SUPPLIER_CONFIRM]: '待供应商确认', |
|
|
|
[orderStatusEnum.ORDERED]: '已下单', |
|
|
|
@ -177,6 +189,8 @@ const showVoucherStatus = [ |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
wxCode: null, |
|
|
|
orderId: null, |
|
|
|
orderInfo: { |
|
|
|
deliveryAddress: {}, |
|
|
|
supplierOrder: [] |
|
|
|
@ -192,6 +206,7 @@ export default { |
|
|
|
}, |
|
|
|
onLoad(option) { |
|
|
|
if (option.orderId) { |
|
|
|
this.orderId = option.orderId |
|
|
|
this.init(option.orderId) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
@ -204,6 +219,15 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
let url = window.location.href |
|
|
|
let codeIndex = url.indexOf('code=') |
|
|
|
if (codeIndex > 0) { |
|
|
|
let endIndex = url.indexOf('&', codeIndex) |
|
|
|
this.wxCode = url.substring(codeIndex + 5, endIndex) |
|
|
|
if (this.wxCode) { |
|
|
|
this.payForOrder(this.wxCode) |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
go2, |
|
|
|
@ -354,6 +378,54 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 服务商支付 |
|
|
|
makeWxpay() { |
|
|
|
let url = ORDER_URL + '?orderId=' + this.orderId |
|
|
|
let redirectUrl = encodeURIComponent(url) |
|
|
|
window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${QN_APPID}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect` |
|
|
|
}, |
|
|
|
payForOrder() { |
|
|
|
getOpenId({ authCode: this.wxCode, authMethod: 'WeChatServiceAccount' }).then((res) => { |
|
|
|
makeSupplierPay({ customerOrderId: this.orderInfo.orderId, wxAppid: QN_APPID, apiType: 'jsapi', openid: res.openId }).then((result) => { |
|
|
|
let info = { |
|
|
|
appId: result.appId, |
|
|
|
timeStamp: result.timeStamp, |
|
|
|
nonceStr: result.nonceStr, |
|
|
|
package: `prepay_id=${result.prepayId}`, |
|
|
|
signType: result.signType, |
|
|
|
paySign: result.paySign |
|
|
|
} |
|
|
|
console.log('info', info) |
|
|
|
|
|
|
|
this.wxPay(info) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 调起微信支付 |
|
|
|
wxPay(info) { |
|
|
|
WeixinJSBridge.invoke('getBrandWCPayRequest', { ...info }, function (res) { |
|
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。 |
|
|
|
if (res.err_msg == 'get_brand_wcpay_request:ok') { |
|
|
|
uni.showToast({ |
|
|
|
title: '支付成功', |
|
|
|
icon: 'success', |
|
|
|
duration: 1000 |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
go2('mine', {}, true) |
|
|
|
}, 1000) |
|
|
|
} else { |
|
|
|
uni.showToast({ |
|
|
|
title: '支付失败', |
|
|
|
icon: 'error', |
|
|
|
duration: 2000 |
|
|
|
}) |
|
|
|
setTimeout(() => { |
|
|
|
go2('mine', {}, true) |
|
|
|
}, 1000) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
clip(content) { |
|
|
|
uni.setClipboardData({ |
|
|
|
data: content, |
|
|
|
|