Commit 696a835c89fd7d9a2adc1dd9cf2f329a27d78e0d

Authored by pengye
1 parent f581db3c

分享给好友后不再拥有券

... ... @@ -13,6 +13,8 @@ Page({
exp_date: {},
resultCoupon: '', //0未领取 1已领取
},
myModal: '',
myToast :'',
/**
* 生命周期函数--监听页面加载
*/
... ... @@ -35,13 +37,15 @@ Page({
id: options.id || obj.id,
sid: options.sid || obj.sid,
oid: options.oid,
types: options.types || obj.types, //1是邀请函过来的(邀请函的券或者点击意见反馈买券) 2是提前点餐 3是商家APP分享的或者短信的链接
types: options.types || obj.types, //1是邀请函过来的(邀请函的券或者点击意见反馈买券) 2是提前点餐 3是商家APP分享的或者短信的链接 4好友赠送的券
rid: options.rid ? options.rid : '',
activity_id:options.activity_id || '',
}
})
console.log('opt', {
...this.data.opt
});
this.myModal = this.selectComponent("#myModal");
},
// 购买完成券之后关注公众号
wananchi() {
... ... @@ -68,6 +72,28 @@ Page({
icon: 'none'
})
}
// 好友分享的券
if(this.data.opt.types=='4'){
App.Activity.GetStatusByActivityId({
activity_id: this.data.opt.activity_id
}).then(res => {
// status 0未核销 1已核销
if (res.ret === 200 && res.data.status == '0') {
this.getActivityCouponFun('1')
}else{
this.myModal.showModal()
}
})
}else{
this.getActivityCouponFun()
}
}, 3000),
// 关闭领券失败弹框
closeCouponModal() {
this.myModal.closeModal()
},
// 领券
getActivityCouponFun(type){
let detail = this.data.detail
detail.name = this.data.sellername;
detail.oid = this.data.opt.oid;
... ... @@ -76,16 +102,28 @@ Page({
rid: this.data.opt.oid,
}).then((json) => {
if (json.ret == 200) {
util.toast('领取成功', 'none');
if(type == '1'){//核销分享人的券
this.writeOff()
}else{
this.myToast.showToast('领取成功', 2000)
this.getCoupon()
}
} else {
wx.showToast({
title: res.msg,
duration: 2000,
mask: true
})
this.myToast.showToast(res.msg, 2000)
}
})
}, 3000),
},
// 好友领取后核销
writeOff(){
App.Activity.SetActivityStatus({
id: this.data.opt.activity_id
}).then(res => {
if (res.ret == '200') {
this.myToast.showToast('领取成功', 2000)
this.getCoupon()
}
})
},
// 获取券信息
getDetail() {
App.Activity.GetActivityById({
... ... @@ -167,26 +205,17 @@ Page({
firstTitle
};
},
// 点转发后核销
writeOff(){
console.log('点转发后',{...this.data.detail});
if(this.data.detail.arule.is_share_have == '0' && this.data.detail.activity_id){
App.Activity.SetActivityStatus({
id: this.data.detail.activity_id,
}).then(res => {
if (res.ret == '200') {
console.log('转发核销');
wx.hideShareMenu()
}
})
}
},
sharesetting() {
let data = this.data.opt;
let detail = this.data.detail;
let types = detail.arule.is_share_have == '0' && detail.activity_id ? '4': data.types;
let path = `/pack-activity/pack/receiveCoupon?id=${data.id}&oid=${data.oid}&rid=${data.rid}&sid=${data.sid}&types=${types}`
if(detail.arule.is_share_have == '0' && detail.activity_id){
path += '&activity_id='+detail.activity_id
}
return {
title: `送你${this.data.sellername}${detail.price}元代金券,点击查看详情,领取到卡包吧!`,
path: `/pack-activity/pack/receiveCoupon?id=${data.id}&oid=${data.oid}&rid=${data.rid}&sid=${data.sid}&types=${data.types}`,
path,
imageUrl: 'https://nosqn.colorcun.com/share_money.png',
}
},
... ... @@ -209,6 +238,7 @@ Page({
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
this.myToast = this.selectComponent("#myToast")
this.getDetail();
this.getSellerDetail();
this.getCoupon()
... ... @@ -253,7 +283,6 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage() {
this.writeOff()
return this.sharesetting();
}
})
\ No newline at end of file
... ...
... ... @@ -2,6 +2,8 @@
"navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black",
"usingComponents": {
"nav": "/components/nav/nav"
"nav": "/components/nav/nav",
"my-modal": "/components/modal/modal",
"toast": "/components/toast/index"
}
}
\ No newline at end of file
... ...
... ... @@ -15,7 +15,9 @@
<image src="https://qn.colorcun.com/voucherUnion_1.png" mode="" />
<text class="font28r">有效期</text>
</view>
<view class="info font24r">{{util.unixtoTime(detail.stime,'YYYY-MM-DD')}}<text>至</text>{{util.unixtoTime(detail.etime,'YYYY-MM-DD')}}</view>
<view class="info font24r"><text>活动期限</text>{{util.unixtoTime(detail.stime,'YYYY-MM-DD')}}<text>至</text>{{util.unixtoTime(detail.etime,'YYYY-MM-DD')}}</view>
<view class="info font24r"><text>领取日期</text>{{util.unixtoTime(detail.cdate,'YYYY-MM-DD')}}</view>
<view class="info font24r" wx:if="{{detail.aexpiration>0}}">领取后{{detail.aexpiration}}天内使用</view>
</view>
<view class="centerMain">
<view class="title">
... ... @@ -88,4 +90,15 @@
<view class="btns">
<view wx:if="{{resultCoupon == '0' && detail.grant_last>0}}" class="btn font36r" bindtap="submitOrder">领取到卡包</view>
</view>
</view>
\ No newline at end of file
</view>
<toast id="myToast"></toast>
<my-modal id="myModal" fadeStyle="slideUp" height="240px">
<view slot="modalName" class="titleModal">
<image bindtap="closeCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/>
<view class="modalText1">您来晚了!</view>
</view>
<view slot="modalContent">
<view class="modalText2 font40r">优惠券已被其他好友抢走了,下次动作要快哦!</view>
<view bindtap="closeCouponModal" class="couponBtn font36r">我知道了</view>
</view>
</my-modal>
\ No newline at end of file
... ...
... ... @@ -170,4 +170,67 @@ page {
line-height: 80rpx;
border-radius: 40rpx;
background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%);
}
#myModal .titleModal {
margin-top: 80%;
width: 100%;
position: relative;
}
#myModal .titleModal2 {
margin-top: 80%;
}
#myModal .titleModal3 {
margin-top: 60%;
}
#myModal .titleModal4 {
margin-top: 30%;
}
#myModal .mymodal {
background: rgba(0, 0, 0, 0.8);
width: 100% !important;
top: 0 !important;
height: auto !important;
z-index: 300;
}
.closeImg {
width: 60rpx;
height: 60rpx;
position: absolute;
right: 0;
top: 0;
}
.modalText1 {
color: #dfdfdf;
font-family: PingFang SC;
font-weight: 600;
font-size: 52rpx;
text-align: center;
}
.modalText2 {
color: #dfdfdf;
font-family: PingFang SC;
font-weight: 500;
text-align: center;
margin: 0 40rpx;
}
.couponBtn {
width: 80%;
margin: 0 auto;
border-radius: 42rpx;
background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%);
font-weight: 400;
color: #fff;
text-align: center;
border: 4rpx solid #fff;
padding: 12rpx 0;
margin: 80rpx auto 20rpx auto;
}
\ No newline at end of file
... ...
... ... @@ -777,4 +777,11 @@ export default {
openid:'openid',
cachetime: 0,
},
//查询券是否核销
'App.Activity.GetStatusByActivityId':{
alias:'App.Activity.GetStatusByActivityId',
openid:'openid',
cachetime: 0,
},
}
\ No newline at end of file
... ...