Commit 6056380660bb35c580ec6cfd8124b85b12c97414
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev
Showing
31 changed files
with
6594 additions
and
6300 deletions
packageA/pages/chongzhi/chongzhi.wxml
| @@ -34,7 +34,7 @@ | @@ -34,7 +34,7 @@ | ||
| 34 | </view> | 34 | </view> |
| 35 | <!-- 下 --> | 35 | <!-- 下 --> |
| 36 | <view class="bottom" wx:if="{{currentIndex == 0}}" > | 36 | <view class="bottom" wx:if="{{currentIndex == 0}}" > |
| 37 | - <text wx:if="{{g_filter.is_acting(item.EndDate)}}" | 37 | + <text wx:if="{{g_filter.is_acting(item.EndDate) || item.EndDate==''}}" |
| 38 | catchtap="viewDetails" data-index="{{index}}" class="btn" >立即使用</text> | 38 | catchtap="viewDetails" data-index="{{index}}" class="btn" >立即使用</text> |
| 39 | <text wx:else class="btn" style="background-color: #ccc;">已过期</text> | 39 | <text wx:else class="btn" style="background-color: #ccc;">已过期</text> |
| 40 | <text data-index="{{index}}" class="btn details" >详情</text> | 40 | <text data-index="{{index}}" class="btn details" >详情</text> |
packageA/pages/goodsInfo/goodsInfo.js
| @@ -555,6 +555,8 @@ Page({ | @@ -555,6 +555,8 @@ Page({ | ||
| 555 | if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | 555 | if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); |
| 556 | } | 556 | } |
| 557 | } | 557 | } |
| 558 | + | ||
| 559 | + this.getTaohe(); | ||
| 558 | 560 | ||
| 559 | // if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length<=0)) { | 561 | // if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length<=0)) { |
| 560 | // //----获取详情页的券的数量---- | 562 | // //----获取详情页的券的数量---- |
| @@ -635,7 +637,7 @@ Page({ | @@ -635,7 +637,7 @@ Page({ | ||
| 635 | //listServiceItem: t.data.data.listServiceItem, | 637 | //listServiceItem: t.data.data.listServiceItem, |
| 636 | }); | 638 | }); |
| 637 | 639 | ||
| 638 | - console.log('0xxxxx999999', t.data.data); | 640 | + // console.log('0xxxxx999999', t.data.data); |
| 639 | //-----商品详情--- | 641 | //-----商品详情--- |
| 640 | if(!t.data.data.serviceContent) t.data.data.serviceContent=" "; | 642 | if(!t.data.data.serviceContent) t.data.data.serviceContent=" "; |
| 641 | a.wxParse("content", "html", t.data.data.serviceContent, ee, 6); | 643 | a.wxParse("content", "html", t.data.data.serviceContent, ee, 6); |
| @@ -2705,6 +2707,43 @@ Page({ | @@ -2705,6 +2707,43 @@ Page({ | ||
| 2705 | }); | 2707 | }); |
| 2706 | }, | 2708 | }, |
| 2707 | 2709 | ||
| 2710 | + | ||
| 2711 | + // 判断是否开启美业,获取套盒列表 | ||
| 2712 | + getTaohe() { | ||
| 2713 | + // 判断是否开启美业 | ||
| 2714 | + getApp().promiseGet('/api/weshop/store/getTabSys/' + os.stoid, {}).then(res => { | ||
| 2715 | + if(res.data.code == 0) { | ||
| 2716 | + let enableMeiye = res.data.data.EnableMeiye; | ||
| 2717 | + self.setData({ | ||
| 2718 | + enableMeiye, | ||
| 2719 | + }); | ||
| 2720 | + | ||
| 2721 | + if(enableMeiye) { // 开启美业 | ||
| 2722 | + // 获取套盒列表 | ||
| 2723 | + let url = '/api/weshop/serviceGoods/list' | ||
| 2724 | + let data = { | ||
| 2725 | + store_id: getApp().globalData.setting.stoid, | ||
| 2726 | + service_id: this.data.data.id, | ||
| 2727 | + }; | ||
| 2728 | + // 请求数据 | ||
| 2729 | + getApp().promiseGet(url, { | ||
| 2730 | + data: data, | ||
| 2731 | + }).then(res => { | ||
| 2732 | + if (res.data.code == 0) { | ||
| 2733 | + console.log('请求成功套盒列表', res); | ||
| 2734 | + self.setData({ | ||
| 2735 | + taoheList: res.data.data, | ||
| 2736 | + }); | ||
| 2737 | + } else { | ||
| 2738 | + throw (res); | ||
| 2739 | + }; | ||
| 2740 | + }).catch(err => {}); | ||
| 2741 | + | ||
| 2742 | + }; | ||
| 2743 | + }; | ||
| 2744 | + }); | ||
| 2745 | + } | ||
| 2746 | + | ||
| 2708 | 2747 | ||
| 2709 | 2748 | ||
| 2710 | }); | 2749 | }); |
packageA/pages/goodsInfo/goodsInfo.wxml
| @@ -203,22 +203,40 @@ | @@ -203,22 +203,40 @@ | ||
| 203 | </view> | 203 | </view> |
| 204 | <view class="pdh20"> | 204 | <view class="pdh20"> |
| 205 | 205 | ||
| 206 | - <view wx:if="{{listServiceItem && listServiceItem.length > 0}}"> | 206 | + <block wx:if="{{listServiceItem && listServiceItem.length > 0}}"> |
| 207 | <view class="card fs28" wx:for="{{listServiceItem}}"> | 207 | <view class="card fs28" wx:for="{{listServiceItem}}"> |
| 208 | <view class="flex ai_c jc_sb" style="height: 88rpx;"> | 208 | <view class="flex ai_c jc_sb" style="height: 88rpx;"> |
| 209 | - <view class="ellipsis-2">{{item.projectName}}({{item.frequency}}次)</view> | 209 | + <view class="ellipsis-2 f1">{{item.projectName}}({{item.frequency}}次)</view> |
| 210 | <view class="pdl30 t-r"> | 210 | <view class="pdl30 t-r"> |
| 211 | - <view class="rmb fs36 bold c-red" wx:if="{{item.money}}">{{item.money}}</view> | ||
| 212 | - <view class="fs22 c-9" wx:if="{{item.showPrice}}">零售价:¥{{item.showPrice}}</view> | 211 | + <view class="rmb fs36 bold c-red">{{item.money}}</view> |
| 212 | + <view class="fs22 c-9 del" wx:if="{{item.showPrice}}">零售价:¥{{item.showPrice}}</view> | ||
| 213 | </view> | 213 | </view> |
| 214 | </view> | 214 | </view> |
| 215 | <view class="flex ai_c jc_sb fs24 c-6"> | 215 | <view class="flex ai_c jc_sb fs24 c-6"> |
| 216 | <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view> | 216 | <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view> |
| 217 | - <!-- <view class="pdl30 shrink0">有效期:50天/2022-02-02</view> --> | 217 | + <!-- 指定开始日期和结束日期 --> |
| 218 | + <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item)}}</view> | ||
| 218 | </view> | 219 | </view> |
| 219 | </view> | 220 | </view> |
| 221 | + </block> | ||
| 220 | 222 | ||
| 221 | - </view> | 223 | + <block wx:if="{{enableMeiye}}"> |
| 224 | + <block wx:if="{{taoheList && taoheList.length > 0}}"> | ||
| 225 | + <view class="taohe fs28" wx:for="{{taoheList}}"> | ||
| 226 | + <view class="flex ai_c jc_sb" style="height: 88rpx;"> | ||
| 227 | + <view class="ellipsis-2 f1">{{item.goods_name}} ({{item.goods_sn}}) ({{item.frequency}}个)</view> | ||
| 228 | + <view class="pdl30 t-r"> | ||
| 229 | + <view class="rmb fs36 bold c-red">{{item.vipprice}}</view> | ||
| 230 | + <view class="fs22 c-9 del">零售价:¥{{item.show_price}}</view> | ||
| 231 | + </view> | ||
| 232 | + </view> | ||
| 233 | + <view class="flex ai_c jc_sb fs24 c-6 pdt10"> | ||
| 234 | + <view class="ellipsis-1">备注:{{filters.show_default(item.remark, '无')}}</view> | ||
| 235 | + <view class="pdl30 shrink0">有效期:{{filters.showStartAndEndDate(item)}}</view> | ||
| 236 | + </view> | ||
| 237 | + </view> | ||
| 238 | + </block> | ||
| 239 | + </block> | ||
| 222 | 240 | ||
| 223 | <view class="table_s" wx:if="{{service_list}}"> | 241 | <view class="table_s" wx:if="{{service_list}}"> |
| 224 | <view class="tb_item tb-l"> | 242 | <view class="tb_item tb-l"> |
packageA/pages/goodsInfo/goodsInfo.wxss
| @@ -2855,7 +2855,8 @@ button.custom-service::after{ | @@ -2855,7 +2855,8 @@ button.custom-service::after{ | ||
| 2855 | .gray{ background-color: #dcdcdc !important;} | 2855 | .gray{ background-color: #dcdcdc !important;} |
| 2856 | 2856 | ||
| 2857 | 2857 | ||
| 2858 | -.card { | 2858 | +.card, |
| 2859 | +.taohe { | ||
| 2859 | position: relative; | 2860 | position: relative; |
| 2860 | padding: 20rpx; | 2861 | padding: 20rpx; |
| 2861 | margin-bottom: 20rpx; | 2862 | margin-bottom: 20rpx; |
| @@ -2870,7 +2871,7 @@ button.custom-service::after{ | @@ -2870,7 +2871,7 @@ button.custom-service::after{ | ||
| 2870 | .card::before { | 2871 | .card::before { |
| 2871 | position: absolute; | 2872 | position: absolute; |
| 2872 | font-family: iconfont; | 2873 | font-family: iconfont; |
| 2873 | - content: '\e630'; | 2874 | + content: '\e62a'; |
| 2874 | color: rgba(255,0,0,.1); | 2875 | color: rgba(255,0,0,.1); |
| 2875 | font-size: 260rpx; | 2876 | font-size: 260rpx; |
| 2876 | /* transform: rotateZ(45deg); */ | 2877 | /* transform: rotateZ(45deg); */ |
| @@ -2878,6 +2879,16 @@ button.custom-service::after{ | @@ -2878,6 +2879,16 @@ button.custom-service::after{ | ||
| 2878 | left: -70rpx; | 2879 | left: -70rpx; |
| 2879 | } | 2880 | } |
| 2880 | 2881 | ||
| 2882 | +.taohe::before { | ||
| 2883 | + position: absolute; | ||
| 2884 | + font-family: iconfont; | ||
| 2885 | + content: '\e64e'; | ||
| 2886 | + color: rgba(255,0,0,.1); | ||
| 2887 | + font-size: 260rpx; | ||
| 2888 | + top: -20rpx; | ||
| 2889 | + left: -30rpx; | ||
| 2890 | +} | ||
| 2891 | + | ||
| 2881 | .rmb::before { | 2892 | .rmb::before { |
| 2882 | content: '¥'; | 2893 | content: '¥'; |
| 2883 | font-size: 24rpx; | 2894 | font-size: 24rpx; |
| @@ -2892,3 +2903,7 @@ button.custom-service::after{ | @@ -2892,3 +2903,7 @@ button.custom-service::after{ | ||
| 2892 | overflow: hidden; | 2903 | overflow: hidden; |
| 2893 | margin-right: 10rpx; | 2904 | margin-right: 10rpx; |
| 2894 | } | 2905 | } |
| 2906 | + | ||
| 2907 | +.del { | ||
| 2908 | + text-decoration: line-through; | ||
| 2909 | +} |
packageB/pages/boxes-details/boxes-details.js
| 1 | // packageA/pages/details_serviceCard/details_serviceCard.js | 1 | // packageA/pages/details_serviceCard/details_serviceCard.js |
| 2 | const app = getApp(); | 2 | const app = getApp(); |
| 3 | -const os = app.globalData.setting; | 3 | +// const os = app.globalData.setting; |
| 4 | let self = null; | 4 | let self = null; |
| 5 | +// 防抖函数用定时器 | ||
| 6 | +let timer; | ||
| 7 | +const { | ||
| 8 | + barcode, | ||
| 9 | + qrcode | ||
| 10 | +} = require('../../../utils/index.js'); | ||
| 5 | 11 | ||
| 6 | Page({ | 12 | Page({ |
| 7 | 13 | ||
| @@ -9,7 +15,7 @@ Page({ | @@ -9,7 +15,7 @@ Page({ | ||
| 9 | * 页面的初始数据 | 15 | * 页面的初始数据 |
| 10 | */ | 16 | */ |
| 11 | data: { | 17 | data: { |
| 12 | - is_summit_ing: 0, | 18 | + // is_summit_ing: 0, |
| 13 | 19 | ||
| 14 | showQr: false, | 20 | showQr: false, |
| 15 | }, | 21 | }, |
| @@ -19,12 +25,18 @@ Page({ | @@ -19,12 +25,18 @@ Page({ | ||
| 19 | */ | 25 | */ |
| 20 | onLoad: function(options) { | 26 | onLoad: function(options) { |
| 21 | self = this; | 27 | self = this; |
| 22 | - this.data.options = options; | 28 | + this.setData({ |
| 29 | + options, | ||
| 30 | + }); | ||
| 31 | + // this.data.options = options; | ||
| 23 | app.isLogin().then(function(data) { | 32 | app.isLogin().then(function(data) { |
| 24 | self.setData({ | 33 | self.setData({ |
| 25 | userInfo: data, | 34 | userInfo: data, |
| 26 | }); | 35 | }); |
| 27 | - self.getConfig(); | 36 | + wx.setNavigationBarTitle({ |
| 37 | + title: options.title, | ||
| 38 | + }); | ||
| 39 | + // self.getConfig(); | ||
| 28 | }); | 40 | }); |
| 29 | }, | 41 | }, |
| 30 | 42 | ||
| @@ -39,6 +51,7 @@ Page({ | @@ -39,6 +51,7 @@ Page({ | ||
| 39 | * 生命周期函数--监听页面显示 | 51 | * 生命周期函数--监听页面显示 |
| 40 | */ | 52 | */ |
| 41 | onShow: function() { | 53 | onShow: function() { |
| 54 | + // console.log('show~~~'); | ||
| 42 | if (app.globalData.userInfo) { | 55 | if (app.globalData.userInfo) { |
| 43 | if (!this.data.isLogin) { | 56 | if (!this.data.isLogin) { |
| 44 | this.setData({ | 57 | this.setData({ |
| @@ -47,32 +60,34 @@ Page({ | @@ -47,32 +60,34 @@ Page({ | ||
| 47 | isLogin: true, | 60 | isLogin: true, |
| 48 | }); | 61 | }); |
| 49 | 62 | ||
| 50 | - let url = '/api/weshop/recharge/user/page' | 63 | + let url = '/api/weshop/serviceCard/listWriteoffWare' |
| 51 | let data = { | 64 | let data = { |
| 52 | store_id: app.globalData.setting.stoid, | 65 | store_id: app.globalData.setting.stoid, |
| 53 | user_id: this.data.userInfo.user_id, | 66 | user_id: this.data.userInfo.user_id, |
| 54 | - order_id: this.data.options.order_id, | 67 | + Id: this.data.options.formlistid, |
| 55 | }; | 68 | }; |
| 56 | 69 | ||
| 57 | // 请求数据 | 70 | // 请求数据 |
| 58 | - app.promiseGet(url, { | 71 | + app.request.promiseGet(url, { |
| 59 | data: data, | 72 | data: data, |
| 60 | }).then(res => { | 73 | }).then(res => { |
| 61 | if (res.data.code == 0) { | 74 | if (res.data.code == 0) { |
| 62 | - console.log('请求成功', res); | 75 | + // console.log('请求成功', res); |
| 63 | this.setData({ | 76 | this.setData({ |
| 64 | - details: res.data.data.pageData[0], | 77 | + details: res.data.data, |
| 78 | + writeOffCode: res.data.data[0].WriteOffCode | ||
| 65 | }); | 79 | }); |
| 66 | } else { | 80 | } else { |
| 67 | throw (res); | 81 | throw (res); |
| 68 | }; | 82 | }; |
| 69 | }).catch(err => { | 83 | }).catch(err => { |
| 70 | - wx.showToast({ | ||
| 71 | - title: err.data.data, | ||
| 72 | - icon: 'error', | ||
| 73 | - }); | 84 | + // wx.showToast({ |
| 85 | + // title: err.data.data, | ||
| 86 | + // icon: 'error', | ||
| 87 | + // }); | ||
| 74 | }); | 88 | }); |
| 75 | - | 89 | + |
| 90 | + | ||
| 76 | }; | 91 | }; |
| 77 | }; | 92 | }; |
| 78 | }, | 93 | }, |
| @@ -113,386 +128,149 @@ Page({ | @@ -113,386 +128,149 @@ Page({ | ||
| 113 | }, | 128 | }, |
| 114 | 129 | ||
| 115 | 130 | ||
| 116 | - // 内容复制到剪贴板 | ||
| 117 | - copy() { | ||
| 118 | - console.log('点击了复制按钮'); | ||
| 119 | - wx.setClipboardData({ | ||
| 120 | - data: this.data.details.order_sn, | ||
| 121 | - success(res) { | ||
| 122 | - wx.getClipboardData({ | ||
| 123 | - success(res) { | ||
| 124 | - console.log(res.data); | ||
| 125 | - } | ||
| 126 | - }) | ||
| 127 | - } | ||
| 128 | - }) | ||
| 129 | - }, | ||
| 130 | - | ||
| 131 | 131 | ||
| 132 | // 图片异常时加载默认图片 | 132 | // 图片异常时加载默认图片 |
| 133 | - bind_bnerr(e) { | ||
| 134 | - var errImg = e.currentTarget.dataset.errorimg; | ||
| 135 | - var errObj = {}; | ||
| 136 | - errObj[errImg] = 'public/images/default_goods_image_240.gif'; | ||
| 137 | - this.setData(errObj); // this.setData({ details.list[0].img_url}); | ||
| 138 | - }, | ||
| 139 | - | ||
| 140 | - | ||
| 141 | - // 查看商品详情 | ||
| 142 | - viewDetails(e) { | ||
| 143 | - let goods_id = e.currentTarget.dataset.gid; | ||
| 144 | - let url = '/packageA/pages/goodsInfo/goodsInfo?goods_id=' + goods_id; | ||
| 145 | - app.goto(url); | ||
| 146 | - }, | ||
| 147 | - | ||
| 148 | - // 获取系统参数 | ||
| 149 | - getConfig() { | ||
| 150 | - app.getConfig2(function(e) { | ||
| 151 | - // console.log('101',e); | ||
| 152 | - let json_d = JSON.parse(e.switch_list); | ||
| 153 | - self.setData({ | ||
| 154 | - sys_switch: json_d, | ||
| 155 | - // weapp_customertype: json_d.weapp_customertype, | ||
| 156 | - }); | ||
| 157 | - }, 1); | ||
| 158 | - }, | 133 | + // bind_bnerr(e) { |
| 134 | + // var errImg = e.currentTarget.dataset.errorimg; | ||
| 135 | + // var errObj = {}; | ||
| 136 | + // errObj[errImg] = 'public/images/default_goods_image_240.gif'; | ||
| 137 | + // this.setData(errObj); // this.setData({ details.list[0].img_url}); | ||
| 138 | + // }, | ||
| 159 | 139 | ||
| 160 | - | ||
| 161 | - // 联系微信客服 | ||
| 162 | - contact_wx() { | ||
| 163 | - var url = this.data.sys_switch.weapp_customertype_url; | ||
| 164 | - var id = this.data.sys_switch.weapp_customertype_appid; | ||
| 165 | - wx.openCustomerServiceChat({ | ||
| 166 | - extInfo: { | ||
| 167 | - url: url | ||
| 168 | - }, | ||
| 169 | - corpId: id, | ||
| 170 | - success(res) {} | ||
| 171 | - }) | ||
| 172 | - }, | ||
| 173 | - | ||
| 174 | - | ||
| 175 | - // 联系电话客服 | ||
| 176 | - contactService() { | ||
| 177 | - app.getConfig(function(t) { | ||
| 178 | - if (t.store_tel == undefined) { | ||
| 179 | - app.request.get('/api/weshop/store/get/' + os.stoid, { | ||
| 180 | - isShowLoading: 1, | ||
| 181 | - data: {}, | ||
| 182 | - success: function(rs) { | ||
| 183 | - app.globalData.config = rs.data.data; | ||
| 184 | - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | ||
| 185 | - app.my_warnning('商家未设置电话', 0, self); | ||
| 186 | - return false; | ||
| 187 | - } | ||
| 188 | - app.confirmBox('请联系客服:' + rs.data.data.store_tel); | ||
| 189 | - } | ||
| 190 | - }) | ||
| 191 | - } else { | ||
| 192 | - app.confirmBox('请联系客服:' + t.store_tel); | ||
| 193 | - } | 140 | + |
| 141 | + showQr() { | ||
| 142 | + // wx.showLoading({ | ||
| 143 | + // title:'生成核销码中', | ||
| 144 | + // }); | ||
| 145 | + | ||
| 146 | + let writeOffCode = this.data.details[0].WriteOffCode; | ||
| 147 | + self.qrcode(writeOffCode); | ||
| 148 | + self.setData({ | ||
| 149 | + showQr: true, | ||
| 194 | }); | 150 | }); |
| 151 | + | ||
| 152 | + // let store_id = app.globalData.setting.stoid; | ||
| 153 | + // let id = this.data.options.id; | ||
| 154 | + // let url = `/api/weshop/rechargeServicelist/update/${store_id}/${id}`; | ||
| 155 | + | ||
| 156 | + // app.request.put(url, { | ||
| 157 | + // data: {}, | ||
| 158 | + // success: function(res) { | ||
| 159 | + // wx.hideLoading(); | ||
| 160 | + // if(res.data.code == 0) { | ||
| 161 | + // let verify_code = res.data.data.verify_code; | ||
| 162 | + // self.qrcode(verify_code); | ||
| 163 | + // self.setData({ | ||
| 164 | + // verify_code, | ||
| 165 | + // showQr: true, | ||
| 166 | + // }); | ||
| 167 | + // }; | ||
| 168 | + // } | ||
| 169 | + // }); | ||
| 195 | }, | 170 | }, |
| 196 | - | ||
| 197 | - | ||
| 198 | - // 评价商品 | ||
| 199 | - access() { | ||
| 200 | - let listLength = this.data.details.list.length; | ||
| 201 | - let order_id = this.data.details.order_id; | ||
| 202 | - let url = ''; | ||
| 203 | - | ||
| 204 | - // 卡项订单跳转到评论页要多加个参数card=1 | ||
| 205 | - // 卡项订单goods_id要带card_id | ||
| 206 | - if (listLength == 1) { | ||
| 207 | - let price = this.data.details.list[0].price; | ||
| 208 | - let card_id = this.data.details.list[0].card_id; | ||
| 209 | - url = | ||
| 210 | - `/packageB/pages/user/add_comment/add_comment?card=1&goods_id=${card_id}&order_id=${order_id}&price=${price}` | ||
| 211 | - }; | ||
| 212 | - if (listLength > 1) { | ||
| 213 | - url = `/packageB/pages/user/comment/comment?card=1&status=0&order_id=${order_id}`; | ||
| 214 | - }; | ||
| 215 | - f | ||
| 216 | - // console.log('url', url); | ||
| 217 | - app.goto(url); | ||
| 218 | - }, | ||
| 219 | - | ||
| 220 | - | ||
| 221 | - // 查看评论 | ||
| 222 | - viewComment() { | ||
| 223 | - let order_id = this.data.details.order_id; | ||
| 224 | - let card_id = this.data.details.list[0].card_id; | ||
| 225 | - let listLength = this.data.details.list.length; | ||
| 226 | - let url = ''; | ||
| 227 | - | ||
| 228 | - // 卡项订单单个商品 | ||
| 229 | - if (listLength == 1) { | ||
| 230 | - url = `/packageB/pages/user/view_comment/view_comment?card=1&goods_id=${card_id}&order_id=${order_id}`; | ||
| 231 | - }; | ||
| 232 | - // 卡项订单多个商品 | ||
| 233 | - if (listLength > 1) { | ||
| 234 | - // status控制评论列表页的activeStatus | ||
| 235 | - url = `/packageB/pages/user/comment/comment?card=1&status=1&order_id=${order_id}`; | ||
| 236 | - }; | ||
| 237 | - | ||
| 238 | - app.goto(url); | ||
| 239 | - }, | ||
| 240 | - | ||
| 241 | - | ||
| 242 | - // 再来一单 | ||
| 243 | - buy2(t) { | ||
| 244 | - let details = this.data.details; | ||
| 245 | - var th = this; | ||
| 246 | - var ind = 1; // 1:加入购物车 | ||
| 247 | - // var ind = t.currentTarget.dataset.openSpecModal_ind; | ||
| 248 | - // var action= t.currentTarget.dataset.action; | ||
| 249 | - var action = 'add'; // | ||
| 250 | - // if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | ||
| 251 | - | ||
| 252 | - th.setData({ | ||
| 253 | - open_ind_store: ind | 171 | + |
| 172 | + // showQr() { | ||
| 173 | + // // this.debounce(this.createQr, 300)(); | ||
| 174 | + // }, | ||
| 175 | + | ||
| 176 | + | ||
| 177 | + closeQr() { | ||
| 178 | + this.setData({ | ||
| 179 | + showQr: false, | ||
| 254 | }); | 180 | }); |
| 255 | - | ||
| 256 | - // if(!th.data.sto_sele_name){ | ||
| 257 | - // getApp().my_warnning('请选择门店', 1, th, 450); | ||
| 258 | - // return false; | ||
| 259 | - // } | ||
| 260 | - | ||
| 261 | - | ||
| 262 | - if (action == "buy") { | ||
| 263 | - //--------------此时操作的数据------------ | ||
| 264 | - // var newd = { | ||
| 265 | - // id: th.data.data.id, | ||
| 266 | - // goods_num: th.data.goodsInputNum, | ||
| 267 | - // pick_id: th.data.sto_sele_id, | ||
| 268 | - // keyid: th.data.sto_sele_keyid, | ||
| 269 | - // }; | ||
| 270 | - // newd['pick_name'] = th.data.sto_sele_name; | ||
| 271 | - // newd['guide_id'] = getApp().globalData.guide_id; | ||
| 272 | - // newd['guide_type']=0; | ||
| 273 | - // th.buyNow(newd); | ||
| 274 | - } else { | ||
| 275 | - | ||
| 276 | - var newd = { | ||
| 277 | - // service_id: th.data.data.id, | ||
| 278 | - // service_sn:th.data.data.service_sn, | ||
| 279 | - // service_name:th.data.data.goods_name, | ||
| 280 | - // goods_num: th.data.goodsInputNum, | ||
| 281 | - // pick_id: th.data.sto_sele_id, | ||
| 282 | - // user_id:oo.user_id, | ||
| 283 | - // store_id:os.stoid, | ||
| 284 | - // money:th.data.data.shop_price, | ||
| 285 | - | ||
| 286 | - service_id: details.list[0].card_id, | ||
| 287 | - service_sn: details.list[0].service_sn, | ||
| 288 | - service_name: details.list[0].service_name, | ||
| 289 | - goods_num: details.list[0].qty, | ||
| 290 | - pick_id: details.list[0].pickup_id, | ||
| 291 | - user_id: this.data.userInfo.user_id, | ||
| 292 | - store_id: app.globalData.setting.stoid, | ||
| 293 | - money: details.list[0].price, | ||
| 294 | - }; | ||
| 295 | - if (getApp().globalData.guide_id) { | ||
| 296 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 297 | - newd['guide_type'] = 0; | ||
| 298 | - } | ||
| 299 | - | ||
| 300 | - //----先看会员在购物车中是否加入了该商品----- | ||
| 301 | - app.request.get("/api/weshop/cartService/page", { | ||
| 302 | - data: { | ||
| 303 | - store_id: app.globalData.setting.stoid, | ||
| 304 | - user_id: this.data.userInfo.user_id, | ||
| 305 | - service_id: details.list[0].card_id, | ||
| 306 | - pick_id: details.list[0].pickup_id, | ||
| 307 | - }, | ||
| 308 | - success: function(re) { | ||
| 309 | - | ||
| 310 | - //-------如果购物车中有相关的数据--------- | ||
| 311 | - if (re.data.data.total > 0) { | ||
| 312 | - var item = re.data.data.pageData[0]; | ||
| 313 | - var updata = { | ||
| 314 | - id: item.id, | ||
| 315 | - goods_num: details.list[0].qty + item.goods_num, | ||
| 316 | - money: details.list[0].price, | ||
| 317 | - store_id: app.globalData.setting.stoid, | ||
| 318 | - }; | ||
| 319 | - | ||
| 320 | - if (getApp().globalData.guide_id) { | ||
| 321 | - updata['guide_id'] = getApp().globalData.guide_id; | ||
| 322 | - updata['guide_type'] = 1; | ||
| 323 | - } | ||
| 324 | - getApp().request.put("/api/weshop/cartService/update", { | ||
| 325 | - data: updata, | ||
| 326 | - success: function(t) { | ||
| 327 | - // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 328 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 329 | - th.setData({ | ||
| 330 | - cartGoodsNum: c_num | ||
| 331 | - }); | ||
| 332 | - app.goto('/pages/cart/cart/cart'); | ||
| 333 | - // th.closeSpecModal(); | ||
| 334 | - } | ||
| 335 | - }); | ||
| 336 | - } else { | ||
| 337 | - | ||
| 338 | - getApp().request.post("/api/weshop/cartService/save", { | ||
| 339 | - data: newd, | ||
| 340 | - success: function(t) { | ||
| 341 | - // getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 342 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 343 | - th.setData({ | ||
| 344 | - cartGoodsNum: c_num | ||
| 345 | - }); | ||
| 346 | - app.goto('/pages/cart/cart/cart'); | ||
| 347 | - // th.closeSpecModal(); | ||
| 348 | - } | ||
| 349 | - }); | ||
| 350 | - } | ||
| 351 | - } | ||
| 352 | - }); | ||
| 353 | - | ||
| 354 | - } | ||
| 355 | - }, | ||
| 356 | - | ||
| 357 | - | ||
| 358 | - // 取消订单 | ||
| 359 | - // api/weshop/recharge/update?store_id=&order_id=&order_status=3 | ||
| 360 | - cancle() { | ||
| 361 | - wx.showModal({ | ||
| 362 | - title: '提示', | ||
| 363 | - content: '确定取消订单吗?', | ||
| 364 | - success(res) { | ||
| 365 | - if (res.confirm) { | ||
| 366 | - console.log('用户点击确定'); | ||
| 367 | - let order_id = self.data.details.order_id; | ||
| 368 | - let order_sn = self.data.details.order_sn; | ||
| 369 | - app.request.put('/api/weshop/recharge/update', { | ||
| 370 | - data: { | ||
| 371 | - store_id: os.stoid, | ||
| 372 | - order_id: order_id, | ||
| 373 | - order_sn: order_sn, | ||
| 374 | - order_status: 3, | ||
| 375 | - }, | ||
| 376 | - success: function(res) { | ||
| 377 | - | ||
| 378 | - //取消成功刷新订单 | ||
| 379 | - let url = '/api/weshop/recharge/user/page' | ||
| 380 | - let data = { | ||
| 381 | - store_id: app.globalData.setting.stoid, | ||
| 382 | - user_id: self.data.userInfo.user_id, | ||
| 383 | - order_id: self.data.options.order_id, | ||
| 384 | - }; | ||
| 385 | - | ||
| 386 | - // 请求数据 | ||
| 387 | - app.promiseGet(url, { | ||
| 388 | - data: data, | ||
| 389 | - }).then(res => { | ||
| 390 | - if (res.data.code == 0) { | ||
| 391 | - console.log('请求成功', res); | ||
| 392 | - wx.showToast({ | ||
| 393 | - title: '取消成功', | ||
| 394 | - }); | ||
| 395 | - self.setData({ | ||
| 396 | - details: res.data.data.pageData[0], | ||
| 397 | - }); | ||
| 398 | - } else { | ||
| 399 | - throw (res); | ||
| 400 | - }; | ||
| 401 | - }).catch(err => { | ||
| 402 | - wx.showToast({ | ||
| 403 | - title: err.data.data, | ||
| 404 | - icon: 'error', | ||
| 405 | - }); | ||
| 406 | - }); | ||
| 407 | - | ||
| 408 | - }, | ||
| 409 | - }) | ||
| 410 | - } else if (res.cancel) { | ||
| 411 | - console.log('用户点击取消'); | ||
| 412 | - } | ||
| 413 | - } | 181 | + |
| 182 | + // 关闭二维码弹窗后,检测核销情况,改变按钮状态 | ||
| 183 | + wx.showLoading({ | ||
| 184 | + title: '刷新中', | ||
| 185 | + mask: true, | ||
| 414 | }); | 186 | }); |
| 415 | - }, | ||
| 416 | - | ||
| 417 | - | ||
| 418 | - // 立即支付 | ||
| 419 | - pay() { | ||
| 420 | - let order_sn = this.data.details.order_sn; | ||
| 421 | - let store_id = app.globalData.setting.stoid; | ||
| 422 | - | ||
| 423 | - app.request.post('/api/weshop/order/pay/createRechargeOrder', { | 187 | + |
| 188 | + // let store_id = app.globalData.setting.stoid; | ||
| 189 | + // let id = this.data.options.id; | ||
| 190 | + let url = '/api/weshop/serviceCard/listWriteoffWare'; | ||
| 191 | + | ||
| 192 | + app.request.promiseGet(url, { | ||
| 424 | data: { | 193 | data: { |
| 425 | - parentSn: order_sn, | ||
| 426 | - store_id: store_id, | ||
| 427 | - }, | ||
| 428 | - | ||
| 429 | - success: function(res) { | ||
| 430 | - var n = res.data.data; | ||
| 431 | - self.weixinPay(n, function() { | ||
| 432 | - app.showWarning('支付成功'); | ||
| 433 | - // setTimeout(function() { | ||
| 434 | - // wx.reLaunch({ | ||
| 435 | - // url: '/pages/user/my_service/i_service', | ||
| 436 | - // }) | ||
| 437 | - // }, 1000) | ||
| 438 | - }, function() { | ||
| 439 | - app.showWarning('支付失败'); | ||
| 440 | - // setTimeout(function() { | ||
| 441 | - // wx.reLaunch({ | ||
| 442 | - // url: '/packageA/pages/cardList/cardList', | ||
| 443 | - // }) | ||
| 444 | - // }, 1000) | ||
| 445 | - }); | ||
| 446 | - } | ||
| 447 | - }) | ||
| 448 | - }, | ||
| 449 | - | ||
| 450 | - | ||
| 451 | - //------调起支付框-------- | ||
| 452 | - weixinPay: function(n, success, fail) { | ||
| 453 | - if (!n) return false; | ||
| 454 | - wx.requestPayment({ | ||
| 455 | - timeStamp: String(n.timeStamp), | ||
| 456 | - nonceStr: n.nonceStr, | ||
| 457 | - package: n.packageValue, | ||
| 458 | - signType: n.signType, | ||
| 459 | - paySign: n.paySign, | ||
| 460 | - success: function(n) { | ||
| 461 | - console.log(n), getApp().showSuccess("支付成功!"); | ||
| 462 | - "function" == typeof success && success(); | ||
| 463 | - wx.redirectTo({ | ||
| 464 | - url: "../deposit/deposit" | ||
| 465 | - }); | 194 | + store_id: app.globalData.setting.stoid, |
| 195 | + user_id: this.data.userInfo.user_id, | ||
| 196 | + Id: this.data.options.formlistid, | ||
| 466 | }, | 197 | }, |
| 467 | - fail: function(n) { | ||
| 468 | - console.log(n), "requestPayment:fail" == n.errMsg ? getApp().showWarning("支付失败") : | ||
| 469 | - "requestPayment:fail cancel" == n.errMsg ? getApp().showWarning("您已取消支付") : getApp().showWarning("支付失败:" + n | ||
| 470 | - .errMsg.substr("requestPayment:fail ".length)), | ||
| 471 | - "function" == typeof fail && fail(); | ||
| 472 | - } | 198 | + }).then(res => { |
| 199 | + wx.hideLoading(); | ||
| 200 | + if (res.data.code == 0) { | ||
| 201 | + | ||
| 202 | + let posNo = res.data.data[0].PosNo; | ||
| 203 | + if(posNo != '') { | ||
| 204 | + self.setData({ | ||
| 205 | + ['options.usestate']: 1, | ||
| 206 | + }); | ||
| 207 | + } else { | ||
| 208 | + self.setData({ | ||
| 209 | + ['options.usestate']: 0, | ||
| 210 | + }); | ||
| 211 | + }; | ||
| 212 | + | ||
| 213 | + } else { | ||
| 214 | + throw (res); | ||
| 215 | + }; | ||
| 216 | + }).catch(err => { | ||
| 217 | + // wx.showToast({ | ||
| 218 | + // title: err.data.data, | ||
| 219 | + // icon: 'error', | ||
| 220 | + // }); | ||
| 473 | }); | 221 | }); |
| 222 | + | ||
| 223 | + | ||
| 224 | + | ||
| 225 | + // app.promiseGet(url, { | ||
| 226 | + // data: { | ||
| 227 | + // store_id: app.globalData.setting.stoid, | ||
| 228 | + // user_id: self.data.userInfo.user_id, | ||
| 229 | + // Id: self.data.options.formlistid, | ||
| 230 | + // }, | ||
| 231 | + // success: function(res) { | ||
| 232 | + // wx.hideLoading(); | ||
| 233 | + // if(res.data.code == 0) { | ||
| 234 | + // console.log('xxx000', res.data.data); | ||
| 235 | + // // let posNo = res.data.data[0].PosNo; | ||
| 236 | + // // if(posNo != '') { | ||
| 237 | + // // self.setData({ | ||
| 238 | + // // ['options.usestate']: 1, | ||
| 239 | + // // }); | ||
| 240 | + // // } else { | ||
| 241 | + // // self.setData({ | ||
| 242 | + // // ['options.usestate']: 0, | ||
| 243 | + // // }); | ||
| 244 | + // // }; | ||
| 245 | + | ||
| 246 | + // }; | ||
| 247 | + // } | ||
| 248 | + // }); | ||
| 249 | + | ||
| 250 | + | ||
| 251 | + | ||
| 474 | }, | 252 | }, |
| 475 | 253 | ||
| 254 | + /** | ||
| 255 | + * 生成二维码 | ||
| 256 | + * by sty | ||
| 257 | + */ | ||
| 258 | + qrcode(val) { | ||
| 259 | + barcode('barcode', val, 600,140); | ||
| 260 | + qrcode('qrcode', val, 300, 300); | ||
| 261 | + }, | ||
| 476 | 262 | ||
| 263 | + touchMove() {}, | ||
| 477 | 264 | ||
| 478 | - | ||
| 479 | - | ||
| 480 | - | ||
| 481 | - | ||
| 482 | - | ||
| 483 | - showQr() { | ||
| 484 | - this.setData({ | ||
| 485 | - showQr: true, | ||
| 486 | - }); | 265 | + // 函数防抖 |
| 266 | + debounce(func, wait) { | ||
| 267 | + return () => { | ||
| 268 | + clearTimeout(timer); | ||
| 269 | + timer = setTimeout(func, wait); | ||
| 270 | + }; | ||
| 487 | }, | 271 | }, |
| 488 | 272 | ||
| 489 | - closeQr() { | ||
| 490 | - this.setData({ | ||
| 491 | - showQr: false, | ||
| 492 | - }); | ||
| 493 | - }, | ||
| 494 | 273 | ||
| 495 | - touchMove() {} | ||
| 496 | 274 | ||
| 497 | 275 | ||
| 498 | 276 |
packageB/pages/boxes-details/boxes-details.json
packageB/pages/boxes-details/boxes-details.wxml
| 1 | -<wxs module="filter" src="../../../utils/filter.wxs"></wxs> | 1 | +<wxs module="filters" src="../../../utils/filter.wxs"></wxs> |
| 2 | 2 | ||
| 3 | <view class="main"> | 3 | <view class="main"> |
| 4 | <view class="bg-white pdh20 bdr12"> | 4 | <view class="bg-white pdh20 bdr12"> |
| 5 | - <block> | ||
| 6 | - <!-- 门店名称栏 --> | ||
| 7 | - <!-- <view class="flex jc_sb ai_c pdv20"> | ||
| 8 | - <view class="ellipsis-1 pdr40 fs30"><text class="iconfont icon-shop c-red pdr10"></text>{{item.pickup_name}}</view> | ||
| 9 | - <block> | ||
| 10 | - <text class="c-red shrink0 fs26" wx:if="{{details.order_status == 0}}">待支付</text> | ||
| 11 | - <text class="c-red shrink0 fs26" wx:if="{{details.order_status == 1}}">待评价</text> | ||
| 12 | - <text class="c-red shrink0 fs26" wx:if="{{details.order_status == 2}}">已评价</text> | ||
| 13 | - <text class="c-red shrink0 fs26" wx:if="{{details.order_status == 3}}">已取消</text> | ||
| 14 | - <text class="c-red shrink0 fs26" wx:if="{{details.order_status == 5}}">已作废</text> | ||
| 15 | - </block> | ||
| 16 | - </view> --> | ||
| 17 | - | ||
| 18 | - <!-- 列表栏 --> | ||
| 19 | - <view> | ||
| 20 | - <!-- <view class="flex pdv20" wx:for="{{details.list}}" bindtap="viewDetails" data-gid="{{item.card_id}}"> --> | ||
| 21 | - <view class="flex pdv20" bindtap="viewDetails" data-gid="{{item.card_id}}" wx:for="{{14}}"> | ||
| 22 | - <view class="pic-box shrink0"> | ||
| 23 | - <text class="iconfont icon-shangpin fs60 white"></text> | ||
| 24 | - </view> | ||
| 25 | - <view class="pdl20 f1"> | ||
| 26 | - <view class="flex jc_sb ai_c"> | ||
| 27 | - <view class="title ellipsis-2 pdr40">商品名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称名称</view> | ||
| 28 | - <text class="c-6">x1{{item.price}}</text> | ||
| 29 | - </view> | ||
| 30 | - <view class="flex ai_c c-9 fs26"> | ||
| 31 | - <!-- <text>10个/蓝色</text> --> | ||
| 32 | - <text class="rmb c-red">2{{filters.price(item.group_price)}}</text> | ||
| 33 | - <view class="fs22 del pdl10 c-c7">零售价<text class="rmb">3{{item.market_price}}</text></view> | ||
| 34 | - </view> | ||
| 35 | - </view> | 5 | + <view class="flex pdv20" wx:for="{{details}}"> |
| 6 | + <view class="pic-box shrink0"> | ||
| 7 | + <text class="iconfont icon-shangpin fs60 white"></text> | ||
| 8 | + </view> | ||
| 9 | + <view class="pdl20 f1"> | ||
| 10 | + <view class="flex jc_sb ai_c"> | ||
| 11 | + <view class="title ellipsis-2 pdr40">{{item.WareName}}</view> | ||
| 12 | + <text class="c-6">x{{item.Qty}}</text> | ||
| 13 | + </view> | ||
| 14 | + <view class="flex ai_c c-9 fs26"> | ||
| 15 | + <text class="rmb c-red">{{filters.show_default(item.VipPrice, '0')}}</text> | ||
| 16 | + <view class="fs22 del pdl10 c-c7">零售价<text class="rmb">{{filters.show_default(item.PosPrice, '0')}}</text></view> | ||
| 36 | </view> | 17 | </view> |
| 37 | </view> | 18 | </view> |
| 38 | - </block> | ||
| 39 | - | ||
| 40 | - | ||
| 41 | - <!-- 统计栏 --> | ||
| 42 | - <!-- <view class="t-r bdt pdv20">共{{filter.count(details.list)}}件商品,合计:<text class="rmb c-red bold fs30">{{details.account}}</text></view> --> | 19 | + </view> |
| 43 | </view> | 20 | </view> |
| 44 | 21 | ||
| 45 | - | ||
| 46 | - | ||
| 47 | - | ||
| 48 | <!-- 底部按钮栏 --> | 22 | <!-- 底部按钮栏 --> |
| 49 | <view class="btn-bar bg-white pd20 t-c"> | 23 | <view class="btn-bar bg-white pd20 t-c"> |
| 50 | - <!-- <text class="btn bg-orange white" bindtap="buy2">再来一单</text> --> | ||
| 51 | - <text class="btn bg-red white" bindtap="showQr">立即兑换</text> | 24 | + <!-- 已核销 --> |
| 25 | + <text class="btn bg-gray white" wx:if="{{options.usestate == 1}}">已核销</text> | ||
| 26 | + <!-- 待核销 --> | ||
| 27 | + <block wx:else> | ||
| 28 | + <text class="btn bg-gray white" wx:if="{{filters.isExpired(options.date)}}">已过期</text> | ||
| 29 | + <text class="btn bg-red white" bindtap="showQr" wx:else>立即兑换</text> | ||
| 30 | + </block> | ||
| 52 | </view> | 31 | </view> |
| 53 | </view> | 32 | </view> |
| 54 | 33 | ||
| 55 | 34 | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - | ||
| 59 | - | ||
| 60 | <!-- 遮罩层 --> | 35 | <!-- 遮罩层 --> |
| 61 | <view class="mask" hidden="{{!showQr}}" catchtouchmove="touchMove"></view> | 36 | <view class="mask" hidden="{{!showQr}}" catchtouchmove="touchMove"></view> |
| 62 | <!-- 码 --> | 37 | <!-- 码 --> |
| 63 | <view class="popup-container" hidden="{{!showQr}}" catchtouchmove="touchMove"> | 38 | <view class="popup-container" hidden="{{!showQr}}" catchtouchmove="touchMove"> |
| 64 | - <view class="t-r pdb20"><text class="iconfont icon-close fs40" bindtap="closeQr"></text></view> | 39 | + <view class="t-r pdb10"><text class="iconfont icon-close fs40" bindtap="closeQr"></text></view> |
| 65 | <view class="popup"> | 40 | <view class="popup"> |
| 66 | - <!-- <view class="popup-title"> | ||
| 67 | - <block wx:if="{{details[useIndex].isby == 1}}">包邮券</block> | ||
| 68 | - <block wx:else> | ||
| 69 | - {{filter.getNum(details[useIndex].Sum)}}元微券 | ||
| 70 | - </block> | ||
| 71 | - </view> --> | ||
| 72 | - <!-- <view class="pdt20 c-fe0000"><text class="rmb fs80" wx:if="{{details[useIndex].isby != 1}}">{{filter.getNum(details[useIndex].Sum)}}</text></view> --> | ||
| 73 | <!-- 条形码 --> | 41 | <!-- 条形码 --> |
| 74 | <view class="bar-container"> | 42 | <view class="bar-container"> |
| 75 | <canvas class="barcode" canvas-id="barcode"/> | 43 | <canvas class="barcode" canvas-id="barcode"/> |
| 76 | - <view class="pdt20 fs26" wx:if="{{details[useIndex].CashRepNo}}">{{details[useIndex].CashRepNo}}</view> | ||
| 77 | - <view class="pdt20 fs26" wx:else>{{details[useIndex].no}}</view> | ||
| 78 | </view> | 44 | </view> |
| 79 | <!-- 二维码 --> | 45 | <!-- 二维码 --> |
| 80 | <view class="qr-container"> | 46 | <view class="qr-container"> |
| 81 | <canvas class="qrcode" canvas-id="qrcode"/> | 47 | <canvas class="qrcode" canvas-id="qrcode"/> |
| 82 | </view> | 48 | </view> |
| 83 | <view class="pdv20 c-7b fs26 bdt"> | 49 | <view class="pdv20 c-7b fs26 bdt"> |
| 84 | - <text wx:if="{{details[useIndex].ValidDate}}" class="ellipsis-1x">有效期:{{details[useIndex].BeginDate==null ? " " : time.replace_time2(details[useIndex].BeginDate)}} 至 {{time.replace_time2(details[useIndex].ValidDate)}}</text> | ||
| 85 | - <text wx:elif="{{details[useIndex].use_end_time}}" class="ellipsis-1x">有效期:{{details[useIndex].use_start_time==null ? " " : time.format_time(details[useIndex].use_start_time)}} 至 {{time.format_time(details[useIndex].use_end_time)}}</text> | ||
| 86 | - <text wx:else>有效期:不限</text> | 50 | + <text>核销码: {{writeOffCode}}</text> |
| 87 | </view> | 51 | </view> |
| 88 | </view> | 52 | </view> |
| 89 | </view> | 53 | </view> |
packageB/pages/boxes-details/boxes-details.wxss
| @@ -29,6 +29,11 @@ page { | @@ -29,6 +29,11 @@ page { | ||
| 29 | background-image: linear-gradient(135deg,#ffba0d,#ffc30d 69%,#ffcf0d); | 29 | background-image: linear-gradient(135deg,#ffba0d,#ffc30d 69%,#ffcf0d); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | +.bg-gray { | ||
| 33 | + background-image: -webkit-linear-gradient(315deg,#bfbfbf,#c3c3c3 70%,#d4d3d3); | ||
| 34 | + background-image: linear-gradient(135deg,#bfbfbf,#c3c3c3 70%,#d4d3d3); | ||
| 35 | + } | ||
| 36 | + | ||
| 32 | .c-orange { | 37 | .c-orange { |
| 33 | color: #ff9000; | 38 | color: #ff9000; |
| 34 | } | 39 | } |
| @@ -177,6 +182,11 @@ page { | @@ -177,6 +182,11 @@ page { | ||
| 177 | background-color: pink; | 182 | background-color: pink; |
| 178 | } | 183 | } |
| 179 | 184 | ||
| 185 | + .barcode { | ||
| 186 | + width: 100%; | ||
| 187 | + height: 140rpx; | ||
| 188 | + } | ||
| 189 | + | ||
| 180 | .qrcode { | 190 | .qrcode { |
| 181 | width: 300rpx; | 191 | width: 300rpx; |
| 182 | height: 300rpx; | 192 | height: 300rpx; |
| @@ -194,6 +204,11 @@ page { | @@ -194,6 +204,11 @@ page { | ||
| 194 | .breakall { | 204 | .breakall { |
| 195 | word-break: break-all; | 205 | word-break: break-all; |
| 196 | } | 206 | } |
| 207 | + | ||
| 208 | + .bar-container { | ||
| 209 | + box-sizing: border-box; | ||
| 210 | + padding: 30rpx 20rpx; | ||
| 211 | + } | ||
| 197 | 212 | ||
| 198 | 213 | ||
| 199 | 214 |
packageB/pages/boxes-list/boxes-list.js
| 1 | const app = getApp(); | 1 | const app = getApp(); |
| 2 | let self = null; | 2 | let self = null; |
| 3 | +// 防抖函数用定时器 | ||
| 4 | +let timer; | ||
| 3 | 5 | ||
| 4 | Page({ | 6 | Page({ |
| 5 | data: { | 7 | data: { |
| @@ -11,26 +13,6 @@ Page({ | @@ -11,26 +13,6 @@ Page({ | ||
| 11 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 | 13 | isLoading: false, // 检测是否已经发送请求,防止重复发送请求 |
| 12 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 | 14 | noMore: false, // 检测是否有更多数据,true为没有更多数据,false为还有数据 |
| 13 | pageNum: 1, // 当前页数 | 15 | pageNum: 1, // 当前页数 |
| 14 | - | ||
| 15 | - // showReward: false, | ||
| 16 | - // prizesArr: [], | ||
| 17 | - | ||
| 18 | - // typeArr: [{ | ||
| 19 | - // key: 'point', | ||
| 20 | - // name: '积分', | ||
| 21 | - // },{ | ||
| 22 | - // key: 'grow', | ||
| 23 | - // name: '成长值', | ||
| 24 | - // },{ | ||
| 25 | - // key: 'point', | ||
| 26 | - // name: '优惠券', | ||
| 27 | - // },{ | ||
| 28 | - // key: 'prestore_name', | ||
| 29 | - // name: '项目服务', | ||
| 30 | - // },{ | ||
| 31 | - // key: 'prestore_money', | ||
| 32 | - // name: '预存金额', | ||
| 33 | - // }], | ||
| 34 | }, | 16 | }, |
| 35 | 17 | ||
| 36 | onLoad: function () { | 18 | onLoad: function () { |
| @@ -54,10 +36,11 @@ Page({ | @@ -54,10 +36,11 @@ Page({ | ||
| 54 | let data = { | 36 | let data = { |
| 55 | store_id: app.globalData.setting.stoid, | 37 | store_id: app.globalData.setting.stoid, |
| 56 | user_id: this.data.userInfo.user_id, | 38 | user_id: this.data.userInfo.user_id, |
| 39 | + IsPos: 0, | ||
| 57 | }; | 40 | }; |
| 58 | 41 | ||
| 59 | - // 默认获取'全部' | ||
| 60 | - this.getData(true, '/api/weshop/prom/luckyOrder/page', data) | 42 | + // 默认获取'待核销' |
| 43 | + this.getData(true, '/api/weshop/serviceCard/pageWriteoff', data) | ||
| 61 | .then(()=>{ | 44 | .then(()=>{ |
| 62 | this.setData({ | 45 | this.setData({ |
| 63 | currentData: data, | 46 | currentData: data, |
| @@ -73,25 +56,25 @@ Page({ | @@ -73,25 +56,25 @@ Page({ | ||
| 73 | * 页面上拉触底事件的处理函数 | 56 | * 页面上拉触底事件的处理函数 |
| 74 | */ | 57 | */ |
| 75 | onReachBottom: function () { | 58 | onReachBottom: function () { |
| 76 | - this.scrollToLower('/api/weshop/prom/luckyOrder/page', this.data.currentData); | 59 | + this.scrollToLower('/api/weshop/serviceCard/pageWriteoff', this.data.currentData); |
| 77 | }, | 60 | }, |
| 78 | 61 | ||
| 79 | 62 | ||
| 80 | // 图片异常时加载默认图片 | 63 | // 图片异常时加载默认图片 |
| 81 | - bind_bnerr: function (e) { | ||
| 82 | - var _errImg = e.target.dataset.errorimg; | ||
| 83 | - var val = e.target.dataset.val; | ||
| 84 | - if(val!=undefined && val!=null && val!='null' ){ | ||
| 85 | - var _errObj = {}; | ||
| 86 | - _errObj[_errImg] = "/public/images/default_goods_image_240.gif"; | ||
| 87 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 88 | - } | ||
| 89 | - }, | 64 | + // bind_bnerr: function (e) { |
| 65 | + // var _errImg = e.target.dataset.errorimg; | ||
| 66 | + // var val = e.target.dataset.val; | ||
| 67 | + // if(val!=undefined && val!=null && val!='null' ){ | ||
| 68 | + // var _errObj = {}; | ||
| 69 | + // _errObj[_errImg] = "/public/images/default_goods_image_240.gif"; | ||
| 70 | + // this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 71 | + // } | ||
| 72 | + // }, | ||
| 90 | 73 | ||
| 91 | 74 | ||
| 92 | 75 | ||
| 93 | // 点击tab选项卡 | 76 | // 点击tab选项卡 |
| 94 | - clickTab(e) { | 77 | + handleTab(e) { |
| 95 | this.setData({ | 78 | this.setData({ |
| 96 | currentTabIndex: e.target.dataset.index, | 79 | currentTabIndex: e.target.dataset.index, |
| 97 | noMore: false, | 80 | noMore: false, |
| @@ -106,28 +89,24 @@ Page({ | @@ -106,28 +89,24 @@ Page({ | ||
| 106 | 89 | ||
| 107 | switch(currentTabIndex) { | 90 | switch(currentTabIndex) { |
| 108 | case 0: { | 91 | case 0: { |
| 109 | - delete currentData.team_status; | 92 | + currentData.IsPos = 0; |
| 110 | break; | 93 | break; |
| 111 | }; | 94 | }; |
| 112 | case 1: { | 95 | case 1: { |
| 113 | - currentData.team_status = 0; | ||
| 114 | - break; | ||
| 115 | - }; | ||
| 116 | - case 2: { | ||
| 117 | - currentData.team_status = 2; | ||
| 118 | - break; | ||
| 119 | - }; | ||
| 120 | - case 3: { | ||
| 121 | - currentData.team_status = 1; | 96 | + currentData.IsPos = 1; |
| 122 | break; | 97 | break; |
| 123 | }; | 98 | }; |
| 124 | }; | 99 | }; |
| 125 | 100 | ||
| 126 | // 请求 | 101 | // 请求 |
| 127 | - this.getData(true, '/api/weshop/prom/luckyOrder/page', currentData); | 102 | + this.getData(true, '/api/weshop/serviceCard/pageWriteoff', currentData); |
| 128 | 103 | ||
| 129 | }, | 104 | }, |
| 130 | 105 | ||
| 106 | + clickTab(e) { | ||
| 107 | + this.debounce(this.handleTab.bind(this, e), 200)(); | ||
| 108 | + }, | ||
| 109 | + | ||
| 131 | 110 | ||
| 132 | /** | 111 | /** |
| 133 | * 请求数据 | 112 | * 请求数据 |
| @@ -197,134 +176,27 @@ Page({ | @@ -197,134 +176,27 @@ Page({ | ||
| 197 | }; | 176 | }; |
| 198 | }, | 177 | }, |
| 199 | 178 | ||
| 179 | + | ||
| 200 | 180 | ||
| 201 | - //跳转 | ||
| 202 | - go: function (e) { | ||
| 203 | - var url = e.currentTarget.dataset.url; | ||
| 204 | - getApp().goto(url); | ||
| 205 | - }, | ||
| 206 | - | ||
| 207 | - //查看奖励 | ||
| 208 | - showReward: function(e) { | ||
| 209 | - this.setData({ | ||
| 210 | - currentItemIndex: e.target.dataset.index, | ||
| 211 | - currentItemAid: e.target.dataset.aid, | ||
| 212 | - }); | ||
| 213 | - this.getPrizes(this.data.currentItemIndex); | ||
| 214 | - }, | ||
| 215 | - | ||
| 216 | - //关闭奖励 | ||
| 217 | - closeReward: function() { | ||
| 218 | - this.setData({ | ||
| 219 | - showReward: false, | ||
| 220 | - }); | 181 | + viewDetails(e) { |
| 182 | + let formlistid = e.currentTarget.dataset.formlistid; | ||
| 183 | + let title = e.currentTarget.dataset.title; | ||
| 184 | + let date = e.currentTarget.dataset.date; //有效截止日期 | ||
| 185 | + let use_state = this.data.currentTabIndex; //0待核销 1已核销 | ||
| 186 | + let url = `/packageB/pages/boxes-details/boxes-details?formlistid=${formlistid}&title=${title}&usestate=${use_state}&date=${date}`; | ||
| 187 | + | ||
| 188 | + app.goto(url); | ||
| 221 | }, | 189 | }, |
| 222 | 190 | ||
| 223 | 191 | ||
| 224 | - // 获取优惠券奖励和服务项目奖励 | ||
| 225 | - getPrizes: function(currentItemIndex) { | ||
| 226 | - let currentItem = this.data.list.pageData[currentItemIndex]; | ||
| 227 | - let type = currentItem.type; | ||
| 228 | - | ||
| 229 | - // 分割type字符串 | ||
| 230 | - let typeArr = this.splitStringToArr(type); | ||
| 231 | - let prizesArr = []; | ||
| 232 | - let promiseArr = []; | ||
| 233 | - typeArr.forEach(function(item) { | ||
| 234 | - | ||
| 235 | - let obj = {}; | ||
| 236 | - obj.type = item; | ||
| 237 | - | ||
| 238 | - let promise = new Promise((resolve, reject) => { | ||
| 239 | - switch(item) { | ||
| 240 | - case 1: { //积分 | ||
| 241 | - obj.name = '积分'; | ||
| 242 | - obj.num = 'point'; | ||
| 243 | - prizesArr.push(obj); | ||
| 244 | - resolve(); | ||
| 245 | - break; | ||
| 246 | - }; | ||
| 247 | - case 2: { //成长值 | ||
| 248 | - obj.name = '成长值'; | ||
| 249 | - obj.num = 'grow'; | ||
| 250 | - prizesArr.push(obj); | ||
| 251 | - resolve(); | ||
| 252 | - break; | ||
| 253 | - }; | ||
| 254 | - case 3: { //优惠券 | ||
| 255 | - app.request.promiseGet('/api/weshop/prom/luckyCoupon/page', { | ||
| 256 | - data: { | ||
| 257 | - store_id: app.globalData.setting.stoid, | ||
| 258 | - aid: self.data.currentItemAid, | ||
| 259 | - } | ||
| 260 | - }).then(res => { | ||
| 261 | - if(res.data.code == 0) { | ||
| 262 | - obj.couponList = res.data.data.pageData; | ||
| 263 | - prizesArr.push(obj); | ||
| 264 | - resolve(); | ||
| 265 | - }; | ||
| 266 | - }); | ||
| 267 | - break; | ||
| 268 | - }; | ||
| 269 | - case 4: { //服务项目 | ||
| 270 | - app.request.promiseGet('/api/weshop/prom/luckyService/page', { | ||
| 271 | - data: { | ||
| 272 | - store_id: app.globalData.setting.stoid, | ||
| 273 | - aid: self.data.currentItemAid, | ||
| 274 | - } | ||
| 275 | - }).then(res => { | ||
| 276 | - if(res.data.code == 0) { | ||
| 277 | - obj.serviceList = res.data.data.pageData; | ||
| 278 | - prizesArr.push(obj); | ||
| 279 | - resolve(); | ||
| 280 | - }; | ||
| 281 | - }); | ||
| 282 | - break; | ||
| 283 | - }; | ||
| 284 | - case 5: { //预存金额 | ||
| 285 | - obj.name = 'prestore_name'; | ||
| 286 | - obj.num = 'prestore_money'; | ||
| 287 | - prizesArr.push(obj); | ||
| 288 | - resolve(); | ||
| 289 | - break; | ||
| 290 | - }; | ||
| 291 | - }; | ||
| 292 | - }); | ||
| 293 | - | ||
| 294 | - promiseArr.push(promise); | ||
| 295 | - | ||
| 296 | - | ||
| 297 | - Promise.all(promiseArr).then(()=> { | ||
| 298 | - self.setData({ | ||
| 299 | - prizesArr, | ||
| 300 | - showReward: true, | ||
| 301 | - }); | ||
| 302 | - }); | ||
| 303 | - | ||
| 304 | - }); | ||
| 305 | - }, | ||
| 306 | - | ||
| 307 | - // 将type字符串分割成数组 | ||
| 308 | - splitStringToArr: function(typeStr) { | ||
| 309 | - var index; | ||
| 310 | - var newTypeArr = []; | ||
| 311 | - var typeStrArr = typeStr.split(','); | ||
| 312 | - typeStrArr.forEach(function(item) { | ||
| 313 | - index = parseInt(item); | ||
| 314 | - newTypeArr.push(index); | ||
| 315 | - }); | ||
| 316 | - return newTypeArr; | 192 | + // 函数防抖 |
| 193 | + debounce(func, wait) { | ||
| 194 | + return () => { | ||
| 195 | + clearTimeout(timer); | ||
| 196 | + timer = setTimeout(func, wait); | ||
| 197 | + }; | ||
| 317 | }, | 198 | }, |
| 318 | 199 | ||
| 319 | 200 | ||
| 320 | - | ||
| 321 | - | ||
| 322 | - | ||
| 323 | - viewDetails() { | ||
| 324 | - let url = '/packageB/pages/boxes-details/boxes-details'; | ||
| 325 | - app.goto(url); | ||
| 326 | - } | ||
| 327 | - | ||
| 328 | - | ||
| 329 | }) | 201 | }) |
| 330 | 202 |
packageB/pages/boxes-list/boxes-list.wxml
| @@ -10,26 +10,34 @@ | @@ -10,26 +10,34 @@ | ||
| 10 | <view class="tab-bd"> | 10 | <view class="tab-bd"> |
| 11 | <view class="list"> | 11 | <view class="list"> |
| 12 | 12 | ||
| 13 | - | ||
| 14 | - <view class="list-item" wx:if="{{currentTabIndex == 0}}" bindtap="viewDetails"> | 13 | + <block wx:for="{{list.pageData}}"> |
| 14 | + <view class="list-item" bindtap="viewDetails" data-formlistid="{{item.FormLIstID}}" data-title="{{item.ItemName}}" data-date="{{item.EndDate}}"> | ||
| 15 | <view class="pd20"> | 15 | <view class="pd20"> |
| 16 | - <view class=""><text class="fs24 c-9">订单编号:</text>191561561565555</view> | ||
| 17 | - <view class="ellipsis-2 title">卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称</view> | 16 | + <!-- <view class="fs26"><text class="c-9">卡项编号:</text></view> --> |
| 17 | + <view class="ellipsis-2 title fs28">{{item.ItemName}} ({{item.ItemNo}})</view> | ||
| 18 | <view class="flex ai-center"> | 18 | <view class="flex ai-center"> |
| 19 | - <text class="rmb fs40 c-red">2{{filters.price(item.group_price)}}</text> | ||
| 20 | - <view class="fs22 del pdl10 c-c7">零售价<text class="rmb">3{{item.market_price}}</text></view> | 19 | + <text class="rmb fs40 c-red">{{filters.show_default(item.VipPrice, '0')}}</text> |
| 20 | + <view class="fs22 del pdl10 c-c7">零售价<text class="rmb">{{filters.show_default(item.PosPrice, '0')}}</text></view> | ||
| 21 | </view> | 21 | </view> |
| 22 | - <view class="fs24 c-red">*兑换截止日期:2022-01-01至2022-12-31</view> | 22 | + <view class="fs24 c-red">*兑换截止日期:{{item.BeginDate}}至{{item.EndDate}}</view> |
| 23 | </view> | 23 | </view> |
| 24 | 24 | ||
| 25 | <view class="pd20 bdt fs24 t-r"> | 25 | <view class="pd20 bdt fs24 t-r"> |
| 26 | - <view class="btn bg-gray white">已过期</view> | ||
| 27 | - <view class="btn bg-red white">立即兑换</view> | 26 | + <block wx:if="{{currentTabIndex == 0}}"> |
| 27 | + <view class="btn bg-gray white" wx:if="{{filters.isExpired(item.EndDate)}}">已过期</view> | ||
| 28 | + <view class="btn bg-red white" wx:else>立即兑换</view> | ||
| 29 | + </block> | ||
| 30 | + | ||
| 31 | + <block wx:if="{{currentTabIndex == 1}}"> | ||
| 32 | + <view class="btn bg-gray white">已核销</view> | ||
| 33 | + </block> | ||
| 28 | </view> | 34 | </view> |
| 35 | + | ||
| 29 | </view> | 36 | </view> |
| 37 | + </block> | ||
| 30 | 38 | ||
| 31 | 39 | ||
| 32 | - <view class="list-item" wx:if="{{currentTabIndex == 1}}"> | 40 | + <!-- <view class="list-item" wx:if="{{currentTabIndex == 1}}"> |
| 33 | <view class="pd20"> | 41 | <view class="pd20"> |
| 34 | <view class=""><text class="fs24 c-9">订单编号:</text>191561561565555</view> | 42 | <view class=""><text class="fs24 c-9">订单编号:</text>191561561565555</view> |
| 35 | <view class="ellipsis-2 title">卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称</view> | 43 | <view class="ellipsis-2 title">卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称项名称卡项名称卡项名称</view> |
| @@ -43,7 +51,7 @@ | @@ -43,7 +51,7 @@ | ||
| 43 | <view class="pd20 bdt fs24 t-r"> | 51 | <view class="pd20 bdt fs24 t-r"> |
| 44 | <view class="btn bg-gray white">已核销</view> | 52 | <view class="btn bg-gray white">已核销</view> |
| 45 | </view> | 53 | </view> |
| 46 | - </view> | 54 | + </view> --> |
| 47 | 55 | ||
| 48 | </view> | 56 | </view> |
| 49 | </view> | 57 | </view> |
packageB/pages/boxes-list/boxes-list.wxss
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml
| @@ -89,6 +89,7 @@ | @@ -89,6 +89,7 @@ | ||
| 89 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 89 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 90 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 90 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 91 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 91 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 92 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 92 | </view> | 93 | </view> |
| 93 | 94 | ||
| 94 | 95 |
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml
| @@ -134,6 +134,7 @@ | @@ -134,6 +134,7 @@ | ||
| 134 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 134 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 135 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 135 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 136 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 136 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 137 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 137 | </view> | 138 | </view> |
| 138 | 139 | ||
| 139 | 140 |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
| @@ -2480,7 +2480,7 @@ Page({ | @@ -2480,7 +2480,7 @@ Page({ | ||
| 2480 | isonsale: 1, | 2480 | isonsale: 1, |
| 2481 | is_on_sale: 1, | 2481 | is_on_sale: 1, |
| 2482 | pageSize: 500, | 2482 | pageSize: 500, |
| 2483 | - orderField: 'sort' | 2483 | + orderField: 'gg_ordid,goods_spec,sort' |
| 2484 | } | 2484 | } |
| 2485 | }).then(res => { | 2485 | }).then(res => { |
| 2486 | var e = res; | 2486 | var e = res; |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml
| @@ -1155,6 +1155,7 @@ | @@ -1155,6 +1155,7 @@ | ||
| 1155 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 1155 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 1156 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 1156 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 1157 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 1157 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 1158 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 1158 | </view> | 1159 | </view> |
| 1159 | </view> | 1160 | </view> |
| 1160 | <view class="spec-cart-btns"> | 1161 | <view class="spec-cart-btns"> |
packageC/pages/presell/cart/cart2.js
| @@ -1069,7 +1069,7 @@ Page({ | @@ -1069,7 +1069,7 @@ Page({ | ||
| 1069 | if (gg.is_pd_normal) goods.is_pd_normal = 1; | 1069 | if (gg.is_pd_normal) goods.is_pd_normal = 1; |
| 1070 | 1070 | ||
| 1071 | //如果不立即购买或者秒杀,如果是线下库存购买的时候 | 1071 | //如果不立即购买或者秒杀,如果是线下库存购买的时候 |
| 1072 | - if (goods.prom_type != 1 && goods.prom_type != 6 && th.data.sales_rules == 2) { | 1072 | + if (goods.prom_type != 1 && goods.prom_type != 6 && goods.prom_type != 8 && th.data.sales_rules == 2) { |
| 1073 | var isok = 1; | 1073 | var isok = 1; |
| 1074 | await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) { | 1074 | await th.check_store_num(goods.goods_id, th.data.bn_pick, gg.goods_num, function (res) { |
| 1075 | isok = res; | 1075 | isok = res; |
| @@ -1327,6 +1327,10 @@ Page({ | @@ -1327,6 +1327,10 @@ Page({ | ||
| 1327 | goods.prom_type = 7; | 1327 | goods.prom_type = 7; |
| 1328 | goods.prom_id = g_item.prom_id; | 1328 | goods.prom_id = g_item.prom_id; |
| 1329 | break | 1329 | break |
| 1330 | + case 8: | ||
| 1331 | + goods.prom_type = 8; | ||
| 1332 | + goods.prom_id = g_item.prom_id; | ||
| 1333 | + break | ||
| 1330 | default: | 1334 | default: |
| 1331 | goods.prom_type = 0; | 1335 | goods.prom_type = 0; |
| 1332 | goods.prom_id = 0; | 1336 | goods.prom_id = 0; |
packageC/pages/presell/goodsInfo/goodsInfo.js
| @@ -137,7 +137,7 @@ Page({ | @@ -137,7 +137,7 @@ Page({ | ||
| 137 | nation_name: '', | 137 | nation_name: '', |
| 138 | 138 | ||
| 139 | //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 8预售 | 139 | //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 8预售 |
| 140 | - prom_type: 0, | 140 | + prom_type: 8, |
| 141 | prom_time_text: "", | 141 | prom_time_text: "", |
| 142 | prom_price: null, | 142 | prom_price: null, |
| 143 | prom_buy_limit: 0, | 143 | prom_buy_limit: 0, |
| @@ -1601,7 +1601,7 @@ Page({ | @@ -1601,7 +1601,7 @@ Page({ | ||
| 1601 | isonsale: 1, | 1601 | isonsale: 1, |
| 1602 | is_on_sale: 1, | 1602 | is_on_sale: 1, |
| 1603 | pageSize: 500, | 1603 | pageSize: 500, |
| 1604 | - orderField: 'sort', | 1604 | + orderField: 'gg_ordid,goods_spec,sort', |
| 1605 | prom_type: 8, | 1605 | prom_type: 8, |
| 1606 | }; | 1606 | }; |
| 1607 | 1607 | ||
| @@ -1852,8 +1852,8 @@ Page({ | @@ -1852,8 +1852,8 @@ Page({ | ||
| 1852 | 1852 | ||
| 1853 | th.setData({ all_pick_list: e.data.data.pageData }); | 1853 | th.setData({ all_pick_list: e.data.data.pageData }); |
| 1854 | 1854 | ||
| 1855 | - //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- | ||
| 1856 | - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { | 1855 | + //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售-- |
| 1856 | + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type !=8 ) || is_normal == 1)) { | ||
| 1857 | setTimeout(function () { | 1857 | setTimeout(function () { |
| 1858 | th.deal_pickup_dline(e); | 1858 | th.deal_pickup_dline(e); |
| 1859 | }, 800) | 1859 | }, 800) |
| @@ -3355,7 +3355,7 @@ Page({ | @@ -3355,7 +3355,7 @@ Page({ | ||
| 3355 | var lock = 0; | 3355 | var lock = 0; |
| 3356 | 3356 | ||
| 3357 | //---如果是活动的时候,同时不是普通购买--- | 3357 | //---如果是活动的时候,同时不是普通购买--- |
| 3358 | - if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { | 3358 | + if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4 || th.data.prom_type == 8) && !th.data.is_normal) { |
| 3359 | func(); return false; | 3359 | func(); return false; |
| 3360 | } | 3360 | } |
| 3361 | 3361 | ||
| @@ -3815,7 +3815,7 @@ Page({ | @@ -3815,7 +3815,7 @@ Page({ | ||
| 3815 | this.data.show_prew_img = 1; | 3815 | this.data.show_prew_img = 1; |
| 3816 | wx.previewImage({ | 3816 | wx.previewImage({ |
| 3817 | //将图片预览出来 | 3817 | //将图片预览出来 |
| 3818 | - urls: [this.data.sele_g.original_img] | 3818 | + urls: [this.data.shareImgPath] |
| 3819 | }); | 3819 | }); |
| 3820 | }, | 3820 | }, |
| 3821 | 3821 | ||
| @@ -3934,6 +3934,18 @@ Page({ | @@ -3934,6 +3934,18 @@ Page({ | ||
| 3934 | 3934 | ||
| 3935 | var err_txt="活动定金时间已经结束"; | 3935 | var err_txt="活动定金时间已经结束"; |
| 3936 | var end_time = act_data.end_time; | 3936 | var end_time = act_data.end_time; |
| 3937 | + if (act_data.presell_type == 1) { | ||
| 3938 | + err_txt="活动时间已经结束"; | ||
| 3939 | + } | ||
| 3940 | + if (end_time < ut.gettimestamp()) { | ||
| 3941 | + wx.showToast({title:err_txt, icon: 'none', duration: 3000}); | ||
| 3942 | + setTimeout(function () { | ||
| 3943 | + ut.wx_back(); | ||
| 3944 | + }, 2000) | ||
| 3945 | + gnext=0; | ||
| 3946 | + return false; | ||
| 3947 | + } | ||
| 3948 | + | ||
| 3937 | if (act_data.presell_type == 0) { | 3949 | if (act_data.presell_type == 0) { |
| 3938 | end_time = act_data.pay_enddate; | 3950 | end_time = act_data.pay_enddate; |
| 3939 | err_txt="活动尾款时间已经结束"; | 3951 | err_txt="活动尾款时间已经结束"; |
packageC/pages/presell/pregoodsInfo/goodsInfo.js
| @@ -1599,7 +1599,7 @@ Page({ | @@ -1599,7 +1599,7 @@ Page({ | ||
| 1599 | isonsale: 1, | 1599 | isonsale: 1, |
| 1600 | is_on_sale: 1, | 1600 | is_on_sale: 1, |
| 1601 | pageSize: 500, | 1601 | pageSize: 500, |
| 1602 | - orderField: 'sort', | 1602 | + orderField: 'gg_ordid,goods_spec,sort', |
| 1603 | prom_type: 8, | 1603 | prom_type: 8, |
| 1604 | }; | 1604 | }; |
| 1605 | 1605 |
pages/activity/seckill_list/seckill_list.js
| @@ -104,6 +104,7 @@ Page({ | @@ -104,6 +104,7 @@ Page({ | ||
| 104 | // 对结束时间进行处理渲染到页面 | 104 | // 对结束时间进行处理渲染到页面 |
| 105 | for (var i = 0; i < endTimeList.length; i++) { | 105 | for (var i = 0; i < endTimeList.length; i++) { |
| 106 | var o = endTimeList[i]; | 106 | var o = endTimeList[i]; |
| 107 | + if(!o) continue; | ||
| 107 | var endTime = o.end_time; | 108 | var endTime = o.end_time; |
| 108 | if (th.data.type == 0) endTime = o.start_time; | 109 | if (th.data.type == 0) endTime = o.start_time; |
| 109 | let obj = null; | 110 | let obj = null; |
pages/cart/cart/cart.wxml
| @@ -150,6 +150,7 @@ | @@ -150,6 +150,7 @@ | ||
| 150 | <text wx:if="{{item.content.is_int==1}}">送积分|</text> | 150 | <text wx:if="{{item.content.is_int==1}}">送积分|</text> |
| 151 | <text wx:if="{{item.content.is_gift==1}}">送赠品|</text> | 151 | <text wx:if="{{item.content.is_gift==1}}">送赠品|</text> |
| 152 | <text wx:if="{{item.content.is_libao==1}}">送礼包|</text> | 152 | <text wx:if="{{item.content.is_libao==1}}">送礼包|</text> |
| 153 | + <text wx:if="{{item.content.is_zxlibao==1}}">送专享礼包|</text> | ||
| 153 | <text></text> | 154 | <text></text> |
| 154 | </view> | 155 | </view> |
| 155 | <view class="co-red" data-prom_id="{{item.prom_id}}" bindtap="go_cou_dang">去凑单></view> | 156 | <view class="co-red" data-prom_id="{{item.prom_id}}" bindtap="go_cou_dang">去凑单></view> |
pages/cart/cart2/cart2.js
| @@ -948,6 +948,7 @@ Page({ | @@ -948,6 +948,7 @@ Page({ | ||
| 948 | ob.prom_id = data.prom_id; | 948 | ob.prom_id = data.prom_id; |
| 949 | ob.goods_id = data.gift_goods_id; | 949 | ob.goods_id = data.gift_goods_id; |
| 950 | ob.goods_name = data.gift_goods_name; | 950 | ob.goods_name = data.gift_goods_name; |
| 951 | + ob.goods_sn = data.gift_goods_sn; | ||
| 951 | ob.goods_color = data.gift_goods_color; | 952 | ob.goods_color = data.gift_goods_color; |
| 952 | ob.goods_spec = data.gift_goods_spec; | 953 | ob.goods_spec = data.gift_goods_spec; |
| 953 | ob.original_img = os.imghost + data.gift_original_img; | 954 | ob.original_img = os.imghost + data.gift_original_img; |
| @@ -1240,6 +1241,10 @@ Page({ | @@ -1240,6 +1241,10 @@ Page({ | ||
| 1240 | } | 1241 | } |
| 1241 | item_map.s_libao = get_data.libao; | 1242 | item_map.s_libao = get_data.libao; |
| 1242 | item_map.s_lb_num = get_data.lb_num; | 1243 | item_map.s_lb_num = get_data.lb_num; |
| 1244 | + | ||
| 1245 | + //专享礼包 | ||
| 1246 | + item_map.zx_libao = get_data.zxlibao; | ||
| 1247 | + item_map.zx_lb_num = get_data.zxlb_num; | ||
| 1243 | } | 1248 | } |
| 1244 | }) | 1249 | }) |
| 1245 | } | 1250 | } |
| @@ -1334,7 +1339,7 @@ Page({ | @@ -1334,7 +1339,7 @@ Page({ | ||
| 1334 | } | 1339 | } |
| 1335 | } | 1340 | } |
| 1336 | 1341 | ||
| 1337 | - //-- 如果有送优包邮券的情况 -- | 1342 | + //-- 如果有送礼包的情况 -- |
| 1338 | if (item_map.s_libao) { | 1343 | if (item_map.s_libao) { |
| 1339 | if (!cart_item.s_libao) { | 1344 | if (!cart_item.s_libao) { |
| 1340 | cart_item.s_libao = item_map.s_libao + ""; | 1345 | cart_item.s_libao = item_map.s_libao + ""; |
| @@ -1345,6 +1350,17 @@ Page({ | @@ -1345,6 +1350,17 @@ Page({ | ||
| 1345 | cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }) | 1350 | cart_item.g_lb_num.push({ 'l_id': item_map.s_libao, "num": item_map.s_lb_num }) |
| 1346 | } | 1351 | } |
| 1347 | } | 1352 | } |
| 1353 | + | ||
| 1354 | + if (item_map.zx_libao) { | ||
| 1355 | + if (!cart_item.zx_libao) { | ||
| 1356 | + cart_item.zx_libao = item_map.zx_libao + ""; | ||
| 1357 | + cart_item.g_zxlb_num = [{'l_id': item_map.zx_libao, "num": item_map.zx_lb_num}]; | ||
| 1358 | + } | ||
| 1359 | + else { | ||
| 1360 | + cart_item.zx_libao += "," + item_map.zx_libao; | ||
| 1361 | + cart_item.g_zxlb_num.push({'l_id': item_map.zx_libao, "num": item_map.zx_lb_num}) | ||
| 1362 | + } | ||
| 1363 | + } | ||
| 1348 | } | 1364 | } |
| 1349 | } | 1365 | } |
| 1350 | } | 1366 | } |
| @@ -1689,6 +1705,7 @@ Page({ | @@ -1689,6 +1705,7 @@ Page({ | ||
| 1689 | } | 1705 | } |
| 1690 | } | 1706 | } |
| 1691 | }else{ | 1707 | }else{ |
| 1708 | + | ||
| 1692 | if(item[j]['exp_sum_type']==2 && out_of_weight!==0){ | 1709 | if(item[j]['exp_sum_type']==2 && out_of_weight!==0){ |
| 1693 | goods_weight = -1; | 1710 | goods_weight = -1; |
| 1694 | out_of_weight = 0; | 1711 | out_of_weight = 0; |
| @@ -2176,6 +2193,16 @@ Page({ | @@ -2176,6 +2193,16 @@ Page({ | ||
| 2176 | ob = JSON.stringify(ob); | 2193 | ob = JSON.stringify(ob); |
| 2177 | th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); | 2194 | th.setData({ [l_txt]: good.s_libao, [l_txt1]: ob }); |
| 2178 | } | 2195 | } |
| 2196 | + | ||
| 2197 | + //专享礼包 | ||
| 2198 | + if (good.zx_libao) { | ||
| 2199 | + var l_txt = "formData.give_zxlb_id"; | ||
| 2200 | + //这个是json格式的 | ||
| 2201 | + var l_txt1 = "formData.g_zxlb_num"; | ||
| 2202 | + var ob = [{"num": good.zx_lb_num, "l_id": good.zx_libao}]; | ||
| 2203 | + ob = JSON.stringify(ob); | ||
| 2204 | + th.setData({[l_txt]: good.zx_libao, [l_txt1]: ob}); | ||
| 2205 | + } | ||
| 2179 | }) | 2206 | }) |
| 2180 | } else { | 2207 | } else { |
| 2181 | 2208 | ||
| @@ -2231,7 +2258,18 @@ Page({ | @@ -2231,7 +2258,18 @@ Page({ | ||
| 2231 | var l_txt1 = "formData.g_lb_num"; | 2258 | var l_txt1 = "formData.g_lb_num"; |
| 2232 | var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; | 2259 | var ob = [{ "num": good.s_lb_num, "l_id": good.s_libao }]; |
| 2233 | ob = JSON.stringify(ob); | 2260 | ob = JSON.stringify(ob); |
| 2234 | - th.setData({ [l_txt]: good.s_coupon_id, [l_txt1]: ob }); | 2261 | + th.setData({[l_txt]: good.s_libao, [l_txt1]: ob}); |
| 2262 | + } | ||
| 2263 | + | ||
| 2264 | + //专享礼包 | ||
| 2265 | + if (good.zx_libao) { | ||
| 2266 | + var l_txt = "formData.give_zxlb_id"; | ||
| 2267 | + //这个是json格式的 | ||
| 2268 | + var l_txt1 = "formData.g_zxlb_num"; | ||
| 2269 | + var ob = [{"num": good.zx_lb_num, "l_id": good.zx_libao}]; | ||
| 2270 | + ob = JSON.stringify(ob); | ||
| 2271 | + th.setData({[l_txt]: good.zx_libao, [l_txt1]: ob}); | ||
| 2272 | + | ||
| 2235 | } | 2273 | } |
| 2236 | } | 2274 | } |
| 2237 | 2275 | ||
| @@ -2349,6 +2387,12 @@ Page({ | @@ -2349,6 +2387,12 @@ Page({ | ||
| 2349 | order_prom_list.give_lb_id = th.data.formData.give_lb_id; | 2387 | order_prom_list.give_lb_id = th.data.formData.give_lb_id; |
| 2350 | order_prom_list.g_lb_num = th.data.formData.g_lb_num; | 2388 | order_prom_list.g_lb_num = th.data.formData.g_lb_num; |
| 2351 | } | 2389 | } |
| 2390 | + //--- 专享礼包 --- | ||
| 2391 | + if (th.data.formData.give_zxlb_id > 0) { | ||
| 2392 | + order_prom_list.give_zxlb_id = th.data.formData.give_zxlb_id; | ||
| 2393 | + order_prom_list.g_zxlb_num = th.data.formData.g_zxlb_num; | ||
| 2394 | + } | ||
| 2395 | + | ||
| 2352 | item.order_prom_list = order_prom_list; | 2396 | item.order_prom_list = order_prom_list; |
| 2353 | 2397 | ||
| 2354 | //组装优惠券的钱 | 2398 | //组装优惠券的钱 |
| @@ -2607,11 +2651,19 @@ Page({ | @@ -2607,11 +2651,19 @@ Page({ | ||
| 2607 | order_prom_list.give_lb_id = t_item.s_libao; | 2651 | order_prom_list.give_lb_id = t_item.s_libao; |
| 2608 | order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); | 2652 | order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); |
| 2609 | } | 2653 | } |
| 2610 | - if (Object.keys(order_prom_list).length > 0) { | ||
| 2611 | - if (order_prom_list.discount_amount) | ||
| 2612 | - order_prom_list.discount_amount = parseFloat(order_prom_list.discount_amount).toFixed(2); | ||
| 2613 | - if (order_prom_list.order_prom_amount) | ||
| 2614 | - order_prom_list.order_prom_amount = parseFloat(order_prom_list.order_prom_amount).toFixed(2); | 2654 | + |
| 2655 | + //-- 送专享礼包的时候 -- | ||
| 2656 | + if (t_item.zx_libao) { | ||
| 2657 | + order_prom_list.give_zxlb_id = t_item.zx_libao; | ||
| 2658 | + order_prom_list.g_zxlb_num = JSON.stringify(t_item.g_zxlb_num); | ||
| 2659 | + } | ||
| 2660 | + | ||
| 2661 | + if (Object.keys(order_prom_list).length > 0){ | ||
| 2662 | + if(order_prom_list.discount_amount) | ||
| 2663 | + order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); | ||
| 2664 | + if(order_prom_list.order_prom_amount) | ||
| 2665 | + order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); | ||
| 2666 | + | ||
| 2615 | item.order_prom_list = order_prom_list; | 2667 | item.order_prom_list = order_prom_list; |
| 2616 | } | 2668 | } |
| 2617 | 2669 | ||
| @@ -3705,7 +3757,6 @@ Page({ | @@ -3705,7 +3757,6 @@ Page({ | ||
| 3705 | if (gd.ld_account) { | 3757 | if (gd.ld_account) { |
| 3706 | item_price2 = gd.ld_account * gd.goods_num; | 3758 | item_price2 = gd.ld_account * gd.goods_num; |
| 3707 | } | 3759 | } |
| 3708 | - | ||
| 3709 | ckeck_quan_price += item_price; | 3760 | ckeck_quan_price += item_price; |
| 3710 | //如果商品有重复的过滤,一般是组合购和阶梯购的情况下 | 3761 | //如果商品有重复的过滤,一般是组合购和阶梯购的情况下 |
| 3711 | var idx = check_quan_ware_list_arr.findIndex(function (ele) { | 3762 | var idx = check_quan_ware_list_arr.findIndex(function (ele) { |
| @@ -3910,6 +3961,7 @@ Page({ | @@ -3910,6 +3961,7 @@ Page({ | ||
| 3910 | arr.gift_id = get_data.gift_id; | 3961 | arr.gift_id = get_data.gift_id; |
| 3911 | arr.gift_goods_id = get_data.goods_id; | 3962 | arr.gift_goods_id = get_data.goods_id; |
| 3912 | arr.gift_goods_name = get_data.goods_name; | 3963 | arr.gift_goods_name = get_data.goods_name; |
| 3964 | + arr.gift_goods_sn = get_data.goodsinfo.goods_sn; | ||
| 3913 | arr.gift_goods_color = get_data.goodsinfo.goods_color; | 3965 | arr.gift_goods_color = get_data.goodsinfo.goods_color; |
| 3914 | arr.gift_goods_spec = get_data.goodsinfo.goods_spec; | 3966 | arr.gift_goods_spec = get_data.goodsinfo.goods_spec; |
| 3915 | arr.gift_original_img = get_data.goodsinfo.original_img; | 3967 | arr.gift_original_img = get_data.goodsinfo.original_img; |
| @@ -3921,6 +3973,10 @@ Page({ | @@ -3921,6 +3973,10 @@ Page({ | ||
| 3921 | } | 3973 | } |
| 3922 | arr.s_libao = get_data.libao; | 3974 | arr.s_libao = get_data.libao; |
| 3923 | arr.s_lb_num = get_data.lb_num; | 3975 | arr.s_lb_num = get_data.lb_num; |
| 3976 | + | ||
| 3977 | + arr.zx_libao = get_data.zxlibao; | ||
| 3978 | + arr.zx_lb_num = get_data.zxlb_num; | ||
| 3979 | + | ||
| 3924 | arr.prom_id = prom_id; | 3980 | arr.prom_id = prom_id; |
| 3925 | } | 3981 | } |
| 3926 | func(arr); | 3982 | func(arr); |
pages/goods/goodsInfo/buy_flash_normal.wxml
0 → 100644
| 1 | +<view bindtap="closeSpecModal_flash_normal" class="cover-layer"></view> | ||
| 2 | + <view class="spec-model"> | ||
| 3 | + <view class="pding"> | ||
| 4 | + <icon bindtap="closeSpecModal_flash_normal" class="modal-close" color="black" size="22" type="cancel"></icon> | ||
| 5 | + <view class="spec-goods"> | ||
| 6 | + <image class="wh100 spec-img xc-distance-bottom" src="{{sele_g.original_img}}" binderror="pop_err_img" data-errorimg="data.original_img"></image> | ||
| 7 | + <view class="spec-goods-info"> | ||
| 8 | + <view class="spec-goods-name ellipsis-2">{{sele_g.goods_name}}</view> | ||
| 9 | + <view class="flex ai_end xc-val-money"> | ||
| 10 | + <text class="fs20">¥</text> | ||
| 11 | + <!-- 如果是等级会员,且有等级价 --> | ||
| 12 | + <block wx:if="{{card_field && sele_g[card_field]>0}}">{{sele_g[card_field]}} </block> | ||
| 13 | + <block wx:else>{{sele_g.shop_price}}</block> | ||
| 14 | + </view> | ||
| 15 | + | ||
| 16 | + <view class="flex"> | ||
| 17 | + <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view> | ||
| 18 | + <block wx:if="{{sales_rules==2}}"> | ||
| 19 | + <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view> | ||
| 20 | + <view class="spec-goods-stock" wx:else>可售:0</view> | ||
| 21 | + </block> | ||
| 22 | + <block wx:else><view class="spec-goods-stock">可售:{{sele_g.store_count}}</view></block> | ||
| 23 | + </view> | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + </view> | ||
| 27 | + | ||
| 28 | + <!-- 选择门店模块 --> | ||
| 29 | + <view class="flex-space-between address ai_end xc-width "> | ||
| 30 | + | ||
| 31 | + <view class="flex ai_end" wx:if="{{def_pick_store && def_pick_store.pickup_name}}"> | ||
| 32 | + <text class="fs30 xc-black3 shop_name">{{def_pick_store.pickup_name}}</text> | ||
| 33 | + <view class="distance fs24 xc-ash"wx:if="{{def_pick_store.distance!=null}}"> | ||
| 34 | + 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}} | ||
| 35 | + | ||
| 36 | + </view> | ||
| 37 | + </view> | ||
| 38 | + | ||
| 39 | + <!-- 没有门店的时候 --> | ||
| 40 | + <view class="flex" bindtap="choice_store" wx:else> | ||
| 41 | + <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image> | ||
| 42 | + <view class="fs30" style="color:black;">选择门店</view> | ||
| 43 | + </view> | ||
| 44 | + | ||
| 45 | + <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view> | ||
| 46 | + </view> | ||
| 47 | + <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view> | ||
| 48 | + <block wx:else> | ||
| 49 | + <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view> | ||
| 50 | + <block wx:else> | ||
| 51 | + <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view> | ||
| 52 | + <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}">(库存不足)</view> | ||
| 53 | + </block> | ||
| 54 | + </block> | ||
| 55 | + <view class="fs24 xc-ash-9f xc-distance-top "wx:if="{{def_pick_store && def_pick_store.fulladdress}}">地址:{{def_pick_store.fulladdress}}</view> | ||
| 56 | + | ||
| 57 | + | ||
| 58 | + <!--商品的属性项目--> | ||
| 59 | + <view class="xc-goods-attribute"> | ||
| 60 | + <view hidden="{{ismend==1}}" class="spec-name">商品规格</view> | ||
| 61 | + <view hidden="{{ismend==1}}" style="max-height: 120rpx;overflow-y: auto;"> | ||
| 62 | + <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-nor="1" data-gid='{{item.goods_id}}' wx:for="{{sku_g_pt}}" wx:key="sku_g"> | ||
| 63 | + {{item.gg}} | ||
| 64 | + </view> | ||
| 65 | + </view> | ||
| 66 | + </view> | ||
| 67 | + | ||
| 68 | + <view class="b_num"> | ||
| 69 | + <view>购买数量</view> | ||
| 70 | + <view class="count"> | ||
| 71 | + <view bindtap="{{goodsInputNum <= 1 ? '':'subCartNum'}}" class="sub {{goodsInputNum <= 1 ? 'active':''}}">-</view> | ||
| 72 | + <input bindblur="inputCartNum" type="number" value="{{goodsInputNum}}"></input> | ||
| 73 | + <view bindtap="addCartNum" class="add">+</view> | ||
| 74 | + </view> | ||
| 75 | + </view> | ||
| 76 | + </view> | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + <!-- 提示再买多少优惠 --> | ||
| 80 | + <view style="margin-top: 35rpx;color:#333;font-size:28rpx;" wx:if="{{hui_condition}}"> | ||
| 81 | + 再买{{hui_condition.need}} | ||
| 82 | + <text wx:if="{{hui_condition.money}}">,免{{hui_condition.money}}元</text> | ||
| 83 | + <text wx:if="{{hui_condition.sale}}">,打{{hui_condition.sale}}折</text> | ||
| 84 | + <text wx:if="{{hui_condition.past==1}}">,包邮</text> | ||
| 85 | + <text wx:if="{{hui_condition.intValue>0}}">,送{{hui_condition.intValue}}积分</text> | ||
| 86 | + <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | ||
| 87 | + <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | ||
| 88 | + <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | ||
| 89 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 90 | + </view> | ||
| 91 | + | ||
| 92 | + | ||
| 93 | + <!-- 按钮部分 --> | ||
| 94 | + <view class="spec-cart-btns"> | ||
| 95 | + | ||
| 96 | + <!-- 根本就找不到门店 --> | ||
| 97 | + <block wx:if="{{def_pick_store && def_pick_store.is_no_dis}}"> | ||
| 98 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">配送不匹配</view> | ||
| 99 | + </block> | ||
| 100 | + <block wx:else> | ||
| 101 | + <!-- 根本就找不到门店 --> | ||
| 102 | + <block wx:if="{{!only_pk && !def_pickpu_list}}"> | ||
| 103 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">库存不足</view> | ||
| 104 | + </block> | ||
| 105 | + <block wx:else> | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + <block wx:if="{{only_pk.length && !only_pk.length}}"> | ||
| 109 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">库存不足</view> | ||
| 110 | + </block> | ||
| 111 | + <block wx:else> | ||
| 112 | + <block wx:if="{{def_pickpu_list && !def_pickpu_list.length}}"> | ||
| 113 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">库存不足</view> | ||
| 114 | + </block> | ||
| 115 | + <block wx:else> | ||
| 116 | + <block wx:if="{{!def_pick_store}}"> | ||
| 117 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">请先选择门店</view> | ||
| 118 | + </block> | ||
| 119 | + <block wx:else> | ||
| 120 | + <block wx:if="{{data.store_count<=0}}"> | ||
| 121 | + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">库存不足</view> | ||
| 122 | + </block> | ||
| 123 | + <block wx:else> | ||
| 124 | + <view class="flex jc_sb"> | ||
| 125 | + <view class="spec-cart-btn spec-buy w40" bindtap="addCart" | ||
| 126 | + data-action="add" style="background-color: #ffb03f;">加入购物车</view> | ||
| 127 | + <view class="spec-cart-btn spec-buy w40" bindtap="addCart" | ||
| 128 | + data-action="buy">立即购买</view> | ||
| 129 | + </view> | ||
| 130 | + </block> | ||
| 131 | + | ||
| 132 | + </block> | ||
| 133 | + </block> | ||
| 134 | + </block> | ||
| 135 | + </block> | ||
| 136 | + </block> | ||
| 137 | + </view> | ||
| 138 | + | ||
| 139 | + </view> | ||
| 140 | + </view> | ||
| 141 | + <view class="clear"></view> | ||
| 0 | \ No newline at end of file | 142 | \ No newline at end of file |
pages/goods/goodsInfo/buy_integral_normal.wxml
| @@ -86,6 +86,7 @@ | @@ -86,6 +86,7 @@ | ||
| 86 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 86 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 87 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 87 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 88 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 88 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 89 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 89 | </view> | 90 | </view> |
| 90 | 91 | ||
| 91 | 92 |
pages/goods/goodsInfo/buy_pt.wxml
| @@ -121,6 +121,7 @@ | @@ -121,6 +121,7 @@ | ||
| 121 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 121 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 122 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 122 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 123 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 123 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 124 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 124 | </view> | 125 | </view> |
| 125 | 126 | ||
| 126 | 127 |
pages/goods/goodsInfo/goodsInfo.js
| @@ -20,1892 +20,1975 @@ var regeneratorRuntime = require('../../../utils/runtime.js'); | @@ -20,1892 +20,1975 @@ var regeneratorRuntime = require('../../../utils/runtime.js'); | ||
| 20 | const { app } = require("../../../utils/common.js"); | 20 | const { app } = require("../../../utils/common.js"); |
| 21 | 21 | ||
| 22 | Page({ | 22 | Page({ |
| 23 | - data: { | ||
| 24 | - start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | ||
| 25 | - color_type: 0, //线条控制 | ||
| 26 | - color_type_one: 0, | ||
| 27 | - color_type_two: 1, | ||
| 28 | - | ||
| 29 | - gid: "", | ||
| 30 | - stoid: o.stoid, | ||
| 31 | - url: o.url, | ||
| 32 | - resourceUrl: o.h5_url, //公众号那边的图片文件域名 | ||
| 33 | - iurl: o.imghost, | ||
| 34 | - defaultAvatar: o.resourceUrl + "/static/images/user68.jpg", | ||
| 35 | - | ||
| 36 | - viplimited_timetype: 0, | ||
| 37 | - | ||
| 38 | - data: null, | ||
| 39 | - content: "", //商品详情 | ||
| 40 | - comments: null, //商品评论 | ||
| 41 | - c_curr_p: 1, //评论分页 | ||
| 42 | - com_num: 0, //评论人数 | ||
| 43 | - gallery: null, //图片滚动 | ||
| 44 | - is_collect: 0, | ||
| 45 | - collect_id: 0, | ||
| 46 | - cartGoodsNum: 0, | ||
| 47 | - specSelect: 0, | ||
| 48 | - optionItemId: 0, | ||
| 49 | - goodsInputNum: 1, | ||
| 50 | - openSpecModal: !1, | ||
| 51 | - openSpecModal_pt: !1, //拼单的弹起, | ||
| 52 | - openPromModal: !1, | ||
| 53 | - activeCategoryId: 0, | ||
| 54 | - supportPageScroll: !1, | ||
| 55 | - address: { | ||
| 56 | - address: "", | ||
| 57 | - district: 0 | ||
| 58 | - }, | ||
| 59 | - shipping: "", | ||
| 60 | - shippingCost: 0, | ||
| 61 | - enterAddressPage: !1, | ||
| 62 | - categories: [{ | ||
| 63 | - name: "商品", | ||
| 64 | - id: 0 | ||
| 65 | - }, { | ||
| 66 | - name: "详情", | ||
| 67 | - id: 1 | ||
| 68 | - }, { | ||
| 69 | - name: "评价", | ||
| 70 | - id: 2 | ||
| 71 | - }], | ||
| 72 | - activeCategoryId2: 0, | ||
| 73 | - categories2: [{ | ||
| 74 | - name: "商品详情", | ||
| 75 | - id: 0 | ||
| 76 | - }, { | ||
| 77 | - name: "规格参数", | ||
| 78 | - id: 1 | ||
| 79 | - }], | ||
| 80 | - activeCategoryId3: 1, | ||
| 81 | - categories3: [{ | ||
| 82 | - name: "全部", | ||
| 83 | - id: 1, | ||
| 84 | - num: 0 | ||
| 85 | - }, | ||
| 86 | - { | ||
| 87 | - name: "有图", | ||
| 88 | - id: 5, | ||
| 89 | - num: 0 | ||
| 90 | - }, | ||
| 91 | - | ||
| 92 | - { | ||
| 93 | - name: "好评", | ||
| 94 | - id: 2, | ||
| 95 | - num: 0 | ||
| 96 | - }, { | ||
| 97 | - name: "中评", | ||
| 98 | - id: 3, | ||
| 99 | - num: 0 | ||
| 100 | - }, { | ||
| 101 | - name: "差评", | ||
| 102 | - id: 4, | ||
| 103 | - num: 0 | ||
| 104 | - }, | ||
| 105 | - ], | ||
| 106 | - | ||
| 107 | - select: { | ||
| 108 | - price: 0, | ||
| 109 | - stock: 0, | ||
| 110 | - specName: "", | ||
| 111 | - activity: null | ||
| 112 | - }, | ||
| 113 | - | ||
| 114 | - //已选的商品(属性) | ||
| 115 | - sele_g_spec_name: '', | ||
| 116 | - sele_g_id: '', | ||
| 117 | - sele_g: null, | ||
| 118 | - //门店相关 | ||
| 119 | - ismend: 0, | ||
| 120 | - is_sec_mend: 0, | ||
| 121 | - sto_sele_name: "", //选中的门店名称 | ||
| 122 | - sto_sele_id: "", //选中的门店id | ||
| 123 | - sto_sele_distr: "", //选择的门店的配送方式 | ||
| 124 | - is_show_sto_cat: 1, //是否显示门店分类 | ||
| 125 | - only_pk: null, | ||
| 126 | - all_sto: null, | ||
| 127 | - sec_sto: null, //选择了的门店分类 | ||
| 128 | - pickpu_list: null, //读出的所有门店list | ||
| 129 | - def_pickpu_list: null, //一开始5个门店list | ||
| 130 | - sec_pick_index: 0, //第二级门店选择ID | ||
| 131 | - fir_pick_index: 0, //第一级门店选择ID | ||
| 132 | - all_pick_list: null,//所有的门店先记录起来 | ||
| 133 | - //同一条形码的所有商品 | ||
| 134 | - sku_g: null, | ||
| 135 | - sku_g_pt: null, //---拼单的普通购买--- | ||
| 136 | - //联系电话 | ||
| 137 | - mobile: '', | ||
| 138 | - //分类,品牌,国别名称 | ||
| 139 | - cat_name: '', | ||
| 140 | - brand_name: '', | ||
| 141 | - nation_name: '', | ||
| 142 | - | ||
| 143 | - //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | ||
| 144 | - prom_type: 0, | ||
| 145 | - prom_time_text: "", | ||
| 146 | - prom_price: null, | ||
| 147 | - prom_buy_limit: 0, | ||
| 148 | - djs: null, | ||
| 149 | - prom_st: 0, | ||
| 150 | - prom_r_null: 0, | ||
| 151 | - prom_end_time: null, | ||
| 152 | - prom_start_time: null, | ||
| 153 | - prom_act: null, | ||
| 154 | - pd_xx: 0, | ||
| 155 | - is_normal: 0, //是否普通购买 | ||
| 156 | - teamgroup: null, //有多少人开团 | ||
| 157 | - grounp_tatal: 0, //有几个人开团 | ||
| 158 | - timer: [], | ||
| 159 | - | ||
| 160 | - //商品的购买次数 | ||
| 161 | - prom_buy_num: -1, | ||
| 162 | - g_buy_num: null, | ||
| 163 | - prom_goods_num: 0, //活动商品数量 | ||
| 164 | - prom_buy_num: 0, //活动商品购买数量 | ||
| 165 | - prom_redis_num: 0, //活动商品redis数量 | ||
| 166 | - | ||
| 167 | - //拼单的规则显示 | ||
| 168 | - is_show_gz: 0, | ||
| 169 | - //会员自己的购买的拼单商品的情况 | ||
| 170 | - user_order_pt_state: 0, | ||
| 171 | - //购买的订单 | ||
| 172 | - buy_order: null, | ||
| 173 | - //1加入购物车 2立即购买 | ||
| 174 | - openSpecModal_ind: 0, | ||
| 175 | - | ||
| 176 | - //---计时器开关---- | ||
| 177 | - is_timer: 1, | ||
| 178 | - isshow: 0, | ||
| 179 | - bconfig: null, //基础配置 | ||
| 180 | - | ||
| 181 | - fir_comments: null, //详情页上的评价 | ||
| 182 | - fir_quan: null, //详情页上的券 | ||
| 183 | - quan_list: null, //券列表 | ||
| 184 | - | ||
| 185 | - coupon: 0, | ||
| 186 | - //会员分享的头像 | ||
| 187 | - share_head: "", | ||
| 188 | - share_goods_img: "", | ||
| 189 | - | ||
| 190 | - //----------视频图片data参数--------- | ||
| 191 | - current: 0, //图片计数 | ||
| 192 | - swiperCurrent: 0, //轮播的下标 | ||
| 193 | - hiddenn: 0, //控制轮播计数显示 | ||
| 194 | - | ||
| 195 | - currentTab: 0, // 选择器控制参数 | ||
| 196 | - mapurl: "", | ||
| 197 | - mapurl_f_img: "", | ||
| 198 | - videopicture: 0, //视频图片的控制 | ||
| 199 | - | ||
| 200 | - video: 0, //视频图片切换器 | ||
| 201 | - index: 0, | ||
| 202 | - noon: 0, //开始视频的隐藏 | ||
| 203 | - | ||
| 204 | - screenWidth: 0, | ||
| 205 | - canvasHidden: 1, | ||
| 206 | - | ||
| 207 | - //--推荐-- | ||
| 208 | - store_config: null, | ||
| 209 | - is_show_pl: 0, //是否品类 | ||
| 210 | - is_show_pp: 0, //是否品牌 | ||
| 211 | - is_show_gb: 0, //是否国别 | ||
| 212 | - is_closecoupon: 0, | ||
| 213 | - | ||
| 214 | - //是否点赞中 | ||
| 215 | - iszaning: 0, | ||
| 216 | - | ||
| 217 | - select_store: 0, //选择更多 | ||
| 218 | - index: 1, | ||
| 219 | - more_store: 0, //选择门店 | ||
| 220 | - sort_store: 0, //门店分类 | ||
| 221 | - choice_sort_store: 0, //选择分类门店 | ||
| 222 | - new_user: 0, //新用户 | ||
| 223 | - | ||
| 224 | - def_pick_store: null, // 默认的门店 | ||
| 225 | - fir_def_store: null, //客户默认的门店的 | ||
| 226 | - lat: null, //维度 | ||
| 227 | - lon: null, //经度 | ||
| 228 | - | ||
| 229 | - is_get_local_ok: 0, //获取坐标是否完成 | ||
| 230 | - region_name: "门店分类", //区域的名字 | ||
| 231 | - is_gps: 1, | ||
| 232 | - open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
| 233 | - default_store: {}, //创建添加默认门店地址的对象 | ||
| 234 | - | ||
| 235 | - comments_no_more: 0, | ||
| 236 | - get_c: 0, //获取评价是不是成 | ||
| 237 | - is_collect_load: 0, //是不是处理 | ||
| 238 | - is_newsales_rules: 0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 | ||
| 239 | - sales_rules: 1, //默认是线上销售 | ||
| 240 | - | ||
| 241 | - wait_for_user_store: null, | ||
| 242 | - prom_goods: null, //商品优惠列表 | ||
| 243 | - order_prom: null, //订单优惠 | ||
| 244 | - collocationGoods: null, //搭配购 | ||
| 245 | - | ||
| 246 | - poster: null, //自定义海报 | ||
| 247 | - share_b_img: '', //自定义分享的背景 | ||
| 248 | - | ||
| 249 | - showPoster: false, | ||
| 250 | - hui_condition: null, | ||
| 251 | - sto_sele_name_1: '',//分享的门店名称 | ||
| 252 | - fir_goods: null, | ||
| 253 | - | ||
| 254 | - share_hidden: false, | ||
| 255 | - }, | 23 | + data: { |
| 24 | + start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | ||
| 25 | + color_type: 0, //线条控制 | ||
| 26 | + color_type_one: 0, | ||
| 27 | + color_type_two: 1, | ||
| 28 | + | ||
| 29 | + gid: "", | ||
| 30 | + stoid: o.stoid, | ||
| 31 | + url: o.url, | ||
| 32 | + resourceUrl: o.h5_url, //公众号那边的图片文件域名 | ||
| 33 | + iurl: o.imghost, | ||
| 34 | + defaultAvatar: o.resourceUrl + "/static/images/user68.jpg", | ||
| 35 | + | ||
| 36 | + data: null, | ||
| 37 | + content: "", //商品详情 | ||
| 38 | + comments: null, //商品评论 | ||
| 39 | + c_curr_p: 1, //评论分页 | ||
| 40 | + com_num: 0, //评论人数 | ||
| 41 | + gallery: null, //图片滚动 | ||
| 42 | + is_collect: 0, | ||
| 43 | + collect_id: 0, | ||
| 44 | + cartGoodsNum: 0, | ||
| 45 | + specSelect: 0, | ||
| 46 | + optionItemId: 0, | ||
| 47 | + goodsInputNum: 1, | ||
| 48 | + openSpecModal: !1, | ||
| 49 | + openSpecModal_pt: !1, //拼单的弹起, | ||
| 50 | + openPromModal: !1, | ||
| 51 | + activeCategoryId: 0, | ||
| 52 | + supportPageScroll: !1, | ||
| 53 | + address: { | ||
| 54 | + address: "", | ||
| 55 | + district: 0 | ||
| 56 | + }, | ||
| 57 | + shipping: "", | ||
| 58 | + shippingCost: 0, | ||
| 59 | + enterAddressPage: !1, | ||
| 60 | + categories: [{ | ||
| 61 | + name: "商品", | ||
| 62 | + id: 0 | ||
| 63 | + }, { | ||
| 64 | + name: "详情", | ||
| 65 | + id: 1 | ||
| 66 | + }, { | ||
| 67 | + name: "评价", | ||
| 68 | + id: 2 | ||
| 69 | + }], | ||
| 70 | + activeCategoryId2: 0, | ||
| 71 | + categories2: [{ | ||
| 72 | + name: "商品详情", | ||
| 73 | + id: 0 | ||
| 74 | + }, { | ||
| 75 | + name: "规格参数", | ||
| 76 | + id: 1 | ||
| 77 | + }], | ||
| 78 | + activeCategoryId3: 1, | ||
| 79 | + categories3: [{ | ||
| 80 | + name: "全部", | ||
| 81 | + id: 1, | ||
| 82 | + num: 0 | ||
| 83 | + }, | ||
| 84 | + { | ||
| 85 | + name: "有图", | ||
| 86 | + id: 5, | ||
| 87 | + num: 0 | ||
| 88 | + }, | ||
| 256 | 89 | ||
| 257 | - //------初始化加载---------- | ||
| 258 | - onLoad: function (t) { | ||
| 259 | - var ee = this, | ||
| 260 | - that = ee, | ||
| 261 | - th = ee, | ||
| 262 | - gid = t.goods_id, | ||
| 263 | - first_leader = t.first_leader, | ||
| 264 | - room_id = t.room_id, | ||
| 265 | - room_user_share = t.room_user_share, //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id | ||
| 266 | - prom_type=t.prom_type, | ||
| 267 | - prom_id=t.prom_id; //活动ID | ||
| 268 | - | ||
| 269 | - if(prom_type){ | ||
| 270 | - this.data.prom_type=prom_type; | ||
| 271 | - this.data.prom_id=prom_id; | ||
| 272 | - } | 90 | + { |
| 91 | + name: "好评", | ||
| 92 | + id: 2, | ||
| 93 | + num: 0 | ||
| 94 | + }, { | ||
| 95 | + name: "中评", | ||
| 96 | + id: 3, | ||
| 97 | + num: 0 | ||
| 98 | + }, { | ||
| 99 | + name: "差评", | ||
| 100 | + id: 4, | ||
| 101 | + num: 0 | ||
| 102 | + }, | ||
| 103 | + ], | ||
| 273 | 104 | ||
| 274 | - //-- 自定义海报 -- | ||
| 275 | - getApp().request.promiseGet("/api/weshop/goods/poster/page", { | ||
| 276 | - data: { store_id: os.stoid, type: 1, is_use: 1 } | ||
| 277 | - }).then(res => { | ||
| 278 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) { | 105 | + select: { |
| 106 | + price: 0, | ||
| 107 | + stock: 0, | ||
| 108 | + specName: "", | ||
| 109 | + activity: null | ||
| 110 | + }, | ||
| 279 | 111 | ||
| 280 | - var poster_data = res.data.data.pageData[0]; | ||
| 281 | - var json_str = poster_data.jsonStr; | 112 | + //已选的商品(属性) |
| 113 | + sele_g_spec_name: '', | ||
| 114 | + sele_g_id: '', | ||
| 115 | + sele_g: null, | ||
| 116 | + //门店相关 | ||
| 117 | + ismend: 0, | ||
| 118 | + is_sec_mend: 0, | ||
| 119 | + sto_sele_name: "", //选中的门店名称 | ||
| 120 | + sto_sele_id: "", //选中的门店id | ||
| 121 | + sto_sele_distr: "", //选择的门店的配送方式 | ||
| 122 | + is_show_sto_cat: 1, //是否显示门店分类 | ||
| 123 | + only_pk: null, | ||
| 124 | + all_sto: null, | ||
| 125 | + sec_sto: null, //选择了的门店分类 | ||
| 126 | + pickpu_list: null, //读出的所有门店list | ||
| 127 | + def_pickpu_list: null, //一开始5个门店list | ||
| 128 | + sec_pick_index: 0, //第二级门店选择ID | ||
| 129 | + fir_pick_index: 0, //第一级门店选择ID | ||
| 130 | + all_pick_list: null,//所有的门店先记录起来 | ||
| 131 | + //同一条形码的所有商品 | ||
| 132 | + sku_g: null, | ||
| 133 | + sku_g_pt: null, //---拼单的普通购买--- | ||
| 134 | + //联系电话 | ||
| 135 | + mobile: '', | ||
| 136 | + //分类,品牌,国别名称 | ||
| 137 | + cat_name: '', | ||
| 138 | + brand_name: '', | ||
| 139 | + nation_name: '', | ||
| 140 | + | ||
| 141 | + //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | ||
| 142 | + prom_type: 0, | ||
| 143 | + prom_time_text: "", | ||
| 144 | + prom_price: null, | ||
| 145 | + prom_buy_limit: 0, | ||
| 146 | + djs: null, | ||
| 147 | + prom_st: 0, | ||
| 148 | + prom_r_null: 0, | ||
| 149 | + prom_end_time: null, | ||
| 150 | + prom_start_time: null, | ||
| 151 | + prom_act: null, | ||
| 152 | + pd_xx: 0, | ||
| 153 | + is_normal: 0, //是否普通购买 | ||
| 154 | + teamgroup: null, //有多少人开团 | ||
| 155 | + grounp_tatal: 0, //有几个人开团 | ||
| 156 | + timer: [], | ||
| 157 | + | ||
| 158 | + //商品的购买次数 | ||
| 159 | + prom_buy_num: -1, | ||
| 160 | + g_buy_num: null, | ||
| 161 | + prom_goods_num: 0, //活动商品数量 | ||
| 162 | + prom_buy_num: 0, //活动商品购买数量 | ||
| 163 | + prom_redis_num: 0, //活动商品redis数量 | ||
| 164 | + | ||
| 165 | + //拼单的规则显示 | ||
| 166 | + is_show_gz: 0, | ||
| 167 | + //会员自己的购买的拼单商品的情况 | ||
| 168 | + user_order_pt_state: 0, | ||
| 169 | + //购买的订单 | ||
| 170 | + buy_order: null, | ||
| 171 | + //1加入购物车 2立即购买 | ||
| 172 | + openSpecModal_ind: 0, | ||
| 173 | + | ||
| 174 | + //---计时器开关---- | ||
| 175 | + is_timer: 1, | ||
| 176 | + isshow: 0, | ||
| 177 | + bconfig: null, //基础配置 | ||
| 178 | + | ||
| 179 | + fir_comments: null, //详情页上的评价 | ||
| 180 | + fir_quan: null, //详情页上的券 | ||
| 181 | + quan_list: null, //券列表 | ||
| 182 | + | ||
| 183 | + coupon: 0, | ||
| 184 | + //会员分享的头像 | ||
| 185 | + share_head: "", | ||
| 186 | + share_goods_img: "", | ||
| 187 | + | ||
| 188 | + //----------视频图片data参数--------- | ||
| 189 | + current: 0, //图片计数 | ||
| 190 | + swiperCurrent: 0, //轮播的下标 | ||
| 191 | + hiddenn: 0, //控制轮播计数显示 | ||
| 192 | + | ||
| 193 | + currentTab: 0, // 选择器控制参数 | ||
| 194 | + mapurl: "", | ||
| 195 | + mapurl_f_img: "", | ||
| 196 | + videopicture: 0, //视频图片的控制 | ||
| 197 | + | ||
| 198 | + video: 0, //视频图片切换器 | ||
| 199 | + index: 0, | ||
| 200 | + noon: 0, //开始视频的隐藏 | ||
| 201 | + | ||
| 202 | + screenWidth: 0, | ||
| 203 | + canvasHidden: 1, | ||
| 204 | + | ||
| 205 | + //--推荐-- | ||
| 206 | + store_config: null, | ||
| 207 | + is_show_pl: 0, //是否品类 | ||
| 208 | + is_show_pp: 0, //是否品牌 | ||
| 209 | + is_show_gb: 0, //是否国别 | ||
| 210 | + is_closecoupon: 0, | ||
| 211 | + | ||
| 212 | + //是否点赞中 | ||
| 213 | + iszaning: 0, | ||
| 214 | + | ||
| 215 | + select_store: 0, //选择更多 | ||
| 216 | + index: 1, | ||
| 217 | + more_store: 0, //选择门店 | ||
| 218 | + sort_store: 0, //门店分类 | ||
| 219 | + choice_sort_store: 0, //选择分类门店 | ||
| 220 | + new_user: 0, //新用户 | ||
| 221 | + | ||
| 222 | + def_pick_store: null, // 默认的门店 | ||
| 223 | + fir_def_store: null, //客户默认的门店的 | ||
| 224 | + lat: null, //维度 | ||
| 225 | + lon: null, //经度 | ||
| 226 | + | ||
| 227 | + is_get_local_ok: 0, //获取坐标是否完成 | ||
| 228 | + region_name: "门店分类", //区域的名字 | ||
| 229 | + is_gps: 1, | ||
| 230 | + open_ind_store: 0, //哪里打开的门店列表的控制属性 | ||
| 231 | + default_store: {}, //创建添加默认门店地址的对象 | ||
| 232 | + | ||
| 233 | + comments_no_more: 0, | ||
| 234 | + get_c: 0, //获取评价是不是成 | ||
| 235 | + is_collect_load: 0, //是不是处理 | ||
| 236 | + is_newsales_rules: 0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 | ||
| 237 | + sales_rules: 1, //默认是线上销售 | ||
| 238 | + | ||
| 239 | + wait_for_user_store: null, | ||
| 240 | + prom_goods: null, //商品优惠列表 | ||
| 241 | + order_prom: null, //订单优惠 | ||
| 242 | + collocationGoods: null, //搭配购 | ||
| 243 | + | ||
| 244 | + poster: null, //自定义海报 | ||
| 245 | + share_b_img: '', //自定义分享的背景 | ||
| 246 | + | ||
| 247 | + showPoster: false, | ||
| 248 | + hui_condition: null, | ||
| 249 | + sto_sele_name_1: '',//分享的门店名称 | ||
| 250 | + fir_goods: null, | ||
| 251 | + | ||
| 252 | + share_hidden: false, | ||
| 253 | + all_activity_list: null, //所有活动的列表 | ||
| 254 | + }, | ||
| 282 | 255 | ||
| 283 | - if (json_str) { | ||
| 284 | - var json_data = JSON.parse(json_str); | ||
| 285 | - if (json_data.bg_img) { | 256 | + //------初始化加载---------- |
| 257 | + onLoad: function (t) { | ||
| 258 | + var ee = this, | ||
| 259 | + that = ee, | ||
| 260 | + th = ee, | ||
| 261 | + gid = t.goods_id, | ||
| 262 | + first_leader = t.first_leader, | ||
| 263 | + room_id = t.room_id, | ||
| 264 | + room_user_share = t.room_user_share, //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id | ||
| 265 | + prom_type = t.prom_type, | ||
| 266 | + prom_id = t.prom_id; //活动ID | ||
| 267 | + | ||
| 268 | + | ||
| 269 | + //-- 自定义海报 -- | ||
| 270 | + getApp().request.promiseGet("/api/weshop/goods/poster/page", { | ||
| 271 | + data: {store_id: os.stoid, type: 1, is_use: 1} | ||
| 272 | + }).then(res => { | ||
| 273 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]) { | ||
| 274 | + | ||
| 275 | + var poster_data = res.data.data.pageData[0]; | ||
| 276 | + var json_str = poster_data.jsonStr; | ||
| 277 | + | ||
| 278 | + if (json_str) { | ||
| 279 | + var json_data = JSON.parse(json_str); | ||
| 280 | + if (json_data.bg_img) { | ||
| 281 | + | ||
| 282 | + //-- 把图片那到本地 -- | ||
| 283 | + wx.getImageInfo({ | ||
| 284 | + src: json_data.bg_img, | ||
| 285 | + success: function (res) { | ||
| 286 | + var path = res.path; | ||
| 287 | + th.setData({share_b_img: path}) | ||
| 288 | + }, | ||
| 289 | + fail: function (res) { | ||
| 290 | + } | ||
| 291 | + }); | ||
| 292 | + } | ||
| 293 | + th.setData({poster: json_data}) | ||
| 286 | 294 | ||
| 287 | - //-- 把图片那到本地 -- | ||
| 288 | - wx.getImageInfo({ | ||
| 289 | - src: json_data.bg_img, | ||
| 290 | - success: function (res) { | ||
| 291 | - var path = res.path; | ||
| 292 | - th.setData({ share_b_img: path }) | ||
| 293 | - }, | ||
| 294 | - fail: function (res) { } | ||
| 295 | - }); | ||
| 296 | - } | ||
| 297 | - th.setData({ poster: json_data }) | 295 | + } |
| 296 | + } | ||
| 297 | + }) | ||
| 298 | 298 | ||
| 299 | - } | ||
| 300 | - } | ||
| 301 | - }) | 299 | + //---获取手机地址坐标-- |
| 300 | + //--如果tg_id是空的话,分享回来-- | ||
| 301 | + if (gid == undefined || gid == null || gid == "") { | ||
| 302 | + var gid_str = decodeURIComponent(t.scene); | ||
| 303 | + gid_str = gid_str.split("_"); | ||
| 304 | + gid = gid_str[0]; | ||
| 305 | + if (gid.indexOf('.') != -1) { | ||
| 306 | + var fir_arr = gid.split("."); | ||
| 307 | + gid = fir_arr[0]; | ||
| 308 | + prom_type = fir_arr[1]; | ||
| 309 | + prom_id = fir_arr[2]; | ||
| 310 | + this.data.prom_type = prom_type; | ||
| 311 | + this.data.prom_id = prom_id; | ||
| 312 | + } | ||
| 302 | 313 | ||
| 303 | - //---获取手机地址坐标-- | ||
| 304 | - //--如果tg_id是空的话,分享回来-- | ||
| 305 | - if (gid == undefined || gid == null || gid == "") { | ||
| 306 | - var gid_str = decodeURIComponent(t.scene); | ||
| 307 | - gid_str = gid_str.split("_"); | ||
| 308 | - gid = gid_str[0]; | ||
| 309 | - if(gid.indexOf('.')!=-1){ | ||
| 310 | - var fir_arr=gid.split("."); | ||
| 311 | - gid=fir_arr[0]; | ||
| 312 | - prom_type=fir_arr[1]; | ||
| 313 | - prom_id=fir_arr[2]; | ||
| 314 | - this.data.prom_type=prom_type; | ||
| 315 | - this.data.prom_id=prom_id; | ||
| 316 | - } | 314 | + if (gid_str.length > 1) { |
| 315 | + first_leader = gid_str[1]; | ||
| 316 | + } | ||
| 317 | + //-- 如果有room_id的获取 -- | ||
| 318 | + if (gid_str.length > 2 && gid_str[2]) { | ||
| 319 | + room_id = gid_str[2]; | ||
| 320 | + room_user_share = 1; | ||
| 321 | + } | ||
| 317 | 322 | ||
| 323 | + } | ||
| 318 | 324 | ||
| 319 | 325 | ||
| 320 | - if (gid_str.length > 1) { | ||
| 321 | - first_leader = gid_str[1]; | ||
| 322 | - } | ||
| 323 | - //-- 如果有room_id的获取 -- | ||
| 324 | - if (gid_str.length > 2 && gid_str[2]) { | ||
| 325 | - room_id = gid_str[2]; | ||
| 326 | - room_user_share = 1; | ||
| 327 | - } | 326 | + //判断活动 |
| 327 | + if (prom_type) { | ||
| 328 | + this.data.prom_type = prom_type; | ||
| 329 | + this.data.prom_id = prom_id; | ||
| 330 | + } | ||
| 331 | + ee.setData({gid: gid}); | ||
| 332 | + if (first_leader) { | ||
| 333 | + console.log("log---".first_leader); | ||
| 334 | + getApp().globalData.first_leader = first_leader; | ||
| 335 | + //调用接口判断是不是会员 | ||
| 336 | + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
| 337 | + if (res.data.code == 0) { | ||
| 338 | + getApp().globalData.guide_id = res.data.data.id; | ||
| 339 | + } | ||
| 340 | + }) | ||
| 341 | + } | ||
| 328 | 342 | ||
| 329 | - } | 343 | + //-- 如果有房间号 -- |
| 344 | + if (room_id) { | ||
| 345 | + getApp().globalData.room_id = room_id; | ||
| 346 | + getApp().globalData.room_goods_id = gid; | ||
| 347 | + //如果是会员分享过来的要记录 | ||
| 348 | + if (room_user_share) | ||
| 349 | + getApp().globalData.room_user_share = room_user_share; | ||
| 350 | + } | ||
| 330 | 351 | ||
| 331 | - ee.setData({ gid: gid }); | ||
| 332 | - if (first_leader) { | ||
| 333 | - console.log("log---".first_leader); | ||
| 334 | - getApp().globalData.first_leader = first_leader; | ||
| 335 | - //调用接口判断是不是会员 | ||
| 336 | - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | ||
| 337 | - if (res.data.code == 0) { | ||
| 338 | - getApp().globalData.guide_id = res.data.data.id; | 352 | + var c_guide_id = t.c_guide_id; |
| 353 | + if (c_guide_id) { | ||
| 354 | + th.data.c_guide_id = c_guide_id; | ||
| 339 | } | 355 | } |
| 340 | - }) | ||
| 341 | - } | ||
| 342 | 356 | ||
| 343 | - //-- 如果有房间号 -- | ||
| 344 | - if (room_id) { | ||
| 345 | - getApp().globalData.room_id = room_id; | ||
| 346 | - getApp().globalData.room_goods_id = gid; | ||
| 347 | - //如果是会员分享过来的要记录 | ||
| 348 | - if (room_user_share) | ||
| 349 | - getApp().globalData.room_user_share = room_user_share; | ||
| 350 | - } | 357 | + getApp().getConfig(function (e) { |
| 358 | + ee.setData({sto_sele_name_1: e.store_name}) | ||
| 359 | + }) | ||
| 351 | 360 | ||
| 352 | - var c_guide_id = t.c_guide_id; | ||
| 353 | - if (c_guide_id) { | ||
| 354 | - th.data.c_guide_id = c_guide_id; | ||
| 355 | - } | 361 | + //----获取系统参数----- |
| 362 | + getApp().getConfig2(function (e) { | ||
| 363 | + ee.setData({ | ||
| 364 | + bconfig: e, | ||
| 365 | + sales_rules: e.sales_rules, | ||
| 366 | + }); | ||
| 356 | 367 | ||
| 357 | - getApp().getConfig(function (e) { | ||
| 358 | - ee.setData({ sto_sele_name_1: e.store_name }) | ||
| 359 | - }) | 368 | + if (e.categoryset.indexOf("," + 1 + ",") != -1) { |
| 369 | + ee.setData({ | ||
| 370 | + is_show_pl: 1 | ||
| 371 | + }); | ||
| 372 | + } | ||
| 373 | + if (e.categoryset.indexOf("," + 3 + ",") != -1) { | ||
| 374 | + ee.setData({ | ||
| 375 | + is_show_pp: 1 | ||
| 376 | + }); | ||
| 377 | + } | ||
| 378 | + if (e.categoryset.indexOf("," + 2 + ",") != -1) { | ||
| 379 | + ee.setData({ | ||
| 380 | + is_show_gb: 1 | ||
| 381 | + }); | ||
| 382 | + } | ||
| 383 | + console.log(e); | ||
| 384 | + var json_d = JSON.parse(e.switch_list); | ||
| 385 | + ee.setData({ | ||
| 386 | + store_config: e, | ||
| 387 | + sys_switch: json_d, | ||
| 388 | + is_closecoupon: json_d.is_closecoupon, | ||
| 389 | + is_newsales_rules: json_d.is_newsales_rules | ||
| 390 | + }); | ||
| 391 | + ee.init(gid); | ||
| 392 | + //------几人评价------- | ||
| 393 | + //n.init(th, "", "comments"); | ||
| 360 | 394 | ||
| 361 | - //----获取系统参数----- | ||
| 362 | - getApp().getConfig2(function (e) { | ||
| 363 | - ee.setData({ | ||
| 364 | - bconfig: e, | ||
| 365 | - sales_rules: e.sales_rules, | ||
| 366 | - }); | 395 | + th.requestCardNum(), wx.pageScrollTo && th.setData({ |
| 396 | + supportPageScroll: !0 | ||
| 397 | + }); | ||
| 367 | 398 | ||
| 368 | - if (e.categoryset.indexOf("," + 1 + ",") != -1) { | ||
| 369 | - ee.setData({ | ||
| 370 | - is_show_pl: 1 | ||
| 371 | - }); | ||
| 372 | - } | ||
| 373 | - if (e.categoryset.indexOf("," + 3 + ",") != -1) { | ||
| 374 | - ee.setData({ | ||
| 375 | - is_show_pp: 1 | ||
| 376 | - }); | ||
| 377 | - } | ||
| 378 | - if (e.categoryset.indexOf("," + 2 + ",") != -1) { | ||
| 379 | - ee.setData({ | ||
| 380 | - is_show_gb: 1 | 399 | + //计算等级价相关 |
| 400 | + var swithc_list = e.switch_list; | ||
| 401 | + var sw_arr = JSON.parse(swithc_list); | ||
| 402 | + //---如果后台又开等级卡的开关--- | ||
| 403 | + if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 404 | + th.setData({rank_switch: true}); | ||
| 405 | + //---回调卡的列表--- | ||
| 406 | + th.getPlusCardType(function (ob) { | ||
| 407 | + th.setData({card_list: ob.card_list}); | ||
| 408 | + var ti = setInterval(function () { | ||
| 409 | + var user = getApp().globalData.userInfo; | ||
| 410 | + if (!user) return false; | ||
| 411 | + clearInterval(ti); | ||
| 412 | + if (user.card_field && user['card_expiredate']) { | ||
| 413 | + var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 414 | + var end = new Date(str); | ||
| 415 | + end = Date.parse(end) / 1000; | ||
| 416 | + var now = ut.gettimestamp(); | ||
| 417 | + //--- 判断是等级会员,且在有效期范围内 --- | ||
| 418 | + if (user.card_field && now < end) { | ||
| 419 | + var card_name = ob.name_map.get(user.card_field); | ||
| 420 | + //if(card_name.length>6) card_name=card_name.substring(0,6); | ||
| 421 | + | ||
| 422 | + var is_near_date = 0; | ||
| 423 | + if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天 | ||
| 424 | + th.setData({ | ||
| 425 | + card_field: user.card_field, | ||
| 426 | + card_name: card_name, | ||
| 427 | + card_list: ob.card_list, | ||
| 428 | + is_near_date: is_near_date | ||
| 429 | + }); | ||
| 430 | + } | ||
| 431 | + } | ||
| 432 | + }, 500) | ||
| 433 | + }) | ||
| 434 | + } | ||
| 435 | + | ||
| 436 | + }, 1); | ||
| 437 | + | ||
| 438 | + //获取用户设备信息,屏幕宽度 | ||
| 439 | + wx.getSystemInfo({ | ||
| 440 | + success: res => { | ||
| 441 | + that.setData({ | ||
| 442 | + screenWidth: res.screenWidth | ||
| 443 | + }) | ||
| 444 | + } | ||
| 381 | }); | 445 | }); |
| 382 | - } | ||
| 383 | - console.log(e); | ||
| 384 | - var json_d = JSON.parse(e.switch_list); | ||
| 385 | - ee.setData({ | ||
| 386 | - store_config: e, | ||
| 387 | - sys_switch: json_d, | ||
| 388 | - is_closecoupon: json_d.is_closecoupon, | ||
| 389 | - is_newsales_rules: json_d.is_newsales_rules | ||
| 390 | - }); | ||
| 391 | - ee.init(gid); | ||
| 392 | - //------几人评价------- | ||
| 393 | - //n.init(th, "", "comments"); | ||
| 394 | - | ||
| 395 | - th.requestCardNum(), wx.pageScrollTo && th.setData({ | ||
| 396 | - supportPageScroll: !0 | ||
| 397 | - }); | ||
| 398 | - | ||
| 399 | - //计算等级价相关 | ||
| 400 | - var swithc_list = e.switch_list; | ||
| 401 | - var sw_arr = JSON.parse(swithc_list); | ||
| 402 | - //---如果后台又开等级卡的开关--- | ||
| 403 | - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 404 | - th.setData({ rank_switch: true }); | ||
| 405 | - //---回调卡的列表--- | ||
| 406 | - th.getPlusCardType(function (ob) { | ||
| 407 | - th.setData({ card_list: ob.card_list }); | ||
| 408 | - var ti = setInterval(function () { | ||
| 409 | - var user = getApp().globalData.userInfo; | ||
| 410 | - if (!user) return false; | ||
| 411 | - clearInterval(ti); | ||
| 412 | - if (user.card_field && user['card_expiredate']) { | ||
| 413 | - var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 414 | - var end = new Date(str); | ||
| 415 | - end = Date.parse(end) / 1000; | ||
| 416 | - var now = ut.gettimestamp(); | ||
| 417 | - //--- 判断是等级会员,且在有效期范围内 --- | ||
| 418 | - if (user.card_field && now < end) { | ||
| 419 | - var card_name = ob.name_map.get(user.card_field); | ||
| 420 | - //if(card_name.length>6) card_name=card_name.substring(0,6); | ||
| 421 | - | ||
| 422 | - var is_near_date = 0; | ||
| 423 | - if (end - now < 60 * 60 * 30 * 24) is_near_date = 1; //如果小于30天 | ||
| 424 | - th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list, is_near_date: is_near_date }); | ||
| 425 | - } | ||
| 426 | - } | ||
| 427 | - }, 500) | ||
| 428 | - }) | ||
| 429 | - } | ||
| 430 | 446 | ||
| 431 | - }, 1); | 447 | + //获取用户的默认门店 |
| 448 | + getApp().get_user_store(function (e) { | ||
| 449 | + if (!e) { | ||
| 450 | + th.data.fir_def_store = {}; //赋值空对象 | ||
| 451 | + return false; | ||
| 452 | + } | ||
| 453 | + var ee = JSON.parse(JSON.stringify(e)); | ||
| 454 | + //--定时器推迟一下-- | ||
| 455 | + setTimeout(function () { | ||
| 456 | + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; | ||
| 457 | + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- | ||
| 458 | + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { | ||
| 459 | + ee.is_no_dis = 1; | ||
| 460 | + } | ||
| 432 | 461 | ||
| 433 | - //获取用户设备信息,屏幕宽度 | ||
| 434 | - wx.getSystemInfo({ | ||
| 435 | - success: res => { | ||
| 436 | - that.setData({ | ||
| 437 | - screenWidth: res.screenWidth | 462 | + var appd = getApp().globalData; |
| 463 | + var w_time = setInterval(function () { | ||
| 464 | + if (that.data.is_get_local_ok == 0) return false; | ||
| 465 | + clearInterval(w_time); | ||
| 466 | + var distance = null; | ||
| 467 | + var e = JSON.parse(JSON.stringify(ee)); | ||
| 468 | + | ||
| 469 | + //如果有开启近距离的话,同时距离优不一样了 | ||
| 470 | + if (that.data.lat != null) { | ||
| 471 | + //如果经纬度有变化的话 | ||
| 472 | + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) { | ||
| 473 | + that.set_def_storage(e); | ||
| 474 | + } else { | ||
| 475 | + //要用接口是获取距离,js的计算不准 | ||
| 476 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 477 | + data: { | ||
| 478 | + store_id: os.stoid, | ||
| 479 | + pickup_id: e.pickup_id, | ||
| 480 | + lat: th.data.lat, | ||
| 481 | + lon: th.data.lon, | ||
| 482 | + isstop: 0, | ||
| 483 | + is_pos: 1 | ||
| 484 | + }, | ||
| 485 | + }).then(res => { | ||
| 486 | + if (res.data.code == 0) { | ||
| 487 | + e = res.data.data.pageData[0]; | ||
| 488 | + if (e) { | ||
| 489 | + e.is_no_dis = ee.is_no_dis; | ||
| 490 | + appd.pk_store = e; | ||
| 491 | + that.set_def_storage(e); | ||
| 492 | + } | ||
| 493 | + | ||
| 494 | + } | ||
| 495 | + }) | ||
| 496 | + } | ||
| 497 | + //e.distance = distance; | ||
| 498 | + appd.lat = that.data.lat; | ||
| 499 | + appd.lon = that.data.lon; | ||
| 500 | + | ||
| 501 | + } else { | ||
| 502 | + if (e) { | ||
| 503 | + e.distance = null; | ||
| 504 | + that.set_def_storage(e); | ||
| 505 | + } | ||
| 506 | + } | ||
| 507 | + }, 500) | ||
| 508 | + }, 700) | ||
| 509 | + }); | ||
| 510 | + | ||
| 511 | + //更新点击量 | ||
| 512 | + getApp().request.put("/api/weshop/goods/updateClick", { | ||
| 513 | + data: {store_id: os.stoid, goods_id: gid} | ||
| 438 | }) | 514 | }) |
| 439 | - } | ||
| 440 | - }); | 515 | + }, |
| 441 | 516 | ||
| 442 | - //获取用户的默认门店 | ||
| 443 | - getApp().get_user_store(function (e) { | ||
| 444 | - if (!e) { | ||
| 445 | - th.data.fir_def_store = {}; //赋值空对象 | ||
| 446 | - return false; | ||
| 447 | - } | ||
| 448 | - var ee = JSON.parse(JSON.stringify(e)); | ||
| 449 | - //--定时器推迟一下-- | ||
| 450 | - setTimeout(function () { | ||
| 451 | - if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; | ||
| 452 | - //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对-- | ||
| 453 | - if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) { | ||
| 454 | - ee.is_no_dis = 1; | ||
| 455 | - } | ||
| 456 | 517 | ||
| 457 | - var appd = getApp().globalData; | ||
| 458 | - var w_time = setInterval(function () { | ||
| 459 | - if (that.data.is_get_local_ok == 0) return false; | ||
| 460 | - clearInterval(w_time); | ||
| 461 | - var distance = null; | ||
| 462 | - var e = JSON.parse(JSON.stringify(ee)); | ||
| 463 | - | ||
| 464 | - //如果有开启近距离的话,同时距离优不一样了 | ||
| 465 | - if (that.data.lat != null) { | ||
| 466 | - //如果经纬度有变化的话 | ||
| 467 | - if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) { | ||
| 468 | - that.set_def_storage(e); | 518 | + //--- 设置一下默认库存的数量 ---- |
| 519 | + set_def_storage(ee) { | ||
| 520 | + var that = this, th = this; | ||
| 521 | + getApp().getConfig2(function (e) { | ||
| 522 | + var sales_rules = e.sales_rules; | ||
| 523 | + if (sales_rules == 2) { | ||
| 524 | + getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { | ||
| 525 | + var lock = 0, plist = null; | ||
| 526 | + var gd = that.data.fir_goods; | ||
| 527 | + //先读取门店的lock,采用链式写法,少用await | ||
| 528 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 529 | + data: { | ||
| 530 | + store_id: os.stoid, | ||
| 531 | + wareId: that.data.fir_goods.goods_id, | ||
| 532 | + storageId: ee.pickup_id, | ||
| 533 | + pageSize: 1000 | ||
| 534 | + } | ||
| 535 | + }).then(res => { | ||
| 536 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 537 | + for (var i in res.data.data.pageData) | ||
| 538 | + lock += res.data.data.pageData[i].outQty | ||
| 539 | + } | ||
| 540 | + //---通过接口获取门店的线下库存信息-- | ||
| 541 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 542 | + data: { | ||
| 543 | + storageNos: ee.pickup_no, | ||
| 544 | + wareIds: encodeURIComponent(th.data.data.erpwareid), | ||
| 545 | + storeId: os.stoid | ||
| 546 | + } | ||
| 547 | + }) | ||
| 548 | + }).then(res => { | ||
| 549 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 550 | + plist = res.data.data.pageData[0]; | ||
| 551 | + } else { | ||
| 552 | + wx.showToast({ | ||
| 553 | + title: '库存不足,请更换其他门店', | ||
| 554 | + icon: 'none', | ||
| 555 | + }); | ||
| 556 | + } | ||
| 557 | + ; | ||
| 558 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 559 | + ee.CanOutQty = plist.CanOutQty - lock; | ||
| 560 | + } else { | ||
| 561 | + ee.CanOutQty = 0; | ||
| 562 | + } | ||
| 563 | + //--给门店赋值线下库存-- | ||
| 564 | + that.data.fir_def_store = ee; | ||
| 565 | + that.setData({ | ||
| 566 | + def_pick_store: ee, | ||
| 567 | + sto_sele_name: ee.pickup_name, | ||
| 568 | + sto_sele_id: ee.pickup_id, | ||
| 569 | + sto_sele_distr: ee.distr_type | ||
| 570 | + }) | ||
| 571 | + }) | ||
| 572 | + }) | ||
| 469 | } else { | 573 | } else { |
| 470 | - //要用接口是获取距离,js的计算不准 | ||
| 471 | - getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 472 | - data: { store_id: os.stoid, pickup_id: e.pickup_id, lat: th.data.lat, lon: th.data.lon,isstop:0,is_pos:1 }, | ||
| 473 | - }).then(res => { | ||
| 474 | - if (res.data.code == 0) { | ||
| 475 | - e = res.data.data.pageData[0]; | ||
| 476 | - if (e) { | ||
| 477 | - e.is_no_dis = ee.is_no_dis; | ||
| 478 | - appd.pk_store = e; | ||
| 479 | - that.set_def_storage(e); | ||
| 480 | - } | ||
| 481 | - | ||
| 482 | - } | ||
| 483 | - }) | 574 | + that.data.fir_def_store = ee; |
| 575 | + that.setData({ | ||
| 576 | + def_pick_store: ee, | ||
| 577 | + sto_sele_name: ee.pickup_name, | ||
| 578 | + sto_sele_id: ee.pickup_id, | ||
| 579 | + sto_sele_distr: ee.distr_type | ||
| 580 | + }) | ||
| 484 | } | 581 | } |
| 485 | - //e.distance = distance; | ||
| 486 | - appd.lat = that.data.lat; | ||
| 487 | - appd.lon = that.data.lon; | 582 | + }) |
| 488 | 583 | ||
| 489 | - } else { | ||
| 490 | - if (e) { | ||
| 491 | - e.distance = null; | ||
| 492 | - that.set_def_storage(e); | ||
| 493 | - } | ||
| 494 | - } | ||
| 495 | - }, 500) | ||
| 496 | - }, 700) | ||
| 497 | - }); | 584 | + }, |
| 498 | 585 | ||
| 499 | - //更新点击量 | ||
| 500 | - getApp().request.put("/api/weshop/goods/updateClick", { | ||
| 501 | - data: { store_id: os.stoid, goods_id: gid } | ||
| 502 | - }) | ||
| 503 | - }, | ||
| 504 | 586 | ||
| 587 | + //------------程序初始化入口------------- | ||
| 588 | + async init(gid) { | ||
| 589 | + var ee = this, | ||
| 590 | + th = ee, | ||
| 591 | + gallery = null, | ||
| 592 | + is_collect = 0, | ||
| 593 | + collect_id = 0, | ||
| 594 | + categories3 = ee.data.categories3, | ||
| 595 | + fir_com = null, | ||
| 596 | + fir_quan = null, | ||
| 597 | + mapurl = null, | ||
| 598 | + mapurl_f_img = null; | ||
| 505 | 599 | ||
| 506 | - //--- 设置一下默认库存的数量 ---- | ||
| 507 | - set_def_storage(ee) { | ||
| 508 | - var that = this, th = this; | ||
| 509 | - getApp().getConfig2(function (e) { | ||
| 510 | - var sales_rules = e.sales_rules; | ||
| 511 | - if (sales_rules == 2) { | ||
| 512 | - getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { | ||
| 513 | - var lock = 0, plist = null; | ||
| 514 | - var gd = that.data.fir_goods; | ||
| 515 | - //先读取门店的lock,采用链式写法,少用await | ||
| 516 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 517 | - data: { store_id: os.stoid, wareId: that.data.fir_goods.goods_id, storageId: ee.pickup_id, pageSize: 1000 } | ||
| 518 | - }).then(res => { | ||
| 519 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 520 | - for (var i in res.data.data.pageData) | ||
| 521 | - lock += res.data.data.pageData[i].outQty | 600 | + |
| 601 | + //------图片滚动---------- | ||
| 602 | + await getApp().request.promiseGet("/api/weshop/goodsimages/page", { | ||
| 603 | + data: { | ||
| 604 | + store_id: os.stoid, | ||
| 605 | + goods_id: gid, | ||
| 606 | + }, | ||
| 607 | + }).then(res => { | ||
| 608 | + | ||
| 609 | + var t = res; | ||
| 610 | + var g = t.data.data.pageData; | ||
| 611 | + if (g.length == 0) { | ||
| 612 | + var ie = { | ||
| 613 | + "image_url": o.imghost + "/public/images/default_goods_image_240.gif" | ||
| 614 | + }; | ||
| 615 | + g.push(ie); | ||
| 616 | + gallery = g; | ||
| 617 | + return; | ||
| 522 | } | 618 | } |
| 523 | - //---通过接口获取门店的线下库存信息-- | ||
| 524 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 525 | - data: { storageNos: ee.pickup_no, wareIds: encodeURIComponent(th.data.data.erpwareid), storeId: os.stoid } | ||
| 526 | - }) | ||
| 527 | - }).then(res => { | ||
| 528 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 529 | - plist = res.data.data.pageData[0]; | ||
| 530 | - } else { | ||
| 531 | - wx.showToast({ | ||
| 532 | - title: '库存不足,请更换其他门店', | ||
| 533 | - icon: 'none', | ||
| 534 | - }); | ||
| 535 | - }; | ||
| 536 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 537 | - ee.CanOutQty = plist.CanOutQty - lock; | ||
| 538 | - } else { | ||
| 539 | - ee.CanOutQty = 0; | 619 | + for (var i = 0; i < g.length; i++) { |
| 620 | + if (g[i].image_url.indexOf(o.imghost) == -1) | ||
| 621 | + g[i].image_url = o.imghost + g[i].image_url; | ||
| 540 | } | 622 | } |
| 541 | - //--给门店赋值线下库存-- | ||
| 542 | - that.data.fir_def_store = ee; | ||
| 543 | - that.setData({ | ||
| 544 | - def_pick_store: ee, | ||
| 545 | - sto_sele_name: ee.pickup_name, | ||
| 546 | - sto_sele_id: ee.pickup_id, | ||
| 547 | - sto_sele_distr: ee.distr_type | ||
| 548 | - }) | ||
| 549 | - }) | 623 | + gallery = g; |
| 550 | }) | 624 | }) |
| 551 | - } else { | ||
| 552 | - that.data.fir_def_store = ee; | ||
| 553 | - that.setData({ | ||
| 554 | - def_pick_store: ee, | ||
| 555 | - sto_sele_name: ee.pickup_name, | ||
| 556 | - sto_sele_id: ee.pickup_id, | ||
| 557 | - sto_sele_distr: ee.distr_type | 625 | + //------是否收藏---------- |
| 626 | + await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | ||
| 627 | + data: { | ||
| 628 | + store_id: os.stoid, | ||
| 629 | + goods_id: gid, | ||
| 630 | + user_id: oo.user_id, | ||
| 631 | + } | ||
| 632 | + }).then(res => { | ||
| 633 | + var t = res; | ||
| 634 | + var data = t.data.data.pageData; | ||
| 635 | + if (data && data.length > 0) { | ||
| 636 | + //ee.setData({ is_collect: 1, collect_id: data[0].collect_id, }); | ||
| 637 | + is_collect = 1; | ||
| 638 | + collect_id = data[0].collect_id; | ||
| 639 | + } | ||
| 558 | }) | 640 | }) |
| 559 | - } | ||
| 560 | - }) | ||
| 561 | - | ||
| 562 | - }, | ||
| 563 | - | ||
| 564 | - | ||
| 565 | - //------------程序初始化入口------------- | ||
| 566 | - async init(gid) { | ||
| 567 | - var ee = this, | ||
| 568 | - th = ee, | ||
| 569 | - gallery = null, | ||
| 570 | - is_collect = 0, | ||
| 571 | - collect_id = 0, | ||
| 572 | - categories3 = ee.data.categories3, | ||
| 573 | - fir_com = null, | ||
| 574 | - fir_quan = null, | ||
| 575 | - mapurl = null, | ||
| 576 | - mapurl_f_img = null; | ||
| 577 | 641 | ||
| 642 | + //------获取评价的统计数量---- | ||
| 643 | + await getApp().request.promiseGet("/api/weshop/comment/countlist/", { | ||
| 644 | + data: { | ||
| 645 | + store_id: os.stoid, | ||
| 646 | + goods_id: gid | ||
| 647 | + }, | ||
| 648 | + //failRollback: !0, | ||
| 578 | 649 | ||
| 579 | - //------图片滚动---------- | ||
| 580 | - await getApp().request.promiseGet("/api/weshop/goodsimages/page", { | ||
| 581 | - data: { | ||
| 582 | - store_id: os.stoid, | ||
| 583 | - goods_id: gid, | ||
| 584 | - }, | ||
| 585 | - }).then(res => { | 650 | + }).then(res => { |
| 651 | + var t = res; | ||
| 652 | + var g = t.data.data[0]; | ||
| 653 | + if (g != null && g != undefined) { | ||
| 654 | + var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | ||
| 655 | + var num2 = g.c4 + g.c5; | ||
| 656 | + var num3 = g.c3; | ||
| 657 | + var num4 = g.c0 + g.c1 + g.c2; | ||
| 658 | + | ||
| 659 | + var dd = ee.data.categories3; | ||
| 660 | + dd[0].num = allnum; | ||
| 661 | + dd[1].num = g.cimg; | ||
| 662 | + dd[2].num = num2; | ||
| 663 | + dd[3].num = num3; | ||
| 664 | + dd[4].num = num4; | ||
| 665 | + | ||
| 666 | + categories3 = dd; | ||
| 667 | + } | ||
| 668 | + }) | ||
| 586 | 669 | ||
| 587 | - var t = res; | ||
| 588 | - var g = t.data.data.pageData; | ||
| 589 | - if (g.length == 0) { | ||
| 590 | - var ie = { | ||
| 591 | - "image_url": o.imghost + "/public/images/default_goods_image_240.gif" | ||
| 592 | - }; | ||
| 593 | - g.push(ie); | ||
| 594 | - gallery = g; | ||
| 595 | - return; | ||
| 596 | - } | ||
| 597 | - for (var i = 0; i < g.length; i++) { | ||
| 598 | - if (g[i].image_url.indexOf(o.imghost) == -1) | ||
| 599 | - g[i].image_url = o.imghost + g[i].image_url; | ||
| 600 | - } | ||
| 601 | - gallery = g; | ||
| 602 | - }) | ||
| 603 | - //------是否收藏---------- | ||
| 604 | - await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | ||
| 605 | - data: { | ||
| 606 | - store_id: os.stoid, | ||
| 607 | - goods_id: gid, | ||
| 608 | - user_id: oo.user_id, | ||
| 609 | - } | ||
| 610 | - }).then(res => { | ||
| 611 | - var t = res; | ||
| 612 | - var data = t.data.data.pageData; | ||
| 613 | - if (data && data.length > 0) { | ||
| 614 | - //ee.setData({ is_collect: 1, collect_id: data[0].collect_id, }); | ||
| 615 | - is_collect = 1; | ||
| 616 | - collect_id = data[0].collect_id; | ||
| 617 | - } | ||
| 618 | - }) | 670 | + //----获取详情页的评价---- |
| 671 | + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 672 | + data: { | ||
| 673 | + store_id: os.stoid, | ||
| 674 | + goods_id: gid, | ||
| 675 | + pageSize: 3, | ||
| 676 | + parent_id: 0, | ||
| 677 | + page: 1, | ||
| 678 | + is_show: 1, | ||
| 679 | + }, | ||
| 680 | + }).then(res => { | ||
| 681 | + fir_com = res.data.data.pageData; | ||
| 682 | + }) | ||
| 619 | 683 | ||
| 620 | - //------获取评价的统计数量---- | ||
| 621 | - await getApp().request.promiseGet("/api/weshop/comment/countlist/", { | ||
| 622 | - data: { | ||
| 623 | - store_id: os.stoid, | ||
| 624 | - goods_id: gid | ||
| 625 | - }, | ||
| 626 | - //failRollback: !0, | 684 | + if (fir_com) { |
| 685 | + for (var ind in fir_com) { | ||
| 686 | + if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 687 | + if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | ||
| 688 | + if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | ||
| 689 | + } | ||
| 690 | + } | ||
| 627 | 691 | ||
| 628 | - }).then(res => { | ||
| 629 | - var t = res; | ||
| 630 | - var g = t.data.data[0]; | ||
| 631 | - if (g != null && g != undefined) { | ||
| 632 | - var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | ||
| 633 | - var num2 = g.c4 + g.c5; | ||
| 634 | - var num3 = g.c3; | ||
| 635 | - var num4 = g.c0 + g.c1 + g.c2; | ||
| 636 | - | ||
| 637 | - var dd = ee.data.categories3; | ||
| 638 | - dd[0].num = allnum; | ||
| 639 | - dd[1].num = g.cimg; | ||
| 640 | - dd[2].num = num2; | ||
| 641 | - dd[3].num = num3; | ||
| 642 | - dd[4].num = num4; | ||
| 643 | - | ||
| 644 | - categories3 = dd; | ||
| 645 | - } | ||
| 646 | - }) | 692 | + if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length <= 0)) { |
| 693 | + //----获取详情页的券的数量---- | ||
| 694 | + await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { | ||
| 695 | + data: { | ||
| 696 | + store_id: os.stoid, | ||
| 697 | + type: 1, | ||
| 698 | + pageSize: 3, | ||
| 699 | + page: 1, | ||
| 700 | + is_share: 0, | ||
| 701 | + }, | ||
| 702 | + }).then(res1 => { | ||
| 703 | + fir_quan = res1.data.data.pageData; | ||
| 704 | + }) | ||
| 705 | + } | ||
| 647 | 706 | ||
| 648 | - //----获取详情页的评价---- | ||
| 649 | - await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 650 | - data: { | ||
| 651 | - store_id: os.stoid, | ||
| 652 | - goods_id: gid, | ||
| 653 | - pageSize: 3, | ||
| 654 | - parent_id: 0, | ||
| 655 | - page: 1, | ||
| 656 | - is_show: 1, | ||
| 657 | - }, | ||
| 658 | - }).then(res => { | ||
| 659 | - fir_com = res.data.data.pageData; | ||
| 660 | - }) | 707 | + //--------获取视频图片--------- |
| 708 | + await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { | ||
| 709 | + 1: 1 | ||
| 710 | + }).then(res1 => { | ||
| 711 | + if (res1.data.code == 0) { | ||
| 712 | + mapurl = res1.data.data.video_url; | ||
| 713 | + mapurl_f_img = res1.data.data.video_img; | ||
| 714 | + } | ||
| 715 | + }) | ||
| 716 | + this.getHistoryBuy(); //获取历史购买 | ||
| 717 | + ee.setData({ | ||
| 718 | + gallery: gallery, | ||
| 719 | + is_collect: is_collect, | ||
| 720 | + collect_id: collect_id, | ||
| 721 | + categories3: categories3, | ||
| 722 | + fir_quan: fir_quan, | ||
| 723 | + fir_comments: fir_com, | ||
| 724 | + mapurl_f_img: mapurl_f_img, | ||
| 725 | + mapurl: mapurl, | ||
| 726 | + }); | ||
| 661 | 727 | ||
| 662 | - if (fir_com) { | ||
| 663 | - for (var ind in fir_com) { | ||
| 664 | - if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 665 | - if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | ||
| 666 | - if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | ||
| 667 | - } | ||
| 668 | - } | 728 | + }, |
| 669 | 729 | ||
| 670 | - if (th.data.is_closecoupon != 1 && (!th.data.fir_quan || th.data.fir_quan.length<=0)) { | ||
| 671 | - //----获取详情页的券的数量---- | ||
| 672 | - await getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", { | ||
| 673 | - data: { | ||
| 674 | - store_id: os.stoid, | ||
| 675 | - type: 1, | ||
| 676 | - pageSize: 3, | ||
| 677 | - page: 1, | ||
| 678 | - is_share: 0, | ||
| 679 | - }, | ||
| 680 | - }).then(res1 => { | ||
| 681 | - fir_quan = res1.data.data.pageData; | ||
| 682 | - }) | ||
| 683 | - } | 730 | + //---展示--- |
| 731 | + onShow: function () { | ||
| 732 | + var goods_list = null, th = this, that = this; | ||
| 733 | + var show_prew_img = this.data.show_prew_img | ||
| 734 | + if (show_prew_img) { | ||
| 735 | + show_prew_img = 0; | ||
| 736 | + return false; | ||
| 737 | + } | ||
| 684 | 738 | ||
| 685 | - //--------获取视频图片--------- | ||
| 686 | - await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { | ||
| 687 | - 1: 1 | ||
| 688 | - }).then(res1 => { | ||
| 689 | - if (res1.data.code == 0) { | ||
| 690 | - mapurl = res1.data.data.video_url; | ||
| 691 | - mapurl_f_img = res1.data.data.video_img; | ||
| 692 | - } | ||
| 693 | - }) | ||
| 694 | - this.getHistoryBuy(); //获取历史购买 | ||
| 695 | - ee.setData({ | ||
| 696 | - gallery: gallery, | ||
| 697 | - is_collect: is_collect, | ||
| 698 | - collect_id: collect_id, | ||
| 699 | - categories3: categories3, | ||
| 700 | - fir_quan: fir_quan, | ||
| 701 | - fir_comments: fir_com, | ||
| 702 | - mapurl_f_img: mapurl_f_img, | ||
| 703 | - mapurl: mapurl, | ||
| 704 | - }); | 739 | + //优惠券要实时更新 |
| 740 | + getApp().getConfig2(function (e) { | ||
| 741 | + var json_d = JSON.parse(e.switch_list); | ||
| 742 | + th.setData({is_closecoupon: json_d.is_closecoupon}) | ||
| 743 | + th.setData({is_open_offline: json_d.is_pricing_open}) | ||
| 744 | + }, 1) | ||
| 705 | 745 | ||
| 706 | - }, | ||
| 707 | 746 | ||
| 708 | - //---展示--- | ||
| 709 | - onShow: function () { | ||
| 710 | - var goods_list = null, th = this, that = this; | ||
| 711 | - this.data.is_go_to_team_show=0; | ||
| 712 | - var show_prew_img = this.data.show_prew_img | ||
| 713 | - if (show_prew_img) { | ||
| 714 | - show_prew_img = 0; | ||
| 715 | - return false; | ||
| 716 | - } | 747 | + var ui = setInterval(function () { |
| 748 | + goods_list = th.selectComponent("#goods_list"); | ||
| 749 | + if (goods_list) { | ||
| 750 | + clearInterval(ui); | ||
| 751 | + goods_list.init(); | ||
| 752 | + return false | ||
| 753 | + } | ||
| 754 | + }, 300) | ||
| 755 | + | ||
| 756 | + this.data.is_timer = 1; | ||
| 757 | + var ee = this, | ||
| 758 | + gid = this.data.gid, | ||
| 759 | + i = getApp().request; | ||
| 760 | + | ||
| 761 | + this.wait_for_store_config(); | ||
| 762 | + //先检验一下商品的活动情况 | ||
| 763 | + this.check_gd_prom_new(function () { | ||
| 764 | + i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { | ||
| 765 | + failRollback: !0, | ||
| 766 | + success: function (t) { | ||
| 767 | + console.log(t); | ||
| 768 | + if (t.data.code == 0) { | ||
| 769 | + if (t.data.data.is_on_sale != 1) { | ||
| 770 | + wx.showModal({ | ||
| 771 | + title: '商品已经下架', | ||
| 772 | + showCancel: !1, | ||
| 773 | + complete: function () { | ||
| 774 | + wx.navigateBack(); | ||
| 775 | + } | ||
| 776 | + }); | ||
| 777 | + } | ||
| 717 | 778 | ||
| 718 | - //优惠券要实时更新 | ||
| 719 | - getApp().getConfig2(function (e) { | ||
| 720 | - var json_d = JSON.parse(e.switch_list); | ||
| 721 | - th.setData({ is_closecoupon: json_d.is_closecoupon }) | ||
| 722 | - th.setData({ is_open_offline: json_d.is_pricing_open }) | ||
| 723 | - }, 1) | 779 | + var timestamp = Date.parse(new Date()); |
| 780 | + timestamp = timestamp / 1000; | ||
| 781 | + if (t.data.data.on_time > timestamp) { | ||
| 782 | + wx.showModal({ | ||
| 783 | + title: '商品还未上架', | ||
| 784 | + showCancel: !1, | ||
| 785 | + complete: function () { | ||
| 786 | + wx.navigateBack(); | ||
| 787 | + } | ||
| 788 | + }); | ||
| 789 | + } | ||
| 724 | 790 | ||
| 791 | + if (t.data.data.down_time > 0) { | ||
| 792 | + if (t.data.data.down_time < timestamp) { | ||
| 793 | + wx.showModal({ | ||
| 794 | + title: '商品已经到期下架', | ||
| 795 | + showCancel: !1, | ||
| 796 | + complete: function () { | ||
| 797 | + wx.navigateBack(); | ||
| 798 | + } | ||
| 799 | + }); | ||
| 800 | + } | ||
| 801 | + } | ||
| 802 | + //动态获取商品名称 | ||
| 803 | + wx.setNavigationBarTitle({ | ||
| 804 | + title: t.data.data.goods_name, | ||
| 805 | + }); | ||
| 725 | 806 | ||
| 726 | - var ui = setInterval(function () { | ||
| 727 | - goods_list = th.selectComponent("#goods_list"); | ||
| 728 | - if (goods_list) { | ||
| 729 | - clearInterval(ui); | ||
| 730 | - goods_list.init(); | ||
| 731 | - return false | ||
| 732 | - } | ||
| 733 | - }, 300) | ||
| 734 | - | ||
| 735 | - this.data.is_timer = 1; | ||
| 736 | - var ee = this, | ||
| 737 | - gid = this.data.gid, | ||
| 738 | - i = getApp().request; | ||
| 739 | - | ||
| 740 | - this.wait_for_store_config(); | ||
| 741 | - | ||
| 742 | - i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { | ||
| 743 | - failRollback: !0, | ||
| 744 | - success: function (t) { | ||
| 745 | - | ||
| 746 | - ee.data.viplimited_timetype = t.data.data.viplimited_timetype; | ||
| 747 | - if (t.data.code == 0) { | ||
| 748 | - if (t.data.data.is_on_sale != 1) { | ||
| 749 | - wx.showModal({ | ||
| 750 | - title: '商品已经下架', | ||
| 751 | - showCancel: !1, | ||
| 752 | - complete: function () { | ||
| 753 | - wx.navigateBack(); | ||
| 754 | - } | ||
| 755 | - }); | ||
| 756 | - } | ||
| 757 | - | ||
| 758 | - var timestamp = Date.parse(new Date()); | ||
| 759 | - timestamp = timestamp / 1000; | ||
| 760 | - if (t.data.data.on_time > timestamp) { | ||
| 761 | - wx.showModal({ | ||
| 762 | - title: '商品还未上架', | ||
| 763 | - showCancel: !1, | ||
| 764 | - complete: function () { | ||
| 765 | - wx.navigateBack(); | ||
| 766 | - } | ||
| 767 | - }); | ||
| 768 | - } | ||
| 769 | - | ||
| 770 | - if (t.data.data.down_time > 0) { | ||
| 771 | - if (t.data.data.down_time < timestamp) { | ||
| 772 | - wx.showModal({ | ||
| 773 | - title: '商品已经到期下架', | ||
| 774 | - showCancel: !1, | ||
| 775 | - complete: function () { | ||
| 776 | - wx.navigateBack(); | ||
| 777 | - } | ||
| 778 | - }); | ||
| 779 | - } | ||
| 780 | - } | ||
| 781 | - //动态获取商品名称 | ||
| 782 | - wx.setNavigationBarTitle({ | ||
| 783 | - title: t.data.data.goods_name, | ||
| 784 | - }); | ||
| 785 | - | ||
| 786 | - //-- 判断是不是组合购活动,必须要登录后才能判断 -- | ||
| 787 | - if (getApp().globalData.userInfo && t.data.data.prom_type == 7) { | ||
| 788 | - //获取活动信息 | ||
| 789 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + | ||
| 790 | - t.data.data.prom_id + "/" + getApp().globalData.user_id; | ||
| 791 | - getApp().request.get(url, { | ||
| 792 | - success: function (e) { | ||
| 793 | - if (e.data.code == 0 && e.data.data) { | ||
| 794 | - if (ut.gettimestamp() < e.data.data.start_time) { | ||
| 795 | - return false; | ||
| 796 | - } | ||
| 797 | - if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { | ||
| 798 | - //-- 获取商品列表 -- | ||
| 799 | - th.setData({ zh_act: e.data.data }); | ||
| 800 | - } | 807 | + //-- 判断是不是组合购活动,必须要登录后才能判断 -- |
| 808 | + if (getApp().globalData.userInfo && t.data.data.prom_type == 7) { | ||
| 809 | + //获取活动信息 | ||
| 810 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + | ||
| 811 | + t.data.data.prom_id + "/" + getApp().globalData.user_id; | ||
| 812 | + getApp().request.get(url, { | ||
| 813 | + success: function (e) { | ||
| 814 | + if (e.data.code == 0 && e.data.data) { | ||
| 815 | + if (ut.gettimestamp() < e.data.data.start_time) { | ||
| 816 | + return false; | ||
| 817 | + } | ||
| 818 | + if (e.data.data.is_end == 0 && ut.gettimestamp() < e.data.data.end_time) { | ||
| 819 | + //-- 获取商品列表 -- | ||
| 820 | + th.setData({zh_act: e.data.data}); | ||
| 821 | + } | ||
| 822 | + | ||
| 823 | + } | ||
| 824 | + } | ||
| 825 | + }); | ||
| 826 | + } | ||
| 801 | 827 | ||
| 802 | - } | ||
| 803 | - } | ||
| 804 | - }); | ||
| 805 | - } | 828 | + //-- 把商品的赋值,同时给活动赋值 -- |
| 829 | + ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); | ||
| 830 | + if (t.data.data.prom_type && t.data.data.prom_id) { | ||
| 831 | + ee.data.prom_type = t.data.data.prom_type; | ||
| 832 | + ee.data.prom_id = t.data.data.prom_id; | ||
| 833 | + } | ||
| 806 | 834 | ||
| 807 | - //-- 把商品的赋值,同时给活动赋值 -- | ||
| 808 | - ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data)); | ||
| 809 | - if(t.data.data.prom_type && t.data.data.prom_id){ | ||
| 810 | - ee.data.prom_type=t.data.data.prom_type; | ||
| 811 | - ee.data.prom_id=t.data.data.prom_id; | ||
| 812 | - } | ||
| 813 | 835 | ||
| 814 | - if(ee.data.prom_type!=1 && ee.data.prom_type!=4 && ee.data.prom_type!=6 && ee.data.prom_type!=2){ | ||
| 815 | - ee.check_is_youhui(ee.data.gid); | ||
| 816 | - } | 836 | + if (ee.data.prom_type != 1 && ee.data.prom_type != 4 && ee.data.prom_type != 6 && ee.data.prom_type != 2) { |
| 837 | + ee.check_is_youhui(ee.data.gid); | ||
| 838 | + } | ||
| 817 | 839 | ||
| 818 | - t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss'); | 840 | + t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss'); |
| 819 | 841 | ||
| 820 | - var cur_price = t.data.data.shop_price; | ||
| 821 | - if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 822 | - var cfile = getApp().globalData.userInfo.card_field; | ||
| 823 | - if (t.data.data[cfile]) { | ||
| 824 | - cur_price = t.data.data[cfile]; | ||
| 825 | - } | ||
| 826 | - } | ||
| 827 | - var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString(); | ||
| 828 | - txt = parseFloat(txt); | 842 | + var cur_price = t.data.data.shop_price; |
| 843 | + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 844 | + var cfile = getApp().globalData.userInfo.card_field; | ||
| 845 | + if (t.data.data[cfile]) { | ||
| 846 | + cur_price = t.data.data[cfile]; | ||
| 847 | + } | ||
| 848 | + } | ||
| 849 | + var txt = (cur_price / t.data.data.market_price * 10).toFixed(2).toString(); | ||
| 850 | + txt = parseFloat(txt); | ||
| 829 | 851 | ||
| 830 | - t.data.data['disc'] = txt; | 852 | + t.data.data['disc'] = txt; |
| 831 | 853 | ||
| 832 | - if (t.data.data.original_img.indexOf(o.imghost) == -1) | ||
| 833 | - t.data.data.original_img = o.imghost + t.data.data.original_img; | 854 | + if (t.data.data.original_img.indexOf(o.imghost) == -1) |
| 855 | + t.data.data.original_img = o.imghost + t.data.data.original_img; | ||
| 834 | 856 | ||
| 835 | - if (t.data.data.goods_content == null) t.data.data.goods_content = ""; | 857 | + if (t.data.data.goods_content == null) t.data.data.goods_content = ""; |
| 836 | 858 | ||
| 837 | - //-----商品详情--- | ||
| 838 | - if (!t.data.data.goods_content) t.data.data.goods_content = " "; | ||
| 839 | - a.wxParse("content", "html", t.data.data.goods_content, ee, 6); | ||
| 840 | - e.wxParseAddFullImageUrl(ee, "content"); | 859 | + //-----商品详情--- |
| 860 | + if (!t.data.data.goods_content) t.data.data.goods_content = " "; | ||
| 861 | + a.wxParse("content", "html", t.data.data.goods_content, ee, 6); | ||
| 862 | + e.wxParseAddFullImageUrl(ee, "content"); | ||
| 841 | 863 | ||
| 842 | - if(ee.data.prom_type){ | ||
| 843 | - t.data.data.prom_type=ee.data.prom_type; | ||
| 844 | - t.data.data.prom_id=ee.data.prom_id; | ||
| 845 | - } | ||
| 846 | - ee.setData({ | ||
| 847 | - data: t.data.data, | ||
| 848 | - sele_g: t.data.data, | ||
| 849 | - userInfo: getApp().globalData.userInfo | ||
| 850 | - }); | 864 | + if (ee.data.prom_type) { |
| 865 | + t.data.data.prom_type = ee.data.prom_type; | ||
| 866 | + t.data.data.prom_id = ee.data.prom_id; | ||
| 867 | + } | ||
| 868 | + ee.setData({ | ||
| 869 | + data: t.data.data, | ||
| 870 | + sele_g: t.data.data, | ||
| 871 | + userInfo: getApp().globalData.userInfo | ||
| 872 | + }); | ||
| 851 | 873 | ||
| 852 | 874 | ||
| 853 | - //获取统一条形码,普通商品和优惠促销的商品 | ||
| 854 | - if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) { | ||
| 855 | - //默认门店要拿下门店库存 | ||
| 856 | - if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { | ||
| 857 | - //获取门店 | ||
| 858 | - ee.get_sto(); | 875 | + //获取统一条形码,普通商品和优惠促销的商品 |
| 876 | + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) { | ||
| 877 | + //默认门店要拿下门店库存 | ||
| 878 | + if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { | ||
| 879 | + //获取门店 | ||
| 880 | + ee.get_sto(); | ||
| 859 | 881 | ||
| 860 | - } else { | ||
| 861 | - //获取门店 | ||
| 862 | - ee.get_sto(); | ||
| 863 | - } | 882 | + } else { |
| 883 | + //获取门店 | ||
| 884 | + ee.get_sto(); | ||
| 885 | + } | ||
| 864 | 886 | ||
| 865 | - ee.get_sku(o.stoid, t.data.data, gid); | ||
| 866 | - ee.check_has_flash(); | 887 | + ee.get_sku(o.stoid, t.data.data, gid); |
| 888 | + ee.check_has_flash(); | ||
| 867 | 889 | ||
| 868 | - } | ||
| 869 | - else { | ||
| 870 | - var gg = "", item = t.data.data; | 890 | + } |
| 891 | + else { | ||
| 892 | + var gg = "", item = t.data.data; | ||
| 871 | 893 | ||
| 872 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 873 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | 894 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; |
| 895 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 874 | 896 | ||
| 875 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 876 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 877 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 878 | - gg = item.goods_spec + item.goods_color; | ||
| 879 | - } else { | ||
| 880 | - gg = "规格1"; | ||
| 881 | - } | ||
| 882 | - t.data.data.gg = gg; | ||
| 883 | - var uu = []; | ||
| 884 | - uu.push(t.data.data); | ||
| 885 | - ee.setData({ | ||
| 886 | - sku_g: uu, | ||
| 887 | - }); | ||
| 888 | - } | ||
| 889 | - ee.data.g_buy_num = new Map(); | ||
| 890 | - ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); | 897 | + if (item.goods_spec != "" && item.goods_color != "") { |
| 898 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 899 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 900 | + gg = item.goods_spec + item.goods_color; | ||
| 901 | + } else { | ||
| 902 | + gg = "规格1"; | ||
| 903 | + } | ||
| 904 | + t.data.data.gg = gg; | ||
| 905 | + var uu = []; | ||
| 906 | + uu.push(t.data.data); | ||
| 907 | + ee.setData({ | ||
| 908 | + sku_g: uu, | ||
| 909 | + }); | ||
| 910 | + } | ||
| 911 | + ee.data.g_buy_num = new Map(); | ||
| 912 | + ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); | ||
| 913 | + | ||
| 914 | + var th = ee; | ||
| 915 | + if (ee.data.cat_name == '') { | ||
| 916 | + //过去国别,分类,品牌的名称 | ||
| 917 | + i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 918 | + success: function (t) { | ||
| 919 | + var dd = t.data.data; | ||
| 920 | + if (t.data.code == 0) { | ||
| 921 | + th.setData({ | ||
| 922 | + cat_name: dd.name | ||
| 923 | + }); | ||
| 924 | + } | ||
| 925 | + } | ||
| 926 | + }); | ||
| 927 | + //过去国别,分类,品牌的名称 | ||
| 928 | + i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 929 | + success: function (t) { | ||
| 930 | + var dd = t.data.data; | ||
| 931 | + if (t.data.code == 0) { | ||
| 932 | + th.setData({ | ||
| 933 | + brand_name: dd.name | ||
| 934 | + }); | ||
| 935 | + } | ||
| 936 | + } | ||
| 937 | + }); | ||
| 938 | + //过去国别,分类,品牌的名称 | ||
| 939 | + i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 940 | + success: function (t) { | ||
| 941 | + var dd = t.data.data; | ||
| 942 | + if (t.data.code == 0) { | ||
| 943 | + th.setData({ | ||
| 944 | + nation_name: dd.name | ||
| 945 | + }); | ||
| 946 | + } | ||
| 947 | + } | ||
| 948 | + }); | ||
| 949 | + } | ||
| 891 | 950 | ||
| 892 | - var th = ee; | ||
| 893 | - if (ee.data.cat_name == '') { | ||
| 894 | - //过去国别,分类,品牌的名称 | ||
| 895 | - i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 896 | - success: function (t) { | ||
| 897 | - var dd = t.data.data; | ||
| 898 | - if (t.data.code == 0) { | ||
| 899 | - th.setData({ | ||
| 900 | - cat_name: dd.name | ||
| 901 | - }); | ||
| 902 | - } | ||
| 903 | - } | ||
| 904 | - }); | ||
| 905 | - //过去国别,分类,品牌的名称 | ||
| 906 | - i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 907 | - success: function (t) { | ||
| 908 | - var dd = t.data.data; | ||
| 909 | - if (t.data.code == 0) { | ||
| 910 | - th.setData({ | ||
| 911 | - brand_name: dd.name | ||
| 912 | - }); | ||
| 913 | - } | ||
| 914 | - } | ||
| 915 | - }); | ||
| 916 | - //过去国别,分类,品牌的名称 | ||
| 917 | - i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 918 | - success: function (t) { | ||
| 919 | - var dd = t.data.data; | ||
| 920 | - if (t.data.code == 0) { | ||
| 921 | - th.setData({ | ||
| 922 | - nation_name: dd.name | ||
| 923 | - }); | 951 | + } |
| 952 | + else { | ||
| 953 | + wx.showModal({ | ||
| 954 | + title: t.data.msg, | ||
| 955 | + showCancel: !1, | ||
| 956 | + complete: function () { | ||
| 957 | + wx.navigateBack(); | ||
| 958 | + } | ||
| 959 | + }); | ||
| 960 | + } | ||
| 924 | } | 961 | } |
| 925 | - } | ||
| 926 | }); | 962 | }); |
| 927 | - } | 963 | + }) |
| 928 | 964 | ||
| 929 | - } | ||
| 930 | - else { | ||
| 931 | - wx.showModal({ | ||
| 932 | - title: t.data.msg, | ||
| 933 | - showCancel: !1, | ||
| 934 | - complete: function () { | ||
| 935 | - wx.navigateBack(); | ||
| 936 | - } | ||
| 937 | - }); | ||
| 938 | - } | ||
| 939 | - } | ||
| 940 | - }); | ||
| 941 | - this.data.enterAddressPage && (this.data.enterAddressPage = !1); | 965 | + this.data.enterAddressPage && (this.data.enterAddressPage = !1); |
| 942 | 966 | ||
| 943 | - }, | ||
| 944 | - enterAddress: function () { | ||
| 945 | - this.data.enterAddressPage = !0, wx.navigateTo({ | ||
| 946 | - url: "/pages/user/address_list/address_list?operate=selectAddress" | ||
| 947 | - }); | ||
| 948 | - }, | ||
| 949 | - onUnload: function () { | ||
| 950 | - for (var i = 1; i < 100; i++) { | ||
| 951 | - clearInterval(i); | ||
| 952 | - } | ||
| 953 | - }, | ||
| 954 | - onHide: function () { | ||
| 955 | - this.data.is_timer = 0; | ||
| 956 | - for (var i = 1; i < 100; i++) { | ||
| 957 | - clearInterval(i); | ||
| 958 | - } | ||
| 959 | - }, | ||
| 960 | - //----------三个选项按钮----------- | ||
| 961 | - tabClick: function (t) { | ||
| 962 | - var e = t.currentTarget.id; | ||
| 963 | - this.setData({ | ||
| 964 | - activeCategoryId: e | ||
| 965 | - }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | ||
| 966 | - }, | ||
| 967 | - tabClick2: function (t) { | ||
| 968 | - this.setData({ | ||
| 969 | - activeCategoryId2: t.currentTarget.id | ||
| 970 | - }); | ||
| 971 | - }, | ||
| 972 | - | ||
| 973 | - tabClick3: function (t) { | ||
| 974 | - var e = this; | ||
| 975 | - if (t.currentTarget.id != this.data.activeCategoryId3) { | ||
| 976 | - e.data.c_curr_p = 1; | ||
| 977 | - this.setData({ | ||
| 978 | - activeCategoryId3: t.currentTarget.id, | ||
| 979 | - comments: null, comments_no_more: 0, get_c: 0, | ||
| 980 | - }); | ||
| 981 | - this.requestComments_new(); | ||
| 982 | - } | ||
| 983 | - }, | ||
| 984 | - | ||
| 985 | - doScrollTop: function () { | ||
| 986 | - wx.pageScrollTo({ | ||
| 987 | - scrollTop: 0 | ||
| 988 | - }); | ||
| 989 | - }, | ||
| 990 | - | ||
| 991 | - tabComment: function () { | ||
| 992 | - this.setData({ | ||
| 993 | - activeCategoryId: 2, comments_no_more: 0, get_c: 0 | ||
| 994 | - }), this.data.comments || this.requestComments_new(); | ||
| 995 | - }, | ||
| 996 | - | ||
| 997 | - //商品详情的时候调用 | ||
| 998 | - tabGoodsContent: function () { | ||
| 999 | - var th = this, | ||
| 1000 | - i = getApp().request; | ||
| 1001 | - this.setData({ | ||
| 1002 | - activeCategoryId: 1 | ||
| 1003 | - }); | ||
| 1004 | - | ||
| 1005 | - if (th.data.cat_name == '') { | ||
| 1006 | - //过去国别,分类,品牌的名称 | ||
| 1007 | - i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 1008 | - success: function (t) { | ||
| 1009 | - var dd = t.data.data; | ||
| 1010 | - if (t.data.code == 0) { | ||
| 1011 | - th.setData({ | ||
| 1012 | - cat_name: dd.name | ||
| 1013 | - }); | ||
| 1014 | - } | ||
| 1015 | - } | ||
| 1016 | - }); | ||
| 1017 | - //过去国别,分类,品牌的名称 | ||
| 1018 | - i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 1019 | - success: function (t) { | ||
| 1020 | - var dd = t.data.data; | ||
| 1021 | - if (t.data.code == 0) { | ||
| 1022 | - th.setData({ | ||
| 1023 | - brand_name: dd.name | ||
| 1024 | - }); | ||
| 1025 | - } | 967 | + }, |
| 968 | + enterAddress: function () { | ||
| 969 | + this.data.enterAddressPage = !0, wx.navigateTo({ | ||
| 970 | + url: "/pages/user/address_list/address_list?operate=selectAddress" | ||
| 971 | + }); | ||
| 972 | + }, | ||
| 973 | + onUnload: function () { | ||
| 974 | + for (var i = 1; i < 100; i++) { | ||
| 975 | + clearInterval(i); | ||
| 1026 | } | 976 | } |
| 1027 | - }); | ||
| 1028 | - //过去国别,分类,品牌的名称 | ||
| 1029 | - i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 1030 | - success: function (t) { | ||
| 1031 | - var dd = t.data.data; | ||
| 1032 | - if (t.data.code == 0) { | ||
| 1033 | - th.setData({ | ||
| 1034 | - nation_name: dd.name | ||
| 1035 | - }); | ||
| 1036 | - } | 977 | + }, |
| 978 | + onHide: function () { | ||
| 979 | + this.data.is_timer = 0; | ||
| 980 | + for (var i = 1; i < 100; i++) { | ||
| 981 | + clearInterval(i); | ||
| 1037 | } | 982 | } |
| 1038 | - }); | ||
| 1039 | - } | ||
| 1040 | - }, | ||
| 1041 | - | ||
| 1042 | - //获取redis中的数量 | ||
| 1043 | - async getactLen(func) { | ||
| 1044 | - var r_num = 0, | ||
| 1045 | - prom_type = this.data.prom_type, | ||
| 1046 | - prom_id = this.data.prom_id; | ||
| 1047 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 1048 | - 1: 1 | ||
| 1049 | - }).then(res => { | ||
| 1050 | - var em = res; | ||
| 1051 | - if (em.data.code == 0) { | ||
| 1052 | - r_num = em.data.data; | ||
| 1053 | - } | ||
| 1054 | - }) | ||
| 1055 | - func(r_num); | ||
| 1056 | - }, | 983 | + }, |
| 984 | + //----------三个选项按钮----------- | ||
| 985 | + tabClick: function (t) { | ||
| 986 | + var e = t.currentTarget.id; | ||
| 987 | + this.setData({ | ||
| 988 | + activeCategoryId: e | ||
| 989 | + }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | ||
| 990 | + }, | ||
| 991 | + tabClick2: function (t) { | ||
| 992 | + this.setData({ | ||
| 993 | + activeCategoryId2: t.currentTarget.id | ||
| 994 | + }); | ||
| 995 | + }, | ||
| 1057 | 996 | ||
| 1058 | - //------------加入购物车-------------- | ||
| 1059 | - addCart: function (t) { | ||
| 1060 | - var th = this; | ||
| 1061 | - var ind = t.currentTarget.dataset.openSpecModal_ind; | ||
| 1062 | - if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | ||
| 1063 | - th.setData({ | ||
| 1064 | - open_ind_store: ind | ||
| 1065 | - }); | ||
| 1066 | - //如果是秒杀的话,要看redis够不够 | ||
| 1067 | - if (this.data.prom_type == 1 || this.data.prom_type == 2) { | ||
| 1068 | - this.getactLen(function (num) { | ||
| 1069 | - if (num < th.data.goodsInputNum) { | ||
| 1070 | - getApp().my_warnning("活动库存不足!", 0, th); | ||
| 1071 | - return false; | ||
| 1072 | - } else { | ||
| 1073 | - th.add_cart_func(t); | 997 | + tabClick3: function (t) { |
| 998 | + var e = this; | ||
| 999 | + if (t.currentTarget.id != this.data.activeCategoryId3) { | ||
| 1000 | + e.data.c_curr_p = 1; | ||
| 1001 | + this.setData({ | ||
| 1002 | + activeCategoryId3: t.currentTarget.id, | ||
| 1003 | + comments: null, comments_no_more: 0, get_c: 0, | ||
| 1004 | + }); | ||
| 1005 | + this.requestComments_new(); | ||
| 1074 | } | 1006 | } |
| 1075 | - }); | ||
| 1076 | - } else { | ||
| 1077 | - th.add_cart_func(t); | ||
| 1078 | - } | ||
| 1079 | - }, | 1007 | + }, |
| 1080 | 1008 | ||
| 1081 | - //-- 加入购物的函数 -- | ||
| 1082 | - add_cart_func_inte: function (t) { | ||
| 1083 | - var i = getApp().request; | ||
| 1084 | - if (oo.user_id == null) { | ||
| 1085 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1086 | - } | ||
| 1087 | - if (!getApp().globalData.userInfo) { | ||
| 1088 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1089 | - } | 1009 | + doScrollTop: function () { |
| 1010 | + wx.pageScrollTo({ | ||
| 1011 | + scrollTop: 0 | ||
| 1012 | + }); | ||
| 1013 | + }, | ||
| 1090 | 1014 | ||
| 1091 | - var e = this, | ||
| 1092 | - th = e, | ||
| 1093 | - a = 0, | ||
| 1094 | - o = this.data.data; | ||
| 1095 | - a = o.goods_id; | ||
| 1096 | - | ||
| 1097 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 1098 | - e.get_buy_num(o, function (ee) { | ||
| 1099 | - //---判断商品是否超出限购--- | ||
| 1100 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1101 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1102 | - wx.showModal({ | ||
| 1103 | - title: '提示', | ||
| 1104 | - content: '超出商品限购' | ||
| 1105 | - }); | ||
| 1106 | - return false; | ||
| 1107 | - } | ||
| 1108 | - } | ||
| 1109 | - //---判断商品是否超出活动限购--- | ||
| 1110 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1111 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1112 | - wx.showModal({ | ||
| 1113 | - title: '提示', | ||
| 1114 | - content: '超出商品活动限购' | ||
| 1115 | - }); | ||
| 1116 | - return false; | ||
| 1117 | - } | ||
| 1118 | - } | 1015 | + tabComment: function () { |
| 1016 | + this.setData({ | ||
| 1017 | + activeCategoryId: 2, comments_no_more: 0, get_c: 0 | ||
| 1018 | + }), this.data.comments || this.requestComments_new(); | ||
| 1019 | + }, | ||
| 1119 | 1020 | ||
| 1120 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1121 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | 1021 | + //商品详情的时候调用 |
| 1022 | + tabGoodsContent: function () { | ||
| 1023 | + var th = this, | ||
| 1024 | + i = getApp().request; | ||
| 1122 | this.setData({ | 1025 | this.setData({ |
| 1123 | - sto_sele_name: "" | 1026 | + activeCategoryId: 1 |
| 1124 | }); | 1027 | }); |
| 1125 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1126 | - | ||
| 1127 | - //--------------此时操作的数据------------ | ||
| 1128 | - var newd = { | ||
| 1129 | - goods_id: o.goods_id, | ||
| 1130 | - goods_num: th.data.goodsInputNum, | ||
| 1131 | - pick_id: th.data.sto_sele_id, | ||
| 1132 | - user_id: oo.user_id, | ||
| 1133 | - store_id: th.data.stoid, | ||
| 1134 | - goods_price: th.data.prom_price, | ||
| 1135 | - integral: th.data.prom_integral, | ||
| 1136 | - member_goods_price: o.shop_price, | ||
| 1137 | - goods_name: o.goods_name, | ||
| 1138 | - goods_sn: o.goods_sn, | ||
| 1139 | - sku: o.sku, | ||
| 1140 | - }; | ||
| 1141 | - | ||
| 1142 | - //---是不是从收藏夹出来的--- | ||
| 1143 | - if (th.data.c_guide_id) { | ||
| 1144 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 1145 | - newd['guide_type'] = 2; | ||
| 1146 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1147 | - } else { | ||
| 1148 | - if (getApp().globalData.guide_id) { | ||
| 1149 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1150 | - newd['guide_type'] = 0; | ||
| 1151 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1152 | - } | ||
| 1153 | - } | ||
| 1154 | 1028 | ||
| 1155 | - //让商品带上房间号 | ||
| 1156 | - //让商品带上房间号 | ||
| 1157 | - if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1158 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1159 | - newd.room_id = getApp().globalData.room_id; | 1029 | + if (th.data.cat_name == '') { |
| 1030 | + //过去国别,分类,品牌的名称 | ||
| 1031 | + i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { | ||
| 1032 | + success: function (t) { | ||
| 1033 | + var dd = t.data.data; | ||
| 1034 | + if (t.data.code == 0) { | ||
| 1035 | + th.setData({ | ||
| 1036 | + cat_name: dd.name | ||
| 1037 | + }); | ||
| 1038 | + } | ||
| 1039 | + } | ||
| 1040 | + }); | ||
| 1041 | + //过去国别,分类,品牌的名称 | ||
| 1042 | + i.get("/api/weshop/brand/get/" + o.stoid + "/" + th.data.data.brand_id, { | ||
| 1043 | + success: function (t) { | ||
| 1044 | + var dd = t.data.data; | ||
| 1045 | + if (t.data.code == 0) { | ||
| 1046 | + th.setData({ | ||
| 1047 | + brand_name: dd.name | ||
| 1048 | + }); | ||
| 1049 | + } | ||
| 1050 | + } | ||
| 1051 | + }); | ||
| 1052 | + //过去国别,分类,品牌的名称 | ||
| 1053 | + i.get("/api/weshop/nation/get/" + o.stoid + "/" + th.data.data.nation_id, { | ||
| 1054 | + success: function (t) { | ||
| 1055 | + var dd = t.data.data; | ||
| 1056 | + if (t.data.code == 0) { | ||
| 1057 | + th.setData({ | ||
| 1058 | + nation_name: dd.name | ||
| 1059 | + }); | ||
| 1060 | + } | ||
| 1061 | + } | ||
| 1062 | + }); | ||
| 1160 | } | 1063 | } |
| 1161 | - } else { | ||
| 1162 | - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1163 | - } | 1064 | + }, |
| 1164 | 1065 | ||
| 1165 | - //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1166 | - //if(o.prom_type==4){ | ||
| 1167 | - //newd.is_integral_normal=1; | ||
| 1168 | - //} | 1066 | + //获取redis中的数量 |
| 1067 | + async getactLen(func) { | ||
| 1068 | + var r_num = 0, | ||
| 1069 | + prom_type = this.data.prom_type, | ||
| 1070 | + prom_id = this.data.prom_id; | ||
| 1071 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 1072 | + 1: 1 | ||
| 1073 | + }).then(res => { | ||
| 1074 | + var em = res; | ||
| 1075 | + if (em.data.code == 0) { | ||
| 1076 | + r_num = em.data.data; | ||
| 1077 | + } | ||
| 1078 | + }) | ||
| 1079 | + func(r_num); | ||
| 1080 | + }, | ||
| 1169 | 1081 | ||
| 1170 | - //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1171 | - newd.prom_type = th.data.prom_type; | ||
| 1172 | - newd.prom_id = th.data.prom_id; | ||
| 1173 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1174 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | 1082 | + //------------加入购物车-------------- |
| 1083 | + addCart: function (t) { | ||
| 1084 | + var th = this; | ||
| 1085 | + var ind = t.currentTarget.dataset.openSpecModal_ind; | ||
| 1086 | + if (!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | ||
| 1087 | + th.setData({ | ||
| 1088 | + open_ind_store: ind | ||
| 1089 | + }); | ||
| 1175 | 1090 | ||
| 1176 | - var i_canbuy=th.data.prom_act.limitqty-th.data.prom_act.buy_num; | ||
| 1177 | - if(i_canbuy<e.data.goodsInputNum){ | ||
| 1178 | - return s.my_warnning("活动库存不足!", 0, th); | ||
| 1179 | - } | ||
| 1180 | - th.add_cart_next(e, t, a, o, newd); //立即购买下一步 | ||
| 1181 | 1091 | ||
| 1182 | - }) | ||
| 1183 | - }, | 1092 | + //如果是秒杀的话,要看redis够不够 |
| 1093 | + if (this.data.prom_type == 1 || this.data.prom_type == 2) { | ||
| 1184 | 1094 | ||
| 1185 | - //-- 加入购物的函数 -- | ||
| 1186 | - add_cart_func: function (t) { | ||
| 1187 | - var i = getApp().request; | ||
| 1188 | - if (oo.user_id == null) { | ||
| 1189 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1190 | - } | 1095 | + if (this.data.openSpecModal_flash_normal) { |
| 1096 | + th.add_cart_func(t); | ||
| 1097 | + return false; | ||
| 1098 | + } | ||
| 1191 | 1099 | ||
| 1192 | - if (!getApp().globalData.userInfo) { | ||
| 1193 | - return s.my_warnning("还未登录!", 0, this); | ||
| 1194 | - } | ||
| 1195 | 1100 | ||
| 1196 | - var e = this, | ||
| 1197 | - th = e, | ||
| 1198 | - a = 0, | ||
| 1199 | - o = this.data.sele_g; | ||
| 1200 | - a = o.goods_id; | ||
| 1201 | - | ||
| 1202 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 1203 | - e.get_buy_num(o, function (ee) { | ||
| 1204 | - //---判断商品是否超出限购--- | ||
| 1205 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1206 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1207 | - wx.showModal({ | ||
| 1208 | - title: '提示', | ||
| 1209 | - content: '超出商品限购' | ||
| 1210 | - }); | ||
| 1211 | - return false; | ||
| 1212 | - } | ||
| 1213 | - } | ||
| 1214 | - //---判断商品是否超出活动限购--- | ||
| 1215 | - if((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { | ||
| 1216 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1217 | - wx.showModal({ | ||
| 1218 | - title: '提示', | ||
| 1219 | - content: '超出商品活动限购' | ||
| 1220 | - }); | ||
| 1221 | - return false; | 1101 | + this.getactLen(function (num) { |
| 1102 | + if (num < th.data.goodsInputNum) { | ||
| 1103 | + getApp().my_warnning("活动库存不足!", 0, th); | ||
| 1104 | + return false; | ||
| 1105 | + } else { | ||
| 1106 | + th.add_cart_func(t); | ||
| 1107 | + } | ||
| 1108 | + }); | ||
| 1109 | + } else { | ||
| 1110 | + th.add_cart_func(t); | ||
| 1222 | } | 1111 | } |
| 1223 | - } | 1112 | + }, |
| 1224 | 1113 | ||
| 1225 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 1226 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1227 | - this.setData({ | ||
| 1228 | - sto_sele_name: "" | ||
| 1229 | - }); | ||
| 1230 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1231 | - | ||
| 1232 | - //--------------此时操作的数据------------ | ||
| 1233 | - var newd = { | ||
| 1234 | - goods_id: o.goods_id, | ||
| 1235 | - goods_num: th.data.goodsInputNum, | ||
| 1236 | - pick_id: th.data.sto_sele_id, | ||
| 1237 | - user_id: oo.user_id, | ||
| 1238 | - store_id: th.data.stoid, | ||
| 1239 | - goods_price: o.shop_price, | ||
| 1240 | - member_goods_price: o.shop_price, | ||
| 1241 | - goods_name: o.goods_name, | ||
| 1242 | - goods_sn: o.goods_sn, | ||
| 1243 | - sku: o.sku, | ||
| 1244 | - prom_id:th.data.sele_g.prom_id, | ||
| 1245 | - prom_type:th.data.sele_g.prom_type, | ||
| 1246 | - }; | ||
| 1247 | - | ||
| 1248 | - //---是不是从收藏夹出来的--- | ||
| 1249 | - if (th.data.c_guide_id) { | ||
| 1250 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 1251 | - newd['guide_type'] = 2; | ||
| 1252 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1253 | - } else { | ||
| 1254 | - if (getApp().globalData.guide_id) { | ||
| 1255 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1256 | - newd['guide_type'] = 0; | ||
| 1257 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | 1114 | + //-- 加入购物的函数 -- |
| 1115 | + add_cart_func_inte: function (t) { | ||
| 1116 | + var i = getApp().request; | ||
| 1117 | + if (oo.user_id == null) { | ||
| 1118 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1258 | } | 1119 | } |
| 1259 | - } | ||
| 1260 | - | ||
| 1261 | - //让商品带上房间号 | ||
| 1262 | - //让商品带上房间号 | ||
| 1263 | - if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1264 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1265 | - newd.room_id = getApp().globalData.room_id; | 1120 | + if (!getApp().globalData.userInfo) { |
| 1121 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1266 | } | 1122 | } |
| 1267 | - } else { | ||
| 1268 | - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1269 | - } | ||
| 1270 | 1123 | ||
| 1271 | - //如果是积分够,is_integral_normal就要有积分购普通购买字段 | ||
| 1272 | - if (o.prom_type == 4) { | ||
| 1273 | - newd.is_integral_normal = 1; | ||
| 1274 | - } | 1124 | + var e = this, |
| 1125 | + th = e, | ||
| 1126 | + a = 0, | ||
| 1127 | + o = this.data.data; | ||
| 1128 | + a = o.goods_id; | ||
| 1129 | + | ||
| 1130 | + //----------添加到购物车时,要判断限购数量,-------- | ||
| 1131 | + e.get_buy_num(o, function (ee) { | ||
| 1132 | + //---判断商品是否超出限购--- | ||
| 1133 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1134 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1135 | + wx.showModal({ | ||
| 1136 | + title: '提示', | ||
| 1137 | + content: '超出商品限购' | ||
| 1138 | + }); | ||
| 1139 | + return false; | ||
| 1140 | + } | ||
| 1141 | + } | ||
| 1142 | + //---判断商品是否超出活动限购--- | ||
| 1143 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1144 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1145 | + wx.showModal({ | ||
| 1146 | + title: '提示', | ||
| 1147 | + content: '超出商品活动限购' | ||
| 1148 | + }); | ||
| 1149 | + return false; | ||
| 1150 | + } | ||
| 1151 | + } | ||
| 1275 | 1152 | ||
| 1276 | - //如果有线下取价 | ||
| 1277 | - if (o.offline_price) { | ||
| 1278 | - newd.offline_price = o.offline_price; | ||
| 1279 | - newd.pricing_type = o.pricing_type; | ||
| 1280 | - } | 1153 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); |
| 1154 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1155 | + this.setData({ | ||
| 1156 | + sto_sele_name: "" | ||
| 1157 | + }); | ||
| 1158 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1281 | 1159 | ||
| 1282 | - //-----如果是秒杀,团购,积分购,拼团----- | ||
| 1283 | - if (th.data.prom_type == 1 || th.data.prom_type == 2) { | ||
| 1284 | - newd.goods_price = th.data.prom_price; | ||
| 1285 | - newd.member_goods_price = th.data.prom_price, | ||
| 1286 | - newd.prom_type = th.data.prom_type; | ||
| 1287 | - newd.prom_id = th.data.prom_id; | 1160 | + //--------------此时操作的数据------------ |
| 1161 | + var newd = { | ||
| 1162 | + goods_id: o.goods_id, | ||
| 1163 | + goods_num: th.data.goodsInputNum, | ||
| 1164 | + pick_id: th.data.sto_sele_id, | ||
| 1165 | + user_id: oo.user_id, | ||
| 1166 | + store_id: th.data.stoid, | ||
| 1167 | + goods_price: th.data.prom_price, | ||
| 1168 | + integral: th.data.prom_integral, | ||
| 1169 | + member_goods_price: o.shop_price, | ||
| 1170 | + goods_name: o.goods_name, | ||
| 1171 | + goods_sn: o.goods_sn, | ||
| 1172 | + sku: o.sku, | ||
| 1173 | + }; | ||
| 1288 | 1174 | ||
| 1289 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1290 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | 1175 | + //---是不是从收藏夹出来的--- |
| 1176 | + if (th.data.c_guide_id) { | ||
| 1177 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 1178 | + newd['guide_type'] = 2; | ||
| 1179 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1180 | + } else { | ||
| 1181 | + if (getApp().globalData.guide_id) { | ||
| 1182 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1183 | + newd['guide_type'] = 0; | ||
| 1184 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1185 | + } | ||
| 1186 | + } | ||
| 1291 | 1187 | ||
| 1292 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | 1188 | + //让商品带上房间号 |
| 1189 | + //让商品带上房间号 | ||
| 1190 | + if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1191 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1192 | + newd.room_id = getApp().globalData.room_id; | ||
| 1193 | + } | ||
| 1194 | + } else { | ||
| 1195 | + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1196 | + } | ||
| 1293 | 1197 | ||
| 1294 | - } else if (o.prom_type == 7) { | 1198 | + //如果是积分够,is_integral_normal就要有积分购普通购买字段 |
| 1199 | + //if(o.prom_type==4){ | ||
| 1200 | + //newd.is_integral_normal=1; | ||
| 1201 | + //} | ||
| 1295 | 1202 | ||
| 1296 | - //判断进行中的活动,是不是要判断线下库存 | ||
| 1297 | - th.check_zh_acting(function (ee) { | ||
| 1298 | - newd.prom_id = 0; | ||
| 1299 | - newd.prom_type = 0; | ||
| 1300 | - if (ee && th.data.sele_g.act) { | ||
| 1301 | - newd.prom_id = th.data.sele_g.act.id; | ||
| 1302 | - newd.prom_type = 7; | 1203 | + //-----如果是秒杀,团购,积分购,拼团----- |
| 1204 | + newd.prom_type = th.data.prom_type; | ||
| 1205 | + newd.prom_id = th.data.prom_id; | ||
| 1303 | if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | 1206 | if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); |
| 1304 | if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | 1207 | if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); |
| 1305 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1306 | - return false; | ||
| 1307 | - } else { | ||
| 1308 | - //---如果是线下门店销售的时候--- | ||
| 1309 | - if (th.data.sales_rules == 2) { | ||
| 1310 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1311 | - //---通过接口获取门店的线下库存信息-- | ||
| 1312 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1313 | - data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | ||
| 1314 | - success: function (res) { | ||
| 1315 | - if (res.data.code == 0) { | ||
| 1316 | - if (res.data.data.pageData.length > 0) { | ||
| 1317 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1318 | - if (CanOutQty < e.data.goodsInputNum) { | ||
| 1319 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1320 | - } | ||
| 1321 | - //在调一次接口,读取商品的预出库的数量,lock | ||
| 1322 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1323 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | ||
| 1324 | - success: function (res_data) { | ||
| 1325 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1326 | - | ||
| 1327 | - var lock = 0; | ||
| 1328 | - for (var i in res_data.data.data.pageData) { | ||
| 1329 | - lock += res_data.data.data.pageData[i].outQty; | ||
| 1330 | - } | ||
| 1331 | - | ||
| 1332 | - if (CanOutQty <= lock) { | ||
| 1333 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1334 | - } | ||
| 1335 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1336 | - } else { | ||
| 1337 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1338 | - } | ||
| 1339 | - } | ||
| 1340 | - }) | ||
| 1341 | - } else { | ||
| 1342 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1343 | - } | ||
| 1344 | 1208 | ||
| 1345 | - } | ||
| 1346 | - } | ||
| 1347 | - }) | ||
| 1348 | - } else { | ||
| 1349 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1350 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1351 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | 1209 | + var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; |
| 1210 | + if (i_canbuy < e.data.goodsInputNum) { | ||
| 1211 | + return s.my_warnning("活动库存不足!", 0, th); | ||
| 1352 | } | 1212 | } |
| 1353 | - } | 1213 | + th.add_cart_next(e, t, a, o, newd); //立即购买下一步 |
| 1214 | + | ||
| 1354 | }) | 1215 | }) |
| 1216 | + }, | ||
| 1355 | 1217 | ||
| 1356 | - } | ||
| 1357 | - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type==10) { | ||
| 1358 | - newd.prom_type = 0; | ||
| 1359 | - newd.prom_id = 0; | ||
| 1360 | - | ||
| 1361 | - if(th.data.prom_type == 10){ | ||
| 1362 | - newd.prom_type = th.data.prom_type; | ||
| 1363 | - newd.prom_id = th.data.prom_id; | ||
| 1364 | - } | ||
| 1365 | - | ||
| 1366 | - //---如果是线下门店销售的时候--- | ||
| 1367 | - if (th.data.sales_rules == 2) { | ||
| 1368 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1369 | - //---通过接口获取门店的线下库存信息-- | ||
| 1370 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1371 | - data: { storageNos: pick.pickup_no, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid }, | ||
| 1372 | - success: function (res) { | ||
| 1373 | - if (res.data.code == 0) { | ||
| 1374 | - if (res.data.data.pageData.length > 0) { | ||
| 1375 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1376 | - if (CanOutQty < e.data.goodsInputNum) { | ||
| 1377 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1378 | - } | ||
| 1379 | - //在调一次接口,读取商品的预出库的数量,lock | ||
| 1380 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1381 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, storageId: pick.pickup_id, pageSize: 1000 }, | ||
| 1382 | - success: function (res_data) { | ||
| 1383 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1384 | - | ||
| 1385 | - var lock = 0; | ||
| 1386 | - for (var i in res_data.data.data.pageData) { | ||
| 1387 | - lock += res_data.data.data.pageData[i].outQty; | ||
| 1388 | - } | 1218 | + //-- 加入购物的函数 -- |
| 1219 | + add_cart_func: function (t) { | ||
| 1220 | + var i = getApp().request; | ||
| 1221 | + if (oo.user_id == null) { | ||
| 1222 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1223 | + } | ||
| 1389 | 1224 | ||
| 1390 | - if (CanOutQty <= lock) { | ||
| 1391 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1392 | - } | ||
| 1393 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1394 | - } else { | ||
| 1395 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1396 | - } | ||
| 1397 | - } | ||
| 1398 | - }) | ||
| 1399 | - } else { | ||
| 1400 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1401 | - } | 1225 | + if (!getApp().globalData.userInfo) { |
| 1226 | + return s.my_warnning("还未登录!", 0, this); | ||
| 1227 | + } | ||
| 1402 | 1228 | ||
| 1403 | - } | 1229 | + var e = this, |
| 1230 | + th = e, | ||
| 1231 | + a = 0, | ||
| 1232 | + o = this.data.sele_g; | ||
| 1233 | + a = o.goods_id; | ||
| 1234 | + | ||
| 1235 | + //----------添加到购物车时,要判断限购数量,-------- | ||
| 1236 | + e.get_buy_num(o, function (ee) { | ||
| 1237 | + //---判断商品是否超出限购--- | ||
| 1238 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1239 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 1240 | + wx.showModal({ | ||
| 1241 | + title: '提示', | ||
| 1242 | + content: '超出商品限购' | ||
| 1243 | + }); | ||
| 1244 | + return false; | ||
| 1245 | + } | ||
| 1246 | + } | ||
| 1247 | + //---判断商品是否超出活动限购--- | ||
| 1248 | + if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { | ||
| 1249 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1250 | + wx.showModal({ | ||
| 1251 | + title: '提示', | ||
| 1252 | + content: '超出商品活动限购' | ||
| 1253 | + }); | ||
| 1254 | + return false; | ||
| 1255 | + } | ||
| 1404 | } | 1256 | } |
| 1405 | - }) | ||
| 1406 | - } else { | ||
| 1407 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1408 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1409 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1410 | - } | ||
| 1411 | - } | ||
| 1412 | - }) | ||
| 1413 | - }, | ||
| 1414 | 1257 | ||
| 1415 | - //---加入购物车的最后一步--- | ||
| 1416 | - add_cart_next(e, t, a, o, newd, CanOutQty) { | ||
| 1417 | - var th = this, i = getApp().request; | ||
| 1418 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 1419 | - if ((o.prom_type != 1 || o.prom_id<=0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type !=2 ) || th.data.is_normal)) { | ||
| 1420 | - var conf = th.data.bconfig; | ||
| 1421 | - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | ||
| 1422 | - var s_list = JSON.parse(conf.switch_list); | ||
| 1423 | - var now = ut.gettimestamp(); | 1258 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); |
| 1259 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 1260 | + this.setData({ | ||
| 1261 | + sto_sele_name: "" | ||
| 1262 | + }); | ||
| 1263 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 1424 | 1264 | ||
| 1265 | + //--------------此时操作的数据------------ | ||
| 1266 | + var newd = { | ||
| 1267 | + goods_id: o.goods_id, | ||
| 1268 | + goods_num: th.data.goodsInputNum, | ||
| 1269 | + pick_id: th.data.sto_sele_id, | ||
| 1270 | + user_id: oo.user_id, | ||
| 1271 | + store_id: th.data.stoid, | ||
| 1272 | + goods_price: o.shop_price, | ||
| 1273 | + member_goods_price: o.shop_price, | ||
| 1274 | + goods_name: o.goods_name, | ||
| 1275 | + goods_sn: o.goods_sn, | ||
| 1276 | + sku: o.sku, | ||
| 1277 | + prom_id: th.data.sele_g.prom_id, | ||
| 1278 | + prom_type: th.data.sele_g.prom_type, | ||
| 1279 | + }; | ||
| 1425 | 1280 | ||
| 1426 | - var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | ||
| 1427 | - var end = new Date(str); | ||
| 1428 | - end = Date.parse(end) / 1000; | 1281 | + //---是不是从收藏夹出来的--- |
| 1282 | + if (th.data.c_guide_id) { | ||
| 1283 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 1284 | + newd['guide_type'] = 2; | ||
| 1285 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | ||
| 1286 | + } else { | ||
| 1287 | + if (getApp().globalData.guide_id) { | ||
| 1288 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 1289 | + newd['guide_type'] = 0; | ||
| 1290 | + if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | ||
| 1291 | + } | ||
| 1292 | + } | ||
| 1429 | 1293 | ||
| 1430 | - //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- | ||
| 1431 | - if (parseInt(s_list.rank_switch) == 2 && end > now) { | ||
| 1432 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 1433 | - //如果会员有等级价 | ||
| 1434 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 1435 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 1436 | - newd.goods_price = card_price; | ||
| 1437 | - newd.member_goods_price = card_price; | ||
| 1438 | - } | ||
| 1439 | - } | ||
| 1440 | - } | ||
| 1441 | - } | 1294 | + //让商品带上房间号 |
| 1295 | + //让商品带上房间号 | ||
| 1296 | + if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 1297 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 1298 | + newd.room_id = getApp().globalData.room_id; | ||
| 1299 | + } | ||
| 1300 | + } else { | ||
| 1301 | + if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | ||
| 1302 | + } | ||
| 1442 | 1303 | ||
| 1443 | - //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); | ||
| 1444 | - if ("add" == t.currentTarget.dataset.action) { | 1304 | + //如果是积分够,is_integral_normal就要有积分购普通购买字段 |
| 1305 | + if (o.prom_type == 4) { | ||
| 1306 | + newd.is_integral_normal = 1; | ||
| 1307 | + } | ||
| 1445 | 1308 | ||
| 1446 | - if (th.data.prom_goods) { | ||
| 1447 | - newd.prom_type = 3; | ||
| 1448 | - newd.prom_id = th.data.prom_goods[0].prom_id; | ||
| 1449 | - } | 1309 | + //如果有线下取价 |
| 1310 | + if (o.offline_price) { | ||
| 1311 | + newd.offline_price = o.offline_price; | ||
| 1312 | + newd.pricing_type = o.pricing_type; | ||
| 1313 | + } | ||
| 1450 | 1314 | ||
| 1451 | - //----先看会员在购物车中是否加入了该商品----- | ||
| 1452 | - i.get("/api/weshop/cart/page", { | ||
| 1453 | - data: { | ||
| 1454 | - store_id: e.data.stoid, | ||
| 1455 | - user_id: oo.user_id, | ||
| 1456 | - goods_id: a, | ||
| 1457 | - pick_id: e.data.sto_sele_id, | ||
| 1458 | - state:0 | ||
| 1459 | - }, | ||
| 1460 | - success: function (re) { | 1315 | + //-----如果是秒杀,团购,积分购,拼团----- |
| 1316 | + if (th.data.prom_type == 1 || th.data.prom_type == 2) { | ||
| 1317 | + | ||
| 1318 | + if (th.data.openSpecModal_flash_normal) { | ||
| 1319 | + | ||
| 1320 | + newd.prom_type = 0; | ||
| 1321 | + newd.prom_id = 0; | ||
| 1322 | + | ||
| 1323 | + //---如果是线下门店销售的时候--- | ||
| 1324 | + if (th.data.sales_rules == 2) { | ||
| 1325 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1326 | + //---通过接口获取门店的线下库存信息-- | ||
| 1327 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1328 | + data: { | ||
| 1329 | + storageNos: pick.pickup_no, | ||
| 1330 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1331 | + storeId: os.stoid | ||
| 1332 | + }, | ||
| 1333 | + success: function (res) { | ||
| 1334 | + if (res.data.code == 0) { | ||
| 1335 | + if (res.data.data.pageData.length > 0) { | ||
| 1336 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1337 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1338 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1339 | + } | ||
| 1340 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1341 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1342 | + data: { | ||
| 1343 | + store_id: os.stoid, | ||
| 1344 | + wareId: th.data.sele_g.goods_id, | ||
| 1345 | + storageId: pick.pickup_id, | ||
| 1346 | + pageSize: 1000 | ||
| 1347 | + }, | ||
| 1348 | + success: function (res_data) { | ||
| 1349 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1350 | + | ||
| 1351 | + var lock = 0; | ||
| 1352 | + for (var i in res_data.data.data.pageData) { | ||
| 1353 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1354 | + } | ||
| 1355 | + | ||
| 1356 | + if (CanOutQty <= lock) { | ||
| 1357 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1358 | + } | ||
| 1359 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1360 | + } else { | ||
| 1361 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1362 | + } | ||
| 1363 | + } | ||
| 1364 | + }) | ||
| 1365 | + } else { | ||
| 1366 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1367 | + } | ||
| 1368 | + | ||
| 1369 | + } | ||
| 1370 | + } | ||
| 1371 | + }) | ||
| 1372 | + } else { | ||
| 1373 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1374 | + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1375 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1376 | + } | ||
| 1461 | 1377 | ||
| 1462 | - //-------如果购物车中有相关的数据--------- | ||
| 1463 | - if (re.data.data.total > 0) { | 1378 | + return false; |
| 1379 | + } | ||
| 1464 | 1380 | ||
| 1465 | - var item = re.data.data.pageData[0]; | ||
| 1466 | 1381 | ||
| 1467 | - //判断数量,要看下购物车中有没有该商品 | ||
| 1468 | - if (CanOutQty) { | ||
| 1469 | - if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | ||
| 1470 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1471 | - } | ||
| 1472 | - } else { | ||
| 1473 | - if (item.goods_num + th.data.goodsInputNum > o.store_count) { | ||
| 1474 | - return s.my_warnning("库存不足!", 0, th); | ||
| 1475 | - } | ||
| 1476 | - } | 1382 | + newd.goods_price = th.data.prom_price; |
| 1383 | + newd.member_goods_price = th.data.prom_price, | ||
| 1384 | + newd.prom_type = th.data.prom_type; | ||
| 1385 | + newd.prom_id = th.data.prom_id; | ||
| 1477 | 1386 | ||
| 1478 | - var updata = { | ||
| 1479 | - id: item.id, | ||
| 1480 | - goods_num: e.data.goodsInputNum + item.goods_num, | ||
| 1481 | - goods_price: newd.goods_price, | ||
| 1482 | - member_goods_price: newd.goods_price, | ||
| 1483 | - store_id: th.data.stoid, | ||
| 1484 | - }; | 1387 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); |
| 1388 | + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1485 | 1389 | ||
| 1486 | - //---是不是从收藏夹出来的--- | ||
| 1487 | - if (th.data.c_guide_id) { | ||
| 1488 | - updata['guide_id'] = th.data.c_guide_id; | ||
| 1489 | - updata['guide_type'] = 3; //加入购物车之后就变成了3 | ||
| 1490 | - } else { | ||
| 1491 | - if (getApp().globalData.guide_id) { | ||
| 1492 | - updata['guide_id'] = getApp().globalData.guide_id; | ||
| 1493 | - updata['guide_type'] = 0; | ||
| 1494 | - } | ||
| 1495 | - } | 1390 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 |
| 1496 | 1391 | ||
| 1497 | - i.put("/api/weshop/cart/update", { | ||
| 1498 | - data: updata, | ||
| 1499 | - success: function (t) { | ||
| 1500 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1501 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 1502 | - th.setData({ | ||
| 1503 | - cartGoodsNum: c_num | ||
| 1504 | - }); | ||
| 1505 | - th.closeSpecModal(); | ||
| 1506 | - } | ||
| 1507 | - }); | ||
| 1508 | - } else { | 1392 | + } else if (o.prom_type == 7) { |
| 1509 | 1393 | ||
| 1394 | + //判断进行中的活动,是不是要判断线下库存 | ||
| 1395 | + th.check_zh_acting(function (ee) { | ||
| 1396 | + newd.prom_id = 0; | ||
| 1397 | + newd.prom_type = 0; | ||
| 1398 | + if (ee && th.data.sele_g.act) { | ||
| 1399 | + newd.prom_id = th.data.sele_g.act.id; | ||
| 1400 | + newd.prom_type = 7; | ||
| 1401 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1402 | + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1403 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1404 | + return false; | ||
| 1405 | + } else { | ||
| 1406 | + //---如果是线下门店销售的时候--- | ||
| 1407 | + if (th.data.sales_rules == 2) { | ||
| 1408 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1409 | + //---通过接口获取门店的线下库存信息-- | ||
| 1410 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1411 | + data: { | ||
| 1412 | + storageNos: pick.pickup_no, | ||
| 1413 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1414 | + storeId: os.stoid | ||
| 1415 | + }, | ||
| 1416 | + success: function (res) { | ||
| 1417 | + if (res.data.code == 0) { | ||
| 1418 | + if (res.data.data.pageData.length > 0) { | ||
| 1419 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1420 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1421 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1422 | + } | ||
| 1423 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1424 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1425 | + data: { | ||
| 1426 | + store_id: os.stoid, | ||
| 1427 | + wareId: th.data.sele_g.goods_id, | ||
| 1428 | + storageId: pick.pickup_id, | ||
| 1429 | + pageSize: 1000 | ||
| 1430 | + }, | ||
| 1431 | + success: function (res_data) { | ||
| 1432 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1433 | + | ||
| 1434 | + var lock = 0; | ||
| 1435 | + for (var i in res_data.data.data.pageData) { | ||
| 1436 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1437 | + } | ||
| 1438 | + | ||
| 1439 | + if (CanOutQty <= lock) { | ||
| 1440 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1441 | + } | ||
| 1442 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1443 | + } else { | ||
| 1444 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1445 | + } | ||
| 1446 | + } | ||
| 1447 | + }) | ||
| 1448 | + } else { | ||
| 1449 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1450 | + } | ||
| 1451 | + | ||
| 1452 | + } | ||
| 1453 | + } | ||
| 1454 | + }) | ||
| 1455 | + } else { | ||
| 1456 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1457 | + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1458 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1459 | + } | ||
| 1460 | + } | ||
| 1461 | + }) | ||
| 1510 | 1462 | ||
| 1511 | - i.post("/api/weshop/cart/save", { | ||
| 1512 | - data: newd, | ||
| 1513 | - success: function (t) { | ||
| 1514 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1515 | - var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; | ||
| 1516 | - th.setData({ | ||
| 1517 | - cartGoodsNum: c_num | ||
| 1518 | - }); | ||
| 1519 | - th.closeSpecModal(); | ||
| 1520 | - } | ||
| 1521 | - }); | ||
| 1522 | - } | ||
| 1523 | - } | ||
| 1524 | - }); | 1463 | + } |
| 1464 | + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type == 10) { | ||
| 1465 | + newd.prom_type = 0; | ||
| 1466 | + newd.prom_id = 0; | ||
| 1525 | 1467 | ||
| 1526 | - } | ||
| 1527 | - else { | 1468 | + if (th.data.prom_type == 10) { |
| 1469 | + newd.prom_type = th.data.prom_type; | ||
| 1470 | + newd.prom_id = th.data.prom_id; | ||
| 1471 | + } | ||
| 1528 | 1472 | ||
| 1529 | - //这一步主要是要让立即购买 走 购物车的逻辑 参与活动 | ||
| 1530 | - if(newd.prom_type==10 || newd.prom_type==7){ | ||
| 1531 | - //----先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 1532 | - getApp().request.get("/api/weshop/cart/page", { | ||
| 1533 | - data: { | ||
| 1534 | - store_id: e.data.stoid, | ||
| 1535 | - user_id: oo.user_id, | ||
| 1536 | - state:1 | ||
| 1537 | - }, | ||
| 1538 | - success: function (res) { | ||
| 1539 | - //-------如果购物车中有相关的数据--------- | ||
| 1540 | - if (res.data.code==0 && res.data.data.total > 0) { | ||
| 1541 | - for(let j in res.data.data.pageData){ | ||
| 1542 | - let item_j=res.data.data.pageData[j]; | ||
| 1543 | - var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id; | ||
| 1544 | - getApp().request.delete(url, {}); | ||
| 1545 | - } | 1473 | + //---如果是线下门店销售的时候--- |
| 1474 | + if (th.data.sales_rules == 2) { | ||
| 1475 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 1476 | + //---通过接口获取门店的线下库存信息-- | ||
| 1477 | + getApp().request.get("/api/weshop/goods/getWareStorages", { | ||
| 1478 | + data: { | ||
| 1479 | + storageNos: pick.pickup_no, | ||
| 1480 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 1481 | + storeId: os.stoid | ||
| 1482 | + }, | ||
| 1483 | + success: function (res) { | ||
| 1484 | + if (res.data.code == 0) { | ||
| 1485 | + if (res.data.data.pageData.length > 0) { | ||
| 1486 | + var CanOutQty = res.data.data.pageData[0].CanOutQty; | ||
| 1487 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 1488 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1489 | + } | ||
| 1490 | + //在调一次接口,读取商品的预出库的数量,lock | ||
| 1491 | + getApp().request.get("/api/weshop/order/ware/lock/page", { | ||
| 1492 | + data: { | ||
| 1493 | + store_id: os.stoid, | ||
| 1494 | + wareId: th.data.sele_g.goods_id, | ||
| 1495 | + storageId: pick.pickup_id, | ||
| 1496 | + pageSize: 1000 | ||
| 1497 | + }, | ||
| 1498 | + success: function (res_data) { | ||
| 1499 | + if (res_data.data.code == 0 && res_data.data.data.total > 0) { | ||
| 1500 | + | ||
| 1501 | + var lock = 0; | ||
| 1502 | + for (var i in res_data.data.data.pageData) { | ||
| 1503 | + lock += res_data.data.data.pageData[i].outQty; | ||
| 1504 | + } | ||
| 1505 | + | ||
| 1506 | + if (CanOutQty <= lock) { | ||
| 1507 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1508 | + } | ||
| 1509 | + th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | ||
| 1510 | + } else { | ||
| 1511 | + th.add_cart_next(e, t, a, o, newd, CanOutQty); | ||
| 1512 | + } | ||
| 1513 | + } | ||
| 1514 | + }) | ||
| 1515 | + } else { | ||
| 1516 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1517 | + } | ||
| 1518 | + | ||
| 1519 | + } | ||
| 1520 | + } | ||
| 1521 | + }) | ||
| 1522 | + } else { | ||
| 1523 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 1524 | + if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | ||
| 1525 | + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | ||
| 1546 | } | 1526 | } |
| 1547 | - newd.state=1; | ||
| 1548 | - getApp().request.post("/api/weshop/cart/save", { | ||
| 1549 | - data: newd, | ||
| 1550 | - success: function (t) { | ||
| 1551 | - th.closeSpecModal(); | ||
| 1552 | - getApp().goto("/pages/cart/cart2/cart2?state=1"); | ||
| 1553 | - } | ||
| 1554 | - }); | ||
| 1555 | } | 1527 | } |
| 1556 | }) | 1528 | }) |
| 1557 | - return false; | ||
| 1558 | - } | 1529 | + }, |
| 1559 | 1530 | ||
| 1560 | - if (th.data.prom_goods) { | ||
| 1561 | - var prom_d = th.data.prom_goods; | ||
| 1562 | - for (var i in prom_d) { | ||
| 1563 | - //判断活动有俩种条件,0元 1件 | ||
| 1564 | - var condition_t = prom_d[i].prom_type; | ||
| 1565 | - switch (condition_t) { | ||
| 1566 | - case 0: //按钱 | ||
| 1567 | - if (newd.goods_price >= condition_t) { | ||
| 1568 | - newd.prom_type = 3; | ||
| 1569 | - newd.prom_id = prom_d[i].prom_id; | ||
| 1570 | - } | ||
| 1571 | - break | ||
| 1572 | - case 1://按购买数量 | ||
| 1573 | - if (newd.goods_num >= condition_t) { | ||
| 1574 | - newd.prom_type = 3; | ||
| 1575 | - newd.prom_id = prom_d[i].prom_id; | ||
| 1576 | - } | ||
| 1577 | - break; | ||
| 1578 | - } | 1531 | + //---加入购物车的最后一步--- |
| 1532 | + add_cart_next(e, t, a, o, newd, CanOutQty) { | ||
| 1533 | + var th = this, i = getApp().request; | ||
| 1534 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 1535 | + if ((o.prom_type != 1 || o.prom_id <= 0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type != 2 ) || th.data.is_normal)) { | ||
| 1536 | + var conf = th.data.bconfig; | ||
| 1537 | + if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | ||
| 1538 | + var s_list = JSON.parse(conf.switch_list); | ||
| 1539 | + var now = ut.gettimestamp(); | ||
| 1540 | + | ||
| 1541 | + | ||
| 1542 | + var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | ||
| 1543 | + var end = new Date(str); | ||
| 1544 | + end = Date.parse(end) / 1000; | ||
| 1545 | + | ||
| 1546 | + //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- | ||
| 1547 | + if (parseInt(s_list.rank_switch) == 2 && end > now) { | ||
| 1548 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 1549 | + //如果会员有等级价 | ||
| 1550 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 1551 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 1552 | + newd.goods_price = card_price; | ||
| 1553 | + newd.member_goods_price = card_price; | ||
| 1554 | + } | ||
| 1555 | + } | ||
| 1556 | + } | ||
| 1579 | } | 1557 | } |
| 1580 | 1558 | ||
| 1581 | - } | 1559 | + //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); |
| 1560 | + if ("add" == t.currentTarget.dataset.action) { | ||
| 1582 | 1561 | ||
| 1583 | - newd['pick_name'] = th.data.sto_sele_name; | ||
| 1584 | - newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 1585 | - th.buyNow(newd); | ||
| 1586 | - } | ||
| 1587 | - }, | 1562 | + if (th.data.prom_goods) { |
| 1563 | + newd.prom_type = 3; | ||
| 1564 | + newd.prom_id = th.data.prom_goods[0].prom_id; | ||
| 1565 | + } | ||
| 1588 | 1566 | ||
| 1567 | + //----先看会员在购物车中是否加入了该商品----- | ||
| 1568 | + i.get("/api/weshop/cart/page", { | ||
| 1569 | + data: { | ||
| 1570 | + store_id: e.data.stoid, | ||
| 1571 | + user_id: oo.user_id, | ||
| 1572 | + goods_id: a, | ||
| 1573 | + pick_id: e.data.sto_sele_id, | ||
| 1574 | + state: 0 | ||
| 1575 | + }, | ||
| 1576 | + success: function (re) { | ||
| 1589 | 1577 | ||
| 1590 | - //----------购买虚拟商品------ | ||
| 1591 | - buyVirtualGoods: function (e) { | ||
| 1592 | - Object.assign(e, { | ||
| 1593 | - goods_name: this.data.data.goods.goods_name, | ||
| 1594 | - spec_name: this.data.select.specName, | ||
| 1595 | - price: this.data.select.price | ||
| 1596 | - }), wx.navigateTo({ | ||
| 1597 | - url: "/pages/virtual/buy_step/buy_step?" + t.Obj2Str(e) | ||
| 1598 | - }); | ||
| 1599 | - }, | ||
| 1600 | - //----------积分兑换--------- | ||
| 1601 | - exchange: function (e) { | ||
| 1602 | - this.data.shippingCost < 0 || this.data.select.stock <= 0 || wx.navigateTo({ | ||
| 1603 | - url: "/pages/cart/integral/integral?" + t.Obj2Str(e) | ||
| 1604 | - }); | ||
| 1605 | - }, | 1578 | + //-------如果购物车中有相关的数据--------- |
| 1579 | + if (re.data.data.total > 0) { | ||
| 1606 | 1580 | ||
| 1581 | + var item = re.data.data.pageData[0]; | ||
| 1607 | 1582 | ||
| 1608 | - //----------立即购买----------- | ||
| 1609 | - buyNow: function (e) { | ||
| 1610 | - // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, { | ||
| 1611 | - // action: "buy_now" | ||
| 1612 | - // }), | ||
| 1613 | - this.setData({ | ||
| 1614 | - openSpecModal: 0, | ||
| 1615 | - openSpecModal_inte: 0, | ||
| 1616 | - openSpecModal_inte_normal: 0, | ||
| 1617 | - openSpecModal_pt: 0, | ||
| 1618 | - }) | 1583 | + //判断数量,要看下购物车中有没有该商品 |
| 1584 | + if (CanOutQty) { | ||
| 1585 | + if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | ||
| 1586 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1587 | + } | ||
| 1588 | + } else { | ||
| 1589 | + if (item.goods_num + th.data.goodsInputNum > o.store_count) { | ||
| 1590 | + return s.my_warnning("库存不足!", 0, th); | ||
| 1591 | + } | ||
| 1592 | + } | ||
| 1619 | 1593 | ||
| 1620 | - if (e.prom_type == 4) { | ||
| 1621 | - s.set_b_now(e); | ||
| 1622 | - var url = "/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id; | ||
| 1623 | - getApp().goto(url); | ||
| 1624 | - } else { | ||
| 1625 | - //要判断积分购的普通购买有没有参加优惠活动 | ||
| 1626 | - if (e.is_integral_normal == 1) { | ||
| 1627 | - this.check_nor_promgood(e.goods_id, function (res) { | ||
| 1628 | - if (res && res.cat_id) { | ||
| 1629 | - e.prom_type = 3; | ||
| 1630 | - e.prom_id = res.cat_id | ||
| 1631 | - } | ||
| 1632 | - s.set_b_now(e); | ||
| 1633 | - /*-- | ||
| 1634 | - wx.redirectTo({ | ||
| 1635 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1636 | - });--*/ | ||
| 1637 | - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | 1594 | + var updata = { |
| 1595 | + id: item.id, | ||
| 1596 | + goods_num: e.data.goodsInputNum + item.goods_num, | ||
| 1597 | + goods_price: newd.goods_price, | ||
| 1598 | + member_goods_price: newd.goods_price, | ||
| 1599 | + store_id: th.data.stoid, | ||
| 1600 | + }; | ||
| 1601 | + | ||
| 1602 | + //---是不是从收藏夹出来的--- | ||
| 1603 | + if (th.data.c_guide_id) { | ||
| 1604 | + updata['guide_id'] = th.data.c_guide_id; | ||
| 1605 | + updata['guide_type'] = 3; //加入购物车之后就变成了3 | ||
| 1606 | + } else { | ||
| 1607 | + if (getApp().globalData.guide_id) { | ||
| 1608 | + updata['guide_id'] = getApp().globalData.guide_id; | ||
| 1609 | + updata['guide_type'] = 0; | ||
| 1610 | + } | ||
| 1611 | + } | ||
| 1638 | 1612 | ||
| 1639 | - }) | ||
| 1640 | - } else { | ||
| 1641 | - s.set_b_now(e); | ||
| 1642 | - /*-- | ||
| 1643 | - wx.redirectTo({ | ||
| 1644 | - url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1645 | - });--*/ | ||
| 1646 | - getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1647 | - } | ||
| 1648 | - | ||
| 1649 | - } | ||
| 1650 | - }, | ||
| 1651 | - | ||
| 1652 | - //----------增加购买数量----------- | ||
| 1653 | - addCartNum: function (t) { | ||
| 1654 | - this.checkCartNum(this.data.goodsInputNum + 1); | ||
| 1655 | - }, | ||
| 1656 | - //----------减少购买数量----------- | ||
| 1657 | - subCartNum: function (t) { | ||
| 1658 | - this.checkCartNum(this.data.goodsInputNum - 1); | ||
| 1659 | - }, | ||
| 1660 | - //----------输入框输入购买数量----------- | ||
| 1661 | - inputCartNum: function (t) { | ||
| 1662 | - this.checkCartNum(Number(t.detail.value)); | ||
| 1663 | - }, | 1613 | + i.put("/api/weshop/cart/update", { |
| 1614 | + data: updata, | ||
| 1615 | + success: function (t) { | ||
| 1616 | + getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1617 | + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | ||
| 1618 | + th.setData({ | ||
| 1619 | + cartGoodsNum: c_num | ||
| 1620 | + }); | ||
| 1621 | + th.closeSpecModal(); | ||
| 1622 | + } | ||
| 1623 | + }); | ||
| 1624 | + } else { | ||
| 1664 | 1625 | ||
| 1665 | - //----------增加购买数量----------- | ||
| 1666 | - addCartNum_inte: function (t) { | ||
| 1667 | - this.checkCartNum_inte(this.data.goodsInputNum + 1); | ||
| 1668 | - }, | ||
| 1669 | - //----------减少购买数量----------- | ||
| 1670 | - subCartNum_inte: function (t) { | ||
| 1671 | - this.checkCartNum_inte(this.data.goodsInputNum - 1); | ||
| 1672 | - }, | ||
| 1673 | - //----------输入框输入购买数量----------- | ||
| 1674 | - inputCartNum_inte: function (t) { | ||
| 1675 | - this.checkCartNum_inte(Number(t.detail.value)); | ||
| 1676 | - }, | ||
| 1677 | 1626 | ||
| 1627 | + i.post("/api/weshop/cart/save", { | ||
| 1628 | + data: newd, | ||
| 1629 | + success: function (t) { | ||
| 1630 | + getApp().my_warnning('加入购物车成功', 1, th, 450); | ||
| 1631 | + var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; | ||
| 1632 | + th.setData({ | ||
| 1633 | + cartGoodsNum: c_num | ||
| 1634 | + }); | ||
| 1635 | + th.closeSpecModal(); | ||
| 1636 | + } | ||
| 1637 | + }); | ||
| 1638 | + } | ||
| 1639 | + } | ||
| 1640 | + }); | ||
| 1678 | 1641 | ||
| 1679 | - //------检查数量是不是超出限购------ | ||
| 1680 | - checkCartNum: function (t) { | ||
| 1681 | - var th = this; | ||
| 1682 | - this.get_buy_num(this.data.sele_g, async function () { | 1642 | + } |
| 1643 | + else { | ||
| 1683 | 1644 | ||
| 1684 | - //--判断商品是否超出限购-- | ||
| 1685 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | 1645 | + //这一步主要是要让立即购买 走 购物车的逻辑 参与活动 |
| 1646 | + if (newd.prom_type == 10 || newd.prom_type == 7) { | ||
| 1647 | + //----先看会员在购物车中是否加入了该商品,立即购买的----- | ||
| 1648 | + getApp().request.get("/api/weshop/cart/page", { | ||
| 1649 | + data: { | ||
| 1650 | + store_id: e.data.stoid, | ||
| 1651 | + user_id: oo.user_id, | ||
| 1652 | + state: 1 | ||
| 1653 | + }, | ||
| 1654 | + success: function (res) { | ||
| 1655 | + //-------如果购物车中有相关的数据--------- | ||
| 1656 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 1657 | + for (let j in res.data.data.pageData) { | ||
| 1658 | + let item_j = res.data.data.pageData[j]; | ||
| 1659 | + var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | ||
| 1660 | + getApp().request.delete(url, {}); | ||
| 1661 | + } | ||
| 1662 | + } | ||
| 1663 | + newd.state = 1; | ||
| 1664 | + getApp().request.post("/api/weshop/cart/save", { | ||
| 1665 | + data: newd, | ||
| 1666 | + success: function (t) { | ||
| 1667 | + th.closeSpecModal(); | ||
| 1668 | + getApp().goto("/pages/cart/cart2/cart2?state=1"); | ||
| 1669 | + } | ||
| 1670 | + }); | ||
| 1671 | + } | ||
| 1672 | + }) | ||
| 1673 | + return false; | ||
| 1674 | + } | ||
| 1686 | 1675 | ||
| 1687 | - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | 1676 | + if (th.data.prom_goods) { |
| 1677 | + var prom_d = th.data.prom_goods; | ||
| 1678 | + for (var i in prom_d) { | ||
| 1679 | + //判断活动有俩种条件,0元 1件 | ||
| 1680 | + var condition_t = prom_d[i].prom_type; | ||
| 1681 | + switch (condition_t) { | ||
| 1682 | + case 0: //按钱 | ||
| 1683 | + if (newd.goods_price >= condition_t) { | ||
| 1684 | + newd.prom_type = 3; | ||
| 1685 | + newd.prom_id = prom_d[i].prom_id; | ||
| 1686 | + } | ||
| 1687 | + break | ||
| 1688 | + case 1://按购买数量 | ||
| 1689 | + if (newd.goods_num >= condition_t) { | ||
| 1690 | + newd.prom_type = 3; | ||
| 1691 | + newd.prom_id = prom_d[i].prom_id; | ||
| 1692 | + } | ||
| 1693 | + break; | ||
| 1694 | + } | ||
| 1695 | + } | ||
| 1688 | 1696 | ||
| 1689 | - if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 1690 | - wx.showModal({ | ||
| 1691 | - title: '超出商品限购', | ||
| 1692 | - }); | 1697 | + } |
| 1693 | 1698 | ||
| 1694 | - var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 1695 | - if (num < 0) num = 0; | ||
| 1696 | - th.setData({ goodsInputNum: num }) | ||
| 1697 | - return false; | 1699 | + newd['pick_name'] = th.data.sto_sele_name; |
| 1700 | + newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 1701 | + th.buyNow(newd); | ||
| 1698 | } | 1702 | } |
| 1699 | - } | 1703 | + }, |
| 1700 | 1704 | ||
| 1701 | - //--判断商品是否超出活动限购-- | ||
| 1702 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | ||
| 1703 | - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1704 | - wx.showModal({ | ||
| 1705 | - title: '超出商品活动限购', | ||
| 1706 | - }); | ||
| 1707 | - | ||
| 1708 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 1709 | - if (num < 0) num = 0; | ||
| 1710 | - th.setData({ goodsInputNum: num }) | ||
| 1711 | - return false; | ||
| 1712 | - } | ||
| 1713 | - } | ||
| 1714 | 1705 | ||
| 1715 | - if((th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) && !th.data.is_normal) { | ||
| 1716 | - var redis_num = 0; | ||
| 1717 | - //------判断活动是否抢光----- | ||
| 1718 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1719 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1720 | - 1: 1 | ||
| 1721 | - }).then(res => { | ||
| 1722 | - redis_num = res.data.data; | 1706 | + //----------购买虚拟商品------ |
| 1707 | + buyVirtualGoods: function (e) { | ||
| 1708 | + Object.assign(e, { | ||
| 1709 | + goods_name: this.data.data.goods.goods_name, | ||
| 1710 | + spec_name: this.data.select.specName, | ||
| 1711 | + price: this.data.select.price | ||
| 1712 | + }), wx.navigateTo({ | ||
| 1713 | + url: "/pages/virtual/buy_step/buy_step?" + t.Obj2Str(e) | ||
| 1714 | + }); | ||
| 1715 | + }, | ||
| 1716 | + //----------积分兑换--------- | ||
| 1717 | + exchange: function (e) { | ||
| 1718 | + this.data.shippingCost < 0 || this.data.select.stock <= 0 || wx.navigateTo({ | ||
| 1719 | + url: "/pages/cart/integral/integral?" + t.Obj2Str(e) | ||
| 1723 | }); | 1720 | }); |
| 1721 | + }, | ||
| 1724 | 1722 | ||
| 1725 | - if (t > redis_num) { | ||
| 1726 | - wx.showModal({ | ||
| 1727 | - title: '超出商品活动库存', | ||
| 1728 | - }); | ||
| 1729 | - th.setData({ goodsInputNum: redis_num }) | ||
| 1730 | - return false; | ||
| 1731 | - } | ||
| 1732 | - } | ||
| 1733 | - var e = th.data.sele_g.store_count; | ||
| 1734 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 1735 | - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 1736 | - if (!th.data.def_pick_store) { | ||
| 1737 | - wx.showModal({ title: '请选择门店', }); | ||
| 1738 | - return false; | 1723 | + |
| 1724 | + //----------立即购买----------- | ||
| 1725 | + buyNow: function (e) { | ||
| 1726 | + // this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, { | ||
| 1727 | + // action: "buy_now" | ||
| 1728 | + // }), | ||
| 1729 | + this.setData({ | ||
| 1730 | + openSpecModal: 0, | ||
| 1731 | + openSpecModal_inte: 0, | ||
| 1732 | + openSpecModal_inte_normal: 0, | ||
| 1733 | + openSpecModal_pt: 0, | ||
| 1734 | + }) | ||
| 1735 | + | ||
| 1736 | + if (e.prom_type == 4) { | ||
| 1737 | + s.set_b_now(e); | ||
| 1738 | + var url = "/pages/cart/cart2_inte/cart2_inte?is_bnow=1&goods_id=" + e.goods_id; | ||
| 1739 | + getApp().goto(url); | ||
| 1739 | } else { | 1740 | } else { |
| 1740 | - e = th.data.def_pick_store.CanOutQty; | 1741 | + //要判断积分购的普通购买有没有参加优惠活动 |
| 1742 | + if (e.is_integral_normal == 1) { | ||
| 1743 | + this.check_nor_promgood(e.goods_id, function (res) { | ||
| 1744 | + if (res && res.cat_id) { | ||
| 1745 | + e.prom_type = 3; | ||
| 1746 | + e.prom_id = res.cat_id | ||
| 1747 | + } | ||
| 1748 | + s.set_b_now(e); | ||
| 1749 | + /*-- | ||
| 1750 | + wx.redirectTo({ | ||
| 1751 | + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1752 | + });--*/ | ||
| 1753 | + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1754 | + | ||
| 1755 | + }) | ||
| 1756 | + } else { | ||
| 1757 | + s.set_b_now(e); | ||
| 1758 | + /*-- | ||
| 1759 | + wx.redirectTo({ | ||
| 1760 | + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, | ||
| 1761 | + });--*/ | ||
| 1762 | + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) | ||
| 1763 | + } | ||
| 1764 | + | ||
| 1741 | } | 1765 | } |
| 1742 | - } | ||
| 1743 | - if (!e) e = 0; | ||
| 1744 | - //库存不足,不增加 | ||
| 1745 | - if (e < t) { | ||
| 1746 | - wx.showModal({ title: '库存不足', }); | ||
| 1747 | - if (e < 0) e = 0; | ||
| 1748 | - th.setData({ goodsInputNum: e }); return false; | ||
| 1749 | - } | ||
| 1750 | - t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 1751 | - th.setData({ goodsInputNum: t }); | ||
| 1752 | - th.is_show_more_buy(); | 1766 | + }, |
| 1753 | 1767 | ||
| 1754 | - }) | ||
| 1755 | - }, | 1768 | + //----------增加购买数量----------- |
| 1769 | + addCartNum: function (t) { | ||
| 1770 | + this.checkCartNum(this.data.goodsInputNum + 1); | ||
| 1771 | + }, | ||
| 1772 | + //----------减少购买数量----------- | ||
| 1773 | + subCartNum: function (t) { | ||
| 1774 | + this.checkCartNum(this.data.goodsInputNum - 1); | ||
| 1775 | + }, | ||
| 1776 | + //----------输入框输入购买数量----------- | ||
| 1777 | + inputCartNum: function (t) { | ||
| 1778 | + this.checkCartNum(Number(t.detail.value)); | ||
| 1779 | + }, | ||
| 1756 | 1780 | ||
| 1757 | - //----- 检查一下积分购的限购之类的问题 ----- | ||
| 1758 | - checkCartNum_inte: function (t) { | ||
| 1759 | - var th = this; | ||
| 1760 | - this.get_buy_num(this.data.data, async function () { | ||
| 1761 | - ; | ||
| 1762 | - //--判断商品是否超出限购-- | ||
| 1763 | - if (th.data.g_buy_num != null && th.data.data.viplimited > 0) { | 1781 | + //----------增加购买数量----------- |
| 1782 | + addCartNum_inte: function (t) { | ||
| 1783 | + this.checkCartNum_inte(this.data.goodsInputNum + 1); | ||
| 1784 | + }, | ||
| 1785 | + //----------减少购买数量----------- | ||
| 1786 | + subCartNum_inte: function (t) { | ||
| 1787 | + this.checkCartNum_inte(this.data.goodsInputNum - 1); | ||
| 1788 | + }, | ||
| 1789 | + //----------输入框输入购买数量----------- | ||
| 1790 | + inputCartNum_inte: function (t) { | ||
| 1791 | + this.checkCartNum_inte(Number(t.detail.value)); | ||
| 1792 | + }, | ||
| 1764 | 1793 | ||
| 1765 | - var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); | ||
| 1766 | 1794 | ||
| 1767 | - if (t + gd_buy_num > th.data.sele_g.viplimited) { | ||
| 1768 | - wx.showModal({ | ||
| 1769 | - title: '超出商品限购', | ||
| 1770 | - }); | 1795 | + //------检查数量是不是超出限购------ |
| 1796 | + checkCartNum: function (t) { | ||
| 1797 | + var th = this; | ||
| 1798 | + this.get_buy_num(this.data.sele_g, async function () { | ||
| 1771 | 1799 | ||
| 1772 | - var num = th.data.sele_g.viplimited - gd_buy_num; | ||
| 1773 | - if (num < 0) num = 0; | ||
| 1774 | - th.setData({ goodsInputNum: num }) | ||
| 1775 | - return false; | ||
| 1776 | - } | ||
| 1777 | - } | 1800 | + //--判断商品是否超出限购-- |
| 1801 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 1778 | 1802 | ||
| 1779 | - //--判断商品是否超出活动限购-- | ||
| 1780 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1781 | - if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1782 | - wx.showModal({ | ||
| 1783 | - title: '超出商品活动限购', | ||
| 1784 | - }); | ||
| 1785 | - | ||
| 1786 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 1787 | - if (num < 0) num = 0; | ||
| 1788 | - th.setData({ goodsInputNum: num }) | ||
| 1789 | - return false; | ||
| 1790 | - } | ||
| 1791 | - } | 1803 | + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); |
| 1792 | 1804 | ||
| 1793 | - if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { | ||
| 1794 | - var redis_num = 0; | ||
| 1795 | - //------判断活动是否抢光----- | ||
| 1796 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1797 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1798 | - 1: 1 | ||
| 1799 | - }).then(res => { | ||
| 1800 | - redis_num = res.data.data; | ||
| 1801 | - }); | 1805 | + if (t + gd_buy_num > th.data.sele_g.viplimited) { |
| 1806 | + wx.showModal({ | ||
| 1807 | + title: '超出商品限购', | ||
| 1808 | + }); | ||
| 1802 | 1809 | ||
| 1803 | - if (t > redis_num) { | ||
| 1804 | - wx.showModal({ | ||
| 1805 | - title: '超出商品活动库存', | ||
| 1806 | - }); | ||
| 1807 | - th.setData({ goodsInputNum: redis_num }) | ||
| 1808 | - return false; | ||
| 1809 | - } | ||
| 1810 | - } | 1810 | + var num = th.data.sele_g.viplimited - gd_buy_num; |
| 1811 | + if (num < 0) num = 0; | ||
| 1812 | + th.setData({goodsInputNum: num}) | ||
| 1813 | + return false; | ||
| 1814 | + } | ||
| 1815 | + } | ||
| 1811 | 1816 | ||
| 1817 | + //--判断商品是否超出活动限购-- | ||
| 1818 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | ||
| 1819 | + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1820 | + wx.showModal({ | ||
| 1821 | + title: '超出商品活动限购', | ||
| 1822 | + }); | ||
| 1812 | 1823 | ||
| 1813 | - //判断积分购库存 | ||
| 1814 | - if(!th.data.is_normal && th.data.prom_type==4){ | ||
| 1815 | - var i_canbuy=th.data.prom_act.limitqty-th.data.prom_act.buy_num; | ||
| 1816 | - if(t>i_canbuy){ | ||
| 1817 | - wx.showModal({ | ||
| 1818 | - title: '超出商品活动库存', | ||
| 1819 | - }); | ||
| 1820 | - return false; | ||
| 1821 | - } | ||
| 1822 | - } | 1824 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; |
| 1825 | + if (num < 0) num = 0; | ||
| 1826 | + th.setData({goodsInputNum: num}) | ||
| 1827 | + return false; | ||
| 1828 | + } | ||
| 1829 | + } | ||
| 1823 | 1830 | ||
| 1824 | - var e = th.data.sele_g.store_count; | ||
| 1825 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 1826 | - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 1827 | - if (!th.data.def_pick_store) { | ||
| 1828 | - wx.showModal({ title: '请选择门店', }); | ||
| 1829 | - return false; | ||
| 1830 | - } else { | ||
| 1831 | - e = th.data.def_pick_store.CanOutQty; | ||
| 1832 | - } | ||
| 1833 | - } | ||
| 1834 | - if (!e) e = 0; | ||
| 1835 | - //库存不足,不增加 | ||
| 1836 | - if (e < t) { | ||
| 1837 | - wx.showModal({ title: '库存不足', }); | ||
| 1838 | - if (e < 0) e = 0; | ||
| 1839 | - th.setData({ goodsInputNum: e }); return false; | ||
| 1840 | - } | ||
| 1841 | - t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 1842 | - th.setData({ goodsInputNum: t }); | ||
| 1843 | - }) | ||
| 1844 | - }, | 1831 | + if ((th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) && !th.data.is_normal) { |
| 1832 | + var redis_num = 0; | ||
| 1833 | + //------判断活动是否抢光----- | ||
| 1834 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1835 | + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1836 | + 1: 1 | ||
| 1837 | + }).then(res => { | ||
| 1838 | + redis_num = res.data.data; | ||
| 1839 | + }); | ||
| 1840 | + | ||
| 1841 | + if (t > redis_num) { | ||
| 1842 | + wx.showModal({ | ||
| 1843 | + title: '超出商品活动库存', | ||
| 1844 | + }); | ||
| 1845 | + th.setData({goodsInputNum: redis_num}) | ||
| 1846 | + return false; | ||
| 1847 | + } | ||
| 1848 | + } | ||
| 1849 | + var e = th.data.sele_g.store_count; | ||
| 1850 | + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 1851 | + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 1852 | + if (!th.data.def_pick_store) { | ||
| 1853 | + wx.showModal({title: '请选择门店',}); | ||
| 1854 | + return false; | ||
| 1855 | + } else { | ||
| 1856 | + e = th.data.def_pick_store.CanOutQty; | ||
| 1857 | + } | ||
| 1858 | + } | ||
| 1859 | + if (!e) e = 0; | ||
| 1860 | + //库存不足,不增加 | ||
| 1861 | + if (e < t) { | ||
| 1862 | + wx.showModal({title: '库存不足',}); | ||
| 1863 | + if (e < 0) e = 0; | ||
| 1864 | + th.setData({goodsInputNum: e}); | ||
| 1865 | + return false; | ||
| 1866 | + } | ||
| 1867 | + t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 1868 | + th.setData({goodsInputNum: t}); | ||
| 1869 | + th.is_show_more_buy(); | ||
| 1845 | 1870 | ||
| 1871 | + }) | ||
| 1872 | + }, | ||
| 1846 | 1873 | ||
| 1847 | - closeSpecModal: function () { | ||
| 1848 | - if (this.data.openSpecModal_pt && this.data.is_normal) { | ||
| 1849 | - this.get_sto(); | ||
| 1850 | - this.setData({ | ||
| 1851 | - sele_g: this.data.data, | ||
| 1852 | - gid: this.data.data.goods_id | ||
| 1853 | - }) | 1874 | + //----- 检查一下积分购的限购之类的问题 ----- |
| 1875 | + checkCartNum_inte: function (t) { | ||
| 1876 | + var th = this; | ||
| 1877 | + this.get_buy_num(this.data.data, async function () { | ||
| 1878 | + ; | ||
| 1879 | + //--判断商品是否超出限购-- | ||
| 1880 | + if (th.data.g_buy_num != null && th.data.data.viplimited > 0) { | ||
| 1854 | 1881 | ||
| 1855 | - this.sele_spec_chech_activity(); | 1882 | + var gd_buy_num = th.data.g_buy_num.get(th.data.sele_g.goods_id); |
| 1856 | 1883 | ||
| 1857 | - } | 1884 | + if (t + gd_buy_num > th.data.sele_g.viplimited) { |
| 1885 | + wx.showModal({ | ||
| 1886 | + title: '超出商品限购', | ||
| 1887 | + }); | ||
| 1858 | 1888 | ||
| 1859 | - this.setData({ | ||
| 1860 | - openSpecModal: !1, | ||
| 1861 | - openSpecModal_pt: !1 | ||
| 1862 | - }); | ||
| 1863 | - }, | 1889 | + var num = th.data.sele_g.viplimited - gd_buy_num; |
| 1890 | + if (num < 0) num = 0; | ||
| 1891 | + th.setData({goodsInputNum: num}) | ||
| 1892 | + return false; | ||
| 1893 | + } | ||
| 1894 | + } | ||
| 1864 | 1895 | ||
| 1896 | + //--判断商品是否超出活动限购-- | ||
| 1897 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { | ||
| 1898 | + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 1899 | + wx.showModal({ | ||
| 1900 | + title: '超出商品活动限购', | ||
| 1901 | + }); | ||
| 1902 | + | ||
| 1903 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 1904 | + if (num < 0) num = 0; | ||
| 1905 | + th.setData({goodsInputNum: num}) | ||
| 1906 | + return false; | ||
| 1907 | + } | ||
| 1908 | + } | ||
| 1909 | + | ||
| 1910 | + if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { | ||
| 1911 | + var redis_num = 0; | ||
| 1912 | + //------判断活动是否抢光----- | ||
| 1913 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | ||
| 1914 | + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | ||
| 1915 | + 1: 1 | ||
| 1916 | + }).then(res => { | ||
| 1917 | + redis_num = res.data.data; | ||
| 1918 | + }); | ||
| 1919 | + | ||
| 1920 | + if (t > redis_num) { | ||
| 1921 | + wx.showModal({ | ||
| 1922 | + title: '超出商品活动库存', | ||
| 1923 | + }); | ||
| 1924 | + th.setData({goodsInputNum: redis_num}) | ||
| 1925 | + return false; | ||
| 1926 | + } | ||
| 1927 | + } | ||
| 1928 | + | ||
| 1929 | + | ||
| 1930 | + //判断积分购库存 | ||
| 1931 | + if (!th.data.is_normal && th.data.prom_type == 4) { | ||
| 1932 | + var i_canbuy = th.data.prom_act.limitqty - th.data.prom_act.buy_num; | ||
| 1933 | + if (t > i_canbuy) { | ||
| 1934 | + wx.showModal({ | ||
| 1935 | + title: '超出商品活动库存', | ||
| 1936 | + }); | ||
| 1937 | + return false; | ||
| 1938 | + } | ||
| 1939 | + } | ||
| 1940 | + | ||
| 1941 | + var e = th.data.sele_g.store_count; | ||
| 1942 | + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | ||
| 1943 | + if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | ||
| 1944 | + if (!th.data.def_pick_store) { | ||
| 1945 | + wx.showModal({title: '请选择门店',}); | ||
| 1946 | + return false; | ||
| 1947 | + } else { | ||
| 1948 | + e = th.data.def_pick_store.CanOutQty; | ||
| 1949 | + } | ||
| 1950 | + } | ||
| 1951 | + if (!e) e = 0; | ||
| 1952 | + //库存不足,不增加 | ||
| 1953 | + if (e < t) { | ||
| 1954 | + wx.showModal({title: '库存不足',}); | ||
| 1955 | + if (e < 0) e = 0; | ||
| 1956 | + th.setData({goodsInputNum: e}); | ||
| 1957 | + return false; | ||
| 1958 | + } | ||
| 1959 | + t > e || 0 == e ? t = e : t < 1 && (t = 1); | ||
| 1960 | + th.setData({goodsInputNum: t}); | ||
| 1961 | + }) | ||
| 1962 | + }, | ||
| 1865 | 1963 | ||
| 1866 | - openSpecModel: function (t) { | ||
| 1867 | - var th = this; | ||
| 1868 | - var open_store = t.currentTarget.dataset.ind; | ||
| 1869 | - this.setData({ | ||
| 1870 | - store: 0, | ||
| 1871 | - choice_sort_store: 0, | ||
| 1872 | - sort_store: 0, | ||
| 1873 | - open_ind_store: open_store, | ||
| 1874 | - }) | ||
| 1875 | - //--先判断会员状态-- | ||
| 1876 | - var user_info = getApp().globalData.userInfo; | ||
| 1877 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 1878 | - wx.navigateTo({ | ||
| 1879 | - url: '/pages/togoin/togoin', | ||
| 1880 | - }) | ||
| 1881 | - return false; | ||
| 1882 | - } | ||
| 1883 | 1964 | ||
| 1884 | - var check_up=0; | ||
| 1885 | - if(th.data.more_flash){ | ||
| 1886 | - for(var i in th.data.more_flash){ | ||
| 1887 | - var item=th.data.more_flash[i]; | ||
| 1888 | - if(item.prom_type==1){ | ||
| 1889 | - check_up=1; | ||
| 1890 | - break | ||
| 1891 | - } | 1965 | + closeSpecModal: function () { |
| 1966 | + if (this.data.openSpecModal_pt && this.data.is_normal) { | ||
| 1967 | + this.get_sto(); | ||
| 1968 | + this.setData({ | ||
| 1969 | + sele_g: this.data.data, | ||
| 1970 | + gid: this.data.data.goods_id | ||
| 1971 | + }) | ||
| 1972 | + | ||
| 1973 | + this.sele_spec_chech_activity(); | ||
| 1974 | + | ||
| 1892 | } | 1975 | } |
| 1893 | - } | ||
| 1894 | 1976 | ||
| 1977 | + this.setData({ | ||
| 1978 | + openSpecModal: !1, | ||
| 1979 | + openSpecModal_pt: !1 | ||
| 1980 | + }); | ||
| 1981 | + }, | ||
| 1895 | 1982 | ||
| 1896 | 1983 | ||
| 1897 | - if(check_up && open_store==1){ | ||
| 1898 | - th.setData({is_pop_more:1}); | ||
| 1899 | - }else{ | ||
| 1900 | - var ind = t.currentTarget.dataset.ind; | ||
| 1901 | - //回调。判断是不是优惠促销 | ||
| 1902 | - th.check_is_prom_goods(function () { | ||
| 1903 | - th.setData({ | ||
| 1904 | - openSpecModal: !0, | ||
| 1905 | - openSpecModal_ind: ind, | ||
| 1906 | - }); | ||
| 1907 | - //var is_open=th.data.config | ||
| 1908 | - th.get_off_price(); | 1984 | + openSpecModel: function (t) { |
| 1985 | + var th = this; | ||
| 1986 | + var open_store = t.currentTarget.dataset.ind; | ||
| 1987 | + this.setData({ | ||
| 1988 | + store: 0, | ||
| 1989 | + choice_sort_store: 0, | ||
| 1990 | + sort_store: 0, | ||
| 1991 | + open_ind_store: open_store, | ||
| 1909 | }) | 1992 | }) |
| 1910 | //--先判断会员状态-- | 1993 | //--先判断会员状态-- |
| 1911 | var user_info = getApp().globalData.userInfo; | 1994 | var user_info = getApp().globalData.userInfo; |
| @@ -1915,11 +1998,22 @@ Page({ | @@ -1915,11 +1998,22 @@ Page({ | ||
| 1915 | }) | 1998 | }) |
| 1916 | return false; | 1999 | return false; |
| 1917 | } | 2000 | } |
| 1918 | - var is_go_next = 1; | ||
| 1919 | - if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) { | ||
| 1920 | - is_go_next = 0; | 2001 | + |
| 2002 | + var check_up = 0; | ||
| 2003 | + if (th.data.more_flash) { | ||
| 2004 | + for (var i in th.data.more_flash) { | ||
| 2005 | + var item = th.data.more_flash[i]; | ||
| 2006 | + if (item.prom_type == 1) { | ||
| 2007 | + check_up = 1; | ||
| 2008 | + break | ||
| 2009 | + } | ||
| 2010 | + } | ||
| 1921 | } | 2011 | } |
| 1922 | - if (is_go_next) { | 2012 | + |
| 2013 | + | ||
| 2014 | + if (check_up && open_store == 1) { | ||
| 2015 | + th.setData({is_pop_more: 1}); | ||
| 2016 | + } else { | ||
| 1923 | var ind = t.currentTarget.dataset.ind; | 2017 | var ind = t.currentTarget.dataset.ind; |
| 1924 | //回调。判断是不是优惠促销 | 2018 | //回调。判断是不是优惠促销 |
| 1925 | th.check_is_prom_goods(function () { | 2019 | th.check_is_prom_goods(function () { |
| @@ -1930,369 +2024,397 @@ Page({ | @@ -1930,369 +2024,397 @@ Page({ | ||
| 1930 | //var is_open=th.data.config | 2024 | //var is_open=th.data.config |
| 1931 | th.get_off_price(); | 2025 | th.get_off_price(); |
| 1932 | }) | 2026 | }) |
| 1933 | - } else { | ||
| 1934 | - th.setData({is_pop_more: 1}); | 2027 | + //--先判断会员状态-- |
| 2028 | + var user_info = getApp().globalData.userInfo; | ||
| 2029 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 2030 | + wx.navigateTo({ | ||
| 2031 | + url: '/pages/togoin/togoin', | ||
| 2032 | + }) | ||
| 2033 | + return false; | ||
| 2034 | + } | ||
| 2035 | + var is_go_next = 1; | ||
| 2036 | + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) { | ||
| 2037 | + is_go_next = 0; | ||
| 2038 | + } | ||
| 2039 | + if (is_go_next) { | ||
| 2040 | + var ind = t.currentTarget.dataset.ind; | ||
| 2041 | + //回调。判断是不是优惠促销 | ||
| 2042 | + th.check_is_prom_goods(function () { | ||
| 2043 | + th.setData({ | ||
| 2044 | + openSpecModal: !0, | ||
| 2045 | + openSpecModal_ind: ind, | ||
| 2046 | + }); | ||
| 2047 | + //var is_open=th.data.config | ||
| 2048 | + th.get_off_price(); | ||
| 2049 | + }) | ||
| 2050 | + } else { | ||
| 2051 | + th.setData({is_pop_more: 1}); | ||
| 1935 | 2052 | ||
| 2053 | + } | ||
| 1936 | } | 2054 | } |
| 1937 | - } | ||
| 1938 | - }, | ||
| 1939 | - open_next(){ | ||
| 1940 | - var th=this; | ||
| 1941 | - //回调。判断是不是优惠促销 | ||
| 1942 | - th.check_is_prom_goods(function () { | ||
| 1943 | - th.setData({ | ||
| 1944 | - openSpecModal: !0, | ||
| 1945 | - openSpecModal_ind: 1, | ||
| 1946 | - is_pop_more:0 | ||
| 1947 | - }); | ||
| 1948 | - th.get_off_price(); | ||
| 1949 | - }) | ||
| 1950 | - }, | 2055 | + }, |
| 2056 | + open_next(){ | ||
| 2057 | + var th = this; | ||
| 2058 | + //回调。判断是不是优惠促销 | ||
| 2059 | + th.check_is_prom_goods(function () { | ||
| 2060 | + th.setData({ | ||
| 2061 | + openSpecModal: !0, | ||
| 2062 | + openSpecModal_ind: 1, | ||
| 2063 | + is_pop_more: 0 | ||
| 2064 | + }); | ||
| 2065 | + th.get_off_price(); | ||
| 2066 | + }) | ||
| 2067 | + }, | ||
| 1951 | 2068 | ||
| 1952 | - //判断是不是优惠促销 | ||
| 1953 | - check_is_prom_goods: function (callback) { | ||
| 1954 | - var th = this; | ||
| 1955 | - var usr = getApp().globalData.userInfo; | ||
| 1956 | - if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) { | ||
| 1957 | - callback(); | ||
| 1958 | - } else { | ||
| 1959 | - //-- 判断有没有优惠活动 -- | ||
| 1960 | - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0", {}).then(res => { | ||
| 1961 | - if (res.data.code == 0) { | ||
| 1962 | - var r_data = res.data.data; | ||
| 1963 | - th.data.prom_goods = r_data.promGoodsLists; | ||
| 1964 | - if (!th.data.prom_goods) { | 2069 | + //判断是不是优惠促销 |
| 2070 | + check_is_prom_goods: function (callback) { | ||
| 2071 | + var th = this; | ||
| 2072 | + var usr = getApp().globalData.userInfo; | ||
| 2073 | + if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) { | ||
| 1965 | callback(); | 2074 | callback(); |
| 1966 | - return false; | ||
| 1967 | - } | 2075 | + } else { |
| 2076 | + //-- 判断有没有优惠活动 -- | ||
| 2077 | + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0", {}).then(res => { | ||
| 2078 | + if (res.data.code == 0) { | ||
| 2079 | + var r_data = res.data.data; | ||
| 2080 | + th.data.prom_goods = r_data.promGoodsLists; | ||
| 2081 | + if (!th.data.prom_goods) { | ||
| 2082 | + callback(); | ||
| 2083 | + return false; | ||
| 2084 | + } | ||
| 1968 | 2085 | ||
| 1969 | - ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1 | ||
| 1970 | - getApp().promiseGet("/api/weshop/order/getWPayOrder", { | ||
| 1971 | - data: { store_id: os.stoid, user_id: usr.user_id, goods_id: th.data.sele_g.goods_id, prom_id: th.data.prom_goods[0].prom_id } | ||
| 1972 | - }).then(res => { | ||
| 1973 | - if (res.data.code == 0) { | ||
| 1974 | - wx.showToast({ | ||
| 1975 | - title: "您已经购买了该商品待支付中", | ||
| 1976 | - icon: 'none', | ||
| 1977 | - duration: 2000 | ||
| 1978 | - }) | ||
| 1979 | - setTimeout(function () { | ||
| 1980 | - getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,) | ||
| 1981 | - }, 1000) | ||
| 1982 | - } | ||
| 1983 | - //未找到相关记录 | ||
| 1984 | - else { | ||
| 1985 | - callback(); | ||
| 1986 | - } | ||
| 1987 | - }) | ||
| 1988 | - } | 2086 | + ///api/weshop/order/getWPayOrder?store_id=1&user_id=5682366&prom_id=1&goods_id=1 |
| 2087 | + getApp().promiseGet("/api/weshop/order/getWPayOrder", { | ||
| 2088 | + data: { | ||
| 2089 | + store_id: os.stoid, | ||
| 2090 | + user_id: usr.user_id, | ||
| 2091 | + goods_id: th.data.sele_g.goods_id, | ||
| 2092 | + prom_id: th.data.prom_goods[0].prom_id | ||
| 2093 | + } | ||
| 2094 | + }).then(res => { | ||
| 2095 | + if (res.data.code == 0) { | ||
| 2096 | + wx.showToast({ | ||
| 2097 | + title: "您已经购买了该商品待支付中", | ||
| 2098 | + icon: 'none', | ||
| 2099 | + duration: 2000 | ||
| 2100 | + }) | ||
| 2101 | + setTimeout(function () { | ||
| 2102 | + getApp().goto("/pages/user/order_detail/order_detail?order_id=" + res.data.data.order_id,) | ||
| 2103 | + }, 1000) | ||
| 2104 | + } | ||
| 2105 | + //未找到相关记录 | ||
| 2106 | + else { | ||
| 2107 | + callback(); | ||
| 2108 | + } | ||
| 2109 | + }) | ||
| 2110 | + } | ||
| 1989 | 2111 | ||
| 1990 | - }) | 2112 | + }) |
| 1991 | 2113 | ||
| 1992 | - } | ||
| 1993 | - }, | 2114 | + } |
| 2115 | + }, | ||
| 1994 | 2116 | ||
| 1995 | 2117 | ||
| 2118 | + //----获取线下价格------- | ||
| 2119 | + get_off_price() { | ||
| 2120 | + var th = this; | ||
| 2121 | + //没有开启就返回 | ||
| 2122 | + if (!th.data.is_open_offline) return false; | ||
| 2123 | + //先看下购买的功能有没有到期 | ||
| 2124 | + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => { | ||
| 2125 | + //未购买 | ||
| 2126 | + if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) { | ||
| 2127 | + return false; | ||
| 2128 | + } else { | ||
| 2129 | + //已经过期 | ||
| 2130 | + var item = res.data.data.pageData[0]; | ||
| 2131 | + if (item.end_time < ut.gettimestamp()) { | ||
| 2132 | + return false; | ||
| 2133 | + } | ||
| 2134 | + } | ||
| 1996 | 2135 | ||
| 1997 | - //----获取线下价格------- | ||
| 1998 | - get_off_price() { | ||
| 1999 | - var th = this; | ||
| 2000 | - //没有开启就返回 | ||
| 2001 | - if (!th.data.is_open_offline) return false; | ||
| 2002 | - //先看下购买的功能有没有到期 | ||
| 2003 | - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => { | ||
| 2004 | - //未购买 | ||
| 2005 | - if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) { | ||
| 2006 | - return false; | ||
| 2007 | - } else { | ||
| 2008 | - //已经过期 | ||
| 2009 | - var item = res.data.data.pageData[0]; | ||
| 2010 | - if (item.end_time < ut.gettimestamp()) { | ||
| 2011 | - return false; | ||
| 2012 | - } | ||
| 2013 | - } | ||
| 2014 | 2136 | ||
| 2137 | + var cur_goods = this.data.sele_g; | ||
| 2138 | + var cur_price = cur_goods.shop_price; | ||
| 2139 | + if (th.data.card_field && cur_goods[th.data.card_field] > 0) { | ||
| 2140 | + cur_price = cur_goods[th.data.card_field]; | ||
| 2141 | + } | ||
| 2015 | 2142 | ||
| 2016 | - var cur_goods = this.data.sele_g; | ||
| 2017 | - var cur_price = cur_goods.shop_price; | ||
| 2018 | - if (th.data.card_field && cur_goods[th.data.card_field] > 0) { | ||
| 2019 | - cur_price = cur_goods[th.data.card_field]; | ||
| 2020 | - } | 2143 | + var user_info = getApp().globalData.userInfo; |
| 2144 | + //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行 | ||
| 2145 | + if (cur_goods.prom_type == 0 && !this.data.prom_goods) { | ||
| 2146 | + cur_goods.offline_price = null; | ||
| 2147 | + //如果没有门店,不用计算线下价格 | ||
| 2148 | + var def_pick_store = this.data.def_pick_store; | ||
| 2149 | + if (!def_pick_store) return false; | ||
| 2150 | + getApp().request.get("/api/weshop/goods/listWarePrice", { | ||
| 2151 | + data: { | ||
| 2152 | + VIPId: encodeURIComponent(user_info.erpvipid), | ||
| 2153 | + store_id: os.stoid, | ||
| 2154 | + PickupId: def_pick_store.pickup_id, | ||
| 2155 | + WareIds: encodeURIComponent(cur_goods.erpwareid) | ||
| 2156 | + }, | ||
| 2157 | + success: function (res) { | ||
| 2158 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 2159 | + var datalist = res.data.data; | ||
| 2160 | + if (datalist[0].WarePrice < cur_price) { | ||
| 2161 | + cur_goods.offline_price = datalist[0].WarePrice; //存储线下活动的价格 | ||
| 2162 | + cur_goods.pricing_type = datalist[0].PriceType; //存储线下活动的类型 | ||
| 2163 | + } | ||
| 2164 | + } | ||
| 2165 | + th.setData({sele_g: cur_goods}); | ||
| 2166 | + } | ||
| 2021 | 2167 | ||
| 2022 | - var user_info = getApp().globalData.userInfo; | ||
| 2023 | - //获取一下接口,判断是不是有线下接口,必须是普通商品,全局优惠活动也是不行 | ||
| 2024 | - if (cur_goods.prom_type == 0 && !this.data.prom_goods) { | ||
| 2025 | - cur_goods.offline_price = null; | ||
| 2026 | - //如果没有门店,不用计算线下价格 | ||
| 2027 | - var def_pick_store = this.data.def_pick_store; | ||
| 2028 | - if (!def_pick_store) return false; | ||
| 2029 | - getApp().request.get("/api/weshop/goods/listWarePrice", { | ||
| 2030 | - data: { | ||
| 2031 | - VIPId: encodeURIComponent(user_info.erpvipid), | ||
| 2032 | - store_id: os.stoid, | ||
| 2033 | - PickupId: def_pick_store.pickup_id, | ||
| 2034 | - WareIds: encodeURIComponent(cur_goods.erpwareid) | ||
| 2035 | - }, | ||
| 2036 | - success: function (res) { | ||
| 2037 | - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 2038 | - var datalist = res.data.data; | ||
| 2039 | - if (datalist[0].WarePrice < cur_price) { | ||
| 2040 | - cur_goods.offline_price = datalist[0].WarePrice; //存储线下活动的价格 | ||
| 2041 | - cur_goods.pricing_type = datalist[0].PriceType; //存储线下活动的类型 | ||
| 2042 | - } | 2168 | + }) |
| 2043 | } | 2169 | } |
| 2044 | - th.setData({ sele_g: cur_goods }); | ||
| 2045 | - } | ||
| 2046 | 2170 | ||
| 2047 | }) | 2171 | }) |
| 2048 | - } | ||
| 2049 | 2172 | ||
| 2050 | - }) | ||
| 2051 | 2173 | ||
| 2174 | + }, | ||
| 2052 | 2175 | ||
| 2053 | - }, | ||
| 2054 | 2176 | ||
| 2177 | + //---------点击收藏和不收藏------------ | ||
| 2178 | + collectGoods: function () { | ||
| 2179 | + var t = this, | ||
| 2180 | + i = getApp().request; | ||
| 2181 | + var user_id = s.globalData.user_id; | ||
| 2182 | + if (user_id == '') { | ||
| 2183 | + getApp().getUserFir(function () { | ||
| 2184 | + }); | ||
| 2185 | + getApp().showWarning("未登录"); | ||
| 2186 | + return false; | ||
| 2187 | + } else { | ||
| 2055 | 2188 | ||
| 2056 | - //---------点击收藏和不收藏------------ | ||
| 2057 | - collectGoods: function () { | ||
| 2058 | - var t = this, | ||
| 2059 | - i = getApp().request; | ||
| 2060 | - var user_id = s.globalData.user_id; | ||
| 2061 | - if (user_id == '') { | ||
| 2062 | - getApp().getUserFir(function () { }); | ||
| 2063 | - getApp().showWarning("未登录"); | ||
| 2064 | - return false; | ||
| 2065 | - } else { | ||
| 2066 | - | ||
| 2067 | - if (t.data.is_collect_load) return false; | ||
| 2068 | - t.data.is_collect_load = 1; | ||
| 2069 | - | ||
| 2070 | - if (t.data.is_collect == 1) { //删除收藏 | ||
| 2071 | - i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, { | ||
| 2072 | - success: function (e) { | ||
| 2073 | - t.data.is_collect_load = 0; | ||
| 2074 | - if (e.data.code == 0) { | ||
| 2075 | - t.setData({ | ||
| 2076 | - is_collect: 0, | ||
| 2077 | - collect_id: 0, | ||
| 2078 | - }); | ||
| 2079 | - } | ||
| 2080 | - } | ||
| 2081 | - }); | ||
| 2082 | - } else { | ||
| 2083 | - var timestamp = Date.parse(new Date()); | ||
| 2084 | - timestamp = timestamp / 1000; | ||
| 2085 | - var d = { | ||
| 2086 | - goods_id: t.data.data.goods_id, | ||
| 2087 | - user_id: s.globalData.user_id, | ||
| 2088 | - store_id: o.stoid, | ||
| 2089 | - add_time: timestamp, | ||
| 2090 | - }; | ||
| 2091 | - //加入收藏夹就是导购的ID | ||
| 2092 | - if (getApp().globalData.guide_id) { | ||
| 2093 | - d.guide_id = getApp().globalData.guide_id; | ||
| 2094 | - d.guide_type = 2; | 2189 | + if (t.data.is_collect_load) return false; |
| 2190 | + t.data.is_collect_load = 1; | ||
| 2191 | + | ||
| 2192 | + if (t.data.is_collect == 1) { //删除收藏 | ||
| 2193 | + i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, { | ||
| 2194 | + success: function (e) { | ||
| 2195 | + t.data.is_collect_load = 0; | ||
| 2196 | + if (e.data.code == 0) { | ||
| 2197 | + t.setData({ | ||
| 2198 | + is_collect: 0, | ||
| 2199 | + collect_id: 0, | ||
| 2200 | + }); | ||
| 2201 | + } | ||
| 2202 | + } | ||
| 2203 | + }); | ||
| 2204 | + } else { | ||
| 2205 | + var timestamp = Date.parse(new Date()); | ||
| 2206 | + timestamp = timestamp / 1000; | ||
| 2207 | + var d = { | ||
| 2208 | + goods_id: t.data.data.goods_id, | ||
| 2209 | + user_id: s.globalData.user_id, | ||
| 2210 | + store_id: o.stoid, | ||
| 2211 | + add_time: timestamp, | ||
| 2212 | + }; | ||
| 2213 | + //加入收藏夹就是导购的ID | ||
| 2214 | + if (getApp().globalData.guide_id) { | ||
| 2215 | + d.guide_id = getApp().globalData.guide_id; | ||
| 2216 | + d.guide_type = 2; | ||
| 2217 | + } | ||
| 2218 | + | ||
| 2219 | + i.post("/api/weshop/goodscollect/save", { //添加收藏 | ||
| 2220 | + data: d, | ||
| 2221 | + success: function (e) { | ||
| 2222 | + t.data.is_collect_load = 0; | ||
| 2223 | + if (e.data.code == 0) { | ||
| 2224 | + t.setData({ | ||
| 2225 | + is_collect: 1, | ||
| 2226 | + collect_id: e.data.data.collect_id, | ||
| 2227 | + }); | ||
| 2228 | + } | ||
| 2229 | + } | ||
| 2230 | + }); | ||
| 2231 | + } | ||
| 2095 | } | 2232 | } |
| 2233 | + }, | ||
| 2096 | 2234 | ||
| 2097 | - i.post("/api/weshop/goodscollect/save", { //添加收藏 | ||
| 2098 | - data: d, | ||
| 2099 | - success: function (e) { | ||
| 2100 | - t.data.is_collect_load = 0; | ||
| 2101 | - if (e.data.code == 0) { | ||
| 2102 | - t.setData({ | ||
| 2103 | - is_collect: 1, | ||
| 2104 | - collect_id: e.data.data.collect_id, | ||
| 2105 | - }); | ||
| 2106 | - } | ||
| 2107 | - } | ||
| 2108 | - }); | ||
| 2109 | - } | ||
| 2110 | - } | ||
| 2111 | - }, | 2235 | + //---------联系客服------------ |
| 2236 | + contactService: function () { | ||
| 2237 | + s.getConfig(function (t) { | ||
| 2238 | + if (t.store_tel == undefined) { | ||
| 2239 | + getApp().request.get("/api/weshop/store/get/" + os.stoid, { | ||
| 2240 | + isShowLoading: 1, | ||
| 2241 | + data: {}, | ||
| 2242 | + success: function (rs) { | ||
| 2243 | + getApp().globalData.config = rs.data.data; | ||
| 2244 | + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | ||
| 2245 | + getApp().my_warnning("商家未设置电话", 0, th); | ||
| 2246 | + return false; | ||
| 2247 | + } | ||
| 2248 | + s.confirmBox("请联系客服:" + rs.data.data.store_tel); | ||
| 2249 | + } | ||
| 2250 | + }) | ||
| 2251 | + } else { | ||
| 2252 | + s.confirmBox("请联系客服:" + t.store_tel); | ||
| 2253 | + } | ||
| 2254 | + }); | ||
| 2255 | + }, | ||
| 2256 | + //-------获取购物车数量---------- | ||
| 2257 | + requestCardNum: function () { | ||
| 2258 | + var t = this; | ||
| 2259 | + getApp().request.get("/api/weshop/cart/page", { | ||
| 2260 | + data: { | ||
| 2261 | + store_id: o.stoid, | ||
| 2262 | + user_id: s.globalData.user_id, | ||
| 2263 | + state: 0, | ||
| 2264 | + is_gift: 0 | ||
| 2265 | + }, | ||
| 2266 | + success: function (e) { | ||
| 2267 | + var num = 0; | ||
| 2268 | + for (var i = 0; i < e.data.data.pageData.length; i++) { | ||
| 2269 | + num += e.data.data.pageData[i].goods_num; | ||
| 2270 | + } | ||
| 2112 | 2271 | ||
| 2113 | - //---------联系客服------------ | ||
| 2114 | - contactService: function () { | ||
| 2115 | - s.getConfig(function (t) { | ||
| 2116 | - if (t.store_tel == undefined) { | ||
| 2117 | - getApp().request.get("/api/weshop/store/get/" + os.stoid, { | ||
| 2118 | - isShowLoading: 1, | ||
| 2119 | - data: {}, | ||
| 2120 | - success: function (rs) { | ||
| 2121 | - getApp().globalData.config = rs.data.data; | ||
| 2122 | - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | ||
| 2123 | - getApp().my_warnning("商家未设置电话", 0, th); | ||
| 2124 | - return false; | ||
| 2125 | - } | ||
| 2126 | - s.confirmBox("请联系客服:" + rs.data.data.store_tel); | ||
| 2127 | - } | ||
| 2128 | - }) | ||
| 2129 | - } else { | ||
| 2130 | - s.confirmBox("请联系客服:" + t.store_tel); | ||
| 2131 | - } | ||
| 2132 | - }); | ||
| 2133 | - }, | ||
| 2134 | - //-------获取购物车数量---------- | ||
| 2135 | - requestCardNum: function () { | ||
| 2136 | - var t = this; | ||
| 2137 | - getApp().request.get("/api/weshop/cart/page", { | ||
| 2138 | - data: { | ||
| 2139 | - store_id: o.stoid, | ||
| 2140 | - user_id: s.globalData.user_id, | ||
| 2141 | - state: 0, | ||
| 2142 | - is_gift: 0 | ||
| 2143 | - }, | ||
| 2144 | - success: function (e) { | ||
| 2145 | - var num = 0; | ||
| 2146 | - for (var i = 0; i < e.data.data.pageData.length; i++) { | ||
| 2147 | - num += e.data.data.pageData[i].goods_num; | 2272 | + //-- 读取服务卡的数量 -- |
| 2273 | + getApp().promiseGet("/api/weshop/cartService/page", { | ||
| 2274 | + data: { | ||
| 2275 | + store_id: s.globalData.setting.stoid, | ||
| 2276 | + user_id: s.globalData.user_id, | ||
| 2277 | + } | ||
| 2278 | + }).then(res => { | ||
| 2279 | + for (var i = 0; i < res.data.data.pageData.length; i++) { | ||
| 2280 | + num += res.data.data.pageData[i].goods_num; | ||
| 2281 | + } | ||
| 2282 | + t.setData({cartGoodsNum: num}); | ||
| 2283 | + }) | ||
| 2284 | + } | ||
| 2285 | + }); | ||
| 2286 | + }, | ||
| 2287 | + | ||
| 2288 | + previewCommentImgs: function (t) { | ||
| 2289 | + var e = this.data.comments[t.currentTarget.dataset.cidx].img; | ||
| 2290 | + var b = e.slice() | ||
| 2291 | + for (var i in b) { | ||
| 2292 | + b[i] = this.data.iurl + e[i]; | ||
| 2148 | } | 2293 | } |
| 2294 | + this.data.show_prew_img = 1; | ||
| 2149 | 2295 | ||
| 2150 | - //-- 读取服务卡的数量 -- | ||
| 2151 | - getApp().promiseGet("/api/weshop/cartService/page", { | ||
| 2152 | - data: { | ||
| 2153 | - store_id: s.globalData.setting.stoid, | ||
| 2154 | - user_id: s.globalData.user_id, | ||
| 2155 | - } | ||
| 2156 | - }).then(res => { | ||
| 2157 | - for (var i = 0; i < res.data.data.pageData.length; i++) { | ||
| 2158 | - num += res.data.data.pageData[i].goods_num; | ||
| 2159 | - } | ||
| 2160 | - t.setData({ cartGoodsNum: num }); | ||
| 2161 | - }) | ||
| 2162 | - } | ||
| 2163 | - }); | ||
| 2164 | - }, | 2296 | + wx.previewImage({ |
| 2297 | + current: b[t.currentTarget.dataset.id], | ||
| 2298 | + urls: b | ||
| 2299 | + }); | ||
| 2300 | + }, | ||
| 2165 | 2301 | ||
| 2166 | - previewCommentImgs: function (t) { | ||
| 2167 | - var e = this.data.comments[t.currentTarget.dataset.cidx].img; | ||
| 2168 | - var b = e.slice() | ||
| 2169 | - for (var i in b) { | ||
| 2170 | - b[i] = this.data.iurl + e[i]; | ||
| 2171 | - } | ||
| 2172 | - this.data.show_prew_img = 1; | 2302 | + previewCommentImgs_w: function (t) { |
| 2303 | + var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | ||
| 2304 | + var b = e.slice() | ||
| 2305 | + for (var i in b) { | ||
| 2306 | + b[i] = this.data.iurl + e[i]; | ||
| 2307 | + } | ||
| 2308 | + this.data.show_prew_img = 1; | ||
| 2309 | + wx.previewImage({ | ||
| 2310 | + current: b[t.currentTarget.dataset.id], | ||
| 2311 | + urls: b | ||
| 2312 | + }); | ||
| 2313 | + }, | ||
| 2173 | 2314 | ||
| 2174 | - wx.previewImage({ | ||
| 2175 | - current: b[t.currentTarget.dataset.id], | ||
| 2176 | - urls: b | ||
| 2177 | - }); | ||
| 2178 | - }, | 2315 | + previewGoodsCommentImgs: function (t) { |
| 2316 | + var e = this, | ||
| 2317 | + a = this.data.data.comment[t.currentTarget.dataset.cidx].img; | ||
| 2318 | + a = a.map(function (t) { | ||
| 2319 | + return e.data.url + t; | ||
| 2320 | + }), wx.previewImage({ | ||
| 2321 | + current: a[t.currentTarget.dataset.id], | ||
| 2322 | + urls: a | ||
| 2323 | + }); | ||
| 2324 | + this.data.show_prew_img = 1; | ||
| 2325 | + }, | ||
| 2326 | + closePromModal: function () { | ||
| 2327 | + this.setData({ | ||
| 2328 | + openPromModal: !1 | ||
| 2329 | + }); | ||
| 2330 | + }, | ||
| 2331 | + openPromModal: function () { | ||
| 2332 | + this.setData({ | ||
| 2333 | + openPromModal: !0 | ||
| 2334 | + }); | ||
| 2335 | + }, | ||
| 2179 | 2336 | ||
| 2180 | - previewCommentImgs_w: function (t) { | ||
| 2181 | - var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | ||
| 2182 | - var b = e.slice() | ||
| 2183 | - for (var i in b) { | ||
| 2184 | - b[i] = this.data.iurl + e[i]; | ||
| 2185 | - } | ||
| 2186 | - this.data.show_prew_img = 1; | ||
| 2187 | - wx.previewImage({ | ||
| 2188 | - current: b[t.currentTarget.dataset.id], | ||
| 2189 | - urls: b | ||
| 2190 | - }); | ||
| 2191 | - }, | 2337 | + //--点击分享事件--- |
| 2338 | + onShareAppMessage: function (t) { | ||
| 2192 | 2339 | ||
| 2193 | - previewGoodsCommentImgs: function (t) { | ||
| 2194 | - var e = this, | ||
| 2195 | - a = this.data.data.comment[t.currentTarget.dataset.cidx].img; | ||
| 2196 | - a = a.map(function (t) { | ||
| 2197 | - return e.data.url + t; | ||
| 2198 | - }), wx.previewImage({ | ||
| 2199 | - current: a[t.currentTarget.dataset.id], | ||
| 2200 | - urls: a | ||
| 2201 | - }); | ||
| 2202 | - this.data.show_prew_img = 1; | ||
| 2203 | - }, | ||
| 2204 | - closePromModal: function () { | ||
| 2205 | - this.setData({ | ||
| 2206 | - openPromModal: !1 | ||
| 2207 | - }); | ||
| 2208 | - }, | ||
| 2209 | - openPromModal: function () { | ||
| 2210 | - this.setData({ | ||
| 2211 | - openPromModal: !0 | ||
| 2212 | - }); | ||
| 2213 | - }, | 2340 | + var th = this; |
| 2341 | + var price = th.data.sele_g.shop_price; | ||
| 2342 | + if (th.data.prom_act) { | ||
| 2343 | + price = th.data.prom_act.price; | ||
| 2214 | 2344 | ||
| 2215 | - //--点击分享事件--- | ||
| 2216 | - onShareAppMessage: function (t) { | 2345 | + } |
| 2346 | + var title = th.data.sele_g.goods_name; | ||
| 2347 | + var img = th.data.sele_g.original_img; | ||
| 2348 | + if (th.data.prom_type == 6 || th.data.prom_type == 1 || th.data.prom_type == 4) { | ||
| 2349 | + title = th.data.prom_act.share_title; | ||
| 2350 | + if (!title) title = th.data.prom_act.title; | ||
| 2351 | + if (th.data.prom_type == 4) title = th.data.prom_act.name; | ||
| 2352 | + | ||
| 2353 | + if (th.data.prom_act.share_imgurl) | ||
| 2354 | + img = th.data.iurl + th.data.prom_act.share_imgurl; | ||
| 2355 | + } | ||
| 2217 | 2356 | ||
| 2218 | - var th = this; | ||
| 2219 | - var price = th.data.sele_g.shop_price; | ||
| 2220 | - if (th.data.prom_act) { | ||
| 2221 | - price = th.data.prom_act.price; | ||
| 2222 | 2357 | ||
| 2223 | - } | ||
| 2224 | - var title = th.data.sele_g.goods_name; | ||
| 2225 | - var img = th.data.sele_g.original_img; | ||
| 2226 | - if (th.data.prom_type == 6 || th.data.prom_type == 1 || th.data.prom_type == 4) { | ||
| 2227 | - title = th.data.prom_act.share_title; | ||
| 2228 | - if (!title) title = th.data.prom_act.title; | ||
| 2229 | - if (th.data.prom_type == 4) title = th.data.prom_act.name; | ||
| 2230 | - | ||
| 2231 | - if (th.data.prom_act.share_imgurl) | ||
| 2232 | - img = th.data.iurl + th.data.prom_act.share_imgurl; | ||
| 2233 | - } | 2358 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" |
| 2359 | + + th.data.sele_g.goods_id + "&prom_type=" + th.data.sele_g.prom_type + "&prom_id=" + th.data.sele_g.prom_id; | ||
| 2360 | + if (getApp().globalData.user_id) { | ||
| 2361 | + url += "&first_leader=" + getApp().globalData.user_id; | ||
| 2362 | + } | ||
| 2234 | 2363 | ||
| 2364 | + //-- 如果房间分享,且不是会员分享的 -- | ||
| 2365 | + if (getApp().globalData.room_id && | ||
| 2366 | + th.data.sele_g.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share | ||
| 2367 | + ) { | ||
| 2368 | + url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | ||
| 2369 | + } | ||
| 2235 | 2370 | ||
| 2236 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" | ||
| 2237 | - + th.data.sele_g.goods_id+"&prom_type="+th.data.sele_g.prom_type+"&prom_id="+th.data.sele_g.prom_id; | ||
| 2238 | - if (getApp().globalData.user_id) { | ||
| 2239 | - url += "&first_leader=" + getApp().globalData.user_id; | ||
| 2240 | - } | 2371 | + var ob = { |
| 2372 | + title: price + "元 " + title, | ||
| 2373 | + path: url, | ||
| 2374 | + imageUrl: img, | ||
| 2375 | + }; | ||
| 2376 | + if (th.data.prom_type == 6) { | ||
| 2377 | + title += '\n' + th.data.prom_act.share_remark; | ||
| 2378 | + ob.title = title; | ||
| 2379 | + ob.desc = th.data.prom_act.share_remark; | ||
| 2380 | + } | ||
| 2241 | 2381 | ||
| 2242 | - //-- 如果房间分享,且不是会员分享的 -- | ||
| 2243 | - if (getApp().globalData.room_id && | ||
| 2244 | - th.data.sele_g.goods_id == getApp().globalData.room_goods_id && | ||
| 2245 | - !getApp().globalData.room_user_share | ||
| 2246 | - ) { | ||
| 2247 | - url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | ||
| 2248 | - } | ||
| 2249 | - console.log(url,500); | ||
| 2250 | - var ob = { | ||
| 2251 | - title: price + "元 " + title, | ||
| 2252 | - path: url, | ||
| 2253 | - imageUrl: img, | ||
| 2254 | - }; | ||
| 2255 | - if (th.data.prom_type == 6) { | ||
| 2256 | - title += '\n' + th.data.prom_act.share_remark; | ||
| 2257 | - ob.title = title; | ||
| 2258 | - ob.desc = th.data.prom_act.share_remark; | ||
| 2259 | - } | 2382 | + //如果是积分购的时候 |
| 2383 | + if (th.data.prom_type == 4) { | ||
| 2384 | + var name = th.data.prom_act.name; | ||
| 2385 | + //-- 积分购的 -- | ||
| 2386 | + var pri0 = th.data.prom_act.addmoney; | ||
| 2387 | + var integral = th.data.prom_act.integral; | ||
| 2388 | + var text = ""; | ||
| 2389 | + if (integral) { text = integral + "积分"; } | ||
| 2390 | + if (pri0 && integral) { text += "+"; } | ||
| 2391 | + if (pri0) { text += "¥" + pri0; } | ||
| 2392 | + | ||
| 2393 | + ob.title = text + " " + name; | ||
| 2394 | + } | ||
| 2395 | + //-- 页面不能刷新 -- | ||
| 2396 | + this.data.show_prew_img=1; | ||
| 2397 | + return ob; | ||
| 2260 | 2398 | ||
| 2261 | - //如果是积分购的时候 | ||
| 2262 | - if (th.data.prom_type == 4) { | ||
| 2263 | - var name = th.data.prom_act.name; | ||
| 2264 | - //-- 积分购的 -- | ||
| 2265 | - var pri0 = th.data.prom_act.addmoney; | ||
| 2266 | - var integral = th.data.prom_act.integral; | ||
| 2267 | - var text = ""; | ||
| 2268 | - if (integral) { text = integral + "积分"; } | ||
| 2269 | - if (pri0 && integral) { text += "+"; } | ||
| 2270 | - if (pri0) { text += "¥" + pri0; } | ||
| 2271 | - | ||
| 2272 | - ob.title = text + " " + name; | ||
| 2273 | - } | ||
| 2274 | - //-- 页面不能刷新 -- | ||
| 2275 | - this.data.show_prew_img=1; | ||
| 2276 | - return ob; | 2399 | + }, |
| 2277 | 2400 | ||
| 2278 | - }, | 2401 | + //-----图片失败,默认图片----- |
| 2402 | + bind_bnerr: function (e) { | ||
| 2403 | + var _errImg = e.target.dataset.errorimg; | ||
| 2404 | + var _errObj = {}; | ||
| 2405 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 2406 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2407 | + }, | ||
| 2279 | 2408 | ||
| 2280 | - //-----图片失败,默认图片----- | ||
| 2281 | - bind_bnerr: function (e) { | ||
| 2282 | - var _errImg = e.target.dataset.errorimg; | ||
| 2283 | - var _errObj = {}; | ||
| 2284 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 2285 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2286 | - }, | 2409 | + //-----图片失败,默认图片----- |
| 2410 | + bind_bnerr2: function (e) { | ||
| 2287 | 2411 | ||
| 2288 | - //-----图片失败,默认图片----- | ||
| 2289 | - bind_bnerr2: function (e) { | 2412 | + var _errImg = e.target.dataset.errorimg; |
| 2413 | + var _errObj = {}; | ||
| 2414 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | ||
| 2415 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2416 | + }, | ||
| 2290 | 2417 | ||
| 2291 | - var _errImg = e.target.dataset.errorimg; | ||
| 2292 | - var _errObj = {}; | ||
| 2293 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | ||
| 2294 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 2295 | - }, | ||
| 2296 | 2418 | ||
| 2297 | //----------装载同一条形码的商品---------- | 2419 | //----------装载同一条形码的商品---------- |
| 2298 | async get_sku(stoid, gd, g_id, is_normal, func) { | 2420 | async get_sku(stoid, gd, g_id, is_normal, func) { |
| @@ -2307,7 +2429,7 @@ Page({ | @@ -2307,7 +2429,7 @@ Page({ | ||
| 2307 | isonsale: 1, | 2429 | isonsale: 1, |
| 2308 | is_on_sale: 1, | 2430 | is_on_sale: 1, |
| 2309 | pageSize: 500, | 2431 | pageSize: 500, |
| 2310 | - orderField: 'sort' | 2432 | + orderField: 'gg_ordid,goods_spec,sort' |
| 2311 | } | 2433 | } |
| 2312 | }).then(res => { | 2434 | }).then(res => { |
| 2313 | var e = res; | 2435 | var e = res; |
| @@ -2331,3866 +2453,3906 @@ Page({ | @@ -2331,3866 +2453,3906 @@ Page({ | ||
| 2331 | }) | 2453 | }) |
| 2332 | } | 2454 | } |
| 2333 | 2455 | ||
| 2334 | - break; | ||
| 2335 | - case 6: | ||
| 2336 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, { | ||
| 2337 | - }).then(res => { | ||
| 2338 | - console.log(res); | ||
| 2339 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2340 | - }) | ||
| 2341 | 2456 | ||
| 2342 | - break; | ||
| 2343 | - case 2: | ||
| 2344 | - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, { | ||
| 2345 | - }).then(res => { | ||
| 2346 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2347 | - }) | ||
| 2348 | - break; | ||
| 2349 | - case 4: | ||
| 2350 | - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, { | ||
| 2351 | - }).then(res => { | ||
| 2352 | - if (res.data.code == 0) prom = res.data.data; | ||
| 2353 | - }) | ||
| 2354 | - break | ||
| 2355 | - //预售和幸运购不参与 | ||
| 2356 | - case 8: | ||
| 2357 | - case 9: | ||
| 2358 | - continue; | ||
| 2359 | - } | 2457 | + break; |
| 2458 | + case 6: | ||
| 2459 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2460 | + console.log(res); | ||
| 2461 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2462 | + }) | ||
| 2360 | 2463 | ||
| 2361 | - } | ||
| 2362 | - //---如果有活动,不算在一起--- | ||
| 2363 | - if (prom) { | ||
| 2364 | - if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 6) { | ||
| 2365 | - console.log(prom); | ||
| 2366 | - if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) continue; | ||
| 2367 | - } else { | ||
| 2368 | - continue; | ||
| 2369 | - } | ||
| 2370 | - } | 2464 | + break; |
| 2465 | + case 2: | ||
| 2466 | + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2467 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2468 | + }) | ||
| 2469 | + break; | ||
| 2470 | + case 4: | ||
| 2471 | + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2472 | + if (res.data.code == 0) prom = res.data.data; | ||
| 2473 | + }) | ||
| 2474 | + break | ||
| 2475 | + //预售和幸运购不参与 | ||
| 2476 | + case 8: | ||
| 2477 | + case 9: | ||
| 2478 | + continue; | ||
| 2479 | + } | ||
| 2480 | + | ||
| 2481 | + } | ||
| 2482 | + //---如果有活动,不算在一起--- | ||
| 2483 | + if (prom) { | ||
| 2484 | + if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 6) { | ||
| 2485 | + console.log(prom); | ||
| 2486 | + if (prom.is_end == 0 && prom.end_time > now && prom.start_time < now) continue; | ||
| 2487 | + } else { | ||
| 2488 | + continue; | ||
| 2489 | + } | ||
| 2490 | + } | ||
| 2371 | 2491 | ||
| 2372 | 2492 | ||
| 2373 | - var item = arrdata[i], gg = ""; | ||
| 2374 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 2375 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | 2493 | + var item = arrdata[i], gg = ""; |
| 2494 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 2495 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 2376 | 2496 | ||
| 2377 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 2378 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 2379 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 2380 | - gg = item.goods_spec + item.goods_color; | ||
| 2381 | - } else { | ||
| 2382 | - gg = "规格" + gb; | ||
| 2383 | - gb++; | ||
| 2384 | - } | ||
| 2385 | - item.gg = gg; | 2497 | + if (item.goods_spec != "" && item.goods_color != "") { |
| 2498 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 2499 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 2500 | + gg = item.goods_spec + item.goods_color; | ||
| 2501 | + } else { | ||
| 2502 | + gg = "规格" + gb; | ||
| 2503 | + gb++; | ||
| 2504 | + } | ||
| 2505 | + item.gg = gg; | ||
| 2386 | 2506 | ||
| 2387 | - if (item.spec_img) | ||
| 2388 | - item.original_img = os.imghost + item.spec_img; | ||
| 2389 | - else | ||
| 2390 | - item.original_img = os.imghost + item.original_img; | 2507 | + if (item.spec_img) |
| 2508 | + item.original_img = os.imghost + item.spec_img; | ||
| 2509 | + else | ||
| 2510 | + item.original_img = os.imghost + item.original_img; | ||
| 2391 | 2511 | ||
| 2392 | 2512 | ||
| 2393 | - if (item.goods_id == g_id) { | ||
| 2394 | - gitem = item; | ||
| 2395 | - } else { | ||
| 2396 | - arrsku.push(item); | ||
| 2397 | - } | ||
| 2398 | - } | ||
| 2399 | - //-----------排列在最前面------------- | ||
| 2400 | - arrsku.splice(0, 0, gitem); | ||
| 2401 | - if (is_normal == 1) { | ||
| 2402 | - tt.setData({ | ||
| 2403 | - sku_g_pt: arrsku, | ||
| 2404 | - sele_g: gitem | ||
| 2405 | - }); | ||
| 2406 | - func(); | ||
| 2407 | - } else { | ||
| 2408 | - tt.setData({ | ||
| 2409 | - sku_g: arrsku, | ||
| 2410 | - sele_g: gitem | ||
| 2411 | - }); | ||
| 2412 | - } | ||
| 2413 | - }, | 2513 | + if (item.goods_id == g_id) { |
| 2514 | + gitem = item; | ||
| 2515 | + } else { | ||
| 2516 | + arrsku.push(item); | ||
| 2517 | + } | ||
| 2518 | + } | ||
| 2519 | + //-----------排列在最前面------------- | ||
| 2520 | + arrsku.splice(0, 0, gitem); | ||
| 2521 | + if (is_normal == 1) { | ||
| 2522 | + tt.setData({ | ||
| 2523 | + sku_g_pt: arrsku, | ||
| 2524 | + sele_g: gitem | ||
| 2525 | + }); | ||
| 2526 | + func(); | ||
| 2527 | + } else { | ||
| 2528 | + tt.setData({ | ||
| 2529 | + sku_g: arrsku, | ||
| 2530 | + sele_g: gitem | ||
| 2531 | + }); | ||
| 2532 | + } | ||
| 2533 | + }, | ||
| 2414 | 2534 | ||
| 2415 | - //-----------选择属性的按钮事件---------- | ||
| 2416 | - sele_spec: function (e) { | ||
| 2417 | - var that = this; | ||
| 2418 | - var gid = e.currentTarget.dataset.gid; | ||
| 2419 | - var nor = e.currentTarget.dataset.nor; | 2535 | + //-----------选择属性的按钮事件---------- |
| 2536 | + sele_spec: function (e) { | ||
| 2537 | + var that = this; | ||
| 2538 | + var gid = e.currentTarget.dataset.gid; | ||
| 2539 | + var nor = e.currentTarget.dataset.nor; | ||
| 2420 | 2540 | ||
| 2421 | - var sku_g = this.data.sku_g; | ||
| 2422 | - if (nor) { | ||
| 2423 | - sku_g = this.data.sku_g_pt; | ||
| 2424 | - } | 2541 | + var sku_g = this.data.sku_g; |
| 2542 | + if (nor) { | ||
| 2543 | + sku_g = this.data.sku_g_pt; | ||
| 2544 | + } | ||
| 2425 | 2545 | ||
| 2426 | - var item = null; | ||
| 2427 | - for (var i in sku_g) { | ||
| 2428 | - if (sku_g[i].goods_id == gid) { | ||
| 2429 | - item = sku_g[i]; | ||
| 2430 | - if(item.original_img.indexOf(that.data.iurl)==-1){ | ||
| 2431 | - item.original_img=that.data.iurl+item.original_img; | 2546 | + var item = null; |
| 2547 | + for (var i in sku_g) { | ||
| 2548 | + if (sku_g[i].goods_id == gid) { | ||
| 2549 | + item = sku_g[i]; | ||
| 2550 | + if (item.original_img.indexOf(that.data.iurl) == -1) { | ||
| 2551 | + item.original_img = that.data.iurl + item.original_img; | ||
| 2552 | + } | ||
| 2553 | + break | ||
| 2554 | + } | ||
| 2432 | } | 2555 | } |
| 2433 | - break | ||
| 2434 | - } | ||
| 2435 | - } | ||
| 2436 | - console.log(item,2000); | ||
| 2437 | - var cur_price = item.shop_price; | ||
| 2438 | - if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | 2556 | + console.log(item, 2000); |
| 2557 | + var cur_price = item.shop_price; | ||
| 2558 | + if (getApp().globalData.userInfo && getApp().globalData.userInfo.card_field) { | ||
| 2439 | var cfile = getApp().globalData.userInfo.card_field; | 2559 | var cfile = getApp().globalData.userInfo.card_field; |
| 2440 | - console.log('cfile',cfile); | 2560 | + console.log('cfile', cfile); |
| 2441 | if (item[cfile]) { | 2561 | if (item[cfile]) { |
| 2442 | - cur_price =item[cfile]; | ||
| 2443 | - } | ||
| 2444 | - } | ||
| 2445 | - var txt = (cur_price / item.market_price * 10).toFixed(2).toString(); | ||
| 2446 | - txt = parseFloat(txt); | ||
| 2447 | - item['disc'] = txt; | ||
| 2448 | - if (item) this.setData({ | ||
| 2449 | - sele_g: item, | ||
| 2450 | - gid: gid, | ||
| 2451 | - data:item, | ||
| 2452 | - }); | ||
| 2453 | - | ||
| 2454 | - | ||
| 2455 | - that.check_is_youhui(gid, that.data.is_normal); | ||
| 2456 | - | ||
| 2457 | - //默认门店要拿下门店库存 | ||
| 2458 | - if (that.data.sales_rules == 2 && that.data.def_pick_store) { | ||
| 2459 | - var lock = 0, plist = null; | ||
| 2460 | - //先读取门店的lock,采用链式写法,少用await | ||
| 2461 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 2462 | - data: { store_id: os.stoid, wareId: that.data.sele_g.goods_id, storageId: that.data.def_pick_store.pickup_id, pageSize: 1000 } | ||
| 2463 | - }).then(res => { | ||
| 2464 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2465 | - for (var i in res.data.data.pageData) | ||
| 2466 | - lock += res.data.data.pageData[i].outQty | ||
| 2467 | - } | ||
| 2468 | - //---通过接口获取门店的线下库存信息-- | ||
| 2469 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 2470 | - data: { storageNos: that.data.def_pick_store.pickup_no, wareIds: encodeURIComponent(that.data.sele_g.erpwareid), storeId: os.stoid } | ||
| 2471 | - }) | ||
| 2472 | - }).then(res => { | ||
| 2473 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2474 | - plist = res.data.data.pageData[0]; | 2562 | + cur_price = item[cfile]; |
| 2563 | + } | ||
| 2475 | } | 2564 | } |
| 2476 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 2477 | - that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | ||
| 2478 | - } else { | ||
| 2479 | - that.data.def_pick_store.CanOutQty = 0; | 2565 | + var txt = (cur_price / item.market_price * 10).toFixed(2).toString(); |
| 2566 | + txt = parseFloat(txt); | ||
| 2567 | + item['disc'] = txt; | ||
| 2568 | + if (item) this.setData({ | ||
| 2569 | + sele_g: item, | ||
| 2570 | + gid: gid, | ||
| 2571 | + data: item, | ||
| 2572 | + }); | ||
| 2573 | + | ||
| 2574 | + | ||
| 2575 | + that.check_is_youhui(gid, that.data.is_normal); | ||
| 2576 | + | ||
| 2577 | + //默认门店要拿下门店库存 | ||
| 2578 | + if (that.data.sales_rules == 2 && that.data.def_pick_store) { | ||
| 2579 | + var lock = 0, plist = null; | ||
| 2580 | + //先读取门店的lock,采用链式写法,少用await | ||
| 2581 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 2582 | + data: { | ||
| 2583 | + store_id: os.stoid, | ||
| 2584 | + wareId: that.data.sele_g.goods_id, | ||
| 2585 | + storageId: that.data.def_pick_store.pickup_id, | ||
| 2586 | + pageSize: 1000 | ||
| 2587 | + } | ||
| 2588 | + }).then(res => { | ||
| 2589 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2590 | + for (var i in res.data.data.pageData) | ||
| 2591 | + lock += res.data.data.pageData[i].outQty | ||
| 2592 | + } | ||
| 2593 | + //---通过接口获取门店的线下库存信息-- | ||
| 2594 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 2595 | + data: { | ||
| 2596 | + storageNos: that.data.def_pick_store.pickup_no, | ||
| 2597 | + wareIds: encodeURIComponent(that.data.sele_g.erpwareid), | ||
| 2598 | + storeId: os.stoid | ||
| 2599 | + } | ||
| 2600 | + }) | ||
| 2601 | + }).then(res => { | ||
| 2602 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2603 | + plist = res.data.data.pageData[0]; | ||
| 2604 | + } | ||
| 2605 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 2606 | + that.data.def_pick_store.CanOutQty = plist.CanOutQty - lock; | ||
| 2607 | + } else { | ||
| 2608 | + that.data.def_pick_store.CanOutQty = 0; | ||
| 2609 | + } | ||
| 2610 | + //--给门店赋值线下库存-- | ||
| 2611 | + that.setData({def_pick_store: that.data.def_pick_store}); | ||
| 2612 | + }) | ||
| 2480 | } | 2613 | } |
| 2481 | - //--给门店赋值线下库存-- | ||
| 2482 | - that.setData({ def_pick_store: that.data.def_pick_store }); | ||
| 2483 | - }) | ||
| 2484 | - } | ||
| 2485 | - this.sele_spec_chech_activity(); | ||
| 2486 | - }, | 2614 | + this.sele_spec_chech_activity(); |
| 2615 | + }, | ||
| 2487 | 2616 | ||
| 2488 | - //选择了不同的规格的时候要判断是不是有活动正在进行中 | ||
| 2489 | - async sele_spec_chech_activity() { | ||
| 2490 | - //---如果是活动的时候--- | ||
| 2491 | - var prom = null, goodsinfo = this.data.sele_g, th = this; | ||
| 2492 | - var user_id=getApp().globalData.user_id; | ||
| 2493 | - if(!user_id) user_id=0; | ||
| 2494 | - if (goodsinfo.prom_type == 1) { | ||
| 2495 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" +user_id+"/"+ goodsinfo.prom_id, { | ||
| 2496 | - }).then(res => { | ||
| 2497 | - if (res.data.code == 0) { | ||
| 2498 | - prom = res.data.data; | ||
| 2499 | - prom.price=prom.user_price; | 2617 | + //选择了不同的规格的时候要判断是不是有活动正在进行中 |
| 2618 | + async sele_spec_chech_activity() { | ||
| 2619 | + //---如果是活动的时候--- | ||
| 2620 | + var prom = null, goodsinfo = this.data.sele_g, th = this; | ||
| 2621 | + var user_id = getApp().globalData.user_id; | ||
| 2622 | + if (!user_id) user_id = 0; | ||
| 2623 | + if (goodsinfo.prom_type == 1) { | ||
| 2624 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2625 | + if (res.data.code == 0) { | ||
| 2626 | + prom = res.data.data; | ||
| 2627 | + prom.price = prom.user_price; | ||
| 2628 | + } | ||
| 2629 | + }) | ||
| 2500 | } | 2630 | } |
| 2501 | - }) | ||
| 2502 | - } | ||
| 2503 | - if (goodsinfo.prom_type == 6) { | ||
| 2504 | - await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, { | ||
| 2505 | - }).then(res => { | ||
| 2506 | - if (res.data.code == 0) { | ||
| 2507 | - prom = res.data.data; | 2631 | + if (goodsinfo.prom_type == 6) { |
| 2632 | + await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2633 | + if (res.data.code == 0) { | ||
| 2634 | + prom = res.data.data; | ||
| 2635 | + } | ||
| 2636 | + }) | ||
| 2508 | } | 2637 | } |
| 2509 | - }) | ||
| 2510 | - } | ||
| 2511 | 2638 | ||
| 2512 | - if (goodsinfo.prom_type == 4) { | ||
| 2513 | - await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, { | ||
| 2514 | - }).then(res => { | ||
| 2515 | - if (res.data.code == 0) { | ||
| 2516 | - prom = res.data.data; | 2639 | + if (goodsinfo.prom_type == 4) { |
| 2640 | + await getApp().request.promiseGet("/api/weshop/integralbuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | ||
| 2641 | + if (res.data.code == 0) { | ||
| 2642 | + prom = res.data.data; | ||
| 2643 | + } | ||
| 2644 | + }) | ||
| 2517 | } | 2645 | } |
| 2518 | - }) | ||
| 2519 | - } | ||
| 2520 | - | ||
| 2521 | - //----------如果有活动,并且在进行中,就不计算线下库存--------------- | ||
| 2522 | - var now = ut.gettimestamp(); | ||
| 2523 | - if (prom) { | ||
| 2524 | 2646 | ||
| 2525 | - var t1=prom.start_time; | ||
| 2526 | - var prom_st=1; | ||
| 2527 | - if(prom.show_time){ | ||
| 2528 | - t1=prom.show_time; | ||
| 2529 | - if(prom.start_time>now) prom_st=0; | ||
| 2530 | - } | ||
| 2531 | - if (prom.is_end == 0 && prom.end_time > now && t1 < now) { | ||
| 2532 | - th.setData({ | ||
| 2533 | - prom_type: goodsinfo.prom_type, | ||
| 2534 | - prom_price: prom.price, | ||
| 2535 | - prom_buy_limit: prom.buy_limit?prom.buy_limit:(prom.limitvipqty? prom.limitvipqty:0), | ||
| 2536 | - prom_end_time: prom.end_time, | ||
| 2537 | - prom_start_time: prom.start_time, | ||
| 2538 | - prom_st: prom_st, | ||
| 2539 | - prom_act: prom, | ||
| 2540 | - prom_id:prom.id | ||
| 2541 | - }) | 2647 | + //----------如果有活动,并且在进行中,就不计算线下库存--------------- |
| 2648 | + var now = ut.gettimestamp(); | ||
| 2649 | + if (prom) { | ||
| 2542 | 2650 | ||
| 2543 | - //却换图片 | ||
| 2544 | - th.init(goodsinfo.goods_id); | ||
| 2545 | - var newTime = ut.gettimestamp(); | ||
| 2546 | - var endTime2 = prom.end_time; | ||
| 2547 | - var endTime1 = prom.start_time; | ||
| 2548 | - | ||
| 2549 | - this.data.is_timer=0; | ||
| 2550 | - | ||
| 2551 | - setTimeout(function () { | ||
| 2552 | - th.data.is_timer=1; | ||
| 2553 | - if (endTime1 > newTime) { | ||
| 2554 | - th.setData({ | ||
| 2555 | - prom_time_text: '距秒杀开始还有' | ||
| 2556 | - }) | ||
| 2557 | - th.countDown(endTime1, 0); | ||
| 2558 | - } else { | ||
| 2559 | - if (endTime2 > newTime) { | ||
| 2560 | - th.setData({ | ||
| 2561 | - prom_time_text: '距秒杀结束还有', | ||
| 2562 | - prom_st: 1 | ||
| 2563 | - }) | ||
| 2564 | - th.countDown(endTime2); | ||
| 2565 | - } | ||
| 2566 | - } | ||
| 2567 | - | ||
| 2568 | - },1000) | ||
| 2569 | - | ||
| 2570 | - return false; | ||
| 2571 | - } | ||
| 2572 | - } | ||
| 2573 | - //---设置普通商品--- | ||
| 2574 | - th.setData({ | ||
| 2575 | - prom_type: 0, | ||
| 2576 | - prom_price: null, | ||
| 2577 | - prom_buy_limit: null, | ||
| 2578 | - prom_end_time: null, | ||
| 2579 | - prom_start_time: null, | ||
| 2580 | - prom_st: null, | ||
| 2581 | - }) | 2651 | + var t1 = prom.start_time; |
| 2652 | + var prom_st = 1; | ||
| 2653 | + if (prom.show_time) { | ||
| 2654 | + t1 = prom.show_time; | ||
| 2655 | + if (prom.start_time > now) prom_st = 0; | ||
| 2656 | + } | ||
| 2657 | + if (prom.is_end == 0 && prom.end_time > now && t1 < now) { | ||
| 2658 | + th.setData({ | ||
| 2659 | + prom_type: goodsinfo.prom_type, | ||
| 2660 | + prom_price: prom.price, | ||
| 2661 | + prom_buy_limit: prom.buy_limit ? prom.buy_limit : (prom.limitvipqty ? prom.limitvipqty : 0), | ||
| 2662 | + prom_end_time: prom.end_time, | ||
| 2663 | + prom_start_time: prom.start_time, | ||
| 2664 | + prom_st: prom_st, | ||
| 2665 | + prom_act: prom, | ||
| 2666 | + prom_id: prom.id | ||
| 2667 | + }) | ||
| 2582 | 2668 | ||
| 2583 | - }, | 2669 | + //却换图片 |
| 2670 | + th.init(goodsinfo.goods_id); | ||
| 2671 | + var newTime = ut.gettimestamp(); | ||
| 2672 | + var endTime2 = prom.end_time; | ||
| 2673 | + var endTime1 = prom.start_time; | ||
| 2584 | 2674 | ||
| 2675 | + this.data.is_timer = 0; | ||
| 2585 | 2676 | ||
| 2586 | - //---------拿出门店分类和门店------------ | ||
| 2587 | - get_sto(e) { | ||
| 2588 | - console.log('get_sto') | ||
| 2589 | - var th = this, that = this; | ||
| 2590 | - var is_normal = e; | 2677 | + setTimeout(function () { |
| 2678 | + th.data.is_timer = 1; | ||
| 2679 | + if (endTime1 > newTime) { | ||
| 2680 | + th.setData({ | ||
| 2681 | + prom_time_text: '距秒杀开始还有' | ||
| 2682 | + }) | ||
| 2683 | + th.countDown(endTime1, 0); | ||
| 2684 | + } else { | ||
| 2685 | + if (endTime2 > newTime) { | ||
| 2686 | + th.setData({ | ||
| 2687 | + prom_time_text: '距秒杀结束还有', | ||
| 2688 | + prom_st: 1 | ||
| 2689 | + }) | ||
| 2690 | + th.countDown(endTime2); | ||
| 2691 | + } | ||
| 2692 | + } | ||
| 2591 | 2693 | ||
| 2592 | - if (e == 1) { | ||
| 2593 | - th.setData({ is_normal: 1 }) | ||
| 2594 | - } else { | ||
| 2595 | - th.setData({ is_normal: 0 }) | ||
| 2596 | - } | 2694 | + }, 1000) |
| 2597 | 2695 | ||
| 2598 | - var timer_get = setInterval(function () { | ||
| 2599 | - if (th.data.is_get_local_ok == 0) return false; | ||
| 2600 | - var dd = null, i = getApp().request; | ||
| 2601 | - if (!th.data.sele_g) return false; | ||
| 2602 | - | ||
| 2603 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 2604 | - if (g_distr_type != 0) { | ||
| 2605 | - dd = { | ||
| 2606 | - store_id: o.stoid, | ||
| 2607 | - distr_type: g_distr_type, | ||
| 2608 | - isstop: 0, | ||
| 2609 | - is_pos:1, | ||
| 2610 | - pageSize: 2000 | ||
| 2611 | - } | ||
| 2612 | - } else { | ||
| 2613 | - dd = { | ||
| 2614 | - store_id: o.stoid, | ||
| 2615 | - isstop: 0, | ||
| 2616 | - is_pos:1, | ||
| 2617 | - pageSize: 2000 | 2696 | + return false; |
| 2697 | + } | ||
| 2618 | } | 2698 | } |
| 2619 | - } | ||
| 2620 | - //如果有距离的话 | ||
| 2621 | - if (th.data.lat != null) { | ||
| 2622 | - dd.lat = th.data.lat; | ||
| 2623 | - dd.lon = th.data.lon; | ||
| 2624 | - } | ||
| 2625 | - clearInterval(timer_get); | ||
| 2626 | - | ||
| 2627 | - //如果会员是有默认的门店话 | ||
| 2628 | - if (!th.data.def_pick_store && th.data.fir_def_store) { | ||
| 2629 | - th.setData({ def_pick_store: th.data.fir_def_store }); | ||
| 2630 | - } | ||
| 2631 | - wx.showLoading({ | ||
| 2632 | - title: '加载中.' | ||
| 2633 | - }); | ||
| 2634 | - //----------获取门店---------------- | ||
| 2635 | - getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 2636 | - data: dd, | ||
| 2637 | - }).then(res => { | ||
| 2638 | - var e = res; | 2699 | + //---设置普通商品--- |
| 2700 | + th.setData({ | ||
| 2701 | + prom_type: 0, | ||
| 2702 | + prom_price: null, | ||
| 2703 | + prom_buy_limit: null, | ||
| 2704 | + prom_end_time: null, | ||
| 2705 | + prom_start_time: null, | ||
| 2706 | + prom_st: null, | ||
| 2707 | + }) | ||
| 2639 | 2708 | ||
| 2640 | - if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { | 2709 | + }, |
| 2641 | 2710 | ||
| 2642 | - var his_cate_num = 0; | ||
| 2643 | - for (let i in e.data.data.pageData) { | ||
| 2644 | - let item = e.data.data.pageData[i]; | ||
| 2645 | - if (item.category_id > 0) { | ||
| 2646 | - his_cate_num = 1; break; | ||
| 2647 | - } | ||
| 2648 | - } | ||
| 2649 | - e.his_cate_num = his_cate_num; | ||
| 2650 | 2711 | ||
| 2712 | + //---------拿出门店分类和门店------------ | ||
| 2713 | + get_sto(e) { | ||
| 2714 | + console.log('get_sto') | ||
| 2715 | + var th = this, that = this; | ||
| 2716 | + var is_normal = e; | ||
| 2651 | 2717 | ||
| 2652 | - //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 | ||
| 2653 | - if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 2654 | - th.setData({ | ||
| 2655 | - def_pick_store: e.data.data.pageData[0], | ||
| 2656 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2657 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2658 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2659 | - }); | ||
| 2660 | - th.data.fir_def_store = e.data.data.pageData[0]; | ||
| 2661 | - } | 2718 | + if (e == 1) { |
| 2719 | + th.setData({is_normal: 1}) | ||
| 2720 | + } else { | ||
| 2721 | + th.setData({is_normal: 0}) | ||
| 2722 | + } | ||
| 2662 | 2723 | ||
| 2663 | - //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | ||
| 2664 | - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { | ||
| 2665 | - for (var k = 0; k < e.data.data.pageData.length; k++) { | ||
| 2666 | - if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 2667 | - e.data.data.pageData.splice(k, 1); //删除 | ||
| 2668 | - break; | ||
| 2669 | - } | 2724 | + var timer_get = setInterval(function () { |
| 2725 | + if (th.data.is_get_local_ok == 0) return false; | ||
| 2726 | + var dd = null, i = getApp().request; | ||
| 2727 | + if (!th.data.sele_g) return false; | ||
| 2728 | + | ||
| 2729 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 2730 | + if (g_distr_type != 0) { | ||
| 2731 | + dd = { | ||
| 2732 | + store_id: o.stoid, | ||
| 2733 | + distr_type: g_distr_type, | ||
| 2734 | + isstop: 0, | ||
| 2735 | + is_pos: 1, | ||
| 2736 | + pageSize: 2000 | ||
| 2737 | + } | ||
| 2738 | + } else { | ||
| 2739 | + dd = { | ||
| 2740 | + store_id: o.stoid, | ||
| 2741 | + isstop: 0, | ||
| 2742 | + is_pos: 1, | ||
| 2743 | + pageSize: 2000 | ||
| 2744 | + } | ||
| 2670 | } | 2745 | } |
| 2671 | - e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | ||
| 2672 | - } | 2746 | + //如果有距离的话 |
| 2747 | + if (th.data.lat != null) { | ||
| 2748 | + dd.lat = th.data.lat; | ||
| 2749 | + dd.lon = th.data.lon; | ||
| 2750 | + } | ||
| 2751 | + clearInterval(timer_get); | ||
| 2673 | 2752 | ||
| 2753 | + //如果会员是有默认的门店话 | ||
| 2754 | + if (!th.data.def_pick_store && th.data.fir_def_store) { | ||
| 2755 | + th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 2756 | + } | ||
| 2757 | + wx.showLoading({ | ||
| 2758 | + title: '加载中.' | ||
| 2759 | + }); | ||
| 2760 | + //----------获取门店---------------- | ||
| 2761 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | ||
| 2762 | + data: dd, | ||
| 2763 | + }).then(res => { | ||
| 2764 | + var e = res; | ||
| 2674 | 2765 | ||
| 2675 | - th.setData({ all_pick_list: e.data.data.pageData }); | 2766 | + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { |
| 2676 | 2767 | ||
| 2677 | - //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- | ||
| 2678 | - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { | ||
| 2679 | - setTimeout(function () { | ||
| 2680 | - th.deal_pickup_dline(e); | ||
| 2681 | - }, 800) | ||
| 2682 | - } else { | ||
| 2683 | - setTimeout(function () { | ||
| 2684 | - th.deal_pickup(e); //--普通门店排版-- | ||
| 2685 | - }, 800) | ||
| 2686 | - } | ||
| 2687 | - } | ||
| 2688 | - }) | ||
| 2689 | - }, 200) | 2768 | + var his_cate_num = 0; |
| 2769 | + for (let i in e.data.data.pageData) { | ||
| 2770 | + let item = e.data.data.pageData[i]; | ||
| 2771 | + if (item.category_id > 0) { | ||
| 2772 | + his_cate_num = 1; | ||
| 2773 | + break; | ||
| 2774 | + } | ||
| 2775 | + } | ||
| 2776 | + e.his_cate_num = his_cate_num; | ||
| 2690 | 2777 | ||
| 2691 | - }, | 2778 | + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 |
| 2779 | + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 2780 | + th.setData({ | ||
| 2781 | + def_pick_store: e.data.data.pageData[0], | ||
| 2782 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2783 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2784 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2785 | + }); | ||
| 2786 | + th.data.fir_def_store = e.data.data.pageData[0]; | ||
| 2787 | + } | ||
| 2692 | 2788 | ||
| 2789 | + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | ||
| 2790 | + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { | ||
| 2791 | + for (var k = 0; k < e.data.data.pageData.length; k++) { | ||
| 2792 | + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 2793 | + e.data.data.pageData.splice(k, 1); //删除 | ||
| 2794 | + break; | ||
| 2795 | + } | ||
| 2796 | + } | ||
| 2797 | + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | ||
| 2798 | + } | ||
| 2693 | 2799 | ||
| 2694 | - //------------处理门店--------------- | ||
| 2695 | - deal_pickup(e) { | ||
| 2696 | - var th = this; | ||
| 2697 | - if (!th.data.sele_g) return false | ||
| 2698 | 2800 | ||
| 2699 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 2700 | - wx.hideLoading(); | 2801 | + th.setData({all_pick_list: e.data.data.pageData}); |
| 2701 | 2802 | ||
| 2702 | - //单总量超出10个的时候,同时门店有分类 | ||
| 2703 | - if (e.data.data.total > 10 && e.his_cate_num) { | ||
| 2704 | - getApp().request.get("/api/weshop/storagecategory/page", { | ||
| 2705 | - data: { | ||
| 2706 | - store_id: o.stoid, | ||
| 2707 | - pageSize: 1000, | ||
| 2708 | - orderField: "sort", | ||
| 2709 | - orderType: 'asc', | ||
| 2710 | - }, | ||
| 2711 | - success: function (ee) { | ||
| 2712 | - if (ee.data.code == 0) { | ||
| 2713 | - var check_all_cate=0; | ||
| 2714 | - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){ | ||
| 2715 | - for(let i in ee.data.data.pageData){ | ||
| 2716 | - let item=ee.data.data.pageData[i]; | ||
| 2717 | - if(item.is_show==1){ | ||
| 2718 | - check_all_cate=1;break | ||
| 2719 | - } | ||
| 2720 | - } | ||
| 2721 | - } | ||
| 2722 | - if (check_all_cate) { | ||
| 2723 | - var sto_cate = ee.data.data.pageData; | ||
| 2724 | - var sto_arr = e.data.data.pageData; | ||
| 2725 | - var newarr = new Array(); | ||
| 2726 | - var qita = new Array(); | ||
| 2727 | - | ||
| 2728 | - | ||
| 2729 | - var is_del_pk=0; | ||
| 2730 | - //----要进行门店分组-------- | ||
| 2731 | - for (var i = 0; i < sto_arr.length; i++) { | ||
| 2732 | - //找一下这个门店有没有在分类数组内 | ||
| 2733 | - var find2 = 0, find2name = "", sort = 0; | ||
| 2734 | - is_del_pk=0; | ||
| 2735 | - for (var m = 0; m < sto_cate.length; m++) { | ||
| 2736 | - if (sto_arr[i].category_id == sto_cate[m].cat_id) { | ||
| 2737 | - if(sto_cate[m].is_show!=1){ | ||
| 2738 | - is_del_pk=1; sto_arr.splice(i,1); | ||
| 2739 | - i--; | ||
| 2740 | - }else { | ||
| 2741 | - find2 = sto_cate[m].cat_id; | ||
| 2742 | - find2name = sto_cate[m].cat_name; | ||
| 2743 | - sort = sto_cate[m].sort; | ||
| 2744 | - is_del_pk=0; | ||
| 2745 | - } | ||
| 2746 | - break; | ||
| 2747 | - } | ||
| 2748 | - } | ||
| 2749 | - if(is_del_pk) continue; | ||
| 2750 | - | ||
| 2751 | - if (newarr.length > 0) { | ||
| 2752 | - var find = 0; | ||
| 2753 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 2754 | - if (find2 != 0) { | ||
| 2755 | - for (var ii = 0; ii < newarr.length; ii++) { | ||
| 2756 | - if (sto_arr[i].category_id == newarr[ii].cat_id) { | ||
| 2757 | - newarr[ii].s_arr.push(sto_arr[i]); | ||
| 2758 | - find = 1; | ||
| 2759 | - break; | ||
| 2760 | - } | ||
| 2761 | - } | ||
| 2762 | - if (find == 0) { | ||
| 2763 | - var arr0 = new Array(); | ||
| 2764 | - arr0.push(sto_arr[i]); | ||
| 2765 | - var item = { | ||
| 2766 | - cat_id: find2, | ||
| 2767 | - name: find2name, | ||
| 2768 | - sort: sort, | ||
| 2769 | - s_arr: arr0 | ||
| 2770 | - }; | ||
| 2771 | - newarr.push(item); | 2803 | + //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购-- |
| 2804 | + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4) || is_normal == 1)) { | ||
| 2805 | + setTimeout(function () { | ||
| 2806 | + th.deal_pickup_dline(e); | ||
| 2807 | + }, 800) | ||
| 2808 | + } else { | ||
| 2809 | + setTimeout(function () { | ||
| 2810 | + th.deal_pickup(e); //--普通门店排版-- | ||
| 2811 | + }, 800) | ||
| 2772 | } | 2812 | } |
| 2773 | - } else { | ||
| 2774 | - qita.push(sto_arr[i]); | ||
| 2775 | - } | ||
| 2776 | - } else { | ||
| 2777 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 2778 | - if (find2 != 0) { | ||
| 2779 | - var arr0 = new Array(); | ||
| 2780 | - arr0.push(sto_arr[i]); | ||
| 2781 | - var item = { | ||
| 2782 | - cat_id: find2, | ||
| 2783 | - name: find2name, | ||
| 2784 | - sort: sort, | ||
| 2785 | - s_arr: arr0 | ||
| 2786 | - }; | ||
| 2787 | - newarr.push(item); | ||
| 2788 | - } else { | ||
| 2789 | - qita.push(sto_arr[i]); | ||
| 2790 | - } | ||
| 2791 | } | 2813 | } |
| 2792 | - } | 2814 | + }) |
| 2815 | + }, 200) | ||
| 2793 | 2816 | ||
| 2794 | - var def_arr = new Array(); | ||
| 2795 | - //-- 开始就看10个门店 -- | ||
| 2796 | - for (var k = 0; k < 10; k++) { | ||
| 2797 | - if (k == sto_arr.length) break; | ||
| 2798 | - def_arr.push(sto_arr[k]); | ||
| 2799 | - } | 2817 | + }, |
| 2800 | 2818 | ||
| 2801 | - th.setData({ | ||
| 2802 | - def_pickpu_list: def_arr, | ||
| 2803 | - pickpu_list: ee.data.data.pageData | ||
| 2804 | - }); | ||
| 2805 | 2819 | ||
| 2820 | + //------------处理门店--------------- | ||
| 2821 | + deal_pickup(e) { | ||
| 2822 | + var th = this; | ||
| 2823 | + if (!th.data.sele_g) return false | ||
| 2806 | 2824 | ||
| 2807 | - //门店分类要排序下 | ||
| 2808 | - function compare(property) { | ||
| 2809 | - return function (a, b) { | ||
| 2810 | - var value1 = a[property]; | ||
| 2811 | - var value2 = b[property]; | ||
| 2812 | - return value1 - value2; | ||
| 2813 | - } | ||
| 2814 | - } | ||
| 2815 | - if (newarr.length > 0) | ||
| 2816 | - newarr.sort(compare("sort")); | 2825 | + var g_distr_type = th.data.sele_g.distr_type; |
| 2826 | + wx.hideLoading(); | ||
| 2817 | 2827 | ||
| 2828 | + //单总量超出10个的时候,同时门店有分类 | ||
| 2829 | + if (e.data.data.total > 10 && e.his_cate_num) { | ||
| 2830 | + getApp().request.get("/api/weshop/storagecategory/page", { | ||
| 2831 | + data: { | ||
| 2832 | + store_id: o.stoid, | ||
| 2833 | + pageSize: 1000, | ||
| 2834 | + orderField: "sort", | ||
| 2835 | + orderType: 'asc', | ||
| 2836 | + }, | ||
| 2837 | + success: function (ee) { | ||
| 2838 | + if (ee.data.code == 0) { | ||
| 2839 | + var check_all_cate = 0; | ||
| 2840 | + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) { | ||
| 2841 | + for (let i in ee.data.data.pageData) { | ||
| 2842 | + let item = ee.data.data.pageData[i]; | ||
| 2843 | + if (item.is_show == 1) { | ||
| 2844 | + check_all_cate = 1; | ||
| 2845 | + break | ||
| 2846 | + } | ||
| 2847 | + } | ||
| 2848 | + } | ||
| 2849 | + if (check_all_cate) { | ||
| 2850 | + var sto_cate = ee.data.data.pageData; | ||
| 2851 | + var sto_arr = e.data.data.pageData; | ||
| 2852 | + var newarr = new Array(); | ||
| 2853 | + var qita = new Array(); | ||
| 2854 | + | ||
| 2855 | + | ||
| 2856 | + var is_del_pk = 0; | ||
| 2857 | + //----要进行门店分组-------- | ||
| 2858 | + for (var i = 0; i < sto_arr.length; i++) { | ||
| 2859 | + //找一下这个门店有没有在分类数组内 | ||
| 2860 | + var find2 = 0, find2name = "", sort = 0; | ||
| 2861 | + is_del_pk = 0; | ||
| 2862 | + for (var m = 0; m < sto_cate.length; m++) { | ||
| 2863 | + if (sto_arr[i].category_id == sto_cate[m].cat_id) { | ||
| 2864 | + if (sto_cate[m].is_show != 1) { | ||
| 2865 | + is_del_pk = 1; | ||
| 2866 | + sto_arr.splice(i, 1); | ||
| 2867 | + i--; | ||
| 2868 | + } else { | ||
| 2869 | + find2 = sto_cate[m].cat_id; | ||
| 2870 | + find2name = sto_cate[m].cat_name; | ||
| 2871 | + sort = sto_cate[m].sort; | ||
| 2872 | + is_del_pk = 0; | ||
| 2873 | + } | ||
| 2874 | + break; | ||
| 2875 | + } | ||
| 2876 | + } | ||
| 2877 | + if (is_del_pk) continue; | ||
| 2878 | + | ||
| 2879 | + if (newarr.length > 0) { | ||
| 2880 | + var find = 0; | ||
| 2881 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 2882 | + if (find2 != 0) { | ||
| 2883 | + for (var ii = 0; ii < newarr.length; ii++) { | ||
| 2884 | + if (sto_arr[i].category_id == newarr[ii].cat_id) { | ||
| 2885 | + newarr[ii].s_arr.push(sto_arr[i]); | ||
| 2886 | + find = 1; | ||
| 2887 | + break; | ||
| 2888 | + } | ||
| 2889 | + } | ||
| 2890 | + if (find == 0) { | ||
| 2891 | + var arr0 = new Array(); | ||
| 2892 | + arr0.push(sto_arr[i]); | ||
| 2893 | + var item = { | ||
| 2894 | + cat_id: find2, | ||
| 2895 | + name: find2name, | ||
| 2896 | + sort: sort, | ||
| 2897 | + s_arr: arr0 | ||
| 2898 | + }; | ||
| 2899 | + newarr.push(item); | ||
| 2900 | + } | ||
| 2901 | + } else { | ||
| 2902 | + qita.push(sto_arr[i]); | ||
| 2903 | + } | ||
| 2904 | + } else { | ||
| 2905 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | ||
| 2906 | + if (find2 != 0) { | ||
| 2907 | + var arr0 = new Array(); | ||
| 2908 | + arr0.push(sto_arr[i]); | ||
| 2909 | + var item = { | ||
| 2910 | + cat_id: find2, | ||
| 2911 | + name: find2name, | ||
| 2912 | + sort: sort, | ||
| 2913 | + s_arr: arr0 | ||
| 2914 | + }; | ||
| 2915 | + newarr.push(item); | ||
| 2916 | + } else { | ||
| 2917 | + qita.push(sto_arr[i]); | ||
| 2918 | + } | ||
| 2919 | + } | ||
| 2920 | + } | ||
| 2818 | 2921 | ||
| 2819 | - //----安排其他的分类----- | ||
| 2820 | - if (qita.length > 0) { | ||
| 2821 | - var item = { | ||
| 2822 | - cat_id: -1, | ||
| 2823 | - name: "其他", | ||
| 2824 | - s_arr: qita | ||
| 2825 | - }; | ||
| 2826 | - newarr.push(item); | ||
| 2827 | - } | 2922 | + var def_arr = new Array(); |
| 2923 | + //-- 开始就看10个门店 -- | ||
| 2924 | + for (var k = 0; k < 10; k++) { | ||
| 2925 | + if (k == sto_arr.length) break; | ||
| 2926 | + def_arr.push(sto_arr[k]); | ||
| 2927 | + } | ||
| 2828 | 2928 | ||
| 2829 | - var sd={ | ||
| 2830 | - all_sto: newarr, | ||
| 2831 | - is_show_sto_cat:1 | ||
| 2832 | - } | ||
| 2833 | - if(!sto_arr || sto_arr.length<=10){ | ||
| 2834 | - sd.is_show_sto_cat=-1; | ||
| 2835 | - sd.only_pk=sto_arr; | ||
| 2836 | - } | ||
| 2837 | - th.setData(sd); | 2929 | + th.setData({ |
| 2930 | + def_pickpu_list: def_arr, | ||
| 2931 | + pickpu_list: ee.data.data.pageData | ||
| 2932 | + }); | ||
| 2838 | 2933 | ||
| 2839 | - } else { | ||
| 2840 | - th.setData({ | ||
| 2841 | - is_show_sto_cat: -1, | ||
| 2842 | - only_pk: e.data.data.pageData | ||
| 2843 | - }); | ||
| 2844 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 2845 | - if (!th.data.def_pick_store) { | ||
| 2846 | - th.setData({ | ||
| 2847 | - def_pick_store: e.data.data.pageData[0], | ||
| 2848 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2849 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2850 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2851 | - }) | ||
| 2852 | - } | ||
| 2853 | - } | ||
| 2854 | - } else { | ||
| 2855 | - th.setData({ | ||
| 2856 | - is_show_sto_cat: -1, | ||
| 2857 | - only_pk: e.data.data.pageData | ||
| 2858 | - }); | ||
| 2859 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 2860 | - if (!th.data.def_pick_store) { | ||
| 2861 | - th.setData({ | ||
| 2862 | - def_pick_store: e.data.data.pageData[0], | ||
| 2863 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2864 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2865 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2866 | - }) | ||
| 2867 | - } | ||
| 2868 | 2934 | ||
| 2869 | - } | ||
| 2870 | - } | ||
| 2871 | - }); | ||
| 2872 | - } else { | ||
| 2873 | - th.setData({ | ||
| 2874 | - is_show_sto_cat: 0, | ||
| 2875 | - only_pk: e.data.data.pageData | ||
| 2876 | - }); | ||
| 2877 | - //-----如果没有默认门店,要取第一个门店作为默认店------ | ||
| 2878 | - if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 2879 | - th.setData({ | ||
| 2880 | - def_pick_store: e.data.data.pageData[0], | ||
| 2881 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2882 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2883 | - sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2884 | - }) | ||
| 2885 | - } | ||
| 2886 | - } | ||
| 2887 | - }, | 2935 | + //门店分类要排序下 |
| 2936 | + function compare(property) { | ||
| 2937 | + return function (a, b) { | ||
| 2938 | + var value1 = a[property]; | ||
| 2939 | + var value2 = b[property]; | ||
| 2940 | + return value1 - value2; | ||
| 2941 | + } | ||
| 2942 | + } | ||
| 2888 | 2943 | ||
| 2889 | - //------------处理线下门店库存-------- | ||
| 2890 | - deal_pickup_dline(e) { | ||
| 2891 | - var pkno = [], th = this; | ||
| 2892 | - if (!th.data.sele_g) return false; | 2944 | + if (newarr.length > 0) |
| 2945 | + newarr.sort(compare("sort")); | ||
| 2893 | 2946 | ||
| 2894 | - if (this.data.def_pick_store) { | ||
| 2895 | - pkno.push(this.data.def_pick_store.pickup_no); | ||
| 2896 | - } | ||
| 2897 | - for (var i in e.data.data.pageData) { | ||
| 2898 | - var item = e.data.data.pageData[i]; | ||
| 2899 | - if (pkno.indexOf(item.pickup_no) < 0) | ||
| 2900 | - pkno.push(item.pickup_no); | ||
| 2901 | - } | ||
| 2902 | - pkno.sort(); | ||
| 2903 | - var pkno_str = pkno.join(","); | ||
| 2904 | - var o_plist = e.data.data.pageData; | ||
| 2905 | - var new_list = []; | ||
| 2906 | - var is_find_def_store = 0; | ||
| 2907 | - | ||
| 2908 | - | ||
| 2909 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 2910 | - var lock = []; | ||
| 2911 | - //先读取门店的lock,采用链式写法,少用await | ||
| 2912 | - getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 2913 | - data: { store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000 } | ||
| 2914 | - }).then(res => { | ||
| 2915 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 2916 | - lock = res.data.data.pageData | ||
| 2917 | - } | ||
| 2918 | - //---通过接口获取门店的线下库存信息-- | ||
| 2919 | - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 2920 | - data: { storageNos: pkno_str, wareIds: encodeURIComponent(th.data.sele_g.erpwareid), storeId: os.stoid, pageSize: 2000 } | ||
| 2921 | - }) | ||
| 2922 | - }).then(res => { | ||
| 2923 | 2947 | ||
| 2924 | - wx.hideLoading(); | ||
| 2925 | - if (res.data.code == 0) { | ||
| 2926 | - if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 2927 | - var plist = res.data.data.pageData; | ||
| 2928 | - var def_pick_store = th.data.def_pick_store; | ||
| 2929 | - //以原来的数组为外循环,保证距离的顺序 | ||
| 2930 | - for (var kk in o_plist) { | ||
| 2931 | - for (var ii in plist) { | ||
| 2932 | - //线下的门店小心 | ||
| 2933 | - var n_item = plist[ii]; | ||
| 2934 | - if (n_item.StorageNo == o_plist[kk].pickup_no) { | ||
| 2935 | - | ||
| 2936 | - //拿到锁库的数量 | ||
| 2937 | - var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | ||
| 2938 | - //可出库数大于预出库库存的数量,可以判断为有库存 | ||
| 2939 | - if (n_item.CanOutQty > lock_num) { | ||
| 2940 | - o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | ||
| 2941 | - new_list.push(o_plist[kk]); | ||
| 2942 | - //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 2943 | - if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 2944 | - th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | ||
| 2945 | - if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | ||
| 2946 | - th.setData({ def_pick_store: th.data.fir_def_store }) | ||
| 2947 | - is_find_def_store = 1; | ||
| 2948 | - } | ||
| 2949 | - } | ||
| 2950 | - break; | ||
| 2951 | - } | ||
| 2952 | - } | ||
| 2953 | - } | ||
| 2954 | - | ||
| 2955 | - //数据组装下 | ||
| 2956 | - var em = {}; em.data = {}; em.data.data = {}; | ||
| 2957 | - em.data.data.total = new_list.length; | ||
| 2958 | - em.data.data.pageData = new_list; | ||
| 2959 | - em.data.data.pageData = new_list; | ||
| 2960 | - | ||
| 2961 | - //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 2962 | - if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 2963 | - th.data.fir_def_store.CanOutQty = 0; | ||
| 2964 | - //--当选择的门店是客户默认的门店的时候-- | ||
| 2965 | - if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 2966 | - th.setData({ def_pick_store: th.data.fir_def_store }); | ||
| 2967 | - em.data.data.pageData.unshift(th.data.def_pick_store); | ||
| 2968 | - } else { | ||
| 2969 | - em.data.data.pageData.splice(1, 0, th.data.fir_def_store); | ||
| 2970 | - } | ||
| 2971 | - } | ||
| 2972 | - | ||
| 2973 | - //---把数组组装进去--- | ||
| 2974 | - th.deal_pickup(em); | ||
| 2975 | - } else { | ||
| 2976 | - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null }) | ||
| 2977 | - } | ||
| 2978 | - } else { | ||
| 2979 | - th.setData({ def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null }) | ||
| 2980 | - } | ||
| 2981 | - }) | ||
| 2982 | - }, | ||
| 2983 | - | ||
| 2984 | - find_lock_num(pick_id, lock) { | ||
| 2985 | - var lock_num = 0; | ||
| 2986 | - if (!lock) return 0; | ||
| 2987 | - if (lock.length < 0) return 0; | ||
| 2988 | - for (var i in lock) { | ||
| 2989 | - if (pick_id == lock[i].pickupId) { | ||
| 2990 | - lock_num += lock[i].outQty; | ||
| 2991 | - } | ||
| 2992 | - } | ||
| 2993 | - return lock_num; | ||
| 2994 | - }, | ||
| 2995 | - | ||
| 2996 | - //----------取货门店被点击的效果------ | ||
| 2997 | - getmendian: function (t) { | ||
| 2998 | - this.setData({ | ||
| 2999 | - ismend: 1, | ||
| 3000 | - }); | ||
| 3001 | - }, | ||
| 3002 | - | ||
| 3003 | - //----------隐藏取货门店,选取门店---------- | ||
| 3004 | - hidemend: function (e) { | ||
| 3005 | - var pid = e.target.dataset.p_id; | ||
| 3006 | - var pname = e.target.dataset.p_name; | ||
| 3007 | - var p_distr_t = e.target.dataset.p_dis; | ||
| 3008 | - this.setData({ | ||
| 3009 | - ismend: 0, | ||
| 3010 | - is_sec_mend: 0, | ||
| 3011 | - sto_sele_id: pid, | ||
| 3012 | - sto_sele_name: pname, | ||
| 3013 | - sto_sele_distr: p_distr_t | ||
| 3014 | - }); | ||
| 3015 | - }, | ||
| 3016 | - | ||
| 3017 | - //------显示取货2级---------- | ||
| 3018 | - show_sec: function (t) { | ||
| 3019 | - var index = t.target.dataset.index; | ||
| 3020 | - var item = this.data.all_sto[index]; | ||
| 3021 | - this.setData({ | ||
| 3022 | - is_sec_mend: 1, | ||
| 3023 | - sec_sto: item | ||
| 3024 | - }); | ||
| 3025 | - }, | 2948 | + //----安排其他的分类----- |
| 2949 | + if (qita.length > 0) { | ||
| 2950 | + var item = { | ||
| 2951 | + cat_id: -1, | ||
| 2952 | + name: "其他", | ||
| 2953 | + s_arr: qita | ||
| 2954 | + }; | ||
| 2955 | + newarr.push(item); | ||
| 2956 | + } | ||
| 3026 | 2957 | ||
| 3027 | - //------隐藏取货门店2级---- | ||
| 3028 | - hide_sec_mend: function () { | ||
| 3029 | - this.setData({ is_sec_mend: 0, }); | ||
| 3030 | - }, | 2958 | + var sd = { |
| 2959 | + all_sto: newarr, | ||
| 2960 | + is_show_sto_cat: 1 | ||
| 2961 | + } | ||
| 2962 | + if (!sto_arr || sto_arr.length <= 10) { | ||
| 2963 | + sd.is_show_sto_cat = -1; | ||
| 2964 | + sd.only_pk = sto_arr; | ||
| 2965 | + } | ||
| 2966 | + th.setData(sd); | ||
| 3031 | 2967 | ||
| 3032 | - //评论的调用 | ||
| 3033 | - requestComments_new: async function () { | ||
| 3034 | - var e = this, th = e, ee = e; var tp = e.data.activeCategoryId3; | ||
| 3035 | - var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p; | 2968 | + } else { |
| 2969 | + th.setData({ | ||
| 2970 | + is_show_sto_cat: -1, | ||
| 2971 | + only_pk: e.data.data.pageData | ||
| 2972 | + }); | ||
| 2973 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 2974 | + if (!th.data.def_pick_store) { | ||
| 2975 | + th.setData({ | ||
| 2976 | + def_pick_store: e.data.data.pageData[0], | ||
| 2977 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2978 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2979 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2980 | + }) | ||
| 2981 | + } | ||
| 2982 | + } | ||
| 2983 | + } else { | ||
| 2984 | + th.setData({ | ||
| 2985 | + is_show_sto_cat: -1, | ||
| 2986 | + only_pk: e.data.data.pageData | ||
| 2987 | + }); | ||
| 2988 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | ||
| 2989 | + if (!th.data.def_pick_store) { | ||
| 2990 | + th.setData({ | ||
| 2991 | + def_pick_store: e.data.data.pageData[0], | ||
| 2992 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 2993 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 2994 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 2995 | + }) | ||
| 2996 | + } | ||
| 3036 | 2997 | ||
| 3037 | - wx.showLoading(); | ||
| 3038 | - var req_where = { | ||
| 3039 | - store_id: o.stoid, pageSize: 5, is_show: 1, | ||
| 3040 | - parent_id: 0, goods_id: th.data.gid, commenttype: tp, | ||
| 3041 | - } | ||
| 3042 | - if (getApp().globalData.userInfo) { | ||
| 3043 | - req_where.userId = getApp().globalData.user_id; | ||
| 3044 | - } | 2998 | + } |
| 2999 | + } | ||
| 3000 | + }); | ||
| 3001 | + } else { | ||
| 3002 | + th.setData({ | ||
| 3003 | + is_show_sto_cat: 0, | ||
| 3004 | + only_pk: e.data.data.pageData | ||
| 3005 | + }); | ||
| 3006 | + //-----如果没有默认门店,要取第一个门店作为默认店------ | ||
| 3007 | + if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | ||
| 3008 | + th.setData({ | ||
| 3009 | + def_pick_store: e.data.data.pageData[0], | ||
| 3010 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | ||
| 3011 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | ||
| 3012 | + sto_sele_distr: e.data.data.pageData[0].distr_type | ||
| 3013 | + }) | ||
| 3014 | + } | ||
| 3015 | + } | ||
| 3016 | + }, | ||
| 3045 | 3017 | ||
| 3046 | - var rs_data = null; | ||
| 3047 | - await getApp().request.promiseGet(t, { data: req_where }).then(res => { | ||
| 3048 | - var tot = res.data.data.total; | ||
| 3049 | - e.data.c_curr_p++; | ||
| 3050 | - e.setData({ | ||
| 3051 | - com_num: tot, //已经有加载 | ||
| 3052 | - }); | ||
| 3053 | - if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3054 | - rs_data = res.data.data.pageData; | ||
| 3055 | - } else { | ||
| 3056 | - th.setData({ comments_no_more: 1, auto: 1 }); | ||
| 3057 | - } | ||
| 3058 | - }) | 3018 | + //------------处理线下门店库存-------- |
| 3019 | + deal_pickup_dline(e) { | ||
| 3020 | + var pkno = [], th = this; | ||
| 3021 | + if (!th.data.sele_g) return false; | ||
| 3059 | 3022 | ||
| 3060 | - if (rs_data) { | ||
| 3061 | - //var cda = th.data.comments; | ||
| 3062 | - var cda = rs_data, com_data = th.data.comments; | ||
| 3063 | - for (var ind in cda) { | ||
| 3064 | - var ep = cda[ind]; | ||
| 3065 | - if (cda[ind].head_pic == '') { | ||
| 3066 | - cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | 3023 | + if (this.data.def_pick_store) { |
| 3024 | + pkno.push(this.data.def_pick_store.pickup_no); | ||
| 3067 | } | 3025 | } |
| 3068 | - if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { | ||
| 3069 | - cda[ind].weapp_img = JSON.parse(ep.weapp_img); | 3026 | + for (var i in e.data.data.pageData) { |
| 3027 | + var item = e.data.data.pageData[i]; | ||
| 3028 | + if (pkno.indexOf(item.pickup_no) < 0) | ||
| 3029 | + pkno.push(item.pickup_no); | ||
| 3070 | } | 3030 | } |
| 3071 | - if (ep.img != "" && ut.isString(ep.img)) { | ||
| 3072 | - cda[ind].img = ut.unserialize(ep.img); | ||
| 3073 | - } | ||
| 3074 | - | ||
| 3075 | - //--测量多有字的宽带,计算有多少行-- | ||
| 3076 | - var widh = ut.measureText(ep.content, 30); | ||
| 3077 | - var lines = widh / 712; | ||
| 3078 | - cda[ind].seeMore = false; | ||
| 3079 | - if (lines > 3) cda[ind].seeMore = true; | ||
| 3080 | - | ||
| 3081 | - await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 3082 | - data: { store_id: o.stoid, parent_id: ep.comment_id } | 3031 | + pkno.sort(); |
| 3032 | + var pkno_str = pkno.join(","); | ||
| 3033 | + var o_plist = e.data.data.pageData; | ||
| 3034 | + var new_list = []; | ||
| 3035 | + var is_find_def_store = 0; | ||
| 3036 | + | ||
| 3037 | + | ||
| 3038 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 3039 | + var lock = []; | ||
| 3040 | + //先读取门店的lock,采用链式写法,少用await | ||
| 3041 | + getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 3042 | + data: {store_id: os.stoid, wareId: th.data.sele_g.goods_id, pageSize: 1000} | ||
| 3083 | }).then(res => { | 3043 | }).then(res => { |
| 3084 | - if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3085 | - cda[ind].replay_list = res.data.data.pageData; | ||
| 3086 | - } | ||
| 3087 | - }) | ||
| 3088 | - } | ||
| 3089 | - | ||
| 3090 | - if (!com_data) com_data = cda; | ||
| 3091 | - else com_data = com_data.concat(cda); | ||
| 3092 | - | ||
| 3093 | - th.setData({ comments: com_data }); | ||
| 3094 | - } | ||
| 3095 | - th.setData({ get_c: 1 }); | ||
| 3096 | - wx.hideLoading(); | ||
| 3097 | - }, | ||
| 3098 | - | ||
| 3099 | - //加载更多是靠这个函数 | ||
| 3100 | - onReachBottom: function () { | ||
| 3101 | - if (this.data.activeCategoryId == 2) { | ||
| 3102 | - if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 3103 | - } | ||
| 3104 | - | ||
| 3105 | - var goods_list = this.selectComponent("#goods_list"); //组件的id | ||
| 3106 | - if (goods_list) goods_list.get_list(); | ||
| 3107 | - }, | ||
| 3108 | - | ||
| 3109 | - //--------检查是否活动,活动是否开始,或者是否结束------- | ||
| 3110 | - async check_prom(gid, prom_type, prom_id) { | ||
| 3111 | - var ee = this, | ||
| 3112 | - th = ee; | ||
| 3113 | - var user_id=getApp().globalData.user_id; | ||
| 3114 | - if(!user_id) user_id=0; | ||
| 3115 | - | ||
| 3116 | - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) { | ||
| 3117 | - this.setData({ | ||
| 3118 | - prom_type: 0,isshow: 1, | ||
| 3119 | - }); | ||
| 3120 | - return false; | ||
| 3121 | - } | ||
| 3122 | - | ||
| 3123 | - if(prom_type==2){ | ||
| 3124 | - | ||
| 3125 | - //-------判断团购活动是否抢光--------- | ||
| 3126 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3127 | - 1: 1 | 3044 | + if (res.data.code == 0 && res.data.data.total > 0) { |
| 3045 | + lock = res.data.data.pageData | ||
| 3046 | + } | ||
| 3047 | + //---通过接口获取门店的线下库存信息-- | ||
| 3048 | + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 3049 | + data: { | ||
| 3050 | + storageNos: pkno_str, | ||
| 3051 | + wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | ||
| 3052 | + storeId: os.stoid, | ||
| 3053 | + pageSize: 2000 | ||
| 3054 | + } | ||
| 3055 | + }) | ||
| 3128 | }).then(res => { | 3056 | }).then(res => { |
| 3129 | - var em = res; | ||
| 3130 | - if (em.data.code == 0) { | ||
| 3131 | - if (em.data.data <= 0) ee.setData({ | ||
| 3132 | - prom_r_null: 1 | ||
| 3133 | - }); | ||
| 3134 | - //拿取价格并且判断时间-- | ||
| 3135 | - getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gid+"/"+ prom_id, { | ||
| 3136 | - success: function (t) { | ||
| 3137 | - if (t.data.code != 0) { | ||
| 3138 | - ee.get_normal(gid); | ||
| 3139 | - return false; | ||
| 3140 | - } | ||
| 3141 | - | ||
| 3142 | - //----已经结束----- | ||
| 3143 | - if (t.data.data.is_end == 1) { | ||
| 3144 | - ee.get_normal(gid); | ||
| 3145 | - return false; | ||
| 3146 | - } | ||
| 3147 | - //----已经过期----- | ||
| 3148 | - var now = ut.gettimestamp(); | ||
| 3149 | - // if (t.data.data.end_time < now || t.data.data.start_time > now) { | ||
| 3150 | - if (t.data.data.end_time < now) { | ||
| 3151 | - ee.get_normal(gid); | ||
| 3152 | - return false; | ||
| 3153 | - } | ||
| 3154 | - | ||
| 3155 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3156 | - if (t.data.data.show_time > now) { | ||
| 3157 | - ee.get_normal(gid); | ||
| 3158 | - return false; | ||
| 3159 | - } | ||
| 3160 | - | ||
| 3161 | - var t_gd = ee.data.data; | ||
| 3162 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3163 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3164 | - | ||
| 3165 | - ee.setData({ | ||
| 3166 | - prom_price: t.data.data.price, | ||
| 3167 | - prom_type: 2, | ||
| 3168 | - prom_id: prom_id, | ||
| 3169 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3170 | - prom_act: t.data.data, | ||
| 3171 | - prom_end_time: prom_end_time, | ||
| 3172 | - prom_start_time: prom_start_time, | ||
| 3173 | - isshow: 1, | ||
| 3174 | - prom_act:t.data.data | ||
| 3175 | - }); | ||
| 3176 | 3057 | ||
| 3177 | - ee.get_sto(); | ||
| 3178 | - var newTime = ut.gettimestamp(); | ||
| 3179 | - var endTime2 = t.data.data.end_time; | ||
| 3180 | - var endTime1 = t.data.data.start_time; | ||
| 3181 | - if (endTime1 > newTime) { | ||
| 3182 | - ee.setData({ | ||
| 3183 | - prom_time_text: '距团购开始还有' | ||
| 3184 | - }) | ||
| 3185 | - ee.countDown(endTime1, 0); | ||
| 3186 | - } else { | ||
| 3187 | - if (endTime2 > newTime) { | ||
| 3188 | - ee.setData({ | ||
| 3189 | - prom_time_text: '距团购结束还有', | ||
| 3190 | - prom_st: 1 | ||
| 3191 | - }) | ||
| 3192 | - ee.countDown(endTime2); | 3058 | + wx.hideLoading(); |
| 3059 | + if (res.data.code == 0) { | ||
| 3060 | + if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3061 | + var plist = res.data.data.pageData; | ||
| 3062 | + var def_pick_store = th.data.def_pick_store; | ||
| 3063 | + //以原来的数组为外循环,保证距离的顺序 | ||
| 3064 | + for (var kk in o_plist) { | ||
| 3065 | + for (var ii in plist) { | ||
| 3066 | + //线下的门店小心 | ||
| 3067 | + var n_item = plist[ii]; | ||
| 3068 | + if (n_item.StorageNo == o_plist[kk].pickup_no) { | ||
| 3069 | + | ||
| 3070 | + //拿到锁库的数量 | ||
| 3071 | + var lock_num = th.find_lock_num(o_plist[kk].pickup_id, lock); | ||
| 3072 | + //可出库数大于预出库库存的数量,可以判断为有库存 | ||
| 3073 | + if (n_item.CanOutQty > lock_num) { | ||
| 3074 | + o_plist[kk].CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3075 | + new_list.push(o_plist[kk]); | ||
| 3076 | + //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3077 | + if (th.data.fir_def_store && n_item.StorageNo == th.data.fir_def_store.pickup_no && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3078 | + th.data.fir_def_store.CanOutQty = n_item.CanOutQty - lock_num; | ||
| 3079 | + if (def_pick_store.pickup_id == th.data.fir_def_store.pickup_id) | ||
| 3080 | + th.setData({def_pick_store: th.data.fir_def_store}) | ||
| 3081 | + is_find_def_store = 1; | ||
| 3082 | + } | ||
| 3083 | + } | ||
| 3084 | + break; | ||
| 3193 | } | 3085 | } |
| 3194 | } | 3086 | } |
| 3087 | + } | ||
| 3195 | 3088 | ||
| 3089 | + //数据组装下 | ||
| 3090 | + var em = {}; | ||
| 3091 | + em.data = {}; | ||
| 3092 | + em.data.data = {}; | ||
| 3093 | + em.data.data.total = new_list.length; | ||
| 3094 | + em.data.data.pageData = new_list; | ||
| 3095 | + em.data.data.pageData = new_list; | ||
| 3096 | + | ||
| 3097 | + //--如果找到默认门店,同时也应该判断配送方式对不对-- | ||
| 3098 | + if (th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id && (g_distr_type == 0 || th.data.fir_def_store.distr_type == 0 || th.data.def_pick_store.distr_type == g_distr_type)) { | ||
| 3099 | + th.data.fir_def_store.CanOutQty = 0; | ||
| 3100 | + //--当选择的门店是客户默认的门店的时候-- | ||
| 3101 | + if (th.data.def_pick_store && th.data.fir_def_store.pickup_id == th.data.def_pick_store.pickup_id) { | ||
| 3102 | + th.setData({def_pick_store: th.data.fir_def_store}); | ||
| 3103 | + em.data.data.pageData.unshift(th.data.def_pick_store); | ||
| 3104 | + } else { | ||
| 3105 | + em.data.data.pageData.splice(1, 0, th.data.fir_def_store); | ||
| 3106 | + } | ||
| 3196 | } | 3107 | } |
| 3197 | - }); | 3108 | + |
| 3109 | + //---把数组组装进去--- | ||
| 3110 | + th.deal_pickup(em); | ||
| 3111 | + } else { | ||
| 3112 | + th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3113 | + } | ||
| 3114 | + } else { | ||
| 3115 | + th.setData({def_pick_store: null, all_sto: null, only_pk: null, def_pickpu_list: null}) | ||
| 3198 | } | 3116 | } |
| 3199 | }) | 3117 | }) |
| 3200 | - } | 3118 | + }, |
| 3119 | + | ||
| 3120 | + find_lock_num(pick_id, lock) { | ||
| 3121 | + var lock_num = 0; | ||
| 3122 | + if (!lock) return 0; | ||
| 3123 | + if (lock.length < 0) return 0; | ||
| 3124 | + for (var i in lock) { | ||
| 3125 | + if (pick_id == lock[i].pickupId) { | ||
| 3126 | + lock_num += lock[i].outQty; | ||
| 3127 | + } | ||
| 3128 | + } | ||
| 3129 | + return lock_num; | ||
| 3130 | + }, | ||
| 3201 | 3131 | ||
| 3202 | - if (prom_type == 1 && prom_id==0){ | 3132 | + //----------取货门店被点击的效果------ |
| 3133 | + getmendian: function (t) { | ||
| 3203 | this.setData({ | 3134 | this.setData({ |
| 3204 | - prom_type: 0,isshow: 1, | 3135 | + ismend: 1, |
| 3205 | }); | 3136 | }); |
| 3137 | + }, | ||
| 3206 | 3138 | ||
| 3207 | - //获取门店 | ||
| 3208 | - this.get_sto(); | ||
| 3209 | - this.get_sku(o.stoid, this.data.data, gid); | ||
| 3210 | - this.check_has_flash(); | ||
| 3211 | - this.data.is_normal=1; | ||
| 3212 | - this.check_is_youhui(gid,1); | ||
| 3213 | - return false; | ||
| 3214 | - } | 3139 | + //----------隐藏取货门店,选取门店---------- |
| 3140 | + hidemend: function (e) { | ||
| 3141 | + var pid = e.target.dataset.p_id; | ||
| 3142 | + var pname = e.target.dataset.p_name; | ||
| 3143 | + var p_distr_t = e.target.dataset.p_dis; | ||
| 3144 | + this.setData({ | ||
| 3145 | + ismend: 0, | ||
| 3146 | + is_sec_mend: 0, | ||
| 3147 | + sto_sele_id: pid, | ||
| 3148 | + sto_sele_name: pname, | ||
| 3149 | + sto_sele_distr: p_distr_t | ||
| 3150 | + }); | ||
| 3151 | + }, | ||
| 3215 | 3152 | ||
| 3216 | - //if (prom_type != 3 && prom_type!=0){ | ||
| 3217 | - //---判断秒杀---- | ||
| 3218 | - if (prom_type == 1 && prom_id>0) { | ||
| 3219 | - //-------判断活动是否抢光--------- | ||
| 3220 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3221 | - 1: 1 | ||
| 3222 | - }).then(res => { | ||
| 3223 | - var em = res; | ||
| 3224 | - if (em.data.code == 0) { | ||
| 3225 | - | ||
| 3226 | - if (em.data.data <= 0) ee.setData({ | ||
| 3227 | - prom_r_null: 1 | ||
| 3228 | - }); | ||
| 3229 | - //拿取价格并且判断时间-- | ||
| 3230 | - getApp().request.get("/api/ms/flash_sale/getNew/" +os.stoid + "/" +user_id+"/"+ prom_id, { | ||
| 3231 | - success: function (t) { | ||
| 3232 | - if (t.data.code != 0) { | ||
| 3233 | - ee.get_normal(gid); | ||
| 3234 | - return false; | ||
| 3235 | - } | ||
| 3236 | - //----已经结束----- | ||
| 3237 | - if (t.data.data.is_end == 1) { | ||
| 3238 | - ee.get_normal(gid); | ||
| 3239 | - return false; | ||
| 3240 | - } | ||
| 3241 | - //----已经过期----- | ||
| 3242 | - var now = ut.gettimestamp(); | ||
| 3243 | - if (t.data.data.end_time < now) { | ||
| 3244 | - ee.get_normal(gid); | ||
| 3245 | - return false; | ||
| 3246 | - } | ||
| 3247 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3248 | - if (t.data.data.show_time > now) { | ||
| 3249 | - ee.get_normal(gid); | ||
| 3250 | - return false; | ||
| 3251 | - } | ||
| 3252 | - | ||
| 3253 | - var t_gd = ee.data.data; | ||
| 3254 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3255 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3256 | - | ||
| 3257 | - ee.setData({ | ||
| 3258 | - prom_price: t.data.data.user_price, | ||
| 3259 | - prom_type: 1, | ||
| 3260 | - prom_id: prom_id, | ||
| 3261 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3262 | - prom_act: t.data.data, | ||
| 3263 | - prom_end_time: prom_end_time, | ||
| 3264 | - prom_start_time: prom_start_time, | ||
| 3265 | - isshow: 1, | ||
| 3266 | - }); | ||
| 3267 | - | ||
| 3268 | - ee.get_sto(); | ||
| 3269 | - var newTime = ut.gettimestamp(); | ||
| 3270 | - var endTime2 = t.data.data.end_time; | ||
| 3271 | - var endTime1 = t.data.data.start_time; | ||
| 3272 | - if (endTime1 > newTime) { | ||
| 3273 | - ee.setData({ | ||
| 3274 | - prom_time_text: '距秒杀开始还有' | ||
| 3275 | - }) | ||
| 3276 | - ee.countDown(endTime1, 0); | ||
| 3277 | - } else { | ||
| 3278 | - if (endTime2 > newTime) { | ||
| 3279 | - ee.setData({ | ||
| 3280 | - prom_time_text: '距秒杀结束还有', | ||
| 3281 | - prom_st: 1 | ||
| 3282 | - }) | ||
| 3283 | - ee.countDown(endTime2); | ||
| 3284 | - } | ||
| 3285 | - } | ||
| 3286 | - | ||
| 3287 | - //如果是进行中的话 | ||
| 3288 | - if (endTime1 < newTime) { | ||
| 3289 | - //-- 获取秒杀活动的多少规格 -- | ||
| 3290 | - ee.get_more_flahs(function (list) { | ||
| 3291 | - if (list && list.length > 1) { | ||
| 3292 | - | ||
| 3293 | - var n_item = list[0]; | ||
| 3294 | - var ind = list.findIndex(function (ele) { | ||
| 3295 | - return ele.goods_id == ee.data.data.goods_id; | ||
| 3296 | - }) | ||
| 3297 | - if (ind < 0) return false; | ||
| 3298 | - if (ind > 0) { | ||
| 3299 | - n_item = JSON.parse(JSON.stringify(list[ind])); | ||
| 3300 | - list.splice(ind, 1); | ||
| 3301 | - list.unshift(n_item); | ||
| 3302 | - } | ||
| 3303 | - | ||
| 3304 | - ee.data.sele_g.viplimited = n_item.viplimited; | ||
| 3305 | - ee.data.data.viplimited = n_item.viplimited; | ||
| 3306 | - | ||
| 3307 | - var gb = 1; | ||
| 3308 | - //-- 显示多规格 -- | ||
| 3309 | - for (let i in list) { | ||
| 3310 | - let item = list[i]; | ||
| 3311 | - var gg = ""; | ||
| 3312 | - if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 3313 | - if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 3314 | - | ||
| 3315 | - if (item.goods_spec != "" && item.goods_color != "") { | ||
| 3316 | - gg = item.goods_spec + "/" + item.goods_color; | ||
| 3317 | - } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 3318 | - gg = item.goods_spec + item.goods_color; | ||
| 3319 | - } else { | ||
| 3320 | - gg = "规格" + gb; | ||
| 3321 | - gb++; | ||
| 3322 | - } | ||
| 3323 | - item.gg = gg; | ||
| 3324 | - item.prom_id = item.prom_id; | ||
| 3325 | - item.prom_type = 1; | ||
| 3326 | - } | ||
| 3327 | - | ||
| 3328 | - ee.setData({ | ||
| 3329 | - sku_g: list, | ||
| 3330 | - }); | ||
| 3331 | - | ||
| 3332 | - } | ||
| 3333 | - }) | ||
| 3334 | - } | ||
| 3335 | - | ||
| 3336 | - } | ||
| 3337 | - }); | ||
| 3338 | - } | ||
| 3339 | - }) | ||
| 3340 | - } | 3153 | + //------显示取货2级---------- |
| 3154 | + show_sec: function (t) { | ||
| 3155 | + var index = t.target.dataset.index; | ||
| 3156 | + var item = this.data.all_sto[index]; | ||
| 3157 | + this.setData({ | ||
| 3158 | + is_sec_mend: 1, | ||
| 3159 | + sec_sto: item | ||
| 3160 | + }); | ||
| 3161 | + }, | ||
| 3341 | 3162 | ||
| 3342 | - if (prom_type == 4) { | ||
| 3343 | - //th.setData({is_integral_normal:1}); | ||
| 3344 | - var rdata = { | ||
| 3345 | - store_id: o.stoid, stype: 1, stypeup: 1, goods_id: gid | ||
| 3346 | - } | 3163 | + //------隐藏取货门店2级---- |
| 3164 | + hide_sec_mend: function () { | ||
| 3165 | + this.setData({is_sec_mend: 0,}); | ||
| 3166 | + }, | ||
| 3347 | 3167 | ||
| 3348 | - var integrals = 0; | ||
| 3349 | - var get_datas = { | ||
| 3350 | - user_id: getApp().globalData.user_id, store_id: o.stoid, | ||
| 3351 | - }; | ||
| 3352 | - await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | ||
| 3353 | - data: get_datas | ||
| 3354 | - }).then(res => { | ||
| 3355 | - if (res.data.code == 0) { | ||
| 3356 | - integrals = res.data.data.Integral; | ||
| 3357 | - } | ||
| 3358 | - }) | ||
| 3359 | - | ||
| 3360 | - //获取一下积分活动 | ||
| 3361 | - await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", { | ||
| 3362 | - data: rdata | ||
| 3363 | - }).then(res => { | ||
| 3364 | - //调用接口有数据的时候 | ||
| 3365 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3366 | - var inte_data = res.data.data.pageData[0]; | ||
| 3367 | - var can_integral = (parseFloat(integrals) >= parseFloat(inte_data.integral)); | ||
| 3368 | - ee.setData({ | ||
| 3369 | - prom_price: parseFloat(inte_data.addmoney), | ||
| 3370 | - prom_integral: parseFloat(inte_data.integral), | ||
| 3371 | - prom_type: 4, | ||
| 3372 | - prom_id: inte_data.id, | ||
| 3373 | - prom_buy_limit: inte_data.limitvipqty, | ||
| 3374 | - prom_act: inte_data, | ||
| 3375 | - isshow: 1, | ||
| 3376 | - can_integral: can_integral, | ||
| 3377 | - is_shopbuy: parseInt(inte_data.is_shopbuy ? inte_data.is_shopbuy : 0) | ||
| 3378 | - }); | ||
| 3379 | - ee.get_sto(); | 3168 | + //评论的调用 |
| 3169 | + requestComments_new: async function () { | ||
| 3170 | + var e = this, th = e, ee = e; | ||
| 3171 | + var tp = e.data.activeCategoryId3; | ||
| 3172 | + var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p; | ||
| 3380 | 3173 | ||
| 3381 | - } else { | ||
| 3382 | - ee.get_normal(gid); | ||
| 3383 | - return false; | 3174 | + wx.showLoading(); |
| 3175 | + var req_where = { | ||
| 3176 | + store_id: o.stoid, pageSize: 5, is_show: 1, | ||
| 3177 | + parent_id: 0, goods_id: th.data.gid, commenttype: tp, | ||
| 3178 | + } | ||
| 3179 | + if (getApp().globalData.userInfo) { | ||
| 3180 | + req_where.userId = getApp().globalData.user_id; | ||
| 3384 | } | 3181 | } |
| 3385 | - }) | ||
| 3386 | 3182 | ||
| 3387 | - } | 3183 | + var rs_data = null; |
| 3184 | + await getApp().request.promiseGet(t, {data: req_where}).then(res => { | ||
| 3185 | + var tot = res.data.data.total; | ||
| 3186 | + e.data.c_curr_p++; | ||
| 3187 | + e.setData({ | ||
| 3188 | + com_num: tot, //已经有加载 | ||
| 3189 | + }); | ||
| 3190 | + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3191 | + rs_data = res.data.data.pageData; | ||
| 3192 | + } else { | ||
| 3193 | + th.setData({comments_no_more: 1, auto: 1}); | ||
| 3194 | + } | ||
| 3195 | + }) | ||
| 3388 | 3196 | ||
| 3389 | - //---判断拼单---- | ||
| 3390 | - if (prom_type == 6) { | ||
| 3391 | - //-------判断活动是否抢光--------- | ||
| 3392 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3393 | - 1: 1 | ||
| 3394 | - }).then(res => { | ||
| 3395 | - var em = res; | ||
| 3396 | - var flag=null; | ||
| 3397 | - if (em.data.code == 0) { | ||
| 3398 | - if (em.data.data <= 0) ee.setData({ | ||
| 3399 | - prom_r_null: 1 | ||
| 3400 | - }); | ||
| 3401 | - //拿取价格并且判断时间-- | ||
| 3402 | - getApp().request.get("/api/weshop/teamlist/get/" + | ||
| 3403 | - os.stoid + "/" + prom_id, { | ||
| 3404 | - success: async function (t) { | ||
| 3405 | - if (t.data.code != 0) { | ||
| 3406 | - ee.get_normal(gid); | ||
| 3407 | - return false; | ||
| 3408 | - } | ||
| 3409 | - //----已经结束----- | ||
| 3410 | - if (t.data.data.is_end == 1) { | ||
| 3411 | - ee.get_normal(gid); | ||
| 3412 | - return false; | ||
| 3413 | - } | ||
| 3414 | - //----已经过期----- | ||
| 3415 | - var now = ut.gettimestamp(); | ||
| 3416 | - if (t.data.data.end_time < now) { | ||
| 3417 | - ee.get_normal(gid); | ||
| 3418 | - return false; | ||
| 3419 | - } | ||
| 3420 | - | ||
| 3421 | - /*-- 还没有开始预热的也不显示 --*/ | ||
| 3422 | - if (t.data.data.show_time > now) { | ||
| 3423 | - ee.get_normal(gid); | ||
| 3424 | - return false; | ||
| 3425 | - } | ||
| 3426 | - | ||
| 3427 | - /*-- 判断拼单是否启用 --*/ | ||
| 3428 | - if (!t.data.data.is_show) { | ||
| 3429 | - console.log('没启用'); | ||
| 3430 | - wx.setNavigationBarTitle({ | ||
| 3431 | - title: '系统提示', | ||
| 3432 | - }); | ||
| 3433 | - wx.showToast({ | ||
| 3434 | - title:'此商品暂时没有拼单活动', | ||
| 3435 | - icon:'none', | ||
| 3436 | - success(){ | ||
| 3437 | - setTimeout(()=>{ | ||
| 3438 | - wx.navigateBack() | ||
| 3439 | - },2000) | ||
| 3440 | - } | ||
| 3441 | - }); | ||
| 3442 | - return false | ||
| 3443 | - } | ||
| 3444 | - | ||
| 3445 | - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2",{ | ||
| 3446 | - data:{ | ||
| 3447 | - store_id: os.stoid, | ||
| 3448 | - is_end: 0, | ||
| 3449 | - is_show: 1, | ||
| 3450 | - user_id: getApp().globalData.user_id, | ||
| 3451 | - pageSize:1000 | 3197 | + if (rs_data) { |
| 3198 | + //var cda = th.data.comments; | ||
| 3199 | + var cda = rs_data, com_data = th.data.comments; | ||
| 3200 | + for (var ind in cda) { | ||
| 3201 | + var ep = cda[ind]; | ||
| 3202 | + if (cda[ind].head_pic == '') { | ||
| 3203 | + cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | ||
| 3452 | } | 3204 | } |
| 3453 | - }).then(res=>{ | ||
| 3454 | - | ||
| 3455 | - let pd_list=res.data.data.pageData; | ||
| 3456 | - if(res.data.code==0 && pd_list.length>0){ | ||
| 3457 | - flag =pd_list.some(pd=>{ | ||
| 3458 | - return pd.goods_id==gid | ||
| 3459 | - }) | 3205 | + if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { |
| 3206 | + cda[ind].weapp_img = JSON.parse(ep.weapp_img); | ||
| 3460 | } | 3207 | } |
| 3461 | - }) | ||
| 3462 | - if(!flag){ | ||
| 3463 | - ee.get_normal(gid); | ||
| 3464 | - return false; | ||
| 3465 | - | ||
| 3466 | - } | ||
| 3467 | - //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | ||
| 3468 | - await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3469 | - data: { | ||
| 3470 | - pt_prom_id: prom_id, | ||
| 3471 | - user_id: oo.user_id, | ||
| 3472 | - store_id: os.stoid, | ||
| 3473 | - pageSize: 1, | ||
| 3474 | - page: 1 | 3208 | + if (ep.img != "" && ut.isString(ep.img)) { |
| 3209 | + cda[ind].img = ut.unserialize(ep.img); | ||
| 3475 | } | 3210 | } |
| 3476 | - }).then(e=>{ | ||
| 3477 | - if (e.data.code == 0 && e.data.data.pageData.length > 0) { | ||
| 3478 | - var odr = e.data.data.pageData[0]; | ||
| 3479 | - th.data.buy_order = odr; | ||
| 3480 | - if (odr.pt_status == 0 && odr.order_status == 1) { | ||
| 3481 | - th.setData({ | ||
| 3482 | - user_order_pt_state: 1 | ||
| 3483 | - }); | ||
| 3484 | - } | ||
| 3485 | - if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 3486 | - if (odr.is_zsorder == 4) { | ||
| 3487 | - getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | ||
| 3488 | - data: { | ||
| 3489 | - store_id: os.stoid, | ||
| 3490 | - team_id: odr.pt_prom_id, | ||
| 3491 | - listno: odr.pt_listno | ||
| 3492 | - } | ||
| 3493 | - }).then(res => { | ||
| 3494 | - var now = ut.gettimestamp(); | ||
| 3495 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3496 | - var tgr = res.data.data.pageData[0]; | ||
| 3497 | - //如果团的时间已经到了 | ||
| 3498 | - if (now >= tgr.kt_end_time) { | ||
| 3499 | - th.update_jiti(tgr.id); | ||
| 3500 | - } else { | ||
| 3501 | - th.setData({ | ||
| 3502 | - user_order_pt_state: 2 | ||
| 3503 | - }); | ||
| 3504 | - } | ||
| 3505 | - } | ||
| 3506 | - }) | ||
| 3507 | - | ||
| 3508 | - } else { | ||
| 3509 | - th.setData({ | ||
| 3510 | - user_order_pt_state: 2 | ||
| 3511 | - }); | ||
| 3512 | - } | ||
| 3513 | - } | ||
| 3514 | 3211 | ||
| 3515 | - if (odr.pt_status == 2 && odr.is_zsorder == 4) { | ||
| 3516 | - th.setData({ | ||
| 3517 | - user_order_pt_state: 3, | ||
| 3518 | - }); | ||
| 3519 | - th.data.wk_order_id = odr.order_id; | 3212 | + //--测量多有字的宽带,计算有多少行-- |
| 3213 | + var widh = ut.measureText(ep.content, 30); | ||
| 3214 | + var lines = widh / 712; | ||
| 3215 | + cda[ind].seeMore = false; | ||
| 3216 | + if (lines > 3) cda[ind].seeMore = true; | ||
| 3217 | + | ||
| 3218 | + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { | ||
| 3219 | + data: {store_id: o.stoid, parent_id: ep.comment_id} | ||
| 3220 | + }).then(res => { | ||
| 3221 | + if (res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3222 | + cda[ind].replay_list = res.data.data.pageData; | ||
| 3520 | } | 3223 | } |
| 3521 | - } | ||
| 3522 | - }) | ||
| 3523 | - | ||
| 3524 | - //----------查看阶梯团------------ | ||
| 3525 | - if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | ||
| 3526 | - t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | ||
| 3527 | - var max_num = 0; | ||
| 3528 | - t.data.data.ct_rylist.forEach(function (val, ind) { | ||
| 3529 | - if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | ||
| 3530 | }) | 3224 | }) |
| 3531 | - t.data.data.max_ct_num = max_num; | ||
| 3532 | - } | ||
| 3533 | - | ||
| 3534 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3535 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3536 | - ee.setData({ | ||
| 3537 | - prom_price: t.data.data.price, | ||
| 3538 | - prom_type: 6, | ||
| 3539 | - prom_id: prom_id, | ||
| 3540 | - prom_buy_limit: t.data.data.buy_limit, | ||
| 3541 | - prom_act: t.data.data, | ||
| 3542 | - prom_end_time: prom_end_time, | ||
| 3543 | - prom_start_time: prom_start_time, | ||
| 3544 | - isshow: 1, | ||
| 3545 | - }); | ||
| 3546 | - | ||
| 3547 | - ee.get_sto(); | ||
| 3548 | - | ||
| 3549 | - var newTime = now; | ||
| 3550 | - var endTime2 = t.data.data.end_time; | ||
| 3551 | - var endTime1 = t.data.data.start_time; | ||
| 3552 | - | ||
| 3553 | - if (endTime1 > newTime) { | ||
| 3554 | - ee.setData({ | ||
| 3555 | - prom_time_text: '距拼单开始还剩:' | ||
| 3556 | - }) | ||
| 3557 | - ee.countDown(endTime1, 0); | ||
| 3558 | - } else { | ||
| 3559 | - if (endTime2 > newTime) { | ||
| 3560 | - ee.setData({ | ||
| 3561 | - prom_time_text: '距拼单结束还剩:', | ||
| 3562 | - prom_st: 1 | ||
| 3563 | - }) | ||
| 3564 | - ee.countDown(endTime2); | ||
| 3565 | - } | ||
| 3566 | - } | ||
| 3567 | - //-------查看有多少人在开这个团------- | ||
| 3568 | - th.get_team_group(prom_id); | ||
| 3569 | } | 3225 | } |
| 3570 | - }); | ||
| 3571 | - } | ||
| 3572 | - }) | ||
| 3573 | - } | ||
| 3574 | 3226 | ||
| 3575 | - }, | 3227 | + if (!com_data) com_data = cda; |
| 3228 | + else com_data = com_data.concat(cda); | ||
| 3576 | 3229 | ||
| 3577 | - //--获取有多少人在开团-- | ||
| 3578 | - async get_team_group(prom_id) { | ||
| 3579 | - var teamgroup = [], | ||
| 3580 | - th = this, | ||
| 3581 | - grounp_tatal = 0; | ||
| 3582 | - //如果活动是开团不是商家团 | ||
| 3583 | - if (this.data.prom_act.kttype > 1) { | ||
| 3584 | - | ||
| 3585 | - var req_data = { | ||
| 3586 | - store_id: os.stoid, | ||
| 3587 | - pageSize: 3, | ||
| 3588 | - page: 1, | ||
| 3589 | - state: 2, | ||
| 3590 | - team_id: prom_id, | ||
| 3591 | - ordernum: 1 | ||
| 3592 | - }; | ||
| 3593 | - | ||
| 3594 | - if (this.data.prom_act.kttype == 3 && this.data.prom_act.max_ct_num) { | ||
| 3595 | - req_data.max_num = this.data.prom_act.max_ct_num; | ||
| 3596 | - } | 3230 | + th.setData({comments: com_data}); |
| 3231 | + } | ||
| 3232 | + th.setData({get_c: 1}); | ||
| 3233 | + wx.hideLoading(); | ||
| 3234 | + }, | ||
| 3597 | 3235 | ||
| 3598 | - //获取活动从表信息team_id | ||
| 3599 | - await getApp().request.promiseGet("/api/weshop/teamgroup/page", { | ||
| 3600 | - data: req_data | ||
| 3601 | - }).then(res => { | ||
| 3602 | - teamgroup = res.data.data.pageData; | ||
| 3603 | - grounp_tatal = res.data.data.total; | ||
| 3604 | - }) | ||
| 3605 | - //获取订单的总数这个接口不能用 | ||
| 3606 | - for (i = 0; i < teamgroup.length; i++) { | ||
| 3607 | - await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3608 | - data: { | ||
| 3609 | - store_id: os.stoid, | ||
| 3610 | - pt_status: 1, | ||
| 3611 | - pt_listno: teamgroup[i].listno | ||
| 3612 | - } | ||
| 3613 | - }).then(res => { | ||
| 3614 | - var order = res.data.data.pageData; | ||
| 3615 | - teamgroup[i].open_num = order.length; | ||
| 3616 | - }) | ||
| 3617 | - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { | ||
| 3618 | - var user = res.data.data; | ||
| 3619 | - teamgroup[i].user = user; | ||
| 3620 | - }) | ||
| 3621 | - } | 3236 | + //加载更多是靠这个函数 |
| 3237 | + onReachBottom: function () { | ||
| 3238 | + if (this.data.activeCategoryId == 2) { | ||
| 3239 | + if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 3240 | + } | ||
| 3622 | 3241 | ||
| 3623 | - if (teamgroup.length > 0) { | ||
| 3624 | - th.setData({ | ||
| 3625 | - teamgroup: teamgroup, | ||
| 3626 | - grounp_tatal: grounp_tatal | ||
| 3627 | - }); | ||
| 3628 | - th.countDown2(); | ||
| 3629 | - } | ||
| 3630 | - } | ||
| 3631 | - }, | 3242 | + var goods_list = this.selectComponent("#goods_list"); //组件的id |
| 3243 | + if (goods_list) goods_list.get_list(); | ||
| 3244 | + }, | ||
| 3632 | 3245 | ||
| 3633 | - //---小于10的格式化函数---- | ||
| 3634 | - timeFormat(param) { | ||
| 3635 | - return param < 10 ? '0' + param : param; | ||
| 3636 | - }, | 3246 | + //--------检查是否活动,活动是否开始,或者是否结束------- |
| 3247 | + async check_prom(gid, prom_type, prom_id) { | ||
| 3248 | + console.log('check_prom'); | ||
| 3249 | + var ee = this, th = ee; | ||
| 3250 | + var user_id = getApp().globalData.user_id; | ||
| 3251 | + if (!user_id) user_id = 0; | ||
| 3637 | 3252 | ||
| 3638 | - //----倒计时函数----- | ||
| 3639 | - countDown(time, prom_st) { | ||
| 3640 | - if (!this.data.is_timer) return false; | ||
| 3641 | - var th = this; | ||
| 3642 | - // 获取当前时间,同时得到活动结束时间数组 | ||
| 3643 | - var endTime = time; | ||
| 3644 | - var newTime = ut.gettimestamp(); | ||
| 3645 | - // 对结束时间进行处理渲染到页面 | ||
| 3646 | - var obj = null; | ||
| 3647 | - // 如果活动未结束,对时间进行处理 | ||
| 3648 | - if (endTime - newTime > 0) { | ||
| 3649 | - var time = (endTime - newTime); | ||
| 3650 | - // 获取天、时、分、秒 | ||
| 3651 | - var day = parseInt(time / (60 * 60 * 24)); | ||
| 3652 | - var hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 3653 | - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 3654 | - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 3655 | - obj = { | ||
| 3656 | - day: this.timeFormat(day), | ||
| 3657 | - hou: this.timeFormat(hou), | ||
| 3658 | - min: this.timeFormat(min), | ||
| 3659 | - sec: this.timeFormat(sec) | ||
| 3660 | - } | ||
| 3661 | - } else { | ||
| 3662 | - if (th.data.prom_st == 0) { | ||
| 3663 | - //var endTime2 = new Date(th.data.prom_end_time).getTime(); | ||
| 3664 | - var endTime2 = th.data.prom_act.end_time; | ||
| 3665 | - th.setData({ | ||
| 3666 | - prom_time_text: '距结束还剩:', | ||
| 3667 | - prom_st: 1 | ||
| 3668 | - }) | ||
| 3669 | - setTimeout(function () { | ||
| 3670 | - th.countDown(endTime2) | ||
| 3671 | - }, 1000); | ||
| 3672 | - return false; | ||
| 3673 | - | ||
| 3674 | - } else { | ||
| 3675 | - //活动已结束,全部设置为'00' | ||
| 3676 | - obj = { | ||
| 3677 | - day: '00', | ||
| 3678 | - hou: '00', | ||
| 3679 | - min: '00', | ||
| 3680 | - sec: '00' | 3253 | + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) { |
| 3254 | + this.setData({ | ||
| 3255 | + prom_type: 0, isshow: 1, | ||
| 3256 | + }); | ||
| 3257 | + return false; | ||
| 3681 | } | 3258 | } |
| 3682 | - th.setData({ | ||
| 3683 | - prom_time_text: '活动已经结束:', | ||
| 3684 | - prom_st: 3 | ||
| 3685 | - }) | ||
| 3686 | - th.setData({ | ||
| 3687 | - djs: obj | ||
| 3688 | - }); | ||
| 3689 | - return false; | ||
| 3690 | - } | ||
| 3691 | - } | ||
| 3692 | 3259 | ||
| 3693 | - th.setData({ | ||
| 3694 | - djs: obj | ||
| 3695 | - }); | ||
| 3696 | - setTimeout(function () { | ||
| 3697 | - th.countDown(endTime) | ||
| 3698 | - }, 1000); | ||
| 3699 | - }, | 3260 | + if (prom_type == 2) { |
| 3261 | + //-------判断团购活动是否抢光--------- | ||
| 3262 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3263 | + 1: 1 | ||
| 3264 | + }).then(res => { | ||
| 3265 | + var em = res; | ||
| 3266 | + if (em.data.code == 0) { | ||
| 3267 | + if (em.data.data <= 0) ee.setData({ | ||
| 3268 | + prom_r_null: 1 | ||
| 3269 | + }); | ||
| 3270 | + //拿取价格并且判断时间-- | ||
| 3271 | + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gid + "/" + prom_id, { | ||
| 3272 | + success: function (t) { | ||
| 3273 | + if (t.data.code != 0) { | ||
| 3274 | + ee.get_normal(gid); | ||
| 3275 | + return false; | ||
| 3276 | + } | ||
| 3277 | + //----已经结束----- | ||
| 3278 | + if (t.data.data.is_end == 1) { | ||
| 3279 | + ee.get_normal(gid); | ||
| 3280 | + return false; | ||
| 3281 | + } | ||
| 3282 | + //----已经过期----- | ||
| 3283 | + var now = ut.gettimestamp(); | ||
| 3284 | + if (t.data.data.end_time < now || t.data.data.start_time > now) { | ||
| 3285 | + ee.get_normal(gid); | ||
| 3286 | + return false; | ||
| 3287 | + } | ||
| 3700 | 3288 | ||
| 3289 | + /*-- 还没有开始预热的也不显示 --*/ | ||
| 3290 | + if (t.data.data.show_time > now) { | ||
| 3291 | + ee.get_normal(gid); | ||
| 3292 | + return false; | ||
| 3293 | + } | ||
| 3701 | 3294 | ||
| 3702 | - //-------------获取购买数量的总函数---------------- | ||
| 3703 | - get_buy_num: function (gd, func) { | ||
| 3704 | - var map = this.data.g_buy_num, | ||
| 3705 | - th = this, | ||
| 3706 | - user_id = getApp().globalData.user_id; | ||
| 3707 | - if (user_id == null) { | ||
| 3708 | - map.set(gd.goods_id, 0); | ||
| 3709 | - th.setData({ | ||
| 3710 | - g_buy_num: map, | ||
| 3711 | - prom_buy_num: 0, | ||
| 3712 | - }); | ||
| 3713 | - "function" == typeof func && func(); | ||
| 3714 | - return false; | ||
| 3715 | - } | 3295 | + var t_gd = ee.data.data; |
| 3296 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3297 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3716 | 3298 | ||
| 3717 | - if (map.has(gd.goods_id)) { | ||
| 3718 | - "function" == typeof func && func(); | ||
| 3719 | - } else { | ||
| 3720 | - //----获取商品购买数---- | ||
| 3721 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3722 | - data: { | ||
| 3723 | - store_id: os.stoid, | ||
| 3724 | - user_id: user_id, | ||
| 3725 | - goods_id: gd.goods_id, | ||
| 3726 | - timetype: th.data.viplimited_timetype | ||
| 3727 | - }, | ||
| 3728 | - success: function (t) { | ||
| 3729 | - if (t.data.code == 0) { | ||
| 3730 | - var g_buy_num = t.data.data.goodsbuynum; | ||
| 3731 | - | ||
| 3732 | - //如果是秒杀的时候 | ||
| 3733 | - if(th.data.prom_type==0 && gd.prom_type == 1 ){ | ||
| 3734 | - gd.prom_type= 0; | ||
| 3735 | - } | ||
| 3736 | - //如果全场优惠,商品做了秒杀 | ||
| 3737 | - if(th.data.prom_type==3 && gd.prom_type == 1 ){ | ||
| 3738 | - gd.prom_type= 0; | ||
| 3739 | - } | ||
| 3740 | - //如果全场阶梯优惠,商品做了秒杀 | ||
| 3741 | - if(th.data.prom_type==10 && gd.prom_type == 1 ){ | ||
| 3742 | - gd.prom_type= 0; | ||
| 3743 | - } | ||
| 3744 | - | 3299 | + ee.setData({ |
| 3300 | + prom_price: t.data.data.price, | ||
| 3301 | + prom_type: 2, | ||
| 3302 | + prom_id: prom_id, | ||
| 3303 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3304 | + prom_act: t.data.data, | ||
| 3305 | + prom_end_time: prom_end_time, | ||
| 3306 | + prom_start_time: prom_start_time, | ||
| 3307 | + isshow: 1, | ||
| 3308 | + prom_act: t.data.data | ||
| 3309 | + }); | ||
| 3310 | + | ||
| 3311 | + ee.get_sto(); | ||
| 3312 | + var newTime = ut.gettimestamp(); | ||
| 3313 | + var endTime2 = t.data.data.end_time; | ||
| 3314 | + var endTime1 = t.data.data.start_time; | ||
| 3315 | + if (endTime1 > newTime) { | ||
| 3316 | + ee.setData({ | ||
| 3317 | + prom_time_text: '距团购开始还有' | ||
| 3318 | + }) | ||
| 3319 | + ee.countDown(endTime1, 0); | ||
| 3320 | + } else { | ||
| 3321 | + if (endTime2 > newTime) { | ||
| 3322 | + ee.setData({ | ||
| 3323 | + prom_time_text: '距团购结束还有', | ||
| 3324 | + prom_st: 1 | ||
| 3325 | + }) | ||
| 3326 | + ee.countDown(endTime2); | ||
| 3327 | + } | ||
| 3328 | + } | ||
| 3745 | 3329 | ||
| 3746 | - if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { | ||
| 3747 | - //----获取活动购买数---- | ||
| 3748 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3749 | - data: { | ||
| 3750 | - store_id: os.stoid, | ||
| 3751 | - user_id: user_id, | ||
| 3752 | - goods_id: gd.goods_id, | ||
| 3753 | - prom_type: gd.prom_type, | ||
| 3754 | - prom_id: gd.prom_id | ||
| 3755 | - }, | ||
| 3756 | - //-----获取----- | ||
| 3757 | - success: function (tt) { | ||
| 3758 | - if (tt.data.code == 0) { | ||
| 3759 | - map.set(gd.goods_id, g_buy_num); | ||
| 3760 | - th.setData({ | ||
| 3761 | - g_buy_num: map, | ||
| 3762 | - prom_buy_num: tt.data.data.goodsbuynum, | 3330 | + } |
| 3763 | }); | 3331 | }); |
| 3764 | - "function" == typeof func && func(); | ||
| 3765 | - } | ||
| 3766 | } | 3332 | } |
| 3767 | - }); | ||
| 3768 | - } else { | ||
| 3769 | - map.set(gd.goods_id, g_buy_num); | ||
| 3770 | - th.setData({ | ||
| 3771 | - g_buy_num: map | ||
| 3772 | - }); | ||
| 3773 | - "function" == typeof func && func(); | ||
| 3774 | - } | ||
| 3775 | - } | 3333 | + }) |
| 3776 | } | 3334 | } |
| 3777 | - }); | ||
| 3778 | - } | ||
| 3779 | - }, | ||
| 3780 | 3335 | ||
| 3781 | - //--拼单推荐的显示--- | ||
| 3782 | - tj_Click: function (e) { | ||
| 3783 | - var ind = parseInt(e.target.dataset.ind); | ||
| 3784 | - this.setData({ | ||
| 3785 | - is_show_gz: ind | ||
| 3786 | - }); | ||
| 3787 | - }, | 3336 | + if (prom_type == 1 && prom_id == 0) { |
| 3337 | + this.setData({ | ||
| 3338 | + prom_type: 0, isshow: 1, | ||
| 3339 | + }); | ||
| 3788 | 3340 | ||
| 3789 | - //--------拼团玩法显示详情-------- | ||
| 3790 | - show_pt_xx: function (e) { | ||
| 3791 | - this.setData({ | ||
| 3792 | - pd_xx: 1, | ||
| 3793 | - }) | ||
| 3794 | - }, | ||
| 3795 | - close_pt_xx: function () { | ||
| 3796 | - this.setData({ | ||
| 3797 | - pd_xx: 0, | ||
| 3798 | - }) | ||
| 3799 | - }, | 3341 | + //获取门店 |
| 3342 | + this.get_sto(); | ||
| 3343 | + this.get_sku(o.stoid, this.data.data, gid); | ||
| 3344 | + this.check_has_flash(); | ||
| 3345 | + this.data.is_normal = 1; | ||
| 3346 | + this.check_is_youhui(gid, 1); | ||
| 3347 | + return false; | ||
| 3348 | + } | ||
| 3800 | 3349 | ||
| 3801 | - //--点击弹起拼单-- | ||
| 3802 | - openSpecModel_pt: function (e) { | 3350 | + //if (prom_type != 3 && prom_type!=0){ |
| 3351 | + //---判断秒杀---- | ||
| 3352 | + if (prom_type == 1 && prom_id > 0) { | ||
| 3353 | + //-------判断活动是否抢光--------- | ||
| 3354 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3355 | + 1: 1 | ||
| 3356 | + }).then(res => { | ||
| 3357 | + var em = res; | ||
| 3358 | + if (em.data.code == 0) { | ||
| 3803 | 3359 | ||
| 3360 | + if (em.data.data <= 0) ee.setData({ | ||
| 3361 | + prom_r_null: 1 | ||
| 3362 | + }); | ||
| 3363 | + //拿取价格并且判断时间-- | ||
| 3364 | + getApp().request.get("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, { | ||
| 3365 | + success: function (t) { | ||
| 3366 | + if (t.data.code != 0) { | ||
| 3367 | + ee.get_normal(gid); | ||
| 3368 | + return false; | ||
| 3369 | + } | ||
| 3370 | + //----已经结束----- | ||
| 3371 | + if (t.data.data.is_end == 1) { | ||
| 3372 | + ee.get_normal(gid); | ||
| 3373 | + return false; | ||
| 3374 | + } | ||
| 3375 | + //----已经过期----- | ||
| 3376 | + var now = ut.gettimestamp(); | ||
| 3377 | + if (t.data.data.end_time < now) { | ||
| 3378 | + ee.get_normal(gid); | ||
| 3379 | + return false; | ||
| 3380 | + } | ||
| 3381 | + /*-- 还没有开始预热的也不显示 --*/ | ||
| 3382 | + if (t.data.data.show_time > now) { | ||
| 3383 | + ee.get_normal(gid); | ||
| 3384 | + return false; | ||
| 3385 | + } | ||
| 3804 | 3386 | ||
| 3805 | - this.setData({ open_ind_store: 4, goodsInputNum: 1 });//拼团直接给4 | 3387 | + var t_gd = ee.data.data; |
| 3388 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3389 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3806 | 3390 | ||
| 3391 | + ee.setData({ | ||
| 3392 | + prom_price: t.data.data.user_price, | ||
| 3393 | + prom_type: 1, | ||
| 3394 | + prom_id: prom_id, | ||
| 3395 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3396 | + prom_act: t.data.data, | ||
| 3397 | + prom_end_time: prom_end_time, | ||
| 3398 | + prom_start_time: prom_start_time, | ||
| 3399 | + isshow: 1, | ||
| 3400 | + }); | ||
| 3401 | + | ||
| 3402 | + ee.get_sto(); | ||
| 3403 | + var newTime = ut.gettimestamp(); | ||
| 3404 | + var endTime2 = t.data.data.end_time; | ||
| 3405 | + var endTime1 = t.data.data.start_time; | ||
| 3406 | + if (endTime1 > newTime) { | ||
| 3407 | + ee.setData({ | ||
| 3408 | + prom_time_text: '距秒杀开始还有' | ||
| 3409 | + }) | ||
| 3410 | + ee.countDown(endTime1, 0); | ||
| 3411 | + } else { | ||
| 3412 | + if (endTime2 > newTime) { | ||
| 3413 | + ee.setData({ | ||
| 3414 | + prom_time_text: '距秒杀结束还有', | ||
| 3415 | + prom_st: 1 | ||
| 3416 | + }) | ||
| 3417 | + ee.countDown(endTime2); | ||
| 3418 | + } | ||
| 3419 | + } | ||
| 3807 | 3420 | ||
| 3808 | - //--先判断会员状态-- | ||
| 3809 | - var user_info = getApp().globalData.userInfo; | ||
| 3810 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 3811 | - wx.navigateTo({ | ||
| 3812 | - url: '/pages/togoin/togoin', | ||
| 3813 | - }) | ||
| 3814 | - return false; | ||
| 3815 | - } | 3421 | + //如果是进行中的话 |
| 3422 | + if (endTime1 < newTime) { | ||
| 3423 | + //-- 获取秒杀活动的多少规格 -- | ||
| 3424 | + ee.get_more_flahs(function (list) { | ||
| 3425 | + if (list && list.length > 1) { | ||
| 3426 | + | ||
| 3427 | + var n_item = list[0]; | ||
| 3428 | + var ind = list.findIndex(function (ele) { | ||
| 3429 | + return ele.goods_id == ee.data.data.goods_id; | ||
| 3430 | + }) | ||
| 3431 | + if (ind < 0) return false; | ||
| 3432 | + if (ind > 0) { | ||
| 3433 | + n_item = JSON.parse(JSON.stringify(list[ind])); | ||
| 3434 | + list.splice(ind, 1); | ||
| 3435 | + list.unshift(n_item); | ||
| 3436 | + } | ||
| 3437 | + | ||
| 3438 | + ee.data.sele_g.viplimited = n_item.viplimited; | ||
| 3439 | + ee.data.data.viplimited = n_item.viplimited; | ||
| 3440 | + | ||
| 3441 | + var gb = 1; | ||
| 3442 | + //-- 显示多规格 -- | ||
| 3443 | + for (let i in list) { | ||
| 3444 | + let item = list[i]; | ||
| 3445 | + var gg = ""; | ||
| 3446 | + if (item.goods_spec == "null" || item.goods_spec == null) item.goods_spec = ""; | ||
| 3447 | + if (item.goods_color == "null" || item.goods_color == null) item.goods_color = ""; | ||
| 3448 | + | ||
| 3449 | + if (item.goods_spec != "" && item.goods_color != "") { | ||
| 3450 | + gg = item.goods_spec + "/" + item.goods_color; | ||
| 3451 | + } else if (item.goods_spec != "" || item.goods_color != "") { | ||
| 3452 | + gg = item.goods_spec + item.goods_color; | ||
| 3453 | + } else { | ||
| 3454 | + gg = "规格" + gb; | ||
| 3455 | + gb++; | ||
| 3456 | + } | ||
| 3457 | + item.gg = gg; | ||
| 3458 | + item.prom_id = item.prom_id; | ||
| 3459 | + item.prom_type = 1; | ||
| 3460 | + } | ||
| 3461 | + | ||
| 3462 | + ee.setData({ | ||
| 3463 | + sku_g: list, | ||
| 3464 | + }); | ||
| 3465 | + | ||
| 3466 | + } | ||
| 3467 | + }) | ||
| 3468 | + } | ||
| 3816 | 3469 | ||
| 3817 | - var th = this; | ||
| 3818 | - var ind = parseInt(e.currentTarget.dataset.it); | 3470 | + } |
| 3471 | + }); | ||
| 3472 | + } | ||
| 3473 | + }) | ||
| 3474 | + } | ||
| 3819 | 3475 | ||
| 3820 | - //如果是拼单活动的普通购买 | ||
| 3821 | - if (ind == 1) { | 3476 | + if (prom_type == 4) { |
| 3477 | + //th.setData({is_integral_normal:1}); | ||
| 3478 | + var rdata = { | ||
| 3479 | + store_id: o.stoid, stype: 1, stypeup: 1, goods_id: gid | ||
| 3480 | + } | ||
| 3822 | 3481 | ||
| 3823 | - if(!th.data.is_normal) { | ||
| 3824 | - th.data.g_buy_num=new Map(); | ||
| 3825 | - } | 3482 | + var integrals = 0; |
| 3483 | + var get_datas = { | ||
| 3484 | + user_id: getApp().globalData.user_id, store_id: o.stoid, | ||
| 3485 | + }; | ||
| 3486 | + await getApp().request.promiseGet("/api/weshop/users/getAllPoints", { | ||
| 3487 | + data: get_datas | ||
| 3488 | + }).then(res => { | ||
| 3489 | + if (res.data.code == 0) { | ||
| 3490 | + integrals = res.data.data.Integral; | ||
| 3491 | + } | ||
| 3492 | + }) | ||
| 3826 | 3493 | ||
| 3827 | - //如果拼单的sku data是空的,就要先获取一下 | ||
| 3828 | - if (th.data.sku_g_pt) { | ||
| 3829 | - th.get_sto(1); | ||
| 3830 | - th.setData({ | ||
| 3831 | - is_normal: ind, | ||
| 3832 | - openSpecModal_pt: 1 | ||
| 3833 | - }); | ||
| 3834 | - } else { | ||
| 3835 | - th.get_sto(1); | ||
| 3836 | - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 3837 | - th.setData({ | ||
| 3838 | - is_normal: ind, | ||
| 3839 | - openSpecModal_pt: 1 | ||
| 3840 | - }); | ||
| 3841 | - }); | ||
| 3842 | - } | ||
| 3843 | - th.check_is_youhui(th.data.gid, 1); | ||
| 3844 | - } else { | 3494 | + //获取一下积分活动 |
| 3495 | + await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList", { | ||
| 3496 | + data: rdata | ||
| 3497 | + }).then(res => { | ||
| 3498 | + //调用接口有数据的时候 | ||
| 3499 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3500 | + var inte_data = res.data.data.pageData[0]; | ||
| 3501 | + var can_integral = (parseFloat(integrals) >= parseFloat(inte_data.integral)); | ||
| 3502 | + ee.setData({ | ||
| 3503 | + prom_price: parseFloat(inte_data.addmoney), | ||
| 3504 | + prom_integral: parseFloat(inte_data.integral), | ||
| 3505 | + prom_type: 4, | ||
| 3506 | + prom_id: inte_data.id, | ||
| 3507 | + prom_buy_limit: inte_data.limitvipqty, | ||
| 3508 | + prom_act: inte_data, | ||
| 3509 | + isshow: 1, | ||
| 3510 | + can_integral: can_integral, | ||
| 3511 | + is_shopbuy: parseInt(inte_data.is_shopbuy ? inte_data.is_shopbuy : 0) | ||
| 3512 | + }); | ||
| 3513 | + ee.get_sto(); | ||
| 3514 | + | ||
| 3515 | + } else { | ||
| 3516 | + ee.get_normal(gid); | ||
| 3517 | + return false; | ||
| 3518 | + } | ||
| 3519 | + }) | ||
| 3845 | 3520 | ||
| 3846 | - if(th.data.is_normal) { | ||
| 3847 | - th.data.g_buy_num=new Map(); | ||
| 3848 | } | 3521 | } |
| 3849 | 3522 | ||
| 3850 | - //拼单商品从这里进,先判断有没有买过商品, | ||
| 3851 | - getApp().request.get("/api/weshop/order/page", { | ||
| 3852 | - data: { | ||
| 3853 | - pt_prom_id: th.data.prom_act.id, | ||
| 3854 | - user_id: oo.user_id, | ||
| 3855 | - store_id: os.stoid, | ||
| 3856 | - pageSize: 1, | ||
| 3857 | - page: 1 | ||
| 3858 | - }, | ||
| 3859 | - success: function (e) { | ||
| 3860 | - //--跳转到已经购买的情况-- | ||
| 3861 | - if (e.data.data.pageData.length > 0) { | ||
| 3862 | - var odr = e.data.data.pageData[0]; | ||
| 3863 | - //还未支付 | ||
| 3864 | - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 3865 | - wx.showModal({ | ||
| 3866 | - title: "您已经购买了该商品待支付中", | ||
| 3867 | - success: function (a) { | ||
| 3868 | - if (a.confirm) { | ||
| 3869 | - wx.navigateTo({ | ||
| 3870 | - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | 3523 | + //---判断拼单---- |
| 3524 | + if (prom_type == 6) { | ||
| 3525 | + //-------判断活动是否抢光--------- | ||
| 3526 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | ||
| 3527 | + 1: 1 | ||
| 3528 | + }).then(res => { | ||
| 3529 | + var em = res; | ||
| 3530 | + var flag = null; | ||
| 3531 | + if (em.data.code == 0) { | ||
| 3532 | + if (em.data.data <= 0) ee.setData({ | ||
| 3533 | + prom_r_null: 1 | ||
| 3871 | }); | 3534 | }); |
| 3872 | - } | ||
| 3873 | - } | ||
| 3874 | - }); | ||
| 3875 | - } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 3876 | - | ||
| 3877 | - if (this.data.is_go_to_team_show) return false; | ||
| 3878 | - this.data.is_go_to_team_show = 1; | ||
| 3879 | - wx.showLoading(); | 3535 | + //拿取价格并且判断时间-- |
| 3536 | + getApp().request.get("/api/weshop/teamlist/get/" + | ||
| 3537 | + os.stoid + "/" + prom_id, { | ||
| 3538 | + success: async function (t) { | ||
| 3539 | + if (t.data.code != 0) { | ||
| 3540 | + ee.get_normal(gid); | ||
| 3541 | + return false; | ||
| 3542 | + } | ||
| 3543 | + //----已经结束----- | ||
| 3544 | + if (t.data.data.is_end == 1) { | ||
| 3545 | + ee.get_normal(gid); | ||
| 3546 | + return false; | ||
| 3547 | + } | ||
| 3548 | + //----已经过期----- | ||
| 3549 | + var now = ut.gettimestamp(); | ||
| 3550 | + if (t.data.data.end_time < now) { | ||
| 3551 | + ee.get_normal(gid); | ||
| 3552 | + return false; | ||
| 3553 | + } | ||
| 3880 | 3554 | ||
| 3881 | - /*--- | ||
| 3882 | - wx.redirectTo({ | ||
| 3883 | - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 3884 | - });--*/ | ||
| 3885 | - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | 3555 | + /*-- 还没有开始预热的也不显示 --*/ |
| 3556 | + if (t.data.data.show_time > now) { | ||
| 3557 | + ee.get_normal(gid); | ||
| 3558 | + return false; | ||
| 3559 | + } | ||
| 3886 | 3560 | ||
| 3887 | - } else { | ||
| 3888 | - th.setData({ | ||
| 3889 | - is_normal: ind, | ||
| 3890 | - openSpecModal_pt: 1 | ||
| 3891 | - }); | ||
| 3892 | - } | 3561 | + /*-- 判断拼单是否启用 --*/ |
| 3562 | + if (!t.data.data.is_show) { | ||
| 3563 | + console.log('没启用'); | ||
| 3564 | + wx.setNavigationBarTitle({ | ||
| 3565 | + title: '系统提示', | ||
| 3566 | + }); | ||
| 3567 | + wx.showToast({ | ||
| 3568 | + title: '此商品暂时没有拼单活动', | ||
| 3569 | + icon: 'none', | ||
| 3570 | + success(){ | ||
| 3571 | + setTimeout(() => { | ||
| 3572 | + wx.navigateBack() | ||
| 3573 | + }, 2000) | ||
| 3574 | + } | ||
| 3575 | + }); | ||
| 3576 | + return false | ||
| 3577 | + } | ||
| 3893 | 3578 | ||
| 3894 | - } else { | ||
| 3895 | - th.setData({ | ||
| 3896 | - is_normal: ind, | ||
| 3897 | - openSpecModal_pt: 1 | ||
| 3898 | - }); | ||
| 3899 | - } | ||
| 3900 | - } | ||
| 3901 | - }); | ||
| 3902 | - } | ||
| 3903 | - }, | 3579 | + //判断拼团的---会员身份-- |
| 3580 | + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { | ||
| 3581 | + data: { | ||
| 3582 | + store_id: os.stoid, | ||
| 3583 | + is_end: 0, | ||
| 3584 | + is_show: 1, | ||
| 3585 | + user_id: getApp().globalData.user_id, | ||
| 3586 | + pageSize: 1000 | ||
| 3587 | + } | ||
| 3588 | + }).then(res => { | ||
| 3589 | + | ||
| 3590 | + let pd_list = res.data.data.pageData; | ||
| 3591 | + if (res.data.code == 0 && pd_list.length > 0) { | ||
| 3592 | + flag = pd_list.some(pd => { | ||
| 3593 | + return pd.goods_id == gid | ||
| 3594 | + }) | ||
| 3595 | + } | ||
| 3596 | + }) | ||
| 3597 | + if (!flag) { | ||
| 3598 | + ee.get_normal(gid); | ||
| 3599 | + return false; | ||
| 3904 | 3600 | ||
| 3905 | - //-----------------拼单生成方法--------------------- | ||
| 3906 | - addCart_pt: function () { | ||
| 3907 | - var th = this; | ||
| 3908 | - if (this.data.is_normal == 0) { | ||
| 3909 | - //看一下有没有起购数,如果有起购数,要计算起购数 | ||
| 3910 | - var qnum = parseFloat(th.data.prom_act.minbuynum); | ||
| 3911 | - if (qnum > 0 && th.data.goodsInputNum < qnum) { | ||
| 3912 | - getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | ||
| 3913 | - return false; | ||
| 3914 | - } | 3601 | + } |
| 3602 | + //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | ||
| 3603 | + await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3604 | + data: { | ||
| 3605 | + pt_prom_id: prom_id, | ||
| 3606 | + user_id: oo.user_id, | ||
| 3607 | + store_id: os.stoid, | ||
| 3608 | + pageSize: 1, | ||
| 3609 | + page: 1 | ||
| 3610 | + } | ||
| 3611 | + }).then(e => { | ||
| 3612 | + if (e.data.code == 0 && e.data.data.pageData.length > 0) { | ||
| 3613 | + var odr = e.data.data.pageData[0]; | ||
| 3614 | + th.data.buy_order = odr; | ||
| 3615 | + if (odr.pt_status == 0 && odr.order_status == 1) { | ||
| 3616 | + th.setData({ | ||
| 3617 | + user_order_pt_state: 1 | ||
| 3618 | + }); | ||
| 3619 | + } | ||
| 3620 | + if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 3621 | + if (odr.is_zsorder == 4) { | ||
| 3622 | + getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | ||
| 3623 | + data: { | ||
| 3624 | + store_id: os.stoid, | ||
| 3625 | + team_id: odr.pt_prom_id, | ||
| 3626 | + listno: odr.pt_listno | ||
| 3627 | + } | ||
| 3628 | + }).then(res => { | ||
| 3629 | + var now = ut.gettimestamp(); | ||
| 3630 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | ||
| 3631 | + var tgr = res.data.data.pageData[0]; | ||
| 3632 | + //如果团的时间已经到了 | ||
| 3633 | + if (now >= tgr.kt_end_time) { | ||
| 3634 | + th.update_jiti(tgr.id); | ||
| 3635 | + } else { | ||
| 3636 | + th.setData({ | ||
| 3637 | + user_order_pt_state: 2 | ||
| 3638 | + }); | ||
| 3639 | + } | ||
| 3640 | + } | ||
| 3641 | + }) | ||
| 3642 | + | ||
| 3643 | + } else { | ||
| 3644 | + th.setData({ | ||
| 3645 | + user_order_pt_state: 2 | ||
| 3646 | + }); | ||
| 3647 | + } | ||
| 3648 | + } | ||
| 3649 | + | ||
| 3650 | + if (odr.pt_status == 2 && odr.is_zsorder == 4) { | ||
| 3651 | + th.setData({ | ||
| 3652 | + user_order_pt_state: 3, | ||
| 3653 | + }); | ||
| 3654 | + th.data.wk_order_id = odr.order_id; | ||
| 3655 | + } | ||
| 3656 | + } | ||
| 3657 | + }) | ||
| 3915 | 3658 | ||
| 3916 | - th.addcart_pt_func(); | ||
| 3917 | - } else { | ||
| 3918 | - th.addcart_pt_func(); | ||
| 3919 | - } | ||
| 3920 | - }, | 3659 | + //----------查看阶梯团------------ |
| 3660 | + if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | ||
| 3661 | + t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | ||
| 3662 | + var max_num = 0; | ||
| 3663 | + t.data.data.ct_rylist.forEach(function (val, ind) { | ||
| 3664 | + if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | ||
| 3665 | + }) | ||
| 3666 | + t.data.data.max_ct_num = max_num; | ||
| 3667 | + } | ||
| 3921 | 3668 | ||
| 3922 | - addcart_pt_func: function () { | ||
| 3923 | - if (oo.user_id == null) { | ||
| 3924 | - s.my_warnning("还未登录!", 0, this); | ||
| 3925 | - return; | ||
| 3926 | - } | ||
| 3927 | - var e = this, | ||
| 3928 | - th = e, | ||
| 3929 | - o = this.data.sele_g; | ||
| 3930 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 3931 | - | ||
| 3932 | - //----------添加到购物车时,要判断限购数量,-------- | ||
| 3933 | - e.get_buy_num(o, async function (ee) { | ||
| 3934 | - | ||
| 3935 | - //---判断商品是否超出限购--- | ||
| 3936 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 3937 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 3938 | - wx.showModal({ | ||
| 3939 | - title: '提示', | ||
| 3940 | - content: '超出商品限购' | ||
| 3941 | - }); | ||
| 3942 | - | ||
| 3943 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 3944 | - if (num < 0) num = 0; | ||
| 3945 | - th.setData({ goodsInputNum: num }) | ||
| 3946 | - return false; | ||
| 3947 | - } | ||
| 3948 | - } | ||
| 3949 | - //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | ||
| 3950 | - if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | ||
| 3951 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 3952 | - wx.showModal({ | ||
| 3953 | - title: '提示', | ||
| 3954 | - content: '超出商品活动限购' | ||
| 3955 | - }); | ||
| 3956 | - | ||
| 3957 | - var num = th.data.prom_buy_limit - th.data.prom_buy_num; | ||
| 3958 | - if (num < 0) num = 0; | ||
| 3959 | - th.setData({ goodsInputNum: num }) | ||
| 3960 | - return false; | 3669 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); |
| 3670 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | ||
| 3671 | + ee.setData({ | ||
| 3672 | + prom_price: t.data.data.price, | ||
| 3673 | + prom_type: 6, | ||
| 3674 | + prom_id: prom_id, | ||
| 3675 | + prom_buy_limit: t.data.data.buy_limit, | ||
| 3676 | + prom_act: t.data.data, | ||
| 3677 | + prom_end_time: prom_end_time, | ||
| 3678 | + prom_start_time: prom_start_time, | ||
| 3679 | + isshow: 1, | ||
| 3680 | + }); | ||
| 3681 | + | ||
| 3682 | + ee.get_sto(); | ||
| 3683 | + | ||
| 3684 | + var newTime = now; | ||
| 3685 | + var endTime2 = t.data.data.end_time; | ||
| 3686 | + var endTime1 = t.data.data.start_time; | ||
| 3687 | + | ||
| 3688 | + if (endTime1 > newTime) { | ||
| 3689 | + ee.setData({ | ||
| 3690 | + prom_time_text: '距拼单开始还剩:' | ||
| 3691 | + }) | ||
| 3692 | + ee.countDown(endTime1, 0); | ||
| 3693 | + } else { | ||
| 3694 | + if (endTime2 > newTime) { | ||
| 3695 | + ee.setData({ | ||
| 3696 | + prom_time_text: '距拼单结束还剩:', | ||
| 3697 | + prom_st: 1 | ||
| 3698 | + }) | ||
| 3699 | + ee.countDown(endTime2); | ||
| 3700 | + } | ||
| 3701 | + } | ||
| 3702 | + //-------查看有多少人在开这个团------- | ||
| 3703 | + th.get_team_group(prom_id); | ||
| 3704 | + } | ||
| 3705 | + }); | ||
| 3706 | + } | ||
| 3707 | + }) | ||
| 3961 | } | 3708 | } |
| 3962 | - } | 3709 | + }, |
| 3963 | 3710 | ||
| 3964 | - var redis_num = 0 | ||
| 3965 | - //不是普通购买的时候 | ||
| 3966 | - if (th.data.is_normal != 1) { | ||
| 3967 | - //-------判断活动是否抢光--------- | ||
| 3968 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { | ||
| 3969 | - 1: 1 | ||
| 3970 | - }).then(res => { | ||
| 3971 | - redis_num = res.data.data; | ||
| 3972 | - }) | 3711 | + //--获取有多少人在开团-- |
| 3712 | + async get_team_group(prom_id) { | ||
| 3713 | + var teamgroup = [], | ||
| 3714 | + th = this, | ||
| 3715 | + grounp_tatal = 0; | ||
| 3716 | + //如果活动是开团不是商家团 | ||
| 3717 | + if (this.data.prom_act.kttype > 1) { | ||
| 3718 | + | ||
| 3719 | + var req_data = { | ||
| 3720 | + store_id: os.stoid, | ||
| 3721 | + pageSize: 3, | ||
| 3722 | + page: 1, | ||
| 3723 | + state: 2, | ||
| 3724 | + team_id: prom_id, | ||
| 3725 | + ordernum: 1 | ||
| 3726 | + }; | ||
| 3973 | 3727 | ||
| 3974 | - if (th.data.goodsInputNum > redis_num) { | ||
| 3975 | - wx.showModal({ | ||
| 3976 | - title: '提示', | ||
| 3977 | - content: '超出商品活动库存' | ||
| 3978 | - }); | 3728 | + if (this.data.prom_act.kttype == 3 && this.data.prom_act.max_ct_num) { |
| 3729 | + req_data.max_num = this.data.prom_act.max_ct_num; | ||
| 3730 | + } | ||
| 3979 | 3731 | ||
| 3980 | - th.setData({ goodsInputNum: redis_num }) | 3732 | + //获取活动从表信息team_id |
| 3733 | + await getApp().request.promiseGet("/api/weshop/teamgroup/page", { | ||
| 3734 | + data: req_data | ||
| 3735 | + }).then(res => { | ||
| 3736 | + teamgroup = res.data.data.pageData; | ||
| 3737 | + grounp_tatal = res.data.data.total; | ||
| 3738 | + }) | ||
| 3739 | + //获取订单的总数这个接口不能用 | ||
| 3740 | + for (i = 0; i < teamgroup.length; i++) { | ||
| 3741 | + await getApp().request.promiseGet("/api/weshop/order/page", { | ||
| 3742 | + data: { | ||
| 3743 | + store_id: os.stoid, | ||
| 3744 | + pt_status: 1, | ||
| 3745 | + pt_listno: teamgroup[i].listno | ||
| 3746 | + } | ||
| 3747 | + }).then(res => { | ||
| 3748 | + var order = res.data.data.pageData; | ||
| 3749 | + teamgroup[i].open_num = order.length; | ||
| 3750 | + }) | ||
| 3751 | + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { | ||
| 3752 | + var user = res.data.data; | ||
| 3753 | + teamgroup[i].user = user; | ||
| 3754 | + }) | ||
| 3755 | + } | ||
| 3981 | 3756 | ||
| 3982 | - return false; | 3757 | + if (teamgroup.length > 0) { |
| 3758 | + th.setData({ | ||
| 3759 | + teamgroup: teamgroup, | ||
| 3760 | + grounp_tatal: grounp_tatal | ||
| 3761 | + }); | ||
| 3762 | + th.countDown2(); | ||
| 3763 | + } | ||
| 3983 | } | 3764 | } |
| 3984 | - } | ||
| 3985 | - | ||
| 3986 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | ||
| 3987 | - if (th.data.goodsInputNum > o.store_count) { | ||
| 3988 | - th.setData({ goodsInputNum: o.store_count }) | ||
| 3989 | - return s.my_warnning("超出商品库存", 0, th); | ||
| 3990 | - } | 3765 | + }, |
| 3991 | 3766 | ||
| 3992 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | ||
| 3993 | - this.setData({ | ||
| 3994 | - sto_sele_name: "" | ||
| 3995 | - }); | ||
| 3996 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 3997 | - //--------------此时操作的数据------------ | ||
| 3998 | - var newd = { | ||
| 3999 | - goods_id: o.goods_id, | ||
| 4000 | - goods_num: th.data.goodsInputNum, | ||
| 4001 | - pick_id: th.data.sto_sele_id, | ||
| 4002 | - user_id: oo.user_id, | ||
| 4003 | - store_id: th.data.stoid, | ||
| 4004 | - goods_price: o.shop_price, | ||
| 4005 | - goods_name: o.goods_name, | ||
| 4006 | - goods_sn: o.goods_sn, | ||
| 4007 | - sku: o.sku, | ||
| 4008 | - }; | ||
| 4009 | - | ||
| 4010 | - //---是不是从收藏夹出来的--- | ||
| 4011 | - if (th.data.c_guide_id) { | ||
| 4012 | - newd['guide_id'] = th.data.c_guide_id; | ||
| 4013 | - newd['guide_type'] = 2; | ||
| 4014 | - | ||
| 4015 | - } else { | ||
| 4016 | - if (getApp().globalData.guide_id) { | ||
| 4017 | - newd['guide_id'] = getApp().globalData.guide_id; | ||
| 4018 | - newd['guide_type'] = 0; | 3767 | + //---小于10的格式化函数---- |
| 3768 | + timeFormat(param) { | ||
| 3769 | + return param < 10 ? '0' + param : param; | ||
| 3770 | + }, | ||
| 4019 | 3771 | ||
| 4020 | - } | ||
| 4021 | - } | 3772 | + //----倒计时函数----- |
| 3773 | + countDown(time, prom_st) { | ||
| 3774 | + if (!this.data.is_timer) return false; | ||
| 3775 | + var th = this; | ||
| 3776 | + // 获取当前时间,同时得到活动结束时间数组 | ||
| 3777 | + var endTime = time; | ||
| 3778 | + var newTime = ut.gettimestamp(); | ||
| 3779 | + // 对结束时间进行处理渲染到页面 | ||
| 3780 | + var obj = null; | ||
| 3781 | + // 如果活动未结束,对时间进行处理 | ||
| 3782 | + if (endTime - newTime > 0) { | ||
| 3783 | + var time = (endTime - newTime); | ||
| 3784 | + // 获取天、时、分、秒 | ||
| 3785 | + var day = parseInt(time / (60 * 60 * 24)); | ||
| 3786 | + var hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 3787 | + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 3788 | + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 3789 | + obj = { | ||
| 3790 | + day: this.timeFormat(day), | ||
| 3791 | + hou: this.timeFormat(hou), | ||
| 3792 | + min: this.timeFormat(min), | ||
| 3793 | + sec: this.timeFormat(sec) | ||
| 3794 | + } | ||
| 3795 | + } else { | ||
| 3796 | + if (th.data.prom_st == 0) { | ||
| 3797 | + //var endTime2 = new Date(th.data.prom_end_time).getTime(); | ||
| 3798 | + var endTime2 = th.data.prom_act.end_time; | ||
| 3799 | + th.setData({ | ||
| 3800 | + prom_time_text: '距结束还剩:', | ||
| 3801 | + prom_st: 1 | ||
| 3802 | + }) | ||
| 3803 | + setTimeout(function () { | ||
| 3804 | + th.countDown(endTime2) | ||
| 3805 | + }, 1000); | ||
| 3806 | + return false; | ||
| 4022 | 3807 | ||
| 4023 | - //让商品带上房间号 | ||
| 4024 | - if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 4025 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 4026 | - newd.room_id = getApp().globalData.room_id; | ||
| 4027 | - } | ||
| 4028 | - } else { | ||
| 4029 | - if (newd.goods_id == getApp().globalData.room_goods_id) { | ||
| 4030 | - newd.room_id = getApp().globalData.room_id; | 3808 | + } else { |
| 3809 | + //活动已结束,全部设置为'00' | ||
| 3810 | + obj = { | ||
| 3811 | + day: '00', | ||
| 3812 | + hou: '00', | ||
| 3813 | + min: '00', | ||
| 3814 | + sec: '00' | ||
| 3815 | + } | ||
| 3816 | + th.setData({ | ||
| 3817 | + prom_time_text: '活动已经结束:', | ||
| 3818 | + prom_st: 3 | ||
| 3819 | + }) | ||
| 3820 | + th.setData({ | ||
| 3821 | + djs: obj | ||
| 3822 | + }); | ||
| 3823 | + return false; | ||
| 3824 | + } | ||
| 4031 | } | 3825 | } |
| 4032 | - } | ||
| 4033 | 3826 | ||
| 4034 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | ||
| 4035 | - | ||
| 4036 | - if (th.data.is_normal == 1) { | ||
| 4037 | - var conf = th.data.bconfig; | ||
| 4038 | - if (conf.switch_list) { | ||
| 4039 | - var s_list = JSON.parse(conf.switch_list); | ||
| 4040 | - //如果后台有开启等级价的功能 | ||
| 4041 | - if (parseInt(s_list.rank_switch) == 2) { | ||
| 4042 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 4043 | - //如果会员有等级价 | ||
| 4044 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 4045 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 4046 | - newd.goods_price = card_price; | ||
| 4047 | - } | ||
| 4048 | - } | ||
| 4049 | - } | ||
| 4050 | - } | 3827 | + th.setData({ |
| 3828 | + djs: obj | ||
| 3829 | + }); | ||
| 3830 | + setTimeout(function () { | ||
| 3831 | + th.countDown(endTime) | ||
| 3832 | + }, 1000); | ||
| 3833 | + }, | ||
| 4051 | 3834 | ||
| 4052 | 3835 | ||
| 4053 | - //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | ||
| 4054 | - if (th.data.prom_type == 6 && th.data.is_normal != 1) { | ||
| 4055 | - newd.goods_price = th.data.prom_price; | ||
| 4056 | - newd.prom_type = th.data.prom_type; | ||
| 4057 | - newd.prom_id = th.data.prom_id; | ||
| 4058 | - newd.kt_type = th.data.prom_act.kttype; //开团类型 | ||
| 4059 | - newd.is_pt_tz = 0; | ||
| 4060 | - //th.data.sto_sele_distr=1; //直接用自提的方式提交 | ||
| 4061 | - if (newd.kt_type > 1) { | ||
| 4062 | - newd.is_pt_tz = 1; //开团类型 | ||
| 4063 | - } | ||
| 4064 | - if (newd.kt_type == 3) { | ||
| 4065 | - th.data.sto_sele_distr = 1; | 3836 | + //-------------获取购买数量的总函数---------------- |
| 3837 | + get_buy_num: function (gd, func) { | ||
| 3838 | + var map = this.data.g_buy_num, | ||
| 3839 | + th = this, | ||
| 3840 | + user_id = getApp().globalData.user_id; | ||
| 3841 | + if (user_id == null) { | ||
| 3842 | + map.set(gd.goods_id, 0); | ||
| 3843 | + th.setData({ | ||
| 3844 | + g_buy_num: map, | ||
| 3845 | + prom_buy_num: 0, | ||
| 3846 | + }); | ||
| 3847 | + "function" == typeof func && func(); | ||
| 3848 | + return false; | ||
| 4066 | } | 3849 | } |
| 4067 | 3850 | ||
| 4068 | - } else if (th.data.prom_type == 3) { | ||
| 4069 | - newd.prom_type = 0; | ||
| 4070 | - newd.prom_id = 0; | ||
| 4071 | - } | 3851 | + if (map.has(gd.goods_id)) { |
| 3852 | + "function" == typeof func && func(); | ||
| 3853 | + } else { | ||
| 3854 | + //----获取商品购买数---- | ||
| 3855 | + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3856 | + data: { | ||
| 3857 | + store_id: os.stoid, | ||
| 3858 | + user_id: user_id, | ||
| 3859 | + goods_id: gd.goods_id | ||
| 3860 | + }, | ||
| 3861 | + success: function (t) { | ||
| 3862 | + if (t.data.code == 0) { | ||
| 3863 | + var g_buy_num = t.data.data.goodsbuynum; | ||
| 4072 | 3864 | ||
| 4073 | - newd['pick_name'] = th.data.sto_sele_name; | ||
| 4074 | - newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 4075 | - newd['is_normal'] = th.data.is_normal; | ||
| 4076 | - | ||
| 4077 | - if (newd['is_normal']) { | ||
| 4078 | - newd['is_pd_normal'] = 1; | ||
| 4079 | - //判断一下有没有全局优惠活动 | ||
| 4080 | - th.check_nor_promgood(newd.goods_id, function (e) { | ||
| 4081 | - if (e && e.act_id) { | ||
| 4082 | - newd['prom_type'] = 3; | ||
| 4083 | - newd['prom_id'] = e.act_id; | ||
| 4084 | - } | ||
| 4085 | - th.buyNow(newd) | ||
| 4086 | - }) | ||
| 4087 | - } | ||
| 4088 | - else th.buyNow_pt(newd); | ||
| 4089 | - }) | ||
| 4090 | - }, | ||
| 4091 | - //----------立即购买_pt----------- | ||
| 4092 | - buyNow_pt: function (e) { | ||
| 4093 | - s.set_b_now(e); | ||
| 4094 | - wx.navigateTo({ | ||
| 4095 | - url: "/pages/cart/cart2_pt/cart2_pt?is_bnow=1&goods_id=" + e.goods_id, | ||
| 4096 | - }); | ||
| 4097 | - }, | 3865 | + //如果是秒杀的时候 |
| 3866 | + if (th.data.prom_type == 0 && gd.prom_type == 1) { | ||
| 3867 | + gd.prom_type = 0; | ||
| 3868 | + } | ||
| 3869 | + //如果全场优惠,商品做了秒杀 | ||
| 3870 | + if (th.data.prom_type == 3 && gd.prom_type == 1) { | ||
| 3871 | + gd.prom_type = 0; | ||
| 3872 | + } | ||
| 3873 | + //如果全场阶梯优惠,商品做了秒杀 | ||
| 3874 | + if (th.data.prom_type == 10 && gd.prom_type == 1) { | ||
| 3875 | + gd.prom_type = 0; | ||
| 3876 | + } | ||
| 4098 | 3877 | ||
| 4099 | - //-------跳转pt商品------- | ||
| 4100 | - go_to_nopay: function () { | ||
| 4101 | - var th = this; | ||
| 4102 | - url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; | ||
| 4103 | - getApp().goto(url); | ||
| 4104 | 3878 | ||
| 4105 | - }, | ||
| 4106 | - //-------跳转pt teamshow------- | ||
| 4107 | - go_to_team_show: function () { | 3879 | + if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { |
| 3880 | + //----获取活动购买数---- | ||
| 3881 | + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | ||
| 3882 | + data: { | ||
| 3883 | + store_id: os.stoid, | ||
| 3884 | + user_id: user_id, | ||
| 3885 | + goods_id: gd.goods_id, | ||
| 3886 | + prom_type: gd.prom_type, | ||
| 3887 | + prom_id: gd.prom_id | ||
| 3888 | + }, | ||
| 3889 | + //-----获取----- | ||
| 3890 | + success: function (tt) { | ||
| 3891 | + if (tt.data.code == 0) { | ||
| 3892 | + map.set(gd.goods_id, g_buy_num); | ||
| 3893 | + th.setData({ | ||
| 3894 | + g_buy_num: map, | ||
| 3895 | + prom_buy_num: tt.data.data.goodsbuynum, | ||
| 3896 | + }); | ||
| 3897 | + "function" == typeof func && func(); | ||
| 3898 | + } | ||
| 3899 | + } | ||
| 3900 | + }); | ||
| 3901 | + } else { | ||
| 3902 | + map.set(gd.goods_id, g_buy_num); | ||
| 3903 | + th.setData({ | ||
| 3904 | + g_buy_num: map | ||
| 3905 | + }); | ||
| 3906 | + "function" == typeof func && func(); | ||
| 3907 | + } | ||
| 3908 | + } | ||
| 3909 | + } | ||
| 3910 | + }); | ||
| 3911 | + } | ||
| 3912 | + }, | ||
| 4108 | 3913 | ||
| 4109 | - if (this.data.is_go_to_team_show) return false; | ||
| 4110 | - this.data.is_go_to_team_show = 1; | ||
| 4111 | - wx.showLoading(); | 3914 | + //--拼单推荐的显示--- |
| 3915 | + tj_Click: function (e) { | ||
| 3916 | + var ind = parseInt(e.target.dataset.ind); | ||
| 3917 | + this.setData({ | ||
| 3918 | + is_show_gz: ind | ||
| 3919 | + }); | ||
| 3920 | + }, | ||
| 4112 | 3921 | ||
| 4113 | - var th = this; | ||
| 4114 | - var url = "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn; | ||
| 4115 | - /*-- | ||
| 4116 | - wx.redirectTo({ | ||
| 4117 | - url:url, | ||
| 4118 | - })--*/ | ||
| 4119 | - getApp().goto(url); | 3922 | + //--------拼团玩法显示详情-------- |
| 3923 | + show_pt_xx: function (e) { | ||
| 3924 | + this.setData({ | ||
| 3925 | + pd_xx: 1, | ||
| 3926 | + }) | ||
| 3927 | + }, | ||
| 3928 | + close_pt_xx: function () { | ||
| 3929 | + this.setData({ | ||
| 3930 | + pd_xx: 0, | ||
| 3931 | + }) | ||
| 3932 | + }, | ||
| 4120 | 3933 | ||
| 4121 | - }, | 3934 | + //--点击弹起拼单-- |
| 3935 | + openSpecModel_pt: function (e) { | ||
| 4122 | 3936 | ||
| 4123 | - //---拼团倒计时--- | ||
| 4124 | - countDown2() { | ||
| 4125 | - if (!this.data.is_timer) return false; | ||
| 4126 | - var th = this; | ||
| 4127 | - // 获取当前时间,同时得到活动结束时间数组 | ||
| 4128 | - var newTime = ut.gettimestamp(); | ||
| 4129 | - var List = th.data.teamgroup; | ||
| 4130 | - for (var j = 0; j < List.length; j++) { | ||
| 4131 | - // 对结束时间进行处理渲染到页面 | ||
| 4132 | - var endTime = List[j].kt_end_time; | ||
| 4133 | - let obj = null; | ||
| 4134 | - // 如果活动未结束,对时间进行处理 | ||
| 4135 | - if (endTime - newTime > 0) { | ||
| 4136 | - let time = (endTime - newTime); | ||
| 4137 | - // 获取天、时、分、秒 | ||
| 4138 | - let day = parseInt(time / (60 * 60 * 24)); | ||
| 4139 | - let hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 4140 | - let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 4141 | - let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 4142 | - obj = { | ||
| 4143 | - day: this.timeFormat(day), | ||
| 4144 | - hou: this.timeFormat(hou), | ||
| 4145 | - min: this.timeFormat(min), | ||
| 4146 | - sec: this.timeFormat(sec) | ||
| 4147 | - } | ||
| 4148 | - } else { | ||
| 4149 | - //活动已结束,全部设置为'00' | ||
| 4150 | - obj = { | ||
| 4151 | - day: '00', | ||
| 4152 | - hou: '00', | ||
| 4153 | - min: '00', | ||
| 4154 | - sec: '00' | ||
| 4155 | - } | ||
| 4156 | - } | ||
| 4157 | - var txt = "timer[" + j + "]"; | ||
| 4158 | - th.setData({ | ||
| 4159 | - [txt]: obj | ||
| 4160 | - }); | ||
| 4161 | - } | ||
| 4162 | - setTimeout(th.countDown2, 1000); | ||
| 4163 | - }, | ||
| 4164 | - //跳转参加团 | ||
| 4165 | - go_cj_team: function (e) { | ||
| 4166 | - var ind = e.currentTarget.dataset.ind; | ||
| 4167 | - var item = this.data.teamgroup[ind]; | ||
| 4168 | - var id = item.id; | ||
| 4169 | - var th = this; | ||
| 4170 | - var goods_id=this.data.data.goods_id; | ||
| 4171 | - getApp().request.get("/api/weshop/order/page", { | ||
| 4172 | - data: { | ||
| 4173 | - pt_prom_id: item.team_id, | ||
| 4174 | - user_id: oo.user_id, | ||
| 4175 | - store_id: os.stoid, | ||
| 4176 | - pageSize: 1, | ||
| 4177 | - page: 1 | ||
| 4178 | - }, | ||
| 4179 | - success: function (e) { | ||
| 4180 | - if (e.data.code != 0) { | ||
| 4181 | - getApp().my_warnning("读取订单失败", 0, th); | ||
| 4182 | - return fasle; | ||
| 4183 | - } | ||
| 4184 | - //--跳转到已经购买的情况-- | ||
| 4185 | - if (e.data.data.pageData.length > 0) { | ||
| 4186 | - var odr = e.data.data.pageData[0]; | ||
| 4187 | - //还未支付 | ||
| 4188 | - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4189 | - wx.showModal({ | ||
| 4190 | - title: "您已经购买了该商品待支付中", | ||
| 4191 | - success: function (a) { | ||
| 4192 | - if (a.confirm) { | ||
| 4193 | - wx.navigateTo({ | ||
| 4194 | - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4195 | - }); | ||
| 4196 | - } | ||
| 4197 | - } | ||
| 4198 | - }); | ||
| 4199 | - } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4200 | 3937 | ||
| 4201 | - if (this.data.is_go_to_team_show) return false; | ||
| 4202 | - this.data.is_go_to_team_show = 1; | ||
| 4203 | - wx.showLoading(); | ||
| 4204 | - /*-- | ||
| 4205 | - wx.redirectTo({ | ||
| 4206 | - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4207 | - });--*/ | 3938 | + this.setData({open_ind_store: 4, goodsInputNum: 1});//拼团直接给4 |
| 4208 | 3939 | ||
| 4209 | - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4210 | 3940 | ||
| 4211 | - } else { | 3941 | + //--先判断会员状态-- |
| 3942 | + var user_info = getApp().globalData.userInfo; | ||
| 3943 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4212 | wx.navigateTo({ | 3944 | wx.navigateTo({ |
| 4213 | - url: `/pages/team/team_show/team_show?tg_id=${id}&goods_id=${goods_id}`, | ||
| 4214 | - }); | ||
| 4215 | - } | ||
| 4216 | - } | ||
| 4217 | - //--跳转到参团-- | ||
| 4218 | - else { | ||
| 4219 | - wx.navigateTo({ | ||
| 4220 | - url: `/pages/team/team_show/team_show?tg_id=${id}&goods_id=${goods_id}`, | ||
| 4221 | - }); | 3945 | + url: '/pages/togoin/togoin', |
| 3946 | + }) | ||
| 3947 | + return false; | ||
| 4222 | } | 3948 | } |
| 4223 | - } | ||
| 4224 | - }) | ||
| 4225 | 3949 | ||
| 4226 | - }, | ||
| 4227 | - | ||
| 4228 | - //跳到团更多 | ||
| 4229 | - go_t_more: function () { | ||
| 4230 | - var team_id = this.data.prom_id; | ||
| 4231 | - wx.navigateTo({ | ||
| 4232 | - url: "/pages/team/team_more/team_more?team_id=" + team_id, | ||
| 4233 | - }); | ||
| 4234 | - }, | 3950 | + var th = this; |
| 3951 | + var ind = parseInt(e.currentTarget.dataset.it); | ||
| 4235 | 3952 | ||
| 4236 | - //--点赞功能-- | ||
| 4237 | - click_zan: function (e) { | ||
| 4238 | - var com_id = e.currentTarget.dataset.com_id; | ||
| 4239 | - var item_id = e.currentTarget.dataset.item_id; | ||
| 4240 | - var app = getApp(), | ||
| 4241 | - th = this; | 3953 | + //如果是拼单活动的普通购买 |
| 3954 | + if (ind == 1) { | ||
| 4242 | 3955 | ||
| 4243 | - if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | ||
| 4244 | - app.confirmBox("您还未登录"); | ||
| 4245 | - return false; | ||
| 4246 | - } | 3956 | + if (!th.data.is_normal) { |
| 3957 | + th.data.g_buy_num = new Map(); | ||
| 3958 | + } | ||
| 4247 | 3959 | ||
| 4248 | - var iszan = th.data.comments[item_id].userZanNum; | ||
| 4249 | - if (this.data.iszaning) return false; | ||
| 4250 | - this.data.iszaning = 1; | 3960 | + //如果拼单的sku data是空的,就要先获取一下 |
| 3961 | + if (th.data.sku_g_pt) { | ||
| 3962 | + th.get_sto(1); | ||
| 3963 | + th.setData({ | ||
| 3964 | + is_normal: ind, | ||
| 3965 | + openSpecModal_pt: 1 | ||
| 3966 | + }); | ||
| 3967 | + } else { | ||
| 3968 | + th.get_sto(1); | ||
| 3969 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 3970 | + th.setData({ | ||
| 3971 | + is_normal: ind, | ||
| 3972 | + openSpecModal_pt: 1 | ||
| 3973 | + }); | ||
| 3974 | + }); | ||
| 3975 | + } | ||
| 3976 | + th.check_is_youhui(th.data.gid, 1); | ||
| 3977 | + } else { | ||
| 4251 | 3978 | ||
| 3979 | + if (th.data.is_normal) { | ||
| 3980 | + th.data.g_buy_num = new Map(); | ||
| 3981 | + } | ||
| 4252 | 3982 | ||
| 4253 | - app.request.post("/api/weshop/commentZan/save", { | ||
| 4254 | - data: { | ||
| 4255 | - store_id: o.stoid, | ||
| 4256 | - user_id: app.globalData.user_id, | ||
| 4257 | - goods_id: th.data.gid, | ||
| 4258 | - comment_id: com_id | ||
| 4259 | - }, | ||
| 4260 | - success: function (ee) { | 3983 | + //拼单商品从这里进,先判断有没有买过商品, |
| 3984 | + getApp().request.get("/api/weshop/order/page", { | ||
| 3985 | + data: { | ||
| 3986 | + pt_prom_id: th.data.prom_act.id, | ||
| 3987 | + user_id: oo.user_id, | ||
| 3988 | + store_id: os.stoid, | ||
| 3989 | + pageSize: 1, | ||
| 3990 | + page: 1 | ||
| 3991 | + }, | ||
| 3992 | + success: function (e) { | ||
| 3993 | + //--跳转到已经购买的情况-- | ||
| 3994 | + if (e.data.data.pageData.length > 0) { | ||
| 3995 | + var odr = e.data.data.pageData[0]; | ||
| 3996 | + //还未支付 | ||
| 3997 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 3998 | + wx.showModal({ | ||
| 3999 | + title: "您已经购买了该商品待支付中", | ||
| 4000 | + success: function (a) { | ||
| 4001 | + if (a.confirm) { | ||
| 4002 | + wx.navigateTo({ | ||
| 4003 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4004 | + }); | ||
| 4005 | + } | ||
| 4006 | + } | ||
| 4007 | + }); | ||
| 4008 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 4009 | + | ||
| 4010 | + if (this.data.is_go_to_team_show) return false; | ||
| 4011 | + this.data.is_go_to_team_show = 1; | ||
| 4012 | + wx.showLoading(); | ||
| 4013 | + | ||
| 4014 | + /*--- | ||
| 4015 | + wx.redirectTo({ | ||
| 4016 | + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4017 | + });--*/ | ||
| 4018 | + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | ||
| 4261 | 4019 | ||
| 4262 | - if (ee.data.code == "-1") { | ||
| 4263 | - app.my_warnning("不能给自己点赞", 0, th); | ||
| 4264 | - th.data.iszaning = 0; | ||
| 4265 | - return; | 4020 | + } else { |
| 4021 | + th.setData({ | ||
| 4022 | + is_normal: ind, | ||
| 4023 | + openSpecModal_pt: 1 | ||
| 4024 | + }); | ||
| 4025 | + } | ||
| 4026 | + } | ||
| 4027 | + else { | ||
| 4028 | + th.setData({ | ||
| 4029 | + is_normal: ind, | ||
| 4030 | + openSpecModal_pt: 1 | ||
| 4031 | + }); | ||
| 4032 | + } | ||
| 4033 | + } | ||
| 4034 | + }) | ||
| 4266 | } | 4035 | } |
| 4036 | + }, | ||
| 4267 | 4037 | ||
| 4268 | - if (ee.data.code == 0 && iszan != 1) { | ||
| 4269 | - var num = th.data.comments[item_id].zan_num; | ||
| 4270 | - num++; | ||
| 4271 | - var text = "comments[" + item_id + "].zan_num"; | ||
| 4272 | - var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4273 | - var _errObj = {}; | ||
| 4274 | - _errObj[text] = num; | ||
| 4275 | - _errObj[text1] = 1; | ||
| 4276 | - th.setData(_errObj); | ||
| 4277 | - | 4038 | + //-----------------拼单生成方法--------------------- |
| 4039 | + addCart_pt: function () { | ||
| 4040 | + var th = this; | ||
| 4041 | + if (this.data.is_normal == 0) { | ||
| 4042 | + //看一下有没有起购数,如果有起购数,要计算起购数 | ||
| 4043 | + var qnum = parseFloat(th.data.prom_act.minbuynum); | ||
| 4044 | + if (qnum > 0 && th.data.goodsInputNum < qnum) { | ||
| 4045 | + getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | ||
| 4046 | + return false; | ||
| 4047 | + } | ||
| 4048 | + th.addcart_pt_func(); | ||
| 4278 | } else { | 4049 | } else { |
| 4279 | - var num = th.data.comments[item_id].zan_num; | ||
| 4280 | - num--; | ||
| 4281 | - var text = "comments[" + item_id + "].zan_num"; | ||
| 4282 | - var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4283 | - var _errObj = {}; | ||
| 4284 | - _errObj[text] = num; | ||
| 4285 | - _errObj[text1] = 0; | ||
| 4286 | - th.setData(_errObj); | 4050 | + th.addcart_pt_func(); |
| 4287 | } | 4051 | } |
| 4052 | + }, | ||
| 4288 | 4053 | ||
| 4289 | - setTimeout(function () { | ||
| 4290 | - th.data.iszaning = 0; | ||
| 4291 | - }, 500) | 4054 | + addcart_pt_func: function () { |
| 4055 | + if (oo.user_id == null) { | ||
| 4056 | + s.my_warnning("还未登录!", 0, this); | ||
| 4057 | + return; | ||
| 4058 | + } | ||
| 4059 | + var e = this, | ||
| 4060 | + th = e, | ||
| 4061 | + o = this.data.sele_g; | ||
| 4062 | + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | ||
| 4292 | 4063 | ||
| 4293 | - } | ||
| 4294 | - }) | ||
| 4295 | - }, | 4064 | + //----------添加到购物车时,要判断限购数量,-------- |
| 4065 | + e.get_buy_num(o, async function (ee) { | ||
| 4296 | 4066 | ||
| 4297 | - /*----券的开关---*/ | ||
| 4298 | - switchCoupon: async function (event) { | ||
| 4299 | - var coupon = event.currentTarget.dataset.coupon; | ||
| 4300 | - var app = getApp(); | ||
| 4301 | - var url = "/api/weshop/prom/coupon/pageCouponList"; | ||
| 4302 | - var quan_list = this.data.quan_list; | ||
| 4303 | - var th = this; | ||
| 4304 | - | ||
| 4305 | - //当开启,且列表为空的情况下要 | ||
| 4306 | - if (!quan_list && coupon == "1") { | ||
| 4307 | - wx.showLoading(); | ||
| 4308 | - await app.request.promiseGet(url, { | ||
| 4309 | - data: { | ||
| 4310 | - store_id: os.stoid, | ||
| 4311 | - type: 1, | ||
| 4312 | - pageSize: 100, | ||
| 4313 | - page: 1, | ||
| 4314 | - user_id: app.globalData.user_id, | ||
| 4315 | - is_share: 0 | ||
| 4316 | - } | ||
| 4317 | - }).then(res => { | ||
| 4318 | - wx.hideLoading(); | ||
| 4319 | - quan_list = res.data.data.pageData; | ||
| 4320 | - }) | ||
| 4321 | - | ||
| 4322 | - if (quan_list) { | ||
| 4323 | - for (var ind in quan_list) { | ||
| 4324 | - var ep = quan_list[ind]; | ||
| 4325 | - var start=""; | ||
| 4326 | - var end=""; | ||
| 4327 | - if( ep.starttype == 0 ){ | ||
| 4328 | - if(ep.use_start_time){ | ||
| 4329 | - start = ut.formatTime(ep.use_start_time, "yyyy-MM-dd"); | ||
| 4330 | - }else{ | ||
| 4331 | - start=ut.formatTime("","yyyy-MM-dd"); | ||
| 4332 | - } | ||
| 4333 | - }else{ | ||
| 4334 | - if(ep.startdays){ | ||
| 4335 | - // start=ut.gettimestamp() + 3600*24*ep.startdays; | ||
| 4336 | - start=ut.formatTime(ut.gettimestamp() + 3600*24*ep.days,"yyyy-MM-dd"); | ||
| 4337 | - }else{ | ||
| 4338 | - start=ut.formatTime("","yyyy-MM-dd"); | ||
| 4339 | - // start=ut.gettimestamp(); | ||
| 4340 | - } | ||
| 4341 | - } | ||
| 4342 | - if( ep.endtype == 0){ | ||
| 4343 | - end = ut.formatTime(ep.use_end_time, "yyyy-MM-dd"); | ||
| 4344 | - }else{ | ||
| 4345 | - if(ep.days){ | ||
| 4346 | - end=ut.formatTime(ut.gettimestamp() + 3600*24*ep.days,"yyyy-MM-dd"); | ||
| 4347 | - }else{ | ||
| 4348 | - end=""; | ||
| 4349 | - // end=ut.gettimestamp(); | ||
| 4350 | - } | ||
| 4351 | - } | ||
| 4352 | - start = start.replace("00:00:00", ""); | ||
| 4353 | - end = end.replace("00:00:00", ""); | ||
| 4354 | - quan_list[ind].start = start; | ||
| 4355 | - quan_list[ind].end = end; | ||
| 4356 | - } | ||
| 4357 | - } | 4067 | + //---判断商品是否超出限购--- |
| 4068 | + if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | ||
| 4069 | + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | ||
| 4070 | + wx.showModal({ | ||
| 4071 | + title: '提示', | ||
| 4072 | + content: '超出商品限购' | ||
| 4073 | + }); | ||
| 4358 | 4074 | ||
| 4359 | - th.setData({ | ||
| 4360 | - coupon: coupon, | ||
| 4361 | - quan_list: quan_list | ||
| 4362 | - }); | ||
| 4363 | - } else { | ||
| 4364 | - th.setData({ | ||
| 4365 | - coupon: coupon | ||
| 4366 | - }); | ||
| 4367 | - } | ||
| 4368 | - }, | 4075 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; |
| 4076 | + if (num < 0) num = 0; | ||
| 4077 | + th.setData({goodsInputNum: num}) | ||
| 4078 | + return false; | ||
| 4079 | + } | ||
| 4080 | + } | ||
| 4081 | + //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | ||
| 4082 | + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | ||
| 4083 | + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | ||
| 4084 | + wx.showModal({ | ||
| 4085 | + title: '提示', | ||
| 4086 | + content: '超出商品活动限购' | ||
| 4087 | + }); | ||
| 4369 | 4088 | ||
| 4370 | - //--查看评价-- | ||
| 4371 | - look_pj: function () { | ||
| 4372 | - this.tabComment(); | ||
| 4373 | - this.doScrollTop(); | ||
| 4374 | - }, | 4089 | + var num = th.data.prom_buy_limit - th.data.prom_buy_num; |
| 4090 | + if (num < 0) num = 0; | ||
| 4091 | + th.setData({goodsInputNum: num}) | ||
| 4092 | + return false; | ||
| 4093 | + } | ||
| 4094 | + } | ||
| 4375 | 4095 | ||
| 4376 | - //-----领取券----- | ||
| 4377 | - get_quan: function (e) { | ||
| 4378 | - var cid = e.currentTarget.dataset.cid; | ||
| 4379 | - var index = e.currentTarget.dataset.ind; | ||
| 4380 | - var item = this.data.quan_list[index]; | 4096 | + var redis_num = 0 |
| 4097 | + //不是普通购买的时候 | ||
| 4098 | + if (th.data.is_normal != 1) { | ||
| 4099 | + //-------判断活动是否抢光--------- | ||
| 4100 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { | ||
| 4101 | + 1: 1 | ||
| 4102 | + }).then(res => { | ||
| 4103 | + redis_num = res.data.data; | ||
| 4104 | + }) | ||
| 4381 | 4105 | ||
| 4106 | + if (th.data.goodsInputNum > redis_num) { | ||
| 4107 | + wx.showModal({ | ||
| 4108 | + title: '提示', | ||
| 4109 | + content: '超出商品活动库存' | ||
| 4110 | + }); | ||
| 4382 | 4111 | ||
| 4383 | - //--先判断会员状态-- | ||
| 4384 | - var user_info = getApp().globalData.userInfo; | ||
| 4385 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4386 | - wx.navigateTo({ | ||
| 4387 | - url: '/pages/togoin/togoin', | ||
| 4388 | - }) | ||
| 4389 | - return false; | ||
| 4390 | - } | 4112 | + th.setData({goodsInputNum: redis_num}) |
| 4391 | 4113 | ||
| 4114 | + return false; | ||
| 4115 | + } | ||
| 4116 | + } | ||
| 4392 | 4117 | ||
| 4393 | - //如果券还在领取中,不能再点 | ||
| 4394 | - if (item.linging == 1) { | ||
| 4395 | - getApp().my_warnning('领取中..', 0, this); | ||
| 4396 | - return false; | ||
| 4397 | - } | 4118 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); |
| 4119 | + if (th.data.goodsInputNum > o.store_count) { | ||
| 4120 | + th.setData({goodsInputNum: o.store_count}) | ||
| 4121 | + return s.my_warnning("超出商品库存", 0, th); | ||
| 4122 | + } | ||
| 4398 | 4123 | ||
| 4399 | - //如果领取的次数到了 | ||
| 4400 | - if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { | ||
| 4401 | - getApp().my_warnning('领取失败,您已领完该券', 0, this); | ||
| 4402 | - return false; | ||
| 4403 | - } | 4124 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) |
| 4125 | + this.setData({ | ||
| 4126 | + sto_sele_name: "" | ||
| 4127 | + }); | ||
| 4128 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | ||
| 4129 | + //--------------此时操作的数据------------ | ||
| 4130 | + var newd = { | ||
| 4131 | + goods_id: o.goods_id, | ||
| 4132 | + goods_num: th.data.goodsInputNum, | ||
| 4133 | + pick_id: th.data.sto_sele_id, | ||
| 4134 | + user_id: oo.user_id, | ||
| 4135 | + store_id: th.data.stoid, | ||
| 4136 | + goods_price: o.shop_price, | ||
| 4137 | + goods_name: o.goods_name, | ||
| 4138 | + goods_sn: o.goods_sn, | ||
| 4139 | + sku: o.sku, | ||
| 4140 | + }; | ||
| 4404 | 4141 | ||
| 4405 | - var lq_num = item.lqnum; | 4142 | + //---是不是从收藏夹出来的--- |
| 4143 | + if (th.data.c_guide_id) { | ||
| 4144 | + newd['guide_id'] = th.data.c_guide_id; | ||
| 4145 | + newd['guide_type'] = 2; | ||
| 4406 | 4146 | ||
| 4407 | - var pdata = { | ||
| 4408 | - 'uid': oo.user_id, | ||
| 4409 | - 'cid': cid, | ||
| 4410 | - 'store_id': os.stoid, | ||
| 4411 | - 'type': 5 | ||
| 4412 | - }; | ||
| 4413 | 4147 | ||
| 4414 | - //-- 导购ID -- | ||
| 4415 | - if (getApp().globalData.guide_id) { | ||
| 4416 | - pdata.guide_id = getApp().globalData.guide_id; | ||
| 4417 | - } | ||
| 4418 | 4148 | ||
| 4419 | - var app = getApp(), | ||
| 4420 | - th = this; | ||
| 4421 | - app.request.post("/api/weshop/couponList/saveCouponList", { | ||
| 4422 | - data: pdata, | ||
| 4423 | - success: function (res) { | ||
| 4424 | - if (res.data.code == 0) { | ||
| 4425 | - app.my_warnning("领取成功", 1, th); | ||
| 4426 | - lq_num++; | ||
| 4427 | - var text = "quan_list[" + index + "].lqnum"; | ||
| 4428 | - var text2 = "quan_list[" + index + "].linging"; | ||
| 4429 | - var obj = {}; | ||
| 4430 | - obj[text] = lq_num; | ||
| 4431 | - obj[text2] = 0; | ||
| 4432 | - th.setData(obj); | ||
| 4433 | - } else { | ||
| 4434 | - app.confirmBox(res.data.msg); | ||
| 4435 | - var text2 = "quan_list[" + index + "].linging"; | ||
| 4436 | - var obj = {}; | ||
| 4437 | - obj[text2] = 0; | ||
| 4438 | - th.setData(obj); | ||
| 4439 | - } | ||
| 4440 | - } | ||
| 4441 | - }) | ||
| 4442 | - }, | ||
| 4443 | - | ||
| 4444 | - | ||
| 4445 | - drawPoster(context, unit, img, vpath) { | ||
| 4446 | - // 1.灰色背景 | ||
| 4447 | - context.setFillStyle('#f2f1f6'); | ||
| 4448 | - context.rect(0,0,554*unit,899*unit); | ||
| 4449 | - context.fill(); | ||
| 4450 | - // 2.商城名称 | ||
| 4451 | - let shopName = this.data.sto_sele_name_1; | ||
| 4452 | - // let shopNameLen = context.measureText(shopName); | ||
| 4453 | - // let x_shopNameLen = (554 - shopNameLen.width)/2*unit; | ||
| 4454 | - // console.log('11111111111111',shopNameLen,x_shopNameLen); | ||
| 4455 | - context.setTextAlign('center'); | ||
| 4456 | - context.setFontSize(26*unit); | ||
| 4457 | - context.setFillStyle('black'); | ||
| 4458 | - context.fillText(shopName, 277*unit, 60*unit); | ||
| 4459 | - // // 3.推荐来源 | ||
| 4460 | - let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | ||
| 4461 | - // let fromTextLen = context.measureText(fromText); | ||
| 4462 | - // let x_fromText = (375 - fromTextLen.width)/2; | ||
| 4463 | - // console.log('222222',fromTextLen,x_fromText); | ||
| 4464 | - context.setTextAlign('center'); | ||
| 4465 | - context.setFontSize(22*unit); | ||
| 4466 | - context.setFillStyle('#96959a'); | ||
| 4467 | - context.fillText(fromText, 277*unit, 105*unit); | ||
| 4468 | - // 4.海报背景 | ||
| 4469 | - // context.beginPath(); | ||
| 4470 | - // context.setStrokeStyle('#f2f1f6'); | ||
| 4471 | - context.setFillStyle('white'); | ||
| 4472 | - context.fillRect(37*unit, 157*unit, 480*unit, 673*unit); | ||
| 4473 | - // context.stroke(); | ||
| 4474 | - // context.fill(); | ||
| 4475 | - // 5.商品图片 | ||
| 4476 | - // 图片的x坐标 | ||
| 4477 | - let bg_x = 37*unit | ||
| 4478 | - // 图片的y坐标 | ||
| 4479 | - let bg_y = 157*unit | ||
| 4480 | - // 图片宽度 | ||
| 4481 | - let bg_w = 480*unit | ||
| 4482 | - // 图片高度 | ||
| 4483 | - let bg_h = 474*unit | ||
| 4484 | - // 图片圆角 | ||
| 4485 | - let bg_r = 4 | ||
| 4486 | - // 绘制海报背景图片圆角 | ||
| 4487 | - context.save() | ||
| 4488 | - context.beginPath() | ||
| 4489 | - context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI*1.5) | ||
| 4490 | - context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | ||
| 4491 | - context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | ||
| 4492 | - context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | ||
| 4493 | - context.clip() | ||
| 4494 | - context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | ||
| 4495 | - context.restore() | ||
| 4496 | - // 6.强烈推荐 | ||
| 4497 | - // context.beginPath(); | ||
| 4498 | - let tj_path = "../../../images/share/q_tj.png"; | ||
| 4499 | - context.beginPath() | ||
| 4500 | - context.drawImage(tj_path, 54*unit, 648*unit, 85*unit, 30*unit); | ||
| 4501 | - context.setFontSize(16*unit) | ||
| 4502 | - context.setLineJoin('round'); //交点设置成圆角 | ||
| 4503 | - context.setFillStyle("white") | ||
| 4504 | - context.setTextAlign('left'); | ||
| 4505 | - context.fillText('强烈推荐', 64*unit, 672*unit); | ||
| 4506 | - // 7.商品价格 | ||
| 4507 | - let price = '¥' + this.data.data.shop_price; | ||
| 4508 | - | ||
| 4509 | - if(this.data.card_field && this.data.data[this.data.card_field]){ | ||
| 4510 | - price = '¥' + this.data.data[this.data.card_field]; | ||
| 4511 | - } | ||
| 4512 | - | ||
| 4513 | - | ||
| 4514 | - // if (th.data.prom_act) | ||
| 4515 | - // pri0 = th.data.prom_act.price; | ||
| 4516 | - context.setFontSize(32*unit); | ||
| 4517 | - context.setFillStyle('#DE1117'); | ||
| 4518 | - context.fillText(price, 54*unit, 730*unit); | ||
| 4519 | - // 8.商品标题 | ||
| 4520 | - context.setFontSize(20*unit); | ||
| 4521 | - context.setFillStyle('#898989'); | ||
| 4522 | - this.draw_Text(context, this.data.data.goods_name, | ||
| 4523 | - 54*unit, 770*unit, 240*unit, 240*unit, unit); | ||
| 4524 | - // 9.小程序码 | ||
| 4525 | - context.drawImage(vpath, 375*unit, 660*unit, 120*unit, 120*unit); | ||
| 4526 | - context.setFontSize(16*unit); | ||
| 4527 | - context.setFillStyle('#777'); | ||
| 4528 | - context.fillText('长按识别二维码', 378*unit, 810*unit); | ||
| 4529 | - // 10.竖线 | ||
| 4530 | - context.beginPath(); | ||
| 4531 | - context.setFillStyle('#eee'); | ||
| 4532 | - context.rect(354*unit, 670*unit, 1*unit, 130*unit); | ||
| 4533 | - context.fill(); | ||
| 4534 | - | ||
| 4535 | - }, | ||
| 4536 | - | ||
| 4537 | - | ||
| 4538 | - | ||
| 4539 | - //--定义的保存图片方法,分享团--- | ||
| 4540 | - saveImageToPhotosAlbum: function () { | ||
| 4541 | - //--先判断会员状态-- | ||
| 4542 | - var user_info = getApp().globalData.userInfo; | ||
| 4543 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4544 | - //getApp().my_warnning("请先登录",0,this); | ||
| 4545 | - wx.navigateTo({ url: '/pages/togoin/togoin', }) | ||
| 4546 | - return false; | ||
| 4547 | - } | ||
| 4548 | 4149 | ||
| 4549 | - if (this.data.share_hidden) { | ||
| 4550 | - this.setData({ share_hidden: false,}); | ||
| 4551 | - }; | ||
| 4552 | - | ||
| 4553 | - //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | ||
| 4554 | - var type = this.data.prom_type; | ||
| 4555 | - if (type==2) type=-1; | ||
| 4556 | - if (type == 6) type = 2; | ||
| 4557 | - | ||
| 4558 | - | ||
| 4559 | - | ||
| 4560 | - if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | ||
| 4561 | - | ||
| 4562 | - wx.showLoading({ title: '生成中...',}) | ||
| 4563 | - var that = this, th = that; | ||
| 4564 | - //设置画板显示,才能开始绘图 | ||
| 4565 | - that.setData({ | ||
| 4566 | - canvasHidden: false | ||
| 4567 | - }) | 4150 | + } else { |
| 4151 | + if (getApp().globalData.guide_id) { | ||
| 4152 | + newd['guide_id'] = getApp().globalData.guide_id; | ||
| 4153 | + newd['guide_type'] = 0; | ||
| 4568 | 4154 | ||
| 4569 | - var app = getApp(); | ||
| 4570 | - var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | ||
| 4571 | - var path2 = that.data.data.original_img; | ||
| 4572 | - var scene = th.data.gid + ""; | ||
| 4573 | - scene+="."+th.data.sele_g.prom_type+"."+th.data.sele_g.prom_id; | ||
| 4574 | 4155 | ||
| 4575 | - var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | ||
| 4576 | - if (user_id > 0) { | ||
| 4577 | - scene += "_" + user_id; | ||
| 4578 | - } | ||
| 4579 | - //-- 如果不是会员分享过来的要分享给别人 -- | ||
| 4580 | - if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | ||
| 4581 | - //固定房间是第3个字符 | ||
| 4582 | - if (!user_id) scene += "_0"; | ||
| 4583 | - scene += "_" + getApp().globalData.room_id; | ||
| 4584 | - } | ||
| 4585 | - ///二微码 | ||
| 4586 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | ||
| 4587 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | ||
| 4588 | - | ||
| 4589 | - console.log(path3); | ||
| 4590 | - | ||
| 4591 | - | ||
| 4592 | - // 读取文件成功则OK-- | ||
| 4593 | - wx.getImageInfo({ | ||
| 4594 | - src: path3, | ||
| 4595 | - success: function (res) { | ||
| 4596 | - // 回调写法 | ||
| 4597 | - th.get_head_temp(th.get_goods_temp, function () { | ||
| 4598 | - var vpath = res.path; | ||
| 4599 | - var context = wx.createCanvasContext('share'); | ||
| 4600 | - // 先画背景 | ||
| 4601 | - var pg_path = "../../../images/share/share_bg.png"; | ||
| 4602 | - | ||
| 4603 | - | ||
| 4604 | - //-- 如果有自定义海报的时候,判断背景的图片 -- | ||
| 4605 | - if (th.data.share_b_img) { | ||
| 4606 | - pg_path = th.data.share_b_img; | ||
| 4607 | - } | ||
| 4608 | - // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4609 | - | ||
| 4610 | - | ||
| 4611 | - if(type == 0 ) { // 如果是普通商品,绘制新海报 | ||
| 4612 | - th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 4613 | - } else { | ||
| 4614 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4615 | - }; | ||
| 4616 | - | ||
| 4617 | - // th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 4618 | - | ||
| 4619 | - | ||
| 4620 | - //-- 是自定义海报的情况下 -- | ||
| 4621 | - if(type != 0) { | ||
| 4622 | - | ||
| 4623 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4624 | - //在线上分享人的情况下 | ||
| 4625 | - if (parseInt(th.data.poster.show_headpic)) { | ||
| 4626 | - //获取坐标 | ||
| 4627 | - var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 4628 | - var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 4629 | - var x1 = (x + 90) * unit; | ||
| 4630 | - var y1 = (y + 50) * unit; | ||
| 4631 | - //--昵称--- | ||
| 4632 | - context.setFontSize(24 * unit) | ||
| 4633 | - context.setFillStyle("black") | ||
| 4634 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | ||
| 4635 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | ||
| 4636 | - //强烈推荐 改许程 | ||
| 4637 | - var tj_path = "../../../images/share/q_tj.png"; | ||
| 4638 | - context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | ||
| 4639 | - context.setFontSize(16 * unit); | ||
| 4640 | - context.setLineJoin('round'); //交点设置成圆角 | ||
| 4641 | - context.setFillStyle("white"); | ||
| 4642 | - context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | ||
| 4643 | - | ||
| 4644 | - //context.setFillStyle("black") | ||
| 4645 | - //context.setFontSize(24 * unit) | ||
| 4646 | - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | ||
| 4647 | - } | ||
| 4648 | - } else { | ||
| 4649 | - //--昵称--- | ||
| 4650 | - context.setFontSize(24 * unit); | ||
| 4651 | - context.setFillStyle("black"); | ||
| 4652 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | ||
| 4653 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | ||
| 4654 | - //强烈推荐 改许程 | ||
| 4655 | - var tj_path = "../../../images/share/q_tj.png"; | ||
| 4656 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | ||
| 4657 | - context.setFontSize(16 * unit); | ||
| 4658 | - context.setLineJoin('round'); //交点设置成圆角 | ||
| 4659 | - context.setFillStyle("white"); | ||
| 4660 | - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | ||
| 4661 | - } | ||
| 4662 | - | ||
| 4663 | - }; | ||
| 4664 | - | ||
| 4665 | - | ||
| 4666 | - | ||
| 4667 | - var share_title = th.data.data.goods_name; | ||
| 4668 | - if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | ||
| 4669 | - share_title = th.data.prom_act.share_title; | ||
| 4670 | - if (!share_title) share_title = th.data.prom_act.title; | ||
| 4671 | - if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | ||
| 4672 | - } | ||
| 4673 | - | ||
| 4674 | - //---产品名称--- | ||
| 4675 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 4676 | - if (type != 4 && type != 0) { | ||
| 4677 | - context.setFillStyle("black"); | ||
| 4678 | - context.setFontSize(21.3 * unit) | ||
| 4679 | - th.draw_Text(context, share_title, | ||
| 4680 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | ||
| 4681 | - | ||
| 4682 | - //------产品的价格------- | ||
| 4683 | - context.setFontSize(23 * unit) | ||
| 4684 | - context.setFillStyle("red") | ||
| 4685 | - | ||
| 4686 | - var pri0 = th.data.data.shop_price; | ||
| 4687 | - if(th.data.card_field && th.data.data[th.data.card_field]){ | ||
| 4688 | - pri0=th.data.data[th.data.card_field]; | ||
| 4689 | - } | ||
| 4690 | - | ||
| 4691 | - if (th.data.prom_act) | ||
| 4692 | - pri0 = th.data.prom_price; | ||
| 4693 | - pri0 = parseFloat(pri0).toFixed(2); | ||
| 4694 | - var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; | ||
| 4695 | - context.fillText("¥", wd1 - 15, 185 * unit); | ||
| 4696 | - context.setFontSize(31 * unit) | ||
| 4697 | - context.fillText(pri0, wd1, 185 * unit); | ||
| 4698 | - | ||
| 4699 | - //---市场价划掉--- | ||
| 4700 | - context.setFillStyle("gray") | ||
| 4701 | - context.setFontSize(22 * unit) | ||
| 4702 | - pri0 = "¥" + th.data.data.market_price.toFixed(2); | ||
| 4703 | - var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
| 4704 | - context.fillText(pri0, wd2, 213 * unit); | ||
| 4705 | - | ||
| 4706 | - context.setStrokeStyle('gray'); | ||
| 4707 | - context.setLineWidth(1 * unit); | ||
| 4708 | - context.moveTo(wd2 - 5, 206 * unit); | ||
| 4709 | - context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | ||
| 4710 | - context.stroke(); | ||
| 4711 | - | ||
| 4712 | - } else if(type == 4 && type != 0) { | ||
| 4713 | - context.setFillStyle("black"); | ||
| 4714 | - context.setFontSize(21.3 * unit) | ||
| 4715 | - th.draw_Text(context, share_title, | ||
| 4716 | - 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); | ||
| 4717 | - //------ 产品的价格 ----- | ||
| 4718 | - var pri0 = th.data.prom_act.addmoney; | ||
| 4719 | - var integral = th.data.prom_act.integral; | ||
| 4720 | - var text = ""; | ||
| 4721 | - if (integral) { text = integral + "积分"; } | ||
| 4722 | - if (pri0 && integral) { text += "+"; } | ||
| 4723 | - if (pri0) { text += "¥" + pri0; } | ||
| 4724 | - | ||
| 4725 | - if (!pri0 && !integral) { text = "0积分"; } | ||
| 4726 | - context.setFillStyle("red"); | ||
| 4727 | - context.fillText(text, 38 * unit, 235 * unit); | ||
| 4728 | - | ||
| 4729 | - } | ||
| 4730 | - | ||
| 4731 | - //---中间大图--- | ||
| 4732 | - if(type != 0) { | ||
| 4733 | - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | ||
| 4734 | - }; | ||
| 4735 | - | ||
| 4736 | - | ||
| 4737 | - | ||
| 4738 | - //-------大图后面就不一样了----------- | ||
| 4739 | - switch (type) { | ||
| 4740 | - case 0: break;//普通商品的展示 | ||
| 4741 | - case 4: | ||
| 4742 | - //中间的几个字 | ||
| 4743 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4744 | - if (parseInt(th.data.poster.show_quality)) { | ||
| 4745 | - var g_path = "../../../images/share/s_gou.png"; | ||
| 4746 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4747 | - context.setFillStyle("red") | ||
| 4748 | - context.setFontSize(18 * unit) | ||
| 4749 | - context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 4750 | - | ||
| 4751 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4752 | - context.setFillStyle("red") | ||
| 4753 | - context.setFontSize(18 * unit) | ||
| 4754 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 4755 | - | ||
| 4756 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4757 | - context.setFillStyle("red") | ||
| 4758 | - context.setFontSize(18 * unit) | ||
| 4759 | - context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 4760 | } | 4156 | } |
| 4157 | + } | ||
| 4761 | 4158 | ||
| 4762 | - } else { | ||
| 4763 | - var g_path = "../../../images/share/s_gou.png"; | ||
| 4764 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4765 | - context.setFillStyle("red") | ||
| 4766 | - context.setFontSize(18 * unit) | ||
| 4767 | - context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 4768 | - | ||
| 4769 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4770 | - context.setFillStyle("red") | ||
| 4771 | - context.setFontSize(18 * unit) | ||
| 4772 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 4773 | - | ||
| 4774 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4775 | - context.setFillStyle("red") | ||
| 4776 | - context.setFontSize(18 * unit) | ||
| 4777 | - context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 4778 | - } | ||
| 4779 | - | ||
| 4780 | - | ||
| 4781 | - //---画线--- | ||
| 4782 | - context.setLineWidth(1 * unit) | ||
| 4783 | - context.moveTo(32 * unit, 710 * unit) | ||
| 4784 | - context.lineTo(520 * unit, 710 * unit) | ||
| 4785 | - context.stroke(); | ||
| 4786 | - | ||
| 4787 | - //---文字--- | ||
| 4788 | - context.setFillStyle("black") | ||
| 4789 | - context.setFontSize(22 * unit) | ||
| 4790 | - | ||
| 4791 | - if (type == 0 || type == -1) { | ||
| 4792 | - // 原来start ---> | ||
| 4793 | - context.setFontSize(24 * unit) | ||
| 4794 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 4795 | - | ||
| 4796 | - context.setFontSize(22 * unit) | ||
| 4797 | - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | ||
| 4798 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | ||
| 4799 | - | ||
| 4800 | - } else { | ||
| 4801 | - context.setFontSize(24 * unit) | ||
| 4802 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 4803 | - context.setFontSize(22 * unit) | ||
| 4804 | - context.fillText("长按识别二维码", 40 * unit, 806 * unit); | ||
| 4805 | - context.fillText("立即开始兑换", 40 * unit, 846 * unit); | ||
| 4806 | - | ||
| 4807 | - } | ||
| 4808 | - | ||
| 4809 | - //---二维吗图--- | ||
| 4810 | - //-- 自定义海报 -- | ||
| 4811 | - if (th.data.poster) { | ||
| 4812 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4813 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4814 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 4815 | - } else { | ||
| 4816 | - //---二维吗图--- | ||
| 4817 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 4818 | - }; | ||
| 4819 | - | ||
| 4820 | - break; | ||
| 4821 | - case 1: //秒杀商品的展示 | ||
| 4822 | - //---画线--- | ||
| 4823 | - context.setLineWidth(1 * unit) | ||
| 4824 | - context.moveTo(32 * unit, 670 * unit) | ||
| 4825 | - context.lineTo(520 * unit, 670 * unit) | ||
| 4826 | - context.stroke(); | ||
| 4827 | - | ||
| 4828 | - //画秒杀的图片 | ||
| 4829 | - var miaos_path = '../../../images/share/miao_share.png'; | ||
| 4830 | - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | ||
| 4831 | - | ||
| 4832 | - context.setFillStyle("black") | ||
| 4833 | - context.setFontSize(24 * unit) | ||
| 4834 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | ||
| 4835 | - //---文字--- | ||
| 4836 | - context.setFontSize(22 * unit) | ||
| 4837 | - context.setFillStyle("black") | ||
| 4838 | - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | ||
| 4839 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | ||
| 4840 | - | ||
| 4841 | - | ||
| 4842 | - //---二维吗图--- | ||
| 4843 | - //-- 自定义海报 -- | ||
| 4844 | - if (th.data.poster) { | ||
| 4845 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4846 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4847 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 4848 | - } else { | ||
| 4849 | - //---二维吗图--- | ||
| 4850 | - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 4851 | - } | ||
| 4852 | - break; | ||
| 4853 | - | ||
| 4854 | - case 2: //会员团和商家团的展示 | ||
| 4855 | - //---画线--- | ||
| 4856 | - context.setLineWidth(1 * unit) | ||
| 4857 | - context.moveTo(32 * unit, 670 * unit) | ||
| 4858 | - context.lineTo(520 * unit, 670 * unit) | ||
| 4859 | - context.stroke(); | ||
| 4860 | - //---文字--- | ||
| 4861 | - context.setFillStyle("black") | ||
| 4862 | - context.setFontSize(24 * unit) | ||
| 4863 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 4864 | - | ||
| 4865 | - //绘制成团图片 | ||
| 4866 | - var ct_img = "../../../images/share/ct_num.png"; | ||
| 4867 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | ||
| 4868 | - var ct_num = th.data.prom_act.ct_num; | ||
| 4869 | - context.setFontSize(14 * unit) | ||
| 4870 | - context.font = 'normal'; | ||
| 4871 | - context.setFillStyle("red") | ||
| 4872 | - if (ct_num < 10) { | ||
| 4873 | - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | ||
| 4874 | - } else { | ||
| 4875 | - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | ||
| 4876 | - } | ||
| 4877 | - context.setFontSize(22 * unit) | ||
| 4878 | - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | ||
| 4879 | - | ||
| 4880 | - context.setFillStyle("gray") | ||
| 4881 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | ||
| 4882 | - context.setFillStyle("black") | ||
| 4883 | - context.font = 'normal bold 18px sans-serif'; | ||
| 4884 | - context.setFontSize(21.3 * unit) | ||
| 4885 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | ||
| 4886 | - | ||
| 4887 | - | ||
| 4888 | - //---二维吗图--- | ||
| 4889 | - //-- 自定义海报 -- | ||
| 4890 | - if (th.data.poster) { | ||
| 4891 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4892 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4893 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 4894 | - } else { | ||
| 4895 | - //---二维吗图--- | ||
| 4896 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 4897 | - } | ||
| 4898 | - break | ||
| 4899 | - case 3: //阶梯团的展示 | ||
| 4900 | - //---画线--- | ||
| 4901 | - context.setLineWidth(1 * unit) | ||
| 4902 | - context.moveTo(32 * unit, 670 * unit) | ||
| 4903 | - context.lineTo(520 * unit, 670 * unit) | ||
| 4904 | - context.stroke(); | ||
| 4905 | - //---文字--- | ||
| 4906 | - context.setFillStyle("black") | ||
| 4907 | - context.setFontSize(24 * unit) | ||
| 4908 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 4909 | - | ||
| 4910 | - //---绘制中间阶梯的价格--- | ||
| 4911 | - var list = th.data.prom_act.ct_rylist; | ||
| 4912 | - for (var i = 0; i < list.length; i++) { | ||
| 4913 | - var item = list[i]; | ||
| 4914 | - var wi = i * 90 * unit; | ||
| 4915 | - context.font = 'normal'; | ||
| 4916 | - context.setFontSize(16 * unit) | ||
| 4917 | - context.setFillStyle("red") | ||
| 4918 | - context.fillText("¥", 40 * unit + wi, 756 * unit); | ||
| 4919 | - context.setFontSize(22 * unit) | ||
| 4920 | - var pri = parseFloat(item.price).toFixed(2); | ||
| 4921 | - context.fillText(pri, 56 * unit + wi, 756 * unit); | ||
| 4922 | - context.setFillStyle("gray") | ||
| 4923 | - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | ||
| 4924 | - } | ||
| 4925 | - //----------------下面部分---------------- | ||
| 4926 | - // context.setFillStyle("gray") | ||
| 4927 | - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | ||
| 4928 | - // context.setFillStyle("black") | ||
| 4929 | - // context.font = 'normal bold 18px sans-serif'; | ||
| 4930 | - // context.setFontSize(22 * unit) | ||
| 4931 | - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | ||
| 4932 | - //context.setFillStyle("gray") | ||
| 4933 | - context.setFillStyle("black") | ||
| 4934 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | ||
| 4935 | - //context.font = 'normal bold 18px sans-serif'; | ||
| 4936 | - context.setFontSize(21 * unit) | ||
| 4937 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | ||
| 4938 | - | ||
| 4939 | - | ||
| 4940 | - //-- 自定义海报 -- | ||
| 4941 | - if (th.data.poster) { | ||
| 4942 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4943 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4944 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 4945 | - } else { | ||
| 4946 | - //---二维吗图--- | ||
| 4947 | - context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 4948 | - } | ||
| 4949 | - break | ||
| 4950 | - | ||
| 4951 | - | ||
| 4952 | - case -1: //秒杀商品的展示 | ||
| 4953 | - //---画线--- | ||
| 4954 | - context.setLineWidth(1 * unit) | ||
| 4955 | - context.moveTo(32 * unit, 670 * unit) | ||
| 4956 | - context.lineTo(520 * unit, 670 * unit) | ||
| 4957 | - context.stroke(); | ||
| 4958 | - | ||
| 4959 | - | ||
| 4960 | - context.setFillStyle("black") | ||
| 4961 | - context.setFontSize(24 * unit) | ||
| 4962 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); | ||
| 4963 | - //---文字--- | ||
| 4964 | - context.setFontSize(22 * unit) | ||
| 4965 | - context.setFillStyle("black") | ||
| 4966 | - context.fillText("长按识别二维码", 40 * unit, 800 * unit); | ||
| 4967 | - context.fillText("立即开始抢购", 40 * unit, 846 * unit); | ||
| 4968 | - | ||
| 4969 | - | ||
| 4970 | - //---二维吗图--- | ||
| 4971 | - //-- 自定义海报 -- | ||
| 4972 | - if (th.data.poster) { | ||
| 4973 | - var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4974 | - var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4975 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 4976 | - } else { | ||
| 4977 | - //---二维吗图--- | ||
| 4978 | - context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 4979 | - } | ||
| 4980 | - break; | ||
| 4981 | - | ||
| 4982 | - | ||
| 4983 | - } | ||
| 4984 | - | ||
| 4985 | - | ||
| 4986 | - //--- 如果是自定义海报的时候 --- | ||
| 4987 | - if(type != 0) { | ||
| 4988 | - | ||
| 4989 | - if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4990 | - | ||
| 4991 | - //如果显示会员信息的话 | ||
| 4992 | - if (parseInt(th.data.poster.show_headpic)) { | ||
| 4993 | - //获取坐标 | ||
| 4994 | - var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 4995 | - var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 4996 | - //---绘制圆形要放在最后---- | ||
| 4997 | - context.save(); | ||
| 4998 | - context.beginPath(); | ||
| 4999 | - var h_x = x * unit; | ||
| 5000 | - var h_y = y * unit; | ||
| 5001 | - var h_r = 40 * unit; | ||
| 5002 | - var cx = h_x + h_r; | ||
| 5003 | - var cy = h_y + h_r; | ||
| 5004 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5005 | - context.closePath(); | ||
| 5006 | - context.fill(); | ||
| 5007 | - context.clip(); | ||
| 5008 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5009 | - context.restore(); | ||
| 5010 | - } | ||
| 5011 | - | ||
| 5012 | - } else { | ||
| 5013 | - //---绘制圆形要放在最后---- | ||
| 5014 | - context.save(); | ||
| 5015 | - context.beginPath(); | ||
| 5016 | - var h_x = 60 * unit; | ||
| 5017 | - var h_y = 24 * unit; | ||
| 5018 | - var h_r = 40 * unit; | ||
| 5019 | - var cx = h_x + h_r; | ||
| 5020 | - var cy = h_y + h_r; | ||
| 5021 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5022 | - context.closePath(); | ||
| 5023 | - context.fill(); | ||
| 5024 | - context.clip(); | ||
| 5025 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5026 | - context.restore(); | ||
| 5027 | - } | ||
| 5028 | - | ||
| 5029 | - }; | ||
| 5030 | - | ||
| 5031 | - | ||
| 5032 | - | ||
| 5033 | - //把画板内容绘制成图片,并回调 画板图片路径 | ||
| 5034 | - context.draw(false, function () { | ||
| 5035 | - setTimeout(function () { | ||
| 5036 | - wx.canvasToTempFilePath({ | ||
| 5037 | - x: 0, | ||
| 5038 | - y: 0, | ||
| 5039 | - width: 750, | ||
| 5040 | - height: 1217, | ||
| 5041 | - destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | ||
| 5042 | - destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | ||
| 5043 | - canvasId: 'share', | ||
| 5044 | - success: function (res) { | ||
| 5045 | - | ||
| 5046 | - that.setData({ | ||
| 5047 | - shareImgPath: res.tempFilePath, | ||
| 5048 | - canvasHidden: true | ||
| 5049 | - }) | 4159 | + //让商品带上房间号 |
| 4160 | + if (th.data.sys_switch.is_skuroom_id == 1) { | ||
| 4161 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | ||
| 4162 | + newd.room_id = getApp().globalData.room_id; | ||
| 4163 | + } | ||
| 4164 | + } else { | ||
| 4165 | + if (newd.goods_id == getApp().globalData.room_goods_id) { | ||
| 4166 | + newd.room_id = getApp().globalData.room_id; | ||
| 4167 | + } | ||
| 4168 | + } | ||
| 5050 | 4169 | ||
| 5051 | - if (!res.tempFilePath) { | ||
| 5052 | - wx.showModal({ | ||
| 5053 | - title: '提示', | ||
| 5054 | - content: '图片绘制中,请稍后重试', | ||
| 5055 | - showCancel: false | ||
| 5056 | - }) | ||
| 5057 | - return false; | ||
| 5058 | - } | ||
| 5059 | - | ||
| 5060 | - // wx.previewImage({ | ||
| 5061 | - // //将图片预览出来 | ||
| 5062 | - // urls: [that.data.shareImgPath] | ||
| 5063 | - // }); | ||
| 5064 | - that.setData({ | ||
| 5065 | - showPoster: true, | ||
| 5066 | - }); | ||
| 5067 | - wx.hideLoading(); | 4170 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ |
| 4171 | + | ||
| 4172 | + if (th.data.is_normal == 1) { | ||
| 4173 | + var conf = th.data.bconfig; | ||
| 4174 | + if (conf.switch_list) { | ||
| 4175 | + var s_list = JSON.parse(conf.switch_list); | ||
| 4176 | + //如果后台有开启等级价的功能 | ||
| 4177 | + if (parseInt(s_list.rank_switch) == 2) { | ||
| 4178 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | ||
| 4179 | + //如果会员有等级价 | ||
| 4180 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | ||
| 4181 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | ||
| 4182 | + newd.goods_price = card_price; | ||
| 4183 | + } | ||
| 4184 | + } | ||
| 5068 | } | 4185 | } |
| 5069 | - }) | ||
| 5070 | - }, 500) | 4186 | + } |
| 5071 | 4187 | ||
| 5072 | - }); | ||
| 5073 | - }); | ||
| 5074 | - }, | ||
| 5075 | - fail: function (res) { | ||
| 5076 | - console.log(res); | ||
| 5077 | - wx.hideLoading(); | ||
| 5078 | 4188 | ||
| 5079 | - } | ||
| 5080 | - }); | ||
| 5081 | - }, | 4189 | + //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- |
| 4190 | + if (th.data.prom_type == 6 && th.data.is_normal != 1) { | ||
| 4191 | + newd.goods_price = th.data.prom_price; | ||
| 4192 | + newd.prom_type = th.data.prom_type; | ||
| 4193 | + newd.prom_id = th.data.prom_id; | ||
| 4194 | + newd.kt_type = th.data.prom_act.kttype; //开团类型 | ||
| 4195 | + newd.is_pt_tz = 0; | ||
| 4196 | + //th.data.sto_sele_distr=1; //直接用自提的方式提交 | ||
| 4197 | + if (newd.kt_type > 1) { | ||
| 4198 | + newd.is_pt_tz = 1; //开团类型 | ||
| 4199 | + } | ||
| 4200 | + if (newd.kt_type == 3) { | ||
| 4201 | + th.data.sto_sele_distr = 1; | ||
| 4202 | + } | ||
| 5082 | 4203 | ||
| 4204 | + } else if (th.data.prom_type == 3) { | ||
| 4205 | + newd.prom_type = 0; | ||
| 4206 | + newd.prom_id = 0; | ||
| 4207 | + } | ||
| 5083 | 4208 | ||
| 5084 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 5085 | - draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | ||
| 5086 | - var lineWidth = 0; | ||
| 5087 | - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | ||
| 5088 | - var han = 0; | ||
| 5089 | - for (let i = 0; i < str.length; i++) { | ||
| 5090 | - if (han == 2) return; | ||
| 5091 | - //lineWidth += ctx.measureText(str[i]).width; | ||
| 5092 | - lineWidth += ut.measureText(str[i], 21.3 * unit); | ||
| 5093 | - if (lineWidth > canvasWidth) { | ||
| 5094 | - han++; | ||
| 5095 | - | ||
| 5096 | - if (han == 2) | ||
| 5097 | - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | ||
| 5098 | - else | ||
| 5099 | - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | ||
| 5100 | - | ||
| 5101 | - initHeight += 22; //22为字体的高度 | ||
| 5102 | - lineWidth = 0; | ||
| 5103 | - lastSubStrIndex = i; | ||
| 5104 | - titleHeight += 20; | ||
| 5105 | - } | ||
| 5106 | - if (i == str.length - 1) { //绘制剩余部分 | ||
| 5107 | - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | ||
| 5108 | - } | ||
| 5109 | - } | ||
| 5110 | - }, | 4209 | + newd['pick_name'] = th.data.sto_sele_name; |
| 4210 | + newd['pick_dis'] = th.data.sto_sele_distr; | ||
| 4211 | + newd['is_normal'] = th.data.is_normal; | ||
| 4212 | + | ||
| 4213 | + if (newd['is_normal']) { | ||
| 4214 | + newd['is_pd_normal'] = 1; | ||
| 4215 | + //判断一下有没有全局优惠活动 | ||
| 4216 | + th.check_nor_promgood(newd.goods_id, function (e) { | ||
| 4217 | + if (e && e.act_id) { | ||
| 4218 | + newd['prom_type'] = 3; | ||
| 4219 | + newd['prom_id'] = e.act_id; | ||
| 4220 | + } | ||
| 4221 | + th.buyNow(newd) | ||
| 4222 | + }) | ||
| 4223 | + } | ||
| 4224 | + else th.buyNow_pt(newd); | ||
| 4225 | + }) | ||
| 4226 | + }, | ||
| 5111 | 4227 | ||
| 5112 | - // ----视频图片---- | ||
| 5113 | - // 图片计数器 | ||
| 5114 | - swiperChange: function (e) { | ||
| 5115 | - var that = this; | ||
| 5116 | - if (e.detail.current > 0) { | ||
| 5117 | - that.setData({ | ||
| 5118 | - hiddenn: 1, | ||
| 5119 | - videopicture: 1, | ||
| 5120 | - }) | ||
| 5121 | - } else { | ||
| 5122 | - that.setData({ | ||
| 5123 | - hiddenn: 0, | ||
| 5124 | - videopicture: 0, | ||
| 5125 | - }) | ||
| 5126 | - } | ||
| 5127 | - if (e.detail.source == 'touch') { | ||
| 5128 | - that.setData({ | ||
| 5129 | - current: e.detail.current | ||
| 5130 | - }) | ||
| 5131 | - } | ||
| 5132 | - }, | 4228 | + //----------立即购买_pt----------- |
| 4229 | + buyNow_pt: function (e) { | ||
| 4230 | + s.set_b_now(e); | ||
| 4231 | + wx.navigateTo({ | ||
| 4232 | + url: "/pages/cart/cart2_pt/cart2_pt?is_bnow=1&goods_id=" + e.goods_id, | ||
| 4233 | + }); | ||
| 4234 | + }, | ||
| 5133 | 4235 | ||
| 5134 | - /*---视频相关--*/ | ||
| 5135 | - videopicture: function (e) { | ||
| 5136 | - var vipi = e.currentTarget.dataset.vipi; | ||
| 5137 | - this.setData({ | ||
| 5138 | - videopicture: vipi, | ||
| 5139 | - swiperCurrent: vipi, | ||
| 5140 | - noon: 0, | ||
| 5141 | - current: 1 | ||
| 5142 | - }); | ||
| 5143 | - }, | 4236 | + //-------跳转pt商品------- |
| 4237 | + go_to_nopay: function () { | ||
| 4238 | + var th = this; | ||
| 4239 | + url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id; | ||
| 4240 | + getApp().goto(url); | ||
| 5144 | 4241 | ||
| 5145 | - videoPlay: function (e) { | ||
| 5146 | - var _index = e.currentTarget.id | ||
| 5147 | - this.setData({ | ||
| 5148 | - _index: _index, | ||
| 5149 | - noon: 1 | ||
| 5150 | - }) | 4242 | + }, |
| 4243 | + //-------跳转pt teamshow------- | ||
| 4244 | + go_to_team_show: function () { | ||
| 4245 | + | ||
| 4246 | + if (this.data.is_go_to_team_show) return false; | ||
| 4247 | + this.data.is_go_to_team_show = 1; | ||
| 4248 | + wx.showLoading(); | ||
| 4249 | + | ||
| 4250 | + var th = this; | ||
| 4251 | + var url = "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn; | ||
| 4252 | + /*-- | ||
| 4253 | + wx.redirectTo({ | ||
| 4254 | + url:url, | ||
| 4255 | + })--*/ | ||
| 4256 | + getApp().goto(url); | ||
| 5151 | 4257 | ||
| 5152 | - setTimeout(function () { | ||
| 5153 | - //将点击视频进行播放 | ||
| 5154 | - var videoContext = wx.createVideoContext(_index) | ||
| 5155 | - videoContext.play(); | ||
| 5156 | - }, 500) | ||
| 5157 | - }, | 4258 | + }, |
| 5158 | 4259 | ||
| 4260 | + //---拼团倒计时--- | ||
| 4261 | + countDown2() { | ||
| 4262 | + if (!this.data.is_timer) return false; | ||
| 4263 | + var th = this; | ||
| 4264 | + // 获取当前时间,同时得到活动结束时间数组 | ||
| 4265 | + var newTime = ut.gettimestamp(); | ||
| 4266 | + var List = th.data.teamgroup; | ||
| 4267 | + for (var j = 0; j < List.length; j++) { | ||
| 4268 | + // 对结束时间进行处理渲染到页面 | ||
| 4269 | + var endTime = List[j].kt_end_time; | ||
| 4270 | + let obj = null; | ||
| 4271 | + // 如果活动未结束,对时间进行处理 | ||
| 4272 | + if (endTime - newTime > 0) { | ||
| 4273 | + let time = (endTime - newTime); | ||
| 4274 | + // 获取天、时、分、秒 | ||
| 4275 | + let day = parseInt(time / (60 * 60 * 24)); | ||
| 4276 | + let hou = parseInt(time % (60 * 60 * 24) / 3600); | ||
| 4277 | + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | ||
| 4278 | + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | ||
| 4279 | + obj = { | ||
| 4280 | + day: this.timeFormat(day), | ||
| 4281 | + hou: this.timeFormat(hou), | ||
| 4282 | + min: this.timeFormat(min), | ||
| 4283 | + sec: this.timeFormat(sec) | ||
| 4284 | + } | ||
| 4285 | + } else { | ||
| 4286 | + //活动已结束,全部设置为'00' | ||
| 4287 | + obj = { | ||
| 4288 | + day: '00', | ||
| 4289 | + hou: '00', | ||
| 4290 | + min: '00', | ||
| 4291 | + sec: '00' | ||
| 4292 | + } | ||
| 4293 | + } | ||
| 4294 | + var txt = "timer[" + j + "]"; | ||
| 4295 | + th.setData({ | ||
| 4296 | + [txt]: obj | ||
| 4297 | + }); | ||
| 4298 | + } | ||
| 4299 | + setTimeout(th.countDown2, 1000); | ||
| 4300 | + }, | ||
| 4301 | + //跳转参加团 | ||
| 4302 | + go_cj_team: function (e) { | ||
| 4303 | + var ind = e.currentTarget.dataset.ind; | ||
| 4304 | + var item = this.data.teamgroup[ind]; | ||
| 4305 | + var id = item.id; | ||
| 4306 | + var th = this; | ||
| 4307 | + | ||
| 4308 | + getApp().request.get("/api/weshop/order/page", { | ||
| 4309 | + data: { | ||
| 4310 | + pt_prom_id: item.team_id, | ||
| 4311 | + user_id: oo.user_id, | ||
| 4312 | + store_id: os.stoid, | ||
| 4313 | + pageSize: 1, | ||
| 4314 | + page: 1 | ||
| 4315 | + }, | ||
| 4316 | + success: function (e) { | ||
| 4317 | + if (e.data.code != 0) { | ||
| 4318 | + getApp().my_warnning("读取订单失败", 0, th); | ||
| 4319 | + return fasle; | ||
| 4320 | + } | ||
| 4321 | + //--跳转到已经购买的情况-- | ||
| 4322 | + if (e.data.data.pageData.length > 0) { | ||
| 4323 | + var odr = e.data.data.pageData[0]; | ||
| 4324 | + //还未支付 | ||
| 4325 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | ||
| 4326 | + wx.showModal({ | ||
| 4327 | + title: "您已经购买了该商品待支付中", | ||
| 4328 | + success: function (a) { | ||
| 4329 | + if (a.confirm) { | ||
| 4330 | + wx.navigateTo({ | ||
| 4331 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | ||
| 4332 | + }); | ||
| 4333 | + } | ||
| 4334 | + } | ||
| 4335 | + }); | ||
| 4336 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | ||
| 5159 | 4337 | ||
| 4338 | + if (this.data.is_go_to_team_show) return false; | ||
| 4339 | + this.data.is_go_to_team_show = 1; | ||
| 4340 | + wx.showLoading(); | ||
| 4341 | + /*-- | ||
| 4342 | + wx.redirectTo({ | ||
| 4343 | + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | ||
| 4344 | + });--*/ | ||
| 5160 | 4345 | ||
| 5161 | - //--获取头像的本地缓存,回调写法-- | ||
| 5162 | - get_head_temp: function (tt, func) { | ||
| 5163 | - var ee = this; | ||
| 5164 | - if (ee.data.share_head) { | ||
| 5165 | - tt(func); | ||
| 5166 | - return false; | ||
| 5167 | - } | ||
| 5168 | - //---获取分享图片的本地地址,头像和商品图片---- | ||
| 5169 | - var path2 = getApp().globalData.userInfo.head_pic; | ||
| 5170 | - if (path2 == "") { | ||
| 5171 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | ||
| 5172 | - tt(func); | ||
| 5173 | - } else { | ||
| 5174 | - path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5175 | - path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5176 | - wx.getImageInfo({ | ||
| 5177 | - src: path2, | ||
| 5178 | - success: function (res) { | ||
| 5179 | - //res.path是网络图片的本地地址 | ||
| 5180 | - ee.data.share_head = res.path; | ||
| 5181 | - tt(func); | ||
| 5182 | - }, | ||
| 5183 | - fail: function (res) { | ||
| 5184 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | ||
| 5185 | - tt(func); | 4346 | + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); |
| 4347 | + | ||
| 4348 | + } else { | ||
| 4349 | + wx.navigateTo({ | ||
| 4350 | + url: "/pages/team/team_show/team_show?tg_id=" + id, | ||
| 4351 | + }); | ||
| 4352 | + } | ||
| 4353 | + } | ||
| 4354 | + //--跳转到参团-- | ||
| 4355 | + else { | ||
| 4356 | + wx.navigateTo({ | ||
| 4357 | + url: "/pages/team/team_show/team_show?tg_id=" + id, | ||
| 4358 | + }); | ||
| 4359 | + } | ||
| 4360 | + } | ||
| 4361 | + }) | ||
| 4362 | + | ||
| 4363 | + }, | ||
| 4364 | + | ||
| 4365 | + //跳到团更多 | ||
| 4366 | + go_t_more: function () { | ||
| 4367 | + var team_id = this.data.prom_id; | ||
| 4368 | + wx.navigateTo({ | ||
| 4369 | + url: "/pages/team/team_more/team_more?team_id=" + team_id, | ||
| 4370 | + }); | ||
| 4371 | + }, | ||
| 4372 | + | ||
| 4373 | + //--点赞功能-- | ||
| 4374 | + click_zan: function (e) { | ||
| 4375 | + var com_id = e.currentTarget.dataset.com_id; | ||
| 4376 | + var item_id = e.currentTarget.dataset.item_id; | ||
| 4377 | + var app = getApp(), | ||
| 4378 | + th = this; | ||
| 4379 | + | ||
| 4380 | + if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | ||
| 4381 | + app.confirmBox("您还未登录"); | ||
| 4382 | + return false; | ||
| 5186 | } | 4383 | } |
| 5187 | - }); | ||
| 5188 | - } | ||
| 5189 | - }, | ||
| 5190 | - //--获取商品图片的本地缓存,回调写法-- | ||
| 5191 | - get_goods_temp: function (tt) { | ||
| 5192 | - var ee = this; | ||
| 5193 | - if (ee.data.share_goods_img) { | ||
| 5194 | - tt(); | ||
| 5195 | - return false; | ||
| 5196 | - } | ||
| 5197 | 4384 | ||
| 5198 | - var img_url = ee.data.data.original_img; | ||
| 5199 | - if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) { | ||
| 5200 | - img_url = this.data.iurl + this.data.prom_act.share_imgurl; | ||
| 5201 | - } | 4385 | + var iszan = th.data.comments[item_id].userZanNum; |
| 4386 | + if (this.data.iszaning) return false; | ||
| 4387 | + this.data.iszaning = 1; | ||
| 5202 | 4388 | ||
| 5203 | - //获取商品是分享图信息 | ||
| 5204 | - wx.getImageInfo({ | ||
| 5205 | - src: img_url, | ||
| 5206 | - success: function (res) { | ||
| 5207 | - //res.path是网络图片的本地地址 | ||
| 5208 | - ee.data.share_goods_img = res.path; | ||
| 5209 | - tt(); | ||
| 5210 | - }, | ||
| 5211 | - fail: function (res) { | ||
| 5212 | - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | ||
| 5213 | - tt(); | ||
| 5214 | - } | ||
| 5215 | - }); | ||
| 5216 | - }, | ||
| 5217 | 4389 | ||
| 5218 | - //--外侧评价的点击效果--- | ||
| 5219 | - clik_evaluate: function (e) { | ||
| 5220 | - var val = e.currentTarget.dataset.val; | ||
| 5221 | - this.setData({ | ||
| 5222 | - activeCategoryId: 2, | ||
| 5223 | - activeCategoryId3: val, | ||
| 5224 | - comments: null | ||
| 5225 | - }); | ||
| 5226 | - this.requestComments_new(); | ||
| 5227 | - }, | 4390 | + app.request.post("/api/weshop/commentZan/save", { |
| 4391 | + data: { | ||
| 4392 | + store_id: o.stoid, | ||
| 4393 | + user_id: app.globalData.user_id, | ||
| 4394 | + goods_id: th.data.gid, | ||
| 4395 | + comment_id: com_id | ||
| 4396 | + }, | ||
| 4397 | + success: function (ee) { | ||
| 5228 | 4398 | ||
| 5229 | - //--跳转到商品详情页面-- | ||
| 5230 | - go_goods: function (e) { | ||
| 5231 | - var gid = e.currentTarget.dataset.gid; | ||
| 5232 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | ||
| 5233 | - getApp().goto(url); | ||
| 5234 | - }, | 4399 | + if (ee.data.code == "-1") { |
| 4400 | + app.my_warnning("不能给自己点赞", 0, th); | ||
| 4401 | + th.data.iszaning = 0; | ||
| 4402 | + return; | ||
| 4403 | + } | ||
| 5235 | 4404 | ||
| 5236 | - //--跳转到支付尾款界面-- | ||
| 5237 | - go_pay_wk: function () { | ||
| 5238 | - var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id; | ||
| 5239 | - getApp().goto(url); | ||
| 5240 | - }, | 4405 | + if (ee.data.code == 0 && iszan != 1) { |
| 4406 | + var num = th.data.comments[item_id].zan_num; | ||
| 4407 | + num++; | ||
| 4408 | + var text = "comments[" + item_id + "].zan_num"; | ||
| 4409 | + var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4410 | + var _errObj = {}; | ||
| 4411 | + _errObj[text] = num; | ||
| 4412 | + _errObj[text1] = 1; | ||
| 4413 | + th.setData(_errObj); | ||
| 5241 | 4414 | ||
| 5242 | - pop_err_img: function (e) { | ||
| 5243 | - var txt = e.currentTarget.dataset.errorimg; | ||
| 5244 | - var ob = {}; | ||
| 5245 | - ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 5246 | - this.setData(ob); | ||
| 5247 | - }, | 4415 | + } else { |
| 4416 | + var num = th.data.comments[item_id].zan_num; | ||
| 4417 | + num--; | ||
| 4418 | + var text = "comments[" + item_id + "].zan_num"; | ||
| 4419 | + var text1 = "comments[" + item_id + "].userZanNum"; | ||
| 4420 | + var _errObj = {}; | ||
| 4421 | + _errObj[text] = num; | ||
| 4422 | + _errObj[text1] = 0; | ||
| 4423 | + th.setData(_errObj); | ||
| 4424 | + } | ||
| 5248 | 4425 | ||
| 5249 | - //--调用更新阶梯团的接口-- | ||
| 5250 | - update_jiti: function (id) { | ||
| 5251 | - var th = this; | ||
| 5252 | - //--更新阶梯团-- | ||
| 5253 | - getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { | ||
| 5254 | - success: function (ee) { | ||
| 5255 | - //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- | ||
| 5256 | - if (ee.data.code == 0) { | ||
| 5257 | - th.setData({ | ||
| 5258 | - user_order_pt_state: 3, | ||
| 5259 | - }); | ||
| 5260 | - } else if (ee.data.code == -1) { | ||
| 5261 | - th.setData({ | ||
| 5262 | - user_order_pt_state: 2, | ||
| 5263 | - }); | ||
| 5264 | - } | ||
| 5265 | - } | ||
| 5266 | - }) | ||
| 5267 | - }, | ||
| 5268 | - // 选择门店 | ||
| 5269 | - choice_store: function (ee) { | ||
| 5270 | - var th = this; | ||
| 5271 | - var ind = ee.currentTarget.dataset.ind; | ||
| 5272 | - var bconfig = th.data.bconfig; | ||
| 5273 | - | ||
| 5274 | - if (!th.data.only_pk && !th.data.def_pickpu_list) { | ||
| 5275 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5276 | - return false; | ||
| 5277 | - } | 4426 | + setTimeout(function () { |
| 4427 | + th.data.iszaning = 0; | ||
| 4428 | + }, 500) | ||
| 5278 | 4429 | ||
| 5279 | - if (th.data.only_pk && !th.data.only_pk.length) { | ||
| 5280 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5281 | - return false; | ||
| 5282 | - } | ||
| 5283 | - if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { | ||
| 5284 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5285 | - return false; | ||
| 5286 | - } | 4430 | + } |
| 4431 | + }) | ||
| 4432 | + }, | ||
| 5287 | 4433 | ||
| 4434 | + /*----券的开关---*/ | ||
| 4435 | + switchCoupon: async function (event) { | ||
| 4436 | + var coupon = event.currentTarget.dataset.coupon; | ||
| 4437 | + var app = getApp(); | ||
| 4438 | + var url = "/api/weshop/prom/coupon/pageCouponList"; | ||
| 4439 | + var quan_list = this.data.quan_list; | ||
| 4440 | + var th = this; | ||
| 4441 | + | ||
| 4442 | + //当开启,且列表为空的情况下要 | ||
| 4443 | + if (!quan_list && coupon == "1") { | ||
| 4444 | + wx.showLoading(); | ||
| 4445 | + await app.request.promiseGet(url, { | ||
| 4446 | + data: { | ||
| 4447 | + store_id: os.stoid, | ||
| 4448 | + type: 1, | ||
| 4449 | + pageSize: 100, | ||
| 4450 | + page: 1, | ||
| 4451 | + user_id: app.globalData.user_id, | ||
| 4452 | + is_share: 0 | ||
| 4453 | + } | ||
| 4454 | + }).then(res => { | ||
| 4455 | + wx.hideLoading(); | ||
| 4456 | + quan_list = res.data.data.pageData; | ||
| 4457 | + }) | ||
| 5288 | 4458 | ||
| 5289 | - if (bconfig && bconfig.is_sort_storage) { | ||
| 5290 | - wx.getLocation({ | ||
| 5291 | - type: 'gcj02', | ||
| 5292 | - success: function (res) { | 4459 | + if (quan_list) { |
| 4460 | + for (var ind in quan_list) { | ||
| 4461 | + var ep = quan_list[ind]; | ||
| 4462 | + var start = ut.formatTime(ep.use_start_time, "yyyy-MM-dd"); | ||
| 4463 | + var end = ut.formatTime(ep.use_end_time, "yyyy-MM-dd"); | ||
| 4464 | + start = start.replace("00:00:00", ""); | ||
| 4465 | + end = end.replace("00:00:00", ""); | ||
| 4466 | + quan_list[ind].start = start; | ||
| 4467 | + quan_list[ind].end = end; | ||
| 4468 | + } | ||
| 4469 | + } | ||
| 5293 | 4470 | ||
| 5294 | - th.data.lat = res.latitude; | ||
| 5295 | - th.data.lon = res.longitude; | ||
| 5296 | - th.data.is_get_local_ok = 1; | ||
| 5297 | - th.setData({ | ||
| 5298 | - is_gps: 1 | ||
| 5299 | - }); | ||
| 5300 | - //th.onShow(); | ||
| 5301 | - th.get_sto(th.data.is_normal); | ||
| 5302 | - }, | ||
| 5303 | - fail: function (res) { | ||
| 5304 | - //th.onShow(); | ||
| 5305 | - th.data.is_get_local_ok = 1; | ||
| 5306 | - th.get_sto(th.data.is_normal); | ||
| 5307 | - if (res.errCode == 2) { | ||
| 5308 | th.setData({ | 4471 | th.setData({ |
| 5309 | - is_gps: 0 | 4472 | + coupon: coupon, |
| 4473 | + quan_list: quan_list | ||
| 5310 | }); | 4474 | }); |
| 5311 | - if (th.data.is_gps == 0) { | ||
| 5312 | - getApp().confirmBox("请开启GPS定位", null, 25000, !1); | ||
| 5313 | - } | ||
| 5314 | - } else { | 4475 | + } else { |
| 5315 | th.setData({ | 4476 | th.setData({ |
| 5316 | - is_gps: "3" | 4477 | + coupon: coupon |
| 5317 | }); | 4478 | }); |
| 5318 | - } | 4479 | + } |
| 4480 | + }, | ||
| 4481 | + | ||
| 4482 | + //--查看评价-- | ||
| 4483 | + look_pj: function () { | ||
| 4484 | + this.tabComment(); | ||
| 4485 | + this.doScrollTop(); | ||
| 4486 | + }, | ||
| 4487 | + | ||
| 4488 | + //-----领取券----- | ||
| 4489 | + get_quan: function (e) { | ||
| 4490 | + var cid = e.currentTarget.dataset.cid; | ||
| 4491 | + var index = e.currentTarget.dataset.ind; | ||
| 4492 | + var item = this.data.quan_list[index]; | ||
| 5319 | 4493 | ||
| 4494 | + | ||
| 4495 | + //--先判断会员状态-- | ||
| 4496 | + var user_info = getApp().globalData.userInfo; | ||
| 4497 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4498 | + wx.navigateTo({ | ||
| 4499 | + url: '/pages/togoin/togoin', | ||
| 4500 | + }) | ||
| 4501 | + return false; | ||
| 5320 | } | 4502 | } |
| 5321 | - }) | ||
| 5322 | - } else { | ||
| 5323 | - th.data.is_get_local_ok = 1; | ||
| 5324 | - th.get_sto(th.data.is_normal); | ||
| 5325 | - } | ||
| 5326 | 4503 | ||
| 5327 | - if (ind != undefined && ind != null) { | ||
| 5328 | - this.setData({ | ||
| 5329 | - open_ind_store: ind, | ||
| 5330 | - store: 1, | ||
| 5331 | - openSpecModal: !1, | ||
| 5332 | - openSpecModal_pt: !1 | ||
| 5333 | - }) | ||
| 5334 | - } else { | ||
| 5335 | - this.setData({ | ||
| 5336 | - store: 1, | ||
| 5337 | - openSpecModal: !1, | ||
| 5338 | - openSpecModal_pt: !1 | ||
| 5339 | - }) | ||
| 5340 | - } | ||
| 5341 | - }, | ||
| 5342 | - //关闭选择门店 | ||
| 5343 | - close_popup: function (e) { | ||
| 5344 | - var th = this; | ||
| 5345 | - this.setData({ | ||
| 5346 | - store: 0, | ||
| 5347 | - choice_sort_store: 0, | ||
| 5348 | - sort_store: 0, | ||
| 5349 | - fir_pick_index: 0, | ||
| 5350 | - sec_pick_index: 0 | ||
| 5351 | - }) | ||
| 5352 | 4504 | ||
| 5353 | - var openindstore = this.data.open_ind_store; | ||
| 5354 | - if (openindstore == 1) { | ||
| 5355 | - th.setData({ | ||
| 5356 | - openSpecModal: !0, | ||
| 5357 | - openSpecModal_ind: openindstore, | ||
| 5358 | - }); | ||
| 5359 | - } else if (openindstore == 2) { | ||
| 5360 | - th.setData({ | ||
| 5361 | - openSpecModal: !0, | ||
| 5362 | - openSpecModal_ind: openindstore, | ||
| 5363 | - }); | ||
| 5364 | - } | ||
| 5365 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5366 | - th.setData({ | ||
| 5367 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5368 | - store: 0, //关闭门店 | ||
| 5369 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5370 | - sort_store: 0, //关闭门店2级 | ||
| 5371 | - }); | ||
| 5372 | - } | ||
| 5373 | - else { | ||
| 5374 | - th.setData({ | ||
| 5375 | - store: 0, | ||
| 5376 | - choice_sort_store: 0, | ||
| 5377 | - sort_store: 0 | ||
| 5378 | - }) | ||
| 5379 | - } | 4505 | + //如果券还在领取中,不能再点 |
| 4506 | + if (item.linging == 1) { | ||
| 4507 | + getApp().my_warnning('领取中..', 0, this); | ||
| 4508 | + return false; | ||
| 4509 | + } | ||
| 5380 | 4510 | ||
| 4511 | + //如果领取的次数到了 | ||
| 4512 | + if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { | ||
| 4513 | + getApp().my_warnning('领取失败,您已领完该券', 0, this); | ||
| 4514 | + return false; | ||
| 4515 | + } | ||
| 5381 | 4516 | ||
| 5382 | - }, | 4517 | + var lq_num = item.lqnum; |
| 5383 | 4518 | ||
| 5384 | - //选择更多门店 | ||
| 5385 | - more_store: function () { | ||
| 5386 | - this.setData({ | ||
| 5387 | - sort_store: 1 | ||
| 5388 | - }); | ||
| 5389 | - }, | ||
| 5390 | - sort_store: function () { | 4519 | + var pdata = { |
| 4520 | + 'uid': oo.user_id, | ||
| 4521 | + 'cid': cid, | ||
| 4522 | + 'store_id': os.stoid, | ||
| 4523 | + 'type': 5 | ||
| 4524 | + }; | ||
| 5391 | 4525 | ||
| 5392 | - }, | ||
| 5393 | - // 返回按钮 | ||
| 5394 | - returns: function () { | ||
| 5395 | - this.setData({ | ||
| 5396 | - sort_store: 0, | ||
| 5397 | - choice_sort_store: 0 | ||
| 5398 | - }); | ||
| 5399 | - }, | ||
| 5400 | - //---选择分类门店--- | ||
| 5401 | - choice_sort_store: function (e) { | ||
| 5402 | - var index = e.currentTarget.dataset.index; | ||
| 5403 | - var region_name = e.currentTarget.dataset.region; | ||
| 5404 | - var item = this.data.all_sto[index]; | ||
| 5405 | - this.setData({ | ||
| 5406 | - region_name: region_name, | ||
| 5407 | - sort_store: 0, | ||
| 5408 | - choice_sort_store: 1, | ||
| 5409 | - sec_sto: item, | ||
| 5410 | - sec_pick_index: 0 | ||
| 5411 | - }); | ||
| 5412 | - }, | 4526 | + //-- 导购ID -- |
| 4527 | + if (getApp().globalData.guide_id) { | ||
| 4528 | + pdata.guide_id = getApp().globalData.guide_id; | ||
| 4529 | + } | ||
| 5413 | 4530 | ||
| 5414 | - choose_for_store_fir: function (e) { | ||
| 5415 | - var index_c = e.currentTarget.dataset.ind; | ||
| 5416 | - var th = this; | ||
| 5417 | - th.setData({ | ||
| 5418 | - fir_pick_index: index_c | ||
| 5419 | - }) | 4531 | + var app = getApp(), |
| 4532 | + th = this; | ||
| 4533 | + app.request.post("/api/weshop/couponList/saveCouponList", { | ||
| 4534 | + data: pdata, | ||
| 4535 | + success: function (res) { | ||
| 4536 | + if (res.data.code == 0) { | ||
| 4537 | + app.my_warnning("领取成功", 1, th); | ||
| 4538 | + lq_num++; | ||
| 4539 | + var text = "quan_list[" + index + "].lqnum"; | ||
| 4540 | + var text2 = "quan_list[" + index + "].linging"; | ||
| 4541 | + var obj = {}; | ||
| 4542 | + obj[text] = lq_num; | ||
| 4543 | + obj[text2] = 0; | ||
| 4544 | + th.setData(obj); | ||
| 4545 | + } else { | ||
| 4546 | + app.confirmBox(res.data.msg); | ||
| 4547 | + var text2 = "quan_list[" + index + "].linging"; | ||
| 4548 | + var obj = {}; | ||
| 4549 | + obj[text2] = 0; | ||
| 4550 | + th.setData(obj); | ||
| 4551 | + } | ||
| 4552 | + } | ||
| 4553 | + }) | ||
| 4554 | + }, | ||
| 5420 | 4555 | ||
| 5421 | - }, | ||
| 5422 | 4556 | ||
| 5423 | - //如果开启线下库存,已经急速库存才会使用 | ||
| 5424 | - async check_the_pick(item, func) { | ||
| 5425 | - var th = this; | ||
| 5426 | - var goodsinfo = th.data.sele_g; | ||
| 5427 | - var erpwareid = goodsinfo.erpwareid; | ||
| 5428 | - var plist = null; | ||
| 5429 | - var lock = 0; | ||
| 5430 | - | ||
| 5431 | - //---如果是活动的时候,同时不是普通购买--- | ||
| 5432 | - if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { | ||
| 5433 | - func(); return false; | ||
| 5434 | - } | 4557 | + drawPoster(context, unit, img, vpath) { |
| 4558 | + // 1.灰色背景 | ||
| 4559 | + context.setFillStyle('#f2f1f6'); | ||
| 4560 | + context.rect(0, 0, 554 * unit, 899 * unit); | ||
| 4561 | + context.fill(); | ||
| 4562 | + // 2.商城名称 | ||
| 4563 | + let shopName = this.data.sto_sele_name_1; | ||
| 4564 | + // let shopNameLen = context.measureText(shopName); | ||
| 4565 | + // let x_shopNameLen = (554 - shopNameLen.width)/2*unit; | ||
| 4566 | + // console.log('11111111111111',shopNameLen,x_shopNameLen); | ||
| 4567 | + context.setTextAlign('center'); | ||
| 4568 | + context.setFontSize(26 * unit); | ||
| 4569 | + context.setFillStyle('black'); | ||
| 4570 | + context.fillText(shopName, 277 * unit, 60 * unit); | ||
| 4571 | + // // 3.推荐来源 | ||
| 4572 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | ||
| 4573 | + // let fromTextLen = context.measureText(fromText); | ||
| 4574 | + // let x_fromText = (375 - fromTextLen.width)/2; | ||
| 4575 | + // console.log('222222',fromTextLen,x_fromText); | ||
| 4576 | + context.setTextAlign('center'); | ||
| 4577 | + context.setFontSize(22 * unit); | ||
| 4578 | + context.setFillStyle('#96959a'); | ||
| 4579 | + context.fillText(fromText, 277 * unit, 105 * unit); | ||
| 4580 | + // 4.海报背景 | ||
| 4581 | + // context.beginPath(); | ||
| 4582 | + // context.setStrokeStyle('#f2f1f6'); | ||
| 4583 | + context.setFillStyle('white'); | ||
| 4584 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | ||
| 4585 | + // context.stroke(); | ||
| 4586 | + // context.fill(); | ||
| 4587 | + // 5.商品图片 | ||
| 4588 | + // 图片的x坐标 | ||
| 4589 | + let bg_x = 37 * unit | ||
| 4590 | + // 图片的y坐标 | ||
| 4591 | + let bg_y = 157 * unit | ||
| 4592 | + // 图片宽度 | ||
| 4593 | + let bg_w = 480 * unit | ||
| 4594 | + // 图片高度 | ||
| 4595 | + let bg_h = 474 * unit | ||
| 4596 | + // 图片圆角 | ||
| 4597 | + let bg_r = 4 | ||
| 4598 | + // 绘制海报背景图片圆角 | ||
| 4599 | + context.save() | ||
| 4600 | + context.beginPath() | ||
| 4601 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | ||
| 4602 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | ||
| 4603 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | ||
| 4604 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | ||
| 4605 | + context.clip() | ||
| 4606 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | ||
| 4607 | + context.restore() | ||
| 4608 | + // 6.强烈推荐 | ||
| 4609 | + // context.beginPath(); | ||
| 4610 | + let tj_path = "../../../images/share/q_tj.png"; | ||
| 4611 | + context.beginPath() | ||
| 4612 | + context.drawImage(tj_path, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | ||
| 4613 | + context.setFontSize(16 * unit) | ||
| 4614 | + context.setLineJoin('round'); //交点设置成圆角 | ||
| 4615 | + context.setFillStyle("white") | ||
| 4616 | + context.setTextAlign('left'); | ||
| 4617 | + context.fillText('强烈推荐', 64 * unit, 672 * unit); | ||
| 4618 | + // 7.商品价格 | ||
| 4619 | + let price = '¥' + this.data.data.shop_price; | ||
| 4620 | + | ||
| 4621 | + if (this.data.card_field && this.data.data[this.data.card_field]) { | ||
| 4622 | + price = '¥' + this.data.data[this.data.card_field]; | ||
| 4623 | + } | ||
| 4624 | + | ||
| 5435 | 4625 | ||
| 5436 | - if (this.data.sales_rules != 2) { | ||
| 5437 | - func(); | ||
| 5438 | - } else { | ||
| 5439 | - | ||
| 5440 | - //先读取门店的lock | ||
| 5441 | - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 5442 | - data: { store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000 } | ||
| 5443 | - }).then(res => { | ||
| 5444 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5445 | - for (var i in res.data.data.pageData) | ||
| 5446 | - lock += res.data.data.pageData[i].outQty; | 4626 | + // if (th.data.prom_act) |
| 4627 | + // pri0 = th.data.prom_act.price; | ||
| 4628 | + context.setFontSize(32 * unit); | ||
| 4629 | + context.setFillStyle('#DE1117'); | ||
| 4630 | + context.fillText(price, 54 * unit, 730 * unit); | ||
| 4631 | + // 8.商品标题 | ||
| 4632 | + context.setFontSize(20 * unit); | ||
| 4633 | + context.setFillStyle('#898989'); | ||
| 4634 | + this.draw_Text(context, this.data.data.goods_name, | ||
| 4635 | + 54 * unit, 770 * unit, 240 * unit, 240 * unit, unit); | ||
| 4636 | + // 9.小程序码 | ||
| 4637 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | ||
| 4638 | + context.setFontSize(16 * unit); | ||
| 4639 | + context.setFillStyle('#777'); | ||
| 4640 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | ||
| 4641 | + // 10.竖线 | ||
| 4642 | + context.beginPath(); | ||
| 4643 | + context.setFillStyle('#eee'); | ||
| 4644 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | ||
| 4645 | + context.fill(); | ||
| 4646 | + | ||
| 4647 | + }, | ||
| 4648 | + | ||
| 4649 | + | ||
| 4650 | + //--定义的保存图片方法,分享团--- | ||
| 4651 | + saveImageToPhotosAlbum: function () { | ||
| 4652 | + //--先判断会员状态-- | ||
| 4653 | + var user_info = getApp().globalData.userInfo; | ||
| 4654 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | ||
| 4655 | + //getApp().my_warnning("请先登录",0,this); | ||
| 4656 | + wx.navigateTo({url: '/pages/togoin/togoin',}) | ||
| 4657 | + return false; | ||
| 5447 | } | 4658 | } |
| 5448 | - }) | ||
| 5449 | - //读取线下的门店库存 | ||
| 5450 | - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 5451 | - data: { storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid } | ||
| 5452 | - }).then(res => { | ||
| 5453 | - if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5454 | - plist = res.data.data.pageData[0]; | 4659 | + |
| 4660 | + if (this.data.share_hidden) { | ||
| 4661 | + this.setData({share_hidden: false,}); | ||
| 5455 | } | 4662 | } |
| 5456 | - }) | 4663 | + ; |
| 5457 | 4664 | ||
| 5458 | - if (plist && plist.CanOutQty - lock > 0) { | ||
| 5459 | - item.CanOutQty = plist.CanOutQty - lock; | ||
| 5460 | - func(); | ||
| 5461 | - return false; | ||
| 5462 | - } | ||
| 5463 | - getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | 4665 | + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 |
| 4666 | + var type = this.data.prom_type; | ||
| 4667 | + if (type == 2) type = -1; | ||
| 4668 | + if (type == 6) type = 2; | ||
| 5464 | 4669 | ||
| 5465 | - } | ||
| 5466 | - }, | ||
| 5467 | 4670 | ||
| 4671 | + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | ||
| 5468 | 4672 | ||
| 5469 | - //确定def_pick为选择的门店 | ||
| 5470 | - sure_pick: function (e) { | ||
| 5471 | - var th = this; | ||
| 5472 | - var item = null; | ||
| 5473 | - var openindstore = th.data.open_ind_store; | 4673 | + wx.showLoading({title: '生成中...',}) |
| 4674 | + var that = this, th = that; | ||
| 4675 | + //设置画板显示,才能开始绘图 | ||
| 4676 | + that.setData({ | ||
| 4677 | + canvasHidden: false | ||
| 4678 | + }) | ||
| 5474 | 4679 | ||
| 5475 | - if (th.data.choice_sort_store == 0) { | ||
| 5476 | - var index = th.data.fir_pick_index; | ||
| 5477 | - if (th.data.is_show_sto_cat == 1) { | ||
| 5478 | - item = th.data.def_pickpu_list[index]; | ||
| 5479 | - } else { | ||
| 5480 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5481 | - } | 4680 | + var app = getApp(); |
| 4681 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | ||
| 4682 | + var path2 = that.data.data.original_img; | ||
| 4683 | + var scene = th.data.gid + ""; | ||
| 4684 | + scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id; | ||
| 5482 | 4685 | ||
| 5483 | - } else { | ||
| 5484 | - var index = th.data.sec_pick_index; | ||
| 5485 | - item = th.data.sec_sto.s_arr[index]; | ||
| 5486 | - } | 4686 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; |
| 4687 | + if (user_id > 0) { | ||
| 4688 | + scene += "_" + user_id; | ||
| 4689 | + } | ||
| 4690 | + //-- 如果不是会员分享过来的要分享给别人 -- | ||
| 4691 | + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | ||
| 4692 | + //固定房间是第3个字符 | ||
| 4693 | + if (!user_id) scene += "_0"; | ||
| 4694 | + scene += "_" + getApp().globalData.room_id; | ||
| 4695 | + } | ||
| 4696 | + ///二微码 | ||
| 4697 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | ||
| 4698 | + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | ||
| 5487 | 4699 | ||
| 5488 | - if (!th.data.sele_g) return false; | ||
| 5489 | - //判断门店的配送方式是不是匹配 | ||
| 5490 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 5491 | - if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5492 | - wx.showToast({ | ||
| 5493 | - title: "门店配送方式不匹配", | ||
| 5494 | - icon: 'none', | ||
| 5495 | - duration: 2000 | ||
| 5496 | - }); | ||
| 5497 | - return false; | ||
| 5498 | - } | 4700 | + console.log(path3); |
| 5499 | 4701 | ||
| 5500 | - //--回调函数的用法-- | ||
| 5501 | - th.check_the_pick(item, function () { | ||
| 5502 | - th.setData({ | ||
| 5503 | - def_pick_store: item, | ||
| 5504 | - sto_sele_name: item.pickup_name, | ||
| 5505 | - sto_sele_id: item.pickup_id, | ||
| 5506 | - sto_sele_distr: item.distr_type, | ||
| 5507 | - store: 0, | ||
| 5508 | - choice_sort_store: 0, | ||
| 5509 | - fir_pick_index: 0 | ||
| 5510 | - }); | ||
| 5511 | - | ||
| 5512 | - if (openindstore == 1) { | ||
| 5513 | - th.setData({ | ||
| 5514 | - openSpecModal: !0, | ||
| 5515 | - openSpecModal_ind: openindstore, | ||
| 5516 | - }); | ||
| 5517 | - } else if (openindstore == 2) { | ||
| 5518 | - th.setData({ | ||
| 5519 | - openSpecModal: !0, | ||
| 5520 | - openSpecModal_ind: openindstore, | 4702 | + |
| 4703 | + // 读取文件成功则OK-- | ||
| 4704 | + wx.getImageInfo({ | ||
| 4705 | + src: path3, | ||
| 4706 | + success: function (res) { | ||
| 4707 | + // 回调写法 | ||
| 4708 | + th.get_head_temp(th.get_goods_temp, function () { | ||
| 4709 | + var vpath = res.path; | ||
| 4710 | + var context = wx.createCanvasContext('share'); | ||
| 4711 | + // 先画背景 | ||
| 4712 | + var pg_path = "../../../images/share/share_bg.png"; | ||
| 4713 | + | ||
| 4714 | + | ||
| 4715 | + //-- 如果有自定义海报的时候,判断背景的图片 -- | ||
| 4716 | + if (th.data.share_b_img) { | ||
| 4717 | + pg_path = th.data.share_b_img; | ||
| 4718 | + } | ||
| 4719 | + // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4720 | + | ||
| 4721 | + | ||
| 4722 | + if (type == 0) { // 如果是普通商品,绘制新海报 | ||
| 4723 | + th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 4724 | + } else { | ||
| 4725 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | ||
| 4726 | + } | ||
| 4727 | + ; | ||
| 4728 | + | ||
| 4729 | + // th.drawPoster(context, unit, th.data.share_goods_img, vpath); | ||
| 4730 | + | ||
| 4731 | + | ||
| 4732 | + //-- 是自定义海报的情况下 -- | ||
| 4733 | + if (type != 0) { | ||
| 4734 | + | ||
| 4735 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4736 | + //在线上分享人的情况下 | ||
| 4737 | + if (parseInt(th.data.poster.show_headpic)) { | ||
| 4738 | + //获取坐标 | ||
| 4739 | + var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 4740 | + var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 4741 | + var x1 = (x + 90) * unit; | ||
| 4742 | + var y1 = (y + 50) * unit; | ||
| 4743 | + //--昵称--- | ||
| 4744 | + context.setFontSize(24 * unit) | ||
| 4745 | + context.setFillStyle("black") | ||
| 4746 | + context.fillText(app.globalData.userInfo.nickname, x1, y1); | ||
| 4747 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | ||
| 4748 | + //强烈推荐 改许程 | ||
| 4749 | + var tj_path = "../../../images/share/q_tj.png"; | ||
| 4750 | + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | ||
| 4751 | + context.setFontSize(16 * unit); | ||
| 4752 | + context.setLineJoin('round'); //交点设置成圆角 | ||
| 4753 | + context.setFillStyle("white"); | ||
| 4754 | + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | ||
| 4755 | + | ||
| 4756 | + //context.setFillStyle("black") | ||
| 4757 | + //context.setFontSize(24 * unit) | ||
| 4758 | + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | ||
| 4759 | + } | ||
| 4760 | + } else { | ||
| 4761 | + //--昵称--- | ||
| 4762 | + context.setFontSize(24 * unit); | ||
| 4763 | + context.setFillStyle("black"); | ||
| 4764 | + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | ||
| 4765 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | ||
| 4766 | + //强烈推荐 改许程 | ||
| 4767 | + var tj_path = "../../../images/share/q_tj.png"; | ||
| 4768 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | ||
| 4769 | + context.setFontSize(16 * unit); | ||
| 4770 | + context.setLineJoin('round'); //交点设置成圆角 | ||
| 4771 | + context.setFillStyle("white"); | ||
| 4772 | + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | ||
| 4773 | + } | ||
| 4774 | + | ||
| 4775 | + } | ||
| 4776 | + ; | ||
| 4777 | + | ||
| 4778 | + | ||
| 4779 | + var share_title = th.data.data.goods_name; | ||
| 4780 | + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { | ||
| 4781 | + share_title = th.data.prom_act.share_title; | ||
| 4782 | + if (!share_title) share_title = th.data.prom_act.title; | ||
| 4783 | + if (th.data.prom_type == 4) share_title = th.data.prom_act.name; | ||
| 4784 | + } | ||
| 4785 | + | ||
| 4786 | + //---产品名称--- | ||
| 4787 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 4788 | + if (type != 4 && type != 0) { | ||
| 4789 | + context.setFillStyle("black"); | ||
| 4790 | + context.setFontSize(21.3 * unit) | ||
| 4791 | + th.draw_Text(context, share_title, | ||
| 4792 | + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | ||
| 4793 | + | ||
| 4794 | + //------产品的价格------- | ||
| 4795 | + context.setFontSize(23 * unit) | ||
| 4796 | + context.setFillStyle("red") | ||
| 4797 | + | ||
| 4798 | + var pri0 = th.data.data.shop_price; | ||
| 4799 | + if (th.data.card_field && th.data.data[th.data.card_field]) { | ||
| 4800 | + pri0 = th.data.data[th.data.card_field]; | ||
| 4801 | + } | ||
| 4802 | + | ||
| 4803 | + if (th.data.prom_act) | ||
| 4804 | + pri0 = th.data.prom_price; | ||
| 4805 | + pri0 = parseFloat(pri0).toFixed(2); | ||
| 4806 | + var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25; | ||
| 4807 | + context.fillText("¥", wd1 - 15, 185 * unit); | ||
| 4808 | + context.setFontSize(31 * unit) | ||
| 4809 | + context.fillText(pri0, wd1, 185 * unit); | ||
| 4810 | + | ||
| 4811 | + //---市场价划掉--- | ||
| 4812 | + context.setFillStyle("gray") | ||
| 4813 | + context.setFontSize(22 * unit) | ||
| 4814 | + pri0 = "¥" + th.data.data.market_price.toFixed(2); | ||
| 4815 | + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25; | ||
| 4816 | + context.fillText(pri0, wd2, 213 * unit); | ||
| 4817 | + | ||
| 4818 | + context.setStrokeStyle('gray'); | ||
| 4819 | + context.setLineWidth(1 * unit); | ||
| 4820 | + context.moveTo(wd2 - 5, 206 * unit); | ||
| 4821 | + context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit); | ||
| 4822 | + context.stroke(); | ||
| 4823 | + | ||
| 4824 | + } else if (type == 4 && type != 0) { | ||
| 4825 | + context.setFillStyle("black"); | ||
| 4826 | + context.setFontSize(21.3 * unit) | ||
| 4827 | + th.draw_Text(context, share_title, | ||
| 4828 | + 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit); | ||
| 4829 | + //------ 产品的价格 ----- | ||
| 4830 | + var pri0 = th.data.prom_act.addmoney; | ||
| 4831 | + var integral = th.data.prom_act.integral; | ||
| 4832 | + var text = ""; | ||
| 4833 | + if (integral) { | ||
| 4834 | + text = integral + "积分"; | ||
| 4835 | + } | ||
| 4836 | + if (pri0 && integral) { | ||
| 4837 | + text += "+"; | ||
| 4838 | + } | ||
| 4839 | + if (pri0) { | ||
| 4840 | + text += "¥" + pri0; | ||
| 4841 | + } | ||
| 4842 | + | ||
| 4843 | + if (!pri0 && !integral) { | ||
| 4844 | + text = "0积分"; | ||
| 4845 | + } | ||
| 4846 | + context.setFillStyle("red"); | ||
| 4847 | + context.fillText(text, 38 * unit, 235 * unit); | ||
| 4848 | + | ||
| 4849 | + } | ||
| 4850 | + | ||
| 4851 | + //---中间大图--- | ||
| 4852 | + if (type != 0) { | ||
| 4853 | + context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | ||
| 4854 | + } | ||
| 4855 | + ; | ||
| 4856 | + | ||
| 4857 | + | ||
| 4858 | + //-------大图后面就不一样了----------- | ||
| 4859 | + switch (type) { | ||
| 4860 | + case 0: | ||
| 4861 | + break;//普通商品的展示 | ||
| 4862 | + case 4: | ||
| 4863 | + //中间的几个字 | ||
| 4864 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 4865 | + if (parseInt(th.data.poster.show_quality)) { | ||
| 4866 | + var g_path = "../../../images/share/s_gou.png"; | ||
| 4867 | + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4868 | + context.setFillStyle("red") | ||
| 4869 | + context.setFontSize(18 * unit) | ||
| 4870 | + context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 4871 | + | ||
| 4872 | + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4873 | + context.setFillStyle("red") | ||
| 4874 | + context.setFontSize(18 * unit) | ||
| 4875 | + context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 4876 | + | ||
| 4877 | + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4878 | + context.setFillStyle("red") | ||
| 4879 | + context.setFontSize(18 * unit) | ||
| 4880 | + context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 4881 | + } | ||
| 4882 | + | ||
| 4883 | + } else { | ||
| 4884 | + var g_path = "../../../images/share/s_gou.png"; | ||
| 4885 | + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4886 | + context.setFillStyle("red") | ||
| 4887 | + context.setFontSize(18 * unit) | ||
| 4888 | + context.fillText("正品保证", 84 * unit, 690 * unit); | ||
| 4889 | + | ||
| 4890 | + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4891 | + context.setFillStyle("red") | ||
| 4892 | + context.setFontSize(18 * unit) | ||
| 4893 | + context.fillText("纯实体店", 246 * unit, 690 * unit); | ||
| 4894 | + | ||
| 4895 | + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | ||
| 4896 | + context.setFillStyle("red") | ||
| 4897 | + context.setFontSize(18 * unit) | ||
| 4898 | + context.fillText("官方验证", 420 * unit, 690 * unit); | ||
| 4899 | + } | ||
| 4900 | + | ||
| 4901 | + | ||
| 4902 | + //---画线--- | ||
| 4903 | + context.setLineWidth(1 * unit) | ||
| 4904 | + context.moveTo(32 * unit, 710 * unit) | ||
| 4905 | + context.lineTo(520 * unit, 710 * unit) | ||
| 4906 | + context.stroke(); | ||
| 4907 | + | ||
| 4908 | + //---文字--- | ||
| 4909 | + context.setFillStyle("black") | ||
| 4910 | + context.setFontSize(22 * unit) | ||
| 4911 | + | ||
| 4912 | + if (type == 0 || type == -1) { | ||
| 4913 | + // 原来start ---> | ||
| 4914 | + context.setFontSize(24 * unit) | ||
| 4915 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 4916 | + | ||
| 4917 | + context.setFontSize(22 * unit) | ||
| 4918 | + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | ||
| 4919 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | ||
| 4920 | + | ||
| 4921 | + } else { | ||
| 4922 | + context.setFontSize(24 * unit) | ||
| 4923 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | ||
| 4924 | + context.setFontSize(22 * unit) | ||
| 4925 | + context.fillText("长按识别二维码", 40 * unit, 806 * unit); | ||
| 4926 | + context.fillText("立即开始兑换", 40 * unit, 846 * unit); | ||
| 4927 | + | ||
| 4928 | + } | ||
| 4929 | + | ||
| 4930 | + //---二维吗图--- | ||
| 4931 | + //-- 自定义海报 -- | ||
| 4932 | + if (th.data.poster) { | ||
| 4933 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4934 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4935 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 4936 | + } else { | ||
| 4937 | + //---二维吗图--- | ||
| 4938 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 4939 | + } | ||
| 4940 | + ; | ||
| 4941 | + | ||
| 4942 | + break; | ||
| 4943 | + case 1: //秒杀商品的展示 | ||
| 4944 | + //---画线--- | ||
| 4945 | + context.setLineWidth(1 * unit) | ||
| 4946 | + context.moveTo(32 * unit, 670 * unit) | ||
| 4947 | + context.lineTo(520 * unit, 670 * unit) | ||
| 4948 | + context.stroke(); | ||
| 4949 | + | ||
| 4950 | + //画秒杀的图片 | ||
| 4951 | + var miaos_path = '../../../images/share/miao_share.png'; | ||
| 4952 | + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | ||
| 4953 | + | ||
| 4954 | + context.setFillStyle("black") | ||
| 4955 | + context.setFontSize(24 * unit) | ||
| 4956 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | ||
| 4957 | + //---文字--- | ||
| 4958 | + context.setFontSize(22 * unit) | ||
| 4959 | + context.setFillStyle("black") | ||
| 4960 | + context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | ||
| 4961 | + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | ||
| 4962 | + | ||
| 4963 | + | ||
| 4964 | + //---二维吗图--- | ||
| 4965 | + //-- 自定义海报 -- | ||
| 4966 | + if (th.data.poster) { | ||
| 4967 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 4968 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 4969 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 4970 | + } else { | ||
| 4971 | + //---二维吗图--- | ||
| 4972 | + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 4973 | + } | ||
| 4974 | + break; | ||
| 4975 | + | ||
| 4976 | + case 2: //会员团和商家团的展示 | ||
| 4977 | + //---画线--- | ||
| 4978 | + context.setLineWidth(1 * unit) | ||
| 4979 | + context.moveTo(32 * unit, 670 * unit) | ||
| 4980 | + context.lineTo(520 * unit, 670 * unit) | ||
| 4981 | + context.stroke(); | ||
| 4982 | + //---文字--- | ||
| 4983 | + context.setFillStyle("black") | ||
| 4984 | + context.setFontSize(24 * unit) | ||
| 4985 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 4986 | + | ||
| 4987 | + //绘制成团图片 | ||
| 4988 | + var ct_img = "../../../images/share/ct_num.png"; | ||
| 4989 | + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | ||
| 4990 | + var ct_num = th.data.prom_act.ct_num; | ||
| 4991 | + context.setFontSize(14 * unit) | ||
| 4992 | + context.font = 'normal'; | ||
| 4993 | + context.setFillStyle("red") | ||
| 4994 | + if (ct_num < 10) { | ||
| 4995 | + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | ||
| 4996 | + } else { | ||
| 4997 | + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | ||
| 4998 | + } | ||
| 4999 | + context.setFontSize(22 * unit) | ||
| 5000 | + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | ||
| 5001 | + | ||
| 5002 | + context.setFillStyle("gray") | ||
| 5003 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | ||
| 5004 | + context.setFillStyle("black") | ||
| 5005 | + context.font = 'normal bold 18px sans-serif'; | ||
| 5006 | + context.setFontSize(21.3 * unit) | ||
| 5007 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | ||
| 5008 | + | ||
| 5009 | + | ||
| 5010 | + //---二维吗图--- | ||
| 5011 | + //-- 自定义海报 -- | ||
| 5012 | + if (th.data.poster) { | ||
| 5013 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5014 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5015 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5016 | + } else { | ||
| 5017 | + //---二维吗图--- | ||
| 5018 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5019 | + } | ||
| 5020 | + break | ||
| 5021 | + case 3: //阶梯团的展示 | ||
| 5022 | + //---画线--- | ||
| 5023 | + context.setLineWidth(1 * unit) | ||
| 5024 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5025 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5026 | + context.stroke(); | ||
| 5027 | + //---文字--- | ||
| 5028 | + context.setFillStyle("black") | ||
| 5029 | + context.setFontSize(24 * unit) | ||
| 5030 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | ||
| 5031 | + | ||
| 5032 | + //---绘制中间阶梯的价格--- | ||
| 5033 | + var list = th.data.prom_act.ct_rylist; | ||
| 5034 | + for (var i = 0; i < list.length; i++) { | ||
| 5035 | + var item = list[i]; | ||
| 5036 | + var wi = i * 90 * unit; | ||
| 5037 | + context.font = 'normal'; | ||
| 5038 | + context.setFontSize(16 * unit) | ||
| 5039 | + context.setFillStyle("red") | ||
| 5040 | + context.fillText("¥", 40 * unit + wi, 756 * unit); | ||
| 5041 | + context.setFontSize(22 * unit) | ||
| 5042 | + var pri = parseFloat(item.price).toFixed(2); | ||
| 5043 | + context.fillText(pri, 56 * unit + wi, 756 * unit); | ||
| 5044 | + context.setFillStyle("gray") | ||
| 5045 | + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | ||
| 5046 | + } | ||
| 5047 | + //----------------下面部分---------------- | ||
| 5048 | + // context.setFillStyle("gray") | ||
| 5049 | + // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | ||
| 5050 | + // context.setFillStyle("black") | ||
| 5051 | + // context.font = 'normal bold 18px sans-serif'; | ||
| 5052 | + // context.setFontSize(22 * unit) | ||
| 5053 | + // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | ||
| 5054 | + //context.setFillStyle("gray") | ||
| 5055 | + context.setFillStyle("black") | ||
| 5056 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | ||
| 5057 | + //context.font = 'normal bold 18px sans-serif'; | ||
| 5058 | + context.setFontSize(21 * unit) | ||
| 5059 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | ||
| 5060 | + | ||
| 5061 | + | ||
| 5062 | + //-- 自定义海报 -- | ||
| 5063 | + if (th.data.poster) { | ||
| 5064 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5065 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5066 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit); | ||
| 5067 | + } else { | ||
| 5068 | + //---二维吗图--- | ||
| 5069 | + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); | ||
| 5070 | + } | ||
| 5071 | + break | ||
| 5072 | + | ||
| 5073 | + | ||
| 5074 | + case -1: //秒杀商品的展示 | ||
| 5075 | + //---画线--- | ||
| 5076 | + context.setLineWidth(1 * unit) | ||
| 5077 | + context.moveTo(32 * unit, 670 * unit) | ||
| 5078 | + context.lineTo(520 * unit, 670 * unit) | ||
| 5079 | + context.stroke(); | ||
| 5080 | + | ||
| 5081 | + | ||
| 5082 | + context.setFillStyle("black") | ||
| 5083 | + context.setFontSize(24 * unit) | ||
| 5084 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); | ||
| 5085 | + //---文字--- | ||
| 5086 | + context.setFontSize(22 * unit) | ||
| 5087 | + context.setFillStyle("black") | ||
| 5088 | + context.fillText("长按识别二维码", 40 * unit, 800 * unit); | ||
| 5089 | + context.fillText("立即开始抢购", 40 * unit, 846 * unit); | ||
| 5090 | + | ||
| 5091 | + | ||
| 5092 | + //---二维吗图--- | ||
| 5093 | + //-- 自定义海报 -- | ||
| 5094 | + if (th.data.poster) { | ||
| 5095 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | ||
| 5096 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | ||
| 5097 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); | ||
| 5098 | + } else { | ||
| 5099 | + //---二维吗图--- | ||
| 5100 | + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); | ||
| 5101 | + } | ||
| 5102 | + break; | ||
| 5103 | + | ||
| 5104 | + | ||
| 5105 | + } | ||
| 5106 | + | ||
| 5107 | + | ||
| 5108 | + //--- 如果是自定义海报的时候 --- | ||
| 5109 | + if (type != 0) { | ||
| 5110 | + | ||
| 5111 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | ||
| 5112 | + | ||
| 5113 | + //如果显示会员信息的话 | ||
| 5114 | + if (parseInt(th.data.poster.show_headpic)) { | ||
| 5115 | + //获取坐标 | ||
| 5116 | + var x = parseFloat(th.data.poster.head_x) * 2; | ||
| 5117 | + var y = parseFloat(th.data.poster.head_y) * 2; | ||
| 5118 | + //---绘制圆形要放在最后---- | ||
| 5119 | + context.save(); | ||
| 5120 | + context.beginPath(); | ||
| 5121 | + var h_x = x * unit; | ||
| 5122 | + var h_y = y * unit; | ||
| 5123 | + var h_r = 40 * unit; | ||
| 5124 | + var cx = h_x + h_r; | ||
| 5125 | + var cy = h_y + h_r; | ||
| 5126 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5127 | + context.closePath(); | ||
| 5128 | + context.fill(); | ||
| 5129 | + context.clip(); | ||
| 5130 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5131 | + context.restore(); | ||
| 5132 | + } | ||
| 5133 | + | ||
| 5134 | + } else { | ||
| 5135 | + //---绘制圆形要放在最后---- | ||
| 5136 | + context.save(); | ||
| 5137 | + context.beginPath(); | ||
| 5138 | + var h_x = 60 * unit; | ||
| 5139 | + var h_y = 24 * unit; | ||
| 5140 | + var h_r = 40 * unit; | ||
| 5141 | + var cx = h_x + h_r; | ||
| 5142 | + var cy = h_y + h_r; | ||
| 5143 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | ||
| 5144 | + context.closePath(); | ||
| 5145 | + context.fill(); | ||
| 5146 | + context.clip(); | ||
| 5147 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | ||
| 5148 | + context.restore(); | ||
| 5149 | + } | ||
| 5150 | + | ||
| 5151 | + } | ||
| 5152 | + ; | ||
| 5153 | + | ||
| 5154 | + | ||
| 5155 | + //把画板内容绘制成图片,并回调 画板图片路径 | ||
| 5156 | + context.draw(false, function () { | ||
| 5157 | + setTimeout(function () { | ||
| 5158 | + wx.canvasToTempFilePath({ | ||
| 5159 | + x: 0, | ||
| 5160 | + y: 0, | ||
| 5161 | + width: 750, | ||
| 5162 | + height: 1217, | ||
| 5163 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | ||
| 5164 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | ||
| 5165 | + canvasId: 'share', | ||
| 5166 | + success: function (res) { | ||
| 5167 | + | ||
| 5168 | + that.setData({ | ||
| 5169 | + shareImgPath: res.tempFilePath, | ||
| 5170 | + canvasHidden: true | ||
| 5171 | + }) | ||
| 5172 | + | ||
| 5173 | + if (!res.tempFilePath) { | ||
| 5174 | + wx.showModal({ | ||
| 5175 | + title: '提示', | ||
| 5176 | + content: '图片绘制中,请稍后重试', | ||
| 5177 | + showCancel: false | ||
| 5178 | + }) | ||
| 5179 | + return false; | ||
| 5180 | + } | ||
| 5181 | + | ||
| 5182 | + // wx.previewImage({ | ||
| 5183 | + // //将图片预览出来 | ||
| 5184 | + // urls: [that.data.shareImgPath] | ||
| 5185 | + // }); | ||
| 5186 | + that.setData({ | ||
| 5187 | + showPoster: true, | ||
| 5188 | + }); | ||
| 5189 | + wx.hideLoading(); | ||
| 5190 | + } | ||
| 5191 | + }) | ||
| 5192 | + }, 500) | ||
| 5193 | + | ||
| 5194 | + }); | ||
| 5195 | + }); | ||
| 5196 | + }, | ||
| 5197 | + fail: function (res) { | ||
| 5198 | + console.log(res); | ||
| 5199 | + wx.hideLoading(); | ||
| 5200 | + | ||
| 5201 | + } | ||
| 5521 | }); | 5202 | }); |
| 5522 | - } | ||
| 5523 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5524 | - th.setData({ | ||
| 5525 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5526 | - store: 0, //关闭门店 | ||
| 5527 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5528 | - sort_store: 0, //关闭门店2级 | 5203 | + }, |
| 5204 | + | ||
| 5205 | + | ||
| 5206 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | ||
| 5207 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | ||
| 5208 | + var lineWidth = 0; | ||
| 5209 | + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | ||
| 5210 | + var han = 0; | ||
| 5211 | + for (let i = 0; i < str.length; i++) { | ||
| 5212 | + if (han == 2) return; | ||
| 5213 | + //lineWidth += ctx.measureText(str[i]).width; | ||
| 5214 | + lineWidth += ut.measureText(str[i], 21.3 * unit); | ||
| 5215 | + if (lineWidth > canvasWidth) { | ||
| 5216 | + han++; | ||
| 5217 | + | ||
| 5218 | + if (han == 2) | ||
| 5219 | + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | ||
| 5220 | + else | ||
| 5221 | + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | ||
| 5222 | + | ||
| 5223 | + initHeight += 22; //22为字体的高度 | ||
| 5224 | + lineWidth = 0; | ||
| 5225 | + lastSubStrIndex = i; | ||
| 5226 | + titleHeight += 20; | ||
| 5227 | + } | ||
| 5228 | + if (i == str.length - 1) { //绘制剩余部分 | ||
| 5229 | + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | ||
| 5230 | + } | ||
| 5231 | + } | ||
| 5232 | + }, | ||
| 5233 | + | ||
| 5234 | + // ----视频图片---- | ||
| 5235 | + // 图片计数器 | ||
| 5236 | + swiperChange: function (e) { | ||
| 5237 | + var that = this; | ||
| 5238 | + if (e.detail.current > 0) { | ||
| 5239 | + that.setData({ | ||
| 5240 | + hiddenn: 1, | ||
| 5241 | + videopicture: 1, | ||
| 5242 | + }) | ||
| 5243 | + } else { | ||
| 5244 | + that.setData({ | ||
| 5245 | + hiddenn: 0, | ||
| 5246 | + videopicture: 0, | ||
| 5247 | + }) | ||
| 5248 | + } | ||
| 5249 | + if (e.detail.source == 'touch') { | ||
| 5250 | + that.setData({ | ||
| 5251 | + current: e.detail.current | ||
| 5252 | + }) | ||
| 5253 | + } | ||
| 5254 | + }, | ||
| 5255 | + | ||
| 5256 | + /*---视频相关--*/ | ||
| 5257 | + videopicture: function (e) { | ||
| 5258 | + var vipi = e.currentTarget.dataset.vipi; | ||
| 5259 | + this.setData({ | ||
| 5260 | + videopicture: vipi, | ||
| 5261 | + swiperCurrent: vipi, | ||
| 5262 | + noon: 0, | ||
| 5263 | + current: 1 | ||
| 5529 | }); | 5264 | }); |
| 5530 | - } | ||
| 5531 | - else { | ||
| 5532 | - th.setData({ | ||
| 5533 | - store: 0, | ||
| 5534 | - choice_sort_store: 0, | ||
| 5535 | - sort_store: 0 | 5265 | + }, |
| 5266 | + | ||
| 5267 | + videoPlay: function (e) { | ||
| 5268 | + var _index = e.currentTarget.id | ||
| 5269 | + this.setData({ | ||
| 5270 | + _index: _index, | ||
| 5271 | + noon: 1 | ||
| 5536 | }) | 5272 | }) |
| 5537 | - } | ||
| 5538 | - //如果商品没有其他活动,要取一下线下价格 | ||
| 5539 | - th.get_off_price(); | ||
| 5540 | - }) | ||
| 5541 | - }, | ||
| 5542 | - //---点击二级之后的选择--- | ||
| 5543 | - choose_for_store: function (e) { | ||
| 5544 | - var index_c = e.currentTarget.dataset.ind; | ||
| 5545 | - var th = this; | ||
| 5546 | - th.setData({ | ||
| 5547 | - sec_pick_index: index_c, | ||
| 5548 | - fir_pick_index: index_c | ||
| 5549 | - }) | ||
| 5550 | 5273 | ||
| 5551 | - }, | ||
| 5552 | - //把选择的门店设置成默认的门店def_pick | ||
| 5553 | - set_def_pick: function (e) { | ||
| 5554 | - var th = this; | ||
| 5555 | - var item = null; | ||
| 5556 | - if (th.data.choice_sort_store == 0) { | ||
| 5557 | - var index = th.data.fir_pick_index; | ||
| 5558 | - if (th.data.is_show_sto_cat == 1) { | ||
| 5559 | - item = th.data.def_pickpu_list[index]; | ||
| 5560 | - } else { | ||
| 5561 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5562 | - } | ||
| 5563 | - } else { | ||
| 5564 | - var index = th.data.sec_pick_index; | ||
| 5565 | - item = th.data.sec_sto.s_arr[index]; | ||
| 5566 | - } | 5274 | + setTimeout(function () { |
| 5275 | + //将点击视频进行播放 | ||
| 5276 | + var videoContext = wx.createVideoContext(_index) | ||
| 5277 | + videoContext.play(); | ||
| 5278 | + }, 500) | ||
| 5279 | + | ||
| 5280 | + }, | ||
| 5567 | 5281 | ||
| 5568 | - //判断门店的配送方式是不是匹配 | ||
| 5569 | - var g_distr_type = th.data.sele_g.distr_type; | ||
| 5570 | - if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5571 | - wx.showToast({ | ||
| 5572 | - title: "门店配送方式不匹配", | ||
| 5573 | - icon: 'none', | ||
| 5574 | - duration: 2000 | ||
| 5575 | - }); | ||
| 5576 | - return false; | 5282 | + //加载更多是靠这个函数 |
| 5283 | + onReachBottom: function () { | ||
| 5284 | + if (this.data.activeCategoryId == 2) { | ||
| 5285 | + if (!this.data.comments_no_more) this.requestComments_new(); | ||
| 5577 | } | 5286 | } |
| 5578 | 5287 | ||
| 5579 | - //先设置之前,要判断是不是有库存 | ||
| 5580 | - th.check_the_pick(item, function () { | ||
| 5581 | - var store_id = o.stoid; | ||
| 5582 | - var user_id = getApp().globalData.user_id; | ||
| 5583 | - var def_pickup_id = item.pickup_id; | 5288 | + var goods_list = this.selectComponent("#goods_list"); //组件的id |
| 5289 | + if (goods_list) goods_list.get_list(); | ||
| 5290 | + }, | ||
| 5584 | 5291 | ||
| 5585 | - getApp().request.put('/api/weshop/users/update', { | ||
| 5586 | - data: { | ||
| 5587 | - user_id: user_id, | ||
| 5588 | - def_pickup_id: def_pickup_id | ||
| 5589 | - }, | ||
| 5590 | - success: function (res) { | ||
| 5591 | - if (res.data.code == 0) { | ||
| 5592 | - if (th.data.choice_sort_store == 0) th.setData({ | ||
| 5593 | - fir_pick_index: 0 | 5292 | + //--获取头像的本地缓存,回调写法-- |
| 5293 | + get_head_temp: function (tt, func) { | ||
| 5294 | + var ee = this; | ||
| 5295 | + if (ee.data.share_head) { | ||
| 5296 | + tt(func); | ||
| 5297 | + return false; | ||
| 5298 | + } | ||
| 5299 | + //---获取分享图片的本地地址,头像和商品图片---- | ||
| 5300 | + var path2 = getApp().globalData.userInfo.head_pic; | ||
| 5301 | + if (path2 == "") { | ||
| 5302 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | ||
| 5303 | + tt(func); | ||
| 5304 | + } else { | ||
| 5305 | + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5306 | + path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | ||
| 5307 | + wx.getImageInfo({ | ||
| 5308 | + src: path2, | ||
| 5309 | + success: function (res) { | ||
| 5310 | + //res.path是网络图片的本地地址 | ||
| 5311 | + ee.data.share_head = res.path; | ||
| 5312 | + tt(func); | ||
| 5313 | + }, | ||
| 5314 | + fail: function (res) { | ||
| 5315 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | ||
| 5316 | + tt(func); | ||
| 5317 | + } | ||
| 5594 | }); | 5318 | }); |
| 5595 | - getApp().globalData.pk_store = item; | ||
| 5596 | - } else { | ||
| 5597 | - //s.showWarning("设置默认门店地址失败", null, 500, !1); | ||
| 5598 | - getApp().my_warnning("设置默认门店地址失败", 0, th) | ||
| 5599 | - } | 5319 | + } |
| 5320 | + }, | ||
| 5321 | + //--获取商品图片的本地缓存,回调写法-- | ||
| 5322 | + get_goods_temp: function (tt) { | ||
| 5323 | + var ee = this; | ||
| 5324 | + if (ee.data.share_goods_img) { | ||
| 5325 | + tt(); | ||
| 5326 | + return false; | ||
| 5327 | + } | ||
| 5600 | 5328 | ||
| 5329 | + var img_url = ee.data.data.original_img; | ||
| 5330 | + if ((this.data.prom_type == 1 || this.data.prom_type == 6) && this.data.prom_act.share_imgurl) { | ||
| 5331 | + img_url = this.data.iurl + this.data.prom_act.share_imgurl; | ||
| 5601 | } | 5332 | } |
| 5602 | - }); | ||
| 5603 | - | ||
| 5604 | - th.setData({ | ||
| 5605 | - def_pick_store: item, | ||
| 5606 | - sto_sele_name: item.pickup_name, | ||
| 5607 | - sto_sele_id: item.pickup_id, | ||
| 5608 | - sto_sele_distr: item.distr_type, | ||
| 5609 | - store: 0, | ||
| 5610 | - choice_sort_store: 0 | ||
| 5611 | - }); | ||
| 5612 | - | ||
| 5613 | - var openindstore = th.data.open_ind_store; | ||
| 5614 | - if (openindstore == 1) { | ||
| 5615 | - th.setData({ | ||
| 5616 | - openSpecModal: !0, | ||
| 5617 | - openSpecModal_ind: openindstore, | ||
| 5618 | - store: 0, | ||
| 5619 | - choice_sort_store: 0, | ||
| 5620 | - sort_store: 0, | 5333 | + |
| 5334 | + //获取商品是分享图信息 | ||
| 5335 | + wx.getImageInfo({ | ||
| 5336 | + src: img_url, | ||
| 5337 | + success: function (res) { | ||
| 5338 | + //res.path是网络图片的本地地址 | ||
| 5339 | + ee.data.share_goods_img = res.path; | ||
| 5340 | + tt(); | ||
| 5341 | + }, | ||
| 5342 | + fail: function (res) { | ||
| 5343 | + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | ||
| 5344 | + tt(); | ||
| 5345 | + } | ||
| 5621 | }); | 5346 | }); |
| 5622 | - } else if (openindstore == 2) { | ||
| 5623 | - th.setData({ | ||
| 5624 | - openSpecModal: !0, | ||
| 5625 | - openSpecModal_ind: openindstore, | ||
| 5626 | - store: 0, | ||
| 5627 | - choice_sort_store: 0, | ||
| 5628 | - sort_store: 0, | 5347 | + }, |
| 5348 | + | ||
| 5349 | + //--外侧评价的点击效果--- | ||
| 5350 | + clik_evaluate: function (e) { | ||
| 5351 | + var val = e.currentTarget.dataset.val; | ||
| 5352 | + this.setData({ | ||
| 5353 | + activeCategoryId: 2, | ||
| 5354 | + activeCategoryId3: val, | ||
| 5355 | + comments: null | ||
| 5629 | }); | 5356 | }); |
| 5630 | - } | ||
| 5631 | - else if (openindstore == 4) { //4就是拼团 | ||
| 5632 | - th.setData({ | ||
| 5633 | - openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5634 | - store: 0, //关闭门店 | ||
| 5635 | - choice_sort_store: 0, //关闭门店2级 | ||
| 5636 | - sort_store: 0, //关闭门店2级 | 5357 | + this.requestComments_new(); |
| 5358 | + }, | ||
| 5359 | + | ||
| 5360 | + //--跳转到商品详情页面-- | ||
| 5361 | + go_goods: function (e) { | ||
| 5362 | + var gid = e.currentTarget.dataset.gid; | ||
| 5363 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | ||
| 5364 | + getApp().goto(url); | ||
| 5365 | + }, | ||
| 5366 | + | ||
| 5367 | + //--跳转到支付尾款界面-- | ||
| 5368 | + go_pay_wk: function () { | ||
| 5369 | + var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id; | ||
| 5370 | + getApp().goto(url); | ||
| 5371 | + }, | ||
| 5372 | + | ||
| 5373 | + pop_err_img: function (e) { | ||
| 5374 | + var txt = e.currentTarget.dataset.errorimg; | ||
| 5375 | + var ob = {}; | ||
| 5376 | + ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | ||
| 5377 | + this.setData(ob); | ||
| 5378 | + }, | ||
| 5379 | + | ||
| 5380 | + //--调用更新阶梯团的接口-- | ||
| 5381 | + update_jiti: function (id) { | ||
| 5382 | + var th = this; | ||
| 5383 | + //--更新阶梯团-- | ||
| 5384 | + getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { | ||
| 5385 | + success: function (ee) { | ||
| 5386 | + //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- | ||
| 5387 | + if (ee.data.code == 0) { | ||
| 5388 | + th.setData({ | ||
| 5389 | + user_order_pt_state: 3, | ||
| 5390 | + }); | ||
| 5391 | + } else if (ee.data.code == -1) { | ||
| 5392 | + th.setData({ | ||
| 5393 | + user_order_pt_state: 2, | ||
| 5394 | + }); | ||
| 5395 | + } | ||
| 5396 | + } | ||
| 5397 | + }) | ||
| 5398 | + }, | ||
| 5399 | + // 选择门店 | ||
| 5400 | + choice_store: function (ee) { | ||
| 5401 | + var th = this; | ||
| 5402 | + var ind = ee.currentTarget.dataset.ind; | ||
| 5403 | + var bconfig = th.data.bconfig; | ||
| 5404 | + | ||
| 5405 | + if (!th.data.only_pk && !th.data.def_pickpu_list) { | ||
| 5406 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5407 | + return false; | ||
| 5408 | + } | ||
| 5409 | + | ||
| 5410 | + if (th.data.only_pk && !th.data.only_pk.length) { | ||
| 5411 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5412 | + return false; | ||
| 5413 | + } | ||
| 5414 | + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { | ||
| 5415 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | ||
| 5416 | + return false; | ||
| 5417 | + } | ||
| 5418 | + | ||
| 5419 | + | ||
| 5420 | + if (bconfig && bconfig.is_sort_storage) { | ||
| 5421 | + wx.getLocation({ | ||
| 5422 | + type: 'gcj02', | ||
| 5423 | + success: function (res) { | ||
| 5424 | + | ||
| 5425 | + th.data.lat = res.latitude; | ||
| 5426 | + th.data.lon = res.longitude; | ||
| 5427 | + th.data.is_get_local_ok = 1; | ||
| 5428 | + th.setData({ | ||
| 5429 | + is_gps: 1 | ||
| 5430 | + }); | ||
| 5431 | + //th.onShow(); | ||
| 5432 | + th.get_sto(th.data.is_normal); | ||
| 5433 | + }, | ||
| 5434 | + fail: function (res) { | ||
| 5435 | + //th.onShow(); | ||
| 5436 | + th.data.is_get_local_ok = 1; | ||
| 5437 | + th.get_sto(th.data.is_normal); | ||
| 5438 | + if (res.errCode == 2) { | ||
| 5439 | + th.setData({ | ||
| 5440 | + is_gps: 0 | ||
| 5441 | + }); | ||
| 5442 | + if (th.data.is_gps == 0) { | ||
| 5443 | + getApp().confirmBox("请开启GPS定位", null, 25000, !1); | ||
| 5444 | + } | ||
| 5445 | + } else { | ||
| 5446 | + th.setData({ | ||
| 5447 | + is_gps: "3" | ||
| 5448 | + }); | ||
| 5449 | + } | ||
| 5450 | + | ||
| 5451 | + } | ||
| 5452 | + }) | ||
| 5453 | + } else { | ||
| 5454 | + th.data.is_get_local_ok = 1; | ||
| 5455 | + th.get_sto(th.data.is_normal); | ||
| 5456 | + } | ||
| 5457 | + | ||
| 5458 | + if (ind != undefined && ind != null) { | ||
| 5459 | + this.setData({ | ||
| 5460 | + open_ind_store: ind, | ||
| 5461 | + store: 1, | ||
| 5462 | + openSpecModal: !1, | ||
| 5463 | + openSpecModal_pt: !1, | ||
| 5464 | + openSpecModal_flash_normal: !1, | ||
| 5465 | + }) | ||
| 5466 | + } else { | ||
| 5467 | + this.setData({ | ||
| 5468 | + store: 1, | ||
| 5469 | + openSpecModal: !1, | ||
| 5470 | + openSpecModal_pt: !1, | ||
| 5471 | + openSpecModal_flash_normal: !1 | ||
| 5472 | + | ||
| 5473 | + }) | ||
| 5474 | + } | ||
| 5475 | + }, | ||
| 5476 | + //关闭选择门店 | ||
| 5477 | + close_popup: function (e) { | ||
| 5478 | + var th = this; | ||
| 5479 | + this.setData({ | ||
| 5480 | + store: 0, | ||
| 5481 | + choice_sort_store: 0, | ||
| 5482 | + sort_store: 0, | ||
| 5483 | + fir_pick_index: 0, | ||
| 5484 | + sec_pick_index: 0 | ||
| 5485 | + }) | ||
| 5486 | + | ||
| 5487 | + var openindstore = this.data.open_ind_store; | ||
| 5488 | + if (openindstore == 1) { | ||
| 5489 | + th.setData({ | ||
| 5490 | + openSpecModal: !0, | ||
| 5491 | + openSpecModal_ind: openindstore, | ||
| 5492 | + }); | ||
| 5493 | + } else if (openindstore == 2) { | ||
| 5494 | + th.setData({ | ||
| 5495 | + openSpecModal: !0, | ||
| 5496 | + openSpecModal_ind: openindstore, | ||
| 5497 | + }); | ||
| 5498 | + } | ||
| 5499 | + else if (openindstore == 4) { //4就是拼团 | ||
| 5500 | + th.setData({ | ||
| 5501 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5502 | + store: 0, //关闭门店 | ||
| 5503 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5504 | + sort_store: 0, //关闭门店2级 | ||
| 5505 | + }); | ||
| 5506 | + } | ||
| 5507 | + else { | ||
| 5508 | + th.setData({ | ||
| 5509 | + store: 0, | ||
| 5510 | + choice_sort_store: 0, | ||
| 5511 | + sort_store: 0 | ||
| 5512 | + }) | ||
| 5513 | + } | ||
| 5514 | + | ||
| 5515 | + | ||
| 5516 | + }, | ||
| 5517 | + | ||
| 5518 | + //选择更多门店 | ||
| 5519 | + more_store: function () { | ||
| 5520 | + this.setData({ | ||
| 5521 | + sort_store: 1 | ||
| 5637 | }); | 5522 | }); |
| 5638 | - } | 5523 | + }, |
| 5524 | + sort_store: function () { | ||
| 5525 | + | ||
| 5526 | + }, | ||
| 5527 | + // 返回按钮 | ||
| 5528 | + returns: function () { | ||
| 5529 | + this.setData({ | ||
| 5530 | + sort_store: 0, | ||
| 5531 | + choice_sort_store: 0 | ||
| 5532 | + }); | ||
| 5533 | + }, | ||
| 5534 | + //---选择分类门店--- | ||
| 5535 | + choice_sort_store: function (e) { | ||
| 5536 | + var index = e.currentTarget.dataset.index; | ||
| 5537 | + var region_name = e.currentTarget.dataset.region; | ||
| 5538 | + var item = this.data.all_sto[index]; | ||
| 5539 | + this.setData({ | ||
| 5540 | + region_name: region_name, | ||
| 5541 | + sort_store: 0, | ||
| 5542 | + choice_sort_store: 1, | ||
| 5543 | + sec_sto: item, | ||
| 5544 | + sec_pick_index: 0 | ||
| 5545 | + }); | ||
| 5546 | + }, | ||
| 5639 | 5547 | ||
| 5640 | - else { | 5548 | + choose_for_store_fir: function (e) { |
| 5549 | + var index_c = e.currentTarget.dataset.ind; | ||
| 5550 | + var th = this; | ||
| 5641 | th.setData({ | 5551 | th.setData({ |
| 5642 | - store: 0, | ||
| 5643 | - choice_sort_store: 0, | ||
| 5644 | - sort_store: 0, | 5552 | + fir_pick_index: index_c |
| 5645 | }) | 5553 | }) |
| 5646 | - } | ||
| 5647 | 5554 | ||
| 5648 | - //如果商品没有其他活动,要取一下线下价格 | ||
| 5649 | - th.get_off_price(); | 5555 | + }, |
| 5556 | + | ||
| 5557 | + //如果开启线下库存,已经急速库存才会使用 | ||
| 5558 | + async check_the_pick(item, func) { | ||
| 5559 | + var th = this; | ||
| 5560 | + var goodsinfo = th.data.sele_g; | ||
| 5561 | + var erpwareid = goodsinfo.erpwareid; | ||
| 5562 | + var plist = null; | ||
| 5563 | + var lock = 0; | ||
| 5564 | + | ||
| 5565 | + //---如果是活动的时候,同时不是普通购买--- | ||
| 5566 | + if ((th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) && !th.data.is_normal) { | ||
| 5567 | + func(); | ||
| 5568 | + return false; | ||
| 5569 | + } | ||
| 5570 | + | ||
| 5571 | + if (this.data.sales_rules != 2) { | ||
| 5572 | + func(); | ||
| 5573 | + } else { | ||
| 5574 | + | ||
| 5575 | + //先读取门店的lock | ||
| 5576 | + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { | ||
| 5577 | + data: {store_id: os.stoid, wareId: goodsinfo.goods_id, storageId: item.pickup_id, pageSize: 1000} | ||
| 5578 | + }).then(res => { | ||
| 5579 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5580 | + for (var i in res.data.data.pageData) | ||
| 5581 | + lock += res.data.data.pageData[i].outQty; | ||
| 5582 | + } | ||
| 5583 | + }) | ||
| 5584 | + //读取线下的门店库存 | ||
| 5585 | + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { | ||
| 5586 | + data: {storageNos: item.pickup_no, wareIds: encodeURIComponent(erpwareid), storeId: os.stoid} | ||
| 5587 | + }).then(res => { | ||
| 5588 | + if (res.data.code == 0 && res.data.data.total > 0) { | ||
| 5589 | + plist = res.data.data.pageData[0]; | ||
| 5590 | + } | ||
| 5591 | + }) | ||
| 5592 | + | ||
| 5593 | + if (plist && plist.CanOutQty - lock > 0) { | ||
| 5594 | + item.CanOutQty = plist.CanOutQty - lock; | ||
| 5595 | + func(); | ||
| 5596 | + return false; | ||
| 5597 | + } | ||
| 5598 | + getApp().my_warnning(item.pickup_name + "库存不足!", 0, th); | ||
| 5599 | + | ||
| 5600 | + } | ||
| 5601 | + }, | ||
| 5602 | + | ||
| 5603 | + | ||
| 5604 | + //确定def_pick为选择的门店 | ||
| 5605 | + sure_pick: function (e) { | ||
| 5606 | + var th = this; | ||
| 5607 | + var item = null; | ||
| 5608 | + var openindstore = th.data.open_ind_store; | ||
| 5609 | + | ||
| 5610 | + if (th.data.choice_sort_store == 0) { | ||
| 5611 | + var index = th.data.fir_pick_index; | ||
| 5612 | + if (th.data.is_show_sto_cat == 1) { | ||
| 5613 | + item = th.data.def_pickpu_list[index]; | ||
| 5614 | + } else { | ||
| 5615 | + item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5616 | + } | ||
| 5617 | + | ||
| 5618 | + } else { | ||
| 5619 | + var index = th.data.sec_pick_index; | ||
| 5620 | + item = th.data.sec_sto.s_arr[index]; | ||
| 5621 | + } | ||
| 5622 | + | ||
| 5623 | + if (!th.data.sele_g) return false; | ||
| 5624 | + //判断门店的配送方式是不是匹配 | ||
| 5625 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 5626 | + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5627 | + wx.showToast({ | ||
| 5628 | + title: "门店配送方式不匹配", | ||
| 5629 | + icon: 'none', | ||
| 5630 | + duration: 2000 | ||
| 5631 | + }); | ||
| 5632 | + return false; | ||
| 5633 | + } | ||
| 5634 | + | ||
| 5635 | + //--回调函数的用法-- | ||
| 5636 | + th.check_the_pick(item, function () { | ||
| 5637 | + th.setData({ | ||
| 5638 | + def_pick_store: item, | ||
| 5639 | + sto_sele_name: item.pickup_name, | ||
| 5640 | + sto_sele_id: item.pickup_id, | ||
| 5641 | + sto_sele_distr: item.distr_type, | ||
| 5642 | + store: 0, | ||
| 5643 | + choice_sort_store: 0, | ||
| 5644 | + fir_pick_index: 0 | ||
| 5645 | + }); | ||
| 5646 | + | ||
| 5647 | + switch (openindstore){ | ||
| 5648 | + case 1: | ||
| 5649 | + th.setData({ openSpecModal: !0,openSpecModal_ind: openindstore, }); | ||
| 5650 | + break; | ||
| 5651 | + case 2: | ||
| 5652 | + th.setData({openSpecModal: !0, openSpecModal_ind: openindstore, }); | ||
| 5653 | + break; | ||
| 5654 | + case 4: | ||
| 5655 | + th.setData({ | ||
| 5656 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5657 | + store: 0, //关闭门店 | ||
| 5658 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5659 | + sort_store: 0, //关闭门店2级 | ||
| 5660 | + }); | ||
| 5661 | + break; | ||
| 5662 | + case 5: | ||
| 5663 | + th.setData({ | ||
| 5664 | + openSpecModal_flash_normal: 1, //打开拼团购买界面 | ||
| 5665 | + store: 0, //关闭门店 | ||
| 5666 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5667 | + sort_store: 0, //关闭门店2级 | ||
| 5668 | + }); | ||
| 5669 | + break; | ||
| 5670 | + default: | ||
| 5671 | + th.setData({ store: 0,choice_sort_store: 0, sort_store: 0}) | ||
| 5672 | + break | ||
| 5673 | + } | ||
| 5674 | + | ||
| 5675 | + /*-- | ||
| 5676 | + if (openindstore == 1) { | ||
| 5677 | + th.setData({ | ||
| 5678 | + openSpecModal: !0, | ||
| 5679 | + openSpecModal_ind: openindstore, | ||
| 5680 | + }); | ||
| 5681 | + } else if (openindstore == 2) { | ||
| 5682 | + th.setData({ | ||
| 5683 | + openSpecModal: !0, | ||
| 5684 | + openSpecModal_ind: openindstore, | ||
| 5685 | + }); | ||
| 5686 | + } | ||
| 5687 | + else if (openindstore == 4) { //4就是拼团 | ||
| 5688 | + th.setData({ | ||
| 5689 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5690 | + store: 0, //关闭门店 | ||
| 5691 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5692 | + sort_store: 0, //关闭门店2级 | ||
| 5693 | + }); | ||
| 5694 | + } | ||
| 5695 | + else { | ||
| 5696 | + th.setData({ | ||
| 5697 | + store: 0, | ||
| 5698 | + choice_sort_store: 0, | ||
| 5699 | + sort_store: 0 | ||
| 5700 | + }) | ||
| 5701 | + }--*/ | ||
| 5702 | + //如果商品没有其他活动,要取一下线下价格 | ||
| 5703 | + th.get_off_price(); | ||
| 5704 | + }) | ||
| 5705 | + }, | ||
| 5706 | + //---点击二级之后的选择--- | ||
| 5707 | + choose_for_store: function (e) { | ||
| 5708 | + var index_c = e.currentTarget.dataset.ind; | ||
| 5709 | + var th = this; | ||
| 5710 | + th.setData({ | ||
| 5711 | + sec_pick_index: index_c, | ||
| 5712 | + fir_pick_index: index_c | ||
| 5713 | + }) | ||
| 5714 | + | ||
| 5715 | + }, | ||
| 5716 | + //把选择的门店设置成默认的门店def_pick | ||
| 5717 | + set_def_pick: function (e) { | ||
| 5718 | + var th = this; | ||
| 5719 | + var item = null; | ||
| 5720 | + if (th.data.choice_sort_store == 0) { | ||
| 5721 | + var index = th.data.fir_pick_index; | ||
| 5722 | + if (th.data.is_show_sto_cat == 1) { | ||
| 5723 | + item = th.data.def_pickpu_list[index]; | ||
| 5724 | + } else { | ||
| 5725 | + item = th.data.only_pk[index]; //当没有门店分类的时候 | ||
| 5726 | + } | ||
| 5727 | + } else { | ||
| 5728 | + var index = th.data.sec_pick_index; | ||
| 5729 | + item = th.data.sec_sto.s_arr[index]; | ||
| 5730 | + } | ||
| 5731 | + | ||
| 5732 | + //判断门店的配送方式是不是匹配 | ||
| 5733 | + var g_distr_type = th.data.sele_g.distr_type; | ||
| 5734 | + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { | ||
| 5735 | + wx.showToast({ | ||
| 5736 | + title: "门店配送方式不匹配", | ||
| 5737 | + icon: 'none', | ||
| 5738 | + duration: 2000 | ||
| 5739 | + }); | ||
| 5740 | + return false; | ||
| 5741 | + } | ||
| 5742 | + | ||
| 5743 | + //先设置之前,要判断是不是有库存 | ||
| 5744 | + th.check_the_pick(item, function () { | ||
| 5745 | + var store_id = o.stoid; | ||
| 5746 | + var user_id = getApp().globalData.user_id; | ||
| 5747 | + var def_pickup_id = item.pickup_id; | ||
| 5748 | + | ||
| 5749 | + getApp().request.put('/api/weshop/users/update', { | ||
| 5750 | + data: { | ||
| 5751 | + user_id: user_id, | ||
| 5752 | + def_pickup_id: def_pickup_id | ||
| 5753 | + }, | ||
| 5754 | + success: function (res) { | ||
| 5755 | + if (res.data.code == 0) { | ||
| 5756 | + if (th.data.choice_sort_store == 0) th.setData({ | ||
| 5757 | + fir_pick_index: 0 | ||
| 5758 | + }); | ||
| 5759 | + getApp().globalData.pk_store = item; | ||
| 5760 | + } else { | ||
| 5761 | + //s.showWarning("设置默认门店地址失败", null, 500, !1); | ||
| 5762 | + getApp().my_warnning("设置默认门店地址失败", 0, th) | ||
| 5763 | + } | ||
| 5764 | + | ||
| 5765 | + } | ||
| 5766 | + }); | ||
| 5767 | + | ||
| 5768 | + th.setData({ | ||
| 5769 | + def_pick_store: item, | ||
| 5770 | + sto_sele_name: item.pickup_name, | ||
| 5771 | + sto_sele_id: item.pickup_id, | ||
| 5772 | + sto_sele_distr: item.distr_type, | ||
| 5773 | + store: 0, | ||
| 5774 | + choice_sort_store: 0 | ||
| 5775 | + }); | ||
| 5776 | + | ||
| 5777 | + var openindstore = th.data.open_ind_store; | ||
| 5778 | + if (openindstore == 1) { | ||
| 5779 | + th.setData({ | ||
| 5780 | + openSpecModal: !0, | ||
| 5781 | + openSpecModal_ind: openindstore, | ||
| 5782 | + store: 0, | ||
| 5783 | + choice_sort_store: 0, | ||
| 5784 | + sort_store: 0, | ||
| 5785 | + }); | ||
| 5786 | + } else if (openindstore == 2) { | ||
| 5787 | + th.setData({ | ||
| 5788 | + openSpecModal: !0, | ||
| 5789 | + openSpecModal_ind: openindstore, | ||
| 5790 | + store: 0, | ||
| 5791 | + choice_sort_store: 0, | ||
| 5792 | + sort_store: 0, | ||
| 5793 | + }); | ||
| 5794 | + } | ||
| 5795 | + else if (openindstore == 4) { //4就是拼团 | ||
| 5796 | + th.setData({ | ||
| 5797 | + openSpecModal_pt: 1, //打开拼团购买界面 | ||
| 5798 | + store: 0, //关闭门店 | ||
| 5799 | + choice_sort_store: 0, //关闭门店2级 | ||
| 5800 | + sort_store: 0, //关闭门店2级 | ||
| 5801 | + }); | ||
| 5802 | + } | ||
| 5803 | + | ||
| 5804 | + else { | ||
| 5805 | + th.setData({ | ||
| 5806 | + store: 0, | ||
| 5807 | + choice_sort_store: 0, | ||
| 5808 | + sort_store: 0, | ||
| 5809 | + }) | ||
| 5810 | + } | ||
| 5811 | + | ||
| 5812 | + //如果商品没有其他活动,要取一下线下价格 | ||
| 5813 | + th.get_off_price(); | ||
| 5814 | + | ||
| 5815 | + }) | ||
| 5816 | + }, | ||
| 5650 | 5817 | ||
| 5651 | - }) | ||
| 5652 | - }, | 5818 | + wait_for_store_config: function () { |
| 5819 | + var th = this; | ||
| 5820 | + var t_time = setInterval(function () { | ||
| 5821 | + if (th.data.bconfig == null) false; | ||
| 5822 | + var e = th.data.bconfig; | ||
| 5823 | + if (e && e.is_sort_storage) { | ||
| 5824 | + wx.getLocation({ | ||
| 5825 | + type: 'gcj02', | ||
| 5826 | + success: function (res) { | ||
| 5827 | + th.data.lat = res.latitude; | ||
| 5828 | + th.data.lon = res.longitude; | ||
| 5829 | + th.data.is_get_local_ok = 1; | ||
| 5830 | + }, | ||
| 5831 | + fail: function (res) { | ||
| 5832 | + if (res.errCode == 2) { | ||
| 5833 | + th.setData({ | ||
| 5834 | + is_gps: 0 | ||
| 5835 | + }); | ||
| 5836 | + if (th.data.is_gps == 0) { | ||
| 5837 | + getApp().confirmBox("请开启GPS定位", null, 10000, !1); | ||
| 5838 | + } | ||
| 5653 | 5839 | ||
| 5654 | - wait_for_store_config: function () { | ||
| 5655 | - var th = this; | ||
| 5656 | - var t_time = setInterval(function () { | ||
| 5657 | - if (th.data.bconfig == null) false; | ||
| 5658 | - var e = th.data.bconfig; | ||
| 5659 | - if (e && e.is_sort_storage) { | ||
| 5660 | - wx.getLocation({ | ||
| 5661 | - type: 'gcj02', | ||
| 5662 | - success: function (res) { | ||
| 5663 | - th.data.lat = res.latitude; | ||
| 5664 | - th.data.lon = res.longitude; | ||
| 5665 | - th.data.is_get_local_ok = 1; | ||
| 5666 | - }, | ||
| 5667 | - fail: function (res) { | ||
| 5668 | - if (res.errCode == 2) { | ||
| 5669 | - th.setData({ | ||
| 5670 | - is_gps: 0 | ||
| 5671 | - }); | ||
| 5672 | - if (th.data.is_gps == 0) { | ||
| 5673 | - getApp().confirmBox("请开启GPS定位", null, 10000, !1); | ||
| 5674 | - } | 5840 | + } else { |
| 5841 | + th.setData({ | ||
| 5842 | + is_gps: "3" | ||
| 5843 | + }); | ||
| 5844 | + } | ||
| 5675 | 5845 | ||
| 5846 | + th.data.is_get_local_ok = 1; | ||
| 5847 | + } | ||
| 5848 | + }) | ||
| 5676 | } else { | 5849 | } else { |
| 5677 | - th.setData({ | ||
| 5678 | - is_gps: "3" | ||
| 5679 | - }); | 5850 | + th.data.is_get_local_ok = 1; |
| 5680 | } | 5851 | } |
| 5681 | - | ||
| 5682 | - th.data.is_get_local_ok = 1; | ||
| 5683 | - } | ||
| 5684 | - }) | ||
| 5685 | - } else { | ||
| 5686 | - th.data.is_get_local_ok = 1; | ||
| 5687 | - } | ||
| 5688 | - clearInterval(t_time); | ||
| 5689 | - }, 500) | ||
| 5690 | - }, | ||
| 5691 | - //显示全部 | ||
| 5692 | - toggleHandler: function (e) { | ||
| 5693 | - var that = this, | ||
| 5694 | - index = e.currentTarget.dataset.index; | ||
| 5695 | - for (var i = 0; i < that.data.comments.length; i++) { | ||
| 5696 | - if (index == i) { | 5852 | + clearInterval(t_time); |
| 5853 | + }, 500) | ||
| 5854 | + }, | ||
| 5855 | + //显示全部 | ||
| 5856 | + toggleHandler: function (e) { | ||
| 5857 | + var that = this, | ||
| 5858 | + index = e.currentTarget.dataset.index; | ||
| 5697 | for (var i = 0; i < that.data.comments.length; i++) { | 5859 | for (var i = 0; i < that.data.comments.length; i++) { |
| 5698 | - that.data.comments[index].auto = true; | ||
| 5699 | - that.data.comments[index].seeMore = false; | 5860 | + if (index == i) { |
| 5861 | + for (var i = 0; i < that.data.comments.length; i++) { | ||
| 5862 | + that.data.comments[index].auto = true; | ||
| 5863 | + that.data.comments[index].seeMore = false; | ||
| 5864 | + } | ||
| 5865 | + } | ||
| 5700 | } | 5866 | } |
| 5701 | - } | ||
| 5702 | - } | ||
| 5703 | - that.setData({ | ||
| 5704 | - comments: that.data.comments | ||
| 5705 | - }) | ||
| 5706 | - }, | 5867 | + that.setData({ |
| 5868 | + comments: that.data.comments | ||
| 5869 | + }) | ||
| 5870 | + }, | ||
| 5707 | 5871 | ||
| 5708 | - //收起更多 | ||
| 5709 | - toggleContent: function (e) { | ||
| 5710 | - var that = this, | ||
| 5711 | - index = e.currentTarget.dataset.index; | ||
| 5712 | - for (var i = 0; i < that.data.comments.length; i++) { | ||
| 5713 | - if (index == i) { | ||
| 5714 | - that.data.comments[index].auto = true; | ||
| 5715 | - that.data.comments[index].seeMore = true; | ||
| 5716 | - } | ||
| 5717 | - } | ||
| 5718 | - that.setData({ | ||
| 5719 | - comments: that.data.comments | ||
| 5720 | - }) | ||
| 5721 | - }, | 5872 | + //收起更多 |
| 5873 | + toggleContent: function (e) { | ||
| 5874 | + var that = this, | ||
| 5875 | + index = e.currentTarget.dataset.index; | ||
| 5876 | + for (var i = 0; i < that.data.comments.length; i++) { | ||
| 5877 | + if (index == i) { | ||
| 5878 | + that.data.comments[index].auto = true; | ||
| 5879 | + that.data.comments[index].seeMore = true; | ||
| 5880 | + } | ||
| 5881 | + } | ||
| 5882 | + that.setData({ | ||
| 5883 | + comments: that.data.comments | ||
| 5884 | + }) | ||
| 5885 | + }, | ||
| 5722 | 5886 | ||
| 5723 | - //--- 获取卡类列表 --- | ||
| 5724 | - getPlusCardType: function (func) { | ||
| 5725 | - var storid = os.stoid; | ||
| 5726 | - var th = this; | ||
| 5727 | - var user = getApp().globalData.userInfo; | ||
| 5728 | - if (!user) return false; | ||
| 5729 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 5730 | - var plusCard = res.data.data; | ||
| 5731 | - var arr = [1219, 2089, 3031]; | ||
| 5732 | - var new_arr = new Array(); | ||
| 5733 | - var card_name_map = new Map(); | ||
| 5734 | - | ||
| 5735 | - var list = []; | ||
| 5736 | - for (var i = 0; i < plusCard.length; i++) { | ||
| 5737 | - if ((!user || user.card_field == null || user.card_field == "") && plusCard[i].IsStopBuy == true) continue; | ||
| 5738 | - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 5739 | - card_name_map.set(name, plusCard[i].CardName); | ||
| 5740 | - list.push(plusCard[i]); | ||
| 5741 | - } | 5887 | + //--- 获取卡类列表 --- |
| 5888 | + getPlusCardType: function (func) { | ||
| 5889 | + var storid = os.stoid; | ||
| 5890 | + var th = this; | ||
| 5891 | + var user = getApp().globalData.userInfo; | ||
| 5892 | + if (!user) return false; | ||
| 5893 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 5894 | + var plusCard = res.data.data; | ||
| 5895 | + var arr = [1219, 2089, 3031]; | ||
| 5896 | + var new_arr = new Array(); | ||
| 5897 | + var card_name_map = new Map(); | ||
| 5898 | + | ||
| 5899 | + var list = []; | ||
| 5900 | + for (var i = 0; i < plusCard.length; i++) { | ||
| 5901 | + if ((!user || user.card_field == null || user.card_field == "") && plusCard[i].IsStopBuy == true) continue; | ||
| 5902 | + var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 5903 | + card_name_map.set(name, plusCard[i].CardName); | ||
| 5904 | + list.push(plusCard[i]); | ||
| 5905 | + } | ||
| 5742 | 5906 | ||
| 5743 | - var ob = { "card_list": list, "name_map": card_name_map }; | ||
| 5744 | - func(ob); | ||
| 5745 | - }) | ||
| 5746 | - }, | 5907 | + var ob = {"card_list": list, "name_map": card_name_map}; |
| 5908 | + func(ob); | ||
| 5909 | + }) | ||
| 5910 | + }, | ||
| 5747 | 5911 | ||
| 5748 | - go_plus: function () { | ||
| 5749 | - getApp().goto("/pages/user/plus/plus"); | ||
| 5750 | - }, | ||
| 5751 | - go_card_info: function () { | ||
| 5752 | - getApp().goto("/pages/user/cardinfo/cardinfo"); | ||
| 5753 | - }, | ||
| 5754 | - //-- 根据ID拿出门店 -- | ||
| 5755 | - get_pick_from_list(pid) { | ||
| 5756 | - var all_pick_list = this.data.all_pick_list; | ||
| 5757 | - for (var i in all_pick_list) { | ||
| 5758 | - var item = all_pick_list[i]; | ||
| 5759 | - if (item.pickup_id == pid) { | ||
| 5760 | - return item; | ||
| 5761 | - } | ||
| 5762 | - } | ||
| 5763 | - }, | ||
| 5764 | - //-----显示优惠券的时候情况----- | ||
| 5765 | - show_more_cx: function () { | ||
| 5766 | - if (this.data.is_more_cx) { | ||
| 5767 | - this.setData({ is_more_cx: 0 }); | ||
| 5768 | - } else { | ||
| 5769 | - this.setData({ is_more_cx: 1 }); | ||
| 5770 | - } | ||
| 5771 | - }, | 5912 | + go_plus: function () { |
| 5913 | + getApp().goto("/pages/user/plus/plus"); | ||
| 5914 | + }, | ||
| 5915 | + go_card_info: function () { | ||
| 5916 | + getApp().goto("/pages/user/cardinfo/cardinfo"); | ||
| 5917 | + }, | ||
| 5918 | + //-- 根据ID拿出门店 -- | ||
| 5919 | + get_pick_from_list(pid) { | ||
| 5920 | + var all_pick_list = this.data.all_pick_list; | ||
| 5921 | + for (var i in all_pick_list) { | ||
| 5922 | + var item = all_pick_list[i]; | ||
| 5923 | + if (item.pickup_id == pid) { | ||
| 5924 | + return item; | ||
| 5925 | + } | ||
| 5926 | + } | ||
| 5927 | + }, | ||
| 5928 | + //-----显示优惠券的时候情况----- | ||
| 5929 | + show_more_cx: function () { | ||
| 5930 | + if (this.data.is_more_cx) { | ||
| 5931 | + this.setData({is_more_cx: 0}); | ||
| 5932 | + } else { | ||
| 5933 | + this.setData({is_more_cx: 1}); | ||
| 5934 | + } | ||
| 5935 | + }, | ||
| 5772 | 5936 | ||
| 5773 | - //----跳转到搭配购买---- | ||
| 5774 | - go_prom_list: function () { | 5937 | + //----跳转到搭配购买---- |
| 5938 | + go_prom_list: function () { | ||
| 5775 | 5939 | ||
| 5776 | - var url = "../../../packageA/pages/prom_list/prom_list?goods_id=" + this.data.gid; | ||
| 5777 | - var room_id = getApp().globalData.room_id; | ||
| 5778 | - if (room_id && this.data.gid == getApp().globalData.room_goods_id) { | ||
| 5779 | - url += "&room_id=" + room_id; | ||
| 5780 | - } | ||
| 5781 | - wx.navigateTo({ url: url, }) | ||
| 5782 | - }, | 5940 | + var url = "../../../packageA/pages/prom_list/prom_list?goods_id=" + this.data.gid; |
| 5941 | + var room_id = getApp().globalData.room_id; | ||
| 5942 | + if (room_id && this.data.gid == getApp().globalData.room_goods_id) { | ||
| 5943 | + url += "&room_id=" + room_id; | ||
| 5944 | + } | ||
| 5945 | + wx.navigateTo({url: url,}) | ||
| 5946 | + }, | ||
| 5783 | 5947 | ||
| 5784 | - //---检查有没有优惠活动--- | ||
| 5785 | - check_is_youhui: function (gid, is_nor) { | ||
| 5786 | - var th = this; | ||
| 5787 | - var user_id=getApp().globalData.user_id; | ||
| 5788 | - if(!user_id) user_id=0; | ||
| 5789 | - //如果是普通购买的时候,要进行调用 | ||
| 5790 | - if (is_nor) { | ||
| 5791 | - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { | ||
| 5792 | - success: function (res) { | ||
| 5793 | - if (res.data.code == 0) { | ||
| 5794 | - var r_data = res.data.data; | ||
| 5795 | - | ||
| 5796 | - if(r_data.ladderLists){ | ||
| 5797 | - var act_id=r_data.ladderLists[0].form_id; | ||
| 5798 | - //-- 判断会员能不能参与阶梯促销 -- | ||
| 5799 | - getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, { | ||
| 5800 | - }).then(res=>{ | ||
| 5801 | - if(res.data.code==0 && res.data.data){ | ||
| 5802 | - var prom_content=""; | ||
| 5803 | - for(let jj in r_data.ladderLists){ | ||
| 5804 | - if(r_data.ladderLists[jj].discount==10){ | ||
| 5805 | - prom_content+="第"+(parseInt(jj)+1)+"件原价,"; | ||
| 5806 | - }else{ | ||
| 5807 | - prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,"; | ||
| 5808 | - } | ||
| 5809 | - } | ||
| 5810 | - prom_content=ut.sub_last(prom_content); | ||
| 5811 | - th.data.prom_type=10; | ||
| 5812 | - th.data.prom_id=act_id; | ||
| 5813 | - th.setData({ | ||
| 5814 | - jieti_prom:prom_content, | ||
| 5815 | - ladder_act_id:act_id | ||
| 5816 | - }) | ||
| 5817 | - } | ||
| 5818 | - }) | ||
| 5819 | - } | 5948 | + //---检查有没有优惠活动--- |
| 5949 | + check_is_youhui: function (gid, is_nor) { | ||
| 5950 | + var th = this; | ||
| 5951 | + var user_id = getApp().globalData.user_id; | ||
| 5952 | + if (!user_id) user_id = 0; | ||
| 5953 | + //如果是普通购买的时候,要进行调用 | ||
| 5954 | + if (is_nor) { | ||
| 5955 | + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { | ||
| 5956 | + success: function (res) { | ||
| 5957 | + if (res.data.code == 0) { | ||
| 5958 | + var r_data = res.data.data; | ||
| 5959 | + | ||
| 5960 | + if (r_data.ladderLists) { | ||
| 5961 | + var act_id = r_data.ladderLists[0].form_id; | ||
| 5962 | + //-- 判断会员能不能参与阶梯促销 -- | ||
| 5963 | + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 5964 | + if (res.data.code == 0 && res.data.data) { | ||
| 5965 | + var prom_content = ""; | ||
| 5966 | + for (let jj in r_data.ladderLists) { | ||
| 5967 | + if (r_data.ladderLists[jj].discount == 10) { | ||
| 5968 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 5969 | + } else { | ||
| 5970 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 5971 | + } | ||
| 5972 | + } | ||
| 5973 | + prom_content = ut.sub_last(prom_content); | ||
| 5974 | + th.data.prom_type = 10; | ||
| 5975 | + th.data.prom_id = act_id; | ||
| 5976 | + th.setData({ | ||
| 5977 | + jieti_prom: prom_content, | ||
| 5978 | + ladder_act_id: act_id | ||
| 5979 | + }) | ||
| 5980 | + } | ||
| 5981 | + }) | ||
| 5982 | + } | ||
| 5820 | 5983 | ||
| 5821 | - th.setData({ | ||
| 5822 | - prom_goods: r_data.promGoodsLists, | 5984 | + th.setData({ |
| 5985 | + prom_goods: r_data.promGoodsLists, | ||
| 5986 | + }) | ||
| 5987 | + th.is_show_more_buy(); | ||
| 5988 | + } | ||
| 5989 | + }, | ||
| 5823 | }) | 5990 | }) |
| 5824 | - th.is_show_more_buy(); | ||
| 5825 | - } | ||
| 5826 | - }, | ||
| 5827 | - }) | ||
| 5828 | - | ||
| 5829 | - } else { | ||
| 5830 | - //调用接口判断订单优惠, | ||
| 5831 | - getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", { | ||
| 5832 | - success: function (res) { | ||
| 5833 | - | ||
| 5834 | - if (res.data.code == 0 && res.data.data) { | ||
| 5835 | - var r_data = res.data.data; | ||
| 5836 | - var max = 0, min = 0; | ||
| 5837 | - if (r_data.collocationList) { | ||
| 5838 | - for (var i in r_data.collocationList) { | ||
| 5839 | - if (max == 0) max = r_data.collocationList[i].price; | ||
| 5840 | - if (min == 0) min = r_data.collocationList[i].price; | ||
| 5841 | - | ||
| 5842 | - if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; | ||
| 5843 | - if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; | ||
| 5844 | - } | ||
| 5845 | - r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); | ||
| 5846 | - r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); | ||
| 5847 | - } | ||
| 5848 | - | ||
| 5849 | - if(r_data.ladderLists){ | ||
| 5850 | - var act_id=r_data.ladderLists[0].form_id; | ||
| 5851 | - //-- 判断会员能不能参与阶梯促销 -- | ||
| 5852 | - getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, { | ||
| 5853 | - }).then(res=>{ | ||
| 5854 | - if(res.data.code==0 && res.data.data){ | ||
| 5855 | - var prom_content=""; | ||
| 5856 | - for(let jj in r_data.ladderLists){ | ||
| 5857 | - if(r_data.ladderLists[jj].discount==10){ | ||
| 5858 | - prom_content+="第"+(parseInt(jj)+1)+"件原价,"; | ||
| 5859 | - }else{ | ||
| 5860 | - prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,"; | 5991 | + |
| 5992 | + } else { | ||
| 5993 | + //调用接口判断订单优惠, | ||
| 5994 | + getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", { | ||
| 5995 | + success: function (res) { | ||
| 5996 | + | ||
| 5997 | + if (res.data.code == 0 && res.data.data) { | ||
| 5998 | + var r_data = res.data.data; | ||
| 5999 | + var max = 0, min = 0; | ||
| 6000 | + if (r_data.collocationList) { | ||
| 6001 | + for (var i in r_data.collocationList) { | ||
| 6002 | + if (max == 0) max = r_data.collocationList[i].price; | ||
| 6003 | + if (min == 0) min = r_data.collocationList[i].price; | ||
| 6004 | + | ||
| 6005 | + if (max < parseFloat(r_data.collocationList[i].price)) max = r_data.collocationList[i].price; | ||
| 6006 | + if (min > parseFloat(r_data.collocationList[i].price)) min = r_data.collocationList[i].price; | ||
| 5861 | } | 6007 | } |
| 6008 | + r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); | ||
| 6009 | + r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); | ||
| 6010 | + } | ||
| 6011 | + | ||
| 6012 | + if (r_data.ladderLists) { | ||
| 6013 | + var act_id = r_data.ladderLists[0].form_id; | ||
| 6014 | + //-- 判断会员能不能参与阶梯促销 -- | ||
| 6015 | + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {}).then(res => { | ||
| 6016 | + if (res.data.code == 0 && res.data.data) { | ||
| 6017 | + var prom_content = ""; | ||
| 6018 | + for (let jj in r_data.ladderLists) { | ||
| 6019 | + if (r_data.ladderLists[jj].discount == 10) { | ||
| 6020 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | ||
| 6021 | + } else { | ||
| 6022 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | ||
| 6023 | + } | ||
| 6024 | + } | ||
| 6025 | + prom_content = ut.sub_last(prom_content); | ||
| 6026 | + th.data.prom_type = 10; | ||
| 6027 | + th.data.prom_id = act_id; | ||
| 6028 | + th.setData({ | ||
| 6029 | + jieti_prom: prom_content, | ||
| 6030 | + ladder_act_id: act_id | ||
| 6031 | + }) | ||
| 6032 | + } | ||
| 6033 | + }) | ||
| 5862 | } | 6034 | } |
| 5863 | - prom_content=ut.sub_last(prom_content); | ||
| 5864 | - th.data.prom_type=10; | ||
| 5865 | - th.data.prom_id=act_id; | 6035 | + |
| 5866 | th.setData({ | 6036 | th.setData({ |
| 5867 | - jieti_prom:prom_content, | ||
| 5868 | - ladder_act_id:act_id | 6037 | + order_prom: r_data.promOrder, |
| 6038 | + collocationGoods: r_data.collocationPromList, | ||
| 6039 | + prom_goods: r_data.promGoodsLists, | ||
| 5869 | }) | 6040 | }) |
| 6041 | + th.is_show_more_buy(); | ||
| 5870 | } | 6042 | } |
| 5871 | - }) | ||
| 5872 | - } | ||
| 5873 | - | ||
| 5874 | - th.setData({ | ||
| 5875 | - order_prom: r_data.promOrder, | ||
| 5876 | - collocationGoods: r_data.collocationPromList, | ||
| 5877 | - prom_goods: r_data.promGoodsLists, | 6043 | + } |
| 5878 | }) | 6044 | }) |
| 5879 | - th.is_show_more_buy(); | ||
| 5880 | - } | ||
| 5881 | } | 6045 | } |
| 5882 | - }) | ||
| 5883 | - } | ||
| 5884 | - }, | 6046 | + }, |
| 5885 | 6047 | ||
| 5886 | - closePoster() { | ||
| 5887 | - this.setData({ | ||
| 5888 | - showPoster: false, | ||
| 5889 | - }); | ||
| 5890 | - }, | 6048 | + closePoster() { |
| 6049 | + this.setData({ | ||
| 6050 | + showPoster: false, | ||
| 6051 | + }); | ||
| 6052 | + }, | ||
| 5891 | 6053 | ||
| 5892 | - // 保存图片到手机 | ||
| 5893 | - savePic() { | ||
| 5894 | - console.log('保存图片'); | ||
| 5895 | - var self = this; | ||
| 5896 | - // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | ||
| 5897 | - this.getSetting().then((res) => { | ||
| 5898 | - // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | ||
| 5899 | - if (!res.authSetting['scope.writePhotosAlbum']) { | ||
| 5900 | - this.authorize().then(() => { | ||
| 5901 | - // 同意授权后保存下载文件 | ||
| 5902 | - this.saveImage(self.data.shareImgPath) | ||
| 5903 | - .then(() => { | ||
| 5904 | - self.setData({ | ||
| 5905 | - showPoster: false | ||
| 5906 | - }); | ||
| 5907 | - }); | ||
| 5908 | - }) | ||
| 5909 | - } else { | ||
| 5910 | - // 如果已经授权,保存下载文件 | ||
| 5911 | - this.saveImage(self.data.shareImgPath) | ||
| 5912 | - .then(() => { | ||
| 5913 | - self.setData({ | ||
| 5914 | - showPoster: false | ||
| 5915 | - }); | ||
| 5916 | - }); | ||
| 5917 | - } | 6054 | + // 保存图片到手机 |
| 6055 | + savePic() { | ||
| 6056 | + console.log('保存图片'); | ||
| 6057 | + var self = this; | ||
| 6058 | + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | ||
| 6059 | + this.getSetting().then((res) => { | ||
| 6060 | + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | ||
| 6061 | + if (!res.authSetting['scope.writePhotosAlbum']) { | ||
| 6062 | + this.authorize().then(() => { | ||
| 6063 | + // 同意授权后保存下载文件 | ||
| 6064 | + this.saveImage(self.data.shareImgPath) | ||
| 6065 | + .then(() => { | ||
| 6066 | + self.setData({ | ||
| 6067 | + showPoster: false | ||
| 6068 | + }); | ||
| 6069 | + }); | ||
| 6070 | + }) | ||
| 6071 | + } else { | ||
| 6072 | + // 如果已经授权,保存下载文件 | ||
| 6073 | + this.saveImage(self.data.shareImgPath) | ||
| 6074 | + .then(() => { | ||
| 6075 | + self.setData({ | ||
| 6076 | + showPoster: false | ||
| 6077 | + }); | ||
| 6078 | + }); | ||
| 6079 | + } | ||
| 5918 | 6080 | ||
| 5919 | - }) | ||
| 5920 | - }, | 6081 | + }) |
| 6082 | + }, | ||
| 5921 | 6083 | ||
| 5922 | - // 获取用户已经授予了哪些权限 | ||
| 5923 | - getSetting() { | ||
| 5924 | - return new Promise((resolve, reject) => { | ||
| 5925 | - wx.getSetting({ | ||
| 5926 | - success: res => { | ||
| 5927 | - resolve(res) | ||
| 5928 | - } | ||
| 5929 | - }) | ||
| 5930 | - }) | ||
| 5931 | - }, | 6084 | + // 获取用户已经授予了哪些权限 |
| 6085 | + getSetting() { | ||
| 6086 | + return new Promise((resolve, reject) => { | ||
| 6087 | + wx.getSetting({ | ||
| 6088 | + success: res => { | ||
| 6089 | + resolve(res) | ||
| 6090 | + } | ||
| 6091 | + }) | ||
| 6092 | + }) | ||
| 6093 | + }, | ||
| 5932 | 6094 | ||
| 5933 | - // 发起首次授权请求 | ||
| 5934 | - authorize() { | ||
| 5935 | - // isFirst 用来记录是否为首次发起授权, | ||
| 5936 | - // 如果首次授权拒绝后,isFirst赋值为1 | ||
| 5937 | - let isFirst = wx.getStorageSync('isFirst') || 0; | ||
| 5938 | - return new Promise((resolve, reject) => { | ||
| 5939 | - wx.authorize({ | ||
| 5940 | - scope: 'scope.writePhotosAlbum', | ||
| 5941 | - // 同意授权 | ||
| 5942 | - success: () => { | ||
| 5943 | - resolve(); | ||
| 5944 | - }, | ||
| 5945 | - // 拒绝授权,这里是用户拒绝授权后的回调 | ||
| 5946 | - fail: res => { | ||
| 5947 | - if (isFirst === 0) { | ||
| 5948 | - wx.setStorageSync('isFirst', 1); | ||
| 5949 | - wx.showToast({ | ||
| 5950 | - title: '保存失败', | ||
| 5951 | - icon: 'none', | ||
| 5952 | - duration: 1000 | 6095 | + // 发起首次授权请求 |
| 6096 | + authorize() { | ||
| 6097 | + // isFirst 用来记录是否为首次发起授权, | ||
| 6098 | + // 如果首次授权拒绝后,isFirst赋值为1 | ||
| 6099 | + let isFirst = wx.getStorageSync('isFirst') || 0; | ||
| 6100 | + return new Promise((resolve, reject) => { | ||
| 6101 | + wx.authorize({ | ||
| 6102 | + scope: 'scope.writePhotosAlbum', | ||
| 6103 | + // 同意授权 | ||
| 6104 | + success: () => { | ||
| 6105 | + resolve(); | ||
| 6106 | + }, | ||
| 6107 | + // 拒绝授权,这里是用户拒绝授权后的回调 | ||
| 6108 | + fail: res => { | ||
| 6109 | + if (isFirst === 0) { | ||
| 6110 | + wx.setStorageSync('isFirst', 1); | ||
| 6111 | + wx.showToast({ | ||
| 6112 | + title: '保存失败', | ||
| 6113 | + icon: 'none', | ||
| 6114 | + duration: 1000 | ||
| 6115 | + }) | ||
| 6116 | + } else { | ||
| 6117 | + this.showModal(); | ||
| 6118 | + } | ||
| 6119 | + console.log('拒绝授权'); | ||
| 6120 | + reject(); | ||
| 6121 | + } | ||
| 5953 | }) | 6122 | }) |
| 5954 | - } else { | ||
| 5955 | - this.showModal(); | ||
| 5956 | - } | ||
| 5957 | - console.log('拒绝授权'); | ||
| 5958 | - reject(); | ||
| 5959 | - } | ||
| 5960 | - }) | ||
| 5961 | - }) | ||
| 5962 | - }, | 6123 | + }) |
| 6124 | + }, | ||
| 5963 | 6125 | ||
| 5964 | 6126 | ||
| 5965 | - // 保存图片到系统相册 | ||
| 5966 | - saveImage(saveUrl) { | ||
| 5967 | - var self = this; | ||
| 5968 | - return new Promise((resolve, reject) => { | ||
| 5969 | - wx.saveImageToPhotosAlbum({ | ||
| 5970 | - filePath: saveUrl, | ||
| 5971 | - success: (res) => { | ||
| 5972 | - wx.showToast({ | ||
| 5973 | - title: '保存成功', | ||
| 5974 | - duration: 1000, | ||
| 5975 | - }); | ||
| 5976 | - self.setData({ | ||
| 5977 | - showPlaybill: 'true' | ||
| 5978 | - }); | ||
| 5979 | - resolve(); | ||
| 5980 | - }, | ||
| 5981 | - fail: () => { | ||
| 5982 | - wx.showToast({ | ||
| 5983 | - title: '保存失败', | ||
| 5984 | - duration: 1000, | ||
| 5985 | - }); | ||
| 5986 | - } | ||
| 5987 | - }) | ||
| 5988 | - }) | ||
| 5989 | - }, | 6127 | + // 保存图片到系统相册 |
| 6128 | + saveImage(saveUrl) { | ||
| 6129 | + var self = this; | ||
| 6130 | + return new Promise((resolve, reject) => { | ||
| 6131 | + wx.saveImageToPhotosAlbum({ | ||
| 6132 | + filePath: saveUrl, | ||
| 6133 | + success: (res) => { | ||
| 6134 | + wx.showToast({ | ||
| 6135 | + title: '保存成功', | ||
| 6136 | + duration: 1000, | ||
| 6137 | + }); | ||
| 6138 | + self.setData({ | ||
| 6139 | + showPlaybill: 'true' | ||
| 6140 | + }); | ||
| 6141 | + resolve(); | ||
| 6142 | + }, | ||
| 6143 | + fail: () => { | ||
| 6144 | + wx.showToast({ | ||
| 6145 | + title: '保存失败', | ||
| 6146 | + duration: 1000, | ||
| 6147 | + }); | ||
| 6148 | + } | ||
| 6149 | + }) | ||
| 6150 | + }) | ||
| 6151 | + }, | ||
| 5990 | 6152 | ||
| 5991 | - previewImage(e) { | ||
| 5992 | - this.data.show_prew_img = 1; | ||
| 5993 | - wx.previewImage({ | ||
| 5994 | - //将图片预览出来 | ||
| 5995 | - urls: [this.data.sele_g.original_img] | ||
| 5996 | - }); | ||
| 5997 | - }, | 6153 | + previewImage(e) { |
| 6154 | + this.data.show_prew_img = 1; | ||
| 6155 | + wx.previewImage({ | ||
| 6156 | + //将图片预览出来 | ||
| 6157 | + urls: [this.data.sele_g.original_img] | ||
| 6158 | + }); | ||
| 6159 | + }, | ||
| 5998 | 6160 | ||
| 5999 | - is_show_more_buy: function () { | ||
| 6000 | - var prom_goods = this.data.prom_goods; | ||
| 6001 | - var per_price = this.data.sele_g.shop_price | ||
| 6002 | - if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { | ||
| 6003 | - per_price = this.data.sele_g[this.data.card_field]; | ||
| 6004 | - } | ||
| 6005 | - var all_price = per_price * this.data.goodsInputNum; | ||
| 6006 | - var con = null; | ||
| 6007 | - for (var i in prom_goods) { | ||
| 6008 | - var item = prom_goods[i]; | ||
| 6009 | - if (item.prom_type == 1) { | ||
| 6010 | - if (item.condition > this.data.goodsInputNum) { | ||
| 6011 | - con = item; | ||
| 6012 | - con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件"; | ||
| 6013 | - break; | 6161 | + is_show_more_buy: function () { |
| 6162 | + var prom_goods = this.data.prom_goods; | ||
| 6163 | + var per_price = this.data.sele_g.shop_price | ||
| 6164 | + if (this.data.card_field && this.data.sele_g[this.data.card_field] > 0) { | ||
| 6165 | + per_price = this.data.sele_g[this.data.card_field]; | ||
| 6014 | } | 6166 | } |
| 6015 | - } else { | ||
| 6016 | - if (item.condition > all_price) { | ||
| 6017 | - con = item; | ||
| 6018 | - con.need = (item.condition - all_price).toFixed(2) + "元"; | ||
| 6019 | - break; | 6167 | + var all_price = per_price * this.data.goodsInputNum; |
| 6168 | + var con = null; | ||
| 6169 | + for (var i in prom_goods) { | ||
| 6170 | + var item = prom_goods[i]; | ||
| 6171 | + if (item.prom_type == 1) { | ||
| 6172 | + if (item.condition > this.data.goodsInputNum) { | ||
| 6173 | + con = item; | ||
| 6174 | + con.need = (item.condition - this.data.goodsInputNum).toFixed(2) + "件"; | ||
| 6175 | + break; | ||
| 6176 | + } | ||
| 6177 | + } else { | ||
| 6178 | + if (item.condition > all_price) { | ||
| 6179 | + con = item; | ||
| 6180 | + con.need = (item.condition - all_price).toFixed(2) + "元"; | ||
| 6181 | + break; | ||
| 6182 | + } | ||
| 6183 | + } | ||
| 6020 | } | 6184 | } |
| 6021 | - } | ||
| 6022 | - } | ||
| 6023 | 6185 | ||
| 6024 | - this.setData({ hui_condition: con }); | 6186 | + this.setData({hui_condition: con}); |
| 6025 | 6187 | ||
| 6026 | - }, | 6188 | + }, |
| 6027 | 6189 | ||
| 6028 | - //-- 积分购 -- | ||
| 6029 | - go_pay_integral: function () { | ||
| 6030 | - this.data.g_buy_num = new Map(); | ||
| 6031 | - this.get_sto(0) | ||
| 6032 | - this.setData({ openSpecModal_inte: 1, goodsInputNum: 1 }); | 6190 | + //-- 积分购 -- |
| 6191 | + go_pay_integral: function () { | ||
| 6192 | + this.data.g_buy_num = new Map(); | ||
| 6193 | + this.get_sto(0) | ||
| 6194 | + this.setData({openSpecModal_inte: 1, goodsInputNum: 1}); | ||
| 6033 | 6195 | ||
| 6034 | 6196 | ||
| 6035 | - }, | ||
| 6036 | - //-- 积分购普通购买 -- | ||
| 6037 | - go_pay_integral_normal: function () { | ||
| 6038 | - | ||
| 6039 | - this.data.g_buy_num = new Map(); | ||
| 6040 | - var th = this; | ||
| 6041 | - if (th.data.sku_g_pt) { | ||
| 6042 | - this.get_sto(1) | ||
| 6043 | - this.setData({ openSpecModal_inte_normal: 1 }); | ||
| 6044 | - } else { | ||
| 6045 | - th.get_sto(1); | ||
| 6046 | - th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6047 | - th.setData({ | ||
| 6048 | - is_normal: 1, | ||
| 6049 | - openSpecModal_inte_normal: 1 | ||
| 6050 | - }); | ||
| 6051 | - }); | ||
| 6052 | - } | ||
| 6053 | - this.check_is_youhui(th.data.gid, 1); | ||
| 6054 | - }, | 6197 | + }, |
| 6198 | + //-- 积分购普通购买 -- | ||
| 6199 | + go_pay_integral_normal: function () { | ||
| 6200 | + | ||
| 6201 | + this.data.g_buy_num = new Map(); | ||
| 6202 | + var th = this; | ||
| 6203 | + if (th.data.sku_g_pt) { | ||
| 6204 | + this.get_sto(1) | ||
| 6205 | + this.setData({openSpecModal_inte_normal: 1}); | ||
| 6206 | + } else { | ||
| 6207 | + th.get_sto(1); | ||
| 6208 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6209 | + th.setData({ | ||
| 6210 | + is_normal: 1, | ||
| 6211 | + openSpecModal_inte_normal: 1 | ||
| 6212 | + }); | ||
| 6213 | + }); | ||
| 6214 | + } | ||
| 6215 | + this.check_is_youhui(th.data.gid, 1); | ||
| 6216 | + }, | ||
| 6055 | 6217 | ||
| 6056 | - closeSpecModal_inte: function () { | ||
| 6057 | - this.setData({ openSpecModal_inte: 0 }); | ||
| 6058 | - }, | ||
| 6059 | - closeSpecModal_inte_normal: function () { | ||
| 6060 | - this.setData({ openSpecModal_inte_normal: 0 }); | ||
| 6061 | - //要进行还原 | ||
| 6062 | - this.get_sto(); | ||
| 6063 | - this.setData({ | ||
| 6064 | - sele_g: this.data.data, | ||
| 6065 | - gid: this.data.data.goods_id | ||
| 6066 | - }) | 6218 | + closeSpecModal_inte: function () { |
| 6219 | + this.setData({openSpecModal_inte: 0}); | ||
| 6220 | + }, | ||
| 6221 | + closeSpecModal_inte_normal: function () { | ||
| 6222 | + this.setData({openSpecModal_inte_normal: 0}); | ||
| 6223 | + //要进行还原 | ||
| 6224 | + this.get_sto(); | ||
| 6225 | + this.setData({ | ||
| 6226 | + sele_g: this.data.data, | ||
| 6227 | + gid: this.data.data.goods_id | ||
| 6228 | + }) | ||
| 6067 | 6229 | ||
| 6068 | - this.sele_spec_chech_activity(); | ||
| 6069 | - }, | 6230 | + this.sele_spec_chech_activity(); |
| 6231 | + }, | ||
| 6070 | 6232 | ||
| 6071 | - addCart_inte: function (t) { | ||
| 6072 | - this.add_cart_func_inte(t); | ||
| 6073 | - }, | 6233 | + addCart_inte: function (t) { |
| 6234 | + this.add_cart_func_inte(t); | ||
| 6235 | + }, | ||
| 6074 | 6236 | ||
| 6075 | - onShareTimeline() { | ||
| 6076 | - var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; | ||
| 6077 | - if (!store_name) | ||
| 6078 | - store_name = getApp().globalData.setting.appName; | ||
| 6079 | - return { | ||
| 6080 | - title: this.data.data.goods_name + '-' + store_name, | ||
| 6081 | - imageUrl: this.data.gallery[0].image_url, | ||
| 6082 | - } | ||
| 6083 | - }, | 6237 | + onShareTimeline() { |
| 6238 | + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; | ||
| 6239 | + if (!store_name) | ||
| 6240 | + store_name = getApp().globalData.setting.appName; | ||
| 6241 | + return { | ||
| 6242 | + title: this.data.data.goods_name + '-' + store_name, | ||
| 6243 | + imageUrl: this.data.gallery[0].image_url, | ||
| 6244 | + } | ||
| 6245 | + }, | ||
| 6084 | 6246 | ||
| 6085 | 6247 | ||
| 6086 | - clickCollapse() { | ||
| 6087 | - this.setData({ | ||
| 6088 | - flag: !this.data.flag, | ||
| 6089 | - }) | ||
| 6090 | - }, | 6248 | + clickCollapse() { |
| 6249 | + this.setData({ | ||
| 6250 | + flag: !this.data.flag, | ||
| 6251 | + }) | ||
| 6252 | + }, | ||
| 6091 | 6253 | ||
| 6092 | - clickShare() { | ||
| 6093 | - this.setData({ | ||
| 6094 | - share_hidden: true, | ||
| 6095 | - }); | ||
| 6096 | - }, | 6254 | + clickShare() { |
| 6255 | + this.setData({ | ||
| 6256 | + share_hidden: true, | ||
| 6257 | + }); | ||
| 6258 | + }, | ||
| 6097 | 6259 | ||
| 6098 | - send() { | ||
| 6099 | - this.setData({ | ||
| 6100 | - share_hidden: false, | ||
| 6101 | - }); | ||
| 6102 | - }, | 6260 | + send() { |
| 6261 | + this.setData({ | ||
| 6262 | + share_hidden: false, | ||
| 6263 | + }); | ||
| 6264 | + }, | ||
| 6103 | 6265 | ||
| 6104 | - cancel() { | ||
| 6105 | - this.setData({ | ||
| 6106 | - share_hidden: false, | ||
| 6107 | - }); | ||
| 6108 | - }, | 6266 | + cancel() { |
| 6267 | + this.setData({ | ||
| 6268 | + share_hidden: false, | ||
| 6269 | + }); | ||
| 6270 | + }, | ||
| 6109 | 6271 | ||
| 6110 | - //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动 | ||
| 6111 | - check_nor_promgood(goods_id, back) { | ||
| 6112 | - getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, { | ||
| 6113 | - success: function (res) { | ||
| 6114 | - if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) { | ||
| 6115 | - var obj = { | ||
| 6116 | - act_id: res.data.data.promGoodsLists[0].prom_id, | ||
| 6117 | - } | ||
| 6118 | - back(obj); | ||
| 6119 | - } else { | ||
| 6120 | - back(0) | ||
| 6121 | - } | ||
| 6122 | - } | ||
| 6123 | - }) | ||
| 6124 | - }, | 6272 | + //积分购和拼团的普通购买的的时候,要判断有没有全场优惠活动 |
| 6273 | + check_nor_promgood(goods_id, back) { | ||
| 6274 | + getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + goods_id, { | ||
| 6275 | + success: function (res) { | ||
| 6276 | + if (res.data.code == 0 && res.data.data && res.data.data.promGoodsLists && res.data.data.promGoodsLists.length > 0) { | ||
| 6277 | + var obj = { | ||
| 6278 | + act_id: res.data.data.promGoodsLists[0].prom_id, | ||
| 6279 | + } | ||
| 6280 | + back(obj); | ||
| 6281 | + } else { | ||
| 6282 | + back(0) | ||
| 6283 | + } | ||
| 6284 | + } | ||
| 6285 | + }) | ||
| 6286 | + }, | ||
| 6125 | 6287 | ||
| 6126 | - go_zh: function (e) { | ||
| 6127 | - var id = e.currentTarget.dataset.id; | ||
| 6128 | - getApp().goto("/packageB/pages/zuhegou/index/index?id=" + id); | ||
| 6129 | - }, | 6288 | + go_zh: function (e) { |
| 6289 | + var id = e.currentTarget.dataset.id; | ||
| 6290 | + getApp().goto("/packageB/pages/zuhegou/index/index?id=" + id); | ||
| 6291 | + }, | ||
| 6130 | 6292 | ||
| 6131 | - check_zh_acting: function (func) { | ||
| 6132 | - var isok = 1, item = this.data.sele_g; | ||
| 6133 | - //如果有组合购 | ||
| 6134 | - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | ||
| 6135 | - getApp().request.promiseGet(url, {}).then(res => { | ||
| 6136 | - if (res.data.code == 0 && res.data.data) { | ||
| 6137 | - if (res.data.data.is_show != 1) { | ||
| 6138 | - isok = 0; | ||
| 6139 | - } | ||
| 6140 | - //如果活动已经结束 | ||
| 6141 | - if (res.data.data.is_end == 1) { | ||
| 6142 | - isok = 0; | ||
| 6143 | - } | ||
| 6144 | - //已经结束 | ||
| 6145 | - if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 6146 | - isok = 0; | ||
| 6147 | - } | ||
| 6148 | - //还未开始 | ||
| 6149 | - if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 6150 | - isok = 0; | ||
| 6151 | - } | 6293 | + check_zh_acting: function (func) { |
| 6294 | + var isok = 1, item = this.data.sele_g; | ||
| 6295 | + //如果有组合购 | ||
| 6296 | + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item.prom_id + "/" + getApp().globalData.user_id; | ||
| 6297 | + getApp().request.promiseGet(url, {}).then(res => { | ||
| 6298 | + if (res.data.code == 0 && res.data.data) { | ||
| 6299 | + if (res.data.data.is_show != 1) { | ||
| 6300 | + isok = 0; | ||
| 6301 | + } | ||
| 6302 | + //如果活动已经结束 | ||
| 6303 | + if (res.data.data.is_end == 1) { | ||
| 6304 | + isok = 0; | ||
| 6305 | + } | ||
| 6306 | + //已经结束 | ||
| 6307 | + if (ut.gettimestamp() > res.data.data.end_time) { | ||
| 6308 | + isok = 0; | ||
| 6309 | + } | ||
| 6310 | + //还未开始 | ||
| 6311 | + if (ut.gettimestamp() < res.data.data.start_time) { | ||
| 6312 | + isok = 0; | ||
| 6313 | + } | ||
| 6152 | 6314 | ||
| 6153 | - } else { | ||
| 6154 | - //未找到商品的活动 | ||
| 6155 | - isok = 0; | ||
| 6156 | - } | ||
| 6157 | - item.act = res.data.data; | ||
| 6158 | - func(isok); | ||
| 6159 | - }) | ||
| 6160 | - }, | 6315 | + } else { |
| 6316 | + //未找到商品的活动 | ||
| 6317 | + isok = 0; | ||
| 6318 | + } | ||
| 6319 | + item.act = res.data.data; | ||
| 6320 | + func(isok); | ||
| 6321 | + }) | ||
| 6322 | + }, | ||
| 6161 | 6323 | ||
| 6162 | //获取更多秒杀 | 6324 | //获取更多秒杀 |
| 6163 | get_more_flahs: async function (func) { | 6325 | get_more_flahs: async function (func) { |
| 6164 | - var f_more=false; | ||
| 6165 | - var user_id=getApp().globalData.user_id; | ||
| 6166 | - if(!user_id) user_id=0; | 6326 | + var f_more = false; |
| 6327 | + var user_id = getApp().globalData.user_id; | ||
| 6328 | + if (!user_id) user_id = 0; | ||
| 6167 | 6329 | ||
| 6168 | - var url="/api/weshop/goods/listSkuFlash?store_id="+os.stoid+"&goods_id="+this.data.data.goods_id+"&user_id="+user_id; | ||
| 6169 | - //获取秒杀的多规格 | ||
| 6170 | - await getApp().request.promiseGet(url, {}).then(res=>{ | ||
| 6171 | - if(res.data.code==0 && res.data.data && res.data.data.length>0){ | ||
| 6172 | - f_more=res.data.data; | 6330 | + var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.data.goods_id + "&user_id=" + user_id; |
| 6331 | + //获取秒杀的多规格 | ||
| 6332 | + await getApp().request.promiseGet(url, {}).then(res => { | ||
| 6333 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
| 6334 | + f_more = res.data.data; | ||
| 6173 | } | 6335 | } |
| 6174 | }) | 6336 | }) |
| 6175 | - if(!f_more) { | 6337 | + if (!f_more) { |
| 6176 | func(false); | 6338 | func(false); |
| 6177 | return false; | 6339 | return false; |
| 6178 | } | 6340 | } |
| 6179 | //-- 秒杀的价格要更新 -- | 6341 | //-- 秒杀的价格要更新 -- |
| 6180 | - for(let i in f_more){ | 6342 | + for (let i in f_more) { |
| 6181 | 6343 | ||
| 6182 | - let item=f_more[i]; | ||
| 6183 | - f_more[i].prom_id=item.act_id; | ||
| 6184 | - f_more[i].prom_type=1; | ||
| 6185 | - if(item.goods_id==this.data.data.goods_id){ | ||
| 6186 | - continue; | 6344 | + let item = f_more[i]; |
| 6345 | + f_more[i].prom_id = item.act_id; | ||
| 6346 | + f_more[i].prom_type = 1; | ||
| 6347 | + if (item.goods_id == this.data.data.goods_id) { | ||
| 6348 | + continue; | ||
| 6187 | } | 6349 | } |
| 6188 | - var url="/api/ms/flash_sale/getNew/"+os.stoid+"/"+user_id+"/"+item.act_id; | ||
| 6189 | - await getApp().request.promiseGet(url, {}).then(rs=>{ | ||
| 6190 | - if(rs.data.code==0){ | ||
| 6191 | - f_more[i].price=rs.data.data.user_price; | 6350 | + var url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + item.act_id; |
| 6351 | + await getApp().request.promiseGet(url, {}).then(rs => { | ||
| 6352 | + if (rs.data.code == 0) { | ||
| 6353 | + f_more[i].price = rs.data.data.user_price; | ||
| 6192 | 6354 | ||
| 6193 | - } | 6355 | + } |
| 6194 | }) | 6356 | }) |
| 6195 | } | 6357 | } |
| 6196 | func(f_more); | 6358 | func(f_more); |
| @@ -6198,57 +6360,58 @@ Page({ | @@ -6198,57 +6360,58 @@ Page({ | ||
| 6198 | }, | 6360 | }, |
| 6199 | 6361 | ||
| 6200 | //-- 判断是否有秒杀 -- | 6362 | //-- 判断是否有秒杀 -- |
| 6201 | - check_has_flash:function () { | ||
| 6202 | - var th=this; | ||
| 6203 | - var url="/api/weshop/activitylist/getGoodActInfo"; | ||
| 6204 | - var user_id=getApp().globalData.user_id; | ||
| 6205 | - if(!user_id) user_id=0; | ||
| 6206 | - | ||
| 6207 | - var req_data={ | ||
| 6208 | - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id | 6363 | + check_has_flash: function () { |
| 6364 | + var th = this; | ||
| 6365 | + var url = "/api/weshop/activitylist/getGoodActInfo"; | ||
| 6366 | + var user_id = getApp().globalData.user_id; | ||
| 6367 | + if (!user_id) user_id = 0; | ||
| 6368 | + | ||
| 6369 | + var req_data = { | ||
| 6370 | + store_id: os.stoid, goodsidlist: this.data.data.goods_id, is_detail: 1, user_id: user_id | ||
| 6209 | }; | 6371 | }; |
| 6210 | //获取秒杀的多规格 | 6372 | //获取秒杀的多规格 |
| 6211 | - getApp().request.promiseGet(url, {data:req_data}).then(async function (res) { | ||
| 6212 | - if(res.data.code==0 && res.data.data && res.data.data.length){ | ||
| 6213 | - var arr_data=res.data.data; | ||
| 6214 | - var new_arr=[]; | ||
| 6215 | - for(let i in arr_data){ | ||
| 6216 | - let item=arr_data[i]; | 6373 | + getApp().request.promiseGet(url, {data: req_data}).then(async function (res) { |
| 6374 | + if (res.data.code == 0 && res.data.data && res.data.data.length) { | ||
| 6375 | + var arr_data = res.data.data; | ||
| 6376 | + var new_arr = []; | ||
| 6377 | + for (let i in arr_data) { | ||
| 6378 | + let item = arr_data[i]; | ||
| 6217 | //找不到活动要剔除 | 6379 | //找不到活动要剔除 |
| 6218 | - if(!item.act_name) continue; | ||
| 6219 | - if(item.prom_type!=1) continue; | 6380 | + if (!item.act_name) continue; |
| 6381 | + if (item.prom_type != 1) continue; | ||
| 6220 | new_arr.push(item); | 6382 | new_arr.push(item); |
| 6221 | } | 6383 | } |
| 6222 | 6384 | ||
| 6223 | - if(new_arr.length==1){ | ||
| 6224 | - th.data.prom_id=new_arr[0].act_id; | ||
| 6225 | - th.data.prom_type=new_arr[0].prom_type; | 6385 | + if (new_arr.length == 1) { |
| 6386 | + th.data.prom_id = new_arr[0].act_id; | ||
| 6387 | + th.data.prom_type = new_arr[0].prom_type; | ||
| 6226 | } | 6388 | } |
| 6227 | 6389 | ||
| 6228 | - th.setData({more_flash:new_arr}); | 6390 | + th.setData({more_flash: new_arr}); |
| 6229 | } | 6391 | } |
| 6230 | }) | 6392 | }) |
| 6231 | }, | 6393 | }, |
| 6232 | 6394 | ||
| 6233 | //-- 跳转到秒杀商品详情页 -- | 6395 | //-- 跳转到秒杀商品详情页 -- |
| 6234 | - go_more_flash:function (e) { | ||
| 6235 | - var prom_id=e.currentTarget.dataset.id; | ||
| 6236 | - var goods_id=this.data.data.goods_id; | ||
| 6237 | - var url="/pages/goods/goodsInfo/goodsInfo?goods_id="+goods_id+"&prom_id="+prom_id+"&prom_type=1"; | 6396 | + go_more_flash: function (e) { |
| 6397 | + var prom_id = e.currentTarget.dataset.id; | ||
| 6398 | + var goods_id = this.data.data.goods_id; | ||
| 6399 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + goods_id + "&prom_id=" + prom_id + "&prom_type=1"; | ||
| 6238 | getApp().goto(url); | 6400 | getApp().goto(url); |
| 6239 | }, | 6401 | }, |
| 6240 | 6402 | ||
| 6241 | - close_pop_more:function () { | ||
| 6242 | - this.setData({is_pop_more:0}) | 6403 | + close_pop_more: function () { |
| 6404 | + this.setData({is_pop_more: 0}) | ||
| 6243 | }, | 6405 | }, |
| 6244 | 6406 | ||
| 6245 | - con_weixin:function () { | ||
| 6246 | - var url=this.data.sys_switch.weapp_customertype_url; | ||
| 6247 | - var id=this.data.sys_switch.weapp_customertype_appid; | 6407 | + con_weixin: function () { |
| 6408 | + var url = this.data.sys_switch.weapp_customertype_url; | ||
| 6409 | + var id = this.data.sys_switch.weapp_customertype_appid; | ||
| 6248 | wx.openCustomerServiceChat({ | 6410 | wx.openCustomerServiceChat({ |
| 6249 | extInfo: {url: url}, | 6411 | extInfo: {url: url}, |
| 6250 | corpId: id, | 6412 | corpId: id, |
| 6251 | - success(res) {} | 6413 | + success(res) { |
| 6414 | + } | ||
| 6252 | }) | 6415 | }) |
| 6253 | }, | 6416 | }, |
| 6254 | get_normal(gid){ | 6417 | get_normal(gid){ |
| @@ -6258,41 +6421,102 @@ Page({ | @@ -6258,41 +6421,102 @@ Page({ | ||
| 6258 | }); | 6421 | }); |
| 6259 | this.get_sku(os.stoid, this.data.data, gid); | 6422 | this.get_sku(os.stoid, this.data.data, gid); |
| 6260 | this.get_sto(); | 6423 | this.get_sto(); |
| 6261 | - this.check_is_youhui(gid,1); | ||
| 6262 | - this.data.is_normal=1; | 6424 | + this.check_is_youhui(gid, 1); |
| 6425 | + this.data.is_normal = 1; | ||
| 6263 | }, | 6426 | }, |
| 6264 | 6427 | ||
| 6265 | - | ||
| 6266 | - // 促销 -> 送礼包 -> 查看详情 | ||
| 6267 | - viewLbDetails(e) { | ||
| 6268 | - let id = e.currentTarget.dataset.id; // 获取礼包id | ||
| 6269 | - let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | ||
| 6270 | - // console.log('myurl', url); | ||
| 6271 | - getApp().goto(url); | ||
| 6272 | - }, | ||
| 6273 | 6428 | ||
| 6274 | - go_more_ladder:function (e) { | ||
| 6275 | - var prom_id=e.currentTarget.dataset.id; | ||
| 6276 | - getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id); | 6429 | + // 促销 -> 送礼包 -> 查看详情 |
| 6430 | + viewLbDetails(e) { | ||
| 6431 | + let id = e.currentTarget.dataset.id; // 获取礼包id | ||
| 6432 | + let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | ||
| 6433 | + // console.log('myurl', url); | ||
| 6434 | + getApp().goto(url); | ||
| 6435 | + }, | ||
| 6436 | + | ||
| 6437 | + go_more_ladder: function (e) { | ||
| 6438 | + var prom_id = e.currentTarget.dataset.id; | ||
| 6439 | + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id=" + prom_id); | ||
| 6277 | }, | 6440 | }, |
| 6278 | 6441 | ||
| 6279 | getHistoryBuy() { | 6442 | getHistoryBuy() { |
| 6280 | - let _this=this; | ||
| 6281 | - let req_data = { | ||
| 6282 | - store_id:os.stoid, | ||
| 6283 | - goods_id:this.data.gid, | ||
| 6284 | - pay_status:1, | ||
| 6285 | - rndid:1 | ||
| 6286 | - }; | ||
| 6287 | - getApp().request.promiseGet('/api/weshop/ordergoods/list',{ | ||
| 6288 | - data:req_data, | ||
| 6289 | - }) | ||
| 6290 | - .then(res=>{ | ||
| 6291 | - if(t.ajax_ok(res)){ | ||
| 6292 | - _this.setData({ | ||
| 6293 | - historyBuyInfo:res.data.data.pageData, | ||
| 6294 | - }) | 6443 | + let _this = this; |
| 6444 | + let req_data = { | ||
| 6445 | + store_id: os.stoid, | ||
| 6446 | + goods_id: this.data.gid, | ||
| 6447 | + pay_status: 1, | ||
| 6448 | + rndid: 1 | ||
| 6449 | + }; | ||
| 6450 | + getApp().request.promiseGet('/api/weshop/ordergoods/list', { | ||
| 6451 | + data: req_data, | ||
| 6452 | + }) | ||
| 6453 | + .then(res => { | ||
| 6454 | + if (t.ajax_ok(res)) { | ||
| 6455 | + _this.setData({ | ||
| 6456 | + historyBuyInfo: res.data.data.pageData, | ||
| 6457 | + }) | ||
| 6458 | + } | ||
| 6459 | + }) | ||
| 6460 | + }, | ||
| 6461 | + | ||
| 6462 | + //-- 检验商品的活动情况 -- | ||
| 6463 | + check_gd_prom_new: function (func) { | ||
| 6464 | + var th = this; | ||
| 6465 | + var user_id = getApp().globalData.user_id; | ||
| 6466 | + if (!user_id) user_id = 0; | ||
| 6467 | + | ||
| 6468 | + var url = '/api/weshop/activitylist/listGoodActInfo2'; | ||
| 6469 | + var req_d = { | ||
| 6470 | + "store_id": os.stoid, | ||
| 6471 | + "goods_id": this.data.gid, | ||
| 6472 | + "user_id": user_id, | ||
| 6295 | } | 6473 | } |
| 6296 | - }) | 6474 | + getApp().request.get(url, { |
| 6475 | + data: req_d, | ||
| 6476 | + success: function (e) { | ||
| 6477 | + if (e.data.code == 0 && e.data.data && e.data.data.length > 0) { | ||
| 6478 | + var arr = e.data.data; | ||
| 6479 | + var arr2 = arr.filter(function (e) { | ||
| 6480 | + return e.s_time < ut.gettimestamp(); | ||
| 6481 | + }) | ||
| 6482 | + //-- 如果只有一个活动的话 -- | ||
| 6483 | + if (arr.length == 1) { | ||
| 6484 | + th.data.prom_type = arr[0].prom_type; | ||
| 6485 | + th.data.prom_id = arr[0].act_id; | ||
| 6486 | + } | ||
| 6487 | + //-- 如果只有一个进行中的活动的话 -- | ||
| 6488 | + else if (arr2.length == 1) { | ||
| 6489 | + th.data.prom_type = arr2[0].prom_type; | ||
| 6490 | + th.data.prom_id = arr2[0].act_id; | ||
| 6491 | + } | ||
| 6492 | + } | ||
| 6493 | + //-- 调用回调 -- | ||
| 6494 | + func(); | ||
| 6495 | + } | ||
| 6496 | + }); | ||
| 6497 | + }, | ||
| 6498 | + | ||
| 6499 | + //-- 秒杀的普通购买 -- | ||
| 6500 | + openSpecModel_Nor: function () { | ||
| 6501 | + this.data.g_buy_num = new Map(); | ||
| 6502 | + var th = this; | ||
| 6503 | + this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 | ||
| 6504 | + if (th.data.sku_g_pt) { | ||
| 6505 | + this.get_sto(1) | ||
| 6506 | + this.setData({openSpecModal_flash_normal: 1}); | ||
| 6507 | + } else { | ||
| 6508 | + th.get_sto(1); | ||
| 6509 | + th.get_sku(o.stoid, th.data.data, th.data.gid, 1, function () { | ||
| 6510 | + th.setData({ | ||
| 6511 | + openSpecModal_flash_normal: 1 | ||
| 6512 | + }); | ||
| 6513 | + }); | ||
| 6514 | + } | ||
| 6515 | + this.check_is_youhui(th.data.gid, 1); | ||
| 6516 | + }, | ||
| 6517 | + | ||
| 6518 | + closeSpecModal_flash_normal: function () { | ||
| 6519 | + this.setData({openSpecModal_flash_normal: 0}); | ||
| 6297 | } | 6520 | } |
| 6298 | -}); | 6521 | + |
| 6522 | +}) |
pages/goods/goodsInfo/goodsInfo.wxml
| @@ -568,6 +568,7 @@ | @@ -568,6 +568,7 @@ | ||
| 568 | <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view> | 568 | <view class="tick lh2 pdr20" wx:if="{{item.couponId>0}}">送{{item.couponMoney}}元优惠券</view> |
| 569 | <view class="tick ellipsis-1x lh2" wx:if="{{item.gift_id>0}}">送商品{{item.goods_name}}</view> | 569 | <view class="tick ellipsis-1x lh2" wx:if="{{item.gift_id>0}}">送商品{{item.goods_name}}</view> |
| 570 | <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view> | 570 | <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.lb_id>0}}" data-id="{{item.lb_id}}" bindtap="viewLbDetails">送{{item.lbtitle}}</view> |
| 571 | + <view class="tick ellipsis-1x lh2 details pdr40" wx:if="{{item.zxlb_id>0}}" data-id="{{item.zxlb_id}}" bindtap="viewLbDetails2">送{{item.zxlbtitle}}</view> | ||
| 571 | </view> | 572 | </view> |
| 572 | </view> | 573 | </view> |
| 573 | </view> | 574 | </view> |
| @@ -1003,6 +1004,7 @@ | @@ -1003,6 +1004,7 @@ | ||
| 1003 | <view bindtap="doScrollTop" class="toTop" wx:if="{{supportPageScroll}}"> | 1004 | <view bindtap="doScrollTop" class="toTop" wx:if="{{supportPageScroll}}"> |
| 1004 | <image class="wh100" src="{{iurl}}/miniapp/images/topup.png"></image> | 1005 | <image class="wh100" src="{{iurl}}/miniapp/images/topup.png"></image> |
| 1005 | </view> | 1006 | </view> |
| 1007 | + | ||
| 1006 | <!-- -----------------底部按钮------------------ --> | 1008 | <!-- -----------------底部按钮------------------ --> |
| 1007 | <view class="join-cart"> | 1009 | <view class="join-cart"> |
| 1008 | <!-- bindtap="contactService" --> | 1010 | <!-- bindtap="contactService" --> |
| @@ -1053,14 +1055,34 @@ | @@ -1053,14 +1055,34 @@ | ||
| 1053 | <view bindtap="openSpecModel" data-ind="1" class="join-btn cart-btn">加入购物车</view> | 1055 | <view bindtap="openSpecModel" data-ind="1" class="join-btn cart-btn">加入购物车</view> |
| 1054 | <view bindtap="openSpecModel" data-ind="2" class="buy-btn cart-btn">立即抢购</view> | 1056 | <view bindtap="openSpecModel" data-ind="2" class="buy-btn cart-btn">立即抢购</view> |
| 1055 | </block> | 1057 | </block> |
| 1058 | + | ||
| 1056 | <block wx:if="{{prom_st==0 && !prom_r_null}}"> | 1059 | <block wx:if="{{prom_st==0 && !prom_r_null}}"> |
| 1057 | - <view class="buy-btn cart-btn cart-btn-lg lanse set_width">即将开始</view> | 1060 | + <!-- 秒杀预热要单独购买 --> |
| 1061 | + <block wx:if="{{prom_type==1 && prom_act.is_shop_buy}}"> | ||
| 1062 | + <view bindtap="openSpecModel_Nor" data-nor="1" class="join-btn cart-btn">单独购买</view> | ||
| 1063 | + <view class="buy-btn cart-btn lanse">即将开始</view> | ||
| 1064 | + </block> | ||
| 1065 | + <block wx:else> | ||
| 1066 | + <view class="buy-btn cart-btn cart-btn-lg lanse set_width">即将开始</view> | ||
| 1067 | + </block> | ||
| 1058 | </block> | 1068 | </block> |
| 1069 | + | ||
| 1070 | + | ||
| 1059 | <block wx:if="{{prom_r_null}}"> | 1071 | <block wx:if="{{prom_r_null}}"> |
| 1060 | - <view class="buy-btn cart-btn cart-btn-lg huise set_width">已抢光</view> | 1072 | + |
| 1073 | + <block wx:if="{{prom_type==1 && prom_act.is_shop_buy}}"> | ||
| 1074 | + <view bindtap="openSpecModel_Nor" data-nor="1" class="join-btn cart-btn">单独购买</view> | ||
| 1075 | + <view class="buy-btn cart-btn huise">已抢光</view> | ||
| 1076 | + </block> | ||
| 1077 | + <view wx:else class="buy-btn cart-btn cart-btn-lg huise set_width">已抢光</view> | ||
| 1061 | </block> | 1078 | </block> |
| 1062 | <block wx:if="{{prom_st==3 && !prom_r_null}}"> | 1079 | <block wx:if="{{prom_st==3 && !prom_r_null}}"> |
| 1063 | - <view class="buy-btn cart-btn cart-btn-lg lanse set_width">活动已经结束</view> | 1080 | + <block wx:if="{{prom_type==1 && prom_act.is_shop_buy}}"> |
| 1081 | + <view bindtap="openSpecModel_Nor" data-nor="1" class="join-btn cart-btn">单独购买</view> | ||
| 1082 | + <view class="buy-btn cart-btn huise">活动已经结束</view> | ||
| 1083 | + </block> | ||
| 1084 | + | ||
| 1085 | + <view wx:else class="buy-btn cart-btn cart-btn-lg lanse set_width">活动已经结束</view> | ||
| 1064 | </block> | 1086 | </block> |
| 1065 | </block> | 1087 | </block> |
| 1066 | <!-- -----拼单------ --> | 1088 | <!-- -----拼单------ --> |
| @@ -1267,6 +1289,7 @@ | @@ -1267,6 +1289,7 @@ | ||
| 1267 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> | 1289 | <text wx:if="{{hui_condition.couponId>0}}">,送优惠券</text> |
| 1268 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> | 1290 | <text wx:if="{{hui_condition.gift_id>0}}">,送赠品</text> |
| 1269 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> | 1291 | <text wx:if="{{hui_condition.lb_id>0}}">,送礼包</text> |
| 1292 | + <text wx:if="{{hui_condition.zxlb_id>0}}">,送专享礼包</text> | ||
| 1270 | </view> | 1293 | </view> |
| 1271 | </view> | 1294 | </view> |
| 1272 | <view class="spec-cart-btns"> | 1295 | <view class="spec-cart-btns"> |
| @@ -1664,3 +1687,8 @@ | @@ -1664,3 +1687,8 @@ | ||
| 1664 | </view> | 1687 | </view> |
| 1665 | </view> | 1688 | </view> |
| 1666 | </view> | 1689 | </view> |
| 1690 | + | ||
| 1691 | +<!-- 弹起来,购买预热商品的普通购买 --> | ||
| 1692 | +<view hidden="{{!openSpecModal_flash_normal}}"> | ||
| 1693 | + <include src="buy_flash_normal.wxml" /> | ||
| 1694 | +</view> |
pages/user/index/index.js
| @@ -98,6 +98,10 @@ Page({ | @@ -98,6 +98,10 @@ Page({ | ||
| 98 | * 生命周期函数--监听页面显示 | 98 | * 生命周期函数--监听页面显示 |
| 99 | */ | 99 | */ |
| 100 | onShow: function() { | 100 | onShow: function() { |
| 101 | + | ||
| 102 | + | ||
| 103 | + | ||
| 104 | + | ||
| 101 | //看一下小程序是不是过期了 | 105 | //看一下小程序是不是过期了 |
| 102 | getApp().getConfig2(function(config2){ | 106 | getApp().getConfig2(function(config2){ |
| 103 | if(config2 && config2.is_overdue==1){ | 107 | if(config2 && config2.is_overdue==1){ |
| @@ -127,6 +131,17 @@ Page({ | @@ -127,6 +131,17 @@ Page({ | ||
| 127 | 131 | ||
| 128 | 132 | ||
| 129 | var th=this; | 133 | var th=this; |
| 134 | + | ||
| 135 | + // 判断是否开启美业 | ||
| 136 | + getApp().promiseGet('/api/weshop/store/getTabSys/' + os.stoid, {}).then(res => { | ||
| 137 | + if(res.data.code == 0) { | ||
| 138 | + th.setData({ | ||
| 139 | + enableMeiye: res.data.data.EnableMeiye, | ||
| 140 | + }); | ||
| 141 | + }; | ||
| 142 | + }); | ||
| 143 | + | ||
| 144 | + | ||
| 130 | getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + os.stoid, {}).then(res => { | 145 | getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + os.stoid, {}).then(res => { |
| 131 | if(res.data.code==0){ | 146 | if(res.data.code==0){ |
| 132 | var plusCard = res.data.data; | 147 | var plusCard = res.data.data; |
pages/user/index/index.wxml
| @@ -241,7 +241,13 @@ | @@ -241,7 +241,13 @@ | ||
| 241 | <image class="xc-center-img" src="{{iurl+item.icoimg}}"></image> | 241 | <image class="xc-center-img" src="{{iurl+item.icoimg}}"></image> |
| 242 | <view class="fs26">我的权益</view> | 242 | <view class="fs26">我的权益</view> |
| 243 | </view> | 243 | </view> |
| 244 | - </block> | 244 | + </block> |
| 245 | + <block wx:elif="{{item.name=='套盒商品'}}"> | ||
| 246 | + <view class="item t-c" data-url="{{item.weappurl}}" bindtap="goto" wx:if="{{enableMeiye}}"> | ||
| 247 | + <image class="xc-center-img" src="{{iurl+item.icoimg}}"></image> | ||
| 248 | + <view class="fs26">套盒商品</view> | ||
| 249 | + </view> | ||
| 250 | + </block> | ||
| 245 | <block wx:else> | 251 | <block wx:else> |
| 246 | <view class="item t-c" data-url="{{item.weappurl}}" bindtap="goto_nav"> | 252 | <view class="item t-c" data-url="{{item.weappurl}}" bindtap="goto_nav"> |
| 247 | <image class="xc-center-img" src="{{iurl+item.icoimg}}"></image> | 253 | <image class="xc-center-img" src="{{iurl+item.icoimg}}"></image> |
pages/user/order_detail/order_detail.js
| @@ -1149,12 +1149,21 @@ Page({ | @@ -1149,12 +1149,21 @@ Page({ | ||
| 1149 | } | 1149 | } |
| 1150 | }) | 1150 | }) |
| 1151 | //----已经结束----- | 1151 | //----已经结束----- |
| 1152 | - if (flash && flash.is_end == 0 && flash.end_time > timestamp && flash.start_time < timestamp) { | ||
| 1153 | - prom = flash; | ||
| 1154 | - prom.price = prom.user_price; | ||
| 1155 | - b_item.price = prom.price; | ||
| 1156 | - good.prom_type = 1; | ||
| 1157 | - good.prom_id = prom.id; | 1152 | + if (flash && flash.is_end == 0) { |
| 1153 | + | ||
| 1154 | + if( flash.end_time > timestamp && flash.start_time < timestamp){ | ||
| 1155 | + prom = flash; | ||
| 1156 | + prom.price = prom.user_price; | ||
| 1157 | + b_item.price = prom.price; | ||
| 1158 | + good.prom_type = 1; | ||
| 1159 | + good.prom_id = prom.id; | ||
| 1160 | + }else{ | ||
| 1161 | + if(g_item.prom_type==0 && !flash.is_shop_buy ){ | ||
| 1162 | + err_text+=g_item['goods_name']+"秒杀活动不允许普通价\n"; | ||
| 1163 | + continue; | ||
| 1164 | + } | ||
| 1165 | + } | ||
| 1166 | + | ||
| 1158 | } | 1167 | } |
| 1159 | break; | 1168 | break; |
| 1160 | case 2: | 1169 | case 2: |
| @@ -1398,8 +1407,11 @@ Page({ | @@ -1398,8 +1407,11 @@ Page({ | ||
| 1398 | redis_num = res.data.data; | 1407 | redis_num = res.data.data; |
| 1399 | }); | 1408 | }); |
| 1400 | if(redis_num<=0){ | 1409 | if(redis_num<=0){ |
| 1401 | - err_text+= good['goods_name']+"活动不足\n"; | ||
| 1402 | - continue; | 1410 | + //不允许商品普通价格修改 |
| 1411 | + if(!prom.is_shop_buy && prom.is_shop_buy!=undefined) { | ||
| 1412 | + err_text += good['goods_name'] + "活动不足\n"; | ||
| 1413 | + continue; | ||
| 1414 | + } | ||
| 1403 | } | 1415 | } |
| 1404 | 1416 | ||
| 1405 | } | 1417 | } |
pages/user/order_list/order_list.js
| @@ -1351,7 +1351,7 @@ Page({ | @@ -1351,7 +1351,7 @@ Page({ | ||
| 1351 | 1351 | ||
| 1352 | var url="/api/weshop/activitylist/getGoodActInfo"; | 1352 | var url="/api/weshop/activitylist/getGoodActInfo"; |
| 1353 | var req_data={ | 1353 | var req_data={ |
| 1354 | - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id | 1354 | + store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id,timetype:0 |
| 1355 | }; | 1355 | }; |
| 1356 | await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ | 1356 | await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ |
| 1357 | if(res.data.code==0){ | 1357 | if(res.data.code==0){ |
| @@ -1367,16 +1367,25 @@ Page({ | @@ -1367,16 +1367,25 @@ Page({ | ||
| 1367 | switch (good.prom_type) { | 1367 | switch (good.prom_type) { |
| 1368 | case 1: | 1368 | case 1: |
| 1369 | var flash = null; | 1369 | var flash = null; |
| 1370 | - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + good.prom_id, {}).then(res => { | 1370 | + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + getApp().globalData.user_id + "/" + good.prom_id, {}).then(res => { |
| 1371 | if (res.data.code == 0) { | 1371 | if (res.data.code == 0) { |
| 1372 | flash = res.data.data; | 1372 | flash = res.data.data; |
| 1373 | } | 1373 | } |
| 1374 | }) | 1374 | }) |
| 1375 | - //----已经结束----- | ||
| 1376 | - if (flash && flash.is_end == 0 && flash.end_time > timestamp && flash.start_time < timestamp) { | ||
| 1377 | - prom = flash; | ||
| 1378 | - prom.price = prom.user_price; | ||
| 1379 | - b_item.price = prom.user_price; | 1375 | + //----没有结束----- |
| 1376 | + if (flash && flash.is_end == 0 ) { | ||
| 1377 | + | ||
| 1378 | + if(flash.end_time > timestamp && flash.start_time < timestamp){ | ||
| 1379 | + prom = flash; | ||
| 1380 | + prom.price = prom.user_price; | ||
| 1381 | + b_item.price = prom.user_price; | ||
| 1382 | + }else{ | ||
| 1383 | + if(g_item.prom_type==0 && !flash.is_shop_buy ){ | ||
| 1384 | + err_text+=g_item['goods_name']+"秒杀活动不允许普通价\n"; | ||
| 1385 | + continue; | ||
| 1386 | + } | ||
| 1387 | + } | ||
| 1388 | + | ||
| 1380 | } | 1389 | } |
| 1381 | break; | 1390 | break; |
| 1382 | 1391 | ||
| @@ -1626,8 +1635,11 @@ Page({ | @@ -1626,8 +1635,11 @@ Page({ | ||
| 1626 | redis_num = res.data.data; | 1635 | redis_num = res.data.data; |
| 1627 | }); | 1636 | }); |
| 1628 | if(redis_num<=0){ | 1637 | if(redis_num<=0){ |
| 1629 | - err_text+= good['goods_name']+"活动不足\n"; | ||
| 1630 | - continue; | 1638 | + //不允许商品普通价格修改 |
| 1639 | + if(!prom.is_shop_buy && prom.is_shop_buy!=undefined ){ | ||
| 1640 | + err_text+= good['goods_name']+"活动不足\n"; | ||
| 1641 | + continue; | ||
| 1642 | + } | ||
| 1631 | } | 1643 | } |
| 1632 | 1644 | ||
| 1633 | } | 1645 | } |
utils/filter.wxs
| @@ -38,6 +38,28 @@ var filters = { | @@ -38,6 +38,28 @@ var filters = { | ||
| 38 | } | 38 | } |
| 39 | return fm; | 39 | return fm; |
| 40 | }, | 40 | }, |
| 41 | + | ||
| 42 | + format_time2: function (ts, isFull) { | ||
| 43 | + // 如果数值位数为1,则补0 | ||
| 44 | + function appendZero(obj) { | ||
| 45 | + if (obj < 10) { | ||
| 46 | + return "0" + "" + obj; | ||
| 47 | + } else { | ||
| 48 | + return obj; | ||
| 49 | + } | ||
| 50 | + }; | ||
| 51 | + | ||
| 52 | + if (ts == null || ts == undefined || ts == '') return ""; | ||
| 53 | + var d = getDate(ts) | ||
| 54 | + var fm = [appendZero(d.getFullYear()), appendZero(d.getMonth() + 1), appendZero(d.getDate())].join('-'); | ||
| 55 | + var md = appendZero(d.getMonth() + 1) + '月' + appendZero(d.getDate()) + '日'; | ||
| 56 | + if (isFull == 1) | ||
| 57 | + fm = fm + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes()), appendZero(d.getSeconds())].join(':'); | ||
| 58 | + if (isFull == 2) { | ||
| 59 | + fm = md + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes())].join(':'); | ||
| 60 | + } | ||
| 61 | + return fm; | ||
| 62 | + }, | ||
| 41 | 63 | ||
| 42 | pInt: function (t) { | 64 | pInt: function (t) { |
| 43 | var d = parseInt(t); | 65 | var d = parseInt(t); |
| @@ -184,6 +206,49 @@ var filters = { | @@ -184,6 +206,49 @@ var filters = { | ||
| 184 | }; | 206 | }; |
| 185 | }, | 207 | }, |
| 186 | 208 | ||
| 209 | + // 判断时间是否过期 | ||
| 210 | + isExpired: function(date) { | ||
| 211 | + var mydate = getDate(date).getTime(); | ||
| 212 | + var currentDate = getDate().getTime(); | ||
| 213 | + | ||
| 214 | + if(currentDate >= mydate) { | ||
| 215 | + return true; | ||
| 216 | + } else { | ||
| 217 | + return false; | ||
| 218 | + }; | ||
| 219 | + }, | ||
| 220 | + | ||
| 221 | + // 显示开始和结束日期 | ||
| 222 | + showStartAndEndDate: function(o) { | ||
| 223 | + var dateType = o.date_type; | ||
| 224 | + var currentDate = getDate().getTime(); | ||
| 225 | + var startDate, endDate, days, begin_days; | ||
| 226 | + | ||
| 227 | + if(dateType === 0) { | ||
| 228 | + days = (o.effective_days === 0 ? o.effective_days : (o.effective_days - 1)) * 24 * 60 * 60 * 1000; | ||
| 229 | + endDate = filters.format_time2(currentDate + days); | ||
| 230 | + currentDate = filters.format_time2(currentDate); | ||
| 231 | + return currentDate + '至' + endDate; | ||
| 232 | + }; | ||
| 233 | + | ||
| 234 | + if(dateType === 1) { | ||
| 235 | + return o.begin_date + '至' + o.effective_date; | ||
| 236 | + }; | ||
| 237 | + | ||
| 238 | + if(dateType === 2) { | ||
| 239 | + // N天后开始 | ||
| 240 | + begin_days = (o.begin_days === 0 ? o.begin_days : (o.begin_days - 1)) * 24 * 60 * 60 * 1000; | ||
| 241 | + // 有效天数 | ||
| 242 | + days = (o.effective_days - 1) * 24 * 60 * 60 * 1000; | ||
| 243 | + startDate = filters.format_time2(currentDate + begin_days); | ||
| 244 | + endDate = filters.format_time2(getDate(startDate).getTime() + days); | ||
| 245 | + return startDate + '至' + endDate; | ||
| 246 | + } | ||
| 247 | + | ||
| 248 | + // console.log('999***', currentDate); | ||
| 249 | + // return currentDate.toLocaleDateString(); | ||
| 250 | + }, | ||
| 251 | + | ||
| 187 | 252 | ||
| 188 | 253 | ||
| 189 | }; | 254 | }; |
| @@ -206,4 +271,6 @@ module.exports = { | @@ -206,4 +271,6 @@ module.exports = { | ||
| 206 | div100: filters.div100, | 271 | div100: filters.div100, |
| 207 | JSONStringify: filters.JSONStringify, | 272 | JSONStringify: filters.JSONStringify, |
| 208 | count: filters.count, | 273 | count: filters.count, |
| 274 | + isExpired: filters.isExpired, | ||
| 275 | + showStartAndEndDate: filters.showStartAndEndDate, | ||
| 209 | } | 276 | } |
| 210 | \ No newline at end of file | 277 | \ No newline at end of file |