Skip to content

Commit

Permalink
Merge pull request #148 from dengjunwen1992/master
Browse files Browse the repository at this point in the history
添加充值优惠按钮
  • Loading branch information
gooking committed Feb 27, 2019
2 parents 53bed17 + d4c2f5e commit f88c039
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 20 deletions.
40 changes: 27 additions & 13 deletions pages/recharge/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,24 @@ Page({
});
},

/**
* 点击充值优惠的充值送
*/
rechargeAmount: function (e) {
var confine = e.currentTarget.dataset.confine;
var amount = confine;
this.setData({
amount: amount
});
wxpay.wxpay(app, amount, 0, "/pages/cashier/cashier");
},


/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {

},

/**
Expand All @@ -44,43 +57,44 @@ Page({
_this.setData({
rechargeSendRules: res.data
});
}
}
})

},

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

},

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

},

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

},

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

},

/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {

},
bindSave: function (e) {
WXAPI.addTempleMsgFormid({
Expand All @@ -91,18 +105,18 @@ Page({
var that = this;
var amount = e.detail.value.amount;

if (amount == "" || amount*1 < 0) {
if (amount == "" || amount * 1 < 0) {
wx.showModal({
title: '错误',
content: '请填写正确的充值金额',
showCancel: false
})
return
}
if (amount * 1 < that.data.recharge_amount_min*1) {
if (amount * 1 < that.data.recharge_amount_min * 1) {
wx.showModal({
title: '错误',
content: '单次充值金额至少' + that.data.recharge_amount_min +'元',
content: '单次充值金额至少' + that.data.recharge_amount_min + '元',
showCancel: false
})
return
Expand Down Expand Up @@ -135,9 +149,9 @@ Page({
_this: that
})
})
}
}
},
saveToMobile: function(){
saveToMobile: function () {
wx.canvasToTempFilePath({
canvasId: 'myQrcode',
success: function (res) {
Expand All @@ -163,4 +177,4 @@ Page({
}
})
}
})
})
24 changes: 21 additions & 3 deletions pages/recharge/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<view class="row-wrap">
<view class="label">充值金额</view>
<view class="label-right">
<input name="amount" class="input" type="text" placeholder="至少充值 {{recharge_amount_min}} 元"/>
<input name="amount" class="input" type="text" value="{{amount}}" placeholder="至少充值 {{recharge_amount_min}} 元"/>
</view>
</view>
</view>
Expand All @@ -13,13 +13,31 @@
<radio-group name="type" class="radio-group">
<label class="radio">
<radio value="wx" checked /> 微信支付
</label>
</label>
<label class="radio" style='margin-left:20rpx;'>
<radio value="alipay" /> 支付宝
</label>
</radio-group>
</view>
</view>


<block wx:if='{{rechargeSendRules}}'>
<view class="charge-rule-wrap">
<block wx:for='{{rechargeSendRules}}' wx:for-item="item">

<!-- <button class='font charge-detail' bindtap="rechargeAmount" data-confine="{{item.confine}}" data-send="{{item.send}}">
<text>充{{item.confine}}送{{item.send}}</text>
</button> -->
<view class="btn charge-detail" bindtap="rechargeAmount" data-confine="{{item.confine}}" data-send="{{item.send}}">
<text>充{{item.confine}}</text>
<text>送{{item.send}}</text>
</view>
</block>

</view>
</block>

<button type="warn" class="save-btn" formType="submit">立即支付</button>
</form>
<view wx:if="{{showalipay}}" style='width:100%;font-size: 30rpx;margin-top:30rpx;color:red;text-align:center;margin-bottom:30rpx;'>保存以下二维码,使用支付宝扫码付款</view>
Expand All @@ -35,4 +53,4 @@
</view>
</view>
</view>
</view>
</view>
48 changes: 45 additions & 3 deletions pages/recharge/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ page{
padding-right: 30rpx;
}
.row-wrap .right-box{
margin-right: 30rpx;
margin-right: 30rpx;
}
.arrow-right{
width: 15rpx;
Expand All @@ -47,7 +47,7 @@ page{
height: 80rpx;
line-height: 80rpx;
text-align: center;
margin-top:30rpx;
margin-top:30rpx;
border-radius: 6rpx;
box-sizing: border-box;
}
Expand Down Expand Up @@ -85,6 +85,48 @@ picker {
.hui{
color: #777;
}

.weui-panel {
width:740rpx;
}
}


.charge-rule-wrap{
background: white;
margin-top:20rpx;
padding:10rpx;
padding-left:20rpx;
display: flex;
flex-direction:row;
flex-wrap:wrap;
}
.btn{
box-sizing: border-box;
text-align: center;
border-radius: 6rpx;
margin-left: 20rpx;
}
.charge-detail{
width:220rpx;
height:100rpx;
color:rgba(99, 190, 133, 1);
background-color:white;
border:3rpx solid rgba(99, 190, 133, 1);
display:table-cell;
line-height:30rpx;
font-weight:300;
font-size:30rpx;
margin:10rpx;
align-items:flex-start;
}
.charge-detail text{
vertical-align:middle;
font-size: 28rpx;
display: flex;
justify-content: center;
align-items: center;
margin-top:12rpx;
}
.button-hover{
background-color:grey;
}
2 changes: 1 addition & 1 deletion wxapi/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ module.exports = {
rechargeSendRules: () => {
return request('/user/recharge/send/rule', true, 'get')
}
}
}

0 comments on commit f88c039

Please sign in to comment.