Selaa lähdekoodia

[购买免费券支付成功][修改]:购买返回券,支付成功,消息提示

tags/2.2.4
meo 6 vuotta sitten
vanhempi
commit
a843f858e4
10 muutettua tiedostoa jossa 284 lisäystä ja 65 poistoa
  1. +3
    -5
      components/coupons/index.wxml
  2. +1
    -1
      pages/bannerdetail/index.wxml
  3. +0
    -1
      pages/bannerdetail/index.wxss
  4. +42
    -39
      pages/coupon/detail/index.js
  5. +2
    -1
      pages/coupon/detail/index.wxml
  6. +188
    -3
      pages/order/detail/index.js
  7. +6
    -2
      pages/order/detail/index.wxml
  8. +31
    -10
      pages/order/detail/index.wxss
  9. +9
    -1
      pages/order/index/index.js
  10. +2
    -2
      pages/order/index/index.wxml

+ 3
- 5
components/coupons/index.wxml Näytä tiedosto

@@ -23,11 +23,9 @@
<view class="coupons-info-name subtitle sy">剩余: {{data.remainInventory}}</view>
<!-- <text class="coupons-info-price-o"><text class='i'>¥</text>{{data.priceStr}}</text> -->
</view>
<i-button i-class="coupons-btn-gm" wx:if="{{data.type==4}}" data-date='{{data}}'>领取</i-button>
<i-button i-class="coupons-btn-gm" wx:elif="{{data.type == 1||data.type == 2||data.type==3||data.type==4}}" data-date='{{data}}'>购买</i-button>
<i-button i-class="coupons-btn-gm" wx:if="{{data.salePriceStr==0}}" data-date='{{data}}'>领取</i-button>
<i-button i-class="coupons-btn-gm" wx:elif="{{data.salePriceStr!=0}}" data-date='{{data}}'>购买</i-button>
</view>
<view class="coupons-border"></view>
</view>
</navigator>
<view class="loading" hidden="{{!searchLoading}}">正在载入更多...</view>
<view class="loading complete" hidden="{{!searchLoadingComplete}}">已加载全部</view>
</navigator>

+ 1
- 1
pages/bannerdetail/index.wxml Näytä tiedosto

@@ -37,7 +37,7 @@
</view> -->

<!-- 优惠券 -->
<navigator wx:for="{{data.coupons}}" url="/pages/coupon/detail/index?id={{item.id}}">
<navigator wx:for="{{data.coupons}}" wx:key="{{index}}" url="/pages/coupon/detail/index?id={{item.id}}">
<!-- 首页优惠券列表页面 -->
<view class="coupons1">
<view class="coupons1-img">


+ 0
- 1
pages/bannerdetail/index.wxss Näytä tiedosto

@@ -4,7 +4,6 @@
background: #f6f6f6;
position: relative;
overflow: hidden;
padding-bottom: 120rpx;
}

