|
@@ -132,7 +132,7 @@
|
|
¥<span>{{shopDetail.price}}</span>
|
|
¥<span>{{shopDetail.price}}</span>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
- <view class="buy">
|
|
|
|
|
|
+ <view class="buy" @click="!payLoding ? pay() : ''" :class="{ clickbg: payLoding }">
|
|
立即支付
|
|
立即支付
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -147,6 +147,9 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
// import uniPopup from '@/components/uni-popup/uni-popup.vue'
|
|
// import uniPopup from '@/components/uni-popup/uni-popup.vue'
|
|
|
|
+ import {
|
|
|
|
+ balance
|
|
|
|
+ } from '@/api/wallet.js';
|
|
import {
|
|
import {
|
|
mapState
|
|
mapState
|
|
} from 'vuex';
|
|
} from 'vuex';
|
|
@@ -155,15 +158,18 @@
|
|
cartAdd
|
|
cartAdd
|
|
} from '@/api/product.js';
|
|
} from '@/api/product.js';
|
|
import {
|
|
import {
|
|
- confirm
|
|
|
|
|
|
+ confirm,
|
|
|
|
+ orderPay,
|
|
|
|
+ createOrderkey
|
|
} from '@/api/order.js'
|
|
} from '@/api/order.js'
|
|
|
|
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- moneyAll: { //购物车金额详情
|
|
|
|
- totalPrice: 0 //总金额
|
|
|
|
- },
|
|
|
|
|
|
+ orderId: '', //订单编号
|
|
|
|
+ moneyAll: '', //购物车订单
|
|
|
|
+ now_money: '', //余额
|
|
|
|
+ payLoding: false, //判断是否支付中
|
|
orderKey: '', //订单的key值
|
|
orderKey: '', //订单的key值
|
|
addressData: {}, //地址信息
|
|
addressData: {}, //地址信息
|
|
shopList: [], //商品列表
|
|
shopList: [], //商品列表
|
|
@@ -178,12 +184,21 @@
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg',
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg'
|
|
// 'https://img.php.cn/upload/article/202104/15/2021041518005466284.jpg'
|
|
- ]
|
|
|
|
|
|
+ ],
|
|
|
|
+ froms: '', //保存h5中数据来源对象
|
|
};
|
|
};
|
|
},
|
|
},
|
|
async onLoad(options) {
|
|
async onLoad(options) {
|
|
this.shopId = options.id
|
|
this.shopId = options.id
|
|
this.goodsDetail()
|
|
this.goodsDetail()
|
|
|
|
+ // 载入余额
|
|
|
|
+ balance({}).then(({
|
|
|
|
+ data
|
|
|
|
+ }) => {
|
|
|
|
+ // 获取余额
|
|
|
|
+ this.now_money = data.now_money;
|
|
|
|
+ });
|
|
|
|
+
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['weichatObj', 'baseURL', 'urlFile'])
|
|
...mapState(['weichatObj', 'baseURL', 'urlFile'])
|
|
@@ -212,6 +227,8 @@
|
|
//点击购买之后自动生成订单
|
|
//点击购买之后自动生成订单
|
|
//如果订单生成没有付款,提示尚未付款,是否离开,确认离开,在我的订单里可看到尚未支付订单,点击付款,付款成功订单待发货,失败,尚未支付
|
|
//如果订单生成没有付款,提示尚未付款,是否离开,确认离开,在我的订单里可看到尚未支付订单,点击付款,付款成功订单待发货,失败,尚未支付
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+
|
|
getKeys() {
|
|
getKeys() {
|
|
let obj = this
|
|
let obj = this
|
|
confirm({
|
|
confirm({
|
|
@@ -220,22 +237,125 @@
|
|
console.log(data, '生平具体信息');
|
|
console.log(data, '生平具体信息');
|
|
obj.addressData = data.data.addressInfo || {};
|
|
obj.addressData = data.data.addressInfo || {};
|
|
obj.shopList = data.data.cartInfo; //商品列表
|
|
obj.shopList = data.data.cartInfo; //商品列表
|
|
- obj.moneyAll = data.data.priceGroup; //金额数据
|
|
|
|
|
|
+ // obj.moneyAll = data.data.cartInfo.truePrice; //金额数据
|
|
obj.orderKey = data.data.orderKey; //订单key
|
|
obj.orderKey = data.data.orderKey; //订单key
|
|
- let url = `/pages/money/pay?key=${obj.orderKey}`
|
|
|
|
- console.log(url);
|
|
|
|
|
|
+ // let url = `/pages/money/pay?key=${obj.orderKey}`
|
|
|
|
+ // console.log(url);
|
|
})
|
|
})
|
|
},
|
|
},
|
|
//支付
|
|
//支付
|
|
- pay() {
|
|
|
|
|
|
+ async pay() {
|
|
let obj = this
|
|
let obj = this
|
|
- if (obj.type == 'weixin') {
|
|
|
|
-
|
|
|
|
|
|
+ // console.log('eeeeeeeeeeeeeee');
|
|
|
|
+ console.log(obj.type == 'yue', obj.now_money, obj.shopDetail.price);
|
|
|
|
+ if (obj.type == 'yue' && obj.now_money < obj.shopDetail.price) {
|
|
|
|
+
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '账户余额不足!',
|
|
|
|
+ showCancel: false,
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // uni.hideLoading()
|
|
|
|
+ uni.showLoading({
|
|
|
|
+ title: "支付中",
|
|
|
|
+ mask: true
|
|
|
|
+ })
|
|
|
|
+ obj.payLoding = true
|
|
|
|
+ if (obj.type != 1) {
|
|
|
|
+ // 初次生成订单
|
|
|
|
+ obj.firstCreateOrder();
|
|
|
|
+ } else {
|
|
|
|
+ // 已经生成订单未支付
|
|
|
|
+ obj.orderMoneyPay();
|
|
}
|
|
}
|
|
- if (obj.type == 'yue') {
|
|
|
|
|
|
+ },
|
|
|
|
+ //非第一次支付订单
|
|
|
|
+ orderMoneyPay() {
|
|
|
|
+ let obj = this;
|
|
|
|
+ orderPay({
|
|
|
|
+ uni: obj.orderKey,
|
|
|
|
+ from: 'app', //来源
|
|
|
|
+ paytype: obj.type //支付类型 weixin-微信 yue-余额
|
|
|
|
+
|
|
|
|
+ }).then(res => {
|
|
|
|
+ console.log(res, '订单支付信息')
|
|
|
|
+ if (res.data.status == 'SUCCESS' && obj.type == 'yue') {
|
|
|
|
+ if (res.status == 200) {
|
|
|
|
+ obj.paySuccessTo()
|
|
|
|
+ } else {
|
|
|
|
+ obj.$api.msg(msg)
|
|
|
|
+ console.log('失败');
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ console.log('失败2');
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ },
|
|
|
|
+ //首次创建订单
|
|
|
|
+ firstCreateOrder() {
|
|
|
|
+ let obj = this;
|
|
|
|
+ // 获取下单页面数据
|
|
|
|
+ // let prepage = obj.$api.prePage();
|
|
|
|
+ // console.log(prepage,'prepage');
|
|
|
|
+ let pages = getCurrentPages(); // 获取页面栈
|
|
|
|
+ let current = pages[pages.length - 1]; // 当前页面
|
|
|
|
+ console.log(current, 'current');
|
|
|
|
|
|
|
|
+ let data = {
|
|
|
|
+ real_name: '', //联系人名称
|
|
|
|
+ phone: '', //联系人号码
|
|
|
|
+ couponId: '', //优惠券编号
|
|
|
|
+ addressId: '', //支付地址id
|
|
|
|
+ useIntegral: 0, //是否积分抵扣1为是0为否
|
|
|
|
+ payType: obj.type, //支付类型 weixin-微信 yue-余额
|
|
|
|
+ mark: '', //备注
|
|
|
|
+ from: 'app', //来源
|
|
|
|
+ shipping_type: 1 //提货方式 1 快递 2自提
|
|
}
|
|
}
|
|
|
|
+ // 生成订单
|
|
|
|
+ createOrderkey(data, obj.orderKey)
|
|
|
|
+ .then(({
|
|
|
|
+ data,
|
|
|
|
+ status,
|
|
|
|
+ msg
|
|
|
|
+ }) => {
|
|
|
|
+ console.log(status);
|
|
|
|
+ // 判断是否支付失败
|
|
|
|
+ if (data.status == 'ORDER_EXIST') {
|
|
|
|
+ uni.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: msg,
|
|
|
|
+ showCancel: false
|
|
|
|
+ });
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // 保存订单号
|
|
|
|
+ obj.orderId = data.result.orderId;
|
|
|
|
+ // 判断是否为余额支付
|
|
|
|
+ if (obj.type == 'yue') {
|
|
|
|
+ if (status == 200) {
|
|
|
|
+ obj.paySuccessTo();
|
|
|
|
+ } else {
|
|
|
|
+ obj.$api.msg(msg);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // 立即支付
|
|
|
|
+ obj.orderMoneyPay();
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(e => {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ obj.payLoding = false;
|
|
|
|
+ console.log(e, '123456789');
|
|
|
|
+ });
|
|
},
|
|
},
|
|
|
|
+
|
|
goodsDetail() {
|
|
goodsDetail() {
|
|
let obj = this
|
|
let obj = this
|
|
goodsDetail({}, obj.shopId).then(res => {
|
|
goodsDetail({}, obj.shopId).then(res => {
|
|
@@ -244,7 +364,14 @@
|
|
console.log(obj.shopDetail, obj.uniqueId, 'res1111');
|
|
console.log(obj.shopDetail, obj.uniqueId, 'res1111');
|
|
|
|
|
|
})
|
|
})
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ // 支付成功跳转
|
|
|
|
+ paySuccessTo() {
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/money/paySuccess?orderKey=' + this.orderKey
|
|
|
|
+ });
|
|
|
|
+ },
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -532,7 +659,12 @@
|
|
text-align: center;
|
|
text-align: center;
|
|
color: #FFFFFF;
|
|
color: #FFFFFF;
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ .clickbg {
|
|
|
|
+ background-color: $color-gray !important;
|
|
|
|
+ }
|
|
</style>
|
|
</style>
|