Commit 696a835c89fd7d9a2adc1dd9cf2f329a27d78e0d

Authored by pengye
1 parent f581db3c

分享给好友后不再拥有券

@@ -13,6 +13,8 @@ Page({ @@ -13,6 +13,8 @@ Page({
13 exp_date: {}, 13 exp_date: {},
14 resultCoupon: '', //0未领取 1已领取 14 resultCoupon: '', //0未领取 1已领取
15 }, 15 },
  16 + myModal: '',
  17 + myToast :'',
16 /** 18 /**
17 * 生命周期函数--监听页面加载 19 * 生命周期函数--监听页面加载
18 */ 20 */
@@ -35,13 +37,15 @@ Page({ @@ -35,13 +37,15 @@ Page({
35 id: options.id || obj.id, 37 id: options.id || obj.id,
36 sid: options.sid || obj.sid, 38 sid: options.sid || obj.sid,
37 oid: options.oid, 39 oid: options.oid,
38 - types: options.types || obj.types, //1是邀请函过来的(邀请函的券或者点击意见反馈买券) 2是提前点餐 3是商家APP分享的或者短信的链接 40 + types: options.types || obj.types, //1是邀请函过来的(邀请函的券或者点击意见反馈买券) 2是提前点餐 3是商家APP分享的或者短信的链接 4好友赠送的券
39 rid: options.rid ? options.rid : '', 41 rid: options.rid ? options.rid : '',
  42 + activity_id:options.activity_id || '',
40 } 43 }
41 }) 44 })
42 console.log('opt', { 45 console.log('opt', {
43 ...this.data.opt 46 ...this.data.opt
44 }); 47 });
  48 + this.myModal = this.selectComponent("#myModal");
45 }, 49 },
46 // 购买完成券之后关注公众号 50 // 购买完成券之后关注公众号
47 wananchi() { 51 wananchi() {
@@ -68,6 +72,28 @@ Page({ @@ -68,6 +72,28 @@ Page({
68 icon: 'none' 72 icon: 'none'
69 }) 73 })
70 } 74 }
  75 + // 好友分享的券
  76 + if(this.data.opt.types=='4'){
  77 + App.Activity.GetStatusByActivityId({
  78 + activity_id: this.data.opt.activity_id
  79 + }).then(res => {
  80 + // status 0未核销 1已核销
  81 + if (res.ret === 200 && res.data.status == '0') {
  82 + this.getActivityCouponFun('1')
  83 + }else{
  84 + this.myModal.showModal()
  85 + }
  86 + })
  87 + }else{
  88 + this.getActivityCouponFun()
  89 + }
  90 + }, 3000),
  91 + // 关闭领券失败弹框
  92 + closeCouponModal() {
  93 + this.myModal.closeModal()
  94 + },
  95 + // 领券
  96 + getActivityCouponFun(type){
71 let detail = this.data.detail 97 let detail = this.data.detail
72 detail.name = this.data.sellername; 98 detail.name = this.data.sellername;
73 detail.oid = this.data.opt.oid; 99 detail.oid = this.data.opt.oid;
@@ -76,16 +102,28 @@ Page({ @@ -76,16 +102,28 @@ Page({
76 rid: this.data.opt.oid, 102 rid: this.data.opt.oid,
77 }).then((json) => { 103 }).then((json) => {
78 if (json.ret == 200) { 104 if (json.ret == 200) {
79 - util.toast('领取成功', 'none'); 105 + if(type == '1'){//核销分享人的券
  106 + this.writeOff()
  107 + }else{
  108 + this.myToast.showToast('领取成功', 2000)
  109 + this.getCoupon()
  110 + }
80 } else { 111 } else {
81 - wx.showToast({  
82 - title: res.msg,  
83 - duration: 2000,  
84 - mask: true  
85 - }) 112 + this.myToast.showToast(res.msg, 2000)
86 } 113 }
87 }) 114 })
88 - }, 3000), 115 + },
  116 + // 好友领取后核销
  117 + writeOff(){
  118 + App.Activity.SetActivityStatus({
  119 + id: this.data.opt.activity_id
  120 + }).then(res => {
  121 + if (res.ret == '200') {
  122 + this.myToast.showToast('领取成功', 2000)
  123 + this.getCoupon()
  124 + }
  125 + })
  126 + },
