Browse Source

支付调通

tags/2.2.4
Stormeye.Wu 6 years ago
parent
commit
64f67e2c0b
4 changed files with 64 additions and 47 deletions
  1. +7
    -4
      components/coupons/index.wxml
  2. +50
    -39
      pages/coupons/details/index.js
  3. +3
    -3
      pages/coupons/details/index.wxml
  4. +4
    -1
      pages/coupons/index/index.wxml

+ 7
- 4
components/coupons/index.wxml View File

@@ -4,16 +4,19 @@
<image src="{{data.coverImg}}"></image>
</view>
<view class="coupons-info">
<view class="coupons-info-name">{{data.name}}</view>
<view class="coupons-info-name">{{data.title}}</view>
<view class="coupons-info-name">{{data.subTitle}}</view>
<view class="coupons-info-price">
<text class="coupons-info-price-p">¥{{data.salePrice}}</text>
<text class="coupons-info-price-o">¥{{data.price}}</text>
<text class="coupons-info-price-p">¥{{data.salePrice/100}}</text>
<text class="coupons-info-price-o">¥{{data.price/100}}</text>
</view>
<view class="coupons-info-distance">
<text class="iconfont icon-dingweib"></text>
{{data.salePrice}}
</view>
<view class="coupons-info-address">{{data.salePrice}}</view>
<!--
<view class="coupons-info-address">{{data.}}</view>
-->
</view>
<view class="coupons-btn">
<i-button i-class="coupons-btn-gm" bind:click="navigateTo" data-date='{{data}}'>购买</i-button>


+ 50
- 39
pages/coupons/details/index.js View File

@@ -27,26 +27,35 @@ Page({
couponId: e.id
})
})
}
}
},
/**
* 支付订单更新
*/
payOrderUpdate: (orderId, payOrderId, status, reason) => {
// 支付成功
return Http.post({
url: config.api.payOrderUpdate,
data: {
payOrderId: payOrderId,
orderId: orderId,
status: status,
reason: 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);
})
},
payment: (res) => {
var that = this;
var payOrderId = '' + res.payOrderId;
var payOrderId = '' + res.data.out_trade_no;
wx.requestPayment({
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
@@ -123,7 +132,7 @@ Page({
if (err.code == 11005) {
// 用户手机未授权
wx.redirectTo({
url: '../../getphoneInfo/index?couponId='+that.data.couponId,
url: '../../getphoneInfo/index?couponId=' + that.data.couponId,
})
}
if (err.code == 11006) {
@@ -134,36 +143,38 @@ Page({
}
})
.then(res => {
const orderId = '' + res.data.id;
that.setData({
orderId: orderId
})
if (res.data.payment > 0) {
// real pay
return Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId
}
if (res != "undefined") {
const orderId = '' + res.data.id;
that.setData({
orderId: orderId
})
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1) // 支付成功
.then(res => {
wx.showToast({
title: "支付成功",
duration: 3000
})
if (res.data.payment > 0) {
// 支付金额不为0
Http.post({
url: config.api.payOrderCreate,
data: {
orderId: orderId
}
}).then(res => {
console.log(res)
var payOrderId = '' + res.data.out_trade_no;
wx.hideLoading();
//payment(res);
that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功
})
} else {
// 免费券
that.payOrderUpdate(orderId, "0", 1) // 支付成功
.then(res => {
wx.showToast({
title: "支付成功",
duration: 3000
})
})
}
}
}).then(res => {
console.log(res)
if (res) {
var payOrderId = '' + res.payOrderId;
wx.hideLoading();
//payment(res);
that.payOrderUpdate(that.data.orderId, payOrderId, 1) // 支付成功
}
}).catch(err => {
console.log(err)
})
},
})

+ 3
- 3
pages/coupons/details/index.wxml View File

@@ -5,13 +5,13 @@
</view>
<view class='coupons_info'>
<view>
<text>{{data.title}}<text>限购件</text></text>
<text>{{data.title}}<text>限购{{data.useLimitQuantity}}件</text></text>
<text>剩余时间:<text>2天12小时25分钟</text></text>
<text>剩余件数:<text>19件</text></text>
<text>剩余件数:<text>{{data.remainInventory}}件</text></text>
</view>
<view>
<text>¥{{data.salePriceStr}}</text>
<text>¥59.00</text>
<text>¥{{data.priceStr}}</text>
</view>
</view>
<view class='posi'>


+ 4
- 1
pages/coupons/index/index.wxml View File

@@ -9,7 +9,10 @@
</view>
<view class='info'>
<view>
<text>黑椒牛排</text>
<text>{{item.title}}</text>
</view>
<view>
<text>{{item.subTitle}}</text>
</view>
<view>
<text>有效期至:</text>{{item.expiredTime}}</view>


Loading…
Cancel
Save