Commit d6cbfb01f15fd2817a5f87775d8b9fbbc6d2f77e

Authored by yiren
1 parent 6508e3a7

代金券和充值接口对接

... ... @@ -6,7 +6,8 @@ Page({
*/
data: {
opt: {
name: '唐人街1号中餐厅',
name: '',
id:'',
},
num: 1,
totalize: '',
... ... @@ -18,7 +19,13 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.data.opt.name = options.name
this.setData({
opt:{
id:options.id,
name:options.name,
}
})
console.log({...this.data.opt});
},
/**
... ...
// pack-activity/pack/confirmPayment.js
import util from '../../utils/util'
Page({
/**
* 页面的初始数据
*/
data: {
type: '2',
detail:{},
time: 1800,
countdown: '',
tip: '',
active: '2',
date: "",
type: '2',
},
... ... @@ -17,17 +19,41 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
opt:{
type:options.type,
detail:JSON.parse(options.detail),
}
})
console.log('options.detail',JSON.parse(options.detail));
this.countdown()
this.modal = this.selectComponent("#payModal"); //通过给组件所起的id调用组件
},
showModal() {
this.modal.showModal() //调用组件中打开模态框方法
},
confirmPayment(){
},
closeModal() {
this.modal.closeModal() //调用组件中关闭模态框方法
},
// 充值————点击确认支付
formSubmit(e) {
console.log('form发生了submit事件,携带数据为:', e.detail.value)
let form=e.detail.value
console.log('form',form);
if (!form.name) {
util.toast('未填写姓名', 'none')
return;
}
if (!form.phone) {
util.toast('未填写手机号码', 'none')
return;
}
if (!/^1\d{10}$/.test(form.phone)) {
util.toast('手机号码错误', 'none')
return;
}
this.confirmPayment()
},
// 选择日期
bind_ChangeDate(event) {
... ... @@ -61,7 +87,7 @@ Page({
})
setTimeout(this.countdown, 1000);
},
// 点击确认支付
// 支付
confirmPayment() {
// wx.requestPayment({
// timeStamp: '',
... ...
<!--pack-activity/pack/confirmPayment.wxml 代金券和充值支付页面-->
<nav> </nav>
<nav>{{opt.detail.name}}</nav>
<view class="box_wrap">
<view wx:if="{{active=='1'}}" class="box">
<view wx:if="{{type=='1'}}" class="box">
<view class="countdown font24r">
支付剩余时间 {{countdown}}
</view>
... ... @@ -15,41 +15,42 @@
唐人街1号中餐厅
</view>
</view>
<view class="coupon">
<view wx:if="{{type=='2'}}" class="coupon">
<form catchsubmit="formSubmit">
<view class="page-section">
<view class="page-section-title font32r">您的姓名</view>
<view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
<input class="weui-input" name="input" placeholder="点击输入您的姓名" placeholder-style="color:#000;" />
<input class="weui-input" name="name" placeholder="点击输入您的姓名" placeholder-style="color:#999;" />
</view>
</view>
<view class="page-section">
<view class="page-section-title font32r">联系电话</view>
<view class="weui-cells weui-cell__bd" style="margin: 30rpx 0">
<input class="weui-input" name="input" placeholder="点击输入您的电话" placeholder-style="color:#000;" />
<input class="weui-input" type="number" name="phone" maxlength="11" placeholder="点击输入您的电话" placeholder-style="color:#999;" style="color: #999"/>
</view>
</view>
<view class="page-section">
<view class="page-section page-section1">
<view class="page-section-title font32r">您的生日</view>
<view class="weui-cells weui-cell__bd">
<picker mode="date" value="{{date}}" bindchange="bind_ChangeDate" class="pickerBox">
{{date?date:'点击输入您的生日'}}
<view class="colorSty">{{date?date:'点击输入您的生日'}}</view>
</picker>
</view>
<view class="more"></view>
</view>
<view class="page-section">
<view class="page-section-title font32r">充值金额</view>
<view class="weui-cells weui-cell__bd sum">
1000元
<view class="weui-cells weui-cell__bd sum colorSty">
{{opt.detail.recharge_money}}元
</view>
</view>
<view class="fixed_box">
<button class="font32r btns" formType="submit">确认支付
</button>
</view>
</form>
</view>
</view>
<view class="fixed_box">
<button class="font32r btns" bindtap="showModal">确认支付
</button>
</view>
<my-modal id="payModal" fadeStyle="slideUp" height="380px">
<view slot="modalName" class="titleModal">成功支付50.00元</view>
<view slot="modalContent">
... ...
... ... @@ -101,6 +101,10 @@
border-bottom: 2rpx solid #E7E7E7;
}
.page-section1 .more {
margin-right: 32rpx;
}
.weui-cells {
flex: 1;
}
... ... @@ -114,12 +118,13 @@
.weui-input {
text-align: right;
margin-right: 30rpx;
font-size: 32rpx;
}
.pickerBox {
display: flex;
justify-content: flex-end;
margin-right: 30rpx;
margin-right: 12rpx;
height: 94rpx;
line-height: 94rpx;
}
... ... @@ -134,4 +139,9 @@
font-family: PingFang SC;
padding: 0 36rpx 0 36rpx;
margin-top: 40rpx;
}
\ No newline at end of file
}
.colorSty{
color: #999999;
font-size: 32rpx;
}
... ...
// pack-activity/pack/seeRecharge.js
import App from '../../utils/api';
import util from '../../utils/util'
Page({
/**
... ... @@ -6,23 +8,31 @@ Page({
*/
data: {
opt: {
name: '唐人街1号中餐厅',
name: '',
id:'',
},
recharge: "关于代金券不得不说的那些事,关于代金券不得不说的那些事,关于代金券不得不说的那些事,关于代金券不得不说的那些事",
stime: '',
etime:'',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
opt:{
id:options.id,
name:options.name,
}
})
console.log({...options});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.getDetail();
},
/**
... ... @@ -31,7 +41,21 @@ Page({
onShow() {
},
getDetail(){
App.Activity.GetActivityById({
id: this.data.opt.id
}).then(res => {
let detail=res.data[0];
let stime=util.unixtoTime(detail.stime,'YYYY-MM-DD');
let etime=util.unixtoTime(detail.etime,'YYYY-MM-DD');
this.setData({
detail,
stime,
etime
})
console.log('detail',{...detail});
})
},
/**
* 生命周期函数--监听页面隐藏
*/
... ...
... ... @@ -3,7 +3,7 @@
<view class="box_wrap">
<view class="info">
<view class="info_left font40r">
50元代金券
{{detail.aname}}
</view>
</view>
<view class="info">
... ... @@ -11,7 +11,7 @@
券要求
</view>
<view class="info_right text_info font32r">
满200可用
{{detail.desc}}
</view>
</view>
<view class="info">
... ... @@ -19,7 +19,7 @@
有效期从
</view>
<view class="info_right text_info font32r">
2023-04-28
{{stime}}
</view>
</view>
<view class="info">
... ... @@ -27,7 +27,7 @@
有效期至
</view>
<view class="info_right text_info font32r">
2023-08-28
{{etime}}
</view>
</view>
<view class="info">
... ... @@ -35,7 +35,7 @@
使用限制:
</view>
<view class="info_right text_info font32r">
无限制
<!-- 没做 -->
</view>
</view>
<view class="info info1">
... ... @@ -43,5 +43,5 @@
券说明
</view>
</view>
<view class="recharge_news">{{recharge}}</view>
<view class="recharge_news">{{detail.explain}}</view>
</view>
\ No newline at end of file
... ...
// pack-activity/pack/vipRecharge.js
import App from '../../utils/api';
import util from '../../utils/util'
Page({
/**
... ... @@ -6,40 +8,32 @@ Page({
*/
data: {
opt: {
name: '唐人街1号中餐厅',
name: '',
id:'',
},
list: [{
val: '1',
info: '50元代金券'
},
{
val: '2',
info: '1000积分'
},
{
val: '3',
info: '优惠券'
},
],
status: 'week', //none 无限制 birthday 生日当天 week 指定日期
num: 1,
totalize: '',
money: 20.55,
explain: "关于代金券不得不说的那些事,关于代金券不得不说的那些事,关于代金券不得不说的那些事,关于代金券不得不说的那些事",
exp_date:{},
detail:{},
recharge_list:{},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
this.setData({
opt:{
id:options.id,
name:options.name,
}
})
console.log({...this.data.opt});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.getDetail();
},
/**
... ... @@ -55,14 +49,34 @@ Page({
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
getDetail(){
App.Activity.GetNewRecharge({
id: this.data.opt.id
}).then(res => {
let detail=res.data
detail.name=this.data.opt.name
let exp_date=util.parseDataValue(res.data.exp_date)
let recharge_list=util.parseDataValue(res.data.recharge_list)
this.setData({
detail,
exp_date,
recharge_list
})
console.log('exp_date',{...exp_date});
console.log('recharge_list',{...recharge_list});
})
},
getCouponDetail(e){
const item= e.currentTarget.dataset['item'];
wx.navigateTo({
url: `./seeRecharge?id=${item.id}&name=${this.data.opt.name}`,
})
},
submitOrder(){
wx.navigateTo({
url: `./confirmPayment?type=2&detail=${JSON.stringify(this.data.detail)}`,
})
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
... ...
... ... @@ -6,7 +6,7 @@
活动名称
</view>
<view class="info_right text_info font32r">
充1000赠398
{{detail.rname}}
</view>
</view>
<view class="info">
... ... @@ -14,36 +14,44 @@
充值满
</view>
<view class="info_right text_info font32r">
1000
{{detail.recharge_money}}
</view>
</view>
<view class="favourable_box">
<view class="about font32r">
优惠活动
</view>
<view class="bundle">
<view class="bundle" wx:if="{{recharge_list.is_price=='1'}}">
<view class="bundle_left font30r">
赠送
</view>
<view class="bundle_right font30r">
200元余额
{{recharge_list.price+'元余额'}}
</view>
</view>
<view class="bundle">
<view class="bundle" wx:if="{{recharge_list.is_score=='1'}}">
<view class="bundle_left font30r">
赠送
</view>
<view class="bundle_right font30r">
200元余额
{{recharge_list.score+'积分'}}
</view>
</view>
<view class="bundle" wx:if="{{recharge_list.is_coupons=='1'}}">
<view class="bundle_left font30r">
赠送
</view>
<view class="bundle_right font30r">
优惠券
</view>
</view>
</view>
<view class="list">
<view class="item font32r" wx:for="{{list}}" wx:key="{{item.val}}">
{{item.info}}
<view class="item font32r" wx:for="{{recharge_list.coupons}}" wx:key="{{item.id}}" bindtap="getCouponDetail" data-item="{{item}}">
{{item.aname}}
</view>
</view>
<view class="week" wx:if="{{status=='week'}}">
<view class="week" wx:if="{{exp_date.is_week=='1'}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
... ... @@ -53,10 +61,10 @@
</view>
</view>
<view class="dateList texts font32r">
周一 周二 周三 周四 周五 周六
{{exp_date.week_date_show}}
</view>
</view>
<view class="week" wx:if="{{status=='birthday'}}">
<view class="week" wx:if="{{exp_date.is_birthday=='1'}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
... ... @@ -66,13 +74,13 @@
</view>
</view>
</view>
<view class="week" wx:if="{{status=='none'}}">
<view class="week" wx:if="{{exp_date.is_fix=='1'}}">
<view class="week_top">
<view class="week_left font32r">
充值日期限制:
</view>
<view class="texts font32r">
无限制
{{exp_date.fix_sdate+'至'+exp_date.fix_edate}}
</view>
</view>
</view>
... ... @@ -81,7 +89,7 @@
备注
</view>
</view>
<view class="explain_news">{{explain}}</view>
<view class="explain_news">{{detail.explain}}</view>
</view>
<view class="fixed_box">
<button class="font32r btns" bindtap="submitOrder">提交订单
... ...
... ... @@ -34,6 +34,8 @@ Page({
date: '',
addr: ''
},
priceInfo:'',
scoreInfo:'',
},
/**
* 生命周期函数--监听页面加载
... ... @@ -260,15 +262,21 @@ Page({
App.Seller.GetSellerTemplateConf({
sid
}).then(res => {
let home,chef,marketing,reserve,signboard,store,homeColor;
chef = res.data.chef?JSON.parse(res.data.chef):'';
reserve = res.data.reserve?JSON.parse(res.data.reserve):'';
marketing = res.data.marketing?JSON.parse(res.data.marketing):'';
signboard = res.data.signboard?JSON.parse(res.data.signboard):'';
store = res.data.store?JSON.parse(res.data.store):'';
home = res.data.home?JSON.parse(res.data.home):'';
if(store && store.images.length>0) store.images = JSON.parse(store.images)
if(signboard && signboard.images) signboard.images = JSON.parse(signboard.images)
let home,chef,marketing,reserve,signboard,store,homeColor,priceInfo,scoreInfo,recharge_data,recharge_list;
chef = util.parseDataValue(res.data.chef)
reserve = util.parseDataValue(res.data.reserve)
marketing = util.parseDataValue(res.data.marketing)
signboard = util.parseDataValue(res.data.signboard)
store = util.parseDataValue(res.data.store)
home = util.parseDataValue(res.data.home)
if(marketing.is_recharge=='1'){
recharge_data=marketing.recharge_data
recharge_list=marketing.recharge_data.recharge_list
if(recharge_list.is_price=='1') priceInfo='会员充值满'+recharge_data.recharge_money+'元赠送'+recharge_list.price+'元余额';
if(recharge_list.is_score=='1') scoreInfo='会员充值满'+recharge_data.recharge_money+'元赠送'+recharge_list.score+'积分';
}
if(store && store.images.length>0) store.images =util.parseDataValue(store.images)
if(signboard && signboard.images) signboard.images = util.parseDataValue(signboard.images)
if (marketing && marketing.is_online_book=='1' && marketing.is_transpond =='1') {
this.setData({
between: true
... ... @@ -293,7 +301,9 @@ Page({
reserve,
signboard,
store,
homeColor //home主题颜色
homeColor, //home主题颜色
priceInfo,
scoreInfo
})
if (home && home.red == '1' && home.green == '67' && home.blue == '163') {
this.setData({
... ...
... ... @@ -188,37 +188,50 @@
</view>
</view>
</view>
<view class="preferential" wx:if="{{marketing && (marketing.is_coupon=='1' || marketing.is_recharge=='1')}}">
<!-- <view class="preferential" wx:if="{{marketing && (marketing.is_coupon=='1' || marketing.is_recharge=='1')}}"> -->
<view class="preferential">
<view class="rubric rubric1">
特别优惠
</view>
<view class="preferentialItems" wx:if="{{marketing && marketing.is_coupon=='1'}}">
<!-- <view class="preferentialItems" wx:if="{{marketing && marketing.is_coupon=='1'}}"> -->
<view class="preferentialItems" wx:if="{{marketing.is_coupon=='1'}}">
<view class="left">
<view class="top">
<text>200元代金券</text>
<text class="price">¥100</text>
<text class="discount">5折</text>
<text>{{marketing.coupon_data.aname}}代金券</text>
<!-- <text class="price">¥{{ticketList.ticket.price1}}</text>
<text class="discount">{{ticketList.ticket.rebate}}折</text> -->
</view>
<view class="bottom">
周一到周五可用,消费满600元可用一张。
</view>
</view>
<view class="font24r orderingFood">
去抢购
<!-- <view class="bottom">
{{ticketList.ticket.info}}
</view> -->
</view>
<navigator url="/pack-activity/pack/buyCoupon?id={{marketing.coupon_data.id}}&name={{seller.name}}" hover-class="navigator-hover">
<view class="font24r orderingFood">
去抢购
</view>
</navigator>
</view>
<view class="preferentialItems" wx:if="{{marketing && marketing.is_recharge=='1'}}">
<!-- <view class="preferentialItems" wx:if="{{marketing && marketing.is_recharge=='1'}}"> -->
<view class="preferentialItems" wx:if="{{marketing.is_recharge=='1'}}">
<view class="left">
<view class="top">
<text>充1000赠300</text>
<text>{{marketing.recharge_data.rname}}</text>
</view>
<view class="bottom">
会员充值满1000元赠余额200元;会员充值满1000元赠送50元代金券;会员充值满1000元赠50元菜品。
{{priceInfo}}{{(marketing.recharge_data.recharge_list.is_coupons=='0' && marketing.recharge_data.recharge_list.is_score=='0')?'。':';'}}
</view>
<view class="bottom">
{{scoreInfo}}{{marketing.recharge_data.recharge_list.is_coupons=='0'?'。':';'}}
</view>
<view class="bottom">
{{marketing.recharge_data.recharge_list.is_coupons=='1'?'会员充值满'+marketing.recharge_data.recharge_money+'元赠送优惠券':''}}。
</view>
</view>
<view class="font24r orderingFood">
去充值
</view>
<navigator url="/pack-activity/pack/vipRecharge?id={{marketing.recharge_data.id}}&name={{seller.name}}" hover-class="navigator-hover">
<view class="font24r orderingFood">
去充值
</view>
</navigator>
</view>
</view>
<view class="vips">
... ...
... ... @@ -624,6 +624,15 @@ export default {
//预定同一商家、时段时提醒
'App.Reserve.GetReserveIsExits':{
openid:'openid'
}
},
//新充值活动详情
'App.Activity.GetNewRecharge':{
openid:'openid'
},
//客户经理优惠券信息
'App.Activity.GetActivityById':{
openid:'openid'
}
}
\ No newline at end of file
... ...
... ... @@ -129,10 +129,20 @@ const wxPromisify = fn => {
})
}
}
// 判断数据是否为空,不为空则JSON.parse转化json数据
function parseDataValue(val) {
var arr = Object.keys(JSON.parse(val));
if(arr.length!= '0'){
let data=JSON.parse(val)
return data
}
}
module.exports = {
formatTime: formatTime,
unixtoTime: unixtoTime,
timetouUnix: timetouUnix,
parseDataValue,
cgi: function (act) {
return uri.HOST__LINE + act //正式
//return uri.HOST__TEST+act //测试
... ...