|
@@ -183,60 +183,67 @@ export default {
|
|
|
// 提交订单
|
|
|
async toSubmit() {
|
|
|
const that = this;
|
|
|
- let data = {
|
|
|
- address: that.address,
|
|
|
- goods: that.orderList,
|
|
|
- total_detail: that.total_detail
|
|
|
- }
|
|
|
- const arr = await that.$api(`/order`, 'POST', data)
|
|
|
- console.log(arr)
|
|
|
- if (arr.errcode == '0') {
|
|
|
- uni.getStorage({
|
|
|
- key: 'system',
|
|
|
- success: async function (res) {
|
|
|
- // 微信小程序支付
|
|
|
- if (res.data.uniPlatform == "mp-weixin") {
|
|
|
- const res = await that.$api('/pay/toPayOrder', 'POST', { order_id: arr.data, type: '0' })
|
|
|
- console.log(res);
|
|
|
- uni.requestPayment({
|
|
|
- "provider": "wxpay",
|
|
|
- ...res.data,
|
|
|
- success(res) {
|
|
|
- console.log('in success');
|
|
|
- console.log(res)
|
|
|
- },
|
|
|
- fail(e) {
|
|
|
- console.log('in fail');
|
|
|
- console.log(e)
|
|
|
- }
|
|
|
- })
|
|
|
- } 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) { }
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: arr.data.msg,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- }
|
|
|
+ if(that.address){
|
|
|
+ let data = {
|
|
|
+ address: that.address,
|
|
|
+ goods: that.orderList,
|
|
|
+ total_detail: that.total_detail
|
|
|
+ }
|
|
|
+ const arr = await that.$api(`/order`, 'POST', data)
|
|
|
+ console.log(arr)
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'system',
|
|
|
+ success: async function (res) {
|
|
|
+ // 微信小程序支付
|
|
|
+ if (res.data.uniPlatform == "mp-weixin") {
|
|
|
+ const res = await that.$api('/pay/toPayOrder', 'POST', { order_id: arr.data, type: '0' })
|
|
|
+ console.log(res);
|
|
|
+ uni.requestPayment({
|
|
|
+ "provider": "wxpay",
|
|
|
+ ...res.data,
|
|
|
+ success(res) {
|
|
|
+ console.log('in success');
|
|
|
+ console.log(res)
|
|
|
+ },
|
|
|
+ fail(e) {
|
|
|
+ console.log('in fail');
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } 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) { }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.data.msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ uni.showToast({
|
|
|
+ title: `没有收货地址`,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 监听用户是否登录
|
|
|
watchLogin() {
|