优化细节
This commit is contained in:
426
libs/order.js
426
libs/order.js
@ -1,204 +1,224 @@
|
|||||||
import { cancelOrder, takeOrder, delOrder, payOrder } from "@/api/order";
|
import {
|
||||||
import dialog from "@/utils/dialog";
|
cancelOrder,
|
||||||
import { weappPay } from "@/libs/wechat";
|
takeOrder,
|
||||||
|
delOrder,
|
||||||
import { _router } from '@/utils'
|
payOrder
|
||||||
|
} from "@/api/order";
|
||||||
export function cancelOrderHandle(orderId) {
|
import dialog from "@/utils/dialog";
|
||||||
return new Promise((resolve, reject) => {
|
import {
|
||||||
uni.showModal({
|
weappPay
|
||||||
title: '提示',
|
} from "@/libs/wechat";
|
||||||
content: '确认取消该订单?',
|
|
||||||
success(res) {
|
import {
|
||||||
if (res.confirm) {
|
_router
|
||||||
cancelOrder(orderId)
|
} from '@/utils'
|
||||||
.then(res => {
|
|
||||||
uni.showToast({
|
export function cancelOrderHandle(orderId) {
|
||||||
title: '取消成功', icon: 'success', duration: 2000
|
return new Promise((resolve, reject) => {
|
||||||
});
|
uni.showModal({
|
||||||
resolve(res);
|
title: '提示',
|
||||||
})
|
content: '确认取消该订单?',
|
||||||
.catch(err => {
|
success(res) {
|
||||||
uni.showToast({
|
if (res.confirm) {
|
||||||
title: '取消失败', icon: 'none', duration: 2000
|
cancelOrder(orderId)
|
||||||
});
|
.then(res => {
|
||||||
reject(err);
|
uni.showToast({
|
||||||
});
|
title: '取消成功',
|
||||||
} else if (res.cancel) {
|
icon: 'success',
|
||||||
}
|
duration: 2000
|
||||||
}
|
});
|
||||||
})
|
resolve(res);
|
||||||
});
|
})
|
||||||
}
|
.catch(err => {
|
||||||
|
uni.showToast({
|
||||||
export function takeOrderHandle(orderId) {
|
title: '取消失败',
|
||||||
return new Promise((resolve, reject) => {
|
icon: 'none',
|
||||||
takeOrder(orderId)
|
duration: 2000
|
||||||
.then(res => {
|
});
|
||||||
uni.showToast({
|
reject(err);
|
||||||
title: '收货成功', icon: 'success', duration: 2000
|
});
|
||||||
});
|
} else if (res.cancel) {}
|
||||||
resolve(res);
|
}
|
||||||
})
|
})
|
||||||
.catch(err => {
|
});
|
||||||
uni.showToast({
|
}
|
||||||
title: '收货失败', icon: 'none', duration: 2000
|
|
||||||
});
|
export function takeOrderHandle(orderId) {
|
||||||
reject(err);
|
return new Promise((resolve, reject) => {
|
||||||
});
|
takeOrder(orderId)
|
||||||
});
|
.then(res => {
|
||||||
}
|
uni.showToast({
|
||||||
|
title: '收货成功',
|
||||||
export function delOrderHandle(orderId) {
|
icon: 'success',
|
||||||
return new Promise((resolve, reject) => {
|
duration: 2000
|
||||||
dialog.confirm({
|
});
|
||||||
mes: "确认删除该订单?",
|
resolve(res);
|
||||||
opts() {
|
})
|
||||||
delOrder(orderId)
|
.catch(err => {
|
||||||
.then(res => {
|
uni.showToast({
|
||||||
uni.showToast({
|
title: '收货失败',
|
||||||
title: '删除成功', icon: 'success', duration: 2000
|
icon: 'none',
|
||||||
});
|
duration: 2000
|
||||||
resolve(res);
|
});
|
||||||
})
|
reject(err);
|
||||||
.catch(err => {
|
});
|
||||||
uni.showToast({
|
});
|
||||||
title: '删除失败', icon: 'none', duration: 2000
|
}
|
||||||
});
|
|
||||||
reject(err);
|
export function delOrderHandle(orderId) {
|
||||||
});
|
return new Promise((resolve, reject) => {
|
||||||
}
|
dialog.confirm({
|
||||||
});
|
mes: "确认删除该订单?",
|
||||||
});
|
opts() {
|
||||||
}
|
delOrder(orderId)
|
||||||
|
.then(res => {
|
||||||
// 使用订单号进行支付
|
uni.showToast({
|
||||||
export async function payOrderHandle(orderId, type, from) {
|
title: '删除成功',
|
||||||
return new Promise((resolve, reject) => {
|
icon: 'success',
|
||||||
uni.showLoading({
|
duration: 2000
|
||||||
title: "支付中",
|
});
|
||||||
mask: true
|
resolve(res);
|
||||||
});
|
})
|
||||||
payOrder(orderId, type, from)
|
.catch(err => {
|
||||||
.then(async res => {
|
uni.showToast({
|
||||||
await handleOrderPayResults(res.data, type)
|
title: '删除失败',
|
||||||
resolve()
|
icon: 'none',
|
||||||
})
|
duration: 2000
|
||||||
.catch(err => {
|
});
|
||||||
reject()
|
reject(err);
|
||||||
uni.hideLoading()
|
});
|
||||||
uni.showToast({
|
}
|
||||||
title: err.msg || err.response.data.msg || err.response.data.message || '订单支付失败',
|
});
|
||||||
icon: "none",
|
});
|
||||||
duration: 2000,
|
}
|
||||||
});
|
|
||||||
});
|
// 使用订单号进行支付
|
||||||
});
|
export async function payOrderHandle(orderId, type, from) {
|
||||||
}
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.showLoading({
|
||||||
// 处理调用支付接口的逻辑
|
title: "支付中",
|
||||||
// @type create(创建订单)||pay(支付订单)
|
mask: true
|
||||||
export function handleOrderPayResults(data, type, payType) {
|
});
|
||||||
console.log(data, type, payType)
|
payOrder(orderId, type, from)
|
||||||
|
.then(async res => {
|
||||||
console.log(data, type)
|
console.log(res)
|
||||||
return new Promise((resolve, reject) => {
|
await handleOrderPayResults(res.data, type)
|
||||||
uni.hideLoading()
|
resolve()
|
||||||
switch (data.status) {
|
})
|
||||||
// 订单号已存在
|
.catch(err => {
|
||||||
case "ORDER_EXIST":
|
reject()
|
||||||
resolve()
|
uni.hideLoading()
|
||||||
break;
|
uni.showToast({
|
||||||
// 取消支付
|
title: err.msg || err.response.data.msg || err.response.data.message || '订单支付失败',
|
||||||
case "EXTEND_ORDER":
|
icon: "none",
|
||||||
uni.showToast({
|
duration: 2000,
|
||||||
title: data.msg,
|
});
|
||||||
icon: "none",
|
});
|
||||||
duration: 2000,
|
});
|
||||||
});
|
}
|
||||||
resolve()
|
|
||||||
goOrderDetails(data.result.orderId, type)
|
// 处理调用支付接口的逻辑
|
||||||
break;
|
// @type create(创建订单)||pay(支付订单)
|
||||||
case "PAY_DEFICIENCY":
|
export function handleOrderPayResults(data, type, payType) {
|
||||||
break;
|
return new Promise((resolve, reject) => {
|
||||||
// 支付出错
|
uni.hideLoading()
|
||||||
case "PAY_ERROR":
|
switch (data.status) {
|
||||||
uni.showToast({
|
// 订单号已存在
|
||||||
title: data.msg,
|
case "ORDER_EXIST":
|
||||||
icon: "none",
|
resolve()
|
||||||
duration: 2000,
|
break;
|
||||||
});
|
// 取消支付
|
||||||
reject()
|
case "EXTEND_ORDER":
|
||||||
goOrderDetails(data.result.orderId, type)
|
uni.showToast({
|
||||||
break;
|
title: data.msg,
|
||||||
// 未传递支付环境
|
icon: "none",
|
||||||
case "SUCCESS":
|
duration: 2000,
|
||||||
uni.showToast({
|
});
|
||||||
title: data.msg || data.payMsg,
|
resolve()
|
||||||
icon: "none",
|
goOrderDetails(data.result.orderId, type)
|
||||||
duration: 2000,
|
break;
|
||||||
});
|
case "PAY_DEFICIENCY":
|
||||||
resolve()
|
break;
|
||||||
goOrderDetails(data.result.orderId, type)
|
// 支付出错
|
||||||
break;
|
case "PAY_ERROR":
|
||||||
// H5支付
|
uni.showToast({
|
||||||
case "WECHAT_H5_PAY":
|
title: data.msg,
|
||||||
goOrderDetails(data.result.orderId, type)
|
icon: "none",
|
||||||
console.log(data)
|
duration: 2000,
|
||||||
setTimeout(() => {
|
});
|
||||||
resolve()
|
reject()
|
||||||
// #ifdef H5
|
goOrderDetails(data.result.orderId, type)
|
||||||
// "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx15171343713577e9f3a418b0865ef90000&package=2547890641"
|
break;
|
||||||
// location.href = data.result.jsConfig.mweb_url;
|
// 未传递支付环境
|
||||||
// #endif
|
case "SUCCESS":
|
||||||
}, 100);
|
uni.showToast({
|
||||||
break;
|
title: data.msg || data.payMsg,
|
||||||
// 小程序支付
|
icon: "none",
|
||||||
case "WECHAT_PAY":
|
duration: 2000,
|
||||||
weappPay(data.result.jsConfig).finally(() => {
|
});
|
||||||
resolve()
|
resolve()
|
||||||
goOrderDetails(data.result.orderId, type)
|
goOrderDetails(data.result.orderId, type)
|
||||||
}).then(res => {
|
break;
|
||||||
// #ifdef MP-WEIXIN
|
// H5支付
|
||||||
subscribeMessage()
|
case "WECHAT_H5_PAY":
|
||||||
// #endif
|
goOrderDetails(data.result.orderId, type)
|
||||||
})
|
console.log(data)
|
||||||
break;
|
setTimeout(() => {
|
||||||
// APP支付
|
resolve()
|
||||||
case "WECHAT_APP_PAY":
|
// #ifdef H5
|
||||||
weappPay(data.result.jsConfig).finally(() => {
|
// "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx15171343713577e9f3a418b0865ef90000&package=2547890641"
|
||||||
resolve()
|
// location.href = data.result.jsConfig.mweb_url;
|
||||||
goOrderDetails(data.result.orderId, type)
|
// #endif
|
||||||
})
|
}, 100);
|
||||||
break;
|
break;
|
||||||
}
|
// 小程序支付
|
||||||
})
|
case "WECHAT_PAY":
|
||||||
}
|
weappPay(data.result.jsConfig).finally(() => {
|
||||||
|
resolve()
|
||||||
export function subscribeMessage() {
|
goOrderDetails(data.result.orderId, type)
|
||||||
// 调用订阅
|
}).then(res => {
|
||||||
console.log('调用订阅')
|
// #ifdef MP-WEIXIN
|
||||||
uni.requestSubscribeMessage({
|
subscribeMessage()
|
||||||
tmplIds: ['W5r2c2kzhbq8uxStkPAVx_sk-5aapMFCqe7b7KU5jXI', '2CB_1UyQrbnlyjJa5syraqJ3cfztPPDOAHe3DEXpMjg', 'vuztugw9VbKbKJDAAVePkjqPpT5mdoREpd4Aq7EGPRU'],
|
// #endif
|
||||||
success(res) {
|
})
|
||||||
console.log(res)
|
break;
|
||||||
},
|
// APP支付
|
||||||
fail(error){
|
case "WECHAT_APP_PAY":
|
||||||
console.log(error)
|
weappPay(data.result.jsConfig).finally(() => {
|
||||||
}
|
resolve()
|
||||||
})
|
goOrderDetails(data.result.orderId, type)
|
||||||
}
|
})
|
||||||
|
break;
|
||||||
|
}
|
||||||
export function goOrderDetails(id, type) {
|
})
|
||||||
// 创建订单时跳转到详情
|
}
|
||||||
if (type == 'create') {
|
|
||||||
console.log(_router)
|
export function subscribeMessage() {
|
||||||
_router.replace({
|
// 调用订阅
|
||||||
path: "/pages/order/OrderDetails/index",
|
console.log('调用订阅')
|
||||||
query: {
|
uni.requestSubscribeMessage({
|
||||||
id
|
tmplIds: ['W5r2c2kzhbq8uxStkPAVx_sk-5aapMFCqe7b7KU5jXI', '2CB_1UyQrbnlyjJa5syraqJ3cfztPPDOAHe3DEXpMjg',
|
||||||
},
|
'vuztugw9VbKbKJDAAVePkjqPpT5mdoREpd4Aq7EGPRU'
|
||||||
});
|
],
|
||||||
}
|
success(res) {
|
||||||
|
console.log(res)
|
||||||
|
},
|
||||||
|
fail(error) {
|
||||||
|
console.log(error)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function goOrderDetails(id, type) {
|
||||||
|
// 创建订单时跳转到详情
|
||||||
|
if (type == 'create') {
|
||||||
|
console.log(_router)
|
||||||
|
_router.replace({
|
||||||
|
path: "/pages/order/OrderDetails/index",
|
||||||
|
query: {
|
||||||
|
id
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
if (!url) {
|
if (!url) {
|
||||||
url = handleUrlParam(getCurrentPageUrlWithArgs())
|
url = handleUrlParam(getCurrentPageUrlWithArgs())
|
||||||
}
|
}
|
||||||
|
console.log(url)
|
||||||
|
console.log('判断是否是分销')
|
||||||
// 判断是否是分销
|
// 判断是否是分销
|
||||||
if (url) {
|
if (url) {
|
||||||
let urlSpread = parseInt(url.spread);
|
let urlSpread = parseInt(url.spread);
|
||||||
|
Reference in New Issue
Block a user