|
@@ -108,6 +108,8 @@
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ // 设备平台信息
|
|
|
+ system: {},
|
|
|
popup: {
|
|
|
type: '1'
|
|
|
},
|
|
@@ -158,6 +160,9 @@
|
|
|
success: function(res) {
|
|
|
let user = that.$jwt(res.data);
|
|
|
that.$set(that, `user`, user);
|
|
|
+ // 设备平台信息
|
|
|
+ let config = that.$config;
|
|
|
+ that.$set(that, `system`, config.system);
|
|
|
that.search()
|
|
|
},
|
|
|
fail: function(err) {
|
|
@@ -226,8 +231,9 @@
|
|
|
// 提交订单
|
|
|
async toSubmit() {
|
|
|
const that = this;
|
|
|
+ let system = that.system;
|
|
|
if (that.address) {
|
|
|
- let data = {
|
|
|
+ let obj = {
|
|
|
address: that.address,
|
|
|
goods: that.orderList,
|
|
|
total_detail: that.total_detail,
|
|
@@ -235,85 +241,84 @@
|
|
|
type: that.type,
|
|
|
inviter: that.inviter
|
|
|
}
|
|
|
- if (that.group_id) {
|
|
|
- data.group = that.group_id
|
|
|
- }
|
|
|
- const arr = await that.$api(`/order`, 'POST', data)
|
|
|
- if (arr.errcode == '0') {
|
|
|
- uni.getStorage({
|
|
|
- key: 'system',
|
|
|
- success: async function(res) {
|
|
|
- // 微信小程序支付
|
|
|
- if (res.data.uniPlatform == "mp-weixin") {
|
|
|
- uni.showLoading({
|
|
|
- title: '加载中'
|
|
|
- })
|
|
|
- const res = await that.$api('/pay/toPayOrder', 'POST', {
|
|
|
- order_id: arr.data,
|
|
|
- type: '0'
|
|
|
- })
|
|
|
- uni.requestPayment({
|
|
|
- "provider": "wxpay",
|
|
|
- ...res.data,
|
|
|
- async success(res) {
|
|
|
- const group = await that.$api('/group/getGroup',
|
|
|
- 'GET', {
|
|
|
- order_id: arr.data,
|
|
|
+ if (that.group_id) obj.group = that.group_id;
|
|
|
+ // 创建订单
|
|
|
+ let p1 = await that.$api(`/order`, 'POST', obj);
|
|
|
+ if (p1.errcode == '0') {
|
|
|
+ if (system.uniPlatform == "mp-weixin") {
|
|
|
+ // 微信支付
|
|
|
+ uni.showLoading({
|
|
|
+ title: '加载中'
|
|
|
+ })
|
|
|
+ // 支付信息
|
|
|
+ let p2 = await that.$api('/pay/toPayOrder', 'POST', {
|
|
|
+ order_id: p1.data,
|
|
|
+ type: '0'
|
|
|
+ })
|
|
|
+ if (p2.errcode == '0' && p2.data.paySign) {
|
|
|
+ uni.requestPayment({
|
|
|
+ "provider": "wxpay",
|
|
|
+ ...p2.data,
|
|
|
+ success: async function(res) {
|
|
|
+ // 获取团信息
|
|
|
+ let p3 = await that.$api('/group/getGroup', 'GET', {
|
|
|
+ order_id: p1.data,
|
|
|
+ })
|
|
|
+ if (p3.errcode == '0') {
|
|
|
+ uni.hideLoading();
|
|
|
+ if (p3.data) {
|
|
|
+ uni.reLaunch({
|
|
|
+ url: `/pagesHome/group/share?id=${p3.data}`
|
|
|
})
|
|
|
- if (group.errcode == '0') {
|
|
|
- if (group.data) {
|
|
|
- uni.hideLoading();
|
|
|
- uni.reLaunch({
|
|
|
- url: `/pagesHome/group/share?id=${group.data}`
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.hideLoading();
|
|
|
- uni.reLaunch({
|
|
|
- url: `/pagesMy/order/index?status=${'1'}`
|
|
|
- })
|
|
|
- }
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
- title: group.errmsg,
|
|
|
- icon: 'none'
|
|
|
+ uni.reLaunch({
|
|
|
+ url: `/pagesMy/order/index?status=${'1'}`
|
|
|
})
|
|
|
}
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
+ } else {
|
|
|
uni.showToast({
|
|
|
- title: `支付失败`,
|
|
|
+ title: p3.errmsg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
- uni.hideLoading();
|
|
|
- uni.reLaunch({
|
|
|
- url: `/pagesMy/order/index?status=${'0'}`
|
|
|
- })
|
|
|
}
|
|
|
- })
|
|
|
- } else if (res.data.uniPlatform == "app") {
|
|
|
- // app支付
|
|
|
- uni.requestPayment({
|
|
|
- provider: 'alipay',
|
|
|
- orderInfo: 'orderInfo', //微信、支付宝订单数据 【注意微信的订单信息,键值应该全部是小写,不能采用驼峰命名】
|
|
|
- success: function(res) {
|
|
|
- console.log('success:' + JSON.stringify(res));
|
|
|
- },
|
|
|
- fail: function(err) {
|
|
|
- console.log('fail:' + JSON.stringify(err));
|
|
|
- }
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: `平台不支持支付`,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ uni.showToast({
|
|
|
+ title: `支付失败`,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ uni.hideLoading();
|
|
|
+ uni.reLaunch({
|
|
|
+ url: `/pagesMy/order/index?status=${'0'}`
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: p2.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } else if (system.uniPlatform == "app") {
|
|
|
+ uni.requestPayment({
|
|
|
+ provider: 'alipay',
|
|
|
+ orderInfo: 'orderInfo',
|
|
|
+ success: function(res) {
|
|
|
+ console.log('success:' + JSON.stringify(res));
|
|
|
+ },
|
|
|
+ fail: function(err) {
|
|
|
+ console.log('fail:' + JSON.stringify(err));
|
|
|
}
|
|
|
- },
|
|
|
- fail: function(err) {}
|
|
|
- })
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: `平台不支持支付`,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
uni.showToast({
|
|
|
- title: arr.errmsg,
|
|
|
+ title: p1.errmsg,
|
|
|
icon: 'none'
|
|
|
})
|
|
|
}
|