Browse Source

[使用消费卡]

tags/广东版3.2.1
meo 6 years ago
parent
commit
95766f3f7a
4 changed files with 136 additions and 107 deletions
  1. +1
    -2
      pages/order/detail/index.wxss
  2. +132
    -103
      pages/scanPay/scanPay.js
  3. +2
    -2
      pages/scanPay/scanPay.wxml
  4. +1
    -0
      pages/scanPay/scanPay.wxss

+ 1
- 2
pages/order/detail/index.wxss View File

@@ -166,8 +166,7 @@ page {
} }


.classif > view:nth-child(6) text:nth-child(2) { .classif > view:nth-child(6) text:nth-child(2) {
color: #ff3434;
font-weight: bold;
color: #666;
} }


.spcode { .spcode {


+ 132
- 103
pages/scanPay/scanPay.js View File

@@ -18,7 +18,7 @@ Page({
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad: function(options) {
onLoad: function (options) {
let that = this; let that = this;
that.setData({ that.setData({
merChant: JSON.parse(options.merChant), merChant: JSON.parse(options.merChant),
@@ -32,34 +32,140 @@ Page({
inputValue: e.detail.value inputValue: e.detail.value
}) })
}, },
gotoPayMoney: function() {
gotoPayMoney: function (flags) {
let that = this; let that = this;
// 卡余额充足的时候,才可以付钱 // 卡余额充足的时候,才可以付钱
if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
Http.post({
url: config.api.cardPayOrder,
data: {
cardId: that.data.cardid,
merchantCode: that.data.merChant.merchant_id,
totalFee: that.data.inputValue
// if(e){
// if(e.currentTarget.dataset.flags == 'check'){
// console.log("frhufr")
// that.setData({
// ids: e.currentTarget.dataset.id,
// cardid: e.currentTarget.dataset.id,
// remainingAmount: e.currentTarget.dataset.remainingamount,
// })
// const startSoterAuthentication = () => {
// wx.startSoterAuthentication({
// requestAuthModes: [AUTH_MODE],
// challenge: 'test',
// authContent: '请验证已有的指纹以继续',
// success: (res) => {
// that.gotoPayMoney()
// },
// fail: (err) => {

// }
// })
// }
// const checkIsEnrolled = () => {
// wx.checkIsSoterEnrolledInDevice({
// checkAuthMode: AUTH_MODE,
// success: (res) => {
// console.log(res)
// if (parseInt(res.isEnrolled) <= 0) {
// that.gotoPayMoney();
// return
// }
// startSoterAuthentication();
// },
// fail: (err) => {
// console.error(err)
// }
// })
// }
// wx.checkIsSupportSoterAuthentication({
// success: (res) => {
// console.log(res)
// checkIsEnrolled()
// },
// fail: (err) => {
// console.error(err);
// that.gotoPayMoney();
// }
// })
// }
// }
const startSoterAuthentication = () => {
wx.startSoterAuthentication({
requestAuthModes: [AUTH_MODE],
challenge: 'test',
authContent: '请验证已有的指纹以继续',
success: (res) => {
that.gotoPay()
},
fail: (err) => {

} }
}) })
.then(res => {
console.log(res);
if(res.code==200){
wx.navigateTo({
url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
})
}
const checkIsEnrolled = () => {
wx.checkIsSoterEnrolledInDevice({
checkAuthMode: AUTH_MODE,
success: (res) => {
console.log(res)
if (parseInt(res.isEnrolled) <= 0) {
that.gotoPay();
return
}
startSoterAuthentication();
},
fail: (err) => {
console.error(err)
} }
}) })
.catch(err => {
wx.showModal({
title: "抱歉",
content: err.message,
showCancel: false
}
wx.checkIsSupportSoterAuthentication({
success: (res) => {
console.log(res)
checkIsEnrolled()
},
fail: (err) => {
console.error(err);
that.gotoPay();
}
})
},
gotoPay: function () {
let that = this;
Http.post({
url: config.api.cardPayOrder,
data: {
cardId: that.data.cardid,
merchantCode: that.data.merChant.merchant_id,
totalFee: that.data.inputValue
}
})
.then(res => {
if (res.code == 200) {
that.setData({
showModel: false
})
wx.navigateTo({
url: `/pages/paySuccess/paySuccess?data=${JSON.stringify(res.data)}`,
}) })
}
})
.catch(err => {
wx.showModal({
title: "抱歉",
content: err.message,
showCancel: false
})
})
},
// 指纹识别
startAuth(e) {
let that = this;
if (e) {
if (e.currentTarget.dataset.flags == 'check') {
that.setData({
ids: e.currentTarget.dataset.id,
cardid: e.currentTarget.dataset.id,
remainingAmount: e.currentTarget.dataset.remainingamount,
}) })
} else if (that.data.inputValue == "") {
}
}
if (that.data.inputValue == "" || that.data.inputValue == 0) {
wx.showModal({ wx.showModal({
title: '抱歉', title: '抱歉',
content: '请输入金额', content: '请输入金额',
@@ -69,53 +175,12 @@ Page({
that.setData({ that.setData({
showModel: true showModel: true
}) })
that.getList();
that.getList('notenogth');
} else if (that.data.inputValue != "" && Number(that.data.remainingAmount) >= Number(that.data.inputValue)) {
that.gotoPayMoney();
} }
}, },
// 指纹识别
startAuth() {
let that = this;
const startSoterAuthentication = () => {
wx.startSoterAuthentication({
requestAuthModes: [AUTH_MODE],
challenge: 'test',
authContent: '请验证已有的指纹以继续',
success: (res) => {
that.gotoPayMoney();
},
fail: (err) => {

}
})
}
const checkIsEnrolled = () => {
wx.checkIsSoterEnrolledInDevice({
checkAuthMode: AUTH_MODE,
success: (res) => {
console.log(res)
if (parseInt(res.isEnrolled) <= 0) {
that.gotoPayMoney();
return
}
startSoterAuthentication();
},
fail: (err) => {
console.error(err)
}
})
}
wx.checkIsSupportSoterAuthentication({
success: (res) => {
console.log(res)
checkIsEnrolled()
},
fail: (err) => {
console.error(err);
that.gotoPayMoney();
}
})
},
gotonewcard: function() {
gotonewcard: function () {
wx.navigateTo({ wx.navigateTo({
url: '/pages/discountCardList/discountCardList' url: '/pages/discountCardList/discountCardList'
}) })
@@ -159,45 +224,9 @@ Page({
}) })
}) })
}, },
check: function(e) {
let ids = e.currentTarget.dataset.id;
this.setData({
ids: ids,
cardId: ids,
remainingAmount: e.currentTarget.dataset.remainingamount
})
},
showModel: function() {
showModel: function () {
this.setData({ this.setData({
showModel: false showModel: false
}) })
}, },

/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {

},

/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {

},

/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {

},

/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {

},
}) })

+ 2
- 2
pages/scanPay/scanPay.wxml View File

@@ -17,12 +17,12 @@
</view> </view>
<view class='card-content'> <view class='card-content'>
<scroll-view scroll-y style="height: 500rpx;" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}"> <scroll-view scroll-y style="height: 500rpx;" bindscroll="scroll" scroll-into-view="{{toView}}" scroll-top="{{scrollTop}}">
<view class='card-items {{item.remainingAmount/100>=inputValue&&item.flag?"":"opcacity"}}' wx:for="{{cardList}}" wx:key="{{index}}" data-remainingAmount='{{item.remainingAmount/100}}' data-id="{{item.id}}" bindtap='check'>
<view class='card-items {{item.remainingAmount/100>=inputValue&&item.flag?"":"opcacity"}}' wx:for="{{cardList}}" wx:key="{{index}}" data-remainingAmount='{{item.remainingAmount/100}}' data-id="{{item.id}}" data-flags="check" bindtap='startAuth'>
<view class='card-items-left'> <view class='card-items-left'>
<view class='card-items-left-img'> <view class='card-items-left-img'>
<image src='{{item.coverImg}}'></image> <image src='{{item.coverImg}}'></image>
</view> </view>
<view class='card-items-left-text'>{{item.title}}</view>
<view class='card-items-left-text'>{{item.id}}</view>
</view> </view>
<view class='card-items-right'> <view class='card-items-right'>
<view class='card-items-right-text'>余额:{{item.remainingAmount/100}}元</view> <view class='card-items-right-text'>余额:{{item.remainingAmount/100}}元</view>


+ 1
- 0
pages/scanPay/scanPay.wxss View File

@@ -102,6 +102,7 @@
top: 0; top: 0;
bottom: 0; bottom: 0;
margin: auto; margin: auto;
z-index: 100;
} }
.card-items{ .card-items{
position: relative; position: relative;


Loading…
Cancel
Save