.coupons-body {


+ 42
- 39
pages/coupon/detail/index.js Näytä tiedosto

@@ -18,7 +18,7 @@ Page({
that.setData({
couponChannelId: options.couponChannelId,
couponId: options.couponId
})
});
wx.showLoading({
title: "加载中..."
});
@@ -29,7 +29,7 @@ Page({
Http.get({
url: config.api.couponDetail,
data: {
couponChannelId: options.couponChannelId,
couponChannelId: options.couponChannelId
}
}).then(res => {
console.log(res);
@@ -72,14 +72,14 @@ Page({
payOrderUpdate: (orderId, payOrderId, status, reason) => {
// 支付成功
Http.post({
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
orderId: orderId,
status: status,
reason: reason
}
})
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
orderId: orderId,
status: status,
reason: reason
}
})
.then(res => {
console.log("payOrderUpdate then", res);
// wx.showToast({
@@ -104,9 +104,9 @@ Page({
// TODO 选取用户下的车牌
} else {
Http.post({
url: config.api.checkPhoneStatus,
data: {}
})
url: config.api.checkPhoneStatus,
data: {}
})
.then(res => {
console.log(res);
/**
@@ -115,8 +115,8 @@ Page({
return Http.post({
url: config.api.orderSave,
data: {
couponChannelId: '' + that.data.couponChannelId,
couponId: '' + that.data.couponId
couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId
}
});
})
@@ -125,17 +125,27 @@ Page({
if (err.code == 11005) {
// 用户手机未授权
wx.redirectTo({
url: "../../getphoneInfo/index?couponChannelId=" + that.data.couponChannelId + "&couponId=" + that.data.couponId
url:
"../../getphoneInfo/index?couponChannelId=" +
that.data.couponChannelId +
"&couponId=" +
that.data.couponId
});
}
if (err.code == 11006) {
// 用户手机已加密
wx.redirectTo({
url: "../../phoneinput/phoneinput?couponChannelId=" + that.data.couponChannelId + "& couponId=" + that.data.couponId
url:
"../../phoneinput/phoneinput?couponChannelId=" +
that.data.couponChannelId +
"& couponId=" +
that.data.couponId
});
}
})
.then(res => {
console.log(res);
console.log("点击领取卡券一直在loading");
if (res != "undefined") {
const orderId = "" + res.data.id;
that.setData({
@@ -153,7 +163,7 @@ Page({
}
}).then(res => {
console.log(res);
/// Begin payment ----
var payOrderId = "" + res.data.payOrderId;
wx.hideLoading();
@@ -166,17 +176,15 @@ Page({
success: res => {
console.log(res);
console.log("姐在检查付款异常");

that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功

console.log(res);
if(res.errMsg=='requestPayment:ok'){
if (res.errMsg == "requestPayment:ok") {
wx.showToast({
title: "购买成功",
duration: 2500
});
}
wx.navigateBack({
delta: 2
});
@@ -208,22 +216,19 @@ Page({
// wx.navigateBack();
// }, 2000);
// }
}
else {
} else {
wx.showToast({
title:'支付失败',
image:'./../../../assets/img/fail.png',
title: "支付失败",
image: "./../../../assets/img/fail.png",
duration: 1500,
mask:false
})
mask: false
});
}
return;
}
});
/// End payment --------
///// virtual pay
//var payOrderId = "" + res.data.out_trade_no;
//that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
@@ -231,13 +236,11 @@ Page({
});
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1) // 支付成功
.then(res => {
wx.showToast({
title: "支付成功",
duration: 3000
});
});
that.payOrderUpdate(orderId, "0", 1);
wx.showToast({
title: "领取成功",
duration: 3000
});
}
}
})
@@ -246,4 +249,4 @@ Page({
});
}
}
});
});

+ 2
- 1
pages/coupon/detail/index.wxml Näytä tiedosto

@@ -47,6 +47,7 @@
</view>
</view>
<view class="buy-view app-border-top">
<button bindtap='orderFunc' class='buy'>立即购买</button>
<button bindtap='orderFunc' class='buy' wx:if="{{data.salePriceStr!=0}}">立即购买</button>
<button bindtap='orderFunc' class='buy' wx:elif="{{data.salePriceStr==0}}">免费领取</button>
</view>
</view>

+ 188
- 3
pages/order/detail/index.js Näytä tiedosto

@@ -71,6 +71,8 @@ Page({
onLoad: function(options) {
let that = this;
console.log(options.orderId);
console.log(options.flag + "我是付款的标识");

Http.get({
url: config.api.orderDetail,
data: {
@@ -85,14 +87,197 @@ Page({

//createDate 创建时间
var createDate = util.fmtDate(res.data.createDate);
console.log(createDate);
that.setData({
createDate:createDate,
})
createDate: createDate
});
});
},

/**
* 发起支付
*/
// orderFunc(e) {
// var that = this;
// console.log(e.currentTarget.dataset.couponchannelid);
// wx.showLoading({
// title: "加载中..."
// });
// Http.post({
// url: config.api.checkPhoneStatus,
// data: {}
// })
// .then(res => {
// console.log(res);
// /**
// * orderSave 下单
// */
// return Http.post({
// url: config.api.orderSave,
// data: {
// couponChannelId: "" + e.currentTarget.dataset.couponchannelid,
// couponId: "" + that.data.couponId
// }
// });
// })
// .catch(err => {
// console.log(err);
// if (err.code == 11005) {
// // 用户手机未授权
// wx.redirectTo({
// url:
// "../../getphoneInfo/index?couponChannelId=" +
// that.data.couponChannelId +
// "&couponId=" +
// that.data.couponId
// });
// }
// if (err.code == 11006) {
// // 用户手机已加密
// wx.redirectTo({
// url:
// "../../phoneinput/phoneinput?couponChannelId=" +
// that.data.couponChannelId +
// "& couponId=" +
// that.data.couponId
// });
// }
// })
// .then(res => {
// if (res != "undefined") {
// const orderId = "" + res.data.id;
// that.setData({
// orderId: orderId
// });
// if (res.data.payment > 0) {
// // 支付金额不为0
// /**
// * 支付订单创建
// */
// Http.post({
// url: config.api.payOrderCreate,
// data: {
// orderId: orderId
// }
// }).then(res => {
// console.log(res);

// /// Begin payment ----
// var payOrderId = "" + res.data.payOrderId;
// wx.hideLoading();
// wx.requestPayment({
// timeStamp: res.data.timeStamp,
// nonceStr: res.data.nonceStr,
// package: res.data.package,
// signType: "MD5",
// paySign: res.data.paySign,
// success: res => {
// console.log(res);
// console.log("姐在检查付款异常");

// that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功

// console.log(res);
// if (res.errMsg == "requestPayment:ok") {
// wx.showToast({
// title: "购买成功",
// duration: 2500
// });
// }

// wx.navigateBack({
// delta: 2
// });
// },

// fail: res => {
// that.payOrderUpdate(that.data.orderId, payOrderId, 2); // 支付失败
// console.log(res);
// return;
// },
// complete: res => {
// console.log(res);
// console.log("支付完成");
// // var url = res.data.url;
// // console.log("get url", url);
// if (res.errMsg == "requestPayment:ok") {
// wx.showModal({
// title: "提示",
// content: "支付成功"
// });
// // if (url) {
// // setTimeout(function () {
// // wx.redirectTo({
// // url: "/pages" + url
// // });
// // }, 2000);
// // } else {
// // setTimeout(() => {
// // wx.navigateBack();
// // }, 2000);
// // }
// } else {
// wx.showToast({
// title: "支付失败",
// image: "./../../../assets/img/fail.png",
// duration: 1500,
// mask: false
// });
// }
// return;
// }
// });
// /// End payment --------

// ///// virtual pay
// //var payOrderId = "" + res.data.out_trade_no;
// //that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
// ///// end virtual pay
// });
// } else {
// // 免费券
// that
// .payOrderUpdate(orderId, "0", 1) // 支付成功
// .then(res => {
// wx.showToast({
// title: "支付成功",
// duration: 3000
// });
// });
// }
// }
// })
// .catch(err => {
// console.log(err);
// });
// },
/**
* 支付订单更新
*/
// payOrderUpdate: (orderId, payOrderId, status, reason) => {
// // 支付成功
// Http.post({
// url: config.api.payOrderUpdate,
// data: {
// payOrderId: payOrderId,
// orderId: orderId,
// status: status,
// reason: reason
// }
// })
// .then(res => {
// console.log("payOrderUpdate then", res);
// // wx.showToast({
// // title: "购买成功",
// // duration: 2500
// // });
// })
// .catch(err => {
// console.log("payOrderUpdate catch", err);
// });
// },

/**
* 生命周期函数--监听页面初次渲染完成
*/


+ 6
- 2
pages/order/detail/index.wxml Näytä tiedosto

@@ -1,7 +1,7 @@
<view class='order'>
<view class='tips'>
<view wx:if="{{data.orderStatus==1}}" class='tips'>
<text class='iconfont icon-choose'></text>
<text wx:if="{{data.orderStatus==1}}">付款成功,请尽快到门店使用</text>
<text>付款成功,请尽快到门店使用</text>
</view>
<view class='section'>
<view class='detail_msg'>
@@ -51,6 +51,10 @@
<text class="jine">¥{{data.salePrice/100}}</text>
</view>
</view>
<!-- 待付款 显示立即购买的按钮 -->
<!-- <view wx:if="{{data.orderStatus==1}}" class="buy-view app-border-top">
<button bindtap='orderFunc' data-couponChannelId="{{data.id}}" class='buy'>立即购买</button>
</view> -->
</view>




+ 31
- 10
pages/order/detail/index.wxss Näytä tiedosto

@@ -47,7 +47,7 @@
.logo image {
width: 100%;
height: 100%;
border-radius:16rpx;
border-radius: 16rpx;
}

.info view:nth-child(1) {
@@ -133,7 +133,7 @@
}
.classif > view:nth-child(1) {
display: block;
border-top:20rpx solid #f8f8f8;
border-top: 20rpx solid #f8f8f8;
}
.classif > view:nth-child(1) text:nth-child(2) {
padding-left: 15rpx;
@@ -260,7 +260,7 @@ radio {
height: 0;
clear: both;
visibility: hidden;
}
}
.panel {
width: 600rpx;
border-radius: 10rpx;
@@ -270,11 +270,11 @@ radio {
position: relative;
z-index: 10000000000;
}
.pane2{
.pane2 {
background: #fff;
opacity: .6;
opacity: 0.6;
}
.pane2 image{
.pane2 image {
width: 500rpx;
display: block;
margin: 40rpx auto 0;
@@ -317,7 +317,28 @@ radio {
width: 350rpx;
height: 350rpx;
}
.jine{
color: #f96563!important;
font-size: 36rpx!important;
}
.jine {
color: #f96563 !important;
font-size: 36rpx !important;
}

.buy-view {
background: #fff;
position: fixed;
padding-top: 10rpx;
height: 98rpx;
bottom: 0rpx;
left: 0;
right: 0;
}

.buy {
background: #00c0ff;
height: 88rpx;
width: 98%;
margin: 0 auto;
color: #fff;
font-size: 36rpx;
line-height: 88rpx;
border-radius: 6rpx;
}

+ 9
- 1
pages/order/index/index.js Näytä tiedosto

@@ -1,5 +1,6 @@
let config = require("../../../config/config.js");
let Http = require("../../../utils/HttpBasics");
const util = require("../../../utils/util");
let app = getApp();

Page({
@@ -30,10 +31,11 @@ Page({
current_scroll: e.id
});
},
gotopay:function(e){
console.log("orderId"+e.currentTarget.dataset.id);
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}`,
url: `/pages/order/detail/index?orderId=${e.currentTarget.dataset.id}&flag='pay'`,
success: function(res){
// success
},
@@ -96,6 +98,12 @@ Page({
that.setData({
list: that.data.list
});
for(let i=0; i<that.data.list.length; i++){
console.log(i);
that.setData({
createDate:util.fmtDate(that.data.list[i].createDate)
})
}
});
} else {
console.log("加载完成allow_load设置成false");


+ 2
- 2
pages/order/index/index.wxml Näytä tiedosto

@@ -13,11 +13,11 @@
<text>{{item.title}}</text>
<text wx:if="{{item.orderStatus==0}}">等待付款</text>
<text wx:if="{{item.orderStatus==1}}">已付款</text>
<text wx:if="{{item.orderStatus==2}}">取消</text>
<text wx:if="{{item.orderStatus==2}}">订单取消</text>
</view>
<view>{{item.subTitle}}</view>
<view>
<text>下单时间:</text>2018-07-10 11:30
<text>下单时间:</text>{{createDate}}
</view>
</view>
</view>


Ladataan…
Peruuta
Tallenna