Commit 1e564142 by 程南

修改领券中心

parent 35c0a533
......@@ -6,7 +6,7 @@
// 修改 BRANCH_ID 为对应的商户id
// app.js 中brandId 修改为对应
const PROJECT_ENV = 'test' // 生产 prod, 开发 dev, 测试 test , 测试门户 test_store, 预生产 pre
const PROJECT_ENV = 'dev' // 生产 prod, 开发 dev, 测试 test , 测试门户 test_store, 预生产 pre
//仅生产环境时 配置 :
//3001 3001 , wx313ec36b710125d4 有直播
//2006 泰华 , wx40fec8944623c8b3 有直播 //门户 wx833d5ece112fc3fd
......@@ -26,7 +26,7 @@ const PROJECT_ENV = 'test' // 生产 prod, 开发 dev, 测试 test , 测试门
//2002 巴黎贝甜 wx21968cb3a486d4ab
//2014 包小姐与鞋先生 wxa00302e2f53dd9c5
const BRANCH_ID = 1002
const BRANCH_ID = 1001
const isMall = true
// const needMock = '' //
......
......@@ -13,7 +13,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.8.2",
"appid": "wxac09792264c49b5c",
"appid": "wxc3b64b09b1d3dfc2",
"projectname": "%E5%BE%AE%E5%95%86%E5%9F%8E",
"debugOptions": {
"hidedInDevtools": []
......@@ -652,6 +652,12 @@
"pathName": "subPackageA/page/pages/moneyBuyCoupon/moneyBuyCoupon",
"query": "",
"scene": null
},
{
"id": -1,
"name": "领券中心",
"pathName": "subPackage/page/pages/couponCenter/couponCenter",
"scene": null
}
]
}
......
......@@ -4,137 +4,171 @@ const util = require('../../../../utils/util')
wxService.page({
/**
* 页面的初始数据
*/
data: {
query: '',
integralCouponList: [], // 积分兑换优惠券列表
showDialog : false,
dialogPicture : '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.hideShareMenu();
this.initIntegralCouponList();
},
// 获取优惠券活动列表
initIntegralCouponList(refresh) {
wx.showLoading({
title: '加载中'
});
wxService.post(`/coupon/couponCenterActivity/buyer/getValidList`).then(res => {
if (res) {
let { result, data } = res.data
if (result == 0) {
wx.hideLoading();
data = data ? data : [];
data.forEach(item => {
//判断活动开始时间是不是已经开始了
item.isStart = true;
//判断是不是老活动
if(item.couponList){
item.isStart = util.compareCurrentDate(item.startTime);
/**
* 页面的初始数据
*/
data: {
query: '',
integralCouponList: [], // 积分兑换优惠券列表
showDialog: false,
dialogPicture: '',
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.hideShareMenu();
this.initIntegralCouponList();
},
// 获取优惠券活动列表
initIntegralCouponList(refresh) {
wx.showLoading({
title: '加载中'
});
wxService.post(`/coupon/couponCenterActivity/buyer/getValidList`).then(res => {
if (res) {
let { result, data } = res.data
if (result == 0) {
wx.hideLoading();
data = data ? data : [];
data.forEach(item => {
//判断活动开始时间是不是已经开始了
item.isStart = true;
//判断是不是老活动
if (item.couponList) {
item.isStart = util.compareCurrentDate(item.startTime);
}
});
this.data.integralCouponList = data;
this.setData({
integralCouponList: this.data.integralCouponList
});
}
}
});
this.data.integralCouponList = data;
this.setData({
integralCouponList: this.data.integralCouponList
});
}
}
if (refresh) {
wx.showToast({
title: '刷新成功',
});
wx.stopPullDownRefresh();
}
if(refresh){
wx.showToast({
title: '刷新成功',
}).finally(() => {
wx.hideLoading();
})
},
//立即兑换优惠券
exchange(e) {
wx.showLoading({
title: '领取中..',
});
wx.stopPullDownRefresh();
}
}).finally(() => {
wx.hideLoading();
})
},
//立即兑换优惠券
exchange(e) {
wx.showLoading({
title: '领取中..',
});
let isStart = e.currentTarget.dataset.start;
const { id } = e.currentTarget.dataset;
let item = e.currentTarget.dataset.item;
//先判断是不是老的活动
if(!item.couponList){
this.getCoupon(id,item);
return ;
}
if(isStart){
this.getCoupon(id,item);
}
//预约
else{
this.orderCouponActivity(id,item);
}
},
//立即领取
getCoupon(id,item){
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading();
if(res){
if(res.data.result == 0){
//判断是不是老活动
if(item.couponList){
this.data.showDialog = true;
this.data.dialogPicture = item.dialogPicture;
this.setData({
showDialog : this.data.showDialog,
dialogPicture : this.data.dialogPicture
});
}
else{
wx.showToast({
title: '领取成功!',
});
}
let isStart = e.currentTarget.dataset.start;
const { id } = e.currentTarget.dataset;
let item = e.currentTarget.dataset.item;
//先判断是不是老的活动
if (!item.couponList) {
this.getCoupon(id, item);
return;
}
if (isStart) {
this.getCoupon(id, item);
}
else{
wx.showToast({
title: '领取失败,请稍后再试',
icon : 'none'
});
//预约
else {
this.orderCouponActivity(id, item);
}
}
});
},
//立即预约
orderCouponActivity(id){
},
//跳转到详情
goCouponDetail(e) {
const { id } = e.currentTarget.dataset
wxService.router(`/subPackage/page/pages/couponCenterInfo/couponCenterInfo?id=${id}`)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.initIntegralCouponList(true);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
},
//立即领取
getCoupon(id, item) {
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading();
if (res) {
if (res.data.result == 0) {
//判断是不是老活动
if (item.couponList) {
this.data.showDialog = true;
this.data.dialogPicture = item.dialogPicture;
this.setData({
showDialog: this.data.showDialog,
dialogPicture: this.data.dialogPicture
});
}
else {
wx.showToast({
title: '领取成功!',
});
}
}
else {
wx.showToast({
title: '领取失败,请稍后再试',
icon: 'none'
});
}
}
});
},
//立即预约
orderCouponActivity(id) {
let baseUserInfo = wx.getStorageSync('_baseUserInfo');
wxService.post(`${'/merchant/message/wxSubMsgMapping/getListByParams'}`, {
scenarioIds: ['usernoticeappointment'],
sourceFrom: 2,
switchType: 3
}).then(res => {
let tempArr = res.data.data ? res.data.data : [];
if (tempArr.length == 0) {
return;
}
let tempids = [];
tempArr.map(item => {
tempids.push(item.templateId);
});
wx.requestSubscribeMessage({
tmplIds: tempids,
success: (res) => {
for (let i = 0; i < tempArr.length; i++) {
wxService.post(`${'/merchant/message/wxSubMsgSubscride/member/subscribe'}`, {
businessId: id,
memberId: baseUserInfo.memberId,
scenarioId: tempArr[i].scenarioId,
templateId: tempArr[i].templateId
}).then(resp => { });
}
},
complete: (res) => {
}
})
}).catch(err => {
})
},
//跳转到详情
goCouponDetail(e) {
const { id } = e.currentTarget.dataset
wxService.router(`/subPackage/page/pages/couponCenterInfo/couponCenterInfo?id=${id}`)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.initIntegralCouponList(true);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment