创建
This commit is contained in:
150
pages/voucher/voucher.js
Normal file
150
pages/voucher/voucher.js
Normal file
@@ -0,0 +1,150 @@
|
||||
var t = getApp(), e = require("../../utils/login.js");
|
||||
|
||||
Page({
|
||||
data: {
|
||||
showLoding: !0,
|
||||
list: [],
|
||||
user: {},
|
||||
page: {
|
||||
next_page: 1
|
||||
},
|
||||
servicetel: "",
|
||||
edition: 1,
|
||||
selectItemID: null,
|
||||
loading: !1,
|
||||
provision: {},
|
||||
tips: [],
|
||||
showTips: !1,
|
||||
approve: !0
|
||||
},
|
||||
onLoad: function(a) {
|
||||
var i = this;
|
||||
e.pageStart(t).then(function(e) {
|
||||
i.getList(), i.setData({
|
||||
servicetel: t.globalData.servicetel
|
||||
});
|
||||
});
|
||||
},
|
||||
onShow: function(e) {
|
||||
t.globalData.isneedUpload && (this.getList(), t.globalData.isneedUpload = !1);
|
||||
},
|
||||
onPullDownRefresh: function() {
|
||||
this.setData({
|
||||
list: []
|
||||
}), this.getList();
|
||||
},
|
||||
onReachBottom: function() {
|
||||
this.getList();
|
||||
},
|
||||
onShareAppMessage: function() {},
|
||||
getList: function() {
|
||||
var a = this;
|
||||
if (this.data.loading) return !1;
|
||||
this.setData({
|
||||
loading: !0
|
||||
}), wx.showLoading({
|
||||
title: ""
|
||||
}), e.request(t.globalData.config.recharge.init, {
|
||||
page: this.data.page.next_page
|
||||
}, !0).then(function(t) {
|
||||
if (wx.hideLoading(), a.setData({
|
||||
loading: !1
|
||||
}), 200 != t.code) return wx.showModal({
|
||||
title: "提示",
|
||||
content: t.message
|
||||
}), !1;
|
||||
a.setData({
|
||||
showLoding: !1,
|
||||
list: t.data.list,
|
||||
user: t.data.user,
|
||||
protocol: t.data.protocol,
|
||||
tips: t.data.tips.split("\n")
|
||||
}, function() {});
|
||||
}).catch(function(t) {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
tobuy: function(a) {
|
||||
var i = a.currentTarget.dataset.id;
|
||||
console.log(i), wx.showLoading({
|
||||
title: ""
|
||||
}), e.request(t.globalData.config.recharge.create, {
|
||||
id: i
|
||||
}, !0).then(function(t) {
|
||||
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
|
||||
title: "提示",
|
||||
content: t.message
|
||||
}), !1;
|
||||
var e = t.data.result;
|
||||
wx.requestPayment({
|
||||
timeStamp: e.timestamp,
|
||||
nonceStr: e.nonceStr,
|
||||
package: e.package,
|
||||
signType: e.signType,
|
||||
paySign: e.paySign,
|
||||
success: function(t) {
|
||||
getCurrentPages().length > 1 ? wx.navigateBack({}) : wx.redirectTo({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(function(t) {
|
||||
wx.hideLoading();
|
||||
});
|
||||
},
|
||||
selectItem: function(t) {
|
||||
var e = t.currentTarget.dataset.id;
|
||||
this.setData({
|
||||
selectItemID: e
|
||||
});
|
||||
},
|
||||
isSubmit: !1,
|
||||
tobuyNow: function(a) {
|
||||
if (!this.data.approve) return wx.showToast({
|
||||
title: "请勾选同意相关条款",
|
||||
icon: "none"
|
||||
}), !1;
|
||||
if (!this.data.selectItemID || this.isSubmit) return wx.showToast({
|
||||
title: "请选择充值金额~",
|
||||
icon: "none"
|
||||
}), !1;
|
||||
this.isSubmit = !0, wx.showLoading({
|
||||
title: ""
|
||||
});
|
||||
var i = this;
|
||||
e.request(t.globalData.config.recharge.create, {
|
||||
id: i.data.selectItemID
|
||||
}, !0).then(function(t) {
|
||||
if (wx.hideLoading(), i.isSubmit = !1, 200 != t.code) return wx.showModal({
|
||||
title: "提示",
|
||||
content: t.message
|
||||
}), !1;
|
||||
var e = t.data.result;
|
||||
wx.requestPayment({
|
||||
timeStamp: e.timestamp,
|
||||
nonceStr: e.nonceStr,
|
||||
package: e.package,
|
||||
signType: e.signType,
|
||||
paySign: e.paySign,
|
||||
success: function(t) {
|
||||
getCurrentPages().length > 1 ? wx.navigateBack({}) : wx.redirectTo({
|
||||
url: "/pages/index/index"
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(function(t) {
|
||||
wx.hideLoading(), i.isSubmit = !1;
|
||||
});
|
||||
},
|
||||
showprovision: function() {
|
||||
this.setData({
|
||||
showTips: !this.data.showTips
|
||||
});
|
||||
},
|
||||
change: function(t) {
|
||||
var e = t.detail.value.length;
|
||||
this.setData({
|
||||
approve: 1 == e
|
||||
});
|
||||
}
|
||||
});
|
||||
8
pages/voucher/voucher.json
Normal file
8
pages/voucher/voucher.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "聚美汽服",
|
||||
"usingComponents": {
|
||||
"service-tel": "../../template/serviceTel/serviceTel",
|
||||
"my-money": "../../template/myMoney/myMoney",
|
||||
"page-loding": "../../template/pageLoding/pageLoding"
|
||||
}
|
||||
}
|
||||
65
pages/voucher/voucher.wxml
Normal file
65
pages/voucher/voucher.wxml
Normal file
@@ -0,0 +1,65 @@
|
||||
<view class="container">
|
||||
<page-loding wx:if="{{showLoding}}"></page-loding>
|
||||
<block wx:if="{{edition==2}}">
|
||||
<view class="money">
|
||||
<my-money user="{{user}}"></my-money>
|
||||
</view>
|
||||
<view class="list-box">
|
||||
<view class="{{item.selected?'item active':'item'}}" wx:for="{{list}}" wx:key="index">
|
||||
<view class="info">
|
||||
<view class="name">{{item.title}}</view>
|
||||
<view class="include">{{item.message}} </view>
|
||||
<view class="price">
|
||||
<view class="now">¥{{item.paymentamount}}元</view>
|
||||
<view class="origin">¥{{item.money*1+item.bonusamount*1}}元</view>
|
||||
</view>
|
||||
</view>
|
||||
<view bindtap="tobuy" class="buy-btn" data-id="{{item.id}}">
|
||||
<text decode="true">优惠
|
||||
购买</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<service-tel tel="{{servicetel+''}}"></service-tel>
|
||||
<navigator class="scan-btn" url="/pages/myDiscount/myDiscount">我的优惠券</navigator>
|
||||
</block>
|
||||
<block wx:if="{{edition==1}}">
|
||||
<view class="edition1-money">
|
||||
<view class="l">选择充值金额</view>
|
||||
<view class="r">余额:{{user.money}}</view>
|
||||
</view>
|
||||
<view class="edition1-list">
|
||||
<view bindtap="selectItem" class="{{selectItemID==item.id?item.special?'edition1-item edition1-select active':'edition1-item active':item.special?'edition1-item edition1-select':'edition1-item'}}" data-id="{{item.id}}" wx:for="{{list}}" wx:key="index">
|
||||
<view class="now">{{item.paymentamount}}元</view>
|
||||
<view class="origin">赠送{{item.bonusamount*1}}元</view>
|
||||
</view>
|
||||
<view></view>
|
||||
<view></view>
|
||||
<view></view>
|
||||
</view>
|
||||
<view class="no-content" wx:if="{{list.length==0&&!loading}}">
|
||||
<image src="/img/nocontent.png"></image>
|
||||
<view>暂无相关数据</view>
|
||||
</view>
|
||||
<view bindtap="tobuyNow" class="tobuy-btn {{approve?'':'disabled'}}" wx:if="{{list.length>0}}">立即充值</view>
|
||||
<checkbox-group bindchange="change">
|
||||
<label class="provision">
|
||||
<checkbox checked value="{{approve}}"></checkbox> 充值即表示同意 <navigator class="text" url="/pages/webview/webview?url={{protocol.url}}">《{{protocol.name}}》</navigator>
|
||||
</label>
|
||||
</checkbox-group>
|
||||
<view catchtap="showprovision" class="provision-box" wx:if="{{showTips}}">
|
||||
<view class="inner">
|
||||
<view class="title">{{protocol.name}}</view>
|
||||
<view class="richbox">
|
||||
<view wx:for="{{tips}}">{{item}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="warm-prompt">
|
||||
<view class="title">温馨提示:</view>
|
||||
<view class="content">
|
||||
<view wx:for="{{tips}}">{{item}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
193
pages/voucher/voucher.wxss
Normal file
193
pages/voucher/voucher.wxss
Normal file
@@ -0,0 +1,193 @@
|
||||
.container {
|
||||
box-sizing: border-box;
|
||||
min-height: 100vh;
|
||||
padding: 0rpx 28rpx 168rpx;
|
||||
}
|
||||
|
||||
.money {
|
||||
margin-top: 36rpx;
|
||||
}
|
||||
|
||||
.list-box {
|
||||
padding: 36rpx 0;
|
||||
}
|
||||
|
||||
.list-box .item {
|
||||
background-color: #fff;
|
||||
border-radius: 18rpx;
|
||||
box-shadow: 0 0rpx 9rpx 4rpx hsla(0,0%,80%,.75);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
|
||||
.list-box .item.active {
|
||||
box-shadow: 0 0rpx 9rpx 4rpx rgba(255,102,0,.4);
|
||||
}
|
||||
|
||||
.list-box .info {
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
padding: 14rpx 50rpx 14rpx 18rpx;
|
||||
}
|
||||
|
||||
.list-box .info .name {
|
||||
color: #333;
|
||||
font-size: 30rpx;
|
||||
margin-bottom: 12rpx;
|
||||
}
|
||||
|
||||
.list-box .info .include {
|
||||
color: #666;
|
||||
font-size: 22rpx;
|
||||
min-height: 64rpx;
|
||||
}
|
||||
|
||||
.list-box .info .click {
|
||||
color: 999;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.list-box .info .price {
|
||||
display: inline-flex;
|
||||
font-size: 22rpx;
|
||||
margin-top: 14rpx;
|
||||
}
|
||||
|
||||
.info .now {
|
||||
color: #f30;
|
||||
margin-right: 50rpx;
|
||||
}
|
||||
|
||||
.info .origin {
|
||||
color: #999;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
.list-box .buy-btn {
|
||||
align-items: center;
|
||||
background-color: #4cadf1;
|
||||
border-radius: 18rpx;
|
||||
color: #fff;
|
||||
display: inline-flex;
|
||||
font-size: 33rpx;
|
||||
justify-content: center;
|
||||
width: 119rpx;
|
||||
}
|
||||
|
||||
.list-box .item.active .buy-btn {
|
||||
background: #f60;
|
||||
}
|
||||
|
||||
.edition1-money {
|
||||
color: #333;
|
||||
display: flex;
|
||||
font-size: 29rpx;
|
||||
justify-content: space-between;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.edition1-money .r {
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.edition1-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.edition1-list>view {
|
||||
display: inline-flex;
|
||||
width: calc(33.333% - 20rpx);
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item {
|
||||
align-items: center;
|
||||
background: #fff;
|
||||
border: 5rpx solid #4cadf1;
|
||||
border-radius: 18rpx;
|
||||
box-sizing: border-box;
|
||||
color: #0281db;
|
||||
display: inline-flex;
|
||||
flex-direction: column;
|
||||
height: 158rpx;
|
||||
justify-content: center;
|
||||
margin: 0 0 28rpx;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item:nth-child(3n+2) {
|
||||
margin: 0 20rpx 28rpx;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item .now {
|
||||
font-size: 42rpx;
|
||||
margin-bottom: 4rpx;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item .origin {
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item.edition1-select {
|
||||
border-color: #f50;
|
||||
color: #f50;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item.active {
|
||||
background: #4cadf1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.edition1-list .edition1-item.edition1-select.active {
|
||||
background: #f50;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tobuy-btn {
|
||||
align-items: center;
|
||||
background: #1baa1c;
|
||||
border: 2rpx solid #218721;
|
||||
border-radius: 18rpx;
|
||||
color: #fff;
|
||||
display: flex;
|
||||
font-size: 33rpx;
|
||||
height: 91rpx;
|
||||
justify-content: center;
|
||||
margin-top: 3rpx;
|
||||
}
|
||||
|
||||
.tobuy-btn.disabled {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.provision {
|
||||
display: block;
|
||||
margin: 40rpx 0 0;
|
||||
}
|
||||
|
||||
.provision .text {
|
||||
color: #0281db;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.warm-prompt {
|
||||
padding: 60rpx 0;
|
||||
}
|
||||
|
||||
.warm-prompt .title {
|
||||
color: #f30;
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.warm-prompt .content {
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.warm-prompt .content .view {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user