确认收货

pull/8/head
kele 2023-10-16 14:14:40 +08:00
parent fd7ccde73a
commit 53507d995d
3 changed files with 78 additions and 8 deletions

View File

@ -14,7 +14,7 @@
console.log('AppOnError:', err);
});
onShow(() => {
onShow((options) => {
// #ifdef APP-PLUS
// urlSchemes
const args = plus.runtime.arguments;
@ -26,6 +26,13 @@
success: (res) => { },
});
// #endif
// #ifdef MP-WEIXIN
//
console.log(options,'options');
// #endif
});
</script>

View File

@ -313,11 +313,14 @@
import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app';
import { computed, reactive } from 'vue';
import { isEmpty } from 'lodash';
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
const headerBg = sheep.$url.css('/static/img/shop/order/order_bg.png');
const state = reactive({
orderInfo: {},
merchantTradeNo: '', //
comeinType: '', //
});
const addressText = computed(() => {
@ -390,14 +393,62 @@
});
}
//
async function onConfirm(orderId) {
//
async function onConfirm(orderId, ignore = false) {
//
// todo:
// 1.return
// 2.mpConfirm,App.vueshow
let isOpenBusinessView = true;
if (
sheep.$platform.name === 'WechatMiniProgram' &&
!isEmpty(state.orderInfo.wechat_extra_data) &&
isOpenBusinessView &&
!ignore
) {
mpConfirm(orderId);
return;
}
//
const { error, data } = await sheep.$api.order.confirm(orderId);
if (error === 0) {
getOrderDetail(data.order_sn);
}
}
// #ifdef MP-WEIXIN
//
function mpConfirm(orderId) {
if (!wx.openBusinessView) {
sheep.$helper.toast(`请升级微信版本`);
return;
}
wx.openBusinessView({
businessType: 'weappOrderConfirm',
extraData: {
merchant_id: '1481069012',
merchant_trade_no: state.orderInfo.wechat_extra_data.merchant_trade_no,
transaction_id: state.orderInfo.wechat_extra_data.transaction_id,
},
success(response) {
console.log('success:', response);
if (response.errMsg === 'openBusinessView:ok') {
if (response.extraData.status === 'success') {
onConfirm(orderId, true);
}
}
},
fail(error) {
console.log('error:', error);
},
complete(result) {
console.log('result:', result);
},
});
}
// #endif
//
function onOrderInvoice(invoiceId) {
sheep.$router.go('/pages/order/invoice', {
@ -423,22 +474,33 @@
});
}
async function getOrderDetail(id) {
const { data, error } = await sheep.$api.order.detail(id);
if (error === 0) {
state.orderInfo = data;
let res = {};
if (state.comeinType === 'wechat') {
res = await sheep.$api.order.detail(id, {
merchant_trade_no: state.merchantTradeNo,
});
} else {
res = await sheep.$api.order.detail(id);
}
if (res.error === 0) {
state.orderInfo = res.data;
} else {
sheep.$router.back();
}
}
onLoad(async (options) => {
let id = '';
let id = 0;
if (options.orderSN) {
id = options.orderSN;
}
if (options.id) {
id = options.id;
}
state.comeinType = options.comein_type;
if (state.comeinType === 'wechat') {
state.merchantTradeNo = options.merchant_trade_no;
}
getOrderDetail(id);
});
</script>

View File

@ -2,10 +2,11 @@ import request from '@/sheep/request';
export default {
// 订单详情
detail: (id) =>
detail: (id,params) =>
request({
url: 'order/order/' + id,
method: 'GET',
params,
}),
// 发票详情
invoice: (id) =>