Commit 429d07e7896d75e41fdefac09de4a1392a31be6f

Authored by 泉州测试
1 parent 8a5e46ea

活动暂停提示

packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... ... @@ -280,22 +280,17 @@ Page({
280 280  
281 281 surplus: 0,
282 282 canBuy: false,
283   -
  283 + btnHidden: false,
284 284 },
285 285  
286 286 //------初始化加载----------
287 287 onLoad: function (t) {
288   -
289   -
  288 +
  289 +
290 290 if(t && t.group_id) {
291   - // wx.setStorage({
292   - // key: 'group_id',
293   - // data: t.group_id,
294   - // });
295 291 this.data.group_id = t.group_id;
296 292 };
297   -
298   -
  293 +
299 294  
300 295  
301 296 var ee = this,
... ... @@ -757,6 +752,63 @@ Page({
757 752 return false;
758 753 }
759 754  
  755 + // 判断活动是否暂停
  756 + //获取单个活动成团信息
  757 + await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
  758 + data: {
  759 + store_id: o.stoid,
  760 + is_end: 0,
  761 + timetype: 1,
  762 + id: this.data.group_id,
  763 + }
  764 + }).then(res => {
  765 + if (res.data.code == 0) {
  766 + console.log('成团信息=======》', res.data.data);
  767 + if(res.data.data.pageData && res.data.data.pageData.length == 0) {
  768 + let obj = {
  769 + day: '00',
  770 + hou: '00',
  771 + min: '00',
  772 + sec: '00'
  773 + };
  774 +
  775 + th.setData({
  776 + djs: obj,
  777 + isTimeUp: true,
  778 + });
  779 + } else {
  780 + th.setData({
  781 + luckGoInfo: res.data.data.pageData[0],
  782 + team_id: res.data.data.pageData[0].team_id,
  783 + luckGoMembers: [],
  784 + });
  785 +
  786 + th.countDown(th.data.luckGoInfo.end_time, 0);
  787 + };
  788 +
  789 + } else {
  790 + this.data.isTimeUp = true;
  791 + th.setData({
  792 + isTimeUp: true,
  793 + });
  794 +
  795 + };
  796 +
  797 +
  798 + });
  799 + // 活动暂停显示空白
  800 + if (this.data.isTimeUp) {
  801 + wx.showModal({
  802 + title: '提示',
  803 + content: '活动已经暂停',
  804 + showCancel: false,
  805 + success: function(){
  806 + wx.navigateBack();
  807 + }
  808 + })
  809 + return false;
  810 + }
  811 +
760 812 //优惠券要实时更新
761 813 getApp().getConfig2(function (e) {
762 814 var json_d = JSON.parse(e.switch_list);
... ... @@ -825,26 +877,7 @@ Page({
825 877 title: t.data.data.goods_name,
826 878 });
827 879  
828   - //-- 判断是不是组合购活动,必须要登录后才能判断 --
829   - // if (getApp().globalData.userInfo && t.data.data.prom_type == 7) {
830   - // //获取活动信息
831   - // var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" +
832   - // t.data.data.prom_id + "/" + getApp().globalData.user_id;
833   - // getApp().request.get(url, {
834   - // success: function (e) {
835   - // if (e.data.code == 0 && e.data.data) {
836   - // if (ut.gettimestamp() < e.data.data.start_time) {
837   - // return false;
838   - // }
839   - // if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) {
840   - // //-- 获取商品列表 --
841   - // th.setData({ zh_act: e.data.data });
842   - // }
843   -
844   - // }
845   - // }
846   - // });
847   - // }
  880 +
848 881  
849 882 //-- 把商品的赋值 --
850 883 ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
... ... @@ -977,45 +1010,8 @@ Page({
977 1010 }
978 1011 });
979 1012 this.data.enterAddressPage && (this.data.enterAddressPage = !1);
980   -
981   - // 检查幸运购活动商品库存
982   - getApp().request.get("/api/weshop/activitylist/getActLen/" + o.stoid + "/9/" + this.data.group_id, {
983   - success: function(res) {
984   - //console.log('当前幸运购活动的剩余库存', res.data.data);
985   - if(res.data.code == 0) {
986   - th.setData({
987   - // 剩余库存量
988   - surplus: res.data.data,
989   - });
990   - };
991   - // else {
992   - // th.setData({
993   - // surplus: 0,
994   - // });
995   - // }
996   - }
997   - });
998   -
999   -
1000   - // 检查是否已经参团购买
1001   - getApp().request.get("/api/weshop/prom/luckyOrder/getUserOrderInfo/" + o.stoid + "/" + oo.user_id + "/" + this.data.group_id, {
1002   - success: function(res) {
1003   - console.log('当前幸运购活动是否已经参团', res.data.code);
1004   - if(res.data.code == 0) {
1005   - th.setData({
1006   - showDetails: true,
1007   - buyInfo: res.data.data,
1008   - });
1009   - } else {
1010   - th.setData({
1011   - showDetails: false,
1012   - });
1013   - };
1014   - }
1015   - });
1016   -
1017   -
1018   -
  1013 +
  1014 +
1019 1015 //获取单个活动已成团数量
1020 1016 getApp().request.get(`/api/weshop/prom/luckyTeam/getCtNum/${o.stoid}/${this.data.group_id}`, {
1021 1017 success: function (res) {
... ... @@ -1026,8 +1022,8 @@ Page({
1026 1022 }
1027 1023 }
1028 1024 });
1029   -
1030   -
  1025 +
  1026 +
1031 1027 //获取单个活动中奖记录
1032 1028 getApp().request.promiseGet('/api/weshop/prom/luckyOrder/page', {
1033 1029 data: {
... ... @@ -1059,50 +1055,7 @@ Page({
1059 1055 });
1060 1056  
1061 1057  
1062   - //获取单个活动成团信息
1063   - await getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
1064   - data: {
1065   - store_id: o.stoid,
1066   - is_end: 0,
1067   - timetype: 1,
1068   - id: this.data.group_id,
1069   - }
1070   - }).then(res => {
1071   - if (res.data.code == 0) {
1072   - console.log('成团信息=======》', res.data.data);
1073   - if(res.data.data.pageData && res.data.data.pageData.length == 0) {
1074   - let obj = {
1075   - day: '00',
1076   - hou: '00',
1077   - min: '00',
1078   - sec: '00'
1079   - };
1080   -
1081   - th.setData({
1082   - djs: obj,
1083   - isTimeUp: true,
1084   - });
1085   - } else {
1086   - th.setData({
1087   - luckGoInfo: res.data.data.pageData[0],
1088   - team_id: res.data.data.pageData[0].team_id,
1089   - luckGoMembers: [],
1090   - });
1091   - // wx.setStorage({
1092   - // key: 'team_id',
1093   - // data: th.data.team_id,
1094   - // });
1095   - th.countDown(th.data.luckGoInfo.end_time, 0);
1096   - };
1097   -
1098   - } else {
1099   - th.setData({
1100   - isTimeUp: true,
1101   - });
1102   - };
1103   -
1104   -
1105   - });
  1058 +
1106 1059  
1107 1060  
1108 1061 // 获取购买次数,判断是否已经超出限购
... ... @@ -1142,23 +1095,54 @@ Page({
1142 1095 }
1143 1096 });
1144 1097  
  1098 + var p1 = new Promise((resolve, reject) => {
  1099 + // 检查幸运购活动商品库存
  1100 + getApp().request.get("/api/weshop/activitylist/getActLen/" + o.stoid + "/9/" + this.data.group_id, {
  1101 + success: function(res) {
  1102 + //console.log('当前幸运购活动的剩余库存', res.data.data);
  1103 + if(res.data.code == 0) {
  1104 + th.setData({
  1105 + // 剩余库存量
  1106 + surplus: res.data.data,
  1107 + });
  1108 + };
  1109 + resolve();
  1110 + }
  1111 + });
  1112 +
  1113 + });
  1114 +
  1115 + var p2 = new Promise((resolve, reject) => {
  1116 + // 检查是否已经参团购买
  1117 + getApp().request.get("/api/weshop/prom/luckyOrder/getUserOrderInfo/" + o.stoid + "/" + oo.user_id + "/" + this.data.group_id, {
  1118 + success: function(res) {
  1119 + console.log('当前幸运购活动是否已经参团', res.data.code);
  1120 + if(res.data.code == 0) {
  1121 + th.setData({
  1122 + showDetails: true,
  1123 + buyInfo: res.data.data,
  1124 + });
  1125 + } else {
  1126 + th.setData({
  1127 + showDetails: false,
  1128 + });
  1129 + };
  1130 + resolve();
  1131 + }
  1132 + });
  1133 +
  1134 + });
  1135 +
  1136 + Promise.all([p1, p2]).then(res => {
  1137 + th.setData({
  1138 + btnHidden: true,
  1139 + });
  1140 + });
1145 1141  
1146   -
1147   -
1148   -
1149   -
1150   -
1151   -
1152   -
1153 1142  
1154 1143 },
1155 1144  
1156   - // 暂时无用
1157   - // enterAddress: function () {
1158   - // this.data.enterAddressPage = !0, wx.navigateTo({
1159   - // url: "/pages/user/address_list/address_list?operate=selectAddress"
1160   - // });
1161   - // },
  1145 +
1162 1146  
1163 1147  
1164 1148 // 页面卸载
... ... @@ -1185,11 +1169,7 @@ Page({
1185 1169 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment();
1186 1170 },
1187 1171  
1188   - // tabClick2: function (t) {
1189   - // this.setData({
1190   - // activeCategoryId2: t.currentTarget.id
1191   - // });
1192   - // },
  1172 +
1193 1173  
1194 1174  
1195 1175 // 点击评价选项卡下的各评价按钮
... ... @@ -1288,19 +1268,7 @@ Page({
1288 1268 th.setData({
1289 1269 open_ind_store: ind
1290 1270 });
1291   - //如果是秒杀的话,要看redis够不够
1292   - // if (this.data.prom_type == 1) {
1293   - // this.getactLen(function (num) {
1294   - // if (num < th.data.goodsInputNum) {
1295   - // getApp().my_warnning("秒杀库存不足!", 0, th);
1296   - // return false;
1297   - // } else {
1298   - // th.add_cart_func(t);
1299   - // }
1300   - // });
1301   - // } else {
1302   - // th.add_cart_func(t);
1303   - // }
  1271 +
1304 1272  
1305 1273 th.add_cart_func(t);
1306 1274 },
... ... @@ -3755,35 +3723,7 @@ Page({
3755 3723 }
3756 3724 // console.log('cd');
3757 3725 } else {
3758   - // if (th.data.prom_st == 0) {
3759   - // //var endTime2 = new Date(th.data.prom_end_time).getTime();
3760   - // var endTime2 = th.data.prom_act.end_time;
3761   - // th.setData({
3762   - // prom_time_text: '距结束还剩:',
3763   - // prom_st: 1
3764   - // })
3765   - // setTimeout(function () {
3766   - // th.countDown(endTime2)
3767   - // }, 1000);
3768   - // return false;
3769   -
3770   - // } else {
3771   - // //活动已结束,全部设置为'00'
3772   - // obj = {
3773   - // day: '00',
3774   - // hou: '00',
3775   - // min: '00',
3776   - // sec: '00'
3777   - // }
3778   - // th.setData({
3779   - // prom_time_text: '活动已经结束:',
3780   - // prom_st: 3
3781   - // })
3782   - // th.setData({
3783   - // djs: obj
3784   - // });
3785   - // return false;
3786   - // }
  3726 +
3787 3727  
3788 3728  
3789 3729 obj = {
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml
... ... @@ -920,12 +920,12 @@
920 920 </view>
921 921 <!-- data-ind="2" -->
922 922 <!-- openSpecModel_pt -->
923   - <view class="xc-ash-b f1 flex ai-center jc-center white fs26" wx:if="{{isTimeUp}}">活动已经结束</view>
  923 + <view class="xc-ash-b f1 flex ai-center jc-center white fs26" wx:if="{{btnHidden && isTimeUp}}">活动已经结束</view>
924 924 <block wx:else>
925   - <view class="btn-red f1 flex ai-center jc-center" bindtap="go" data-it="0" data-url="/packageC/pages/luckyGo/luckyGo_details/luckyGo_details?group_id={{luckGoInfo.id}}&goods_id={{luckGoInfo.goods_id}}&goods_name={{data.goods_name}}&team_id={{buyInfo.team_id}}" wx:if="{{showDetails}}">查看详情</view>
926   - <view class="f1 flex ai-center jc-center xc-ash-b fs26 white" wx:if="{{!showDetails && surplus == 0}}">已经抢光了</view>
927   - <view class="f1 flex ai-center jc-center xc-ash-b fs26 white" wx:if="{{!showDetails && surplus != 0 && !canBuy}}">已超限购次数</view>
928   - <view class="btn-red f1 flex ai-center jc-center" bindtap="openSpecModel_pt" data-it="0" wx:if="{{!showDetails && surplus != 0 && canBuy}}">立即参团</view>
  925 + <view class="btn-red f1 flex ai-center jc-center" bindtap="go" data-it="0" data-url="/packageC/pages/luckyGo/luckyGo_details/luckyGo_details?group_id={{luckGoInfo.id}}&goods_id={{luckGoInfo.goods_id}}&goods_name={{data.goods_name}}&team_id={{buyInfo.team_id}}" wx:if="{{btnHidden && showDetails}}">查看详情</view>
  926 + <view class="f1 flex ai-center jc-center xc-ash-b fs26 white" wx:if="{{btnHidden && !showDetails && surplus == 0}}">已经抢光了</view>
  927 + <view class="f1 flex ai-center jc-center xc-ash-b fs26 white" wx:if="{{btnHidden && !showDetails && surplus != 0 && !canBuy}}">已超限购次数</view>
  928 + <view class="btn-red f1 flex ai-center jc-center" bindtap="openSpecModel_pt" data-it="0" wx:if="{{btnHidden && !showDetails && surplus != 0 && canBuy}}">立即参团</view>
929 929 </block>
930 930  
931 931 <!-- <view class="btn-red f1 flex ai-center jc-center" wx:else>已经抢光</view> -->
... ...