89 // 获取券信息 127 // 获取券信息
90 getDetail() { 128 getDetail() {
91 App.Activity.GetActivityById({ 129 App.Activity.GetActivityById({
@@ -167,26 +205,17 @@ Page({ @@ -167,26 +205,17 @@ Page({
167 firstTitle 205 firstTitle
168 }; 206 };
169 }, 207 },
170 - // 点转发后核销  
171 - writeOff(){  
172 - console.log('点转发后',{...this.data.detail});  
173 - if(this.data.detail.arule.is_share_have == '0' && this.data.detail.activity_id){  
174 - App.Activity.SetActivityStatus({  
175 - id: this.data.detail.activity_id,  
176 - }).then(res => {  
177 - if (res.ret == '200') {  
178 - console.log('转发核销');  
179 - wx.hideShareMenu()  
180 - }  
181 - })  
182 - }  
183 - },  
184 sharesetting() { 208 sharesetting() {
185 let data = this.data.opt; 209 let data = this.data.opt;
186 let detail = this.data.detail; 210 let detail = this.data.detail;
  211 + let types = detail.arule.is_share_have == '0' && detail.activity_id ? '4': data.types;
  212 + let path = `/pack-activity/pack/receiveCoupon?id=${data.id}&oid=${data.oid}&rid=${data.rid}&sid=${data.sid}&types=${types}`
  213 + if(detail.arule.is_share_have == '0' && detail.activity_id){
  214 + path += '&activity_id='+detail.activity_id
  215 + }
187 return { 216 return {
188 title: `送你${this.data.sellername}${detail.price}元代金券,点击查看详情,领取到卡包吧!`, 217 title: `送你${this.data.sellername}${detail.price}元代金券,点击查看详情,领取到卡包吧!`,
189 - path: `/pack-activity/pack/receiveCoupon?id=${data.id}&oid=${data.oid}&rid=${data.rid}&sid=${data.sid}&types=${data.types}`, 218 + path,
190 imageUrl: 'https://nosqn.colorcun.com/share_money.png', 219 imageUrl: 'https://nosqn.colorcun.com/share_money.png',
191 } 220 }
192 }, 221 },
@@ -209,6 +238,7 @@ Page({ @@ -209,6 +238,7 @@ Page({
209 * 生命周期函数--监听页面初次渲染完成 238 * 生命周期函数--监听页面初次渲染完成
210 */ 239 */
211 onReady() { 240 onReady() {
  241 + this.myToast = this.selectComponent("#myToast")
212 this.getDetail(); 242 this.getDetail();
213 this.getSellerDetail(); 243 this.getSellerDetail();
214 this.getCoupon() 244 this.getCoupon()
@@ -253,7 +283,6 @@ Page({ @@ -253,7 +283,6 @@ Page({
253 * 用户点击右上角分享 283 * 用户点击右上角分享
254 */ 284 */
255 onShareAppMessage() { 285 onShareAppMessage() {
256 - this.writeOff()  
257 return this.sharesetting(); 286 return this.sharesetting();
258 } 287 }
259 }) 288 })
@@ -2,6 +2,8 @@ @@ -2,6 +2,8 @@
2 "navigationBarBackgroundColor": "#fff", 2 "navigationBarBackgroundColor": "#fff",
3 "navigationBarTextStyle": "black", 3 "navigationBarTextStyle": "black",
4 "usingComponents": { 4 "usingComponents": {
5 - "nav": "/components/nav/nav" 5 + "nav": "/components/nav/nav",
  6 + "my-modal": "/components/modal/modal",
  7 + "toast": "/components/toast/index"
6 } 8 }
7 } 9 }
@@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
15 <image src="https://qn.colorcun.com/voucherUnion_1.png" mode="" /> 15 <image src="https://qn.colorcun.com/voucherUnion_1.png" mode="" />
16 <text class="font28r">有效期</text> 16 <text class="font28r">有效期</text>
17 </view> 17 </view>
18 - <view class="info font24r">{{util.unixtoTime(detail.stime,'YYYY-MM-DD')}}<text>至</text>{{util.unixtoTime(detail.etime,'YYYY-MM-DD')}}</view> 18 + <view class="info font24r"><text>活动期限</text>{{util.unixtoTime(detail.stime,'YYYY-MM-DD')}}<text>至</text>{{util.unixtoTime(detail.etime,'YYYY-MM-DD')}}</view>
  19 + <view class="info font24r"><text>领取日期</text>{{util.unixtoTime(detail.cdate,'YYYY-MM-DD')}}</view>
  20 + <view class="info font24r" wx:if="{{detail.aexpiration>0}}">领取后{{detail.aexpiration}}天内使用</view>
19 </view> 21 </view>
20 <view class="centerMain"> 22 <view class="centerMain">
21 <view class="title"> 23 <view class="title">
@@ -88,4 +90,15 @@ @@ -88,4 +90,15 @@
88 <view class="btns"> 90 <view class="btns">
89 <view wx:if="{{resultCoupon == '0' && detail.grant_last>0}}" class="btn font36r" bindtap="submitOrder">领取到卡包</view> 91 <view wx:if="{{resultCoupon == '0' && detail.grant_last>0}}" class="btn font36r" bindtap="submitOrder">领取到卡包</view>
90 </view> 92 </view>
91 -</view>  
  93 +</view>
  94 +<toast id="myToast"></toast>
  95 +<my-modal id="myModal" fadeStyle="slideUp" height="240px">
  96 + <view slot="modalName" class="titleModal">
  97 + <image bindtap="closeCouponModal" class="closeImg" src="https://qn.colorcun.com/closeOutline.png" mode=""/>
  98 + <view class="modalText1">您来晚了!</view>
  99 + </view>
  100 + <view slot="modalContent">
  101 + <view class="modalText2 font40r">优惠券已被其他好友抢走了,下次动作要快哦!</view>
  102 + <view bindtap="closeCouponModal" class="couponBtn font36r">我知道了</view>
  103 + </view>
  104 +</my-modal>
@@ -170,4 +170,67 @@ page { @@ -170,4 +170,67 @@ page {
170 line-height: 80rpx; 170 line-height: 80rpx;
171 border-radius: 40rpx; 171 border-radius: 40rpx;
172 background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%); 172 background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%);
  173 +}
  174 +
  175 +#myModal .titleModal {
  176 + margin-top: 80%;
  177 + width: 100%;
  178 + position: relative;
  179 +}
  180 +
  181 +#myModal .titleModal2 {
  182 + margin-top: 80%;
  183 +}
  184 +
  185 +#myModal .titleModal3 {
  186 + margin-top: 60%;
  187 +}
  188 +
  189 +#myModal .titleModal4 {
  190 + margin-top: 30%;
  191 +}
  192 +
  193 +#myModal .mymodal {
  194 + background: rgba(0, 0, 0, 0.8);
  195 + width: 100% !important;
  196 + top: 0 !important;
  197 + height: auto !important;
  198 + z-index: 300;
  199 +}
  200 +
  201 +.closeImg {
  202 + width: 60rpx;
  203 + height: 60rpx;
  204 + position: absolute;
  205 + right: 0;
  206 + top: 0;
  207 +}
  208 +
  209 +.modalText1 {
  210 + color: #dfdfdf;
  211 + font-family: PingFang SC;
  212 + font-weight: 600;
  213 + font-size: 52rpx;
  214 + text-align: center;
  215 +}
  216 +
  217 +.modalText2 {
  218 + color: #dfdfdf;
  219 + font-family: PingFang SC;
  220 + font-weight: 500;
  221 + text-align: center;
  222 + margin: 0 40rpx;
  223 +}
  224 +
  225 +.couponBtn {
  226 + width: 80%;
  227 + margin: 0 auto;
  228 + border-radius: 42rpx;
  229 + background: linear-gradient(90.98deg, #f41919 0.25%, #ff7426 120.07%);
  230 + font-weight: 400;
  231 + color: #fff;
  232 + text-align: center;
  233 + border: 4rpx solid #fff;
  234 + padding: 12rpx 0;
  235 + margin: 80rpx auto 20rpx auto;
173 } 236 }
@@ -777,4 +777,11 @@ export default { @@ -777,4 +777,11 @@ export default {
777 openid:'openid', 777 openid:'openid',
778 cachetime: 0, 778 cachetime: 0,
779 }, 779 },
  780 +
  781 + //查询券是否核销
  782 + 'App.Activity.GetStatusByActivityId':{
  783 + alias:'App.Activity.GetStatusByActivityId',
  784 + openid:'openid',
  785 + cachetime: 0,
  786 + },
780 } 787 }