|
@@ -43,10 +43,14 @@
|
|
|
<text>总价¥{{item.money}}</text>
|
|
|
</view>
|
|
|
<view class="btn">
|
|
|
- <button v-if="item.status=='0'" type="default" @click="toCancel(item)" size="mini">取消订单</button>
|
|
|
- <button v-if="item.status=='0'" type="default" @click="toPay(item)" size="mini">付款</button>
|
|
|
- <button v-if="item.status=='3'" type="default" @click="toAfter(item)" size="mini">申请售后</button>
|
|
|
- <button v-if="item.status=='3'" type="default" @click="toRefund(item)" size="mini">申请退款</button>
|
|
|
+ <button v-if="item.status=='0'" type="default" @click="toCancel(item)"
|
|
|
+ size="mini">取消订单</button>
|
|
|
+ <button v-if="item.status=='0'" type="default" @click="toPay(item)"
|
|
|
+ size="mini">付款</button>
|
|
|
+ <button v-if="item.status=='3'" type="default" @click="toAfter(item)"
|
|
|
+ size="mini">申请售后</button>
|
|
|
+ <button v-if="item.status=='3'" type="default" @click="toRefund(item)"
|
|
|
+ size="mini">申请退款</button>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
@@ -157,15 +161,105 @@
|
|
|
},
|
|
|
// 取消订单
|
|
|
toCancel(e) {
|
|
|
- console.log(e);
|
|
|
+ const that = this;
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定取消订单吗?',
|
|
|
+ success: async function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const arr = await that.$api(`/order/${e._id}`, 'POST', {
|
|
|
+ status: '-1'
|
|
|
+ });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '取消订单成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ that.clearPage();
|
|
|
+ that.search();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
// 付款
|
|
|
toPay(e) {
|
|
|
- console.log(e);
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'system',
|
|
|
+ success: async function(res) {
|
|
|
+ // 微信小程序支付
|
|
|
+ if (res.data.uniPlatform == "mp-weixin") {
|
|
|
+ const res = await that.$api('/pay/toPayOrder', 'POST', {
|
|
|
+ order_id: e,
|
|
|
+ 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) {}
|
|
|
+ })
|
|
|
},
|
|
|
// 申请售后
|
|
|
toAfter(e) {
|
|
|
- console.log(e);
|
|
|
+ const that = this;
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '确定申请售后吗?',
|
|
|
+ success: async function(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ const arr = await that.$api(`/order/${e._id}`, 'POST', {
|
|
|
+ status: '-3'
|
|
|
+ });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.showToast({
|
|
|
+ title: '申请售后成功',
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ that.clearPage();
|
|
|
+ that.search();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
// 申请退款
|
|
|
toRefund(e) {
|