Commit 340aa305316a340102d2858042a833aed2022f6a
1 parent
40e607aa
拼团商品详情页面的优化
Showing
5 changed files
with
3671 additions
and
4227 deletions
packageA/pages/serviceCard_pd/goodsInfo/buy_pt.wxml
| ... | ... | @@ -5,18 +5,13 @@ |
| 5 | 5 | |
| 6 | 6 | <!-- 商品名称 --> |
| 7 | 7 | <view class="spec-goods"> |
| 8 | - <image class="wh100 spec-img xc-distance-bottom" bindtap="previewImage" src="{{data.original_img}}" binderror="pop_err_img" data-errorimg="data.original_img"></image> | |
| 8 | + <image class="wh100 spec-img" src="{{iurl}}{{data.image_url?data.image_url:'miniapp/images/default_g_img.gif'}}" | |
| 9 | + binderror="pop_err_img" data-errorimg="data.image_url" /> | |
| 9 | 10 | <view class="spec-goods-info"> |
| 10 | - <view class="spec-goods-name ellipsis-1">{{sele_g.goods_name}}</view> | |
| 11 | - <view class="flex ai_end xc-val-money {{sele_g[card_field]}}" > | |
| 11 | + <view class="spec-goods-name ellipsis-1">{{sele_g.serviceName}}</view> | |
| 12 | + <view class="flex ai_end xc-val-money" > | |
| 12 | 13 | <view class="spec-goods-price" wx:if="{{is_normal==1}}" > |
| 13 | - <!-- 如果是等级会员,且有等级价 --> | |
| 14 | - <block wx:if="{{card_field && sele_g[card_field]>0}}"> | |
| 15 | - ¥ {{sele_g[card_field]}} | |
| 16 | - </block> | |
| 17 | - <block wx:else> | |
| 18 | - ¥ {{sele_g.shop_price}} | |
| 19 | - </block> | |
| 14 | + ¥ {{sele_g.money}} | |
| 20 | 15 | </view> |
| 21 | 16 | <view class="spec-goods-price" wx:else>¥ {{prom_price}}</view> |
| 22 | 17 | </view> |
| ... | ... | @@ -24,11 +19,7 @@ |
| 24 | 19 | <block wx:if="{{is_normal==1}}"> |
| 25 | 20 | <view class="flex"> |
| 26 | 21 | <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view> |
| 27 | - <block wx:if="{{sales_rules==2}}"> | |
| 28 | - <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view> | |
| 29 | - <view class="spec-goods-stock" wx:else>可售:0</view> | |
| 30 | - </block> | |
| 31 | - <block wx:else><view class="spec-goods-stock">可售:{{sele_g.store_count}}</view></block> | |
| 22 | + <block><view class="spec-goods-stock">可售:{{sele_g.store_count}}</view></block> | |
| 32 | 23 | </view> |
| 33 | 24 | </block> |
| 34 | 25 | <block wx:if="{{is_normal==0}}"> |
| ... | ... | @@ -63,11 +54,11 @@ |
| 63 | 54 | <view class="fs28 xc-ash-9f">选择门店</view> |
| 64 | 55 | </view> |
| 65 | 56 | |
| 66 | - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view> | |
| 57 | + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view> | |
| 67 | 58 | </view> |
| 68 | 59 | <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view> |
| 69 | 60 | <view class="no_store" wx:elif="{{is_normal && def_pick_store && def_pick_store.CanOutQty<=0}}">(库存不足)</view> |
| 70 | - <view class="fs24 xc-ash-9f xc-distance-top "wx:if="{{def_pick_store && def_pick_store.pickup_name}}">地址:{{def_pick_store.fulladdress}}</view> | |
| 61 | + <view class="fs24 xc-ash-9f xc-distance-top" wx:if="{{def_pick_store && def_pick_store.pickup_name}}">地址:{{def_pick_store.fulladdress}}</view> | |
| 71 | 62 | </view> |
| 72 | 63 | <!----商品的属性项目----> |
| 73 | 64 | <view> | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/filter.wxs
| ... | ... | @@ -20,8 +20,19 @@ function act_type(ty){ |
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | +//拿来判断是不是在指定门店内 | |
| 24 | +function is_no_dis(text,val){ | |
| 25 | + if(text==undefined) return false; | |
| 26 | + if(text=='') return false; | |
| 27 | + if(!text) return false; | |
| 28 | + | |
| 29 | + if(text.indexOf(val)==-1) return true; | |
| 30 | + return false; | |
| 31 | +} | |
| 32 | + | |
| 23 | 33 | module.exports = { |
| 24 | 34 | is_has: is_has, |
| 25 | 35 | format_tt:format_tt, |
| 26 | - act_type:act_type | |
| 36 | + act_type:act_type, | |
| 37 | + is_no_dis:is_no_dis | |
| 27 | 38 | } | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.js
Changes suppressed. Click to show
| ... | ... | @@ -3,4270 +3,3343 @@ var ut = require("../../../../utils/util.js"), |
| 3 | 3 | e = require("../../../../utils/common.js"), |
| 4 | 4 | oo = getApp().globalData, |
| 5 | 5 | os = oo.setting; |
| 6 | +var s=getApp(); | |
| 6 | 7 | //评价加载更多 |
| 7 | -var more = function(e) { | |
| 8 | - return e && e.__esModule ? e : { | |
| 9 | - default: e | |
| 10 | - }; | |
| 8 | +var more = function (e) { | |
| 9 | + return e && e.__esModule ? e : { | |
| 10 | + default: e | |
| 11 | + }; | |
| 11 | 12 | }(require("../../../../utils/LoadMore.js")), |
| 12 | 13 | n = new more.default(); |
| 13 | 14 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
| 14 | 15 | |
| 15 | 16 | Page({ |
| 16 | - data: { | |
| 17 | - start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | |
| 18 | - color_type: 0, //线条控制 | |
| 19 | - color_type_one: 0, | |
| 20 | - color_type_two: 1, | |
| 21 | - gid: "", | |
| 22 | - stoid: os.stoid, | |
| 23 | - url: os.url, | |
| 24 | - resourceUrl: os.h5_url, //公众号那边的图片文件域名 | |
| 25 | - iurl: os.imghost, | |
| 26 | - | |
| 27 | - data: null, | |
| 28 | - content: "", //商品详情 | |
| 29 | - | |
| 30 | - gallery: null, //图片滚动 | |
| 31 | - is_collect: 0, | |
| 32 | - collect_id: 0, | |
| 33 | - cartGoodsNum: 0, | |
| 34 | - specSelect: 0, | |
| 35 | - optionItemId: 0, | |
| 36 | - goodsInputNum: 1, | |
| 37 | - openSpecModal: !1, | |
| 38 | - | |
| 39 | - activeCategoryId: 0, | |
| 40 | - supportPageScroll: !1, | |
| 41 | - address: { | |
| 42 | - address: "", | |
| 43 | - district: 0, | |
| 44 | - }, | |
| 45 | - shipping: "", | |
| 46 | - shippingCost: 0, | |
| 47 | - enterAddressPage: !1, | |
| 48 | - categories: [{ | |
| 49 | - name: "卡项", | |
| 50 | - id: 0 | |
| 51 | - }, { | |
| 52 | - name: "详情", | |
| 53 | - id: 1 | |
| 54 | - },{ | |
| 55 | - name: "评价", | |
| 56 | - id: 2 | |
| 57 | - }], | |
| 58 | - activeCategoryId2: 0, | |
| 59 | - categories2: [{ | |
| 60 | - name: "商品详情", | |
| 61 | - id: 0 | |
| 62 | - }, { | |
| 63 | - name: "规格参数", | |
| 64 | - id: 1 | |
| 65 | - }], | |
| 66 | - activeCategoryId3: 1, // 点击评价-全部、有图、好评、中评时对应的id | |
| 67 | - categories3: [{ | |
| 68 | - name: "全部", | |
| 69 | - id: 1, | |
| 70 | - num: 0 | |
| 71 | - }, | |
| 72 | - { | |
| 73 | - name: "有图", | |
| 74 | - id: 5, | |
| 75 | - num: 0 | |
| 76 | - }, | |
| 77 | - | |
| 78 | - { | |
| 79 | - name: "好评", | |
| 80 | - id: 2, | |
| 81 | - num: 0 | |
| 82 | - }, { | |
| 83 | - name: "中评", | |
| 84 | - id: 3, | |
| 85 | - num: 0 | |
| 86 | - }, { | |
| 87 | - name: "差评", | |
| 88 | - id: 4, | |
| 89 | - num: 0 | |
| 90 | - }, | |
| 91 | - ], | |
| 92 | - | |
| 93 | - select: { | |
| 94 | - price: 0, | |
| 95 | - stock: 0, | |
| 96 | - specName: "", | |
| 97 | - activity: null | |
| 17 | + data: { | |
| 18 | + start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) | |
| 19 | + color_type: 0, //线条控制 | |
| 20 | + color_type_one: 0, | |
| 21 | + color_type_two: 1, | |
| 22 | + gid: "", | |
| 23 | + stoid: os.stoid, | |
| 24 | + url: os.url, | |
| 25 | + resourceUrl: os.h5_url, //公众号那边的图片文件域名 | |
| 26 | + iurl: os.imghost, | |
| 27 | + | |
| 28 | + data: null, | |
| 29 | + content: "", //商品详情 | |
| 30 | + | |
| 31 | + gallery: null, //图片滚动 | |
| 32 | + is_collect: 0, | |
| 33 | + collect_id: 0, | |
| 34 | + cartGoodsNum: 0, | |
| 35 | + specSelect: 0, | |
| 36 | + optionItemId: 0, | |
| 37 | + goodsInputNum: 1, | |
| 38 | + openSpecModal: !1, | |
| 39 | + | |
| 40 | + activeCategoryId: 0, | |
| 41 | + supportPageScroll: !1, | |
| 42 | + address: { | |
| 43 | + address: "", | |
| 44 | + district: 0, | |
| 45 | + }, | |
| 46 | + shipping: "", | |
| 47 | + shippingCost: 0, | |
| 48 | + enterAddressPage: !1, | |
| 49 | + categories: [{ | |
| 50 | + name: "卡项", | |
| 51 | + id: 0 | |
| 52 | + }, { | |
| 53 | + name: "详情", | |
| 54 | + id: 1 | |
| 55 | + }, { | |
| 56 | + name: "评价", | |
| 57 | + id: 2 | |
| 58 | + }], | |
| 59 | + activeCategoryId2: 0, | |
| 60 | + categories2: [{ | |
| 61 | + name: "商品详情", | |
| 62 | + id: 0 | |
| 63 | + }, { | |
| 64 | + name: "规格参数", | |
| 65 | + id: 1 | |
| 66 | + }], | |
| 67 | + activeCategoryId3: 1, // 点击评价-全部、有图、好评、中评时对应的id | |
| 68 | + categories3: [{ | |
| 69 | + name: "全部", | |
| 70 | + id: 1, | |
| 71 | + num: 0 | |
| 72 | + }, | |
| 73 | + { | |
| 74 | + name: "有图", | |
| 75 | + id: 5, | |
| 76 | + num: 0 | |
| 77 | + }, | |
| 78 | + | |
| 79 | + { | |
| 80 | + name: "好评", | |
| 81 | + id: 2, | |
| 82 | + num: 0 | |
| 83 | + }, { | |
| 84 | + name: "中评", | |
| 85 | + id: 3, | |
| 86 | + num: 0 | |
| 87 | + }, { | |
| 88 | + name: "差评", | |
| 89 | + id: 4, | |
| 90 | + num: 0 | |
| 91 | + }, | |
| 92 | + ], | |
| 93 | + | |
| 94 | + select: { | |
| 95 | + price: 0, | |
| 96 | + stock: 0, | |
| 97 | + specName: "", | |
| 98 | + activity: null | |
| 99 | + }, | |
| 100 | + | |
| 101 | + | |
| 102 | + //门店相关 | |
| 103 | + ismend: 0, | |
| 104 | + is_sec_mend: 0, | |
| 105 | + sto_sele_name: "", //选中的门店名称 | |
| 106 | + sto_sele_id: "", //选中的门店id | |
| 107 | + sto_sele_keyid: '', //选中的门店线下 | |
| 108 | + sto_sele_distr: "", //选择的门店的配送方式 | |
| 109 | + is_show_sto_cat: 1, //是否显示门店分类 | |
| 110 | + only_pk: null, | |
| 111 | + all_sto: null, | |
| 112 | + sec_sto: null, //选择了的门店分类 | |
| 113 | + pickpu_list: null, //读出的所有门店list | |
| 114 | + def_pickpu_list: null, //一开始5个门店list | |
| 115 | + sec_pick_index: 0, //第二级门店选择ID | |
| 116 | + fir_pick_index: 0, //第一级门店选择ID | |
| 117 | + all_pick_list: null,//所有的门店先记录起来 | |
| 118 | + | |
| 119 | + //联系电话 | |
| 120 | + mobile: '', | |
| 121 | + //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | |
| 122 | + timer: [], | |
| 123 | + //商品的购买次数 | |
| 124 | + prom_buy_num: -1, | |
| 125 | + g_buy_num: null, | |
| 126 | + | |
| 127 | + //会员自己的购买的拼单商品的情况 | |
| 128 | + //购买的订单 | |
| 129 | + buy_order: null, | |
| 130 | + //1加入购物车 2立即购买 | |
| 131 | + openSpecModal_ind: 0, | |
| 132 | + | |
| 133 | + //---计时器开关---- | |
| 134 | + is_timer: 1, | |
| 135 | + isshow: 0, | |
| 136 | + bconfig: null, //基础配置 | |
| 137 | + | |
| 138 | + //会员分享的头像 | |
| 139 | + share_head: "", | |
| 140 | + share_goods_img: "", | |
| 141 | + | |
| 142 | + //----------视频图片data参数--------- | |
| 143 | + current: 0, //图片计数 | |
| 144 | + swiperCurrent: 0, //轮播的下标 | |
| 145 | + hiddenn: 0, //控制轮播计数显示 | |
| 146 | + | |
| 147 | + currentTab: 0, // 选择器控制参数 | |
| 148 | + mapurl: "", | |
| 149 | + mapurl_f_img: "", | |
| 150 | + videopicture: 0, //视频图片的控制 | |
| 151 | + | |
| 152 | + video: 0, //视频图片切换器 | |
| 153 | + index: 0, | |
| 154 | + noon: 0, //开始视频的隐藏 | |
| 155 | + | |
| 156 | + screenWidth: 0, | |
| 157 | + canvasHidden: 1, | |
| 158 | + | |
| 159 | + //--推荐-- | |
| 160 | + store_config: null, | |
| 161 | + is_show_pl: 0, //是否品类 | |
| 162 | + is_show_pp: 0, //是否品牌 | |
| 163 | + is_show_gb: 0, //是否国别 | |
| 164 | + is_closecoupon: 0, | |
| 165 | + select_store: 0, //选择更多 | |
| 166 | + index: 1, | |
| 167 | + more_store: 0, //选择门店 | |
| 168 | + sort_store: 0, //门店分类 | |
| 169 | + choice_sort_store: 0, //选择分类门店 | |
| 170 | + new_user: 0, //新用户 | |
| 171 | + | |
| 172 | + def_pick_store: null, // 默认的门店 | |
| 173 | + fir_def_store: null, //客户默认的门店的 | |
| 174 | + lat: null, //维度 | |
| 175 | + lon: null, //经度 | |
| 176 | + | |
| 177 | + is_get_local_ok: 0, //获取坐标是否完成 | |
| 178 | + region_name: "门店分类", //区域的名字 | |
| 179 | + is_gps: 1, | |
| 180 | + open_ind_store: 0, //哪里打开的门店列表的控制属性 | |
| 181 | + default_store: {}, //创建添加默认门店地址的对象 | |
| 182 | + | |
| 183 | + comments_no_more: 0, | |
| 184 | + | |
| 185 | + is_collect_load: 0, //是不是处理 | |
| 186 | + wait_for_user_store: null, | |
| 187 | + poster: null, //自定义海报 | |
| 188 | + share_b_img: '', //自定义分享的背景 | |
| 189 | + showPoster: false, | |
| 190 | + hui_condition: null, | |
| 191 | + sto_sele_name_1: '',//分享的门店名称 | |
| 192 | + | |
| 193 | + //-- 活动的情况 -- | |
| 194 | + prom_st: null, | |
| 195 | + prom_r_null: 0, | |
| 196 | + hiddenCS: true, //控制客服操作菜单显示和控制 | |
| 197 | + user_order_pt_state: 0, | |
| 98 | 198 | }, |
| 99 | 199 | |
| 100 | - | |
| 101 | - //门店相关 | |
| 102 | - ismend: 0, | |
| 103 | - is_sec_mend: 0, | |
| 104 | - sto_sele_name: "", //选中的门店名称 | |
| 105 | - sto_sele_id: "", //选中的门店id | |
| 106 | - sto_sele_keyid:'', //选中的门店线下 | |
| 107 | - sto_sele_distr: "", //选择的门店的配送方式 | |
| 108 | - is_show_sto_cat: 1, //是否显示门店分类 | |
| 109 | - only_pk: null, | |
| 110 | - all_sto: null, | |
| 111 | - sec_sto: null, //选择了的门店分类 | |
| 112 | - pickpu_list: null, //读出的所有门店list | |
| 113 | - def_pickpu_list: null, //一开始5个门店list | |
| 114 | - sec_pick_index: 0, //第二级门店选择ID | |
| 115 | - fir_pick_index: 0, //第一级门店选择ID | |
| 116 | - all_pick_list:null,//所有的门店先记录起来 | |
| 117 | - | |
| 118 | - //联系电话 | |
| 119 | - mobile: '', | |
| 120 | - //商品的活动类型 0普通 1秒杀 2团购 3优惠 4 积分购 6拼单 | |
| 121 | - timer: [], | |
| 122 | - //商品的购买次数 | |
| 123 | - prom_buy_num: -1, | |
| 124 | - g_buy_num: null, | |
| 125 | - | |
| 126 | - //会员自己的购买的拼单商品的情况 | |
| 127 | - //购买的订单 | |
| 128 | - buy_order: null, | |
| 129 | - //1加入购物车 2立即购买 | |
| 130 | - openSpecModal_ind: 0, | |
| 131 | - | |
| 132 | - //---计时器开关---- | |
| 133 | - is_timer: 1, | |
| 134 | - isshow: 0, | |
| 135 | - bconfig: null, //基础配置 | |
| 136 | - | |
| 137 | - //会员分享的头像 | |
| 138 | - share_head: "", | |
| 139 | - share_goods_img: "", | |
| 140 | - | |
| 141 | - //----------视频图片data参数--------- | |
| 142 | - current: 0, //图片计数 | |
| 143 | - swiperCurrent: 0, //轮播的下标 | |
| 144 | - hiddenn: 0, //控制轮播计数显示 | |
| 145 | - | |
| 146 | - currentTab: 0, // 选择器控制参数 | |
| 147 | - mapurl: "", | |
| 148 | - mapurl_f_img: "", | |
| 149 | - videopicture: 0, //视频图片的控制 | |
| 150 | - | |
| 151 | - video: 0, //视频图片切换器 | |
| 152 | - index: 0, | |
| 153 | - noon: 0, //开始视频的隐藏 | |
| 154 | - | |
| 155 | - screenWidth: 0, | |
| 156 | - canvasHidden: 1, | |
| 157 | - | |
| 158 | - //--推荐-- | |
| 159 | - store_config: null, | |
| 160 | - is_show_pl: 0, //是否品类 | |
| 161 | - is_show_pp: 0, //是否品牌 | |
| 162 | - is_show_gb: 0, //是否国别 | |
| 163 | - is_closecoupon: 0, | |
| 164 | - | |
| 165 | - | |
| 166 | - select_store: 0, //选择更多 | |
| 167 | - index: 1, | |
| 168 | - more_store: 0, //选择门店 | |
| 169 | - sort_store: 0, //门店分类 | |
| 170 | - choice_sort_store: 0, //选择分类门店 | |
| 171 | - new_user: 0, //新用户 | |
| 172 | - | |
| 173 | - def_pick_store: null, // 默认的门店 | |
| 174 | - fir_def_store:null, //客户默认的门店的 | |
| 175 | - lat: null, //维度 | |
| 176 | - lon: null, //经度 | |
| 177 | - | |
| 178 | - is_get_local_ok: 0, //获取坐标是否完成 | |
| 179 | - region_name: "门店分类", //区域的名字 | |
| 180 | - is_gps: 1, | |
| 181 | - open_ind_store: 0, //哪里打开的门店列表的控制属性 | |
| 182 | - default_store: {}, //创建添加默认门店地址的对象 | |
| 183 | - | |
| 184 | - comments_no_more:0, | |
| 185 | - | |
| 186 | - is_collect_load:0, //是不是处理 | |
| 187 | - is_newsales_rules:0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 | |
| 188 | - sales_rules:1, //默认是线上销售 | |
| 189 | - | |
| 190 | - wait_for_user_store:null, | |
| 191 | - poster:null, //自定义海报 | |
| 192 | - share_b_img:'', //自定义分享的背景 | |
| 193 | - showPoster: false, | |
| 194 | - hui_condition:null, | |
| 195 | - sto_sele_name_1:'',//分享的门店名称 | |
| 196 | - | |
| 197 | - // 秒杀 | |
| 198 | - prom_st: null, | |
| 199 | - prom_r_null: 0, | |
| 200 | - hiddenCS: true, //控制客服操作菜单显示和控制 | |
| 201 | - openSpecModal_flash_normal: 0, | |
| 202 | - }, | |
| 203 | - | |
| 204 | - //------初始化加载---------- | |
| 205 | - onLoad: function(t) { | |
| 206 | - self = this; | |
| 207 | - this.setData({ options: t,}); | |
| 208 | - | |
| 209 | - var ee = this, | |
| 210 | - that = ee, | |
| 211 | - th = ee, | |
| 212 | - gid = t.goods_id, | |
| 213 | - first_leader=t.first_leader; | |
| 214 | - | |
| 215 | - | |
| 216 | - //-- 自定义海报 -- | |
| 217 | - // getApp().request.promiseGet("/api/weshop/goods/poster/page", { | |
| 218 | - // data:{store_id:os.stoid, type:1, is_use:1} | |
| 219 | - // }).then(res=>{ | |
| 220 | - // if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]){ | |
| 221 | - // var poster_data=res.data.data.pageData[0]; | |
| 222 | - // var json_str=poster_data.jsonStr; | |
| 223 | - // if(json_str){ | |
| 224 | - // var json_data=JSON.parse(json_str); | |
| 225 | - // if(json_data.bg_img){ | |
| 226 | - // //-- 把图片那到本地 -- | |
| 227 | - // wx.getImageInfo({ | |
| 228 | - // src:json_data.bg_img, | |
| 229 | - // success: function(res) { | |
| 230 | - // var path= res.path; | |
| 231 | - // th.setData({share_b_img:path}) | |
| 232 | - // }, | |
| 233 | - // fail: function(res) {} | |
| 234 | - // }); | |
| 235 | - // } | |
| 236 | - // th.setData({poster:json_data}) | |
| 237 | - // } | |
| 238 | - // } | |
| 239 | - // }) | |
| 240 | - | |
| 241 | - | |
| 242 | - //---获取手机地址坐标-- | |
| 243 | - //--如果tg_id是空的话,分享回来-- | |
| 244 | - if (gid == undefined || gid == null || gid == "") { | |
| 245 | - var gid_str = decodeURIComponent(t.scene); | |
| 246 | - gid_str=gid_str.split("_"); | |
| 247 | - gid=gid_str[0]; | |
| 248 | - if(gid_str.length>1){ | |
| 249 | - first_leader=gid_str[1]; | |
| 250 | - } | |
| 251 | - //-- 如果有room_id的获取 -- | |
| 252 | - if(gid_str.length>2 && gid_str[2]) { | |
| 253 | - room_id=gid_str[2]; | |
| 254 | - room_user_share=1; | |
| 255 | - }; | |
| 256 | - }; | |
| 257 | - | |
| 258 | - ee.setData({ gid: gid}); | |
| 259 | - | |
| 260 | - if(first_leader) { | |
| 261 | - getApp().globalData.first_leader=first_leader; | |
| 262 | - //调用接口判断是不是会员 | |
| 263 | - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ | |
| 264 | - if(res.data.code==0) { | |
| 265 | - getApp().globalData.guide_id=res.data.data.id; | |
| 266 | - } | |
| 267 | - }) | |
| 268 | - } | |
| 269 | - | |
| 270 | - var c_guide_id=t.c_guide_id; | |
| 271 | - if(c_guide_id){ | |
| 272 | - th.data.c_guide_id=c_guide_id; | |
| 273 | - } | |
| 274 | - | |
| 275 | - getApp().getConfig(function(e) { | |
| 276 | - ee.setData({sto_sele_name_1:e.store_name}) | |
| 277 | - }) | |
| 278 | - | |
| 279 | - //----获取系统参数----- | |
| 280 | - getApp().getConfig2(function (e) { | |
| 281 | - ee.setData({ | |
| 282 | - bconfig: e, | |
| 283 | - sales_rules: e.sales_rules, | |
| 284 | - }); | |
| 285 | - | |
| 286 | - if (e.categoryset.indexOf("," + 1 + ",") != -1) { | |
| 287 | - ee.setData({ | |
| 288 | - is_show_pl: 1 | |
| 289 | - }); | |
| 290 | - } | |
| 291 | - if (e.categoryset.indexOf("," + 3 + ",") != -1) { | |
| 292 | - ee.setData({ | |
| 293 | - is_show_pp: 1 | |
| 294 | - }); | |
| 295 | - } | |
| 296 | - if (e.categoryset.indexOf("," + 2 + ",") != -1) { | |
| 297 | - ee.setData({ | |
| 298 | - is_show_gb: 1 | |
| 299 | - }); | |
| 300 | - } | |
| 301 | - | |
| 302 | - var json_d = JSON.parse(e.switch_list); | |
| 303 | - ee.setData({ | |
| 304 | - store_config: e, | |
| 305 | - sys_switch: json_d, | |
| 306 | - is_closecoupon: json_d.is_closecoupon, | |
| 307 | - is_newsales_rules: json_d.is_newsales_rules | |
| 308 | - }); | |
| 309 | - ee.init(gid); | |
| 310 | - | |
| 311 | - //------几人评价------- | |
| 312 | - //n.init(th, "", "comments"); | |
| 313 | - | |
| 314 | - th.requestCardNum(), wx.pageScrollTo && th.setData({ | |
| 315 | - supportPageScroll: !0 | |
| 316 | - }); | |
| 317 | - | |
| 318 | - | |
| 319 | - }, 1); | |
| 320 | - | |
| 321 | - //获取用户设备信息,屏幕宽度 | |
| 322 | - wx.getSystemInfo({ | |
| 323 | - success: res => { | |
| 324 | - that.setData({ | |
| 325 | - screenWidth: res.screenWidth | |
| 200 | + //------初始化加载---------- | |
| 201 | + onLoad: function (t) { | |
| 202 | + self = this; | |
| 203 | + this.setData({options: t,}); | |
| 204 | + | |
| 205 | + var ee = this, that = ee, th = ee, | |
| 206 | + gid = t.goods_id, | |
| 207 | + first_leader = t.first_leader; | |
| 208 | + | |
| 209 | + | |
| 210 | + //-- 自定义海报 -- | |
| 211 | + getApp().request.promiseGet("/api/weshop/goods/poster/page", { | |
| 212 | + data:{store_id:os.stoid, type:1, is_use:1} | |
| 213 | + }).then(res=>{ | |
| 214 | + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData[0]){ | |
| 215 | + var poster_data=res.data.data.pageData[0]; | |
| 216 | + var json_str=poster_data.jsonStr; | |
| 217 | + if(json_str){ | |
| 218 | + var json_data=JSON.parse(json_str); | |
| 219 | + if(json_data.bg_img){ | |
| 220 | + //-- 把图片那到本地 -- | |
| 221 | + wx.getImageInfo({ | |
| 222 | + src:json_data.bg_img, | |
| 223 | + success: function(res) { | |
| 224 | + var path= res.path; | |
| 225 | + th.setData({share_b_img:path}) | |
| 226 | + }, | |
| 227 | + fail: function(res) {} | |
| 228 | + }); | |
| 229 | + } | |
| 230 | + th.setData({poster:json_data}) | |
| 231 | + } | |
| 232 | + } | |
| 326 | 233 | }) |
| 327 | - } | |
| 328 | - }); | |
| 329 | - | |
| 330 | - //获取用户的默认门店 | |
| 331 | - getApp().get_user_store(function(e) { | |
| 332 | - if(!e) { | |
| 333 | - th.data.fir_def_store={}; //赋值空对象 | |
| 334 | - return false; | |
| 335 | - } | |
| 336 | - var ee=JSON.parse(JSON.stringify(e)); | |
| 337 | - //--定时器推迟一下-- | |
| 338 | - setTimeout(function () { | |
| 339 | - if(!th.data.data) return false; | |
| 340 | - var ser_card=th.data.data; | |
| 341 | - //--如果默认门店不在等级卡的默认们店以内 | |
| 342 | - if(ser_card.storageId!=null && ser_card.storageId!="" && ser_card.storageId.indexOf(ee.keyid)==-1){ | |
| 343 | - ee.is_no_dis=1; | |
| 234 | + | |
| 235 | + var room_id=0; | |
| 236 | + var room_user_share=0; | |
| 237 | + | |
| 238 | + //---获取手机地址坐标-- | |
| 239 | + //--如果tg_id是空的话,分享回来-- | |
| 240 | + if (gid == undefined || gid == null || gid == "") { | |
| 241 | + var gid_str = decodeURIComponent(t.scene); | |
| 242 | + gid_str = gid_str.split("_"); | |
| 243 | + gid = gid_str[0]; | |
| 244 | + if (gid_str.length > 1) { | |
| 245 | + first_leader = gid_str[1]; | |
| 246 | + } | |
| 247 | + //-- 如果有room_id的获取 -- | |
| 248 | + if (gid_str.length > 2 && gid_str[2]) { | |
| 249 | + room_id = gid_str[2]; | |
| 250 | + room_user_share = 1; | |
| 251 | + } | |
| 344 | 252 | } |
| 345 | 253 | |
| 346 | - var appd=getApp().globalData; | |
| 347 | - var w_time = setInterval(function() { | |
| 348 | - if (that.data.is_get_local_ok == 0) return false; | |
| 349 | - clearInterval(w_time); | |
| 350 | - var distance = null; | |
| 351 | - var e=JSON.parse(JSON.stringify(ee)); | |
| 352 | - | |
| 353 | - //如果有开启近距离的话,同时距离优不一样了 | |
| 354 | - if (that.data.lat != null) { | |
| 355 | - //如果经纬度有变化的话 | |
| 356 | - if(e && appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){ | |
| 357 | - that.data.fir_def_store=e; | |
| 358 | - that.setData({ | |
| 359 | - def_pick_store: e, | |
| 360 | - sto_sele_name: e.pickup_name, | |
| 361 | - sto_sele_id: e.pickup_id, | |
| 362 | - sto_sele_distr: e.distr_type, | |
| 363 | - sto_sele_keyid:e.keyid, | |
| 364 | - }) | |
| 365 | - }else{ | |
| 366 | - //要用接口是获取距离,js的计算不准 | |
| 367 | - getApp().request.promiseGet("/api/weshop/pickup/list",{ | |
| 368 | - data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1}, | |
| 369 | - }).then(res=>{ | |
| 370 | - if(ut.ajax_ok(res)){ | |
| 371 | - e=res.data.data.pageData[0]; | |
| 372 | - if (e){ | |
| 373 | - e.is_no_dis=ee.is_no_dis; | |
| 374 | - appd.pk_store=e; | |
| 375 | - that.data.fir_def_store=e; | |
| 376 | - that.setData({ | |
| 377 | - def_pick_store: e, | |
| 378 | - sto_sele_name: e.pickup_name, | |
| 379 | - sto_sele_id: e.pickup_id, | |
| 380 | - sto_sele_distr: e.distr_type, | |
| 381 | - sto_sele_keyid:e.keyid, | |
| 382 | - }) | |
| 383 | - } | |
| 254 | + //-- 如果有房间号 -- | |
| 255 | + if (room_id) { | |
| 256 | + getApp().globalData.room_id = room_id; | |
| 257 | + getApp().globalData.room_goods_id = gid; | |
| 258 | + //如果是会员分享过来的要记录 | |
| 259 | + if (room_user_share) | |
| 260 | + getApp().globalData.room_user_share = room_user_share; | |
| 261 | + } | |
| 384 | 262 | |
| 263 | + | |
| 264 | + | |
| 265 | + ee.setData({gid: gid}); | |
| 266 | + | |
| 267 | + if (first_leader) { | |
| 268 | + getApp().globalData.first_leader = first_leader; | |
| 269 | + //调用接口判断是不是会员 | |
| 270 | + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => { | |
| 271 | + if (res.data.code == 0) { | |
| 272 | + getApp().globalData.guide_id = res.data.data.id; | |
| 273 | + getApp().globalData.guide_pick_id= res.data.data.pickup_id | |
| 385 | 274 | } |
| 386 | - }) | |
| 275 | + }) | |
| 276 | + } | |
| 277 | + | |
| 278 | + var c_guide_id = t.c_guide_id; | |
| 279 | + if (c_guide_id) { | |
| 280 | + th.data.c_guide_id = c_guide_id; | |
| 281 | + } | |
| 282 | + | |
| 283 | + getApp().getConfig(function (e) { | |
| 284 | + ee.setData({sto_sele_name_1: e.store_name}) | |
| 285 | + }) | |
| 286 | + | |
| 287 | + //----获取系统参数----- | |
| 288 | + getApp().getConfig2(function (e) { | |
| 289 | + ee.setData({ | |
| 290 | + bconfig: e, | |
| 291 | + sales_rules: e.sales_rules, | |
| 292 | + }); | |
| 293 | + | |
| 294 | + if (e.categoryset.indexOf("," + 1 + ",") != -1) { | |
| 295 | + ee.setData({ | |
| 296 | + is_show_pl: 1 | |
| 297 | + }); | |
| 298 | + } | |
| 299 | + if (e.categoryset.indexOf("," + 3 + ",") != -1) { | |
| 300 | + ee.setData({ | |
| 301 | + is_show_pp: 1 | |
| 302 | + }); | |
| 303 | + } | |
| 304 | + if (e.categoryset.indexOf("," + 2 + ",") != -1) { | |
| 305 | + ee.setData({ | |
| 306 | + is_show_gb: 1 | |
| 307 | + }); | |
| 308 | + } | |
| 309 | + | |
| 310 | + var json_d = JSON.parse(e.switch_list); | |
| 311 | + ee.setData({ | |
| 312 | + store_config: e, | |
| 313 | + sys_switch: json_d, | |
| 314 | + is_closecoupon: json_d.is_closecoupon, | |
| 315 | + is_newsales_rules: json_d.is_newsales_rules | |
| 316 | + }); | |
| 317 | + ee.init(gid); | |
| 318 | + | |
| 319 | + //------几人评价------ | |
| 320 | + //n.init(th, "", "comments"); | |
| 321 | + wx.pageScrollTo && th.setData({ | |
| 322 | + supportPageScroll: !0 | |
| 323 | + }); | |
| 324 | + | |
| 325 | + | |
| 326 | + }, 1); | |
| 327 | + | |
| 328 | + //获取用户设备信息,屏幕宽度 | |
| 329 | + wx.getSystemInfo({ | |
| 330 | + success: res => { | |
| 331 | + that.setData({ | |
| 332 | + screenWidth: res.screenWidth | |
| 333 | + }) | |
| 387 | 334 | } |
| 335 | + }); | |
| 388 | 336 | |
| 389 | - //e.distance = distance; | |
| 390 | - appd.lat=that.data.lat; | |
| 391 | - appd.lon=that.data.lon; | |
| 392 | - | |
| 393 | - } else { | |
| 394 | - if (e) { | |
| 395 | - e.distance = null; | |
| 396 | - that.data.fir_def_store=e; | |
| 397 | - that.setData({ | |
| 398 | - def_pick_store: e, | |
| 399 | - sto_sele_name: e.pickup_name, | |
| 400 | - sto_sele_id: e.pickup_id, | |
| 401 | - sto_sele_distr: e.distr_type, | |
| 402 | - sto_sele_keyid:e.keyid, | |
| 403 | - }) | |
| 337 | + //获取用户的默认门店 | |
| 338 | + getApp().get_user_store(function (e) { | |
| 339 | + if (!e) { | |
| 340 | + th.data.fir_def_store = {}; //赋值空对象 | |
| 341 | + return false; | |
| 404 | 342 | } |
| 405 | - } | |
| 406 | - }, 500) | |
| 407 | - },700) | |
| 408 | - | |
| 409 | - }); | |
| 410 | - | |
| 411 | - | |
| 412 | - }, | |
| 413 | - | |
| 414 | - | |
| 415 | - onReady() { | |
| 416 | - // 用于控制保障服务折叠图标的显示 | |
| 417 | - setTimeout(() => { | |
| 418 | - wx.createSelectorQuery().selectAll(".showArea, .hideArea").boundingClientRect(res => { | |
| 419 | - | |
| 420 | - if(res.length != 0) { | |
| 421 | - this.setData({ | |
| 422 | - showFold: res[0].height < res[1].height, | |
| 423 | - }); | |
| 424 | - }; | |
| 425 | - | |
| 426 | - }).exec(); | |
| 427 | - }, 1000); | |
| 428 | - | |
| 429 | - }, | |
| 430 | - | |
| 431 | - | |
| 432 | - //------------程序初始化入口------------- | |
| 433 | - async init(gid) { | |
| 434 | - var ee = this, | |
| 435 | - th = ee, | |
| 436 | - gallery = null, | |
| 437 | - is_collect = 0, | |
| 438 | - collect_id = 0, | |
| 439 | - categories3 = ee.data.categories3, | |
| 440 | - fir_com = null, | |
| 441 | - fir_quan = null, | |
| 442 | - mapurl = null, | |
| 443 | - mapurl_f_img = null; | |
| 444 | - | |
| 445 | - | |
| 446 | - //------图片滚动---------- | |
| 447 | - // await getApp().request.promiseGet("/api/weshop/goodsimages/page", { | |
| 448 | - // data: { | |
| 449 | - // store_id: os.stoid, | |
| 450 | - // goods_id: gid, | |
| 451 | - // }, | |
| 452 | - // }).then(res => { | |
| 453 | - | |
| 454 | - // var t = res; | |
| 455 | - // var g = t.data.data.pageData; | |
| 456 | - // if (g.length == 0) { | |
| 457 | - // var ie = { | |
| 458 | - // "image_url": o.imghost + "/public/images/default_goods_image_240.gif" | |
| 459 | - // }; | |
| 460 | - // g.push(ie); | |
| 461 | - // gallery = g; | |
| 462 | - // return; | |
| 463 | - // } | |
| 464 | - // for (var i = 0; i < g.length; i++) { | |
| 465 | - // if (g[i].image_url.indexOf(o.imghost) == -1) | |
| 466 | - // g[i].image_url = o.imghost + g[i].image_url; | |
| 467 | - // } | |
| 468 | - // gallery = g; | |
| 469 | - // }) | |
| 470 | - | |
| 471 | - | |
| 472 | - // ----> 秒杀 | |
| 473 | - let prom_type = this.data.options.prom_type; | |
| 474 | - | |
| 475 | - let goods_id = this.data.options.goods_id; | |
| 476 | - if(!goods_id) goods_id = this.data.data.goods_id; | |
| 477 | - | |
| 478 | - if(prom_type) { // 进入商品详情页地址传参有带goods_id、prom_type、prom_id参数, 即从秒杀入口进入 | |
| 479 | - let prom_id = this.data.options.prom_id; | |
| 480 | - // 检查活动是否开始 | |
| 481 | - this.check_prom(goods_id, prom_type, prom_id); | |
| 482 | - | |
| 483 | - } else { // 从非秒杀入口进入,地址不带prom_type、prom_id参数 | |
| 484 | - getApp().request.promiseGet('/api/weshop/activitylist/listGoodActInfo2', { | |
| 485 | - data: { | |
| 486 | - store_id: os.stoid, | |
| 487 | - goods_id: goods_id, | |
| 488 | - goods_type: 1, | |
| 489 | - user_id: oo.user_id, | |
| 490 | - } | |
| 491 | - }).then(res => { | |
| 492 | - if (res.data.code == 0) { | |
| 493 | - let result = res.data.data; | |
| 494 | - let resLength = result.length; | |
| 495 | - if(resLength == 1) { // 如果数组长度为1,则直接显示当前活动 | |
| 496 | - let goods_id = this.data.options.goods_id; | |
| 497 | - let prom_type = result[0].prom_type; | |
| 498 | - let prom_id = result[0].act_id; | |
| 499 | - this.setData({ | |
| 500 | - 'options.prom_type': prom_type, | |
| 501 | - 'options.prom_id': prom_id, | |
| 502 | - }); | |
| 503 | - // 检查活动是否开始 | |
| 504 | - this.check_prom(goods_id, prom_type, prom_id); | |
| 505 | - } else if(resLength > 1) { //如果数组长度大于1,表示当前商品参加多个活动,以列表形式显示多活动 | |
| 506 | - this.setData({ | |
| 507 | - actList: res.data.data, | |
| 508 | - }); | |
| 509 | - }; | |
| 510 | - | |
| 511 | - }; | |
| 512 | - }); | |
| 513 | - }; | |
| 514 | - // <---- 秒杀 | |
| 515 | - | |
| 516 | - | |
| 517 | - | |
| 518 | - | |
| 519 | - | |
| 520 | - | |
| 521 | - | |
| 522 | - | |
| 523 | - | |
| 524 | - | |
| 525 | - //------是否收藏---------- | |
| 526 | - await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | |
| 527 | - data: { | |
| 528 | - store_id: os.stoid, | |
| 529 | - goods_id: gid, | |
| 530 | - user_id: oo.user_id, | |
| 531 | - } | |
| 532 | - }).then(res => { | |
| 533 | - var t = res; | |
| 534 | - var data = t.data.data.pageData; | |
| 535 | - if (data && data.length > 0) { | |
| 536 | - //ee.setData({ is_collect: 1, collect_id: data[0].collect_id, }); | |
| 537 | - is_collect = 1; | |
| 538 | - collect_id = data[0].collect_id; | |
| 539 | - } | |
| 540 | - }) | |
| 541 | - | |
| 542 | - //------获取评价的统计数量---- | |
| 543 | - await getApp().request.promiseGet("/api/weshop/serviceComment/countlist/", { | |
| 544 | - data: { | |
| 545 | - store_id: os.stoid, | |
| 546 | - service_id: gid | |
| 547 | - }, | |
| 548 | - }).then(res => { | |
| 549 | - console.log('get评价统计数量', res.data.data); | |
| 550 | - var t = res; | |
| 551 | - var g = t.data.data[0]; | |
| 552 | - if (g != null && g != undefined) { | |
| 553 | - var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | |
| 554 | - var num2 = g.c4 + g.c5; | |
| 555 | - var num3 = g.c3; | |
| 556 | - var num4 = g.c0 + g.c1 + g.c2; | |
| 557 | - | |
| 558 | - var dd = ee.data.categories3; | |
| 559 | - dd[0].num = allnum; | |
| 560 | - dd[1].num = g.cimg; | |
| 561 | - dd[2].num = num2; | |
| 562 | - dd[3].num = num3; | |
| 563 | - dd[4].num = num4; | |
| 564 | - | |
| 565 | - categories3 = dd; | |
| 566 | - } | |
| 567 | - }); | |
| 568 | - | |
| 569 | - //----获取详情页的评价---- | |
| 570 | - await getApp().request.promiseGet("/api/weshop/serviceComment/pageComment", { | |
| 571 | - data: { | |
| 572 | - store_id: os.stoid, | |
| 573 | - service_id: gid, | |
| 574 | - pageSize: 3, | |
| 575 | - parent_id: 0, | |
| 576 | - page: 1, | |
| 577 | - is_show: 1, | |
| 578 | - }, | |
| 579 | - }).then(res => { | |
| 580 | - console.log('get详情页评价', res.data.data); | |
| 581 | - fir_com = res.data.data.pageData; | |
| 582 | - }); | |
| 583 | - | |
| 584 | - if (fir_com) { | |
| 585 | - for (var ind in fir_com) { | |
| 586 | - if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | |
| 587 | - if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | |
| 588 | - if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | |
| 589 | - } | |
| 590 | - }; | |
| 591 | - | |
| 592 | - this.getTaohe(); | |
| 593 | - | |
| 594 | - //this.getHistoryBuy(); //获取历史购买 | |
| 595 | - ee.setData({ | |
| 596 | - is_collect: is_collect, | |
| 597 | - collect_id: collect_id, | |
| 598 | - categories3: categories3, | |
| 599 | - fir_quan: fir_quan, | |
| 600 | - fir_comments: fir_com, | |
| 601 | - // cardComments: fir_com, | |
| 602 | - }); | |
| 603 | - | |
| 604 | - }, | |
| 605 | - | |
| 606 | - //---展示--- | |
| 607 | - // gid 在onload阶段已经保存在this.data中 | |
| 608 | - onShow: function() { | |
| 609 | - | |
| 610 | - getApp().check_can_share(); | |
| 611 | - var that=this; | |
| 612 | - var ee = this,gid = this.data.gid, i = getApp().request; | |
| 613 | - this.data.is_timer = 1; | |
| 614 | - this.wait_for_store_config(); | |
| 615 | - | |
| 616 | - | |
| 617 | - | |
| 618 | - | |
| 619 | - i.get("/api/weshop/serviceCard/get/" + os.stoid + "/" + ee.data.gid, { | |
| 620 | - failRollback: !0, | |
| 621 | - success: function(t) { | |
| 622 | - if (t.data.code == 0) { | |
| 623 | - // console.log('GET pic and video'); | |
| 624 | - if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_url) { | |
| 625 | - that.setData({ | |
| 626 | - mapurl: t.data.data.listServiceVideos[0].video_url, | |
| 627 | - }); | |
| 628 | - }; | |
| 629 | - if(t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_img) { | |
| 630 | - that.setData({ | |
| 631 | - mapurl_f_img: t.data.data.listServiceVideos[0].video_img, | |
| 632 | - }); | |
| 633 | - }; | |
| 634 | - if(t.data.data.listServiceImages) { | |
| 635 | - that.setData({ | |
| 636 | - gallery: t.data.data.listServiceImages, | |
| 637 | - }); | |
| 638 | - }; | |
| 639 | - if(t.data.data.listServiceItem) { | |
| 640 | - that.setData({ | |
| 641 | - listServiceItem: t.data.data.listServiceItem, | |
| 642 | - }); | |
| 643 | - }; | |
| 644 | - that.setData({ | |
| 645 | - 'data.goods_name': t.data.data.serviceName, | |
| 646 | - 'data.shop_price': t.data.data.money, | |
| 647 | - 'data.show_price': t.data.data.show_price, | |
| 648 | - 'data.validDays': t.data.data.validDays, | |
| 649 | - 'data.serviceContent': t.data.data.serviceContent, | |
| 650 | - 'data.image_url': t.data.data.imgUrl, | |
| 651 | - 'data.goods_id': t.data.data.id, | |
| 652 | - 'data.id': t.data.data.id, | |
| 653 | - 'data.sales_sum': t.data.data.sales_sum, | |
| 654 | - 'data.storageId':t.data.data.storageId, | |
| 655 | - 'data.service_sn':t.data.data.serviceSn, | |
| 656 | - 'data.listServiceVideos': t.data.data.listServiceVideos, | |
| 657 | - // gallery: t.data.data.listServiceImages, | |
| 658 | - // mapurl: t.data.data.listServiceVideos[0].video_url, | |
| 659 | - // mapurl_f_img: t.data.data.listServiceVideos[0].video_img, | |
| 660 | - //listServiceItem: t.data.data.listServiceItem, | |
| 661 | - }); | |
| 662 | - | |
| 663 | - // console.log('0xxxxx999999', t.data.data); | |
| 664 | - //-----商品详情--- | |
| 665 | - if(!t.data.data.serviceContent) t.data.data.serviceContent=" "; | |
| 666 | - a.wxParse("content", "html", t.data.data.serviceContent, ee, 6); | |
| 667 | - e.wxParseAddFullImageUrl(ee, "content"); | |
| 668 | - | |
| 669 | - //获取重表 | |
| 670 | - getApp().promiseGet("/api/weshop/serviceItem/list",{ | |
| 671 | - data:{store_id:os.stoid,service_id:t.data.data.id} | |
| 672 | - }).then(res=>{ | |
| 673 | - if(res.data.code==0){ | |
| 674 | - var list=res.data.data; | |
| 675 | - that.setData({service_list:list}) | |
| 676 | - } | |
| 677 | - }) | |
| 678 | - | |
| 679 | - | |
| 680 | 343 | |
| 681 | - } else { | |
| 682 | - wx.showModal({ | |
| 683 | - title: t.data.msg, | |
| 684 | - showCancel: !1, | |
| 685 | - complete: function() { | |
| 686 | - wx.navigateBack(); | |
| 687 | - } | |
| 688 | - }); | |
| 689 | - }; | |
| 690 | - } | |
| 691 | - }); | |
| 692 | - | |
| 693 | - | |
| 694 | - | |
| 695 | - this.data.enterAddressPage && (this.data.enterAddressPage = !1); | |
| 696 | - this.get_sto(); | |
| 697 | - | |
| 698 | - | |
| 699 | - | |
| 700 | - }, | |
| 701 | - | |
| 702 | - enterAddress: function() { | |
| 703 | - this.data.enterAddressPage = !0, wx.navigateTo({ | |
| 704 | - url: "/pages/user/address_list/address_list?operate=selectAddress" | |
| 705 | - }); | |
| 706 | - }, | |
| 707 | - | |
| 708 | - onUnload: function() { | |
| 709 | - for(var i = 1; i < 100; i++) { | |
| 710 | - clearInterval(i); | |
| 711 | - } | |
| 712 | - }, | |
| 713 | - | |
| 714 | - onHide: function() { | |
| 715 | - this.data.is_timer = 0; | |
| 716 | - for(var i = 1; i < 100; i++) { | |
| 717 | - clearInterval(i); | |
| 718 | - } | |
| 719 | - }, | |
| 720 | - //----------三个选项按钮----------- | |
| 721 | - tabClick: function(t) { | |
| 722 | - var e = t.currentTarget.id; | |
| 723 | - this.setData({ | |
| 724 | - activeCategoryId: e | |
| 725 | - }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | |
| 726 | - }, | |
| 727 | - | |
| 728 | - // tabClick2: function(t) { | |
| 729 | - // this.setData({ | |
| 730 | - // activeCategoryId2: t.currentTarget.id | |
| 731 | - // }); | |
| 732 | - // }, | |
| 733 | - | |
| 734 | - tabClick3: function(t) { | |
| 735 | - var e = this; | |
| 736 | - if (t.currentTarget.id != this.data.activeCategoryId3) { | |
| 737 | - e.data.c_curr_p = 1; | |
| 738 | - this.setData({ | |
| 739 | - activeCategoryId3: t.currentTarget.id, | |
| 740 | - comments: null,comments_no_more:0,get_c:0, | |
| 741 | - }); | |
| 742 | - this.requestComments_new(); | |
| 743 | - } | |
| 744 | - }, | |
| 745 | - | |
| 746 | - // doScrollTop: function() { | |
| 747 | - // wx.pageScrollTo({ | |
| 748 | - // scrollTop: 0 | |
| 749 | - // }); | |
| 750 | - // }, | |
| 751 | - | |
| 752 | - tabComment: function() { | |
| 753 | - this.setData({ | |
| 754 | - activeCategoryId: 2,comments_no_more:0,get_c:0 | |
| 755 | - }), this.data.comments || this.requestComments_new(); | |
| 756 | - }, | |
| 757 | - | |
| 758 | - //商品详情的时候调用 | |
| 759 | - tabGoodsContent: function() { | |
| 760 | - var th = this, | |
| 761 | - i = getApp().request; | |
| 762 | - this.setData({ | |
| 763 | - activeCategoryId: 1 | |
| 764 | - }); | |
| 765 | - }, | |
| 766 | - | |
| 767 | - | |
| 768 | - | |
| 769 | - //------------加入购物车-------------- | |
| 770 | - addCart: async function(t) { | |
| 771 | - var th = this; | |
| 772 | - var ind = t.currentTarget.dataset.openSpecModal_ind; | |
| 773 | - var action= t.currentTarget.dataset.action; | |
| 774 | - if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind; | |
| 775 | - | |
| 776 | - th.setData({ | |
| 777 | - open_ind_store: ind | |
| 778 | - }); | |
| 779 | - | |
| 780 | - if(!th.data.sto_sele_name) { | |
| 781 | - getApp().my_warnning('请选择门店', 1, th, 450); | |
| 782 | - return false; | |
| 783 | - }; | |
| 784 | - | |
| 785 | - // 库存 | |
| 786 | - var redisNums = 0; | |
| 787 | - // 限购数 | |
| 788 | - var limitNum = 0; | |
| 789 | - // 已购买数量 | |
| 790 | - var boughtNum = 0; | |
| 791 | - | |
| 792 | - // 秒杀活动 | |
| 793 | - if(this.data.prom_type == 1) { | |
| 794 | - // 如果是秒杀活动下的单独购买,is_normal为1 | |
| 795 | - if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1; | |
| 796 | - | |
| 797 | - if(!this.data.is_normal) {// 秒杀购买 | |
| 798 | - | |
| 799 | - // 获取redis当前可以购买的数量 | |
| 800 | - // 如果数量为0,设置和显示已抢光 | |
| 801 | - // 否则,进一步判断是否超出限购或超出库存 | |
| 802 | - await this.getactLen().then(async function(res) { | |
| 803 | - redisNums = res; | |
| 804 | - let curNum = th.data.goodsInputNum; | |
| 805 | - // res: redis可购买数量 | |
| 806 | - console.log('当前可以购买的数量:', res); | |
| 807 | - if(res <= 0) { | |
| 808 | - // 可购买数量<=0, 设置和显示已抢光 | |
| 809 | - th.setData({ | |
| 810 | - prom_r_null: 1, | |
| 811 | - }); | |
| 812 | - // wx.showModal({ | |
| 813 | - // title: '超出活动库存', | |
| 814 | - // }); | |
| 815 | - getApp().my_warnning('超出活动库存', 0, self); | |
| 816 | - return false; | |
| 817 | - } else { | |
| 818 | - // 可购买数量>0 | |
| 819 | - // 计算自己还可以购买的数量 | |
| 820 | - // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | |
| 821 | - // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | |
| 822 | - // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | |
| 823 | - let actInfo = th.data.sele_g; | |
| 824 | - await th.get_buy_num2().then(function (data) { | |
| 825 | - let limited = actInfo.buy_limit; // 限购数量a | |
| 826 | - let promcardbuynum = data.data.data.promcardbuynum; | |
| 827 | - let buyedNum = promcardbuynum; // 自己已经购买的数量b | |
| 828 | - let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | |
| 829 | - limitNum = limited; | |
| 830 | - boughtNum = buyedNum; | |
| 831 | - | |
| 832 | - if(canBuyNum <= 0) { | |
| 833 | - canBuyNum = 0; | |
| 834 | - }; | |
| 835 | - | |
| 836 | - if(canBuyNum > res) { | |
| 837 | - if(curNum > res) { // t当前增减的数量 | |
| 838 | - // wx.showModal({ | |
| 839 | - // title: '超出活动库存', | |
| 840 | - // }); | |
| 841 | - getApp().my_warnning('超出活动库存', 0, self); | |
| 842 | - th.setData({ | |
| 843 | - goodsInputNum: res, | |
| 844 | - }); | |
| 845 | - return false; | |
| 846 | - }; | |
| 847 | - }; | |
| 848 | - | |
| 849 | - if(canBuyNum <= res) { | |
| 850 | - if(curNum > canBuyNum) { | |
| 851 | - // wx.showModal({ | |
| 852 | - // title: '超出限购数量', | |
| 853 | - // }); | |
| 854 | - getApp().my_warnning('超出限购数量', 0, self); | |
| 855 | - th.setData({ | |
| 856 | - goodsInputNum: canBuyNum, | |
| 857 | - }); | |
| 858 | - return false; | |
| 859 | - }; | |
| 860 | - }; | |
| 861 | - | |
| 862 | - | |
| 863 | - }); | |
| 864 | - | |
| 865 | - | |
| 866 | - | |
| 867 | - }; | |
| 868 | - }); | |
| 869 | - | |
| 870 | - }; | |
| 871 | - | |
| 872 | - | |
| 873 | - }; | |
| 874 | - | |
| 875 | - | |
| 876 | - | |
| 877 | - if(action=="buy"){ | |
| 878 | - //--------------此时操作的数据------------ | |
| 879 | - var newd = { | |
| 880 | - id: th.data.data.id, | |
| 881 | - goods_num: th.data.goodsInputNum, | |
| 882 | - pick_id: th.data.sto_sele_id, | |
| 883 | - keyid: th.data.sto_sele_keyid, | |
| 884 | - }; | |
| 885 | - newd['pick_name'] = th.data.sto_sele_name; | |
| 886 | - newd['guide_id'] = getApp().globalData.guide_id; | |
| 887 | - newd['guide_type']=0; | |
| 888 | - | |
| 889 | - if(this.data.prom_type && this.data.prom_type == 1) { | |
| 890 | - newd['prom_type'] = this.data.prom_type; | |
| 891 | - newd['prom_id'] = this.data.prom_id; | |
| 892 | - newd['prom_price'] = this.data.prom_price; | |
| 893 | - }; | |
| 894 | - | |
| 895 | - if(this.data.prom_type == 1 && this.data.openSpecModal_flash_normal) { | |
| 896 | - newd['prom_type'] = 0; | |
| 897 | - newd['prom_price'] = this.data.data.shop_price; | |
| 898 | - }; | |
| 899 | - | |
| 900 | - // console.log('newd++++++++', newd); | |
| 901 | - th.buyNow(newd); | |
| 902 | - } else { | |
| 903 | - | |
| 904 | - var newd = { | |
| 905 | - service_id: th.data.data.id, | |
| 906 | - service_sn:th.data.data.service_sn, | |
| 907 | - service_name:th.data.data.goods_name, | |
| 908 | - goods_num: th.data.goodsInputNum, | |
| 909 | - pick_id: th.data.sto_sele_id, | |
| 910 | - user_id:oo.user_id, | |
| 911 | - store_id:os.stoid, | |
| 912 | - money:th.data.data.shop_price, | |
| 913 | - }; | |
| 914 | - if(getApp().globalData.guide_id) { | |
| 915 | - newd['guide_id'] = getApp().globalData.guide_id; | |
| 916 | - newd['guide_type']=0; | |
| 917 | - }; | |
| 918 | - // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 | |
| 919 | - if(th.data.options.prom_type == 1) { | |
| 920 | - newd['prom_type'] = th.data.options.prom_type; | |
| 921 | - newd['prom_id'] = th.data.options.prom_id; | |
| 922 | - if(th.data.openSpecModal_flash_normal) { | |
| 923 | - newd['money'] = th.data.data.shop_price; | |
| 924 | - newd['is_pd_normal'] = 1; | |
| 925 | - } else { | |
| 926 | - newd['money'] = th.data.prom_price; | |
| 927 | - }; | |
| 928 | - }; | |
| 929 | - | |
| 930 | - | |
| 931 | - //----先看会员在购物车中是否加入了该商品----- | |
| 932 | - getApp().request.get("/api/weshop/cartService/page", { | |
| 344 | + if(getApp().globalData.is_dj_pk) th.setData({has_def:1}) | |
| 345 | + var ee = JSON.parse(JSON.stringify(e)); | |
| 346 | + //--定时器推迟一下-- | |
| 347 | + setTimeout(function () { | |
| 348 | + if (!th.data.data) return false; | |
| 349 | + var ser_card = th.data.data; | |
| 350 | + //--如果默认门店不在等级卡的默认们店以内 | |
| 351 | + if (ser_card.storageId != null && ser_card.storageId != "" && ser_card.storageId.indexOf(ee.keyid) == -1) { | |
| 352 | + ee.is_no_dis = 1; | |
| 353 | + } | |
| 354 | + | |
| 355 | + var appd = getApp().globalData; | |
| 356 | + var w_time = setInterval(function () { | |
| 357 | + if (that.data.is_get_local_ok == 0) return false; | |
| 358 | + clearInterval(w_time); | |
| 359 | + var distance = null; | |
| 360 | + var e = JSON.parse(JSON.stringify(ee)); | |
| 361 | + | |
| 362 | + //如果有开启近距离的话,同时距离优不一样了 | |
| 363 | + if (that.data.lat != null) { | |
| 364 | + //如果经纬度有变化的话 | |
| 365 | + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) { | |
| 366 | + that.data.fir_def_store = e; | |
| 367 | + that.setData({ | |
| 368 | + def_pick_store: e, | |
| 369 | + sto_sele_name: e.pickup_name, | |
| 370 | + sto_sele_id: e.pickup_id, | |
| 371 | + sto_sele_distr: e.distr_type, | |
| 372 | + sto_sele_keyid: e.keyid, | |
| 373 | + }) | |
| 374 | + } else { | |
| 375 | + //要用接口是获取距离,js的计算不准 | |
| 376 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | |
| 377 | + data: { | |
| 378 | + store_id: os.stoid, | |
| 379 | + pickup_id: e.pickup_id, | |
| 380 | + lat: th.data.lat, | |
| 381 | + lon: th.data.lon, | |
| 382 | + is_pos: 1 | |
| 383 | + }, | |
| 384 | + }).then(res => { | |
| 385 | + if (ut.ajax_ok(res)) { | |
| 386 | + e = res.data.data.pageData[0]; | |
| 387 | + if (e) { | |
| 388 | + e.is_no_dis = ee.is_no_dis; | |
| 389 | + appd.pk_store = e; | |
| 390 | + that.data.fir_def_store = e; | |
| 391 | + that.setData({ | |
| 392 | + def_pick_store: e, | |
| 393 | + sto_sele_name: e.pickup_name, | |
| 394 | + sto_sele_id: e.pickup_id, | |
| 395 | + sto_sele_distr: e.distr_type, | |
| 396 | + sto_sele_keyid: e.keyid, | |
| 397 | + }) | |
| 398 | + } | |
| 399 | + | |
| 400 | + } | |
| 401 | + }) | |
| 402 | + } | |
| 403 | + | |
| 404 | + //e.distance = distance; | |
| 405 | + appd.lat = that.data.lat; | |
| 406 | + appd.lon = that.data.lon; | |
| 407 | + | |
| 408 | + } else { | |
| 409 | + if (e) { | |
| 410 | + e.distance = null; | |
| 411 | + that.data.fir_def_store = e; | |
| 412 | + that.setData({ | |
| 413 | + def_pick_store: e, | |
| 414 | + sto_sele_name: e.pickup_name, | |
| 415 | + sto_sele_id: e.pickup_id, | |
| 416 | + sto_sele_distr: e.distr_type, | |
| 417 | + sto_sele_keyid: e.keyid, | |
| 418 | + }) | |
| 419 | + } | |
| 420 | + } | |
| 421 | + }, 500) | |
| 422 | + }, 700) | |
| 423 | + | |
| 424 | + }); | |
| 425 | + | |
| 426 | + | |
| 427 | + }, | |
| 428 | + | |
| 429 | + | |
| 430 | + onReady() { | |
| 431 | + // 用于控制保障服务折叠图标的显示 | |
| 432 | + setTimeout(() => { | |
| 433 | + wx.createSelectorQuery().selectAll(".showArea, .hideArea").boundingClientRect(res => { | |
| 434 | + | |
| 435 | + if (res.length != 0) { | |
| 436 | + this.setData({ | |
| 437 | + showFold: res[0].height < res[1].height, | |
| 438 | + }); | |
| 439 | + } | |
| 440 | + | |
| 441 | + }).exec(); | |
| 442 | + }, 1000); | |
| 443 | + | |
| 444 | + }, | |
| 445 | + | |
| 446 | + | |
| 447 | + //------------程序初始化入口------------- | |
| 448 | + async init(gid) { | |
| 449 | + var ee = this, | |
| 450 | + th = ee, | |
| 451 | + gallery = null, | |
| 452 | + is_collect = 0, | |
| 453 | + collect_id = 0, | |
| 454 | + categories3 = ee.data.categories3, | |
| 455 | + fir_com = null, | |
| 456 | + fir_quan = null, | |
| 457 | + mapurl = null, | |
| 458 | + mapurl_f_img = null; | |
| 459 | + | |
| 460 | + | |
| 461 | + // ----> 秒杀 | |
| 462 | + let prom_type = this.data.options.prom_type; | |
| 463 | + | |
| 464 | + let goods_id = this.data.options.goods_id; | |
| 465 | + if (!goods_id) goods_id = this.data.data.goods_id; | |
| 466 | + | |
| 467 | + if (prom_type) { // 进入商品详情页地址传参有带goods_id、prom_type、prom_id参数, 即从秒杀入口进入 | |
| 468 | + let prom_id = this.data.options.prom_id; | |
| 469 | + // 检查活动是否开始 | |
| 470 | + this.check_prom(goods_id, prom_type, prom_id); | |
| 471 | + | |
| 472 | + } | |
| 473 | + | |
| 474 | + | |
| 475 | + //------是否收藏---------- | |
| 476 | + await getApp().request.promiseGet("/api/weshop/goodscollect/page", { | |
| 933 | 477 | data: { |
| 934 | 478 | store_id: os.stoid, |
| 479 | + goods_id: gid, | |
| 935 | 480 | user_id: oo.user_id, |
| 936 | - service_id: th.data.data.id, | |
| 481 | + } | |
| 482 | + }).then(res => { | |
| 483 | + var t = res; | |
| 484 | + var data = t.data.data.pageData; | |
| 485 | + if (data && data.length > 0) { | |
| 486 | + is_collect = 1; | |
| 487 | + collect_id = data[0].collect_id; | |
| 488 | + } | |
| 489 | + }) | |
| 490 | + | |
| 491 | + //------获取评价的统计数量---- | |
| 492 | + await getApp().request.promiseGet("/api/weshop/serviceComment/countlist/", { | |
| 493 | + data: { | |
| 494 | + store_id: os.stoid, | |
| 495 | + service_id: gid | |
| 937 | 496 | }, |
| 938 | - success: function(re) { | |
| 939 | - //-------如果购物车中有相关的数据--------- | |
| 940 | - if (re.data.data.total > 0) { | |
| 941 | - var item = null; | |
| 942 | - // 多门店问题 | |
| 943 | - var cartGoodsNum = 0; | |
| 944 | - const tmpObj = re.data.data.pageData; | |
| 945 | - for (let i = 0; i < tmpObj.length; i++) { | |
| 946 | - if (th.data.sto_sele_id != tmpObj[i].pick_id) { | |
| 947 | - cartGoodsNum += parseInt(tmpObj[i].goods_num); | |
| 948 | - } else { | |
| 949 | - item = tmpObj[i]; | |
| 950 | - } | |
| 951 | - } | |
| 952 | - // 当前门店同类商品还没加入到购物车 但是有其他门店的同类商品 | |
| 953 | - if (th.data.prom_type == 1 && !th.data.is_normal && !item) { | |
| 954 | - | |
| 955 | - // 秒杀购物车购买 修正数量 | |
| 956 | - var snum = limitNum - boughtNum; | |
| 957 | - if (snum <= 0) { | |
| 958 | - // wx.showModal({ | |
| 959 | - // title: '超出限购数量', | |
| 960 | - // }); | |
| 961 | - getApp().my_warnning('超出限购数量', 0, self); | |
| 962 | - return false; | |
| 963 | - } | |
| 964 | - | |
| 965 | - var cSnum = snum- cartGoodsNum <= 0 ? 0 : snum- cartGoodsNum; | |
| 966 | - var cRedisNums = redisNums- cartGoodsNum <= 0 ? 0 : redisNums- cartGoodsNum; | |
| 967 | - | |
| 968 | - if (newd['goods_num'] >= redisNums){ | |
| 969 | - if (redisNums > snum) { | |
| 970 | - newd['goods_num'] = cSnum; | |
| 971 | - } else { | |
| 972 | - newd['goods_num'] = cRedisNums; | |
| 973 | - } | |
| 974 | - } else { | |
| 975 | - if (newd['goods_num'] > snum) newd['goods_num'] = cSnum; | |
| 976 | - } | |
| 977 | - | |
| 978 | - if (newd['goods_num'] <= 0) { | |
| 979 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 980 | - th.closeSpecModal(); | |
| 981 | - return false; | |
| 982 | - } | |
| 983 | - getApp().request.post("/api/weshop/cartService/save", { | |
| 984 | - data: newd, | |
| 985 | - success: function(t) { | |
| 986 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 987 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | |
| 988 | - th.setData({ | |
| 989 | - cartGoodsNum: c_num | |
| 990 | - }); | |
| 991 | - th.closeSpecModal(); | |
| 992 | - } | |
| 993 | - }); | |
| 994 | - return false; | |
| 995 | - } | |
| 996 | - | |
| 997 | - // 以下为当前门店同类商品已经加入到购物车 | |
| 998 | - var totalNum = th.data.goodsInputNum + item.goods_num; | |
| 999 | - | |
| 1000 | - // 秒杀购物车购买 修正数量 | |
| 1001 | - if (th.data.prom_type == 1 && !th.data.is_normal) { | |
| 1002 | - var snum = limitNum - boughtNum; | |
| 1003 | - if (snum <= 0) { | |
| 1004 | - // wx.showModal({ | |
| 1005 | - // title: '超出限购数量', | |
| 1006 | - // }); | |
| 1007 | - getApp().my_warnning('超出限购数量', 0, self); | |
| 1008 | - return false; | |
| 1009 | - } | |
| 1010 | - if (totalNum >= redisNums){ | |
| 1011 | - if (redisNums > snum) { | |
| 1012 | - totalNum = snum- cartGoodsNum; | |
| 1013 | - } else { | |
| 1014 | - totalNum = redisNums- cartGoodsNum; | |
| 1015 | - } | |
| 1016 | - } else { | |
| 1017 | - if (totalNum > snum) | |
| 1018 | - totalNum = snum- cartGoodsNum; | |
| 1019 | - } | |
| 1020 | - } | |
| 1021 | - | |
| 1022 | - var updata = { | |
| 1023 | - id: item.id, | |
| 1024 | - goods_num: totalNum, | |
| 1025 | - money: th.data.data.shop_price, | |
| 1026 | - store_id: os.stoid, | |
| 1027 | - }; | |
| 1028 | - | |
| 1029 | - // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价 | |
| 1030 | - if(th.data.options.prom_type == 1) { | |
| 1031 | - // updata['prom_type'] = th.data.options.prom_type; | |
| 1032 | - // updata['prom_id'] = th.data.options.prom_id; | |
| 1033 | - if(th.data.openSpecModal_flash_normal) { | |
| 1034 | - updata['money'] = th.data.data.shop_price; | |
| 1035 | - updata['is_pd_normal'] = 1; | |
| 1036 | - } else { | |
| 1037 | - updata['money'] = th.data.prom_price; | |
| 1038 | - }; | |
| 1039 | - }; | |
| 1040 | - | |
| 1041 | - if (getApp().globalData.guide_id) { | |
| 1042 | - updata['guide_id'] = getApp().globalData.guide_id; | |
| 1043 | - updata['guide_type'] = 1; | |
| 497 | + }).then(res => { | |
| 498 | + console.log('get评价统计数量', res.data.data); | |
| 499 | + var t = res; | |
| 500 | + var g = t.data.data[0]; | |
| 501 | + if (g != null && g != undefined) { | |
| 502 | + var allnum = g.c0 + g.c1 + g.c2 + g.c3 + g.c4 + g.c5; | |
| 503 | + var num2 = g.c4 + g.c5; | |
| 504 | + var num3 = g.c3; | |
| 505 | + var num4 = g.c0 + g.c1 + g.c2; | |
| 506 | + | |
| 507 | + var dd = ee.data.categories3; | |
| 508 | + dd[0].num = allnum; | |
| 509 | + dd[1].num = g.cimg; | |
| 510 | + dd[2].num = num2; | |
| 511 | + dd[3].num = num3; | |
| 512 | + dd[4].num = num4; | |
| 513 | + | |
| 514 | + categories3 = dd; | |
| 515 | + } | |
| 516 | + }); | |
| 517 | + | |
| 518 | + //----获取详情页的评价---- | |
| 519 | + await getApp().request.promiseGet("/api/weshop/serviceComment/pageComment", { | |
| 520 | + data: { | |
| 521 | + store_id: os.stoid, | |
| 522 | + service_id: gid, | |
| 523 | + pageSize: 3, | |
| 524 | + parent_id: 0, | |
| 525 | + page: 1, | |
| 526 | + is_show: 1, | |
| 527 | + }, | |
| 528 | + }).then(res => { | |
| 529 | + fir_com = res.data.data.pageData; | |
| 530 | + }); | |
| 531 | + | |
| 532 | + if (fir_com) { | |
| 533 | + for (var ind in fir_com) { | |
| 534 | + if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; | |
| 535 | + if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); | |
| 536 | + if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); | |
| 537 | + } | |
| 538 | + } | |
| 539 | + | |
| 540 | + | |
| 541 | + //this.getHistoryBuy(); //获取历史购买 | |
| 542 | + ee.setData({ | |
| 543 | + is_collect: is_collect, | |
| 544 | + collect_id: collect_id, | |
| 545 | + categories3: categories3, | |
| 546 | + fir_quan: fir_quan, | |
| 547 | + fir_comments: fir_com, | |
| 548 | + //cardComments: fir_com, | |
| 549 | + }); | |
| 550 | + | |
| 551 | + }, | |
| 552 | + | |
| 553 | + //---展示--- | |
| 554 | + // gid 在onload阶段已经保存在this.data中 | |
| 555 | + onShow: function () { | |
| 556 | + | |
| 557 | + getApp().check_can_share(this); | |
| 558 | + var that = this; | |
| 559 | + var ee = this, gid = this.data.gid, i = getApp().request; | |
| 560 | + this.data.is_timer = 1; | |
| 561 | + this.wait_for_store_config(); | |
| 562 | + | |
| 563 | + i.get("/api/weshop/serviceCard/get/" + os.stoid + "/" + ee.data.gid, { | |
| 564 | + failRollback: !0, | |
| 565 | + success: function (t) { | |
| 566 | + if (t.data.code == 0) { | |
| 567 | + // console.log('GET pic and video'); | |
| 568 | + if (t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_url) { | |
| 569 | + that.setData({ | |
| 570 | + mapurl: t.data.data.listServiceVideos[0].video_url, | |
| 571 | + }); | |
| 1044 | 572 | } |
| 1045 | - getApp().request.put("/api/weshop/cartService/update", { | |
| 1046 | - data: updata, | |
| 1047 | - success: function(t) { | |
| 1048 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 1049 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | |
| 1050 | - th.setData({ | |
| 1051 | - cartGoodsNum: c_num | |
| 1052 | - }); | |
| 1053 | - th.closeSpecModal(); | |
| 1054 | - } | |
| 573 | + | |
| 574 | + if (t.data.data.listServiceVideos && t.data.data.listServiceVideos[0] && t.data.data.listServiceVideos[0].video_img) { | |
| 575 | + that.setData({ | |
| 576 | + mapurl_f_img: t.data.data.listServiceVideos[0].video_img, | |
| 577 | + }); | |
| 578 | + } | |
| 579 | + | |
| 580 | + if (t.data.data.listServiceImages) { | |
| 581 | + that.setData({ | |
| 582 | + gallery: t.data.data.listServiceImages, | |
| 583 | + }); | |
| 584 | + } | |
| 585 | + | |
| 586 | + if (t.data.data.listServiceItem) { | |
| 587 | + that.setData({ | |
| 588 | + listServiceItem: t.data.data.listServiceItem, | |
| 589 | + }); | |
| 590 | + } | |
| 591 | + | |
| 592 | + that.setData({ | |
| 593 | + 'sele_g':t.data.data, | |
| 594 | + 'data.goods_name': t.data.data.serviceName, | |
| 595 | + 'data.shop_price': t.data.data.money, | |
| 596 | + 'data.show_price': t.data.data.show_price, | |
| 597 | + 'data.validDays': t.data.data.validDays, | |
| 598 | + 'data.serviceContent': t.data.data.serviceContent, | |
| 599 | + 'data.image_url': t.data.data.imgUrl, | |
| 600 | + 'data.goods_id': t.data.data.id, | |
| 601 | + 'data.id': t.data.data.id, | |
| 602 | + 'data.sales_sum': t.data.data.sales_sum, | |
| 603 | + 'data.storageId': t.data.data.storageId, | |
| 604 | + 'data.service_sn': t.data.data.serviceSn, | |
| 605 | + 'data.listServiceVideos': t.data.data.listServiceVideos, | |
| 606 | + // gallery: t.data.data.listServiceImages, | |
| 607 | + // mapurl: t.data.data.listServiceVideos[0].video_url, | |
| 608 | + // mapurl_f_img: t.data.data.listServiceVideos[0].video_img, | |
| 609 | + //listServiceItem: t.data.data.listServiceItem, | |
| 1055 | 610 | }); |
| 611 | + | |
| 612 | + | |
| 613 | + that.getTaohe(); | |
| 614 | + //-----商品详情--- | |
| 615 | + if (!t.data.data.serviceContent) t.data.data.serviceContent = " "; | |
| 616 | + a.wxParse("content", "html", ut.format_content(t.data.data.serviceContent), ee, 6); | |
| 617 | + e.wxParseAddFullImageUrl(ee, "content"); | |
| 618 | + | |
| 619 | + //获取重表 | |
| 620 | + getApp().promiseGet("/api/weshop/serviceItem/list", { | |
| 621 | + data: {store_id: os.stoid, service_id: t.data.data.id} | |
| 622 | + }).then(res => { | |
| 623 | + if (res.data.code == 0) { | |
| 624 | + var list = res.data.data; | |
| 625 | + that.setData({service_list: list}) | |
| 626 | + } | |
| 627 | + }) | |
| 628 | + | |
| 1056 | 629 | } else { |
| 1057 | - getApp().request.post("/api/weshop/cartService/save", { | |
| 1058 | - data: newd, | |
| 1059 | - success: function(t) { | |
| 1060 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 1061 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | |
| 1062 | - th.setData({ | |
| 1063 | - cartGoodsNum: c_num | |
| 1064 | - }); | |
| 1065 | - th.closeSpecModal(); | |
| 630 | + wx.showModal({ | |
| 631 | + title: t.data.msg, | |
| 632 | + showCancel: !1, | |
| 633 | + complete: function () { | |
| 634 | + wx.navigateBack(); | |
| 1066 | 635 | } |
| 1067 | 636 | }); |
| 1068 | 637 | } |
| 638 | + | |
| 1069 | 639 | } |
| 1070 | 640 | }); |
| 1071 | 641 | |
| 1072 | - }; | |
| 1073 | - | |
| 1074 | - | |
| 1075 | - | |
| 1076 | - | |
| 1077 | - | |
| 1078 | - | |
| 1079 | - | |
| 1080 | - }, | |
| 1081 | - | |
| 1082 | - //----------立即购买----------- | |
| 1083 | - buyNow: function(e) { | |
| 1084 | - getApp().globalData.service_now=e; | |
| 1085 | - wx.redirectTo({ | |
| 1086 | - url: "/packageA/pages/cart2_ser/cart2_ser", | |
| 1087 | - }); | |
| 1088 | - }, | |
| 1089 | - //----------增加购买数量----------- | |
| 1090 | - addCartNum: function(t) { | |
| 1091 | - this.checkCartNum(this.data.goodsInputNum + 1); | |
| 1092 | - }, | |
| 1093 | - //----------减少购买数量----------- | |
| 1094 | - subCartNum: function(t) { | |
| 1095 | - this.checkCartNum(this.data.goodsInputNum - 1); | |
| 1096 | - }, | |
| 1097 | - //----------输入框输入购买数量----------- | |
| 1098 | - inputCartNum: function(t) { | |
| 1099 | - this.checkCartNum(Number(t.detail.value)); | |
| 1100 | - }, | |
| 1101 | - | |
| 1102 | - //------检查数量是不是超出限购------ | |
| 1103 | - checkCartNum: async function(t) { | |
| 1104 | - var th = this; | |
| 1105 | - | |
| 1106 | - if(!th.data.def_pick_store) { | |
| 1107 | - wx.showModal({title: '请选择门店',}); | |
| 1108 | - return false; | |
| 1109 | - }; | |
| 1110 | - | |
| 1111 | - // 非秒杀活动 | |
| 1112 | - if(this.data.prom_type != 1) { | |
| 1113 | - this.setData({ | |
| 1114 | - goodsInputNum: t, | |
| 1115 | - }); | |
| 1116 | - }; | |
| 1117 | - | |
| 1118 | - // 秒杀活动 | |
| 1119 | - if(this.data.prom_type == 1) { | |
| 1120 | - // 如果是秒杀活动下的单独购买,is_normal为1 | |
| 1121 | - if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1; | |
| 1122 | - | |
| 1123 | - if(this.data.is_normal) {// 单独购买 | |
| 1124 | - this.setData({ | |
| 1125 | - goodsInputNum: t, | |
| 1126 | - }); | |
| 1127 | - } else {// 秒杀购买 | |
| 1128 | - | |
| 1129 | - // 获取redis当前可以购买的数量 | |
| 1130 | - // 如果数量为0,设置和显示已抢光 | |
| 1131 | - // 否则,进一步判断是否超出限购或超出库存 | |
| 1132 | - await this.getactLen().then(async function(res) { | |
| 1133 | - // res: redis可购买数量 | |
| 1134 | - // console.log('当前可以购买的数量:', res); | |
| 1135 | - if(res <= 0) { | |
| 1136 | - // 可购买数量<=0, 设置和显示已抢光 | |
| 1137 | - th.setData({ | |
| 1138 | - prom_r_null: 1, | |
| 1139 | - }); | |
| 1140 | - } else { | |
| 1141 | - // 可购买数量>0 | |
| 1142 | - // 计算自己还可以购买的数量 | |
| 1143 | - // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | |
| 1144 | - // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | |
| 1145 | - // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | |
| 1146 | - let actInfo = th.data.sele_g; | |
| 1147 | - await th.get_buy_num2().then(function (data) { | |
| 1148 | - let limited = actInfo.buy_limit; // 限购数量a | |
| 1149 | - let promcardbuynum = data.data.data.promcardbuynum; | |
| 1150 | - let buyedNum = promcardbuynum; // 自己已经购买的数量b | |
| 1151 | - let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | |
| 1152 | - | |
| 1153 | - if(canBuyNum <= 0) { | |
| 1154 | - canBuyNum = 0; | |
| 1155 | - }; | |
| 1156 | - | |
| 1157 | - if(limited > res) { | |
| 1158 | - if(t > res) { // t当前增减的数量 | |
| 1159 | - // wx.showModal({ | |
| 1160 | - // title: '超出活动库存', | |
| 1161 | - // }); | |
| 1162 | - getApp().my_warnning('超出活动库存', 0, self); | |
| 1163 | - th.setData({ | |
| 1164 | - goodsInputNum: res, | |
| 1165 | - }); | |
| 1166 | - return false; | |
| 1167 | - }; | |
| 1168 | - }; | |
| 1169 | - | |
| 1170 | - if(limited <= res) { | |
| 1171 | - if(t>canBuyNum) { | |
| 1172 | - // wx.showModal({ | |
| 1173 | - // title: '超出限购数量', | |
| 1174 | - // }); | |
| 1175 | - getApp().my_warnning('超出限购数量', 0, self); | |
| 1176 | - th.setData({ | |
| 1177 | - goodsInputNum: canBuyNum, | |
| 1178 | - }); | |
| 1179 | - return false; | |
| 1180 | - }; | |
| 1181 | - }; | |
| 1182 | - | |
| 1183 | - th.setData({ | |
| 1184 | - goodsInputNum: t, | |
| 1185 | - }); | |
| 1186 | - }); | |
| 1187 | - }; | |
| 1188 | - }); | |
| 1189 | - | |
| 1190 | - } | |
| 1191 | - | |
| 1192 | - | |
| 1193 | - }; | |
| 1194 | - | |
| 1195 | - }, | |
| 1196 | - | |
| 1197 | - | |
| 1198 | - closeSpecModal: function() { | |
| 1199 | - this.setData({ | |
| 1200 | - openSpecModal: !1, | |
| 1201 | - openSpecModal_pt: !1, | |
| 1202 | - openSpecModal_flash_normal: !1, | |
| 1203 | - }); | |
| 1204 | - }, | |
| 1205 | - | |
| 1206 | - openSpecModel: function(t) { | |
| 1207 | - var th=this; | |
| 1208 | - var open_store = t.currentTarget.dataset.ind; | |
| 1209 | - this.setData({ | |
| 1210 | - store: 0, | |
| 1211 | - choice_sort_store: 0, | |
| 1212 | - sort_store: 0, | |
| 1213 | - open_ind_store: open_store, | |
| 1214 | - }) | |
| 1215 | - //--先判断会员状态-- | |
| 1216 | - var user_info = getApp().globalData.userInfo; | |
| 1217 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 1218 | - wx.navigateTo({ | |
| 1219 | - url: '/packageE/pages/togoin/togoin', | |
| 1220 | - }) | |
| 1221 | - return false; | |
| 1222 | - } | |
| 1223 | - | |
| 1224 | - var ind = t.currentTarget.dataset.ind; | |
| 1225 | - this.setData({ | |
| 1226 | - openSpecModal: !0, | |
| 1227 | - openSpecModal_ind: ind, | |
| 1228 | - }); | |
| 1229 | - | |
| 1230 | - }, | |
| 1231 | - | |
| 1232 | - //---------点击收藏和不收藏------------ | |
| 1233 | - collectGoods: function() { | |
| 1234 | - var t = this,i = getApp().request; | |
| 1235 | - var user_id = s.globalData.user_id; | |
| 1236 | - if (user_id == '') { | |
| 1237 | - getApp().getUserFir(function() {}); | |
| 1238 | - getApp().showWarning("未登录"); | |
| 1239 | - return false; | |
| 1240 | - } else { | |
| 1241 | - | |
| 1242 | - if(t.data.is_collect_load) return false; | |
| 1243 | - t.data.is_collect_load=1; | |
| 1244 | - | |
| 1245 | - if (t.data.is_collect == 1) { //删除收藏 | |
| 1246 | - i.delete("/api/weshop/goodscollect/del/" + os.stoid + "/" + t.data.collect_id, { | |
| 1247 | - success: function(e) { | |
| 1248 | - t.data.is_collect_load=0; | |
| 1249 | - if (e.data.code == 0) { | |
| 1250 | - t.setData({ | |
| 1251 | - is_collect: 0, | |
| 1252 | - collect_id: 0, | |
| 1253 | - }); | |
| 1254 | - } | |
| 1255 | - } | |
| 642 | + this.data.enterAddressPage && (this.data.enterAddressPage = !1); | |
| 643 | + this.get_sto(); | |
| 644 | + | |
| 645 | + }, | |
| 646 | + | |
| 647 | + enterAddress: function () { | |
| 648 | + this.data.enterAddressPage = !0, wx.navigateTo({ | |
| 649 | + url: "/pages/user/address_list/address_list?operate=selectAddress" | |
| 1256 | 650 | }); |
| 1257 | - } else { | |
| 1258 | - var timestamp = Date.parse(new Date()); | |
| 1259 | - timestamp = timestamp / 1000; | |
| 1260 | - var d = { | |
| 1261 | - goods_id: t.data.data.goods_id, | |
| 1262 | - user_id: s.globalData.user_id, | |
| 1263 | - store_id: os.stoid, | |
| 1264 | - add_time: timestamp, | |
| 1265 | - type: 1, | |
| 1266 | - }; | |
| 1267 | - //加入收藏夹就是导购的ID | |
| 1268 | - if(getApp().globalData.guide_id){ | |
| 1269 | - d.guide_id=getApp().globalData.guide_id; | |
| 1270 | - d.guide_type=2; | |
| 651 | + }, | |
| 652 | + | |
| 653 | + onUnload: function () { | |
| 654 | + for (var i = 1; i < 100; i++) { | |
| 655 | + clearInterval(i); | |
| 1271 | 656 | } |
| 657 | + }, | |
| 1272 | 658 | |
| 1273 | - i.post("/api/weshop/goodscollect/save", { //添加收藏 | |
| 1274 | - data: d, | |
| 1275 | - success: function(e) { | |
| 1276 | - t.data.is_collect_load=0; | |
| 1277 | - if (e.data.code == 0) { | |
| 1278 | - t.setData({ | |
| 1279 | - is_collect: 1, | |
| 1280 | - collect_id: e.data.data.collect_id, | |
| 1281 | - }); | |
| 1282 | - } | |
| 1283 | - } | |
| 659 | + onHide: function () { | |
| 660 | + this.data.is_timer = 0; | |
| 661 | + for (var i = 1; i < 100; i++) { | |
| 662 | + clearInterval(i); | |
| 663 | + } | |
| 664 | + }, | |
| 665 | + //----------三个选项按钮----------- | |
| 666 | + tabClick: function (t) { | |
| 667 | + var e = t.currentTarget.id; | |
| 668 | + this.setData({ | |
| 669 | + activeCategoryId: e | |
| 670 | + }), 1 == e ? this.tabGoodsContent() : 2 == e && this.tabComment(); | |
| 671 | + }, | |
| 672 | + | |
| 673 | + // tabClick2: function(t) { | |
| 674 | + // this.setData({ | |
| 675 | + // activeCategoryId2: t.currentTarget.id | |
| 676 | + // }); | |
| 677 | + // }, | |
| 678 | + | |
| 679 | + tabClick3: function (t) { | |
| 680 | + var e = this; | |
| 681 | + if (t.currentTarget.id != this.data.activeCategoryId3) { | |
| 682 | + e.data.c_curr_p = 1; | |
| 683 | + this.setData({ | |
| 684 | + activeCategoryId3: t.currentTarget.id, | |
| 685 | + comments: null, comments_no_more: 0, get_c: 0, | |
| 686 | + }); | |
| 687 | + this.requestComments_new(); | |
| 688 | + } | |
| 689 | + }, | |
| 690 | + | |
| 691 | + tabComment: function () { | |
| 692 | + this.setData({ | |
| 693 | + activeCategoryId: 2, comments_no_more: 0, get_c: 0 | |
| 694 | + }), this.data.comments || this.requestComments_new(); | |
| 695 | + }, | |
| 696 | + | |
| 697 | + //商品详情的时候调用 | |
| 698 | + tabGoodsContent: function () { | |
| 699 | + this.setData({ | |
| 700 | + activeCategoryId: 1 | |
| 1284 | 701 | }); |
| 1285 | - } | |
| 1286 | - } | |
| 1287 | - }, | |
| 1288 | - //---------联系客服------------ | |
| 1289 | - contactService: function () { | |
| 1290 | - this.getTel() | |
| 1291 | - .then(() => { | |
| 1292 | - if(self.data.store_tel) { | |
| 1293 | - wx.showModal({ | |
| 1294 | - title: '联系客服', | |
| 1295 | - content: '客服热线:' + self.data.store_tel, | |
| 1296 | - confirmText: '拨打', | |
| 1297 | - success(res) { | |
| 1298 | - if(res.confirm) { | |
| 1299 | - wx.makePhoneCall({ | |
| 1300 | - phoneNumber: self.data.store_tel, | |
| 1301 | - }) | |
| 1302 | - }; | |
| 1303 | - }, | |
| 1304 | - }); | |
| 1305 | - }; | |
| 1306 | - }); | |
| 1307 | - }, | |
| 1308 | - // 获取客服电话 | |
| 1309 | - getTel() { | |
| 1310 | - return new Promise((resolve, reject) => { | |
| 1311 | - s.getConfig(function (t) { | |
| 1312 | - if (t.store_tel == undefined) { | |
| 1313 | - getApp().request.get("/api/weshop/store/get/" + os.stoid, { | |
| 1314 | - isShowLoading: 1, | |
| 1315 | - data: {}, | |
| 1316 | - success: function (rs) { | |
| 1317 | - getApp().globalData.config = rs.data.data; | |
| 1318 | - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | |
| 1319 | - getApp().my_warnning("商家未设置电话", 0, th); | |
| 1320 | - return false; | |
| 1321 | - } | |
| 1322 | - self.setData({ | |
| 1323 | - store_tel: rs.data.data.store_tel, | |
| 1324 | - }); | |
| 1325 | - // s.confirmBox("请联系客服:" + rs.data.data.store_tel); | |
| 1326 | - } | |
| 1327 | - }) | |
| 1328 | - } else { | |
| 1329 | - self.setData({ | |
| 1330 | - store_tel: t.store_tel, | |
| 1331 | - }); | |
| 1332 | - // s.confirmBox("请联系客服:" + t.store_tel); | |
| 1333 | - }; | |
| 1334 | - resolve(); | |
| 1335 | - }); | |
| 1336 | - }); | |
| 1337 | - }, | |
| 1338 | - //-------获取购物车数量---------- | |
| 1339 | - requestCardNum: function() { | |
| 1340 | - var t = this; | |
| 1341 | - getApp().request.get("/api/weshop/cart/page", { | |
| 1342 | - data: { | |
| 1343 | - store_id: os.stoid, | |
| 1344 | - user_id: getApp().globalData.user_id, | |
| 1345 | - state:0, | |
| 1346 | - is_gift:0 | |
| 1347 | - }, | |
| 1348 | - success: function(e) { | |
| 1349 | - var num = 0; | |
| 1350 | - for (var i = 0; i < e.data.data.pageData.length; i++) { | |
| 1351 | - num += e.data.data.pageData[i].goods_num; | |
| 1352 | - } | |
| 1353 | - //-- 读取服务卡的数量 -- | |
| 1354 | - getApp().promiseGet("/api/weshop/cartService/page",{ | |
| 1355 | - data:{ | |
| 1356 | - store_id: os.stoid, | |
| 1357 | - user_id: getApp().globalData.user_id, | |
| 1358 | - } | |
| 1359 | - }).then(res=>{ | |
| 1360 | - for (var i = 0; i < res.data.data.pageData.length; i++) { | |
| 1361 | - num += res.data.data.pageData[i].goods_num; | |
| 1362 | - } | |
| 1363 | - t.setData({cartGoodsNum:num}); | |
| 1364 | - }) | |
| 1365 | - | |
| 1366 | - | |
| 1367 | - } | |
| 1368 | - }); | |
| 1369 | - }, | |
| 1370 | - | |
| 1371 | - //--点击分享事件--- | |
| 1372 | - onShareAppMessage: function(t) { | |
| 1373 | - | |
| 1374 | - var th = this; | |
| 1375 | - var price = th.data.data.shop_price; | |
| 1376 | - if (th.data.prom_act) { | |
| 1377 | - price = th.data.prom_act.price; | |
| 1378 | - | |
| 1379 | - } | |
| 1380 | - var title= th.data.data.goods_name; | |
| 1381 | - var img=th.data.data.original_img; | |
| 1382 | - if(th.data.prom_type==6){ | |
| 1383 | - title=th.data.prom_act.share_title; | |
| 1384 | - img=th.data.iurl+th.data.prom_act.share_imgurl; | |
| 1385 | - } | |
| 1386 | - | |
| 1387 | - | |
| 1388 | - | |
| 1389 | - | |
| 1390 | - var url="/packageA/pages/goodsInfo/goodsInfo?goods_id=" + th.data.gid; | |
| 1391 | - if(getApp().globalData.user_id) { | |
| 1392 | - url+="&first_leader="+getApp().globalData.user_id; | |
| 1393 | - } | |
| 1394 | - | |
| 1395 | - //-- 如果房间分享,且不是会员分享的 -- | |
| 1396 | - if(getApp().globalData.room_id && | |
| 1397 | - th.data.data.goods_id==getApp().globalData.room_goods_id && | |
| 1398 | - !getApp().globalData.room_user_share | |
| 1399 | - ){ | |
| 1400 | - url+="&room_id="+getApp().globalData.room_id+"&room_user_share=1"; | |
| 1401 | - } | |
| 1402 | - | |
| 1403 | - | |
| 1404 | - var ob={ | |
| 1405 | - title: price + "元 " +title, | |
| 1406 | - path:url, | |
| 1407 | - imageUrl: img, | |
| 1408 | - }; | |
| 1409 | - | |
| 1410 | - // 如果服务卡参加秒杀活动,且后台设置了分享标题和分享图片 | |
| 1411 | - if(th.data.prom_type == 1) { | |
| 1412 | - if(th.data.sele_g && th.data.sele_g.share_title) { | |
| 1413 | - title = th.data.sele_g.share_title; | |
| 1414 | - ob.title = title; | |
| 1415 | - }; | |
| 1416 | - if(th.data.sele_g && th.data.sele_g.share_imgurl) { | |
| 1417 | - img = th.data.iurl + th.data.sele_g.share_imgurl; | |
| 1418 | - ob.imageUrl = img; | |
| 1419 | - }; | |
| 1420 | - }; | |
| 1421 | - | |
| 1422 | - return ob; | |
| 1423 | - | |
| 1424 | - }, | |
| 1425 | - | |
| 1426 | - //-----图片失败,默认图片----- | |
| 1427 | - bind_bnerr: function(e) { | |
| 1428 | - var _errImg = e.target.dataset.errorimg; | |
| 1429 | - var _errObj = {}; | |
| 1430 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | |
| 1431 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | |
| 1432 | - }, | |
| 1433 | - | |
| 1434 | - //-----图片失败,默认图片----- | |
| 1435 | - bind_bnerr2: function(e) { | |
| 1436 | - | |
| 1437 | - var _errImg = e.target.dataset.errorimg; | |
| 1438 | - var _errObj = {}; | |
| 1439 | - _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | |
| 1440 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | |
| 1441 | - }, | |
| 1442 | - | |
| 1443 | - | |
| 1444 | - //---------拿出门店分类和门店------------ | |
| 1445 | - get_sto(e) { | |
| 1446 | - var th = this,that=this; | |
| 1447 | - var timer_get = setInterval(function() { | |
| 1448 | - if (th.data.is_get_local_ok == 0) return false; | |
| 1449 | - var i = getApp().request; | |
| 1450 | - if (!th.data.data) return false; | |
| 1451 | - var dd= { | |
| 1452 | - store_id: os.stoid, | |
| 1453 | - isstop: 0, | |
| 1454 | - is_pos: 1, | |
| 1455 | - pageSize: 2000 | |
| 1456 | - } | |
| 1457 | - //如果有距离的话 | |
| 1458 | - if (th.data.lat != null) { | |
| 1459 | - dd.lat = th.data.lat; | |
| 1460 | - dd.lon = th.data.lon; | |
| 1461 | - } | |
| 1462 | - clearInterval(timer_get); | |
| 1463 | - | |
| 1464 | - //如果会员是有默认的门店话 | |
| 1465 | - if(!th.data.def_pick_store && th.data.fir_def_store){ | |
| 1466 | - th.setData({def_pick_store:th.data.fir_def_store}); | |
| 1467 | - } | |
| 1468 | - | |
| 1469 | - wx.showLoading({ | |
| 1470 | - title:'加载中.' | |
| 1471 | - }); | |
| 1472 | - //----------获取门店---------------- | |
| 1473 | - getApp().request.promiseGet("/api/weshop/pickup/list", { | |
| 1474 | - data: dd, | |
| 1475 | - }).then(res => { | |
| 1476 | - var e = res; | |
| 1477 | - if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length>0) { | |
| 1478 | - | |
| 1479 | - var his_cate_num=0; | |
| 1480 | - for(let i in e.data.data.pageData){ | |
| 1481 | - let item=e.data.data.pageData[i]; | |
| 1482 | - if(item.category_id>0){ | |
| 1483 | - his_cate_num=1;break; | |
| 1484 | - } | |
| 702 | + }, | |
| 703 | + | |
| 704 | + //-----------------拼单生成方法--------------------- | |
| 705 | + addCart_pt: function () { | |
| 706 | + var th = this; | |
| 707 | + if (this.data.is_normal == 0) { | |
| 708 | + //看一下有没有起购数,如果有起购数,要计算起购数 | |
| 709 | + var qnum = parseFloat(th.data.prom_act.minbuynum); | |
| 710 | + if (qnum > 0 && th.data.goodsInputNum < qnum) { | |
| 711 | + getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | |
| 712 | + return false; | |
| 1485 | 713 | } |
| 1486 | - e.his_cate_num=his_cate_num; | |
| 1487 | - | |
| 1488 | - //--普通门店排版-- | |
| 1489 | - setTimeout(function(){ | |
| 1490 | - var sto_list=th.data.data.storageId; | |
| 1491 | - if(sto_list){ | |
| 1492 | - for (var k = 0; k < e.data.data.pageData.length; k++) { | |
| 1493 | - var it=e.data.data.pageData[k]; | |
| 1494 | - if (sto_list.indexOf(it.keyid)==-1) { | |
| 1495 | - //删除 | |
| 1496 | - e.data.data.pageData.splice(k--, 1); | |
| 1497 | - } | |
| 1498 | - } | |
| 1499 | - } | |
| 1500 | - | |
| 1501 | - //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 | |
| 1502 | - if(dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store)=='{}') && th.data.bconfig && th.data.bconfig.is_sort_storage){ | |
| 1503 | - th.setData({ | |
| 1504 | - def_pick_store:e.data.data.pageData[0], | |
| 1505 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | |
| 1506 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | |
| 1507 | - sto_sele_distr: e.data.data.pageData[0].distr_type | |
| 1508 | - }); | |
| 1509 | - th.data.fir_def_store=e.data.data.pageData[0]; | |
| 1510 | - } | |
| 1511 | - | |
| 1512 | - //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | |
| 1513 | - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store)!='{}'){ | |
| 1514 | - for (var k = 0; k < e.data.data.pageData.length; k++) { | |
| 1515 | - if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | |
| 1516 | - e.data.data.pageData.splice(k, 1); //删除 | |
| 1517 | - break; | |
| 1518 | - } | |
| 1519 | - } | |
| 1520 | - e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | |
| 1521 | - } | |
| 1522 | - | |
| 1523 | - th.setData({all_pick_list:e.data.data.pageData}); | |
| 1524 | - th.deal_pickup(e); | |
| 1525 | - },800) | |
| 1526 | - | |
| 714 | + th.addcart_pt_func(); | |
| 715 | + } else { | |
| 716 | + th.addcart_pt_func(); | |
| 1527 | 717 | } |
| 1528 | - }) | |
| 1529 | - }, 200) | |
| 1530 | - }, | |
| 1531 | - | |
| 1532 | - | |
| 1533 | - //------------处理门店--------------- | |
| 1534 | - deal_pickup(e){ | |
| 1535 | - var th=this; | |
| 1536 | - if(!th.data.data) return false | |
| 1537 | - wx.hideLoading(); | |
| 1538 | - //单总量超出5个的时候 | |
| 1539 | - if (e.data.data.total > 10 && e.his_cate_num) { | |
| 1540 | - getApp().request.get("/api/weshop/storagecategory/page", { | |
| 1541 | - data: { | |
| 1542 | - store_id: os.stoid, | |
| 1543 | - pageSize: 1000, | |
| 1544 | - orderField:"sort", | |
| 1545 | - orderType:'asc', | |
| 1546 | - }, | |
| 1547 | - success: function(ee) { | |
| 1548 | - if (ee.data.code == 0) { | |
| 1549 | - | |
| 1550 | - var check_all_cate=0; | |
| 1551 | - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){ | |
| 1552 | - for(let i in ee.data.data.pageData){ | |
| 1553 | - let item=ee.data.data.pageData[i]; | |
| 1554 | - if(item.is_show==1){ | |
| 1555 | - check_all_cate=1;break | |
| 1556 | - } | |
| 1557 | - } | |
| 1558 | - } | |
| 1559 | - | |
| 1560 | - if (check_all_cate) { | |
| 1561 | - | |
| 1562 | - | |
| 1563 | - var sto_cate = ee.data.data.pageData; | |
| 1564 | - var sto_arr = e.data.data.pageData; | |
| 1565 | - var newarr = new Array(); | |
| 1566 | - var qita = new Array(); | |
| 1567 | - | |
| 1568 | - var is_del_pk=0; | |
| 1569 | - | |
| 1570 | - //----要进行门店分组-------- | |
| 1571 | - for (var i = 0; i < sto_arr.length; i++) { | |
| 1572 | - //找一下这个门店有没有在分类数组内 | |
| 1573 | - var find2 = 0, find2name = "",sort=0; | |
| 1574 | - is_del_pk=0; | |
| 1575 | - for (var m = 0; m < sto_cate.length; m++) { | |
| 1576 | - if (sto_arr[i].category_id == sto_cate[m].cat_id) { | |
| 1577 | - if (sto_cate[m].is_show != 1) { | |
| 1578 | - is_del_pk = 1; | |
| 1579 | - sto_arr.splice(i, 1); | |
| 1580 | - i--; | |
| 1581 | - } else { | |
| 1582 | - find2 = sto_cate[m].cat_id; | |
| 1583 | - find2name = sto_cate[m].cat_name; | |
| 1584 | - sort = sto_cate[m].sort; | |
| 1585 | - is_del_pk = 0; | |
| 1586 | - } | |
| 1587 | - break; | |
| 1588 | - } | |
| 1589 | - } | |
| 1590 | - if(is_del_pk) continue; | |
| 1591 | - | |
| 1592 | - if (newarr.length > 0) { | |
| 1593 | - var find = 0; | |
| 1594 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
| 1595 | - if (find2 != 0) { | |
| 1596 | - for (var ii = 0; ii < newarr.length; ii++) { | |
| 1597 | - if (sto_arr[i].category_id == newarr[ii].cat_id) { | |
| 1598 | - newarr[ii].s_arr.push(sto_arr[i]); | |
| 1599 | - find = 1; | |
| 1600 | - break; | |
| 1601 | - } | |
| 1602 | - } | |
| 1603 | - if (find == 0) { | |
| 1604 | - var arr0 = new Array(); | |
| 1605 | - arr0.push(sto_arr[i]); | |
| 1606 | - var item = { | |
| 1607 | - cat_id: find2, | |
| 1608 | - name: find2name, | |
| 1609 | - sort:sort, | |
| 1610 | - s_arr: arr0 | |
| 1611 | - }; | |
| 1612 | - newarr.push(item); | |
| 1613 | - } | |
| 1614 | - } else { | |
| 1615 | - qita.push(sto_arr[i]); | |
| 1616 | - } | |
| 1617 | - } else { | |
| 1618 | - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
| 1619 | - if (find2 != 0) { | |
| 1620 | - var arr0 = new Array(); | |
| 1621 | - arr0.push(sto_arr[i]); | |
| 1622 | - var item = { | |
| 1623 | - cat_id: find2, | |
| 1624 | - name: find2name, | |
| 1625 | - sort:sort, | |
| 1626 | - s_arr: arr0 | |
| 1627 | - }; | |
| 1628 | - newarr.push(item); | |
| 1629 | - } else { | |
| 1630 | - qita.push(sto_arr[i]); | |
| 1631 | - } | |
| 718 | + }, | |
| 719 | + | |
| 720 | + addcart_pt_func: function () { | |
| 721 | + if (oo.user_id == null) { | |
| 722 | + s.my_warnning("还未登录!", 0, this); | |
| 723 | + return; | |
| 724 | + } | |
| 725 | + var e = this, | |
| 726 | + th = e, | |
| 727 | + o = this.data.sele_g; | |
| 728 | + | |
| 729 | + //----------添加到购物车时,要判断限购数量,-------- | |
| 730 | + e.get_buy_num(async function (ee) { | |
| 731 | + | |
| 732 | + //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购--- | |
| 733 | + if (th.data.promcardbuynum != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { | |
| 734 | + if (th.data.goodsInputNum + th.data.promcardbuynum > th.data.prom_buy_limit) { | |
| 735 | + | |
| 736 | + s.my_warnning('超出商品活动限购', 0, th); | |
| 737 | + var num = th.data.prom_buy_limit - th.data.promcardbuynum; | |
| 738 | + if (num < 0) num = 0; | |
| 739 | + th.setData({goodsInputNum: num}) | |
| 740 | + return false; | |
| 1632 | 741 | } |
| 1633 | - } | |
| 742 | + } | |
| 743 | + | |
| 744 | + var redis_num = 0 | |
| 745 | + //不是普通购买的时候 | |
| 746 | + if (th.data.is_normal != 1) { | |
| 747 | + //-------判断活动是否抢光--------- | |
| 748 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.prom_id, { | |
| 749 | + 1: 1 | |
| 750 | + }).then(res => { | |
| 751 | + redis_num = res.data.data; | |
| 752 | + }) | |
| 1634 | 753 | |
| 1635 | - var def_arr = new Array(); | |
| 1636 | - //-- 开始就看10个门店 -- | |
| 1637 | - for (var k = 0; k < 10; k++) { | |
| 1638 | - if (k == sto_arr.length) break; | |
| 1639 | - def_arr.push(sto_arr[k]); | |
| 754 | + if (th.data.goodsInputNum > redis_num) { | |
| 755 | + s.my_warnning('超出商品活动库存', 0, th); | |
| 756 | + th.setData({goodsInputNum: redis_num}) | |
| 757 | + | |
| 758 | + return false; | |
| 1640 | 759 | } |
| 760 | + } | |
| 761 | + | |
| 762 | + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | |
| 763 | + if (th.data.goodsInputNum > o.store_count) { | |
| 764 | + th.setData({goodsInputNum: o.store_count}) | |
| 765 | + return s.my_warnning("超出商品库存", 0, th); | |
| 766 | + } | |
| 1641 | 767 | |
| 768 | + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | |
| 1642 | 769 | th.setData({ |
| 1643 | - def_pickpu_list: def_arr, | |
| 1644 | - pickpu_list: ee.data.data.pageData | |
| 770 | + sto_sele_name: "" | |
| 1645 | 771 | }); |
| 1646 | - | |
| 1647 | - //门店分类要排序下 | |
| 1648 | - function compare(property){ | |
| 1649 | - return function(a,b){ | |
| 1650 | - var value1 = a[property]; | |
| 1651 | - var value2 = b[property]; | |
| 1652 | - return value1 - value2; | |
| 1653 | - } | |
| 1654 | - } | |
| 1655 | - if(newarr.length>0) | |
| 1656 | - newarr.sort(compare("sort")); | |
| 1657 | - | |
| 1658 | - //----安排其他的分类----- | |
| 1659 | - if (qita.length > 0) { | |
| 1660 | - var item = { | |
| 1661 | - cat_id: -1, | |
| 1662 | - name: "其他", | |
| 1663 | - s_arr: qita | |
| 1664 | - }; | |
| 1665 | - newarr.push(item); | |
| 1666 | - } | |
| 772 | + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | |
| 773 | + //--------------此时操作的数据------------ | |
| 774 | + var newd = { | |
| 775 | + id: o.id, | |
| 776 | + goods_num: th.data.goodsInputNum, | |
| 777 | + pick_id: th.data.sto_sele_id, | |
| 778 | + keyid: th.data.sto_sele_keyid, | |
| 779 | + user_id: oo.user_id, | |
| 780 | + store_id: th.data.stoid, | |
| 781 | + goods_price: o.money, | |
| 782 | + goods_name: o.serviceName, | |
| 783 | + goods_sn: o.serviceSn, | |
| 784 | + sku: o.sku, | |
| 785 | + }; | |
| 1667 | 786 | |
| 1668 | - var sd={ | |
| 1669 | - all_sto: newarr, | |
| 1670 | - is_show_sto_cat:1 | |
| 1671 | - } | |
| 1672 | - if(!sto_arr || sto_arr.length<=10){ | |
| 1673 | - sd.is_show_sto_cat=-1; | |
| 1674 | - sd.only_pk=sto_arr; | |
| 787 | + //---是不是从收藏夹出来的--- | |
| 788 | + if (th.data.c_guide_id) { | |
| 789 | + newd['guide_id'] = th.data.c_guide_id; | |
| 790 | + newd['guide_type'] = 2; | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + } else { | |
| 796 | + if (getApp().globalData.guide_id) { | |
| 797 | + newd['guide_id'] = getApp().globalData.guide_id; | |
| 798 | + newd['guide_type'] = 0; | |
| 1675 | 799 | } |
| 1676 | - th.setData(sd); | |
| 800 | + } | |
| 1677 | 801 | |
| 802 | + //让商品带上房间号 | |
| 803 | + if (!th.data.sys_switch.is_skuroom_id && th.data.sys_switch.is_skuroom_id == 1) { | |
| 804 | + if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | |
| 805 | + newd.room_id = getApp().globalData.room_id; | |
| 806 | + } | |
| 1678 | 807 | } else { |
| 1679 | - th.setData({ | |
| 1680 | - is_show_sto_cat: -1, | |
| 1681 | - only_pk: e.data.data.pageData | |
| 1682 | - }); | |
| 1683 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
| 1684 | - if (!th.data.def_pick_store) { | |
| 1685 | - th.setData({def_pick_store:e.data.data.pageData[0]}) | |
| 1686 | - } | |
| 808 | + if (newd.goods_id == getApp().globalData.room_goods_id) { | |
| 809 | + newd.room_id = getApp().globalData.room_id; | |
| 810 | + } | |
| 1687 | 811 | } |
| 1688 | - } else { | |
| 1689 | - th.setData({ | |
| 1690 | - is_show_sto_cat: -1, | |
| 1691 | - only_pk: e.data.data.pageData | |
| 1692 | - }); | |
| 1693 | - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
| 1694 | - if (!th.data.def_pick_store) { | |
| 1695 | - th.setData({def_pick_store:e.data.data.pageData[0]}) | |
| 812 | + | |
| 813 | + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | |
| 814 | + | |
| 815 | + if (th.data.is_normal == 1) { | |
| 816 | + var conf = th.data.bconfig; | |
| 817 | + if (conf.switch_list) { | |
| 818 | + var s_list = JSON.parse(conf.switch_list); | |
| 819 | + //如果后台有开启等级价的功能 | |
| 820 | + if (parseInt(s_list.rank_switch) == 2) { | |
| 821 | + var card_price = o[getApp().globalData.userInfo['card_field']]; | |
| 822 | + //如果会员有等级价 | |
| 823 | + if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | |
| 824 | + && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | |
| 825 | + newd.goods_price = card_price; | |
| 826 | + } | |
| 827 | + } | |
| 828 | + } | |
| 1696 | 829 | } |
| 1697 | 830 | |
| 1698 | - } | |
| 1699 | - } | |
| 1700 | - }); | |
| 1701 | - } else { | |
| 1702 | - th.setData({ | |
| 1703 | - is_show_sto_cat: 0, | |
| 1704 | - only_pk: e.data.data.pageData | |
| 1705 | - }); | |
| 1706 | - //-----如果没有默认门店,要取第一个门店作为默认店------ | |
| 1707 | - if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | |
| 1708 | - | |
| 1709 | - if(e.data.data && e.data.data.pageData && e.data.data.pageData.length>0){ | |
| 1710 | - th.setData({ | |
| 1711 | - def_pick_store:e.data.data.pageData[0], | |
| 1712 | - sto_sele_name: e.data.data.pageData[0].pickup_name, | |
| 1713 | - sto_sele_id: e.data.data.pageData[0].pickup_id, | |
| 1714 | - sto_sele_distr: e.data.data.pageData[0].distr_type | |
| 1715 | - }) | |
| 1716 | - } | |
| 1717 | - | |
| 1718 | - } | |
| 1719 | - } | |
| 1720 | - }, | |
| 1721 | - | |
| 1722 | - //加载更多是靠这个函数 | |
| 1723 | - onReachBottom: function() { | |
| 1724 | - if (this.data.activeCategoryId == 2){ | |
| 1725 | - if(!this.data.comments_no_more) this.requestComments_new(); | |
| 1726 | - } | |
| 1727 | - | |
| 1728 | - var goods_list = this.selectComponent("#goods_list"); //组件的id | |
| 1729 | - if (goods_list) goods_list.get_list(); | |
| 1730 | - }, | |
| 1731 | - | |
| 1732 | - | |
| 1733 | - //---小于10的格式化函数---- | |
| 1734 | - timeFormat(param) { | |
| 1735 | - return param < 10 ? '0' + param : param; | |
| 1736 | - }, | |
| 1737 | - | |
| 1738 | - | |
| 1739 | - //--定义的保存图片方法,分享团--- | |
| 1740 | - saveImageToPhotosAlbum: function() { | |
| 1741 | - //--先判断会员状态-- | |
| 1742 | - var user_info = getApp().globalData.userInfo; | |
| 1743 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 1744 | - //getApp().my_warnning("请先登录",0,this); | |
| 1745 | - wx.navigateTo({ url: '/packageE/pages/togoin/togoin', }) | |
| 1746 | - return false; | |
| 1747 | - } | |
| 1748 | - | |
| 1749 | - //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 | |
| 1750 | - var type = this.data.prom_type; | |
| 1751 | - if (type == 6) type = 2; | |
| 1752 | - if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | |
| 1753 | - | |
| 1754 | - wx.showLoading({ | |
| 1755 | - title: '生成中...', | |
| 1756 | - }) | |
| 1757 | - var that = this, | |
| 1758 | - th = that; | |
| 1759 | - //设置画板显示,才能开始绘图 | |
| 1760 | - that.setData({ | |
| 1761 | - canvasHidden: false | |
| 1762 | - }) | |
| 1763 | - | |
| 1764 | - var app = getApp(); | |
| 1765 | - var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | |
| 1766 | - var path2 = that.data.data.original_img; | |
| 1767 | - var scene = th.data.gid+""; | |
| 1768 | - var user_id = getApp().globalData.user_id?getApp().globalData.user_id:0; | |
| 1769 | - if(user_id>0) { | |
| 1770 | - scene+="_"+user_id; | |
| 1771 | - } | |
| 1772 | - //-- 如果不是会员分享过来的要分享给别人 -- | |
| 1773 | - if(getApp().globalData.room_id && th.data.data.goods_id==getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | |
| 1774 | - //固定房间是第3个字符 | |
| 1775 | - if(!user_id) scene+="_0"; | |
| 1776 | - scene+="_"+getApp().globalData.room_id ; | |
| 1777 | - } | |
| 1778 | - ///二微码 | |
| 1779 | - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
| 1780 | - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
| 1781 | - | |
| 1782 | - console.log(path3); | |
| 1783 | - | |
| 1784 | - //读取文件成功则OK-- | |
| 1785 | - wx.getImageInfo({ | |
| 1786 | - src: path3, | |
| 1787 | - success: function(res) { | |
| 1788 | - //回调写法 | |
| 1789 | - th.get_head_temp(th.get_goods_temp, function() { | |
| 1790 | - var vpath = res.path; | |
| 1791 | - var context = wx.createCanvasContext('share'); | |
| 1792 | - //先画背景 | |
| 1793 | - var pg_path = "../../../images/share/share_bg.png"; | |
| 1794 | - | |
| 1795 | - // context.fillStyle="#FFFFFF"; | |
| 1796 | - // context.fillRect(0,0,554 * unit, 899 * unit); | |
| 1797 | - | |
| 1798 | - //-- 如果有自定义海报的时候,判断背景的图片 -- | |
| 1799 | - if(th.data.share_b_img){ | |
| 1800 | - pg_path=th.data.share_b_img; | |
| 1801 | - } | |
| 1802 | - context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 1803 | - | |
| 1804 | - //-- 是自定义海报的情况下 -- | |
| 1805 | - if(th.data.poster && parseInt(th.data.poster.style)==2) { | |
| 1806 | - //在线上分享人的情况下 | |
| 1807 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 1808 | - //获取坐标 | |
| 1809 | - var x=parseFloat(th.data.poster.head_x)*2; | |
| 1810 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 1811 | - var x1=(x+90) *unit; | |
| 1812 | - var y1=(y+50) *unit; | |
| 1813 | - //--昵称--- | |
| 1814 | - context.setFontSize(24 * unit) | |
| 1815 | - context.setFillStyle("black") | |
| 1816 | - context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 1817 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 1818 | - //强烈推荐 改许程 | |
| 1819 | - var tj_path = "../../../images/share/q_tj.png"; | |
| 1820 | - context.drawImage(tj_path, x1 + width, y1-22*unit, 85 * unit, 30 * unit); | |
| 1821 | - context.setFontSize(16 * unit) | |
| 1822 | - context.setLineJoin('round'); //交点设置成圆角 | |
| 1823 | - context.setFillStyle("white") | |
| 1824 | - context.fillText('强烈推荐', x1 + width+8*unit, y1-1*unit); | |
| 1825 | - | |
| 1826 | - //context.setFillStyle("black") | |
| 1827 | - //context.setFontSize(24 * unit) | |
| 1828 | - //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit); | |
| 1829 | - } | |
| 1830 | - } else { | |
| 1831 | - //--昵称--- | |
| 1832 | - context.setFontSize(24 * unit) | |
| 1833 | - context.setFillStyle("black") | |
| 1834 | - context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 1835 | - var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 1836 | - //强烈推荐 改许程 | |
| 1837 | - var tj_path = "../../../images/share/q_tj.png"; | |
| 1838 | - context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | |
| 1839 | - context.setFontSize(16 * unit); | |
| 1840 | - context.setLineJoin('round'); //交点设置成圆角 | |
| 1841 | - context.setFillStyle("white"); | |
| 1842 | - context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | |
| 1843 | - } | |
| 1844 | - | |
| 1845 | - | |
| 1846 | - //---产品名称--- | |
| 1847 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
| 1848 | - if(type!=4){ | |
| 1849 | - context.setFillStyle("black"); | |
| 1850 | - context.setFontSize(21.3 * unit) | |
| 1851 | - th.draw_Text(context, th.data.data.goods_name, | |
| 1852 | - 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 1853 | - //------产品的价格------- | |
| 1854 | - context.setFontSize(23 * unit) | |
| 1855 | - context.setFillStyle("red") | |
| 1856 | - context.fillText("¥", 416 * unit, 185 * unit); | |
| 1857 | - context.setFontSize(31 * unit) | |
| 1858 | - var pri0 = th.data.data.shop_price; | |
| 1859 | - if (th.data.prom_act) | |
| 1860 | - pri0 = th.data.prom_act.price; | |
| 1861 | - pri0 = parseFloat(pri0).toFixed(2); | |
| 1862 | - context.fillText(pri0, 438 * unit, 185 * unit); | |
| 1863 | - //---市场价划掉--- | |
| 1864 | - context.setFillStyle("gray") | |
| 1865 | - context.setFontSize(22 * unit) | |
| 1866 | - context.fillText("¥" + th.data.data.market_price, 426 * unit, 213 * unit); | |
| 1867 | - context.setStrokeStyle('gray'); | |
| 1868 | - context.setLineWidth(1 * unit); | |
| 1869 | - context.moveTo(426 * unit, 206 * unit); | |
| 1870 | - context.lineTo(510 * unit, 206 * unit); | |
| 1871 | - context.stroke(); | |
| 1872 | - | |
| 1873 | - }else{ | |
| 1874 | - context.setFillStyle("black"); | |
| 1875 | - context.setFontSize(21.3 * unit) | |
| 1876 | - th.draw_Text(context, th.data.data.goods_name, | |
| 1877 | - 38 * unit, 170 * unit, 20 * unit, 300*unit, unit); | |
| 1878 | - //------ 产品的价格 ----- | |
| 1879 | - var pri0 = th.data.prom_act.addmoney; | |
| 1880 | - var integral=th.data.prom_act.integral; | |
| 1881 | - var text= ""; | |
| 1882 | - if(integral){text=integral+"积分"; } | |
| 1883 | - if(pri0 && integral){ text+="+";} | |
| 1884 | - if(pri0){ text+="¥"+pri0;} | |
| 1885 | - | |
| 1886 | - if(!pri0 && !integral){ text="0积分";} | |
| 1887 | - context.setFillStyle("red"); | |
| 1888 | - context.fillText(text, 38 * unit, 235 * unit); | |
| 1889 | - | |
| 1890 | - } | |
| 1891 | - | |
| 1892 | - //---中间大图--- | |
| 1893 | - context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | |
| 1894 | - //-------大图后面就不一样了----------- | |
| 1895 | - switch (type) { | |
| 1896 | - case 0: //普通商品的展示 | |
| 1897 | - case 4: | |
| 1898 | - //中间的几个字 | |
| 1899 | - if(th.data.poster && parseInt(th.data.poster.style)==2 ){ | |
| 1900 | - if(parseInt(th.data.poster.show_quality)){ | |
| 1901 | - var g_path = "../../../images/share/s_gou.png"; | |
| 1902 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1903 | - context.setFillStyle("red") | |
| 1904 | - context.setFontSize(18 * unit) | |
| 1905 | - context.fillText("正品保证", 84 * unit, 690 * unit); | |
| 1906 | - | |
| 1907 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1908 | - context.setFillStyle("red") | |
| 1909 | - context.setFontSize(18 * unit) | |
| 1910 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | |
| 1911 | - | |
| 1912 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1913 | - context.setFillStyle("red") | |
| 1914 | - context.setFontSize(18 * unit) | |
| 1915 | - context.fillText("官方验证", 420 * unit, 690 * unit); | |
| 1916 | - } | |
| 1917 | - | |
| 1918 | - }else{ | |
| 1919 | - var g_path = "../../../images/share/s_gou.png"; | |
| 1920 | - context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1921 | - context.setFillStyle("red") | |
| 1922 | - context.setFontSize(18 * unit) | |
| 1923 | - context.fillText("正品保证", 84 * unit, 690 * unit); | |
| 1924 | - | |
| 1925 | - context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1926 | - context.setFillStyle("red") | |
| 1927 | - context.setFontSize(18 * unit) | |
| 1928 | - context.fillText("纯实体店", 246 * unit, 690 * unit); | |
| 1929 | - | |
| 1930 | - context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); | |
| 1931 | - context.setFillStyle("red") | |
| 1932 | - context.setFontSize(18 * unit) | |
| 1933 | - context.fillText("官方验证", 420 * unit, 690 * unit); | |
| 1934 | - } | |
| 1935 | - | |
| 1936 | - | |
| 1937 | - //---画线--- | |
| 1938 | - context.setLineWidth(1 * unit) | |
| 1939 | - context.moveTo(32 * unit, 710 * unit) | |
| 1940 | - context.lineTo(520 * unit, 710 * unit) | |
| 1941 | - context.stroke(); | |
| 1942 | - | |
| 1943 | - //---文字--- | |
| 1944 | - context.setFillStyle("black") | |
| 1945 | - context.setFontSize(22 * unit) | |
| 1946 | - | |
| 1947 | - if(type==0){ | |
| 1948 | - // 原来start ---> | |
| 1949 | - context.setFontSize(24 * unit) | |
| 1950 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | |
| 1951 | - | |
| 1952 | - context.setFontSize(22 * unit) | |
| 1953 | - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit); | |
| 1954 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); | |
| 1955 | - | |
| 1956 | - }else{ | |
| 1957 | - context.setFontSize(24 * unit) | |
| 1958 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); | |
| 1959 | - context.setFontSize(22 * unit) | |
| 1960 | - context.fillText("长按识别二维码", 40 * unit, 806 * unit); | |
| 1961 | - context.fillText("立即开始兑换", 40 * unit, 846 * unit); | |
| 1962 | - | |
| 1963 | - | |
| 1964 | - } | |
| 1965 | - | |
| 1966 | - //---二维吗图--- | |
| 1967 | - //-- 自定义海报 -- | |
| 1968 | - if(th.data.poster){ | |
| 1969 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 1970 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 1971 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 1972 | - }else{ | |
| 1973 | - //---二维吗图--- | |
| 1974 | - context.drawImage(vpath, 410 * unit, 726 * unit, 115 * unit, 125 * unit); | |
| 1975 | - } | |
| 1976 | - | |
| 1977 | - break; | |
| 1978 | - case 1: //秒杀商品的展示 | |
| 1979 | - //---画线--- | |
| 1980 | - context.setLineWidth(1 * unit) | |
| 1981 | - context.moveTo(32 * unit, 670 * unit) | |
| 1982 | - context.lineTo(520 * unit, 670 * unit) | |
| 1983 | - context.stroke(); | |
| 1984 | - | |
| 1985 | - //画秒杀的图片 | |
| 1986 | - var miaos_path = '../../../images/share/miao_share.png'; | |
| 1987 | - context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); | |
| 1988 | - | |
| 1989 | - context.setFillStyle("black") | |
| 1990 | - context.setFontSize(24 * unit) | |
| 1991 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit); | |
| 1992 | - //---文字--- | |
| 1993 | - context.setFontSize(22 * unit) | |
| 1994 | - context.setFillStyle("black") | |
| 1995 | - context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit); | |
| 1996 | - context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit); | |
| 1997 | - | |
| 1998 | - | |
| 1999 | - //---二维吗图--- | |
| 2000 | - //-- 自定义海报 -- | |
| 2001 | - if(th.data.poster){ | |
| 2002 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 2003 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 2004 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 2005 | - }else{ | |
| 2006 | - //---二维吗图--- | |
| 2007 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 2008 | - } | |
| 2009 | - break; | |
| 2010 | - | |
| 2011 | - case 2: //会员团和商家团的展示 | |
| 2012 | - //---画线--- | |
| 2013 | - context.setLineWidth(1 * unit) | |
| 2014 | - context.moveTo(32 * unit, 670 * unit) | |
| 2015 | - context.lineTo(520 * unit, 670 * unit) | |
| 2016 | - context.stroke(); | |
| 2017 | - //---文字--- | |
| 2018 | - | |
| 2019 | - context.setFillStyle("black") | |
| 2020 | - context.setFontSize(24 * unit) | |
| 2021 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
| 2022 | - | |
| 2023 | - //绘制成团图片 | |
| 2024 | - var ct_img = "../../../images/share/ct_num.png"; | |
| 2025 | - context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 2026 | - var ct_num = th.data.prom_act.ct_num; | |
| 2027 | - context.setFontSize(14 * unit) | |
| 2028 | - context.font = 'normal'; | |
| 2029 | - context.setFillStyle("red") | |
| 2030 | - if (ct_num < 10) { | |
| 2031 | - context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | |
| 2032 | - } else { | |
| 2033 | - context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | |
| 2034 | - } | |
| 2035 | - context.setFontSize(22 * unit) | |
| 2036 | - context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | |
| 2037 | - | |
| 2038 | - context.setFillStyle("gray") | |
| 2039 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | |
| 2040 | - context.setFillStyle("black") | |
| 2041 | - context.font = 'normal bold 18px sans-serif'; | |
| 2042 | - context.setFontSize(21.3 * unit) | |
| 2043 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | |
| 2044 | - | |
| 2045 | - | |
| 2046 | - //---二维吗图--- | |
| 2047 | - //-- 自定义海报 -- | |
| 2048 | - if(th.data.poster){ | |
| 2049 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 2050 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 2051 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 2052 | - }else{ | |
| 2053 | - //---二维吗图--- | |
| 2054 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 2055 | - } | |
| 2056 | - break | |
| 2057 | - case 3: //阶梯团的展示 | |
| 2058 | - //---画线--- | |
| 2059 | - context.setLineWidth(1 * unit) | |
| 2060 | - context.moveTo(32 * unit, 670 * unit) | |
| 2061 | - context.lineTo(520 * unit, 670 * unit) | |
| 2062 | - context.stroke(); | |
| 2063 | - //---文字--- | |
| 2064 | - | |
| 2065 | - context.setFillStyle("black") | |
| 2066 | - context.setFontSize(24 * unit) | |
| 2067 | - context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
| 2068 | - | |
| 2069 | - //---绘制中间阶梯的价格--- | |
| 2070 | - var list = th.data.prom_act.ct_rylist; | |
| 2071 | - for (var i = 0; i < list.length; i++) { | |
| 2072 | - var item = list[i]; | |
| 2073 | - var wi = i * 90 * unit; | |
| 2074 | - context.font = 'normal'; | |
| 2075 | - context.setFontSize(16 * unit) | |
| 2076 | - context.setFillStyle("red") | |
| 2077 | - context.fillText("¥", 40 * unit + wi, 756 * unit); | |
| 2078 | - context.setFontSize(22 * unit) | |
| 2079 | - var pri = parseFloat(item.price).toFixed(2); | |
| 2080 | - context.fillText(pri, 56 * unit + wi, 756 * unit); | |
| 2081 | - context.setFillStyle("gray") | |
| 2082 | - context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | |
| 2083 | - } | |
| 2084 | - //----------------下面部分---------------- | |
| 2085 | - // context.setFillStyle("gray") | |
| 2086 | - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); | |
| 2087 | - // context.setFillStyle("black") | |
| 2088 | - // context.font = 'normal bold 18px sans-serif'; | |
| 2089 | - // context.setFontSize(22 * unit) | |
| 2090 | - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); | |
| 2091 | - //context.setFillStyle("gray") | |
| 2092 | - context.setFillStyle("black") | |
| 2093 | - context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | |
| 2094 | - //context.font = 'normal bold 18px sans-serif'; | |
| 2095 | - context.setFontSize(22 * unit) | |
| 2096 | - context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | |
| 2097 | - | |
| 2098 | - | |
| 2099 | - //-- 自定义海报 -- | |
| 2100 | - if(th.data.poster){ | |
| 2101 | - var erm_x= parseFloat(th.data.poster.ewm_x)*2; | |
| 2102 | - var erm_y= parseFloat(th.data.poster.ewm_y)*2; | |
| 2103 | - context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 2104 | - }else{ | |
| 2105 | - //---二维吗图--- | |
| 2106 | - context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 2107 | - } | |
| 2108 | - break | |
| 2109 | - | |
| 2110 | - | |
| 2111 | - } | |
| 2112 | - | |
| 2113 | - | |
| 2114 | - //--- 如果是自定义海报的时候 --- | |
| 2115 | - if(th.data.poster && parseInt(th.data.poster.style)==2){ | |
| 2116 | - | |
| 2117 | - //如果显示会员信息的话 | |
| 2118 | - if(parseInt(th.data.poster.show_headpic)){ | |
| 2119 | - //获取坐标 | |
| 2120 | - var x= parseFloat(th.data.poster.head_x)*2; | |
| 2121 | - var y=parseFloat(th.data.poster.head_y)*2; | |
| 2122 | - //---绘制圆形要放在最后---- | |
| 2123 | - context.save(); | |
| 2124 | - context.beginPath(); | |
| 2125 | - var h_x = x* unit; | |
| 2126 | - var h_y = y * unit; | |
| 2127 | - var h_r = 40 * unit; | |
| 2128 | - var cx = h_x + h_r; | |
| 2129 | - var cy = h_y + h_r; | |
| 2130 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 2131 | - context.closePath(); | |
| 2132 | - context.fill(); | |
| 2133 | - context.clip(); | |
| 2134 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 2135 | - context.restore(); | |
| 2136 | - } | |
| 2137 | - | |
| 2138 | - }else{ | |
| 2139 | - //---绘制圆形要放在最后---- | |
| 2140 | - context.save(); | |
| 2141 | - context.beginPath(); | |
| 2142 | - var h_x = 60 * unit; | |
| 2143 | - var h_y = 24 * unit; | |
| 2144 | - var h_r = 40 * unit; | |
| 2145 | - var cx = h_x + h_r; | |
| 2146 | - var cy = h_y + h_r; | |
| 2147 | - context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 2148 | - context.closePath(); | |
| 2149 | - context.fill(); | |
| 2150 | - context.clip(); | |
| 2151 | - context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 2152 | - context.restore(); | |
| 2153 | - } | |
| 2154 | - | |
| 2155 | - | |
| 2156 | - //把画板内容绘制成图片,并回调 画板图片路径 | |
| 2157 | - context.draw(false, function() { | |
| 2158 | - setTimeout(function() { | |
| 2159 | - wx.canvasToTempFilePath({ | |
| 2160 | - x: 0, | |
| 2161 | - y: 0, | |
| 2162 | - width: 750, | |
| 2163 | - height: 1217, | |
| 2164 | - destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | |
| 2165 | - destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | |
| 2166 | - canvasId: 'share', | |
| 2167 | - success: function(res) { | |
| 2168 | - that.setData({ | |
| 2169 | - shareImgPath: res.tempFilePath, | |
| 2170 | - canvasHidden: true | |
| 2171 | - }) | |
| 2172 | - if (!res.tempFilePath) { | |
| 2173 | - wx.showModal({ | |
| 2174 | - title: '提示', | |
| 2175 | - content: '图片绘制中,请稍后重试', | |
| 2176 | - showCancel: false | |
| 2177 | - }) | |
| 2178 | - return false; | |
| 2179 | - } | |
| 2180 | - // wx.previewImage({ | |
| 2181 | - // //将图片预览出来 | |
| 2182 | - // urls: [that.data.shareImgPath] | |
| 2183 | - // }); | |
| 2184 | - that.setData({ | |
| 2185 | - showPoster: true, | |
| 2186 | - }); | |
| 2187 | - wx.hideLoading(); | |
| 831 | + | |
| 832 | + //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- | |
| 833 | + if (th.data.prom_type == 6 && th.data.is_normal != 1) { | |
| 834 | + newd.goods_price = th.data.prom_price; | |
| 835 | + newd.prom_type = th.data.prom_type; | |
| 836 | + newd.prom_id = th.data.prom_id; | |
| 837 | + newd.kt_type = th.data.prom_act.kttype; //开团类型 | |
| 838 | + newd.is_pt_tz = 0; | |
| 839 | + //th.data.sto_sele_distr=1; //直接用自提的方式提交 | |
| 840 | + if (newd.kt_type > 1) { | |
| 841 | + newd.is_pt_tz = 1; //开团类型 | |
| 2188 | 842 | } |
| 2189 | - }) | |
| 2190 | - }, 500) | |
| 843 | + if (newd.kt_type == 3) { | |
| 844 | + th.data.sto_sele_distr = 1; | |
| 845 | + } | |
| 846 | + | |
| 847 | + } | |
| 848 | + else if (th.data.prom_type == 3) { | |
| 849 | + newd.prom_type = 0; | |
| 850 | + newd.prom_id = 0; | |
| 851 | + } | |
| 852 | + newd['pick_name'] = th.data.sto_sele_name; | |
| 853 | + newd['pick_dis'] = th.data.sto_sele_distr; | |
| 854 | + newd['is_normal'] = th.data.is_normal; | |
| 855 | + | |
| 856 | + if (newd['is_normal']) { | |
| 857 | + newd['is_pd_normal'] = 1; | |
| 858 | + th.buyNow(newd); | |
| 859 | + return false; | |
| 860 | + //判断一下有没有全局优惠活动 | |
| 861 | + //th.check_nor_promgood(newd.goods_id, function (e) { | |
| 862 | + // if (e && e.act_id) { | |
| 863 | + // newd['prom_type'] = 3; | |
| 864 | + // newd['prom_id'] = e.act_id; | |
| 865 | + // } | |
| 866 | + // th.buyNow(newd) | |
| 867 | + //}) | |
| 868 | + } | |
| 869 | + else th.buyNow_pt(newd); | |
| 870 | + }) | |
| 871 | + }, | |
| 872 | + | |
| 873 | + //----------立即购买----------- | |
| 874 | + buyNow: function(e) { | |
| 875 | + getApp().globalData.service_now=e; | |
| 876 | + wx.redirectTo({ | |
| 877 | + url: "/packageA/pages/cart2_ser/cart2_ser", | |
| 878 | + }); | |
| 879 | + }, | |
| 880 | + | |
| 881 | + //----------立即购买_pt----------- | |
| 882 | + buyNow_pt: function (e) { | |
| 883 | + getApp().set_b_now(e); | |
| 884 | + getApp().goto("/packageA/pages/serviceCard_pd/cart/cart?is_bnow=1&goods_id=" + e.goods_id); | |
| 885 | + }, | |
| 886 | + | |
| 887 | + //----------增加购买数量----------- | |
| 888 | + addCartNum: function (t) { | |
| 889 | + this.checkCartNum(this.data.goodsInputNum + 1); | |
| 890 | + }, | |
| 891 | + //----------减少购买数量----------- | |
| 892 | + subCartNum: function (t) { | |
| 893 | + this.checkCartNum(this.data.goodsInputNum - 1); | |
| 894 | + }, | |
| 895 | + //----------输入框输入购买数量----------- | |
| 896 | + inputCartNum: function (t) { | |
| 897 | + this.checkCartNum(Number(t.detail.value)); | |
| 898 | + }, | |
| 899 | + | |
| 900 | + //------检查数量是不是超出限购------ | |
| 901 | + checkCartNum: async function (t) { | |
| 902 | + var th = this; | |
| 903 | + | |
| 904 | + if (!th.data.def_pick_store) { | |
| 905 | + wx.showModal({title: '请选择门店',}); | |
| 906 | + return false; | |
| 907 | + } | |
| 908 | + | |
| 909 | + // 非秒杀活动 | |
| 910 | + if (this.data.prom_type != 1) { | |
| 911 | + this.setData({ | |
| 912 | + goodsInputNum: t, | |
| 913 | + }); | |
| 914 | + } | |
| 915 | + | |
| 916 | + // 秒杀活动 | |
| 917 | + // 如果是秒杀活动下的单独购买,is_normal为1 | |
| 918 | + if (this.data.is_normal) {// 单独购买 | |
| 919 | + this.setData({ | |
| 920 | + goodsInputNum: t, | |
| 921 | + }); | |
| 922 | + } else {// 秒杀购买 | |
| 923 | + | |
| 924 | + // 获取redis当前可以购买的数量 | |
| 925 | + // 如果数量为0,设置和显示已抢光 | |
| 926 | + // 否则,进一步判断是否超出限购或超出库存 | |
| 927 | + await this.getactLen().then(async function (res) { | |
| 928 | + // res: redis可购买数量 | |
| 929 | + // console.log('当前可以购买的数量:', res); | |
| 930 | + if (res <= 0) { | |
| 931 | + // 可购买数量<=0, 设置和显示已抢光 | |
| 932 | + th.setData({ | |
| 933 | + prom_r_null: 1, | |
| 934 | + }); | |
| 935 | + } else { | |
| 936 | + // 可购买数量>0 | |
| 937 | + // 计算自己还可以购买的数量 | |
| 938 | + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | |
| 939 | + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | |
| 940 | + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | |
| 941 | + let actInfo = th.data.prom_act; | |
| 942 | + th.get_buy_num2().then(function (data) { | |
| 943 | + let limited = actInfo.buy_limit; // 限购数量a | |
| 944 | + let promcardbuynum = data.data.data.promcardbuynum; | |
| 945 | + let buyedNum = promcardbuynum; // 自己已经购买的数量b | |
| 946 | + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | |
| 947 | + | |
| 948 | + if (canBuyNum <= 0) { | |
| 949 | + canBuyNum = 0; | |
| 950 | + } | |
| 951 | + if (limited > res) { | |
| 952 | + if (t > res) { // t当前增减的数量 | |
| 953 | + getApp().my_warnning('超出活动库存', 0, self); | |
| 954 | + th.setData({ | |
| 955 | + goodsInputNum: res, | |
| 956 | + }); | |
| 957 | + return false; | |
| 958 | + } | |
| 959 | + | |
| 960 | + } | |
| 961 | + | |
| 962 | + if (limited <= res) { | |
| 963 | + if (t > canBuyNum) { | |
| 964 | + getApp().my_warnning('超出限购数量', 0, self); | |
| 965 | + th.setData({ | |
| 966 | + goodsInputNum: canBuyNum, | |
| 967 | + }); | |
| 968 | + return false; | |
| 969 | + } | |
| 970 | + | |
| 971 | + } | |
| 972 | + | |
| 973 | + th.setData({ | |
| 974 | + goodsInputNum: t, | |
| 975 | + }); | |
| 976 | + }); | |
| 977 | + } | |
| 978 | + | |
| 979 | + }) | |
| 980 | + | |
| 981 | + } | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + }, | |
| 987 | + | |
| 988 | + | |
| 989 | + closeSpecModal: function () { | |
| 990 | + this.setData({ | |
| 991 | + openSpecModal: !1, | |
| 992 | + openSpecModal_pt: !1, | |
| 993 | + openSpecModal_flash_normal: !1, | |
| 994 | + }); | |
| 995 | + }, | |
| 996 | + | |
| 997 | + openSpecModel: function (t) { | |
| 998 | + var th = this; | |
| 999 | + var open_store = t.currentTarget.dataset.ind; | |
| 1000 | + this.setData({ | |
| 1001 | + store: 0, | |
| 1002 | + choice_sort_store: 0, | |
| 1003 | + sort_store: 0, | |
| 1004 | + open_ind_store: open_store, | |
| 1005 | + }) | |
| 1006 | + //--先判断会员状态-- | |
| 1007 | + var user_info = getApp().globalData.userInfo; | |
| 1008 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 1009 | + wx.navigateTo({ | |
| 1010 | + url: '/packageE/pages/togoin/togoin', | |
| 1011 | + }) | |
| 1012 | + return false; | |
| 1013 | + } | |
| 1014 | + | |
| 1015 | + var ind = t.currentTarget.dataset.ind; | |
| 1016 | + this.setData({ | |
| 1017 | + openSpecModal: !0, | |
| 1018 | + openSpecModal_ind: ind, | |
| 1019 | + }); | |
| 1020 | + | |
| 1021 | + }, | |
| 1022 | + | |
| 1023 | + //---------点击收藏和不收藏------------ | |
| 1024 | + collectGoods: function () { | |
| 1025 | + var t = this, i = getApp().request; | |
| 1026 | + var user_id = s.globalData.user_id; | |
| 1027 | + if (user_id == '') { | |
| 1028 | + getApp().getUserFir(function () { | |
| 1029 | + }); | |
| 1030 | + getApp().showWarning("未登录"); | |
| 1031 | + return false; | |
| 1032 | + } else { | |
| 1033 | + | |
| 1034 | + if (t.data.is_collect_load) return false; | |
| 1035 | + t.data.is_collect_load = 1; | |
| 1036 | + | |
| 1037 | + if (t.data.is_collect == 1) { //删除收藏 | |
| 1038 | + i.delete("/api/weshop/goodscollect/del/" + os.stoid + "/" + t.data.collect_id, { | |
| 1039 | + success: function (e) { | |
| 1040 | + t.data.is_collect_load = 0; | |
| 1041 | + if (e.data.code == 0) { | |
| 1042 | + t.setData({ | |
| 1043 | + is_collect: 0, | |
| 1044 | + collect_id: 0, | |
| 1045 | + }); | |
| 1046 | + } | |
| 1047 | + } | |
| 1048 | + }); | |
| 1049 | + } else { | |
| 1050 | + var timestamp = Date.parse(new Date()); | |
| 1051 | + timestamp = timestamp / 1000; | |
| 1052 | + var d = { | |
| 1053 | + goods_id: t.data.data.goods_id, | |
| 1054 | + user_id: s.globalData.user_id, | |
| 1055 | + store_id: os.stoid, | |
| 1056 | + add_time: timestamp, | |
| 1057 | + type: 1, | |
| 1058 | + }; | |
| 1059 | + //加入收藏夹就是导购的ID | |
| 1060 | + if (getApp().globalData.guide_id) { | |
| 1061 | + d.guide_id = getApp().globalData.guide_id; | |
| 1062 | + d.guide_type = 2; | |
| 1063 | + } | |
| 1064 | + | |
| 1065 | + i.post("/api/weshop/goodscollect/save", { //添加收藏 | |
| 1066 | + data: d, | |
| 1067 | + success: function (e) { | |
| 1068 | + t.data.is_collect_load = 0; | |
| 1069 | + if (e.data.code == 0) { | |
| 1070 | + t.setData({ | |
| 1071 | + is_collect: 1, | |
| 1072 | + collect_id: e.data.data.collect_id, | |
| 1073 | + }); | |
| 1074 | + } | |
| 1075 | + } | |
| 1076 | + }); | |
| 1077 | + } | |
| 1078 | + } | |
| 1079 | + }, | |
| 1080 | + //---------联系客服------------ | |
| 1081 | + contactService: function () { | |
| 1082 | + this.getTel() | |
| 1083 | + .then(() => { | |
| 1084 | + if (self.data.store_tel) { | |
| 1085 | + wx.showModal({ | |
| 1086 | + title: '联系客服', | |
| 1087 | + content: '客服热线:' + self.data.store_tel, | |
| 1088 | + confirmText: '拨打', | |
| 1089 | + success(res) { | |
| 1090 | + if (res.confirm) { | |
| 1091 | + wx.makePhoneCall({ | |
| 1092 | + phoneNumber: self.data.store_tel, | |
| 1093 | + }) | |
| 1094 | + } | |
| 1095 | + }, | |
| 1096 | + }); | |
| 1097 | + } | |
| 1098 | + }); | |
| 1099 | + }, | |
| 1100 | + // 获取客服电话 | |
| 1101 | + getTel() { | |
| 1102 | + return new Promise((resolve, reject) => { | |
| 1103 | + s.getConfig(function (t) { | |
| 1104 | + if (t.store_tel == undefined) { | |
| 1105 | + getApp().request.get("/api/weshop/store/get/" + os.stoid, { | |
| 1106 | + isShowLoading: 1, | |
| 1107 | + data: {}, | |
| 1108 | + success: function (rs) { | |
| 1109 | + getApp().globalData.config = rs.data.data; | |
| 1110 | + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { | |
| 1111 | + getApp().my_warnning("商家未设置电话", 0, th); | |
| 1112 | + return false; | |
| 1113 | + } | |
| 1114 | + self.setData({ | |
| 1115 | + store_tel: rs.data.data.store_tel, | |
| 1116 | + }); | |
| 1117 | + // s.confirmBox("请联系客服:" + rs.data.data.store_tel); | |
| 1118 | + } | |
| 1119 | + }) | |
| 1120 | + } else { | |
| 1121 | + self.setData({ | |
| 1122 | + store_tel: t.store_tel, | |
| 1123 | + }); | |
| 1124 | + // s.confirmBox("请联系客服:" + t.store_tel); | |
| 1125 | + } | |
| 1126 | + resolve(); | |
| 1127 | + }); | |
| 1128 | + }); | |
| 1129 | + }, | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + //--点击分享事件--- | |
| 1133 | + onShareAppMessage: function (t) { | |
| 1134 | + | |
| 1135 | + var th = this; | |
| 1136 | + var price = th.data.data.shop_price; | |
| 1137 | + if (th.data.prom_act) { | |
| 1138 | + price = th.data.prom_act.price; | |
| 1139 | + | |
| 1140 | + } | |
| 1141 | + var title = th.data.data.goods_name; | |
| 1142 | + var img = th.data.data.original_img; | |
| 1143 | + if (th.data.prom_type == 6) { | |
| 1144 | + title = th.data.prom_act.share_title; | |
| 1145 | + img = th.data.iurl + th.data.prom_act.share_imgurl; | |
| 1146 | + } | |
| 1147 | + | |
| 1148 | + | |
| 1149 | + var url = "/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=" + th.data.gid; | |
| 1150 | + if (getApp().globalData.user_id) { | |
| 1151 | + url += "&first_leader=" + getApp().globalData.user_id; | |
| 1152 | + } | |
| 1153 | + | |
| 1154 | + //-- 如果房间分享,且不是会员分享的 -- | |
| 1155 | + if (getApp().globalData.room_id && | |
| 1156 | + th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share | |
| 1157 | + ) { | |
| 1158 | + url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | |
| 1159 | + } | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + var ob = { | |
| 1163 | + title: price + "元 " + title, | |
| 1164 | + path: url, | |
| 1165 | + imageUrl: img, | |
| 1166 | + }; | |
| 1167 | + | |
| 1168 | + // 如果服务卡参加秒杀活动,且后台设置了分享标题和分享图片 | |
| 1169 | + if (th.data.prom_type == 1) { | |
| 1170 | + if (th.data.sele_g && th.data.sele_g.share_title) { | |
| 1171 | + title = th.data.sele_g.share_title; | |
| 1172 | + ob.title = title; | |
| 1173 | + } | |
| 1174 | + | |
| 1175 | + if (th.data.sele_g && th.data.sele_g.share_imgurl) { | |
| 1176 | + img = th.data.iurl + th.data.sele_g.share_imgurl; | |
| 1177 | + ob.imageUrl = img; | |
| 1178 | + } | |
| 1179 | + | |
| 1180 | + } | |
| 1181 | + | |
| 1182 | + return ob; | |
| 1183 | + | |
| 1184 | + }, | |
| 1185 | + | |
| 1186 | + //-----图片失败,默认图片----- | |
| 1187 | + bind_bnerr: function (e) { | |
| 1188 | + var _errImg = e.target.dataset.errorimg; | |
| 1189 | + var _errObj = {}; | |
| 1190 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | |
| 1191 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | |
| 1192 | + }, | |
| 1193 | + | |
| 1194 | + //-----图片失败,默认图片----- | |
| 1195 | + bind_bnerr2: function (e) { | |
| 1196 | + | |
| 1197 | + var _errImg = e.target.dataset.errorimg; | |
| 1198 | + var _errObj = {}; | |
| 1199 | + _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" | |
| 1200 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | |
| 1201 | + }, | |
| 1202 | + | |
| 1203 | + | |
| 1204 | + //---------拿出门店分类和门店------------ | |
| 1205 | + get_sto(e) { | |
| 1206 | + var th = this, that = this; | |
| 1207 | + var timer_get = setInterval(function () { | |
| 1208 | + if (th.data.is_get_local_ok == 0) return false; | |
| 1209 | + var i = getApp().request; | |
| 1210 | + if (!th.data.data) return false; | |
| 1211 | + var dd = { | |
| 1212 | + store_id: os.stoid, | |
| 1213 | + isstop: 0, | |
| 1214 | + is_pos: 1, | |
| 1215 | + pageSize: 2000 | |
| 1216 | + } | |
| 1217 | + //如果有距离的话 | |
| 1218 | + if (th.data.lat != null) { | |
| 1219 | + dd.lat = th.data.lat; | |
| 1220 | + dd.lon = th.data.lon; | |
| 1221 | + } | |
| 1222 | + clearInterval(timer_get); | |
| 1223 | + | |
| 1224 | + //如果会员是有默认的门店话 | |
| 1225 | + if (!th.data.def_pick_store && th.data.fir_def_store) { | |
| 1226 | + th.setData({def_pick_store: th.data.fir_def_store}); | |
| 1227 | + } | |
| 1228 | + | |
| 1229 | + wx.showLoading({ | |
| 1230 | + title: '加载中.' | |
| 1231 | + }); | |
| 1232 | + //----------获取门店---------------- | |
| 1233 | + getApp().request.promiseGet("/api/weshop/pickup/list", { | |
| 1234 | + data: dd, | |
| 1235 | + }).then(res => { | |
| 1236 | + var e = res; | |
| 1237 | + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { | |
| 1238 | + | |
| 1239 | + var his_cate_num = 0; | |
| 1240 | + for (let i in e.data.data.pageData) { | |
| 1241 | + let item = e.data.data.pageData[i]; | |
| 1242 | + if (item.category_id > 0) { | |
| 1243 | + his_cate_num = 1; | |
| 1244 | + break; | |
| 1245 | + } | |
| 1246 | + } | |
| 1247 | + e.his_cate_num = his_cate_num; | |
| 1248 | + | |
| 1249 | + //--普通门店排版,服务卡项有指定门店才能使用,所以要筛选一下-- | |
| 1250 | + setTimeout(function () { | |
| 1251 | + var sto_list = th.data.data.storageId; | |
| 1252 | + if (sto_list) { | |
| 1253 | + for (var k = 0; k < e.data.data.pageData.length; k++) { | |
| 1254 | + var it = e.data.data.pageData[k]; | |
| 1255 | + if (sto_list.indexOf(it.keyid) == -1) { | |
| 1256 | + //删除 | |
| 1257 | + e.data.data.pageData.splice(k--, 1); | |
| 1258 | + } | |
| 1259 | + } | |
| 1260 | + } | |
| 1261 | + | |
| 1262 | + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 | |
| 1263 | + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) { | |
| 1264 | + th.setData({ | |
| 1265 | + def_pick_store: e.data.data.pageData[0], | |
| 1266 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | |
| 1267 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | |
| 1268 | + sto_sele_distr: e.data.data.pageData[0].distr_type, | |
| 1269 | + sto_sele_keyid: e.data.data.pageData[0].keyid, | |
| 1270 | + }); | |
| 1271 | + th.data.fir_def_store = e.data.data.pageData[0]; | |
| 1272 | + } | |
| 1273 | + | |
| 1274 | + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 -- | |
| 1275 | + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') { | |
| 1276 | + for (var k = 0; k < e.data.data.pageData.length; k++) { | |
| 1277 | + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { | |
| 1278 | + e.data.data.pageData.splice(k, 1); //删除 | |
| 1279 | + break; | |
| 1280 | + } | |
| 1281 | + } | |
| 1282 | + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 | |
| 1283 | + } | |
| 1284 | + | |
| 1285 | + th.setData({all_pick_list: e.data.data.pageData}); | |
| 1286 | + th.deal_pickup(e); | |
| 1287 | + }, 800) | |
| 1288 | + | |
| 1289 | + } | |
| 1290 | + }) | |
| 1291 | + }, 200) | |
| 1292 | + }, | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + //------------处理门店--------------- | |
| 1296 | + deal_pickup(e){ | |
| 1297 | + var th = this; | |
| 1298 | + if (!th.data.data) return false | |
| 1299 | + wx.hideLoading(); | |
| 1300 | + //单总量超出5个的时候 | |
| 1301 | + if (e.data.data.total > 10 && e.his_cate_num) { | |
| 1302 | + getApp().request.get("/api/weshop/storagecategory/page", { | |
| 1303 | + data: { | |
| 1304 | + store_id: os.stoid, | |
| 1305 | + pageSize: 1000, | |
| 1306 | + orderField: "sort", | |
| 1307 | + orderType: 'asc', | |
| 1308 | + }, | |
| 1309 | + success: function (ee) { | |
| 1310 | + if (ee.data.code == 0) { | |
| 1311 | + | |
| 1312 | + var check_all_cate = 0; | |
| 1313 | + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) { | |
| 1314 | + for (let i in ee.data.data.pageData) { | |
| 1315 | + let item = ee.data.data.pageData[i]; | |
| 1316 | + if (item.is_show == 1) { | |
| 1317 | + check_all_cate = 1; | |
| 1318 | + break | |
| 1319 | + } | |
| 1320 | + } | |
| 1321 | + } | |
| 1322 | + | |
| 1323 | + if (check_all_cate) { | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + var sto_cate = ee.data.data.pageData; | |
| 1327 | + var sto_arr = e.data.data.pageData; | |
| 1328 | + var newarr = new Array(); | |
| 1329 | + var qita = new Array(); | |
| 1330 | + | |
| 1331 | + var is_del_pk = 0; | |
| 1332 | + | |
| 1333 | + //----要进行门店分组-------- | |
| 1334 | + for (var i = 0; i < sto_arr.length; i++) { | |
| 1335 | + //找一下这个门店有没有在分类数组内 | |
| 1336 | + var find2 = 0, find2name = "", sort = 0; | |
| 1337 | + is_del_pk = 0; | |
| 1338 | + for (var m = 0; m < sto_cate.length; m++) { | |
| 1339 | + if (sto_arr[i].category_id == sto_cate[m].cat_id) { | |
| 1340 | + if (sto_cate[m].is_show != 1) { | |
| 1341 | + is_del_pk = 1; | |
| 1342 | + sto_arr.splice(i, 1); | |
| 1343 | + i--; | |
| 1344 | + } else { | |
| 1345 | + find2 = sto_cate[m].cat_id; | |
| 1346 | + find2name = sto_cate[m].cat_name; | |
| 1347 | + sort = sto_cate[m].sort; | |
| 1348 | + is_del_pk = 0; | |
| 1349 | + } | |
| 1350 | + break; | |
| 1351 | + } | |
| 1352 | + } | |
| 1353 | + if (is_del_pk) continue; | |
| 1354 | + | |
| 1355 | + if (newarr.length > 0) { | |
| 1356 | + var find = 0; | |
| 1357 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
| 1358 | + if (find2 != 0) { | |
| 1359 | + for (var ii = 0; ii < newarr.length; ii++) { | |
| 1360 | + if (sto_arr[i].category_id == newarr[ii].cat_id) { | |
| 1361 | + newarr[ii].s_arr.push(sto_arr[i]); | |
| 1362 | + find = 1; | |
| 1363 | + break; | |
| 1364 | + } | |
| 1365 | + } | |
| 1366 | + if (find == 0) { | |
| 1367 | + var arr0 = new Array(); | |
| 1368 | + arr0.push(sto_arr[i]); | |
| 1369 | + var item = { | |
| 1370 | + cat_id: find2, | |
| 1371 | + name: find2name, | |
| 1372 | + sort: sort, | |
| 1373 | + s_arr: arr0 | |
| 1374 | + }; | |
| 1375 | + newarr.push(item); | |
| 1376 | + } | |
| 1377 | + } else { | |
| 1378 | + qita.push(sto_arr[i]); | |
| 1379 | + } | |
| 1380 | + } else { | |
| 1381 | + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 | |
| 1382 | + if (find2 != 0) { | |
| 1383 | + var arr0 = new Array(); | |
| 1384 | + arr0.push(sto_arr[i]); | |
| 1385 | + var item = { | |
| 1386 | + cat_id: find2, | |
| 1387 | + name: find2name, | |
| 1388 | + sort: sort, | |
| 1389 | + s_arr: arr0 | |
| 1390 | + }; | |
| 1391 | + newarr.push(item); | |
| 1392 | + } else { | |
| 1393 | + qita.push(sto_arr[i]); | |
| 1394 | + } | |
| 1395 | + } | |
| 1396 | + } | |
| 1397 | + | |
| 1398 | + var def_arr = new Array(); | |
| 1399 | + //-- 开始就看10个门店 -- | |
| 1400 | + for (var k = 0; k < 10; k++) { | |
| 1401 | + if (k == sto_arr.length) break; | |
| 1402 | + def_arr.push(sto_arr[k]); | |
| 1403 | + } | |
| 1404 | + | |
| 1405 | + th.setData({ | |
| 1406 | + def_pickpu_list: def_arr, | |
| 1407 | + pickpu_list: ee.data.data.pageData | |
| 1408 | + }); | |
| 1409 | + | |
| 1410 | + //门店分类要排序下 | |
| 1411 | + function compare(property) { | |
| 1412 | + return function (a, b) { | |
| 1413 | + var value1 = a[property]; | |
| 1414 | + var value2 = b[property]; | |
| 1415 | + return value1 - value2; | |
| 1416 | + } | |
| 1417 | + } | |
| 1418 | + | |
| 1419 | + if (newarr.length > 0) | |
| 1420 | + newarr.sort(compare("sort")); | |
| 1421 | + | |
| 1422 | + //----安排其他的分类----- | |
| 1423 | + if (qita.length > 0) { | |
| 1424 | + var item = { | |
| 1425 | + cat_id: -1, | |
| 1426 | + name: "其他", | |
| 1427 | + s_arr: qita | |
| 1428 | + }; | |
| 1429 | + newarr.push(item); | |
| 1430 | + } | |
| 1431 | + | |
| 1432 | + var sd = { | |
| 1433 | + all_sto: newarr, | |
| 1434 | + is_show_sto_cat: 1 | |
| 1435 | + } | |
| 1436 | + if (!sto_arr || sto_arr.length <= 10) { | |
| 1437 | + sd.is_show_sto_cat = -1; | |
| 1438 | + sd.only_pk = sto_arr; | |
| 1439 | + } | |
| 1440 | + th.setData(sd); | |
| 1441 | + | |
| 1442 | + } else { | |
| 1443 | + th.setData({ | |
| 1444 | + is_show_sto_cat: -1, | |
| 1445 | + only_pk: e.data.data.pageData | |
| 1446 | + }); | |
| 1447 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
| 1448 | + if (!th.data.def_pick_store) { | |
| 1449 | + th.setData({def_pick_store: e.data.data.pageData[0]}) | |
| 1450 | + } | |
| 1451 | + } | |
| 1452 | + } else { | |
| 1453 | + th.setData({ | |
| 1454 | + is_show_sto_cat: -1, | |
| 1455 | + only_pk: e.data.data.pageData | |
| 1456 | + }); | |
| 1457 | + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ | |
| 1458 | + if (!th.data.def_pick_store) { | |
| 1459 | + th.setData({def_pick_store: e.data.data.pageData[0]}) | |
| 1460 | + } | |
| 1461 | + | |
| 1462 | + } | |
| 1463 | + } | |
| 1464 | + }); | |
| 1465 | + } else { | |
| 1466 | + th.setData({ | |
| 1467 | + is_show_sto_cat: 0, | |
| 1468 | + only_pk: e.data.data.pageData | |
| 1469 | + }); | |
| 1470 | + //-----如果没有默认门店,要取第一个门店作为默认店------ | |
| 1471 | + if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) { | |
| 1472 | + | |
| 1473 | + if (e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { | |
| 1474 | + th.setData({ | |
| 1475 | + def_pick_store: e.data.data.pageData[0], | |
| 1476 | + sto_sele_name: e.data.data.pageData[0].pickup_name, | |
| 1477 | + sto_sele_id: e.data.data.pageData[0].pickup_id, | |
| 1478 | + sto_sele_distr: e.data.data.pageData[0].distr_type, | |
| 1479 | + sto_sele_keyid:e.data.data.pageData[0].keyid, | |
| 1480 | + }) | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + } | |
| 1484 | + } | |
| 1485 | + }, | |
| 1486 | + | |
| 1487 | + //加载更多是靠这个函数 | |
| 1488 | + onReachBottom: function () { | |
| 1489 | + if (this.data.activeCategoryId == 2) { | |
| 1490 | + if (!this.data.comments_no_more) this.requestComments_new(); | |
| 1491 | + } | |
| 1492 | + | |
| 1493 | + var goods_list = this.selectComponent("#goods_list"); //组件的id | |
| 1494 | + if (goods_list) goods_list.get_list(); | |
| 1495 | + }, | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + //---小于10的格式化函数---- | |
| 1499 | + timeFormat(param) { | |
| 1500 | + return param < 10 ? '0' + param : param; | |
| 1501 | + }, | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + //--定义的保存图片方法,分享团--- | |
| 1505 | + saveImageToPhotosAlbum: function () { | |
| 1506 | + //--先判断会员状态-- | |
| 1507 | + var user_info = getApp().globalData.userInfo; | |
| 1508 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 1509 | + //getApp().my_warnning("请先登录",0,this); | |
| 1510 | + wx.navigateTo({url: '/packageE/pages/togoin/togoin',}) | |
| 1511 | + return false; | |
| 1512 | + } | |
| 1513 | + | |
| 1514 | + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4积分购 | |
| 1515 | + var type = 2 | |
| 1516 | + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; | |
| 1517 | + | |
| 1518 | + wx.showLoading({ | |
| 1519 | + title: '生成中...', | |
| 1520 | + }) | |
| 1521 | + var that = this, | |
| 1522 | + th = that; | |
| 1523 | + //设置画板显示,才能开始绘图 | |
| 1524 | + that.setData({ | |
| 1525 | + canvasHidden: false | |
| 1526 | + }) | |
| 1527 | + | |
| 1528 | + var app = getApp(); | |
| 1529 | + var unit = that.data.screenWidth / 750 * 1.35; //基础单位, | |
| 1530 | + var path2 = that.data.data.original_img; | |
| 1531 | + var scene = th.data.gid + ""; | |
| 1532 | + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0; | |
| 1533 | + if (user_id > 0) { | |
| 1534 | + scene += "_" + user_id; | |
| 1535 | + } | |
| 1536 | + //-- 如果不是会员分享过来的要分享给别人 -- | |
| 1537 | + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) { | |
| 1538 | + //固定房间是第3个字符 | |
| 1539 | + if (!user_id) scene += "_0"; | |
| 1540 | + scene += "_" + getApp().globalData.room_id; | |
| 1541 | + } | |
| 1542 | + ///二微码 | |
| 1543 | + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + | |
| 1544 | + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; | |
| 1545 | + | |
| 1546 | + console.log(path3); | |
| 1547 | + | |
| 1548 | + //读取文件成功则OK-- | |
| 1549 | + wx.getImageInfo({ | |
| 1550 | + src: path3, | |
| 1551 | + success: function (res) { | |
| 1552 | + //回调写法 | |
| 1553 | + th.get_head_temp(th.get_goods_temp, function () { | |
| 1554 | + var vpath = res.path; | |
| 1555 | + var context = wx.createCanvasContext('share'); | |
| 1556 | + //先画背景 | |
| 1557 | + var pg_path = "../../../../images/share/share_bg.png"; | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + //-- 如果有自定义海报的时候,判断背景的图片 -- | |
| 1561 | + if (th.data.share_b_img) { | |
| 1562 | + pg_path = th.data.share_b_img; | |
| 1563 | + } | |
| 1564 | + | |
| 1565 | + var act_time=''; | |
| 1566 | + if (!th.data.share_b_img){ // 如果是普通商品,绘制新海报 | |
| 1567 | + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type); | |
| 1568 | + } else { | |
| 1569 | + | |
| 1570 | + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); | |
| 1571 | + | |
| 1572 | + //-- 是自定义海报的情况下 -- | |
| 1573 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | |
| 1574 | + //在线上分享人的情况下 | |
| 1575 | + if (parseInt(th.data.poster.show_headpic)) { | |
| 1576 | + //获取坐标 | |
| 1577 | + var x = parseFloat(th.data.poster.head_x) * 2; | |
| 1578 | + var y = parseFloat(th.data.poster.head_y) * 2; | |
| 1579 | + var x1 = (x + 90) * unit; | |
| 1580 | + var y1 = (y + 50) * unit; | |
| 1581 | + //--昵称--- | |
| 1582 | + context.setFontSize(24 * unit) | |
| 1583 | + context.setFillStyle("black") | |
| 1584 | + context.fillText(app.globalData.userInfo.nickname, x1, y1); | |
| 1585 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit; | |
| 1586 | + //强烈推荐 改许程 | |
| 1587 | + var tj_path = "../../../../images/share/q_tj.png"; | |
| 1588 | + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit); | |
| 1589 | + context.setFontSize(16 * unit) | |
| 1590 | + context.setLineJoin('round'); //交点设置成圆角 | |
| 1591 | + context.setFillStyle("white") | |
| 1592 | + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit); | |
| 1593 | + | |
| 1594 | + } | |
| 1595 | + } else { | |
| 1596 | + //--昵称--- | |
| 1597 | + context.setFontSize(24 * unit) | |
| 1598 | + context.setFillStyle("black") | |
| 1599 | + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit); | |
| 1600 | + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit; | |
| 1601 | + //强烈推荐 改许程 | |
| 1602 | + var tj_path = "../../../../images/share/q_tj.png"; | |
| 1603 | + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); | |
| 1604 | + context.setFontSize(16 * unit); | |
| 1605 | + context.setLineJoin('round'); //交点设置成圆角 | |
| 1606 | + context.setFillStyle("white"); | |
| 1607 | + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit); | |
| 1608 | + } | |
| 1609 | + | |
| 1610 | + | |
| 1611 | + //---产品名称--- | |
| 1612 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
| 1613 | + | |
| 1614 | + context.setFillStyle("black"); | |
| 1615 | + context.setFontSize(21.3 * unit) | |
| 1616 | + th.draw_Text(context, th.data.data.goods_name, | |
| 1617 | + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); | |
| 1618 | + //------产品的价格------- | |
| 1619 | + context.setFontSize(23 * unit) | |
| 1620 | + context.setFillStyle("red") | |
| 1621 | + context.fillText("¥", 416 * unit, 185 * unit); | |
| 1622 | + context.setFontSize(31 * unit) | |
| 1623 | + var pri0 = th.data.data.shop_price; | |
| 1624 | + if (th.data.prom_act) | |
| 1625 | + pri0 = th.data.prom_act.price; | |
| 1626 | + pri0 = parseFloat(pri0).toFixed(2); | |
| 1627 | + context.fillText(pri0, 438 * unit, 185 * unit); | |
| 1628 | + //---市场价划掉--- | |
| 1629 | + context.setFillStyle("gray") | |
| 1630 | + context.setFontSize(22 * unit) | |
| 1631 | + context.fillText("¥" + th.data.data.show_price, 426 * unit, 213 * unit); | |
| 1632 | + context.setStrokeStyle('gray'); | |
| 1633 | + context.setLineWidth(1 * unit); | |
| 1634 | + context.moveTo(426 * unit, 206 * unit); | |
| 1635 | + context.lineTo(510 * unit, 206 * unit); | |
| 1636 | + context.stroke(); | |
| 1637 | + | |
| 1638 | + //---中间大图--- | |
| 1639 | + context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit); | |
| 1640 | + //-------大图后面就不一样了----------- | |
| 1641 | + switch (type) { | |
| 1642 | + case 2: //会员团和商家团的展示 | |
| 1643 | + //---画线--- | |
| 1644 | + context.setLineWidth(1 * unit) | |
| 1645 | + context.moveTo(32 * unit, 670 * unit) | |
| 1646 | + context.lineTo(520 * unit, 670 * unit) | |
| 1647 | + context.stroke(); | |
| 1648 | + //---文字--- | |
| 1649 | + | |
| 1650 | + context.setFillStyle("black") | |
| 1651 | + context.setFontSize(24 * unit) | |
| 1652 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
| 1653 | + | |
| 1654 | + //绘制成团图片 | |
| 1655 | + var ct_img = "../../../../images/share/ct_num.png"; | |
| 1656 | + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); | |
| 1657 | + var ct_num = th.data.prom_act.ct_num; | |
| 1658 | + context.setFontSize(14 * unit) | |
| 1659 | + context.font = 'normal'; | |
| 1660 | + context.setFillStyle("red") | |
| 1661 | + if (ct_num < 10) { | |
| 1662 | + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); | |
| 1663 | + } else { | |
| 1664 | + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); | |
| 1665 | + } | |
| 1666 | + context.setFontSize(22 * unit) | |
| 1667 | + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); | |
| 1668 | + | |
| 1669 | + context.setFillStyle("gray") | |
| 1670 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit); | |
| 1671 | + context.setFillStyle("black") | |
| 1672 | + context.font = 'normal bold 18px sans-serif'; | |
| 1673 | + context.setFontSize(21.3 * unit) | |
| 1674 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit); | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + //---二维吗图--- | |
| 1678 | + //-- 自定义海报 -- | |
| 1679 | + if (th.data.poster) { | |
| 1680 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | |
| 1681 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | |
| 1682 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 1683 | + } else { | |
| 1684 | + //---二维吗图--- | |
| 1685 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 1686 | + } | |
| 1687 | + break | |
| 1688 | + case 3: //阶梯团的展示 | |
| 1689 | + //---画线--- | |
| 1690 | + context.setLineWidth(1 * unit) | |
| 1691 | + context.moveTo(32 * unit, 670 * unit) | |
| 1692 | + context.lineTo(520 * unit, 670 * unit) | |
| 1693 | + context.stroke(); | |
| 1694 | + //---文字--- | |
| 1695 | + | |
| 1696 | + context.setFillStyle("black") | |
| 1697 | + context.setFontSize(24 * unit) | |
| 1698 | + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit); | |
| 1699 | + | |
| 1700 | + //---绘制中间阶梯的价格--- | |
| 1701 | + var list = th.data.prom_act.ct_rylist; | |
| 1702 | + for (var i = 0; i < list.length; i++) { | |
| 1703 | + var item = list[i]; | |
| 1704 | + var wi = i * 90 * unit; | |
| 1705 | + context.font = 'normal'; | |
| 1706 | + context.setFontSize(16 * unit) | |
| 1707 | + context.setFillStyle("red") | |
| 1708 | + context.fillText("¥", 40 * unit + wi, 756 * unit); | |
| 1709 | + context.setFontSize(22 * unit) | |
| 1710 | + var pri = parseFloat(item.price).toFixed(2); | |
| 1711 | + context.fillText(pri, 56 * unit + wi, 756 * unit); | |
| 1712 | + context.setFillStyle("gray") | |
| 1713 | + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); | |
| 1714 | + } | |
| 1715 | + //----------------下面部分---------------- | |
| 1716 | + context.setFillStyle("black") | |
| 1717 | + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit); | |
| 1718 | + //context.font = 'normal bold 18px sans-serif'; | |
| 1719 | + context.setFontSize(22 * unit) | |
| 1720 | + context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit); | |
| 1721 | + //-- 自定义海报 -- | |
| 1722 | + if (th.data.poster) { | |
| 1723 | + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; | |
| 1724 | + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; | |
| 1725 | + context.drawImage(vpath, erm_x * unit, erm_y * unit, 120 * unit, 120 * unit); | |
| 1726 | + } else { | |
| 1727 | + //---二维吗图--- | |
| 1728 | + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); | |
| 1729 | + } | |
| 1730 | + break | |
| 1731 | + | |
| 1732 | + | |
| 1733 | + } | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + //--- 如果是自定义海报的时候 --- | |
| 1737 | + if (th.data.poster && parseInt(th.data.poster.style) == 2) { | |
| 1738 | + | |
| 1739 | + //如果显示会员信息的话 | |
| 1740 | + if (parseInt(th.data.poster.show_headpic)) { | |
| 1741 | + //获取坐标 | |
| 1742 | + var x = parseFloat(th.data.poster.head_x) * 2; | |
| 1743 | + var y = parseFloat(th.data.poster.head_y) * 2; | |
| 1744 | + //---绘制圆形要放在最后---- | |
| 1745 | + context.save(); | |
| 1746 | + context.beginPath(); | |
| 1747 | + var h_x = x * unit; | |
| 1748 | + var h_y = y * unit; | |
| 1749 | + var h_r = 40 * unit; | |
| 1750 | + var cx = h_x + h_r; | |
| 1751 | + var cy = h_y + h_r; | |
| 1752 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 1753 | + context.closePath(); | |
| 1754 | + context.fill(); | |
| 1755 | + context.clip(); | |
| 1756 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 1757 | + context.restore(); | |
| 1758 | + } | |
| 1759 | + | |
| 1760 | + } else { | |
| 1761 | + //---绘制圆形要放在最后---- | |
| 1762 | + context.save(); | |
| 1763 | + context.beginPath(); | |
| 1764 | + var h_x = 60 * unit; | |
| 1765 | + var h_y = 24 * unit; | |
| 1766 | + var h_r = 40 * unit; | |
| 1767 | + var cx = h_x + h_r; | |
| 1768 | + var cy = h_y + h_r; | |
| 1769 | + context.arc(cx, cy, h_r, 0, Math.PI * 2, false); | |
| 1770 | + context.closePath(); | |
| 1771 | + context.fill(); | |
| 1772 | + context.clip(); | |
| 1773 | + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2); | |
| 1774 | + context.restore(); | |
| 1775 | + } | |
| 1776 | + } | |
| 1777 | + | |
| 1778 | + | |
| 1779 | + //把画板内容绘制成图片,并回调 画板图片路径 | |
| 1780 | + context.draw(false, function () { | |
| 1781 | + setTimeout(function () { | |
| 1782 | + wx.canvasToTempFilePath({ | |
| 1783 | + x: 0, | |
| 1784 | + y: 0, | |
| 1785 | + width: 750, | |
| 1786 | + height: 1217, | |
| 1787 | + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, | |
| 1788 | + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, | |
| 1789 | + canvasId: 'share', | |
| 1790 | + success: function (res) { | |
| 1791 | + that.setData({ | |
| 1792 | + shareImgPath: res.tempFilePath, | |
| 1793 | + canvasHidden: true | |
| 1794 | + }) | |
| 1795 | + if (!res.tempFilePath) { | |
| 1796 | + wx.showModal({ | |
| 1797 | + title: '提示', | |
| 1798 | + content: '图片绘制中,请稍后重试', | |
| 1799 | + showCancel: false | |
| 1800 | + }) | |
| 1801 | + return false; | |
| 1802 | + } | |
| 1803 | + // wx.previewImage({ | |
| 1804 | + // //将图片预览出来 | |
| 1805 | + // urls: [that.data.shareImgPath] | |
| 1806 | + // }); | |
| 1807 | + that.setData({ | |
| 1808 | + showPoster: true, | |
| 1809 | + }); | |
| 1810 | + wx.hideLoading(); | |
| 1811 | + } | |
| 1812 | + }) | |
| 1813 | + }, 500) | |
| 1814 | + | |
| 1815 | + }); | |
| 1816 | + }); | |
| 1817 | + } | |
| 1818 | + }); | |
| 1819 | + }, | |
| 1820 | + | |
| 1821 | + | |
| 1822 | + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
| 1823 | + draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | |
| 1824 | + var lineWidth = 0; | |
| 1825 | + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | |
| 1826 | + var han = 0; | |
| 1827 | + for (let i = 0; i < str.length; i++) { | |
| 1828 | + if (han == 2) return; | |
| 1829 | + //lineWidth += ctx.measureText(str[i]).width; | |
| 1830 | + lineWidth += ut.measureText(str[i], 21.3 * unit); | |
| 1831 | + if (lineWidth > canvasWidth) { | |
| 1832 | + han++; | |
| 1833 | + | |
| 1834 | + if (han == 2) | |
| 1835 | + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | |
| 1836 | + else | |
| 1837 | + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | |
| 1838 | + | |
| 1839 | + initHeight += 22; //22为字体的高度 | |
| 1840 | + lineWidth = 0; | |
| 1841 | + lastSubStrIndex = i; | |
| 1842 | + titleHeight += 20; | |
| 1843 | + } | |
| 1844 | + if (i == str.length - 1) { //绘制剩余部分 | |
| 1845 | + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | |
| 1846 | + } | |
| 1847 | + } | |
| 1848 | + }, | |
| 1849 | + | |
| 1850 | + // ----视频图片---- | |
| 1851 | + // 图片计数器 | |
| 1852 | + swiperChange: function (e) { | |
| 1853 | + var that = this; | |
| 1854 | + if (e.detail.current > 0) { | |
| 1855 | + that.setData({ | |
| 1856 | + hiddenn: 1, | |
| 1857 | + videopicture: 1, | |
| 1858 | + }) | |
| 1859 | + } else { | |
| 1860 | + that.setData({ | |
| 1861 | + hiddenn: 0, | |
| 1862 | + videopicture: 0, | |
| 1863 | + }) | |
| 1864 | + } | |
| 1865 | + if (e.detail.source == 'touch') { | |
| 1866 | + that.setData({ | |
| 1867 | + current: e.detail.current | |
| 1868 | + }) | |
| 1869 | + } | |
| 1870 | + }, | |
| 1871 | + | |
| 1872 | + /*---视频相关--*/ | |
| 1873 | + videopicture: function (e) { | |
| 1874 | + var vipi = e.currentTarget.dataset.vipi; | |
| 1875 | + this.setData({ | |
| 1876 | + videopicture: vipi, | |
| 1877 | + swiperCurrent: vipi, | |
| 1878 | + noon: 0, | |
| 1879 | + current: 1 | |
| 1880 | + }); | |
| 1881 | + }, | |
| 1882 | + | |
| 1883 | + videoPlay: function (e) { | |
| 1884 | + var _index = e.currentTarget.id | |
| 1885 | + this.setData({ | |
| 1886 | + _index: _index, | |
| 1887 | + noon: 1 | |
| 1888 | + }) | |
| 1889 | + | |
| 1890 | + setTimeout(function () { | |
| 1891 | + //将点击视频进行播放 | |
| 1892 | + var videoContext = wx.createVideoContext(_index) | |
| 1893 | + videoContext.play(); | |
| 1894 | + }, 500) | |
| 1895 | + }, | |
| 1896 | + | |
| 1897 | + //--获取头像的本地缓存,回调写法-- | |
| 1898 | + get_head_temp: function (tt, func) { | |
| 1899 | + var ee = this; | |
| 1900 | + if (ee.data.share_head) { | |
| 1901 | + tt(func); | |
| 1902 | + return false; | |
| 1903 | + } | |
| 1904 | + //---获取分享图片的本地地址,头像和商品图片---- | |
| 1905 | + var path2 = getApp().globalData.userInfo.head_pic; | |
| 1906 | + if (path2 == "") { | |
| 1907 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | |
| 1908 | + tt(func); | |
| 1909 | + } else { | |
| 1910 | + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | |
| 1911 | + path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | |
| 1912 | + wx.getImageInfo({ | |
| 1913 | + src: path2, | |
| 1914 | + success: function (res) { | |
| 1915 | + //res.path是网络图片的本地地址 | |
| 1916 | + ee.data.share_head = res.path; | |
| 1917 | + tt(func); | |
| 1918 | + }, | |
| 1919 | + fail: function (res) { | |
| 1920 | + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | |
| 1921 | + tt(func); | |
| 1922 | + } | |
| 1923 | + }); | |
| 1924 | + } | |
| 1925 | + }, | |
| 1926 | + //--获取商品图片的本地缓存,回调写法-- | |
| 1927 | + get_goods_temp: function (tt) { | |
| 1928 | + var ee = this; | |
| 1929 | + if (ee.data.share_goods_img) { | |
| 1930 | + tt(); | |
| 1931 | + return false; | |
| 1932 | + } | |
| 1933 | + //获取商品是分享图信息 | |
| 1934 | + wx.getImageInfo({ | |
| 1935 | + src: ee.data.data.original_img, | |
| 1936 | + success: function (res) { | |
| 1937 | + //res.path是网络图片的本地地址 | |
| 1938 | + ee.data.share_goods_img = res.path; | |
| 1939 | + tt(); | |
| 1940 | + }, | |
| 1941 | + fail: function (res) { | |
| 1942 | + //获取默认空白图 | |
| 1943 | + wx.getImageInfo({ | |
| 1944 | + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', | |
| 1945 | + success: function(res) { | |
| 1946 | + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 | |
| 1947 | + tt(); | |
| 1948 | + } | |
| 1949 | + }) | |
| 1950 | + } | |
| 1951 | + }); | |
| 1952 | + }, | |
| 1953 | + | |
| 1954 | + | |
| 1955 | + //--跳转到商品详情页面-- | |
| 1956 | + go_goods: function (e) { | |
| 1957 | + var gid = e.currentTarget.dataset.gid; | |
| 1958 | + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | |
| 1959 | + getApp().goto(url); | |
| 1960 | + }, | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + pop_err_img: function (e) { | |
| 1964 | + var txt = e.currentTarget.dataset.errorimg; | |
| 1965 | + var ob = {}; | |
| 1966 | + ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | |
| 1967 | + this.setData(ob); | |
| 1968 | + }, | |
| 1969 | + | |
| 1970 | + // 选择门店 | |
| 1971 | + choice_store: function (ee) { | |
| 1972 | + var th = this; | |
| 1973 | + var ind = ee.currentTarget.dataset.ind; | |
| 1974 | + var bconfig = th.data.bconfig; | |
| 1975 | + | |
| 1976 | + //如果开启了,则不在选择门店 | |
| 1977 | + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ | |
| 1978 | + return false; | |
| 1979 | + } | |
| 1980 | + | |
| 1981 | + if (!th.data.only_pk && !th.data.def_pickpu_list) { | |
| 1982 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 1983 | + return false; | |
| 1984 | + } | |
| 1985 | + | |
| 1986 | + if (th.data.only_pk && !th.data.only_pk.length) { | |
| 1987 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 1988 | + return false; | |
| 1989 | + } | |
| 1990 | + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { | |
| 1991 | + getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 1992 | + return false; | |
| 1993 | + } | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + if (bconfig && bconfig.is_sort_storage) { | |
| 1997 | + wx.getLocation({ | |
| 1998 | + type: 'gcj02', | |
| 1999 | + success: function (res) { | |
| 2000 | + | |
| 2001 | + th.data.lat = res.latitude; | |
| 2002 | + th.data.lon = res.longitude; | |
| 2003 | + th.data.is_get_local_ok = 1; | |
| 2004 | + th.setData({is_gps: 1}); | |
| 2005 | + th.get_sto(th.data.is_normal); | |
| 2006 | + }, | |
| 2007 | + fail: function (res) { | |
| 2008 | + | |
| 2009 | + th.data.is_get_local_ok = 1; | |
| 2010 | + th.get_sto(th.data.is_normal); | |
| 2011 | + if (res.errCode == 2) { | |
| 2012 | + th.setData({is_gps: 0}); | |
| 2013 | + if (th.data.is_gps == 0) { | |
| 2014 | + getApp().confirmBox("请开启GPS定位", null, 25000, !1); | |
| 2015 | + } | |
| 2016 | + } else { | |
| 2017 | + th.setData({is_gps: "3"}); | |
| 2018 | + } | |
| 2019 | + | |
| 2020 | + } | |
| 2021 | + }) | |
| 2022 | + } else { | |
| 2023 | + th.data.is_get_local_ok = 1; | |
| 2024 | + th.get_sto(th.data.is_normal); | |
| 2025 | + } | |
| 2026 | + | |
| 2027 | + if (ind != undefined && ind != null) { | |
| 2028 | + this.setData({ | |
| 2029 | + open_ind_store: ind, | |
| 2030 | + store: 1, | |
| 2031 | + openSpecModal: !1, | |
| 2032 | + openSpecModal_pt: !1 | |
| 2033 | + }) | |
| 2034 | + } else { | |
| 2035 | + this.setData({ | |
| 2036 | + store: 1, | |
| 2037 | + openSpecModal: !1, | |
| 2038 | + openSpecModal_pt: !1 | |
| 2039 | + }) | |
| 2040 | + } | |
| 2041 | + }, | |
| 2042 | + //关闭选择门店 | |
| 2043 | + close_popup: function (e) { | |
| 2044 | + var th = this; | |
| 2045 | + this.setData({ | |
| 2046 | + store: 0, | |
| 2047 | + choice_sort_store: 0, | |
| 2048 | + sort_store: 0, | |
| 2049 | + fir_pick_index: 0, | |
| 2050 | + sec_pick_index: 0 | |
| 2051 | + }) | |
| 2052 | + | |
| 2053 | + var openindstore = this.data.open_ind_store; | |
| 2054 | + if (openindstore == 1) { | |
| 2055 | + th.setData({ | |
| 2056 | + openSpecModal: !0, | |
| 2057 | + openSpecModal_ind: openindstore, | |
| 2058 | + }); | |
| 2059 | + } else if (openindstore == 2) { | |
| 2060 | + th.setData({ | |
| 2061 | + openSpecModal: !0, | |
| 2062 | + openSpecModal_ind: openindstore, | |
| 2063 | + }); | |
| 2064 | + } | |
| 2065 | + else if (openindstore == 4) { //4就是拼团 | |
| 2066 | + th.setData({ | |
| 2067 | + openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2068 | + store: 0, //关闭门店 | |
| 2069 | + choice_sort_store: 0, //关闭门店2级 | |
| 2070 | + sort_store: 0, //关闭门店2级 | |
| 2071 | + }); | |
| 2072 | + } | |
| 2073 | + else { | |
| 2074 | + th.setData({ | |
| 2075 | + store: 0, | |
| 2076 | + choice_sort_store: 0, | |
| 2077 | + sort_store: 0 | |
| 2078 | + }) | |
| 2079 | + } | |
| 2080 | + }, | |
| 2081 | + | |
| 2082 | + //选择更多门店 | |
| 2083 | + more_store: function () { | |
| 2084 | + this.setData({ | |
| 2085 | + sort_store: 1 | |
| 2086 | + }); | |
| 2087 | + }, | |
| 2088 | + | |
| 2089 | + sort_store: function () { | |
| 2090 | + }, | |
| 2091 | + // 返回按钮 | |
| 2092 | + returns: function () { | |
| 2093 | + this.setData({ | |
| 2094 | + sort_store: 0, | |
| 2095 | + choice_sort_store: 0 | |
| 2096 | + }); | |
| 2097 | + }, | |
| 2098 | + //---选择分类门店--- | |
| 2099 | + choice_sort_store: function (e) { | |
| 2100 | + var index = e.currentTarget.dataset.index; | |
| 2101 | + var region_name = e.currentTarget.dataset.region; | |
| 2102 | + var item = this.data.all_sto[index]; | |
| 2103 | + this.setData({ | |
| 2104 | + region_name: region_name, | |
| 2105 | + sort_store: 0, | |
| 2106 | + choice_sort_store: 1, | |
| 2107 | + sec_sto: item, | |
| 2108 | + sec_pick_index: 0 | |
| 2109 | + }); | |
| 2110 | + }, | |
| 2111 | + | |
| 2112 | + choose_for_store_fir: function (e) { | |
| 2113 | + var index_c = e.currentTarget.dataset.ind; | |
| 2114 | + var th = this; | |
| 2115 | + th.setData({ | |
| 2116 | + fir_pick_index: index_c | |
| 2117 | + }) | |
| 2118 | + | |
| 2119 | + }, | |
| 2120 | + | |
| 2121 | + //确定def_pick为选择的门店 | |
| 2122 | + sure_pick: function (e) { | |
| 2123 | + var th = this; | |
| 2124 | + var item = null; | |
| 2125 | + var openindstore = th.data.open_ind_store; | |
| 2126 | + | |
| 2127 | + if (th.data.choice_sort_store == 0) { | |
| 2128 | + var index = th.data.fir_pick_index; | |
| 2129 | + if (th.data.is_show_sto_cat == 1) { | |
| 2130 | + item = th.data.def_pickpu_list[index]; | |
| 2131 | + } else { | |
| 2132 | + item = th.data.only_pk?th.data.only_pk[index]:null; //当没有门店分类的时候 | |
| 2133 | + } | |
| 2134 | + | |
| 2135 | + } else { | |
| 2136 | + var index = th.data.sec_pick_index; | |
| 2137 | + item = th.data.sec_sto.s_arr[index]; | |
| 2138 | + } | |
| 2139 | + | |
| 2140 | + if(!item) return false; | |
| 2141 | + | |
| 2142 | + var ser_card = this.data.data; | |
| 2143 | + //判断门店的配送方式是不是匹配 | |
| 2144 | + if (ser_card.storageId != null && ser_card.storageId != "" && ser_card.storageId.indexOf(item.keyid) == -1) { | |
| 2145 | + wx.showToast({ | |
| 2146 | + title: "该门店无此服务项目,请重新选择!", | |
| 2147 | + icon: 'none', | |
| 2148 | + duration: 2000 | |
| 2149 | + }); | |
| 2150 | + return false; | |
| 2151 | + } | |
| 2152 | + | |
| 2153 | + if (!item) return false; | |
| 2154 | + | |
| 2155 | + th.setData({ | |
| 2156 | + def_pick_store: item, | |
| 2157 | + sto_sele_name: item.pickup_name, | |
| 2158 | + sto_sele_id: item.pickup_id, | |
| 2159 | + sto_sele_keyid: item.keyid, | |
| 2160 | + sto_sele_distr: item.distr_type, | |
| 2161 | + store: 0, | |
| 2162 | + choice_sort_store: 0, | |
| 2163 | + fir_pick_index: 0 | |
| 2164 | + }); | |
| 2165 | + | |
| 2166 | + if (openindstore == 1) { | |
| 2167 | + th.setData({ | |
| 2168 | + openSpecModal: !0, | |
| 2169 | + openSpecModal_ind: openindstore, | |
| 2170 | + }); | |
| 2171 | + } else if (openindstore == 2) { | |
| 2172 | + th.setData({ | |
| 2173 | + openSpecModal: !0, | |
| 2174 | + openSpecModal_ind: openindstore, | |
| 2175 | + }); | |
| 2176 | + } | |
| 2177 | + else if (openindstore == 4) { //4就是拼团 | |
| 2178 | + th.setData({ | |
| 2179 | + openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2180 | + store: 0, //关闭门店 | |
| 2181 | + choice_sort_store: 0, //关闭门店2级 | |
| 2182 | + sort_store: 0, //关闭门店2级 | |
| 2183 | + }); | |
| 2184 | + } | |
| 2185 | + else { | |
| 2186 | + th.setData({ | |
| 2187 | + store: 0, | |
| 2188 | + choice_sort_store: 0, | |
| 2189 | + sort_store: 0 | |
| 2190 | + }) | |
| 2191 | + } | |
| 2192 | + }, | |
| 2193 | + | |
| 2194 | + //---点击二级之后的选择--- | |
| 2195 | + choose_for_store: function (e) { | |
| 2196 | + var index_c = e.currentTarget.dataset.ind; | |
| 2197 | + var th = this; | |
| 2198 | + th.setData({ | |
| 2199 | + sec_pick_index: index_c, | |
| 2200 | + fir_pick_index: index_c | |
| 2201 | + }) | |
| 2202 | + | |
| 2203 | + }, | |
| 2204 | + //把选择的门店设置成默认的门店def_pick | |
| 2205 | + set_def_pick: function (e) { | |
| 2206 | + var th = this; | |
| 2207 | + var item = null; | |
| 2208 | + if (th.data.choice_sort_store == 0) { | |
| 2209 | + var index = th.data.fir_pick_index; | |
| 2210 | + if (th.data.is_show_sto_cat == 1) { | |
| 2211 | + item = th.data.def_pickpu_list[index]; | |
| 2212 | + } else { | |
| 2213 | + item = th.data.only_pk?th.data.only_pk[index]:null; //当没有门店分类的时候 | |
| 2214 | + } | |
| 2215 | + } else { | |
| 2216 | + var index = th.data.sec_pick_index; | |
| 2217 | + item = th.data.sec_sto.s_arr[index]; | |
| 2218 | + } | |
| 2219 | + | |
| 2220 | + if(!item) return false; | |
| 2221 | + | |
| 2222 | + //判断门店的配送方式是不是匹配 | |
| 2223 | + var ser_card = this.data.data; | |
| 2224 | + //判断门店的配送方式是不是匹配 | |
| 2225 | + if (ser_card.storageId != null && ser_card.storageId != "" && ser_card.storageId.indexOf(item.keyid) == -1) { | |
| 2226 | + wx.showToast({ | |
| 2227 | + title: "该门店无此服务项目,请重新选择!", | |
| 2228 | + icon: 'none', | |
| 2229 | + duration: 2000 | |
| 2230 | + }); | |
| 2231 | + return false; | |
| 2232 | + } | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + var store_id = os.stoid; | |
| 2236 | + var user_id = getApp().globalData.user_id; | |
| 2237 | + var def_pickup_id = item.pickup_id; | |
| 2238 | + | |
| 2239 | + getApp().request.put('/api/weshop/users/update', { | |
| 2240 | + data: { | |
| 2241 | + user_id: user_id, | |
| 2242 | + def_pickup_id: def_pickup_id | |
| 2243 | + }, | |
| 2244 | + success: function (res) { | |
| 2245 | + if (res.data.code == 0) { | |
| 2246 | + if (th.data.choice_sort_store == 0) th.setData({ | |
| 2247 | + fir_pick_index: 0 | |
| 2248 | + }); | |
| 2249 | + getApp().globalData.pk_store = item; | |
| 2250 | + } else { | |
| 2251 | + //s.showWarning("设置默认门店地址失败", null, 500, !1); | |
| 2252 | + getApp().my_warnning("设置默认门店地址失败", 0, th) | |
| 2253 | + } | |
| 2254 | + | |
| 2255 | + } | |
| 2256 | + }); | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + if (!item) return false; | |
| 2260 | + | |
| 2261 | + th.setData({ | |
| 2262 | + def_pick_store: item, | |
| 2263 | + sto_sele_name: item.pickup_name, | |
| 2264 | + sto_sele_id: item.pickup_id, | |
| 2265 | + sto_sele_keyid: item.keyid, | |
| 2266 | + sto_sele_distr: item.distr_type, | |
| 2267 | + store: 0, | |
| 2268 | + choice_sort_store: 0 | |
| 2269 | + }); | |
| 2270 | + | |
| 2271 | + var openindstore = th.data.open_ind_store; | |
| 2272 | + if (openindstore == 1) { | |
| 2273 | + th.setData({ | |
| 2274 | + openSpecModal: !0, | |
| 2275 | + openSpecModal_ind: openindstore, | |
| 2276 | + store: 0, | |
| 2277 | + choice_sort_store: 0, | |
| 2278 | + sort_store: 0, | |
| 2279 | + }); | |
| 2280 | + } else if (openindstore == 2) { | |
| 2281 | + th.setData({ | |
| 2282 | + openSpecModal: !0, | |
| 2283 | + openSpecModal_ind: openindstore, | |
| 2284 | + store: 0, | |
| 2285 | + choice_sort_store: 0, | |
| 2286 | + sort_store: 0, | |
| 2287 | + }); | |
| 2288 | + } | |
| 2289 | + else if (openindstore == 4) { //4就是拼团 | |
| 2290 | + th.setData({ | |
| 2291 | + openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2292 | + store: 0, //关闭门店 | |
| 2293 | + choice_sort_store: 0, //关闭门店2级 | |
| 2294 | + sort_store: 0, //关闭门店2级 | |
| 2295 | + }); | |
| 2296 | + } | |
| 2297 | + | |
| 2298 | + else { | |
| 2299 | + th.setData({ | |
| 2300 | + store: 0, | |
| 2301 | + choice_sort_store: 0, | |
| 2302 | + sort_store: 0, | |
| 2303 | + }) | |
| 2304 | + } | |
| 2305 | + | |
| 2306 | + }, | |
| 2307 | + | |
| 2308 | + wait_for_store_config: function () { | |
| 2309 | + var th = this; | |
| 2310 | + var t_time = setInterval(function () { | |
| 2311 | + if (th.data.bconfig == null) false; | |
| 2312 | + var e = th.data.bconfig; | |
| 2313 | + if (e && e.is_sort_storage) { | |
| 2314 | + wx.getLocation({ | |
| 2315 | + type: 'gcj02', | |
| 2316 | + success: function (res) { | |
| 2317 | + th.data.lat = res.latitude; | |
| 2318 | + th.data.lon = res.longitude; | |
| 2319 | + th.data.is_get_local_ok = 1; | |
| 2320 | + }, | |
| 2321 | + fail: function (res) { | |
| 2322 | + if (res.errCode == 2) { | |
| 2323 | + th.setData({ | |
| 2324 | + is_gps: 0 | |
| 2325 | + }); | |
| 2326 | + if (th.data.is_gps == 0) { | |
| 2327 | + getApp().confirmBox("请开启GPS定位", null, 10000, !1); | |
| 2328 | + } | |
| 2329 | + | |
| 2330 | + } else { | |
| 2331 | + th.setData({ | |
| 2332 | + is_gps: "3" | |
| 2333 | + }); | |
| 2334 | + } | |
| 2335 | + | |
| 2336 | + th.data.is_get_local_ok = 1; | |
| 2337 | + } | |
| 2338 | + }) | |
| 2339 | + } else { | |
| 2340 | + th.data.is_get_local_ok = 1; | |
| 2341 | + } | |
| 2342 | + clearInterval(t_time); | |
| 2343 | + }, 500) | |
| 2344 | + }, | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + //-- 根据ID拿出门店 -- | |
| 2348 | + get_pick_from_list(pid){ | |
| 2349 | + var all_pick_list = this.data.all_pick_list; | |
| 2350 | + for (var i in all_pick_list) { | |
| 2351 | + var item = all_pick_list[i]; | |
| 2352 | + if (item.pickup_id == pid) { | |
| 2353 | + return item; | |
| 2354 | + } | |
| 2355 | + } | |
| 2356 | + }, | |
| 2357 | + | |
| 2358 | + closePoster() { | |
| 2359 | + this.setData({ | |
| 2360 | + showPoster: false, | |
| 2361 | + }); | |
| 2362 | + }, | |
| 2363 | + | |
| 2364 | + // 保存图片到手机 | |
| 2365 | + savePic() { | |
| 2366 | + console.log('保存图片'); | |
| 2367 | + var self = this; | |
| 2368 | + // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | |
| 2369 | + this.getSetting().then((res) => { | |
| 2370 | + // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | |
| 2371 | + if (!res.authSetting['scope.writePhotosAlbum']) { | |
| 2372 | + this.authorize().then(() => { | |
| 2373 | + // 同意授权后保存下载文件 | |
| 2374 | + this.saveImage(self.data.shareImgPath) | |
| 2375 | + .then(() => { | |
| 2376 | + self.setData({ | |
| 2377 | + showPoster: false | |
| 2378 | + }); | |
| 2379 | + }); | |
| 2380 | + }) | |
| 2381 | + } else { | |
| 2382 | + // 如果已经授权,保存下载文件 | |
| 2383 | + this.saveImage(self.data.shareImgPath) | |
| 2384 | + .then(() => { | |
| 2385 | + self.setData({showPoster: false}); | |
| 2386 | + }); | |
| 2387 | + } | |
| 2388 | + | |
| 2389 | + }) | |
| 2390 | + }, | |
| 2391 | + | |
| 2392 | + // 获取用户已经授予了哪些权限 | |
| 2393 | + getSetting() { | |
| 2394 | + return new Promise((resolve, reject) => { | |
| 2395 | + wx.getSetting({ | |
| 2396 | + success: res => { | |
| 2397 | + resolve(res) | |
| 2398 | + } | |
| 2399 | + }) | |
| 2400 | + }) | |
| 2401 | + }, | |
| 2402 | + | |
| 2403 | + // 发起首次授权请求 | |
| 2404 | + authorize() { | |
| 2405 | + // isFirst 用来记录是否为首次发起授权, | |
| 2406 | + // 如果首次授权拒绝后,isFirst赋值为1 | |
| 2407 | + let isFirst = wx.getStorageSync('isFirst') || 0; | |
| 2408 | + return new Promise((resolve, reject) => { | |
| 2409 | + wx.authorize({ | |
| 2410 | + scope: 'scope.writePhotosAlbum', | |
| 2411 | + // 同意授权 | |
| 2412 | + success: () => { | |
| 2413 | + resolve(); | |
| 2414 | + }, | |
| 2415 | + // 拒绝授权,这里是用户拒绝授权后的回调 | |
| 2416 | + fail: res => { | |
| 2417 | + if (isFirst === 0) { | |
| 2418 | + wx.setStorageSync('isFirst', 1); | |
| 2419 | + wx.showToast({ | |
| 2420 | + title: '保存失败', | |
| 2421 | + icon: 'none', | |
| 2422 | + duration: 1000 | |
| 2423 | + }) | |
| 2424 | + } else { | |
| 2425 | + this.showModal(); | |
| 2426 | + } | |
| 2427 | + console.log('拒绝授权'); | |
| 2428 | + reject(); | |
| 2429 | + } | |
| 2430 | + }) | |
| 2431 | + }) | |
| 2432 | + }, | |
| 2433 | + | |
| 2434 | + // 保存图片到系统相册 | |
| 2435 | + saveImage(saveUrl) { | |
| 2436 | + var self = this; | |
| 2437 | + return new Promise((resolve, reject) => { | |
| 2438 | + wx.saveImageToPhotosAlbum({ | |
| 2439 | + filePath: saveUrl, | |
| 2440 | + success: (res) => { | |
| 2441 | + wx.showToast({ | |
| 2442 | + title: '保存成功', | |
| 2443 | + duration: 1000, | |
| 2444 | + }); | |
| 2445 | + self.setData({ | |
| 2446 | + showPlaybill: 'true' | |
| 2447 | + }); | |
| 2448 | + resolve(); | |
| 2449 | + }, | |
| 2450 | + fail: () => { | |
| 2451 | + wx.showToast({ | |
| 2452 | + title: '保存失败', | |
| 2453 | + duration: 1000, | |
| 2454 | + }); | |
| 2455 | + } | |
| 2456 | + }) | |
| 2457 | + }) | |
| 2458 | + }, | |
| 2459 | + | |
| 2460 | + previewImage() { | |
| 2461 | + getApp().pre_img(this.data.shareImgPath); | |
| 2462 | + }, | |
| 2463 | + | |
| 2464 | + onShareTimeline() { | |
| 2465 | + getApp().globalData.no_clear = 1; | |
| 2466 | + var th=this; | |
| 2467 | + var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : ''; | |
| 2468 | + if (!store_name) | |
| 2469 | + store_name = getApp().globalData.setting.appName; | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + var url = "goods_id=" + th.data.gid; | |
| 2473 | + if (getApp().globalData.user_id) { | |
| 2474 | + url += "&first_leader=" + getApp().globalData.user_id; | |
| 2475 | + } | |
| 2476 | + | |
| 2477 | + //-- 如果房间分享,且不是会员分享的 -- | |
| 2478 | + if (getApp().globalData.room_id && | |
| 2479 | + th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share | |
| 2480 | + ) { | |
| 2481 | + url += "&room_id=" + getApp().globalData.room_id + "&room_user_share=1"; | |
| 2482 | + } | |
| 2483 | + | |
| 2484 | + return { | |
| 2485 | + title: this.data.data.goods_name + '-' + store_name, | |
| 2486 | + imageUrl: this.data.gallery[0].image_url, | |
| 2487 | + query: url | |
| 2488 | + } | |
| 2489 | + }, | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + clickCollapse() { | |
| 2493 | + this.setData({ | |
| 2494 | + flag: !this.data.flag, | |
| 2495 | + }) | |
| 2496 | + }, | |
| 2497 | + | |
| 2498 | + //---------联系微信客服------------ | |
| 2499 | + con_weixin: function () { | |
| 2500 | + var url = this.data.sys_switch.weapp_customertype_url; | |
| 2501 | + var id = this.data.sys_switch.weapp_customertype_appid; | |
| 2502 | + wx.openCustomerServiceChat({ | |
| 2503 | + extInfo: {url: url}, | |
| 2504 | + corpId: id, | |
| 2505 | + success(res) { | |
| 2506 | + } | |
| 2507 | + }) | |
| 2508 | + }, | |
| 2509 | + | |
| 2510 | + //评论的调用 | |
| 2511 | + requestComments_new: async function () { | |
| 2512 | + var e = this, th = e, ee = e; | |
| 2513 | + var tp = e.data.activeCategoryId3; | |
| 2514 | + var t = '/api/weshop/serviceComment/pageComment?page=' + e.data.c_curr_p; | |
| 2515 | + | |
| 2516 | + wx.showLoading(); | |
| 2517 | + var req_where = { | |
| 2518 | + store_id: os.stoid, pageSize: 5, is_show: 1, | |
| 2519 | + parent_id: 0, goods_id: th.data.gid, commenttype: tp, | |
| 2520 | + service_id: this.data.gid, | |
| 2521 | + } | |
| 2522 | + if (getApp().globalData.userInfo) { | |
| 2523 | + req_where.userId = getApp().globalData.user_id; | |
| 2524 | + } | |
| 2525 | + | |
| 2526 | + var rs_data = null; | |
| 2527 | + await getApp().request.promiseGet(t, {data: req_where}).then(res => { | |
| 2528 | + var tot = res.data.data.total; | |
| 2529 | + e.data.c_curr_p++; | |
| 2530 | + e.setData({ | |
| 2531 | + com_num: tot, //已经有加载 | |
| 2532 | + }); | |
| 2533 | + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 2534 | + rs_data = res.data.data.pageData; | |
| 2535 | + } else { | |
| 2536 | + th.setData({comments_no_more: 1, auto: 1}); | |
| 2537 | + } | |
| 2538 | + }) | |
| 2539 | + | |
| 2540 | + if (rs_data) { | |
| 2541 | + //var cda = th.data.comments; | |
| 2542 | + var cda = rs_data, com_data = th.data.comments; | |
| 2543 | + for (var ind in cda) { | |
| 2544 | + var ep = cda[ind]; | |
| 2545 | + if (cda[ind].head_pic == '') { | |
| 2546 | + cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | |
| 2547 | + } | |
| 2548 | + if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { | |
| 2549 | + cda[ind].weapp_img = JSON.parse(ep.weapp_img); | |
| 2550 | + } | |
| 2551 | + if (ep.img != "" && ut.isString(ep.img)) { | |
| 2552 | + cda[ind].img = ut.unserialize(ep.img); | |
| 2553 | + } | |
| 2554 | + | |
| 2555 | + //--测量多有字的宽带,计算有多少行-- | |
| 2556 | + var widh = ut.measureText(ep.content, 30); | |
| 2557 | + var lines = widh / 712; | |
| 2558 | + cda[ind].seeMore = false; | |
| 2559 | + if (lines > 3) cda[ind].seeMore = true; | |
| 2560 | + | |
| 2561 | + await getApp().request.promiseGet("/api/weshop/serviceComment/pageComment", { | |
| 2562 | + data: { | |
| 2563 | + store_id: os.stoid, | |
| 2564 | + parent_id: ep.comment_id, | |
| 2565 | + service_id: this.data.gid, | |
| 2566 | + } | |
| 2567 | + }).then(res => { | |
| 2568 | + if (res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 2569 | + cda[ind].replay_list = res.data.data.pageData; | |
| 2570 | + } | |
| 2571 | + }) | |
| 2572 | + } | |
| 2573 | + | |
| 2574 | + if (!com_data) com_data = cda; | |
| 2575 | + else com_data = com_data.concat(cda); | |
| 2576 | + | |
| 2577 | + th.setData({comments: com_data}); | |
| 2578 | + } | |
| 2579 | + th.setData({get_c: 1}); | |
| 2580 | + wx.hideLoading(); | |
| 2581 | + }, | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + //--点赞功能-- | |
| 2585 | + click_zan: function (e) { | |
| 2586 | + var com_id = e.currentTarget.dataset.com_id; | |
| 2587 | + var item_id = e.currentTarget.dataset.item_id; | |
| 2588 | + var app = getApp(), | |
| 2589 | + th = this; | |
| 2590 | + | |
| 2591 | + if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | |
| 2592 | + app.confirmBox("您还未登录"); | |
| 2593 | + return false; | |
| 2594 | + } | |
| 2595 | + | |
| 2596 | + var iszan = th.data.comments[item_id].userZanNum; | |
| 2597 | + if (this.data.iszaning) return false; | |
| 2598 | + this.data.iszaning = 1; | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + app.request.post("/api/weshop/serviceCommentZan/save", { | |
| 2602 | + data: { | |
| 2603 | + store_id: os.stoid, | |
| 2604 | + user_id: app.globalData.user_id, | |
| 2605 | + goods_id: th.data.gid, | |
| 2606 | + service_id: th.data.gid, | |
| 2607 | + comment_id: com_id | |
| 2608 | + }, | |
| 2609 | + success: function (ee) { | |
| 2610 | + | |
| 2611 | + if (ee.data.code == "-1") { | |
| 2612 | + app.my_warnning("不能给自己点赞", 0, th); | |
| 2613 | + th.data.iszaning = 0; | |
| 2614 | + return; | |
| 2615 | + } | |
| 2616 | + | |
| 2617 | + if (ee.data.code == 0 && iszan != 1) { | |
| 2618 | + var num = th.data.comments[item_id].zan_num; | |
| 2619 | + num++; | |
| 2620 | + var text = "comments[" + item_id + "].zan_num"; | |
| 2621 | + var text1 = "comments[" + item_id + "].userZanNum"; | |
| 2622 | + var _errObj = {}; | |
| 2623 | + _errObj[text] = num; | |
| 2624 | + _errObj[text1] = 1; | |
| 2625 | + th.setData(_errObj); | |
| 2626 | + | |
| 2627 | + } else { | |
| 2628 | + var num = th.data.comments[item_id].zan_num; | |
| 2629 | + num--; | |
| 2630 | + var text = "comments[" + item_id + "].zan_num"; | |
| 2631 | + var text1 = "comments[" + item_id + "].userZanNum"; | |
| 2632 | + var _errObj = {}; | |
| 2633 | + _errObj[text] = num; | |
| 2634 | + _errObj[text1] = 0; | |
| 2635 | + th.setData(_errObj); | |
| 2636 | + } | |
| 2637 | + | |
| 2638 | + setTimeout(function () { | |
| 2639 | + th.data.iszaning = 0; | |
| 2640 | + }, 500) | |
| 2641 | + | |
| 2642 | + } | |
| 2643 | + }) | |
| 2644 | + }, | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + //--外侧评价的点击效果--- | |
| 2648 | + clik_evaluate: function (e) { | |
| 2649 | + var val = e.currentTarget.dataset.val; | |
| 2650 | + this.setData({ | |
| 2651 | + activeCategoryId: 2, | |
| 2652 | + activeCategoryId3: val, | |
| 2653 | + comments: null | |
| 2654 | + }); | |
| 2655 | + this.requestComments_new(); | |
| 2656 | + }, | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + //显示全部 | |
| 2660 | + toggleHandler: function (e) { | |
| 2661 | + var that = this, | |
| 2662 | + index = e.currentTarget.dataset.index; | |
| 2663 | + for (var i = 0; i < that.data.comments.length; i++) { | |
| 2664 | + if (index == i) { | |
| 2665 | + for (var i = 0; i < that.data.comments.length; i++) { | |
| 2666 | + that.data.comments[index].auto = true; | |
| 2667 | + that.data.comments[index].seeMore = false; | |
| 2668 | + } | |
| 2669 | + } | |
| 2670 | + } | |
| 2671 | + that.setData({ | |
| 2672 | + comments: that.data.comments | |
| 2673 | + }) | |
| 2674 | + }, | |
| 2675 | + | |
| 2676 | + //收起更多 | |
| 2677 | + toggleContent: function (e) { | |
| 2678 | + var that = this, | |
| 2679 | + index = e.currentTarget.dataset.index; | |
| 2680 | + for (var i = 0; i < that.data.comments.length; i++) { | |
| 2681 | + if (index == i) { | |
| 2682 | + that.data.comments[index].auto = true; | |
| 2683 | + that.data.comments[index].seeMore = true; | |
| 2684 | + } | |
| 2685 | + } | |
| 2686 | + that.setData({ | |
| 2687 | + comments: that.data.comments | |
| 2688 | + }) | |
| 2689 | + }, | |
| 2690 | + | |
| 2691 | + //--查看评价-- | |
| 2692 | + look_pj: function () { | |
| 2693 | + this.tabComment(); | |
| 2694 | + this.doScrollTop(); | |
| 2695 | + }, | |
| 2696 | + | |
| 2697 | + previewCommentImgs_w: function (t) { | |
| 2698 | + var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | |
| 2699 | + var b = e.slice() | |
| 2700 | + // for (var i in b) { | |
| 2701 | + // b[i] = this.data.iurl + e[i]; | |
| 2702 | + // } | |
| 2703 | + this.data.show_prew_img = 1; | |
| 2704 | + wx.previewImage({ | |
| 2705 | + current: b[t.currentTarget.dataset.id], | |
| 2706 | + urls: b | |
| 2707 | + }); | |
| 2708 | + }, | |
| 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 | + ; | |
| 2741 | + }).catch(err => { | |
| 2742 | + }); | |
| 2743 | + | |
| 2744 | + } | |
| 2745 | + ; | |
| 2746 | + } | |
| 2747 | + ; | |
| 2748 | + }); | |
| 2749 | + }, | |
| 2750 | + | |
| 2751 | + //---小于10的格式化函数---- | |
| 2752 | + timeFormat(param) { | |
| 2753 | + return param < 10 ? '0' + param : param; | |
| 2754 | + }, | |
| 2755 | + //----倒计时函数----- | |
| 2756 | + countDown(time, prom_st) { | |
| 2757 | + if (!this.data.is_timer) return false; | |
| 2758 | + var th = this; | |
| 2759 | + // 获取当前时间,同时得到活动结束时间数组 | |
| 2760 | + var endTime = time; | |
| 2761 | + var newTime = ut.gettimestamp(); | |
| 2762 | + // 对结束时间进行处理渲染到页面 | |
| 2763 | + var obj = null; | |
| 2764 | + // 如果活动未结束,对时间进行处理 | |
| 2765 | + if (endTime - newTime > 0) { | |
| 2766 | + var time = (endTime - newTime); | |
| 2767 | + // 获取天、时、分、秒 | |
| 2768 | + var day = parseInt(time / (60 * 60 * 24)); | |
| 2769 | + var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
| 2770 | + var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
| 2771 | + var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
| 2772 | + obj = { | |
| 2773 | + day: this.timeFormat(day), | |
| 2774 | + hou: this.timeFormat(hou), | |
| 2775 | + min: this.timeFormat(min), | |
| 2776 | + sec: this.timeFormat(sec) | |
| 2777 | + } | |
| 2778 | + } else { | |
| 2779 | + if (th.data.prom_st == 0) { | |
| 2780 | + //var endTime2 = new Date(th.data.prom_end_time).getTime(); | |
| 2781 | + var endTime2 = th.data.prom_act.end_time; | |
| 2782 | + th.setData({ | |
| 2783 | + prom_time_text: '距结束还剩:', | |
| 2784 | + prom_st: 1 | |
| 2785 | + }) | |
| 2786 | + setTimeout(function () { | |
| 2787 | + th.countDown(endTime2) | |
| 2788 | + }, 1000); | |
| 2789 | + return false; | |
| 2790 | + | |
| 2791 | + } else { | |
| 2792 | + //活动已结束,全部设置为'00' | |
| 2793 | + obj = { | |
| 2794 | + day: '00', | |
| 2795 | + hou: '00', | |
| 2796 | + min: '00', | |
| 2797 | + sec: '00' | |
| 2798 | + } | |
| 2799 | + th.setData({ | |
| 2800 | + prom_time_text: '活动已经结束:', | |
| 2801 | + prom_st: 3 | |
| 2802 | + }) | |
| 2803 | + th.setData({ | |
| 2804 | + djs: obj | |
| 2805 | + }); | |
| 2806 | + return false; | |
| 2807 | + } | |
| 2808 | + } | |
| 2809 | + | |
| 2810 | + th.setData({ | |
| 2811 | + djs: obj | |
| 2812 | + }); | |
| 2813 | + setTimeout(function () { | |
| 2814 | + th.countDown(endTime) | |
| 2815 | + }, 1000); | |
| 2816 | + }, | |
| 2817 | + get_normal(gid) { | |
| 2818 | + this.setData({ | |
| 2819 | + prom_type: 0, | |
| 2820 | + isshow: 1, | |
| 2821 | + }); | |
| 2822 | + this.get_sku(os.stoid, this.data.data, gid); | |
| 2823 | + this.get_sto(); | |
| 2824 | + //this.check_is_youhui(gid, 1); | |
| 2825 | + this.data.is_normal = 1; | |
| 2826 | + }, | |
| 2827 | + //获取redis中的数量 | |
| 2828 | + async getactLen() { | |
| 2829 | + let prom_type = this.data.options.prom_type; | |
| 2830 | + let prom_id = this.data.options.prom_id; | |
| 2831 | + return await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | |
| 2832 | + 1: 1 | |
| 2833 | + }).then(res => { | |
| 2834 | + if (res.data.code == 0) { | |
| 2835 | + // 当前可以购买的数量 | |
| 2836 | + let r_num = res.data.data; | |
| 2837 | + return r_num; | |
| 2838 | + } | |
| 2839 | + ; | |
| 2840 | + }) | |
| 2841 | + }, | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + //--------检查是否活动,活动是否开始,或者是否结束------- | |
| 2845 | + async check_prom(gid, prom_type, prom_id) { | |
| 2846 | + var ee = this, th = ee; | |
| 2847 | + var user_id = getApp().globalData.user_id; | |
| 2848 | + if (!user_id) user_id = 0; | |
| 2849 | + //-------判断活动是否抢光--------- | |
| 2850 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + prom_id, { | |
| 2851 | + 1: 1 | |
| 2852 | + }).then(res => { | |
| 2853 | + var em = res; | |
| 2854 | + var flag = null; | |
| 2855 | + if (em.data.code == 0) { | |
| 2856 | + if (em.data.data <= 0) ee.setData({ | |
| 2857 | + prom_r_null: 1 | |
| 2858 | + }); | |
| 2859 | + //拿取价格并且判断时间-- | |
| 2860 | + getApp().request.get("/api/weshop/teamlist/get/" + | |
| 2861 | + os.stoid + "/" + prom_id, { | |
| 2862 | + success: async function (t) { | |
| 2863 | + if (t.data.code != 0) { | |
| 2864 | + ee.get_normal(gid); | |
| 2865 | + return false; | |
| 2866 | + } | |
| 2867 | + //----已经结束----- | |
| 2868 | + if (t.data.data.is_end == 1) { | |
| 2869 | + ee.get_normal(gid); | |
| 2870 | + return false; | |
| 2871 | + } | |
| 2872 | + //----已经过期----- | |
| 2873 | + var now = ut.gettimestamp(); | |
| 2874 | + if (t.data.data.end_time < now) { | |
| 2875 | + ee.get_normal(gid); | |
| 2876 | + return false; | |
| 2877 | + } | |
| 2878 | + | |
| 2879 | + /*-- 还没有开始预热的也不显示 --*/ | |
| 2880 | + if (t.data.data.show_time > now) { | |
| 2881 | + ee.get_normal(gid); | |
| 2882 | + return false; | |
| 2883 | + } | |
| 2884 | + | |
| 2885 | + /*-- 判断拼单是否启用 --*/ | |
| 2886 | + if (!t.data.data.is_show) { | |
| 2887 | + console.log('没启用'); | |
| 2888 | + wx.setNavigationBarTitle({ | |
| 2889 | + title: '系统提示', | |
| 2890 | + }); | |
| 2891 | + wx.showToast({ | |
| 2892 | + title: '此商品暂时没有拼单活动', | |
| 2893 | + icon: 'none', | |
| 2894 | + success(){ | |
| 2895 | + setTimeout(() => { | |
| 2896 | + wx.navigateBack() | |
| 2897 | + }, 2000) | |
| 2898 | + } | |
| 2899 | + }); | |
| 2900 | + return false | |
| 2901 | + } | |
| 2902 | + | |
| 2903 | + //判断拼团的---会员身份-- | |
| 2904 | + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { | |
| 2905 | + data: { | |
| 2906 | + store_id: os.stoid, | |
| 2907 | + is_end: 0, | |
| 2908 | + is_show: 1, | |
| 2909 | + user_id: getApp().globalData.user_id, | |
| 2910 | + pageSize: 1000 | |
| 2911 | + } | |
| 2912 | + }).then(res => { | |
| 2913 | + let pd_list = res.data.data.pageData; | |
| 2914 | + if (res.data.code == 0 && pd_list.length > 0) { | |
| 2915 | + flag = pd_list.some(pd => { | |
| 2916 | + return pd.goods_id == gid && pd.goods_type==1 | |
| 2917 | + }) | |
| 2918 | + } | |
| 2919 | + }) | |
| 2920 | + if (!flag) { | |
| 2921 | + ee.get_normal(gid); | |
| 2922 | + return false; | |
| 2923 | + | |
| 2924 | + } | |
| 2925 | + //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | |
| 2926 | + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/page", { | |
| 2927 | + data: { | |
| 2928 | + prom_id: prom_id, | |
| 2929 | + prom_type: 6, | |
| 2930 | + user_id: oo.user_id, | |
| 2931 | + store_id: os.stoid, | |
| 2932 | + pageSize: 1, | |
| 2933 | + page: 1 | |
| 2934 | + } | |
| 2935 | + }).then(e => { | |
| 2936 | + if (e.data.code == 0 && e.data.data.pageData.length > 0) { | |
| 2937 | + var odr = e.data.data.pageData[0]; | |
| 2938 | + th.data.buy_order = odr; | |
| 2939 | + if (odr.pt_status == 0 && odr.order_status == 1) { | |
| 2940 | + th.setData({ | |
| 2941 | + user_order_pt_state: 1 | |
| 2942 | + }); | |
| 2943 | + } | |
| 2944 | + if (odr.pt_status == 1) { | |
| 2945 | + if (odr.is_zsorder == 4) { | |
| 2946 | + getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | |
| 2947 | + data: { | |
| 2948 | + store_id: os.stoid, | |
| 2949 | + team_id: odr.prom_id, | |
| 2950 | + listno: odr.pt_listno | |
| 2951 | + } | |
| 2952 | + }).then(res => { | |
| 2953 | + var now = ut.gettimestamp(); | |
| 2954 | + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 2955 | + var tgr = res.data.data.pageData[0]; | |
| 2956 | + //如果团的时间已经到了 | |
| 2957 | + if (now >= tgr.kt_end_time) { | |
| 2958 | + th.update_jiti(tgr.id); | |
| 2959 | + } else { | |
| 2960 | + th.setData({ | |
| 2961 | + user_order_pt_state: 2 | |
| 2962 | + }); | |
| 2963 | + } | |
| 2964 | + } | |
| 2965 | + }) | |
| 2966 | + | |
| 2967 | + } else { | |
| 2968 | + th.setData({ | |
| 2969 | + user_order_pt_state: 2 | |
| 2970 | + }); | |
| 2971 | + } | |
| 2972 | + } | |
| 2973 | + | |
| 2974 | + if (odr.pt_status == 2 && odr.is_zsorder == 4) { | |
| 2975 | + th.setData({ | |
| 2976 | + user_order_pt_state: 3, | |
| 2977 | + }); | |
| 2978 | + th.data.wk_order_id = odr.order_id; | |
| 2979 | + } | |
| 2980 | + } | |
| 2981 | + }) | |
| 2982 | + | |
| 2983 | + //----------查看阶梯团------------ | |
| 2984 | + if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | |
| 2985 | + t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | |
| 2986 | + var max_num = 0; | |
| 2987 | + t.data.data.ct_rylist.forEach(function (val, ind) { | |
| 2988 | + if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | |
| 2989 | + }) | |
| 2990 | + t.data.data.max_ct_num = max_num; | |
| 2991 | + } | |
| 2992 | + | |
| 2993 | + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | |
| 2994 | + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | |
| 2995 | + | |
| 2996 | + ee.setData({ | |
| 2997 | + prom_price: t.data.data.price, | |
| 2998 | + prom_type: 6, | |
| 2999 | + prom_id: prom_id, | |
| 3000 | + prom_buy_limit: t.data.data.buy_limit, | |
| 3001 | + prom_act: t.data.data, | |
| 3002 | + prom_end_time: prom_end_time, | |
| 3003 | + prom_start_time: prom_start_time, | |
| 3004 | + isshow: 1, | |
| 3005 | + }); | |
| 3006 | + | |
| 3007 | + ee.get_sto(); | |
| 3008 | + | |
| 3009 | + var newTime = now; | |
| 3010 | + var endTime2 = t.data.data.end_time; | |
| 3011 | + var endTime1 = t.data.data.start_time; | |
| 3012 | + | |
| 3013 | + if (endTime1 > newTime) { | |
| 3014 | + ee.setData({ | |
| 3015 | + prom_time_text: '距拼单开始还剩:', | |
| 3016 | + prom_st: 0 | |
| 3017 | + }) | |
| 3018 | + ee.countDown(endTime1, 0); | |
| 3019 | + } else { | |
| 3020 | + if (endTime2 > newTime) { | |
| 3021 | + ee.setData({ | |
| 3022 | + prom_time_text: '距拼单结束还剩:', | |
| 3023 | + prom_st: 1 | |
| 3024 | + }) | |
| 3025 | + ee.countDown(endTime2); | |
| 3026 | + } | |
| 3027 | + } | |
| 3028 | + //-------查看有多少人在开这个团------- | |
| 3029 | + th.get_team_group(prom_id); | |
| 3030 | + } | |
| 3031 | + }); | |
| 3032 | + } | |
| 3033 | + }) | |
| 3034 | + | |
| 3035 | + }, | |
| 3036 | + | |
| 3037 | + | |
| 3038 | + viewFlash(e) { | |
| 3039 | + let prom_type = e.currentTarget.dataset.promtype; | |
| 3040 | + let prom_id = e.currentTarget.dataset.promid; | |
| 3041 | + let goods_id = this.data.data.goods_id; | |
| 3042 | + let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`; | |
| 3043 | + s | |
| 3044 | + getApp().goto(url); | |
| 3045 | + }, | |
| 2191 | 3046 | |
| 2192 | - }); | |
| 2193 | - }); | |
| 2194 | - } | |
| 2195 | - }); | |
| 2196 | - }, | |
| 2197 | - | |
| 2198 | - | |
| 2199 | - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 | |
| 2200 | - draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { | |
| 2201 | - var lineWidth = 0; | |
| 2202 | - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 | |
| 2203 | - var han = 0; | |
| 2204 | - for (let i = 0; i < str.length; i++) { | |
| 2205 | - if (han == 2) return; | |
| 2206 | - //lineWidth += ctx.measureText(str[i]).width; | |
| 2207 | - lineWidth += ut.measureText(str[i], 21.3 * unit); | |
| 2208 | - if (lineWidth > canvasWidth) { | |
| 2209 | - han++; | |
| 2210 | - | |
| 2211 | - if (han == 2) | |
| 2212 | - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 | |
| 2213 | - else | |
| 2214 | - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); | |
| 2215 | - | |
| 2216 | - initHeight += 22; //22为字体的高度 | |
| 2217 | - lineWidth = 0; | |
| 2218 | - lastSubStrIndex = i; | |
| 2219 | - titleHeight += 20; | |
| 2220 | - } | |
| 2221 | - if (i == str.length - 1) { //绘制剩余部分 | |
| 2222 | - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); | |
| 2223 | - } | |
| 2224 | - } | |
| 2225 | - }, | |
| 2226 | - | |
| 2227 | - // ----视频图片---- | |
| 2228 | - // 图片计数器 | |
| 2229 | - swiperChange: function (e) { | |
| 2230 | - var that = this; | |
| 2231 | - if (e.detail.current > 0) { | |
| 2232 | - that.setData({ | |
| 2233 | - hiddenn: 1, | |
| 2234 | - videopicture: 1, | |
| 2235 | - }) | |
| 2236 | - } else { | |
| 2237 | - that.setData({ | |
| 2238 | - hiddenn: 0, | |
| 2239 | - videopicture: 0, | |
| 2240 | - }) | |
| 2241 | - } | |
| 2242 | - if (e.detail.source == 'touch') { | |
| 2243 | - that.setData({ | |
| 2244 | - current: e.detail.current | |
| 2245 | - }) | |
| 2246 | - } | |
| 2247 | - }, | |
| 2248 | - | |
| 2249 | - /*---视频相关--*/ | |
| 2250 | - videopicture: function (e) { | |
| 2251 | - var vipi = e.currentTarget.dataset.vipi; | |
| 2252 | - this.setData({ | |
| 2253 | - videopicture: vipi, | |
| 2254 | - swiperCurrent: vipi, | |
| 2255 | - noon: 0, | |
| 2256 | - current: 1 | |
| 2257 | - }); | |
| 2258 | - }, | |
| 2259 | - | |
| 2260 | - videoPlay: function (e) { | |
| 2261 | - var _index = e.currentTarget.id | |
| 2262 | - this.setData({ | |
| 2263 | - _index: _index, | |
| 2264 | - noon: 1 | |
| 2265 | - }) | |
| 2266 | - | |
| 2267 | - setTimeout(function () { | |
| 2268 | - //将点击视频进行播放 | |
| 2269 | - var videoContext = wx.createVideoContext(_index) | |
| 2270 | - videoContext.play(); | |
| 2271 | - }, 500) | |
| 2272 | - }, | |
| 2273 | - | |
| 2274 | - //--获取头像的本地缓存,回调写法-- | |
| 2275 | - get_head_temp: function(tt, func) { | |
| 2276 | - var ee = this; | |
| 2277 | - if (ee.data.share_head) { | |
| 2278 | - tt(func); | |
| 2279 | - return false; | |
| 2280 | - } | |
| 2281 | - //---获取分享图片的本地地址,头像和商品图片---- | |
| 2282 | - var path2 = getApp().globalData.userInfo.head_pic; | |
| 2283 | - if (path2 == "") { | |
| 2284 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; | |
| 2285 | - tt(func); | |
| 2286 | - } else { | |
| 2287 | - path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | |
| 2288 | - path2 = path2.replace("https://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); | |
| 2289 | - wx.getImageInfo({ | |
| 2290 | - src: path2, | |
| 2291 | - success: function(res) { | |
| 2292 | - //res.path是网络图片的本地地址 | |
| 2293 | - ee.data.share_head = res.path; | |
| 2294 | - tt(func); | |
| 2295 | - }, | |
| 2296 | - fail: function(res) { | |
| 2297 | - ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 | |
| 2298 | - tt(func); | |
| 3047 | + | |
| 3048 | + //获取更多秒杀 | |
| 3049 | + get_more_flash: async function (func) { | |
| 3050 | + var f_more = false; | |
| 3051 | + var user_id = getApp().globalData.user_id; | |
| 3052 | + if (!user_id) user_id = 0; | |
| 3053 | + | |
| 3054 | + var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.options.goods_id + "&user_id=" + user_id; | |
| 3055 | + //获取秒杀的多规格 | |
| 3056 | + await getApp().request.promiseGet(url, {}).then(res => { | |
| 3057 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 3058 | + f_more = res.data.data; | |
| 3059 | + } | |
| 3060 | + }) | |
| 3061 | + if (!f_more) { | |
| 3062 | + func(false); | |
| 3063 | + return false; | |
| 2299 | 3064 | } |
| 2300 | - }); | |
| 2301 | - } | |
| 2302 | - }, | |
| 2303 | - //--获取商品图片的本地缓存,回调写法-- | |
| 2304 | - get_goods_temp: function(tt) { | |
| 2305 | - var ee = this; | |
| 2306 | - if (ee.data.share_goods_img) { | |
| 2307 | - tt(); | |
| 2308 | - return false; | |
| 2309 | - } | |
| 2310 | - //获取商品是分享图信息 | |
| 2311 | - wx.getImageInfo({ | |
| 2312 | - src: ee.data.data.original_img, | |
| 2313 | - success: function(res) { | |
| 2314 | - //res.path是网络图片的本地地址 | |
| 2315 | - ee.data.share_goods_img = res.path; | |
| 2316 | - tt(); | |
| 2317 | - }, | |
| 2318 | - fail: function(res) { | |
| 2319 | - | |
| 2320 | - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 | |
| 2321 | - tt(); | |
| 2322 | - } | |
| 2323 | - }); | |
| 2324 | - }, | |
| 2325 | - | |
| 2326 | - | |
| 2327 | - //--跳转到商品详情页面-- | |
| 2328 | - go_goods: function(e) { | |
| 2329 | - var gid = e.currentTarget.dataset.gid; | |
| 2330 | - var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; | |
| 2331 | - getApp().goto(url); | |
| 2332 | - }, | |
| 2333 | - | |
| 2334 | - | |
| 2335 | - pop_err_img: function(e) { | |
| 2336 | - var txt = e.currentTarget.dataset.errorimg; | |
| 2337 | - var ob = {}; | |
| 2338 | - ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; | |
| 2339 | - this.setData(ob); | |
| 2340 | - }, | |
| 2341 | - | |
| 2342 | - // 选择门店 | |
| 2343 | - choice_store: function(ee) { | |
| 2344 | - var th = this; | |
| 2345 | - var ind=ee.currentTarget.dataset.ind; | |
| 2346 | - var bconfig = th.data.bconfig; | |
| 2347 | - | |
| 2348 | - if(!th.data.only_pk && !th.data.def_pickpu_list){ | |
| 2349 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 2350 | - return false; | |
| 2351 | - } | |
| 2352 | - | |
| 2353 | - if(th.data.only_pk && !th.data.only_pk.length){ | |
| 2354 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 2355 | - return false; | |
| 2356 | - } | |
| 2357 | - if(th.data.def_pickpu_list && !th.data.def_pickpu_list.length){ | |
| 2358 | - getApp().confirmBox("门店库存不足", null, 25000, !1); | |
| 2359 | - return false; | |
| 2360 | - } | |
| 2361 | - | |
| 2362 | - | |
| 2363 | - if (bconfig && bconfig.is_sort_storage) { | |
| 2364 | - wx.getLocation({ | |
| 2365 | - type: 'gcj02', | |
| 2366 | - success: function(res) { | |
| 2367 | - | |
| 2368 | - th.data.lat = res.latitude; | |
| 2369 | - th.data.lon = res.longitude; | |
| 2370 | - th.data.is_get_local_ok = 1; | |
| 2371 | - th.setData({ is_gps: 1 }); | |
| 2372 | - th.get_sto(th.data.is_normal); | |
| 2373 | - }, | |
| 2374 | - fail: function(res) { | |
| 2375 | - | |
| 2376 | - th.data.is_get_local_ok = 1; | |
| 2377 | - th.get_sto(th.data.is_normal); | |
| 2378 | - if (res.errCode == 2) { | |
| 2379 | - th.setData({is_gps: 0}); | |
| 2380 | - if (th.data.is_gps == 0) { | |
| 2381 | - getApp().confirmBox("请开启GPS定位", null, 25000, !1); | |
| 3065 | + //-- 秒杀的价格要更新 -- | |
| 3066 | + for (let i in f_more) { | |
| 3067 | + | |
| 3068 | + let item = f_more[i]; | |
| 3069 | + f_more[i].prom_id = item.act_id; | |
| 3070 | + f_more[i].prom_type = 1; | |
| 3071 | + if (item.goods_id == this.data.data.goods_id) { | |
| 3072 | + continue; | |
| 2382 | 3073 | } |
| 2383 | - } else { | |
| 2384 | - th.setData({ is_gps: "3" }); | |
| 2385 | - } | |
| 3074 | + var url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + item.act_id; | |
| 3075 | + await getApp().request.promiseGet(url, {}).then(rs => { | |
| 3076 | + if (rs.data.code == 0) { | |
| 3077 | + f_more[i].price = rs.data.data.user_price; | |
| 2386 | 3078 | |
| 3079 | + } | |
| 3080 | + }) | |
| 2387 | 3081 | } |
| 2388 | - }) | |
| 2389 | - }else{ | |
| 2390 | - th.data.is_get_local_ok = 1; | |
| 2391 | - th.get_sto(th.data.is_normal); | |
| 2392 | - } | |
| 2393 | - | |
| 2394 | - if(ind!=undefined && ind!=null ){ | |
| 2395 | - this.setData({ | |
| 2396 | - open_ind_store: ind, | |
| 2397 | - store: 1, | |
| 2398 | - openSpecModal: !1, | |
| 2399 | - openSpecModal_pt: !1 | |
| 2400 | - }) | |
| 2401 | - }else{ | |
| 2402 | - this.setData({ | |
| 2403 | - store: 1, | |
| 2404 | - openSpecModal: !1, | |
| 2405 | - openSpecModal_pt: !1 | |
| 2406 | - }) | |
| 2407 | - } | |
| 2408 | - }, | |
| 2409 | - //关闭选择门店 | |
| 2410 | - close_popup: function(e) { | |
| 2411 | - var th=this; | |
| 2412 | - this.setData({ | |
| 2413 | - store: 0, | |
| 2414 | - choice_sort_store: 0, | |
| 2415 | - sort_store: 0, | |
| 2416 | - fir_pick_index:0, | |
| 2417 | - sec_pick_index:0 | |
| 2418 | - }) | |
| 2419 | - | |
| 2420 | - var openindstore=this.data.open_ind_store; | |
| 2421 | - if (openindstore == 1) { | |
| 2422 | - th.setData({ | |
| 2423 | - openSpecModal: !0, | |
| 2424 | - openSpecModal_ind: openindstore, | |
| 2425 | - }); | |
| 2426 | - } else if (openindstore == 2) { | |
| 2427 | - th.setData({ | |
| 2428 | - openSpecModal: !0, | |
| 2429 | - openSpecModal_ind: openindstore, | |
| 2430 | - }); | |
| 2431 | - } | |
| 2432 | - else if (openindstore == 4) { //4就是拼团 | |
| 2433 | - th.setData({ | |
| 2434 | - openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2435 | - store: 0, //关闭门店 | |
| 2436 | - choice_sort_store: 0, //关闭门店2级 | |
| 2437 | - sort_store: 0, //关闭门店2级 | |
| 2438 | - }); | |
| 2439 | - } | |
| 2440 | - else { | |
| 2441 | - th.setData({ | |
| 2442 | - store: 0, | |
| 2443 | - choice_sort_store: 0, | |
| 2444 | - sort_store: 0 | |
| 2445 | - }) | |
| 2446 | - } | |
| 2447 | - }, | |
| 2448 | - | |
| 2449 | - //选择更多门店 | |
| 2450 | - more_store: function() { | |
| 2451 | - this.setData({ | |
| 2452 | - sort_store: 1 | |
| 2453 | - }); | |
| 2454 | - }, | |
| 2455 | - | |
| 2456 | - sort_store: function() { }, | |
| 2457 | - // 返回按钮 | |
| 2458 | - returns: function() { | |
| 2459 | - this.setData({ | |
| 2460 | - sort_store: 0, | |
| 2461 | - choice_sort_store: 0 | |
| 2462 | - }); | |
| 2463 | - }, | |
| 2464 | - //---选择分类门店--- | |
| 2465 | - choice_sort_store: function(e) { | |
| 2466 | - var index = e.currentTarget.dataset.index; | |
| 2467 | - var region_name = e.currentTarget.dataset.region; | |
| 2468 | - var item = this.data.all_sto[index]; | |
| 2469 | - this.setData({ | |
| 2470 | - region_name: region_name, | |
| 2471 | - sort_store: 0, | |
| 2472 | - choice_sort_store: 1, | |
| 2473 | - sec_sto: item, | |
| 2474 | - sec_pick_index: 0 | |
| 2475 | - }); | |
| 2476 | - }, | |
| 2477 | - | |
| 2478 | - choose_for_store_fir: function(e) { | |
| 2479 | - var index_c = e.currentTarget.dataset.ind; | |
| 2480 | - var th=this; | |
| 2481 | - th.setData({ | |
| 2482 | - fir_pick_index: index_c | |
| 2483 | - }) | |
| 2484 | - | |
| 2485 | - }, | |
| 2486 | - | |
| 2487 | - //确定def_pick为选择的门店 | |
| 2488 | - sure_pick: function(e) { | |
| 2489 | - var th = this; | |
| 2490 | - var item = null; | |
| 2491 | - var openindstore = th.data.open_ind_store; | |
| 2492 | - | |
| 2493 | - if (th.data.choice_sort_store == 0) { | |
| 2494 | - var index = th.data.fir_pick_index; | |
| 2495 | - if (th.data.is_show_sto_cat == 1) { | |
| 2496 | - item = th.data.def_pickpu_list[index]; | |
| 2497 | - } else { | |
| 2498 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | |
| 2499 | - } | |
| 2500 | - | |
| 2501 | - } else { | |
| 2502 | - var index = th.data.sec_pick_index; | |
| 2503 | - item = th.data.sec_sto.s_arr[index]; | |
| 2504 | - } | |
| 2505 | - | |
| 2506 | - var ser_card=this.data.data; | |
| 2507 | - //判断门店的配送方式是不是匹配 | |
| 2508 | - if(ser_card.storageId!=null && ser_card.storageId!="" && ser_card.storageId.indexOf(item.keyid)==-1){ | |
| 2509 | - wx.showToast({ | |
| 2510 | - title: "该门店无此服务项目,请重新选择!", | |
| 2511 | - icon: 'none', | |
| 2512 | - duration: 2000 | |
| 2513 | - }); | |
| 2514 | - return false; | |
| 2515 | - } | |
| 2516 | - | |
| 2517 | - if(!item) return false; | |
| 2518 | - | |
| 2519 | - th.setData({ | |
| 2520 | - def_pick_store: item, | |
| 2521 | - sto_sele_name: item.pickup_name, | |
| 2522 | - sto_sele_id: item.pickup_id, | |
| 2523 | - sto_sele_keyid: item.keyid, | |
| 2524 | - sto_sele_distr: item.distr_type, | |
| 2525 | - store: 0, | |
| 2526 | - choice_sort_store: 0, | |
| 2527 | - fir_pick_index: 0 | |
| 2528 | - }); | |
| 2529 | - | |
| 2530 | - if (openindstore == 1) { | |
| 2531 | - th.setData({ | |
| 2532 | - openSpecModal: !0, | |
| 2533 | - openSpecModal_ind: openindstore, | |
| 2534 | - }); | |
| 2535 | - } else if (openindstore == 2) { | |
| 2536 | - th.setData({ | |
| 2537 | - openSpecModal: !0, | |
| 2538 | - openSpecModal_ind: openindstore, | |
| 2539 | - }); | |
| 2540 | - } | |
| 2541 | - else if(openindstore == 4) { //4就是拼团 | |
| 2542 | - th.setData({ | |
| 2543 | - openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2544 | - store: 0, //关闭门店 | |
| 2545 | - choice_sort_store: 0, //关闭门店2级 | |
| 2546 | - sort_store: 0, //关闭门店2级 | |
| 2547 | - }); | |
| 2548 | - } | |
| 2549 | - else { | |
| 2550 | - th.setData({ | |
| 2551 | - store: 0, | |
| 2552 | - choice_sort_store: 0, | |
| 2553 | - sort_store: 0 | |
| 2554 | - }) | |
| 2555 | - } | |
| 2556 | - }, | |
| 2557 | - | |
| 2558 | - //---点击二级之后的选择--- | |
| 2559 | - choose_for_store: function(e) { | |
| 2560 | - var index_c = e.currentTarget.dataset.ind; | |
| 2561 | - var th=this; | |
| 2562 | - th.setData({ | |
| 2563 | - sec_pick_index: index_c, | |
| 2564 | - fir_pick_index: index_c | |
| 2565 | - }) | |
| 2566 | - | |
| 2567 | - }, | |
| 2568 | - //把选择的门店设置成默认的门店def_pick | |
| 2569 | - set_def_pick: function(e) { | |
| 2570 | - var th = this; | |
| 2571 | - var item = null; | |
| 2572 | - if (th.data.choice_sort_store == 0) { | |
| 2573 | - var index = th.data.fir_pick_index; | |
| 2574 | - if (th.data.is_show_sto_cat == 1) { | |
| 2575 | - item = th.data.def_pickpu_list[index]; | |
| 2576 | - } else { | |
| 2577 | - item = th.data.only_pk[index]; //当没有门店分类的时候 | |
| 2578 | - } | |
| 2579 | - } else { | |
| 2580 | - var index = th.data.sec_pick_index; | |
| 2581 | - item = th.data.sec_sto.s_arr[index]; | |
| 2582 | - } | |
| 2583 | - | |
| 2584 | - //判断门店的配送方式是不是匹配 | |
| 2585 | - var ser_card=this.data.data; | |
| 2586 | - //判断门店的配送方式是不是匹配 | |
| 2587 | - if(ser_card.storageId!=null && ser_card.storageId!="" && ser_card.storageId.indexOf(item.keyid)==-1){ | |
| 2588 | - wx.showToast({ | |
| 2589 | - title: "该门店无此服务项目,请重新选择!", | |
| 2590 | - icon: 'none', | |
| 2591 | - duration: 2000 | |
| 2592 | - }); | |
| 2593 | - return false; | |
| 2594 | - } | |
| 2595 | - | |
| 2596 | - | |
| 2597 | - | |
| 2598 | - var store_id = os.stoid; | |
| 2599 | - var user_id = getApp().globalData.user_id; | |
| 2600 | - var def_pickup_id = item.pickup_id; | |
| 2601 | - | |
| 2602 | - getApp().request.put('/api/weshop/users/update', { | |
| 2603 | - data: { | |
| 2604 | - user_id:user_id, | |
| 2605 | - def_pickup_id:def_pickup_id | |
| 2606 | - }, | |
| 2607 | - success: function(res) { | |
| 2608 | - if (res.data.code == 0) { | |
| 2609 | - if (th.data.choice_sort_store == 0) th.setData({ | |
| 2610 | - fir_pick_index: 0 | |
| 2611 | - }); | |
| 2612 | - getApp().globalData.pk_store = item; | |
| 2613 | - } else { | |
| 2614 | - //s.showWarning("设置默认门店地址失败", null, 500, !1); | |
| 2615 | - getApp().my_warnning("设置默认门店地址失败",0,th) | |
| 2616 | - } | |
| 3082 | + func(f_more); | |
| 3083 | + | |
| 3084 | + }, | |
| 2617 | 3085 | |
| 3086 | + | |
| 3087 | + //-------------获取购买数量的总函数---------------- | |
| 3088 | + get_buy_num: function (func) { | |
| 3089 | + | |
| 3090 | + var th = this, | |
| 3091 | + user_id = getApp().globalData.user_id; | |
| 3092 | + if (user_id == null) { | |
| 3093 | + | |
| 3094 | + th.setData({ | |
| 3095 | + prom_buy_num: 0, | |
| 3096 | + }); | |
| 3097 | + "function" == typeof func && func(); | |
| 3098 | + return false; | |
| 2618 | 3099 | } |
| 2619 | - }); | |
| 2620 | 3100 | |
| 3101 | + //----获取活动购买数---- | |
| 3102 | + getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3103 | + data: { | |
| 3104 | + store_id: os.stoid, | |
| 3105 | + user_id: user_id, | |
| 3106 | + card_id: th.data.options.goods_id, | |
| 3107 | + prom_type: th.data.options.prom_type, | |
| 3108 | + prom_id: th.data.options.prom_id | |
| 3109 | + }, | |
| 3110 | + //-----获取----- | |
| 3111 | + success: function (tt) { | |
| 3112 | + if (tt.data.code == 0) { | |
| 3113 | + // map.set(gd.goods_id, g_buy_num); | |
| 3114 | + th.setData({ | |
| 3115 | + // g_buy_num: map, | |
| 3116 | + promcardbuynum: tt.data.data.promcardbuynum, | |
| 3117 | + cardbuynum: tt.data.data.cardbuynum, | |
| 3118 | + }); | |
| 3119 | + "function" == typeof func && func(); | |
| 3120 | + } | |
| 3121 | + } | |
| 3122 | + }); | |
| 2621 | 3123 | |
| 2622 | - if(!item) return false; | |
| 3124 | + }, | |
| 2623 | 3125 | |
| 2624 | - th.setData({ | |
| 2625 | - def_pick_store: item, | |
| 2626 | - sto_sele_name: item.pickup_name, | |
| 2627 | - sto_sele_id: item.pickup_id, | |
| 2628 | - sto_sele_keyid: item.keyid, | |
| 2629 | - sto_sele_distr: item.distr_type, | |
| 2630 | - store: 0, | |
| 2631 | - choice_sort_store: 0 | |
| 2632 | - }); | |
| 2633 | 3126 | |
| 2634 | - var openindstore = th.data.open_ind_store; | |
| 2635 | - if (openindstore == 1) { | |
| 2636 | - th.setData({ | |
| 2637 | - openSpecModal: !0, | |
| 2638 | - openSpecModal_ind: openindstore, | |
| 2639 | - store: 0, | |
| 2640 | - choice_sort_store: 0, | |
| 2641 | - sort_store: 0, | |
| 2642 | - }); | |
| 2643 | - } else if (openindstore == 2) { | |
| 2644 | - th.setData({ | |
| 2645 | - openSpecModal: !0, | |
| 2646 | - openSpecModal_ind: openindstore, | |
| 2647 | - store: 0, | |
| 2648 | - choice_sort_store: 0, | |
| 2649 | - sort_store: 0, | |
| 2650 | - }); | |
| 2651 | - } | |
| 2652 | - else if (openindstore == 4) { //4就是拼团 | |
| 2653 | - th.setData({ | |
| 2654 | - openSpecModal_pt: 1, //打开拼团购买界面 | |
| 2655 | - store: 0, //关闭门店 | |
| 2656 | - choice_sort_store: 0, //关闭门店2级 | |
| 2657 | - sort_store: 0, //关闭门店2级 | |
| 3127 | + get_buy_num2: async function () { | |
| 3128 | + // var map = this.data.g_buy_num, | |
| 3129 | + var th = this, user_id = getApp().globalData.user_id; | |
| 3130 | + //----获取活动购买数---- | |
| 3131 | + return await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3132 | + data: { | |
| 3133 | + store_id: os.stoid, | |
| 3134 | + user_id: user_id, | |
| 3135 | + card_id: th.data.options.goods_id, | |
| 3136 | + prom_type: th.data.options.prom_type, | |
| 3137 | + prom_id: th.data.options.prom_id | |
| 3138 | + } | |
| 2658 | 3139 | }); |
| 2659 | - } | |
| 3140 | + }, | |
| 2660 | 3141 | |
| 2661 | - else { | |
| 2662 | - th.setData({ | |
| 2663 | - store: 0, | |
| 2664 | - choice_sort_store: 0, | |
| 2665 | - sort_store: 0, | |
| 3142 | + | |
| 3143 | + // 促销 -> 送礼包 -> 查看详情 | |
| 3144 | + viewLbDetails(e) { | |
| 3145 | + let id = e.currentTarget.dataset.id; // 获取礼包id | |
| 3146 | + let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | |
| 3147 | + // console.log('myurl', url); | |
| 3148 | + getApp().goto(url); | |
| 3149 | + }, | |
| 3150 | + | |
| 3151 | + go_more_ladder: function (e) { | |
| 3152 | + var prom_id = e.currentTarget.dataset.id; | |
| 3153 | + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id=" + prom_id); | |
| 3154 | + }, | |
| 3155 | + | |
| 3156 | + getHistoryBuy() { | |
| 3157 | + let _this = this; | |
| 3158 | + let req_data = { | |
| 3159 | + store_id: os.stoid, | |
| 3160 | + goods_id: this.data.gid, | |
| 3161 | + pay_status: 1, | |
| 3162 | + rndid: 1 | |
| 3163 | + }; | |
| 3164 | + getApp().request.promiseGet('/api/weshop/ordergoods/list', { | |
| 3165 | + data: req_data, | |
| 2666 | 3166 | }) |
| 2667 | - } | |
| 2668 | - | |
| 2669 | - }, | |
| 2670 | - | |
| 2671 | - wait_for_store_config: function() { | |
| 2672 | - var th = this; | |
| 2673 | - var t_time = setInterval(function() { | |
| 2674 | - if (th.data.bconfig == null) false; | |
| 2675 | - var e = th.data.bconfig; | |
| 2676 | - if (e && e.is_sort_storage) { | |
| 2677 | - wx.getLocation({ | |
| 2678 | - type: 'gcj02', | |
| 2679 | - success: function(res) { | |
| 2680 | - th.data.lat = res.latitude; | |
| 2681 | - th.data.lon = res.longitude; | |
| 2682 | - th.data.is_get_local_ok = 1; | |
| 2683 | - }, | |
| 2684 | - fail: function(res) { | |
| 2685 | - if (res.errCode == 2) { | |
| 2686 | - th.setData({ | |
| 2687 | - is_gps: 0 | |
| 2688 | - }); | |
| 2689 | - if (th.data.is_gps == 0) { | |
| 2690 | - getApp().confirmBox("请开启GPS定位", null, 10000, !1); | |
| 2691 | - } | |
| 3167 | + .then(res => { | |
| 3168 | + if (ut.ajax_ok(res)) { | |
| 3169 | + _this.setData({ | |
| 3170 | + historyBuyInfo: res.data.data.pageData, | |
| 3171 | + }) | |
| 3172 | + } | |
| 3173 | + }) | |
| 3174 | + }, | |
| 2692 | 3175 | |
| 3176 | + | |
| 3177 | + //打开客服操作菜单 | |
| 3178 | + openCS() { | |
| 3179 | + // 判断会员状态 | |
| 3180 | + let user_info = getApp().globalData.userInfo; | |
| 3181 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { | |
| 3182 | + wx.navigateTo({ | |
| 3183 | + url: '/packageE/pages/togoin/togoin', | |
| 3184 | + }) | |
| 3185 | + return false; | |
| 3186 | + } | |
| 3187 | + ; | |
| 3188 | + // csType/在线客服设置: | |
| 3189 | + // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | |
| 3190 | + // 1小程序客服、 | |
| 3191 | + // 2企业微信客服 | |
| 3192 | + if (this.data.sys_switch) { | |
| 3193 | + let csType = this.data.sys_switch.weapp_customertype; | |
| 3194 | + if (csType == 0) { | |
| 3195 | + // 拨打电话号码 | |
| 3196 | + this.contactService(); | |
| 2693 | 3197 | } else { |
| 2694 | - th.setData({ | |
| 2695 | - is_gps: "3" | |
| 2696 | - }); | |
| 3198 | + this.getTel() | |
| 3199 | + .then(() => { | |
| 3200 | + self.setData({ | |
| 3201 | + hiddenCS: false, | |
| 3202 | + }); | |
| 3203 | + }); | |
| 2697 | 3204 | } |
| 3205 | + ; | |
| 3206 | + } | |
| 3207 | + ; | |
| 2698 | 3208 | |
| 2699 | - th.data.is_get_local_ok = 1; | |
| 2700 | - } | |
| 2701 | - }) | |
| 2702 | - } else { | |
| 2703 | - th.data.is_get_local_ok = 1; | |
| 2704 | - } | |
| 2705 | - clearInterval(t_time); | |
| 2706 | - }, 500) | |
| 2707 | - }, | |
| 2708 | - | |
| 2709 | - | |
| 2710 | - //-- 根据ID拿出门店 -- | |
| 2711 | - get_pick_from_list(pid){ | |
| 2712 | - var all_pick_list=this.data.all_pick_list; | |
| 2713 | - for(var i in all_pick_list){ | |
| 2714 | - var item=all_pick_list[i]; | |
| 2715 | - if(item.pickup_id==pid){ return item;} | |
| 2716 | - } | |
| 2717 | - }, | |
| 2718 | - | |
| 2719 | - closePoster() { | |
| 2720 | - this.setData({ | |
| 2721 | - showPoster: false, | |
| 2722 | - }); | |
| 2723 | - }, | |
| 2724 | - | |
| 2725 | - // 保存图片到手机 | |
| 2726 | - savePic() { | |
| 2727 | - console.log('保存图片'); | |
| 2728 | - var self = this; | |
| 2729 | - // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 | |
| 2730 | - this.getSetting().then((res) => { | |
| 2731 | - // 判断用户是否授权了保存到相册的权限,如果没有发起授权 | |
| 2732 | - if (!res.authSetting['scope.writePhotosAlbum']) { | |
| 2733 | - this.authorize().then(() => { | |
| 2734 | - // 同意授权后保存下载文件 | |
| 2735 | - this.saveImage(self.data.shareImgPath) | |
| 2736 | - .then(() => { | |
| 2737 | - self.setData({ | |
| 2738 | - showPoster: false | |
| 2739 | - }); | |
| 2740 | - }); | |
| 2741 | - }) | |
| 2742 | - } else { | |
| 2743 | - // 如果已经授权,保存下载文件 | |
| 2744 | - this.saveImage(self.data.shareImgPath) | |
| 2745 | - .then(() => { | |
| 2746 | - self.setData({ showPoster: false }); | |
| 2747 | - }); | |
| 2748 | - } | |
| 2749 | - | |
| 2750 | - }) | |
| 2751 | - }, | |
| 2752 | - | |
| 2753 | - // 获取用户已经授予了哪些权限 | |
| 2754 | - getSetting() { | |
| 2755 | - return new Promise((resolve, reject) => { | |
| 2756 | - wx.getSetting({ | |
| 2757 | - success: res => { | |
| 2758 | - resolve(res) | |
| 2759 | - } | |
| 2760 | - }) | |
| 2761 | - }) | |
| 2762 | - }, | |
| 2763 | - | |
| 2764 | - // 发起首次授权请求 | |
| 2765 | - authorize() { | |
| 2766 | - // isFirst 用来记录是否为首次发起授权, | |
| 2767 | - // 如果首次授权拒绝后,isFirst赋值为1 | |
| 2768 | - let isFirst = wx.getStorageSync('isFirst') || 0; | |
| 2769 | - return new Promise((resolve, reject) => { | |
| 2770 | - wx.authorize({ | |
| 2771 | - scope: 'scope.writePhotosAlbum', | |
| 2772 | - // 同意授权 | |
| 2773 | - success: () => { | |
| 2774 | - resolve(); | |
| 2775 | - }, | |
| 2776 | - // 拒绝授权,这里是用户拒绝授权后的回调 | |
| 2777 | - fail: res => { | |
| 2778 | - if(isFirst === 0) { | |
| 2779 | - wx.setStorageSync('isFirst', 1); | |
| 2780 | - wx.showToast({ | |
| 2781 | - title: '保存失败', | |
| 2782 | - icon: 'none', | |
| 2783 | - duration: 1000 | |
| 2784 | - }) | |
| 2785 | - } else { | |
| 2786 | - this.showModal(); | |
| 2787 | - } | |
| 2788 | - console.log('拒绝授权'); | |
| 2789 | - reject(); | |
| 2790 | - } | |
| 2791 | - }) | |
| 2792 | - }) | |
| 2793 | - }, | |
| 2794 | - | |
| 2795 | - // 保存图片到系统相册 | |
| 2796 | - saveImage(saveUrl) { | |
| 2797 | - var self = this; | |
| 2798 | - return new Promise((resolve, reject) => { | |
| 2799 | - wx.saveImageToPhotosAlbum({ | |
| 2800 | - filePath: saveUrl, | |
| 2801 | - success: (res) => { | |
| 2802 | - wx.showToast({ | |
| 2803 | - title: '保存成功', | |
| 2804 | - duration: 1000, | |
| 2805 | - }); | |
| 2806 | - self.setData({ | |
| 2807 | - showPlaybill: 'true' | |
| 2808 | - }); | |
| 2809 | - resolve(); | |
| 2810 | - }, | |
| 2811 | - fail: () => { | |
| 2812 | - wx.showToast({ | |
| 2813 | - title: '保存失败', | |
| 2814 | - duration: 1000, | |
| 2815 | - }); | |
| 2816 | - } | |
| 2817 | - }) | |
| 2818 | - }) | |
| 2819 | - }, | |
| 2820 | - | |
| 2821 | - previewImage() { | |
| 2822 | - getApp().pre_img(this.data.shareImgPath); | |
| 2823 | - }, | |
| 2824 | - | |
| 2825 | - onShareTimeline() { | |
| 2826 | - getApp().globalData.no_clear=1 | |
| 2827 | - var store_name=getApp().globalData.config?getApp().globalData.config.store_name:''; | |
| 2828 | - if(!store_name) | |
| 2829 | - store_name=getApp().globalData.setting.appName; | |
| 2830 | - | |
| 2831 | - return { | |
| 2832 | - title:this.data.data.goods_name + '-' + store_name, | |
| 2833 | - imageUrl:this.data.gallery[0].image_url, | |
| 2834 | - } | |
| 2835 | - }, | |
| 2836 | - | |
| 2837 | - | |
| 2838 | - | |
| 2839 | - clickCollapse() { | |
| 2840 | - this.setData({ | |
| 2841 | - flag: !this.data.flag, | |
| 2842 | - }) | |
| 2843 | - }, | |
| 3209 | + }, | |
| 2844 | 3210 | |
| 2845 | - //---------联系微信客服------------ | |
| 2846 | - con_weixin:function () { | |
| 2847 | - var url=this.data.sys_switch.weapp_customertype_url; | |
| 2848 | - var id=this.data.sys_switch.weapp_customertype_appid; | |
| 2849 | - wx.openCustomerServiceChat({ | |
| 2850 | - extInfo: {url: url}, | |
| 2851 | - corpId: id, | |
| 2852 | - success(res) {} | |
| 2853 | - }) | |
| 3211 | + //关闭客服操作菜单 | |
| 3212 | + closeCS() { | |
| 3213 | + this.setData({ | |
| 3214 | + hiddenCS: true, | |
| 3215 | + }); | |
| 2854 | 3216 | }, |
| 2855 | - | |
| 2856 | - //评论的调用 | |
| 2857 | - requestComments_new: async function () { | |
| 2858 | - var e = this, th = e, ee = e; var tp = e.data.activeCategoryId3; | |
| 2859 | - var t = '/api/weshop/serviceComment/pageComment?page=' + e.data.c_curr_p; | |
| 2860 | - | |
| 2861 | - wx.showLoading(); | |
| 2862 | - var req_where = { | |
| 2863 | - store_id: os.stoid, pageSize: 5, is_show: 1, | |
| 2864 | - parent_id: 0, goods_id: th.data.gid, commenttype: tp, | |
| 2865 | - service_id: this.data.gid, | |
| 2866 | - } | |
| 2867 | - if (getApp().globalData.userInfo) { | |
| 2868 | - req_where.userId = getApp().globalData.user_id; | |
| 2869 | - } | |
| 2870 | - | |
| 2871 | - var rs_data = null; | |
| 2872 | - await getApp().request.promiseGet(t, { data: req_where }).then(res => { | |
| 2873 | - var tot = res.data.data.total; | |
| 2874 | - e.data.c_curr_p++; | |
| 2875 | - e.setData({ | |
| 2876 | - com_num: tot, //已经有加载 | |
| 2877 | - }); | |
| 2878 | - if (res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 2879 | - rs_data = res.data.data.pageData; | |
| 2880 | - } else { | |
| 2881 | - th.setData({ comments_no_more: 1, auto: 1 }); | |
| 2882 | - } | |
| 2883 | - }) | |
| 2884 | - | |
| 2885 | - if (rs_data) { | |
| 2886 | - //var cda = th.data.comments; | |
| 2887 | - var cda = rs_data, com_data = th.data.comments; | |
| 2888 | - for (var ind in cda) { | |
| 2889 | - var ep = cda[ind]; | |
| 2890 | - if (cda[ind].head_pic == '') { | |
| 2891 | - cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; | |
| 2892 | - } | |
| 2893 | - if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { | |
| 2894 | - cda[ind].weapp_img = JSON.parse(ep.weapp_img); | |
| 2895 | - } | |
| 2896 | - if (ep.img != "" && ut.isString(ep.img)) { | |
| 2897 | - cda[ind].img = ut.unserialize(ep.img); | |
| 2898 | - } | |
| 2899 | - | |
| 2900 | - //--测量多有字的宽带,计算有多少行-- | |
| 2901 | - var widh = ut.measureText(ep.content, 30); | |
| 2902 | - var lines = widh / 712; | |
| 2903 | - cda[ind].seeMore = false; | |
| 2904 | - if (lines > 3) cda[ind].seeMore = true; | |
| 2905 | - | |
| 2906 | - await getApp().request.promiseGet("/api/weshop/serviceComment/pageComment", { | |
| 2907 | - data: { | |
| 2908 | - store_id: os.stoid, | |
| 2909 | - parent_id: ep.comment_id, | |
| 2910 | - service_id: this.data.gid, | |
| 2911 | - } | |
| 2912 | - }).then(res => { | |
| 2913 | - if (res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 2914 | - cda[ind].replay_list = res.data.data.pageData; | |
| 2915 | - } | |
| 2916 | - }) | |
| 2917 | - } | |
| 2918 | - | |
| 2919 | - if (!com_data) com_data = cda; | |
| 2920 | - else com_data = com_data.concat(cda); | |
| 2921 | - | |
| 2922 | - th.setData({ comments: com_data }); | |
| 2923 | - } | |
| 2924 | - th.setData({ get_c: 1 }); | |
| 2925 | - wx.hideLoading(); | |
| 2926 | - }, | |
| 2927 | - | |
| 2928 | - | |
| 2929 | - | |
| 2930 | - //--点赞功能-- | |
| 2931 | - click_zan: function (e) { | |
| 2932 | - var com_id = e.currentTarget.dataset.com_id; | |
| 2933 | - var item_id = e.currentTarget.dataset.item_id; | |
| 2934 | - var app = getApp(), | |
| 2935 | - th = this; | |
| 2936 | - | |
| 2937 | - if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { | |
| 2938 | - app.confirmBox("您还未登录"); | |
| 2939 | - return false; | |
| 2940 | - } | |
| 2941 | - | |
| 2942 | - var iszan = th.data.comments[item_id].userZanNum; | |
| 2943 | - if (this.data.iszaning) return false; | |
| 2944 | - this.data.iszaning = 1; | |
| 2945 | - | |
| 2946 | - | |
| 2947 | - app.request.post("/api/weshop/serviceCommentZan/save", { | |
| 2948 | - data: { | |
| 2949 | - store_id: os.stoid, | |
| 2950 | - user_id: app.globalData.user_id, | |
| 2951 | - goods_id: th.data.gid, | |
| 2952 | - service_id: th.data.gid, | |
| 2953 | - comment_id: com_id | |
| 2954 | - }, | |
| 2955 | - success: function (ee) { | |
| 2956 | - | |
| 2957 | - if (ee.data.code == "-1") { | |
| 2958 | - app.my_warnning("不能给自己点赞", 0, th); | |
| 2959 | - th.data.iszaning = 0; | |
| 2960 | - return; | |
| 2961 | - } | |
| 2962 | - | |
| 2963 | - if (ee.data.code == 0 && iszan != 1) { | |
| 2964 | - var num = th.data.comments[item_id].zan_num; | |
| 2965 | - num++; | |
| 2966 | - var text = "comments[" + item_id + "].zan_num"; | |
| 2967 | - var text1 = "comments[" + item_id + "].userZanNum"; | |
| 2968 | - var _errObj = {}; | |
| 2969 | - _errObj[text] = num; | |
| 2970 | - _errObj[text1] = 1; | |
| 2971 | - th.setData(_errObj); | |
| 2972 | - | |
| 2973 | - } else { | |
| 2974 | - var num = th.data.comments[item_id].zan_num; | |
| 2975 | - num--; | |
| 2976 | - var text = "comments[" + item_id + "].zan_num"; | |
| 2977 | - var text1 = "comments[" + item_id + "].userZanNum"; | |
| 2978 | - var _errObj = {}; | |
| 2979 | - _errObj[text] = num; | |
| 2980 | - _errObj[text1] = 0; | |
| 2981 | - th.setData(_errObj); | |
| 2982 | - } | |
| 2983 | - | |
| 2984 | - setTimeout(function () { | |
| 2985 | - th.data.iszaning = 0; | |
| 2986 | - }, 500) | |
| 2987 | - | |
| 2988 | - } | |
| 2989 | - }) | |
| 2990 | - }, | |
| 2991 | - | |
| 2992 | - | |
| 2993 | - //--外侧评价的点击效果--- | |
| 2994 | - clik_evaluate: function (e) { | |
| 2995 | - var val = e.currentTarget.dataset.val; | |
| 2996 | - this.setData({ | |
| 2997 | - activeCategoryId: 2, | |
| 2998 | - activeCategoryId3: val, | |
| 2999 | - comments: null | |
| 3000 | - }); | |
| 3001 | - this.requestComments_new(); | |
| 3002 | - }, | |
| 3003 | - | |
| 3004 | - | |
| 3005 | - //显示全部 | |
| 3006 | - toggleHandler: function (e) { | |
| 3007 | - var that = this, | |
| 3008 | - index = e.currentTarget.dataset.index; | |
| 3009 | - for (var i = 0; i < that.data.comments.length; i++) { | |
| 3010 | - if (index == i) { | |
| 3011 | - for (var i = 0; i < that.data.comments.length; i++) { | |
| 3012 | - that.data.comments[index].auto = true; | |
| 3013 | - that.data.comments[index].seeMore = false; | |
| 3014 | - } | |
| 3015 | - } | |
| 3016 | - } | |
| 3017 | - that.setData({ | |
| 3018 | - comments: that.data.comments | |
| 3019 | - }) | |
| 3020 | - }, | |
| 3021 | - | |
| 3022 | - //收起更多 | |
| 3023 | - toggleContent: function (e) { | |
| 3024 | - var that = this, | |
| 3025 | - index = e.currentTarget.dataset.index; | |
| 3026 | - for (var i = 0; i < that.data.comments.length; i++) { | |
| 3027 | - if (index == i) { | |
| 3028 | - that.data.comments[index].auto = true; | |
| 3029 | - that.data.comments[index].seeMore = true; | |
| 3030 | - } | |
| 3031 | - } | |
| 3032 | - that.setData({ | |
| 3033 | - comments: that.data.comments | |
| 3034 | - }) | |
| 3035 | - }, | |
| 3036 | - | |
| 3037 | - //--查看评价-- | |
| 3038 | - look_pj: function () { | |
| 3039 | - this.tabComment(); | |
| 3040 | - this.doScrollTop(); | |
| 3041 | - }, | |
| 3042 | - | |
| 3043 | - previewCommentImgs_w: function (t) { | |
| 3044 | - var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; | |
| 3045 | - var b = e.slice() | |
| 3046 | - // for (var i in b) { | |
| 3047 | - // b[i] = this.data.iurl + e[i]; | |
| 3048 | - // } | |
| 3049 | - this.data.show_prew_img = 1; | |
| 3050 | - wx.previewImage({ | |
| 3051 | - current: b[t.currentTarget.dataset.id], | |
| 3052 | - urls: b | |
| 3053 | - }); | |
| 3054 | - }, | |
| 3055 | - | |
| 3056 | - | |
| 3057 | - // 判断是否开启美业,获取套盒列表 | |
| 3058 | - getTaohe() { | |
| 3059 | - // 判断是否开启美业 | |
| 3060 | - getApp().promiseGet('/api/weshop/store/getTabSys/' + os.stoid, {}).then(res => { | |
| 3061 | - if(res.data.code == 0) { | |
| 3062 | - let enableMeiye = res.data.data.EnableMeiye; | |
| 3063 | - self.setData({ | |
| 3064 | - enableMeiye, | |
| 3065 | - }); | |
| 3066 | - | |
| 3067 | - if(enableMeiye) { // 开启美业 | |
| 3068 | - // 获取套盒列表 | |
| 3069 | - let url = '/api/weshop/serviceGoods/list' | |
| 3070 | - let data = { | |
| 3071 | - store_id: getApp().globalData.setting.stoid, | |
| 3072 | - service_id: this.data.data.id, | |
| 3073 | - }; | |
| 3074 | - // 请求数据 | |
| 3075 | - getApp().promiseGet(url, { | |
| 3076 | - data: data, | |
| 3077 | - }).then(res => { | |
| 3078 | - if (res.data.code == 0) { | |
| 3079 | - console.log('请求成功套盒列表', res); | |
| 3080 | - self.setData({ | |
| 3081 | - taoheList: res.data.data, | |
| 3082 | - }); | |
| 3083 | - } else { | |
| 3084 | - throw (res); | |
| 3085 | - }; | |
| 3086 | - }).catch(err => {}); | |
| 3087 | - | |
| 3088 | - }; | |
| 3089 | - }; | |
| 3090 | - }); | |
| 3091 | - }, | |
| 3092 | - | |
| 3093 | - //---小于10的格式化函数---- | |
| 3094 | - timeFormat(param) { | |
| 3095 | - return param < 10 ? '0' + param : param; | |
| 3217 | + | |
| 3218 | + click_contact: function () { | |
| 3219 | + getApp().globalData.no_clear = 1; | |
| 3096 | 3220 | }, |
| 3097 | - //----倒计时函数----- | |
| 3098 | - countDown(time, prom_st) { | |
| 3099 | - if (!this.data.is_timer) return false; | |
| 3100 | - var th = this; | |
| 3101 | - // 获取当前时间,同时得到活动结束时间数组 | |
| 3102 | - var endTime = time; | |
| 3103 | - var newTime = ut.gettimestamp(); | |
| 3104 | - // 对结束时间进行处理渲染到页面 | |
| 3105 | - var obj = null; | |
| 3106 | - // 如果活动未结束,对时间进行处理 | |
| 3107 | - if (endTime - newTime > 0) { | |
| 3108 | - var time = (endTime - newTime); | |
| 3109 | - // 获取天、时、分、秒 | |
| 3110 | - var day = parseInt(time / (60 * 60 * 24)); | |
| 3111 | - var hou = parseInt(time % (60 * 60 * 24) / 3600); | |
| 3112 | - var min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
| 3113 | - var sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
| 3114 | - obj = { | |
| 3115 | - day: this.timeFormat(day), | |
| 3116 | - hou: this.timeFormat(hou), | |
| 3117 | - min: this.timeFormat(min), | |
| 3118 | - sec: this.timeFormat(sec) | |
| 3119 | - } | |
| 3120 | - } else { | |
| 3121 | - if (th.data.prom_st == 0) { | |
| 3122 | - //var endTime2 = new Date(th.data.prom_end_time).getTime(); | |
| 3123 | - var endTime2 = th.data.prom_act.end_time; | |
| 3124 | - th.setData({ | |
| 3125 | - prom_time_text: '距结束还剩:', | |
| 3126 | - prom_st: 1 | |
| 3127 | - }) | |
| 3128 | - setTimeout(function () { | |
| 3129 | - th.countDown(endTime2) | |
| 3130 | - }, 1000); | |
| 3131 | - return false; | |
| 3132 | - | |
| 3133 | - } else { | |
| 3134 | - //活动已结束,全部设置为'00' | |
| 3135 | - obj = { | |
| 3136 | - day: '00', | |
| 3137 | - hou: '00', | |
| 3138 | - min: '00', | |
| 3139 | - sec: '00' | |
| 3140 | - } | |
| 3141 | - th.setData({ | |
| 3142 | - prom_time_text: '活动已经结束:', | |
| 3143 | - prom_st: 3 | |
| 3144 | - }) | |
| 3145 | - th.setData({ | |
| 3146 | - djs: obj | |
| 3147 | - }); | |
| 3148 | - return false; | |
| 3149 | - } | |
| 3150 | - } | |
| 3151 | - | |
| 3152 | - th.setData({ | |
| 3153 | - djs: obj | |
| 3154 | - }); | |
| 3155 | - setTimeout(function () { | |
| 3156 | - th.countDown(endTime) | |
| 3157 | - }, 1000); | |
| 3158 | - }, | |
| 3159 | - | |
| 3160 | - | |
| 3161 | - get_normal(gid) { | |
| 3162 | - this.setData({ | |
| 3163 | - prom_type: 0, | |
| 3164 | - isshow: 1, | |
| 3165 | - }); | |
| 3166 | - this.get_sku(os.stoid, this.data.data, gid); | |
| 3167 | - this.get_sto(); | |
| 3168 | - this.check_is_youhui(gid, 1); | |
| 3169 | - this.data.is_normal = 1; | |
| 3170 | - }, | |
| 3171 | - | |
| 3172 | - //获取redis中的数量 | |
| 3173 | - async getactLen() { | |
| 3174 | - let prom_type = this.data.options.prom_type; | |
| 3175 | - let prom_id = this.data.options.prom_id; | |
| 3176 | - return await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | |
| 3177 | - 1: 1 | |
| 3178 | - }).then(res => { | |
| 3179 | - if (res.data.code == 0) { | |
| 3180 | - // 当前可以购买的数量 | |
| 3181 | - let r_num = res.data.data; | |
| 3182 | - return r_num; | |
| 3183 | - }; | |
| 3184 | - }) | |
| 3185 | - }, | |
| 3186 | 3221 | |
| 3222 | + //打开客服操作菜单 | |
| 3223 | + openCS() { | |
| 3224 | + // csType/在线客服设置: | |
| 3225 | + // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | |
| 3226 | + // 1小程序客服、 | |
| 3227 | + // 2企业微信客服 | |
| 3228 | + let csType = this.data.sys_switch.weapp_customertype; | |
| 3229 | + if (csType == 0) { | |
| 3230 | + // 获取电话号码 | |
| 3231 | + this.contactService(); | |
| 3232 | + } else { | |
| 3233 | + this.getTel() | |
| 3234 | + .then(() => { | |
| 3235 | + self.setData({ | |
| 3236 | + hiddenCS: false, | |
| 3237 | + }); | |
| 3238 | + }); | |
| 3187 | 3239 | |
| 3240 | + } | |
| 3241 | + ; | |
| 3242 | + }, | |
| 3188 | 3243 | |
| 3189 | - //--------检查是否活动,活动是否开始,或者是否结束------- | |
| 3190 | - async check_prom(gid, prom_type, prom_id) { | |
| 3191 | - var ee = this, th = ee; | |
| 3192 | - var user_id = getApp().globalData.user_id; | |
| 3193 | - if (!user_id) user_id = 0; | |
| 3194 | - //-------判断活动是否抢光--------- | |
| 3195 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + prom_id, { | |
| 3196 | - 1: 1 | |
| 3197 | - }).then(res => { | |
| 3198 | - var em = res; | |
| 3199 | - var flag = null; | |
| 3200 | - if (em.data.code == 0) { | |
| 3201 | - if (em.data.data <= 0) ee.setData({ | |
| 3202 | - prom_r_null: 1 | |
| 3203 | - }); | |
| 3204 | - //拿取价格并且判断时间-- | |
| 3205 | - getApp().request.get("/api/weshop/teamlist/get/" + | |
| 3206 | - os.stoid + "/" + prom_id, { | |
| 3207 | - success: async function (t) { | |
| 3208 | - if (t.data.code != 0) { | |
| 3209 | - ee.get_normal(gid); | |
| 3210 | - return false; | |
| 3211 | - } | |
| 3212 | - //----已经结束----- | |
| 3213 | - if (t.data.data.is_end == 1) { | |
| 3214 | - ee.get_normal(gid); | |
| 3215 | - return false; | |
| 3216 | - } | |
| 3217 | - //----已经过期----- | |
| 3218 | - var now = ut.gettimestamp(); | |
| 3219 | - if (t.data.data.end_time < now) { | |
| 3220 | - ee.get_normal(gid); | |
| 3221 | - return false; | |
| 3222 | - } | |
| 3244 | + //关闭客服操作菜单 | |
| 3245 | + closeCS() { | |
| 3246 | + this.setData({ | |
| 3247 | + hiddenCS: true, | |
| 3248 | + }); | |
| 3249 | + }, | |
| 3223 | 3250 | |
| 3224 | - /*-- 还没有开始预热的也不显示 --*/ | |
| 3225 | - if (t.data.data.show_time > now) { | |
| 3226 | - ee.get_normal(gid); | |
| 3227 | - return false; | |
| 3228 | - } | |
| 3251 | + //--点击弹起拼单-- | |
| 3252 | + openSpecModel_pt: function (e) { | |
| 3229 | 3253 | |
| 3230 | - /*-- 判断拼单是否启用 --*/ | |
| 3231 | - if (!t.data.data.is_show) { | |
| 3232 | - console.log('没启用'); | |
| 3233 | - wx.setNavigationBarTitle({ | |
| 3234 | - title: '系统提示', | |
| 3235 | - }); | |
| 3236 | - wx.showToast({ | |
| 3237 | - title: '此商品暂时没有拼单活动', | |
| 3238 | - icon: 'none', | |
| 3239 | - success(){ | |
| 3240 | - setTimeout(() => { | |
| 3241 | - wx.navigateBack() | |
| 3242 | - }, 2000) | |
| 3243 | - } | |
| 3244 | - }); | |
| 3245 | - return false | |
| 3246 | - } | |
| 3247 | 3254 | |
| 3248 | - //判断拼团的---会员身份-- | |
| 3249 | - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/2", { | |
| 3250 | - data: { | |
| 3251 | - store_id: os.stoid, | |
| 3252 | - is_end: 0, | |
| 3253 | - is_show: 1, | |
| 3254 | - user_id: getApp().globalData.user_id, | |
| 3255 | - pageSize: 1000 | |
| 3256 | - } | |
| 3257 | - }).then(res => { | |
| 3258 | - let pd_list = res.data.data.pageData; | |
| 3259 | - if (res.data.code == 0 && pd_list.length > 0) { | |
| 3260 | - flag = pd_list.some(pd => { | |
| 3261 | - return pd.goods_id == gid | |
| 3262 | - }) | |
| 3263 | - } | |
| 3264 | - }) | |
| 3265 | - if (!flag) { | |
| 3266 | - ee.get_normal(gid); | |
| 3267 | - return false; | |
| 3255 | + this.setData({open_ind_store: 4, goodsInputNum: 1});//拼团直接给4 | |
| 3268 | 3256 | |
| 3269 | - } | |
| 3270 | - //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- | |
| 3271 | - await getApp().request.promiseGet("/api/weshop/order/page", { | |
| 3272 | - data: { | |
| 3273 | - pt_prom_id: prom_id, | |
| 3274 | - user_id: oo.user_id, | |
| 3275 | - store_id: os.stoid, | |
| 3276 | - pageSize: 1, | |
| 3277 | - page: 1 | |
| 3278 | - } | |
| 3279 | - }).then(e => { | |
| 3280 | - if (e.data.code == 0 && e.data.data.pageData.length > 0) { | |
| 3281 | - var odr = e.data.data.pageData[0]; | |
| 3282 | - th.data.buy_order = odr; | |
| 3283 | - if (odr.pt_status == 0 && odr.order_status == 1) { | |
| 3284 | - th.setData({ | |
| 3285 | - user_order_pt_state: 1 | |
| 3286 | - }); | |
| 3287 | - } | |
| 3288 | - if (odr.pt_status == 1 && odr.order_status == 1) { | |
| 3289 | - if (odr.is_zsorder == 4) { | |
| 3290 | - getApp().request.promiseGet("/api/weshop/teamgroup/page/", { | |
| 3291 | - data: { | |
| 3292 | - store_id: os.stoid, | |
| 3293 | - team_id: odr.pt_prom_id, | |
| 3294 | - listno: odr.pt_listno | |
| 3295 | - } | |
| 3296 | - }).then(res => { | |
| 3297 | - var now = ut.gettimestamp(); | |
| 3298 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) { | |
| 3299 | - var tgr = res.data.data.pageData[0]; | |
| 3300 | - //如果团的时间已经到了 | |
| 3301 | - if (now >= tgr.kt_end_time) { | |
| 3302 | - th.update_jiti(tgr.id); | |
| 3303 | - } else { | |
| 3304 | - th.setData({ | |
| 3305 | - user_order_pt_state: 2 | |
| 3306 | - }); | |
| 3307 | - } | |
| 3308 | - } | |
| 3309 | - }) | |
| 3310 | 3257 | |
| 3311 | - } else { | |
| 3312 | - th.setData({ | |
| 3313 | - user_order_pt_state: 2 | |
| 3314 | - }); | |
| 3315 | - } | |
| 3316 | - } | |
| 3258 | + //--先判断会员状态-- | |
| 3259 | + var user_info = getApp().globalData.userInfo; | |
| 3260 | + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 3261 | + wx.navigateTo({ | |
| 3262 | + url: '/packageE/pages/togoin/togoin', | |
| 3263 | + }) | |
| 3264 | + return false; | |
| 3265 | + } | |
| 3317 | 3266 | |
| 3318 | - if (odr.pt_status == 2 && odr.is_zsorder == 4) { | |
| 3319 | - th.setData({ | |
| 3320 | - user_order_pt_state: 3, | |
| 3321 | - }); | |
| 3322 | - th.data.wk_order_id = odr.order_id; | |
| 3323 | - } | |
| 3324 | - } | |
| 3325 | - }) | |
| 3267 | + var th = this; | |
| 3268 | + var ind = parseInt(e.currentTarget.dataset.it); | |
| 3326 | 3269 | |
| 3327 | - //----------查看阶梯团------------ | |
| 3328 | - if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { | |
| 3329 | - t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); | |
| 3330 | - var max_num = 0; | |
| 3331 | - t.data.data.ct_rylist.forEach(function (val, ind) { | |
| 3332 | - if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); | |
| 3333 | - }) | |
| 3334 | - t.data.data.max_ct_num = max_num; | |
| 3335 | - } | |
| 3270 | + //如果是拼单活动的普通购买 | |
| 3271 | + if (ind == 1) { | |
| 3336 | 3272 | |
| 3337 | - var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); | |
| 3338 | - var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); | |
| 3273 | + if (!th.data.is_normal) { | |
| 3274 | + th.data.g_buy_num = new Map(); | |
| 3275 | + } | |
| 3276 | + //如果拼单的sku data是空的,就要先获取一下 | |
| 3277 | + th.get_sto(1); | |
| 3278 | + th.setData({ | |
| 3279 | + is_normal: ind, | |
| 3280 | + openSpecModal_pt: 1 | |
| 3281 | + }); | |
| 3282 | + //th.check_is_youhui(th.data.gid, 1); | |
| 3283 | + } else { | |
| 3339 | 3284 | |
| 3340 | - ee.setData({ | |
| 3341 | - prom_price: t.data.data.price, | |
| 3342 | - prom_type: 6, | |
| 3343 | - prom_id: prom_id, | |
| 3344 | - prom_buy_limit: t.data.data.buy_limit, | |
| 3345 | - prom_act: t.data.data, | |
| 3346 | - prom_end_time: prom_end_time, | |
| 3347 | - prom_start_time: prom_start_time, | |
| 3348 | - isshow: 1, | |
| 3285 | + if (th.data.is_normal) { | |
| 3286 | + th.data.g_buy_num = new Map(); | |
| 3287 | + } | |
| 3288 | + | |
| 3289 | + //拼单商品从这里进,先判断有没有买过商品, | |
| 3290 | + getApp().request.get("/api/weshop/order/page", { | |
| 3291 | + data: { | |
| 3292 | + pt_prom_id: th.data.prom_act.id, | |
| 3293 | + user_id: oo.user_id, | |
| 3294 | + store_id: os.stoid, | |
| 3295 | + pageSize: 1, | |
| 3296 | + page: 1 | |
| 3297 | + }, | |
| 3298 | + success: function (e) { | |
| 3299 | + //--跳转到已经购买的情况-- | |
| 3300 | + if (e.data.data.pageData.length > 0) { | |
| 3301 | + var odr = e.data.data.pageData[0]; | |
| 3302 | + //还未支付 | |
| 3303 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | |
| 3304 | + wx.showModal({ | |
| 3305 | + title: "您已经购买了该商品待支付中", | |
| 3306 | + success: function (a) { | |
| 3307 | + if (a.confirm) { | |
| 3308 | + wx.navigateTo({ | |
| 3309 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | |
| 3310 | + }); | |
| 3311 | + } | |
| 3312 | + } | |
| 3349 | 3313 | }); |
| 3314 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | |
| 3350 | 3315 | |
| 3351 | - ee.get_sto(); | |
| 3316 | + if (this.data.is_go_to_team_show) return false; | |
| 3317 | + this.data.is_go_to_team_show = 1; | |
| 3318 | + wx.showLoading(); | |
| 3352 | 3319 | |
| 3353 | - var newTime = now; | |
| 3354 | - var endTime2 = t.data.data.end_time; | |
| 3355 | - var endTime1 = t.data.data.start_time; | |
| 3320 | + /*--- | |
| 3321 | + wx.redirectTo({ | |
| 3322 | + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | |
| 3323 | + });--*/ | |
| 3324 | + getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | |
| 3356 | 3325 | |
| 3357 | - if (endTime1 > newTime) { | |
| 3358 | - ee.setData({ | |
| 3359 | - prom_time_text: '距拼单开始还剩:' | |
| 3360 | - }) | |
| 3361 | - ee.countDown(endTime1, 0); | |
| 3362 | - } else { | |
| 3363 | - if (endTime2 > newTime) { | |
| 3364 | - ee.setData({ | |
| 3365 | - prom_time_text: '距拼单结束还剩:', | |
| 3366 | - prom_st: 1 | |
| 3367 | - }) | |
| 3368 | - ee.countDown(endTime2); | |
| 3369 | - } | |
| 3370 | - } | |
| 3371 | - //-------查看有多少人在开这个团------- | |
| 3372 | - th.get_team_group(prom_id); | |
| 3326 | + } else { | |
| 3327 | + th.setData({ | |
| 3328 | + is_normal: ind, | |
| 3329 | + openSpecModal_pt: 1 | |
| 3330 | + }); | |
| 3373 | 3331 | } |
| 3374 | - }); | |
| 3332 | + } | |
| 3333 | + else { | |
| 3334 | + th.setData({ | |
| 3335 | + is_normal: ind, | |
| 3336 | + openSpecModal_pt: 1 | |
| 3337 | + }); | |
| 3338 | + } | |
| 3375 | 3339 | } |
| 3376 | 3340 | }) |
| 3377 | - | |
| 3341 | + } | |
| 3378 | 3342 | }, |
| 3379 | - | |
| 3380 | - | |
| 3381 | - viewFlash(e) { | |
| 3382 | - let prom_type = e.currentTarget.dataset.promtype; | |
| 3383 | - let prom_id = e.currentTarget.dataset.promid; | |
| 3384 | - let goods_id = this.data.data.goods_id; | |
| 3385 | - let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`;s | |
| 3386 | - getApp().goto(url); | |
| 3387 | - }, | |
| 3388 | - | |
| 3389 | - | |
| 3390 | - | |
| 3391 | - //获取更多秒杀 | |
| 3392 | - get_more_flash: async function (func) { | |
| 3393 | - var f_more = false; | |
| 3394 | - var user_id = getApp().globalData.user_id; | |
| 3395 | - if (!user_id) user_id = 0; | |
| 3396 | - | |
| 3397 | - var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.options.goods_id + "&user_id=" + user_id; | |
| 3398 | - //获取秒杀的多规格 | |
| 3399 | - await getApp().request.promiseGet(url, {}).then(res => { | |
| 3400 | - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 3401 | - f_more = res.data.data; | |
| 3402 | - } | |
| 3403 | - }) | |
| 3404 | - if (!f_more) { | |
| 3405 | - func(false); | |
| 3406 | - return false; | |
| 3407 | - } | |
| 3408 | - //-- 秒杀的价格要更新 -- | |
| 3409 | - for (let i in f_more) { | |
| 3410 | - | |
| 3411 | - let item = f_more[i]; | |
| 3412 | - f_more[i].prom_id = item.act_id; | |
| 3413 | - f_more[i].prom_type = 1; | |
| 3414 | - if (item.goods_id == this.data.data.goods_id) { | |
| 3415 | - continue; | |
| 3416 | - } | |
| 3417 | - var url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + item.act_id; | |
| 3418 | - await getApp().request.promiseGet(url, {}).then(rs => { | |
| 3419 | - if (rs.data.code == 0) { | |
| 3420 | - f_more[i].price = rs.data.data.user_price; | |
| 3421 | - | |
| 3422 | - } | |
| 3423 | - }) | |
| 3424 | - } | |
| 3425 | - func(f_more); | |
| 3426 | - | |
| 3427 | - }, | |
| 3428 | - | |
| 3429 | - | |
| 3430 | - | |
| 3431 | - | |
| 3432 | - | |
| 3433 | - | |
| 3434 | - //-------------获取购买数量的总函数---------------- | |
| 3435 | - get_buy_num: function (gd, func) { | |
| 3436 | - // var map = this.data.g_buy_num, | |
| 3437 | - var th = this, | |
| 3438 | - user_id = getApp().globalData.user_id; | |
| 3439 | - if (user_id == null) { | |
| 3440 | - // map.set(gd.goods_id, 0); | |
| 3441 | - th.setData({ | |
| 3442 | - // g_buy_num: map, | |
| 3443 | - prom_buy_num: 0, | |
| 3444 | - }); | |
| 3445 | - "function" == typeof func && func(); | |
| 3446 | - return false; | |
| 3447 | - } | |
| 3448 | - | |
| 3449 | - // if (map.has(gd.goods_id)) { | |
| 3450 | - // "function" == typeof func && func(); | |
| 3451 | - // } else { | |
| 3452 | - //----获取商品购买数---- | |
| 3453 | - if (th.data.prom_type == 1) { | |
| 3454 | - //----获取活动购买数---- | |
| 3455 | - getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3456 | - data: { | |
| 3457 | - store_id: os.stoid, | |
| 3458 | - user_id: user_id, | |
| 3459 | - card_id: th.data.options.goods_id, | |
| 3460 | - prom_type: th.data.options.prom_type, | |
| 3461 | - prom_id: th.data.options.prom_id | |
| 3462 | - }, | |
| 3463 | - //-----获取----- | |
| 3464 | - success: function (tt) { | |
| 3465 | - if (tt.data.code == 0) { | |
| 3466 | - // map.set(gd.goods_id, g_buy_num); | |
| 3467 | - th.setData({ | |
| 3468 | - // g_buy_num: map, | |
| 3469 | - promcardbuynum: tt.data.data.promcardbuynum, | |
| 3470 | - cardbuynum: tt.data.data.cardbuynum, | |
| 3471 | - }); | |
| 3472 | - "function" == typeof func && func(); | |
| 3473 | - } | |
| 3474 | - } | |
| 3475 | - }); | |
| 3476 | - } else { | |
| 3477 | - "function" == typeof func && func(); | |
| 3478 | - }; | |
| 3479 | - | |
| 3480 | - }, | |
| 3481 | - | |
| 3482 | - | |
| 3483 | - get_buy_num2: async function () { | |
| 3484 | - // var map = this.data.g_buy_num, | |
| 3485 | - var th = this, | |
| 3486 | - user_id = getApp().globalData.user_id; | |
| 3487 | - // if (user_id == null) { | |
| 3488 | - // // map.set(gd.goods_id, 0); | |
| 3489 | - // th.setData({ | |
| 3490 | - // // g_buy_num: map, | |
| 3491 | - // prom_buy_num: 0, | |
| 3492 | - // }); | |
| 3493 | - // "function" == typeof func && func(); | |
| 3494 | - // return false; | |
| 3495 | - // } | |
| 3496 | - | |
| 3497 | - | |
| 3498 | - //----获取商品购买数---- | |
| 3499 | - | |
| 3500 | - //----获取活动购买数---- | |
| 3501 | - return await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3502 | - data: { | |
| 3503 | - store_id: os.stoid, | |
| 3504 | - user_id: user_id, | |
| 3505 | - card_id: th.data.options.goods_id, | |
| 3506 | - prom_type: th.data.options.prom_type, | |
| 3507 | - prom_id: th.data.options.prom_id | |
| 3508 | - }, | |
| 3509 | - //-----获取----- | |
| 3510 | - success: function (tt) { | |
| 3511 | - if (tt.data.code == 0) { | |
| 3512 | - // map.set(gd.goods_id, g_buy_num); | |
| 3513 | - th.setData({ | |
| 3514 | - // g_buy_num: map, | |
| 3515 | - promcardbuynum: tt.data.data.promcardbuynum, | |
| 3516 | - cardbuynum: tt.data.data.cardbuynum, | |
| 3517 | - }); | |
| 3518 | - } | |
| 3519 | - } | |
| 3520 | - }); | |
| 3521 | - | |
| 3522 | - | |
| 3523 | - }, | |
| 3524 | - | |
| 3525 | - | |
| 3526 | - | |
| 3527 | - | |
| 3528 | - | |
| 3529 | - // 促销 -> 送礼包 -> 查看详情 | |
| 3530 | - viewLbDetails(e) { | |
| 3531 | - let id = e.currentTarget.dataset.id; // 获取礼包id | |
| 3532 | - let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 | |
| 3533 | - // console.log('myurl', url); | |
| 3534 | - getApp().goto(url); | |
| 3535 | - }, | |
| 3536 | - | |
| 3537 | - go_more_ladder: function (e) { | |
| 3538 | - var prom_id = e.currentTarget.dataset.id; | |
| 3539 | - getApp().goto("/pages/goods/goodsList/goodsList?ladder_id=" + prom_id); | |
| 3540 | - }, | |
| 3541 | - | |
| 3542 | - getHistoryBuy() { | |
| 3543 | - let _this = this; | |
| 3544 | - let req_data = { | |
| 3545 | - store_id: os.stoid, | |
| 3546 | - goods_id: this.data.gid, | |
| 3547 | - pay_status: 1, | |
| 3548 | - rndid: 1 | |
| 3549 | - }; | |
| 3550 | - getApp().request.promiseGet('/api/weshop/ordergoods/list', { | |
| 3551 | - data: req_data, | |
| 3552 | - }) | |
| 3553 | - .then(res => { | |
| 3554 | - if (t.ajax_ok(res)) { | |
| 3555 | - _this.setData({ | |
| 3556 | - historyBuyInfo: res.data.data.pageData, | |
| 3557 | - }) | |
| 3558 | - } | |
| 3559 | - }) | |
| 3560 | - }, | |
| 3561 | - | |
| 3562 | - | |
| 3563 | - | |
| 3564 | - //-- 秒杀的普通购买 -- | |
| 3565 | - openSpecModel_Nor: function () { | |
| 3566 | - | |
| 3567 | - // 是否授权登陆 | |
| 3568 | - var user_info = getApp().globalData.userInfo; | |
| 3569 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 3570 | - wx.navigateTo({ | |
| 3571 | - url: '/packageE/pages/togoin/togoin', | |
| 3572 | - }) | |
| 3573 | - return false; | |
| 3574 | - } | |
| 3575 | - | |
| 3576 | - | |
| 3577 | - this.data.g_buy_num = new Map(); | |
| 3578 | - var th = this; | |
| 3579 | - this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 | |
| 3580 | - | |
| 3581 | - this.setData({openSpecModal_flash_normal: 1}); | |
| 3582 | - | |
| 3583 | - | |
| 3584 | - // if (th.data.sku_g_pt) { | |
| 3585 | - // // this.get_sto(1) | |
| 3586 | - // this.setData({openSpecModal_flash_normal: 1}); | |
| 3587 | - // } else { | |
| 3588 | - // th.get_sto(1); | |
| 3589 | - // th.get_sku(os.stoid, th.data.data, th.data.gid, 1, function () { | |
| 3590 | - // th.setData({ | |
| 3591 | - // openSpecModal_flash_normal: 1 | |
| 3592 | - // }); | |
| 3593 | - // }); | |
| 3594 | - // } | |
| 3595 | - // this.check_is_youhui(th.data.gid, 1); | |
| 3596 | - }, | |
| 3597 | - | |
| 3598 | - closeSpecModal_flash_normal: function () { | |
| 3599 | - this.setData({openSpecModal_flash_normal: 0}); | |
| 3600 | - }, | |
| 3601 | - | |
| 3602 | - | |
| 3603 | - //打开客服操作菜单 | |
| 3604 | - openCS() { | |
| 3605 | - // 判断会员状态 | |
| 3606 | - let user_info = getApp().globalData.userInfo; | |
| 3607 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) { | |
| 3608 | - wx.navigateTo({ | |
| 3609 | - url: '/packageE/pages/togoin/togoin', | |
| 3610 | - }) | |
| 3611 | - return false; | |
| 3612 | - }; | |
| 3613 | - // csType/在线客服设置: | |
| 3614 | - // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | |
| 3615 | - // 1小程序客服、 | |
| 3616 | - // 2企业微信客服 | |
| 3617 | - if(this.data.sys_switch) { | |
| 3618 | - let csType = this.data.sys_switch.weapp_customertype; | |
| 3619 | - if(csType == 0) { | |
| 3620 | - // 拨打电话号码 | |
| 3621 | - this.contactService(); | |
| 3622 | - } else { | |
| 3623 | - this.getTel() | |
| 3624 | - .then(() => { | |
| 3625 | - self.setData({ | |
| 3626 | - hiddenCS: false, | |
| 3627 | - }); | |
| 3628 | - }); | |
| 3629 | - }; | |
| 3630 | - }; | |
| 3631 | - | |
| 3632 | - }, | |
| 3633 | - | |
| 3634 | - //关闭客服操作菜单 | |
| 3635 | - closeCS() { | |
| 3636 | - this.setData({ | |
| 3637 | - hiddenCS: true, | |
| 3638 | - }); | |
| 3639 | - }, | |
| 3640 | - | |
| 3641 | - | |
| 3642 | - | |
| 3643 | - | |
| 3644 | - | |
| 3645 | - | |
| 3646 | - | |
| 3647 | - //-- 加入购物的函数 -- | |
| 3648 | - add_cart_func: function (t) { | |
| 3649 | - var i = getApp().request; | |
| 3650 | - if (oo.user_id == null) { | |
| 3651 | - return s.my_warnning("还未登录!", 0, this); | |
| 3652 | - } | |
| 3653 | - | |
| 3654 | - if (!getApp().globalData.userInfo) { | |
| 3655 | - return s.my_warnning("还未登录!", 0, this); | |
| 3656 | - } | |
| 3657 | - | |
| 3658 | - var e = this, | |
| 3659 | - th = e, | |
| 3660 | - a = 0, | |
| 3661 | - o = this.data.sele_g; | |
| 3662 | - a = o.goods_id; | |
| 3663 | - | |
| 3664 | - //----------添加到购物车时,要判断限购数量,-------- | |
| 3665 | - e.get_buy_num(o, function (ee) { | |
| 3666 | - //---判断商品是否超出限购--- | |
| 3667 | - if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
| 3668 | - if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { | |
| 3669 | - // wx.showModal({ | |
| 3670 | - // title: '提示', | |
| 3671 | - // content: '超出活动限购数量' | |
| 3672 | - // }); | |
| 3673 | - getApp().my_warnning('超出活动限购数量', 0, self); | |
| 3674 | - return false; | |
| 3675 | - } | |
| 3676 | - } | |
| 3677 | - //---判断商品是否超出活动限购--- | |
| 3678 | - if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { | |
| 3679 | - if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { | |
| 3680 | - // wx.showModal({ | |
| 3681 | - // title: '提示', | |
| 3682 | - // content: '超出活动限购数量' | |
| 3683 | - // }); | |
| 3684 | - getApp().my_warnning('超出活动限购数量', 0, self); | |
| 3685 | - return false; | |
| 3686 | - } | |
| 3687 | - } | |
| 3688 | - | |
| 3689 | - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); | |
| 3690 | - if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) | |
| 3691 | - this.setData({ | |
| 3692 | - sto_sele_name: "" | |
| 3693 | - }); | |
| 3694 | - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); | |
| 3695 | - | |
| 3696 | - //--------------此时操作的数据------------ | |
| 3697 | - var newd = { | |
| 3698 | - goods_id: o.goods_id, | |
| 3699 | - goods_num: th.data.goodsInputNum, | |
| 3700 | - pick_id: th.data.sto_sele_id, | |
| 3701 | - user_id: oo.user_id, | |
| 3702 | - store_id: th.data.stoid, | |
| 3703 | - goods_price: o.shop_price, | |
| 3704 | - member_goods_price: o.shop_price, | |
| 3705 | - goods_name: o.goods_name, | |
| 3706 | - goods_sn: o.goods_sn, | |
| 3707 | - sku: o.sku, | |
| 3708 | - prom_id: th.data.sele_g.prom_id, | |
| 3709 | - prom_type: th.data.sele_g.prom_type, | |
| 3710 | - }; | |
| 3711 | - | |
| 3712 | - //---是不是从收藏夹出来的--- | |
| 3713 | - if (th.data.c_guide_id) { | |
| 3714 | - newd['guide_id'] = th.data.c_guide_id; | |
| 3715 | - newd['guide_type'] = 2; | |
| 3716 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 3; | |
| 3717 | - } else { | |
| 3718 | - if (getApp().globalData.guide_id) { | |
| 3719 | - newd['guide_id'] = getApp().globalData.guide_id; | |
| 3720 | - newd['guide_type'] = 0; | |
| 3721 | - if ("add" == t.currentTarget.dataset.action) newd['guide_type'] = 1; | |
| 3722 | - } | |
| 3723 | - } | |
| 3724 | - | |
| 3725 | - //让商品带上房间号 | |
| 3726 | - //让商品带上房间号 | |
| 3727 | - if (th.data.sys_switch.is_skuroom_id == 1) { | |
| 3728 | - if (th.data.data.goods_id == getApp().globalData.room_goods_id) { | |
| 3729 | - newd.room_id = getApp().globalData.room_id; | |
| 3730 | - } | |
| 3731 | - } else { | |
| 3732 | - if (newd.goods_id == getApp().globalData.room_goods_id) newd.room_id = getApp().globalData.room_id; | |
| 3733 | - } | |
| 3734 | - | |
| 3735 | - //如果是积分够,is_integral_normal就要有积分购普通购买字段 | |
| 3736 | - if (o.prom_type == 4) { | |
| 3737 | - newd.is_integral_normal = 1; | |
| 3738 | - } | |
| 3739 | - | |
| 3740 | - //如果有线下取价 | |
| 3741 | - if (o.offline_price) { | |
| 3742 | - newd.offline_price = o.offline_price; | |
| 3743 | - newd.pricing_type = o.pricing_type; | |
| 3744 | - } | |
| 3745 | - | |
| 3746 | - //-----如果是秒杀,团购,积分购,拼团----- | |
| 3747 | - if (th.data.prom_type == 1 || th.data.prom_type == 2) { | |
| 3748 | - | |
| 3749 | - if (th.data.openSpecModal_flash_normal) { | |
| 3750 | - | |
| 3751 | - newd.prom_type = 0; | |
| 3752 | - newd.prom_id = 0; | |
| 3753 | - | |
| 3754 | - //---如果是线下门店销售的时候--- | |
| 3755 | - if (th.data.sales_rules == 2) { | |
| 3756 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | |
| 3757 | - //---通过接口获取门店的线下库存信息-- | |
| 3758 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 3759 | - data: { | |
| 3760 | - storageNos: pick.pickup_no, | |
| 3761 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | |
| 3762 | - storeId: os.stoid | |
| 3763 | - }, | |
| 3764 | - success: function (res) { | |
| 3765 | - if (res.data.code == 0) { | |
| 3766 | - if (res.data.data.pageData.length > 0) { | |
| 3767 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 3768 | - if (CanOutQty < e.data.goodsInputNum) { | |
| 3769 | - return s.my_warnning("库存不足!", 0, th); | |
| 3770 | - } | |
| 3771 | - //在调一次接口,读取商品的预出库的数量,lock | |
| 3772 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 3773 | - data: { | |
| 3774 | - store_id: os.stoid, | |
| 3775 | - wareId: th.data.sele_g.goods_id, | |
| 3776 | - storageId: pick.pickup_id, | |
| 3777 | - pageSize: 1000 | |
| 3778 | - }, | |
| 3779 | - success: function (res_data) { | |
| 3780 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 3781 | - | |
| 3782 | - var lock = 0; | |
| 3783 | - for (var i in res_data.data.data.pageData) { | |
| 3784 | - lock += res_data.data.data.pageData[i].outQty; | |
| 3785 | - } | |
| 3786 | - | |
| 3787 | - if (CanOutQty <= lock) { | |
| 3788 | - return s.my_warnning("库存不足!", 0, th); | |
| 3789 | - } | |
| 3790 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 3791 | - } else { | |
| 3792 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 3793 | - } | |
| 3794 | - } | |
| 3795 | - }) | |
| 3796 | - } else { | |
| 3797 | - return s.my_warnning("库存不足!", 0, th); | |
| 3798 | - } | |
| 3799 | - | |
| 3800 | - } | |
| 3801 | - } | |
| 3802 | - }) | |
| 3803 | - } else { | |
| 3804 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | |
| 3805 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | |
| 3806 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | |
| 3807 | - } | |
| 3808 | - | |
| 3809 | - return false; | |
| 3810 | - } | |
| 3811 | - | |
| 3812 | - | |
| 3813 | - newd.goods_price = th.data.prom_price; | |
| 3814 | - newd.member_goods_price = th.data.prom_price, | |
| 3815 | - newd.prom_type = th.data.prom_type; | |
| 3816 | - newd.prom_id = th.data.prom_id; | |
| 3817 | - | |
| 3818 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | |
| 3819 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | |
| 3820 | - | |
| 3821 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | |
| 3822 | - | |
| 3823 | - } else if (o.prom_type == 7) { | |
| 3824 | - | |
| 3825 | - //判断进行中的活动,是不是要判断线下库存 | |
| 3826 | - th.check_zh_acting(function (ee) { | |
| 3827 | - newd.prom_id = 0; | |
| 3828 | - newd.prom_type = 0; | |
| 3829 | - if (ee && th.data.sele_g.act) { | |
| 3830 | - newd.prom_id = th.data.sele_g.act.id; | |
| 3831 | - newd.prom_type = 7; | |
| 3832 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | |
| 3833 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | |
| 3834 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | |
| 3835 | - return false; | |
| 3836 | - } else { | |
| 3837 | - //---如果是线下门店销售的时候--- | |
| 3838 | - if (th.data.sales_rules == 2) { | |
| 3839 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | |
| 3840 | - //---通过接口获取门店的线下库存信息-- | |
| 3841 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 3842 | - data: { | |
| 3843 | - storageNos: pick.pickup_no, | |
| 3844 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | |
| 3845 | - storeId: os.stoid | |
| 3846 | - }, | |
| 3847 | - success: function (res) { | |
| 3848 | - if (res.data.code == 0) { | |
| 3849 | - if (res.data.data.pageData.length > 0) { | |
| 3850 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 3851 | - if (CanOutQty < e.data.goodsInputNum) { | |
| 3852 | - return s.my_warnning("库存不足!", 0, th); | |
| 3853 | - } | |
| 3854 | - //在调一次接口,读取商品的预出库的数量,lock | |
| 3855 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 3856 | - data: { | |
| 3857 | - store_id: os.stoid, | |
| 3858 | - wareId: th.data.sele_g.goods_id, | |
| 3859 | - storageId: pick.pickup_id, | |
| 3860 | - pageSize: 1000 | |
| 3861 | - }, | |
| 3862 | - success: function (res_data) { | |
| 3863 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 3864 | - | |
| 3865 | - var lock = 0; | |
| 3866 | - for (var i in res_data.data.data.pageData) { | |
| 3867 | - lock += res_data.data.data.pageData[i].outQty; | |
| 3868 | - } | |
| 3869 | - | |
| 3870 | - if (CanOutQty <= lock) { | |
| 3871 | - return s.my_warnning("库存不足!", 0, th); | |
| 3872 | - } | |
| 3873 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 3874 | - } else { | |
| 3875 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 3876 | - } | |
| 3877 | - } | |
| 3878 | - }) | |
| 3879 | - } else { | |
| 3880 | - return s.my_warnning("库存不足!", 0, th); | |
| 3881 | - } | |
| 3882 | - | |
| 3883 | - } | |
| 3884 | - } | |
| 3885 | - }) | |
| 3886 | - } else { | |
| 3887 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | |
| 3888 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | |
| 3889 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | |
| 3890 | - } | |
| 3891 | - } | |
| 3892 | - }) | |
| 3893 | - | |
| 3894 | - } | |
| 3895 | - 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) { | |
| 3896 | - newd.prom_type = 0; | |
| 3897 | - newd.prom_id = 0; | |
| 3898 | - | |
| 3899 | - if (th.data.prom_type == 10) { | |
| 3900 | - newd.prom_type = th.data.prom_type; | |
| 3901 | - newd.prom_id = th.data.prom_id; | |
| 3902 | - } | |
| 3903 | - | |
| 3904 | - //---如果是线下门店销售的时候--- | |
| 3905 | - if (th.data.sales_rules == 2) { | |
| 3906 | - var pick = th.get_pick_from_list(th.data.sto_sele_id) | |
| 3907 | - //---通过接口获取门店的线下库存信息-- | |
| 3908 | - getApp().request.get("/api/weshop/goods/getWareStorages", { | |
| 3909 | - data: { | |
| 3910 | - storageNos: pick.pickup_no, | |
| 3911 | - wareIds: encodeURIComponent(th.data.sele_g.erpwareid), | |
| 3912 | - storeId: os.stoid | |
| 3913 | - }, | |
| 3914 | - success: function (res) { | |
| 3915 | - if (res.data.code == 0) { | |
| 3916 | - if (res.data.data.pageData.length > 0) { | |
| 3917 | - var CanOutQty = res.data.data.pageData[0].CanOutQty; | |
| 3918 | - if (CanOutQty < e.data.goodsInputNum) { | |
| 3919 | - return s.my_warnning("库存不足!", 0, th); | |
| 3920 | - } | |
| 3921 | - //在调一次接口,读取商品的预出库的数量,lock | |
| 3922 | - getApp().request.get("/api/weshop/order/ware/lock/page", { | |
| 3923 | - data: { | |
| 3924 | - store_id: os.stoid, | |
| 3925 | - wareId: th.data.sele_g.goods_id, | |
| 3926 | - storageId: pick.pickup_id, | |
| 3927 | - pageSize: 1000 | |
| 3928 | - }, | |
| 3929 | - success: function (res_data) { | |
| 3930 | - if (res_data.data.code == 0 && res_data.data.data.total > 0) { | |
| 3931 | - | |
| 3932 | - var lock = 0; | |
| 3933 | - for (var i in res_data.data.data.pageData) { | |
| 3934 | - lock += res_data.data.data.pageData[i].outQty; | |
| 3935 | - } | |
| 3936 | - | |
| 3937 | - if (CanOutQty <= lock) { | |
| 3938 | - return s.my_warnning("库存不足!", 0, th); | |
| 3939 | - } | |
| 3940 | - th.add_cart_next(e, t, a, o, newd, CanOutQty - lock); | |
| 3941 | - } else { | |
| 3942 | - th.add_cart_next(e, t, a, o, newd, CanOutQty); | |
| 3943 | - } | |
| 3944 | - } | |
| 3945 | - }) | |
| 3946 | - } else { | |
| 3947 | - return s.my_warnning("库存不足!", 0, th); | |
| 3948 | - } | |
| 3949 | - | |
| 3950 | - } | |
| 3951 | - } | |
| 3952 | - }) | |
| 3953 | - } else { | |
| 3954 | - if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); | |
| 3955 | - if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); | |
| 3956 | - th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 | |
| 3957 | - } | |
| 3958 | - } | |
| 3959 | - }) | |
| 3960 | - }, | |
| 3961 | - | |
| 3962 | - //---加入购物车的最后一步--- | |
| 3963 | - add_cart_next(e, t, a, o, newd, CanOutQty) { | |
| 3964 | - var th = this, i = getApp().request; | |
| 3965 | - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ | |
| 3966 | - 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)) { | |
| 3967 | - var conf = th.data.bconfig; | |
| 3968 | - if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { | |
| 3969 | - var s_list = JSON.parse(conf.switch_list); | |
| 3970 | - var now = ut.gettimestamp(); | |
| 3971 | - | |
| 3972 | - | |
| 3973 | - var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); | |
| 3974 | - var end = new Date(str); | |
| 3975 | - end = Date.parse(end) / 1000; | |
| 3976 | - | |
| 3977 | - //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- | |
| 3978 | - if (parseInt(s_list.rank_switch) == 2 && end > now) { | |
| 3979 | - var card_price = o[getApp().globalData.userInfo['card_field']]; | |
| 3980 | - //如果会员有等级价 | |
| 3981 | - if (getApp().globalData.userInfo['card_field'] != undefined && getApp().globalData.userInfo['card_field'] != null | |
| 3982 | - && getApp().globalData.userInfo['card_field'] != "" && card_price > 0) { | |
| 3983 | - newd.goods_price = card_price; | |
| 3984 | - newd.member_goods_price = card_price; | |
| 3985 | - } | |
| 3986 | - } | |
| 3987 | - } | |
| 3988 | - } | |
| 3989 | - | |
| 3990 | - if ("add" == t.currentTarget.dataset.action) { | |
| 3991 | - | |
| 3992 | - if (th.data.prom_goods) { | |
| 3993 | - newd.prom_type = 3; | |
| 3994 | - newd.prom_id = th.data.prom_goods[0].prom_id; | |
| 3995 | - } | |
| 3996 | - | |
| 3997 | - //----先看会员在购物车中是否加入了该商品----- | |
| 3998 | - i.get("/api/weshop/cart/page", { | |
| 3999 | - data: { | |
| 4000 | - store_id: e.data.stoid, | |
| 4001 | - user_id: oo.user_id, | |
| 4002 | - goods_id: a, | |
| 4003 | - pick_id: e.data.sto_sele_id, | |
| 4004 | - state: 0 | |
| 4005 | - }, | |
| 4006 | - success: function (re) { | |
| 4007 | - | |
| 4008 | - //-------如果购物车中有相关的数据--------- | |
| 4009 | - if (re.data.data.total > 0) { | |
| 4010 | - | |
| 4011 | - var item = re.data.data.pageData[0]; | |
| 4012 | - | |
| 4013 | - //判断数量,要看下购物车中有没有该商品 | |
| 4014 | - if (CanOutQty) { | |
| 4015 | - if (item.goods_num + th.data.goodsInputNum > CanOutQty) { | |
| 4016 | - return s.my_warnning("库存不足!", 0, th); | |
| 4017 | - } | |
| 4018 | - } else { | |
| 4019 | - if (item.goods_num + th.data.goodsInputNum > o.store_count) { | |
| 4020 | - return s.my_warnning("库存不足!", 0, th); | |
| 4021 | - } | |
| 4022 | - } | |
| 4023 | - | |
| 4024 | - var updata = { | |
| 4025 | - id: item.id, | |
| 4026 | - goods_num: e.data.goodsInputNum + item.goods_num, | |
| 4027 | - goods_price: newd.goods_price, | |
| 4028 | - member_goods_price: newd.goods_price, | |
| 4029 | - store_id: th.data.stoid, | |
| 4030 | - }; | |
| 4031 | - | |
| 4032 | - //---是不是从收藏夹出来的--- | |
| 4033 | - if (th.data.c_guide_id) { | |
| 4034 | - updata['guide_id'] = th.data.c_guide_id; | |
| 4035 | - updata['guide_type'] = 3; //加入购物车之后就变成了3 | |
| 4036 | - } else { | |
| 4037 | - if (getApp().globalData.guide_id) { | |
| 4038 | - updata['guide_id'] = getApp().globalData.guide_id; | |
| 4039 | - updata['guide_type'] = 0; | |
| 4040 | - } | |
| 4041 | - } | |
| 4042 | - | |
| 4043 | - i.put("/api/weshop/cart/update", { | |
| 4044 | - data: updata, | |
| 4045 | - success: function (t) { | |
| 4046 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 4047 | - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; | |
| 4048 | - th.setData({ | |
| 4049 | - cartGoodsNum: c_num | |
| 4050 | - }); | |
| 4051 | - th.closeSpecModal(); | |
| 4052 | - } | |
| 4053 | - }); | |
| 4054 | - } else { | |
| 4055 | - | |
| 4056 | - | |
| 4057 | - i.post("/api/weshop/cart/save", { | |
| 4058 | - data: newd, | |
| 4059 | - success: function (t) { | |
| 4060 | - getApp().my_warnning('加入购物车成功', 1, th, 450); | |
| 4061 | - var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; | |
| 4062 | - th.setData({ | |
| 4063 | - cartGoodsNum: c_num | |
| 4064 | - }); | |
| 4065 | - th.closeSpecModal(); | |
| 4066 | - } | |
| 4067 | - }); | |
| 4068 | - } | |
| 4069 | - } | |
| 4070 | - }); | |
| 4071 | - | |
| 4072 | - } | |
| 4073 | - else { | |
| 4074 | - | |
| 4075 | - //这一步主要是要让立即购买 走 购物车的逻辑 参与活动 | |
| 4076 | - if (newd.prom_type == 10 || newd.prom_type == 7) { | |
| 4077 | - //----先看会员在购物车中是否加入了该商品,立即购买的----- | |
| 4078 | - getApp().request.get("/api/weshop/cart/page", { | |
| 4079 | - data: { | |
| 4080 | - store_id: e.data.stoid, | |
| 4081 | - user_id: oo.user_id, | |
| 4082 | - state: 1 | |
| 4083 | - }, | |
| 4084 | - success: function (res) { | |
| 4085 | - //-------如果购物车中有相关的数据--------- | |
| 4086 | - if (res.data.code == 0 && res.data.data.total > 0) { | |
| 4087 | - for (let j in res.data.data.pageData) { | |
| 4088 | - let item_j = res.data.data.pageData[j]; | |
| 4089 | - var url = '/api/weshop/cart/del/' + e.data.stoid + '/' + item_j.id; | |
| 4090 | - getApp().request.delete(url, {}); | |
| 4091 | - } | |
| 4092 | - } | |
| 4093 | - newd.state = 1; | |
| 4094 | - getApp().request.post("/api/weshop/cart/save", { | |
| 4095 | - data: newd, | |
| 4096 | - success: function (t) { | |
| 4097 | - th.closeSpecModal(); | |
| 4098 | - getApp().goto("/packageE/pages/cart/cart2/cart2?state=1"); | |
| 4099 | - } | |
| 4100 | - }); | |
| 4101 | - }, | |
| 4102 | - }) | |
| 4103 | - return false; | |
| 4104 | - } | |
| 4105 | - | |
| 4106 | - if (th.data.prom_goods) { | |
| 4107 | - var prom_d = th.data.prom_goods; | |
| 4108 | - for (var i in prom_d) { | |
| 4109 | - //判断活动有俩种条件,0元 1件 | |
| 4110 | - var condition_t = prom_d[i].prom_type; | |
| 4111 | - switch (condition_t) { | |
| 4112 | - case 0: //按钱 | |
| 4113 | - if (newd.goods_price >= condition_t) { | |
| 4114 | - newd.prom_type = 3; | |
| 4115 | - newd.prom_id = prom_d[i].prom_id; | |
| 4116 | - } | |
| 4117 | - break | |
| 4118 | - case 1://按购买数量 | |
| 4119 | - if (newd.goods_num >= condition_t) { | |
| 4120 | - newd.prom_type = 3; | |
| 4121 | - newd.prom_id = prom_d[i].prom_id; | |
| 4122 | - } | |
| 4123 | - break; | |
| 4124 | - } | |
| 4125 | - } | |
| 4126 | - | |
| 4127 | - } | |
| 4128 | - | |
| 4129 | - newd['pick_name'] = th.data.sto_sele_name; | |
| 4130 | - newd['pick_dis'] = th.data.sto_sele_distr; | |
| 4131 | - th.buyNow(newd); | |
| 4132 | - } | |
| 4133 | - }, | |
| 4134 | - | |
| 4135 | - click_contact:function () { | |
| 4136 | - getApp().globalData.no_clear=1; | |
| 4137 | - }, | |
| 4138 | - | |
| 4139 | - //打开客服操作菜单 | |
| 4140 | - openCS() { | |
| 4141 | - // csType/在线客服设置: | |
| 4142 | - // 0关闭(如果有设置热线电话,则显示拨打热线电话)、 | |
| 4143 | - // 1小程序客服、 | |
| 4144 | - // 2企业微信客服 | |
| 4145 | - let csType = this.data.sys_switch.weapp_customertype; | |
| 4146 | - if(csType == 0) { | |
| 4147 | - // 获取电话号码 | |
| 4148 | - this.contactService(); | |
| 4149 | - } else { | |
| 4150 | - this.getTel() | |
| 4151 | - .then(() => { | |
| 4152 | - self.setData({ | |
| 4153 | - hiddenCS: false, | |
| 4154 | - }); | |
| 4155 | - }); | |
| 4156 | - | |
| 4157 | - }; | |
| 4158 | - }, | |
| 4159 | - | |
| 4160 | - //关闭客服操作菜单 | |
| 4161 | - closeCS() { | |
| 4162 | - this.setData({ | |
| 4163 | - hiddenCS: true, | |
| 4164 | - }); | |
| 4165 | - }, | |
| 4166 | - | |
| 4167 | - //--点击弹起拼单-- | |
| 4168 | - openSpecModel_pt: function (e) { | |
| 4169 | - | |
| 4170 | - | |
| 4171 | - this.setData({open_ind_store: 4, goodsInputNum: 1});//拼团直接给4 | |
| 4172 | - | |
| 4173 | - | |
| 4174 | - //--先判断会员状态-- | |
| 4175 | - var user_info = getApp().globalData.userInfo; | |
| 4176 | - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { | |
| 4177 | - wx.navigateTo({ | |
| 4178 | - url: '/packageE/pages/togoin/togoin', | |
| 4179 | - }) | |
| 4180 | - return false; | |
| 4181 | - } | |
| 4182 | - | |
| 4183 | - var th = this; | |
| 4184 | - var ind = parseInt(e.currentTarget.dataset.it); | |
| 4185 | - | |
| 4186 | - //如果是拼单活动的普通购买 | |
| 4187 | - if (ind == 1) { | |
| 4188 | - | |
| 4189 | - if (!th.data.is_normal) { | |
| 4190 | - th.data.g_buy_num = new Map(); | |
| 4191 | - } | |
| 4192 | - | |
| 4193 | - //如果拼单的sku data是空的,就要先获取一下 | |
| 4194 | - if (th.data.sku_g_pt) { | |
| 4195 | - th.get_sto(1); | |
| 4196 | - th.setData({ | |
| 4197 | - is_normal: ind, | |
| 4198 | - openSpecModal_pt: 1 | |
| 4199 | - }); | |
| 4200 | - } else { | |
| 4201 | - th.get_sto(1); | |
| 4202 | - th.get_sku(os.stoid, th.data.data, th.data.gid, 1, function () { | |
| 4203 | - th.setData({ | |
| 4204 | - is_normal: ind, | |
| 4205 | - openSpecModal_pt: 1 | |
| 4206 | - }); | |
| 4207 | - }); | |
| 4208 | - } | |
| 4209 | - th.check_is_youhui(th.data.gid, 1); | |
| 4210 | - } else { | |
| 4211 | - | |
| 4212 | - if (th.data.is_normal) { | |
| 4213 | - th.data.g_buy_num = new Map(); | |
| 4214 | - } | |
| 4215 | - | |
| 4216 | - //拼单商品从这里进,先判断有没有买过商品, | |
| 4217 | - getApp().request.get("/api/weshop/order/page", { | |
| 4218 | - data: { | |
| 4219 | - pt_prom_id: th.data.prom_act.id, | |
| 4220 | - user_id: oo.user_id, | |
| 4221 | - store_id: os.stoid, | |
| 4222 | - pageSize: 1, | |
| 4223 | - page: 1 | |
| 4224 | - }, | |
| 4225 | - success: function (e) { | |
| 4226 | - //--跳转到已经购买的情况-- | |
| 4227 | - if (e.data.data.pageData.length > 0) { | |
| 4228 | - var odr = e.data.data.pageData[0]; | |
| 4229 | - //还未支付 | |
| 4230 | - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | |
| 4231 | - wx.showModal({ | |
| 4232 | - title: "您已经购买了该商品待支付中", | |
| 4233 | - success: function (a) { | |
| 4234 | - if (a.confirm) { | |
| 4235 | - wx.navigateTo({ | |
| 4236 | - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | |
| 4237 | - }); | |
| 4238 | - } | |
| 4239 | - } | |
| 4240 | - }); | |
| 4241 | - } else if (odr.pt_status == 1 && odr.order_status == 1) { | |
| 4242 | - | |
| 4243 | - if (this.data.is_go_to_team_show) return false; | |
| 4244 | - this.data.is_go_to_team_show = 1; | |
| 4245 | - wx.showLoading(); | |
| 4246 | - | |
| 4247 | - /*--- | |
| 4248 | - wx.redirectTo({ | |
| 4249 | - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, | |
| 4250 | - });--*/ | |
| 4251 | - getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn); | |
| 4252 | - | |
| 4253 | - } else { | |
| 4254 | - th.setData({ | |
| 4255 | - is_normal: ind, | |
| 4256 | - openSpecModal_pt: 1 | |
| 4257 | - }); | |
| 4258 | - } | |
| 4259 | - } | |
| 4260 | - else { | |
| 4261 | - th.setData({ | |
| 4262 | - is_normal: ind, | |
| 4263 | - openSpecModal_pt: 1 | |
| 4264 | - }); | |
| 4265 | - } | |
| 4266 | - } | |
| 4267 | - }) | |
| 4268 | - } | |
| 4269 | - }, | |
| 4270 | 3343 | |
| 4271 | 3344 | //--获取有多少人在开团-- |
| 4272 | 3345 | async get_team_group(prom_id) { |
| ... | ... | @@ -4296,18 +3369,31 @@ Page({ |
| 4296 | 3369 | teamgroup = res.data.data.pageData; |
| 4297 | 3370 | grounp_tatal = res.data.data.total; |
| 4298 | 3371 | }) |
| 3372 | + | |
| 4299 | 3373 | //获取订单的总数这个接口不能用 |
| 4300 | - for (i = 0; i < teamgroup.length; i++) { | |
| 4301 | - await getApp().request.promiseGet("/api/weshop/order/page", { | |
| 4302 | - data: { | |
| 4303 | - store_id: os.stoid, | |
| 4304 | - pt_status: 1, | |
| 4305 | - pt_listno: teamgroup[i].listno | |
| 4306 | - } | |
| 4307 | - }).then(res => { | |
| 4308 | - var order = res.data.data.pageData; | |
| 4309 | - teamgroup[i].open_num = order.length; | |
| 4310 | - }) | |
| 3374 | + for (var i = 0; i < teamgroup.length; i++) { | |
| 3375 | + | |
| 3376 | + if(teamgroup[i].goods_type==0){ | |
| 3377 | + await getApp().request.promiseGet("/api/weshop/order/page", { | |
| 3378 | + data: { | |
| 3379 | + store_id: os.stoid, | |
| 3380 | + pt_status: 1, | |
| 3381 | + pt_listno: teamgroup[i].listno | |
| 3382 | + } | |
| 3383 | + }).then(res => { | |
| 3384 | + var order = res.data.data.pageData; | |
| 3385 | + teamgroup[i].open_num = order.length; | |
| 3386 | + }) | |
| 3387 | + }else{ | |
| 3388 | + //获取order信息根据订单编号order_sn | |
| 3389 | + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/page", { | |
| 3390 | + data: { store_id: os.stoid, prom_id: prom_id,pt_status: 1} | |
| 3391 | + }).then(res => { | |
| 3392 | + var order = res.data.data.pageData; | |
| 3393 | + teamgroup[i].open_num = order.length; | |
| 3394 | + }) | |
| 3395 | + } | |
| 3396 | + | |
| 4311 | 3397 | await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { |
| 4312 | 3398 | var user = res.data.data; |
| 4313 | 3399 | teamgroup[i].user = user; |
| ... | ... | @@ -4324,6 +3410,370 @@ Page({ |
| 4324 | 3410 | } |
| 4325 | 3411 | }, |
| 4326 | 3412 | |
| 3413 | + doScrollTop: function () { | |
| 3414 | + wx.pageScrollTo({ | |
| 3415 | + scrollTop: 0 | |
| 3416 | + }); | |
| 3417 | + }, | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + clickShare() { | |
| 3421 | + if(!getApp().globalData.user_id){ | |
| 3422 | + getApp().goto("/packageE/pages/togoin/togoin"); | |
| 3423 | + return false; | |
| 3424 | + } | |
| 3425 | + this.setData({ | |
| 3426 | + share_hidden: true, | |
| 3427 | + }); | |
| 3428 | + }, | |
| 3429 | + | |
| 3430 | + cancel() { | |
| 3431 | + this.setData({ | |
| 3432 | + share_hidden: false, | |
| 3433 | + }); | |
| 3434 | + }, | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + //-- 先版绘制 -- | |
| 3438 | + drawPoster(context, unit, img, vpath, type) { | |
| 3439 | + // 1.灰色背景 | |
| 3440 | + context.setFillStyle('#f2f1f6'); | |
| 3441 | + context.rect(0, 0, 554 * unit, 899 * unit); | |
| 3442 | + context.fill(); | |
| 3443 | + | |
| 3444 | + // 2.商城名称 | |
| 3445 | + let shopName = this.data.sto_sele_name_1; | |
| 3446 | + context.setTextAlign('center'); | |
| 3447 | + context.setFontSize(26 * unit); | |
| 3448 | + context.setFillStyle('black'); | |
| 3449 | + context.fillText(shopName, 277 * unit, 60 * unit); | |
| 3450 | + | |
| 3451 | + // 3.推荐来源 | |
| 3452 | + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`; | |
| 3453 | + context.setTextAlign('center'); | |
| 3454 | + context.setFontSize(22 * unit); | |
| 3455 | + context.setFillStyle('#96959a'); | |
| 3456 | + context.fillText(fromText, 277 * unit, 105 * unit); | |
| 3457 | + | |
| 3458 | + // 4.海报背景 | |
| 3459 | + context.setFillStyle('white'); | |
| 3460 | + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit); | |
| 3461 | + | |
| 3462 | + // 5.商品图片 | |
| 3463 | + // 图片的x坐标 | |
| 3464 | + let bg_x = 37 * unit | |
| 3465 | + // 图片的y坐标 | |
| 3466 | + let bg_y = 157 * unit | |
| 3467 | + // 图片宽度 | |
| 3468 | + let bg_w = 480 * unit | |
| 3469 | + // 图片高度 | |
| 3470 | + let bg_h = 474 * unit | |
| 3471 | + // 图片圆角 | |
| 3472 | + let bg_r = 4 | |
| 3473 | + // 绘制海报背景图片圆角 | |
| 3474 | + context.save() | |
| 3475 | + context.beginPath() | |
| 3476 | + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5) | |
| 3477 | + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2) | |
| 3478 | + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5) | |
| 3479 | + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI) | |
| 3480 | + context.clip() | |
| 3481 | + context.drawImage(img, bg_x, bg_y, bg_w, bg_h); | |
| 3482 | + context.restore(); | |
| 3483 | + | |
| 3484 | + // 6.强烈推荐 | |
| 3485 | + let src = ''; | |
| 3486 | + context.beginPath(); | |
| 3487 | + if (type == 0) { // 普通 | |
| 3488 | + src = '../../../../images/share/q_tj.png'; | |
| 3489 | + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit); | |
| 3490 | + context.setFontSize(16 * unit) | |
| 3491 | + context.setFillStyle("white") | |
| 3492 | + context.setTextAlign('left'); | |
| 3493 | + context.fillText('强烈推荐', 64 * unit, 668 * unit); | |
| 3494 | + } | |
| 3495 | + | |
| 3496 | + if (type == 1) { // 秒杀 | |
| 3497 | + | |
| 3498 | + if(this.data.is_share_text==1){ | |
| 3499 | + src = '../../../../images/share/miao_share.png'; | |
| 3500 | + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit); | |
| 3501 | + } | |
| 3502 | + context.setTextAlign('left'); | |
| 3503 | + } | |
| 3504 | + | |
| 3505 | + if (type == 2) { // 商家和会员团 | |
| 3506 | + src = '../../../../images/share/ct_num.png'; | |
| 3507 | + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit); | |
| 3508 | + context.setTextAlign('left'); | |
| 3509 | + | |
| 3510 | + let ct_num = self.data.prom_act.ct_num; | |
| 3511 | + context.setFontSize(16 * unit) | |
| 3512 | + context.font = 'normal'; | |
| 3513 | + context.setFillStyle("red") | |
| 3514 | + if (ct_num < 10) { | |
| 3515 | + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit); | |
| 3516 | + } else { | |
| 3517 | + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit); | |
| 3518 | + } | |
| 3519 | + context.setFontSize(22 * unit) | |
| 3520 | + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit); | |
| 3521 | + } | |
| 3522 | + | |
| 3523 | + if (type == 3) { // 阶梯团 | |
| 3524 | + let list = self.data.prom_act.ct_rylist; | |
| 3525 | + for (let i = 0; i < list.length; i++) { | |
| 3526 | + let item = list[i]; | |
| 3527 | + let wi = i * 90 * unit; | |
| 3528 | + context.font = 'normal'; | |
| 3529 | + context.setTextAlign('left'); | |
| 3530 | + context.setFontSize(16 * unit) | |
| 3531 | + context.setFillStyle("red") | |
| 3532 | + context.fillText("¥", 50 * unit + wi, 680 * unit); | |
| 3533 | + context.setFontSize(22 * unit) | |
| 3534 | + let pri = parseFloat(item.price).toFixed(2); | |
| 3535 | + context.fillText(pri, 66 * unit + wi, 680 * unit); | |
| 3536 | + | |
| 3537 | + | |
| 3538 | + context.setFillStyle("gray") | |
| 3539 | + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit); | |
| 3540 | + } | |
| 3541 | + | |
| 3542 | + | |
| 3543 | + var wp= 52 * unit; | |
| 3544 | + var hp=755 * unit | |
| 3545 | + self.draw_pos_price(context,wp,hp,self.data.data.market_price,unit); | |
| 3546 | + } | |
| 3547 | + | |
| 3548 | + | |
| 3549 | + // 7.商品价格 | |
| 3550 | + if (type != 3) { | |
| 3551 | + let price = this.data.data.money; | |
| 3552 | + if (this.data.card_field && this.data.data[this.data.card_field]) { | |
| 3553 | + price = this.data.data[this.data.card_field]; | |
| 3554 | + } | |
| 3555 | + if (this.data.prom_act) price = this.data.prom_price; | |
| 3556 | + price = parseFloat(price).toFixed(2); | |
| 3557 | + context.setFontSize(32 * unit); | |
| 3558 | + context.setFillStyle('#DE1117'); | |
| 3559 | + if (this.data.prom_type == 4 && this.data.prom_integral) { | |
| 3560 | + context.fillText(this.data.prom_integral + '积分+¥' + price, 54 * unit, 735 * unit); | |
| 3561 | + | |
| 3562 | + var wp= 62 * unit+ut.measureText(this.data.prom_integral + '积分+¥' + price, 32 * unit); | |
| 3563 | + var hp=735 * unit | |
| 3564 | + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); | |
| 3565 | + | |
| 3566 | + } else { | |
| 3567 | + context.fillText('¥' + price, 54 * unit, 735 * unit); | |
| 3568 | + var wp= 62 * unit+ut.measureText('¥' + price, 32 * unit); | |
| 3569 | + var hp=735 * unit | |
| 3570 | + this.draw_pos_price(context,wp,hp,this.data.data.market_price,unit); | |
| 3571 | + | |
| 3572 | + } | |
| 3573 | + | |
| 3574 | + } | |
| 3575 | + | |
| 3576 | + // 8.商品标题 | |
| 3577 | + context.setFontSize(20 * unit); | |
| 3578 | + context.setFillStyle('#898989'); | |
| 3579 | + getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1); | |
| 3580 | + // 9.小程序码 | |
| 3581 | + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit); | |
| 3582 | + context.setFontSize(16 * unit); | |
| 3583 | + context.setFillStyle('#777'); | |
| 3584 | + context.fillText('长按识别二维码', 378 * unit, 810 * unit); | |
| 3585 | + | |
| 3586 | + // 10.竖线 | |
| 3587 | + context.beginPath(); | |
| 3588 | + context.setFillStyle('#eee'); | |
| 3589 | + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit); | |
| 3590 | + context.fill(); | |
| 3591 | + }, | |
| 3592 | + | |
| 3593 | + //---市场价划掉--- | |
| 3594 | + draw_pos_price(context,w,h,market_price,unit){ | |
| 3595 | + | |
| 3596 | + if(!this.data.sys_switch) return false; | |
| 3597 | + if(!this.data.sys_switch.is_retail_price) return false; | |
| 3598 | + context.setFillStyle("gray") | |
| 3599 | + context.setFontSize(22 * unit) | |
| 3600 | + var pri0 = "¥" + market_price.toFixed(2); | |
| 3601 | + context.fillText(pri0, w, h); | |
| 3602 | + | |
| 3603 | + var c_h=h-6; | |
| 3604 | + context.setStrokeStyle('gray'); | |
| 3605 | + context.setLineWidth(1 * unit); | |
| 3606 | + context.moveTo(w - 5, c_h); | |
| 3607 | + context.lineTo(w + ut.measureText(pri0, 22 * unit) + 5, c_h); | |
| 3608 | + context.stroke(); | |
| 3609 | + | |
| 3610 | + }, | |
| 3611 | + | |
| 3612 | + | |
| 3613 | + //-------跳转pt teamshow------- | |
| 3614 | + go_to_team_show: function () { | |
| 3615 | + | |
| 3616 | + if (this.data.is_go_to_team_show) return false; | |
| 3617 | + this.data.is_go_to_team_show = 1; | |
| 3618 | + wx.showLoading(); | |
| 3619 | + | |
| 3620 | + var th = this; | |
| 3621 | + var url = "/packageA/pages/serviceCard_pd/team_success/team_success?ordersn=" + th.data.buy_order.order_sn; | |
| 3622 | + /*-- | |
| 3623 | + wx.redirectTo({ | |
| 3624 | + url:url, | |
| 3625 | + })--*/ | |
| 3626 | + getApp().goto(url); | |
| 3627 | + | |
| 3628 | + setTimeout(()=>{ | |
| 3629 | + this.data.is_go_to_team_show =0; | |
| 3630 | + },1000) | |
| 3631 | + | |
| 3632 | + }, | |
| 3633 | + | |
| 3634 | + | |
| 3635 | + //---拼团倒计时--- | |
| 3636 | + countDown2() { | |
| 3637 | + if (!this.data.is_timer) return false; | |
| 3638 | + var th = this; | |
| 3639 | + // 获取当前时间,同时得到活动结束时间数组 | |
| 3640 | + var newTime = ut.gettimestamp(); | |
| 3641 | + var List = th.data.teamgroup; | |
| 3642 | + for (var j = 0; j < List.length; j++) { | |
| 3643 | + // 对结束时间进行处理渲染到页面 | |
| 3644 | + var endTime = List[j].kt_end_time; | |
| 3645 | + let obj = null; | |
| 3646 | + // 如果活动未结束,对时间进行处理 | |
| 3647 | + if (endTime - newTime > 0) { | |
| 3648 | + let time = (endTime - newTime); | |
| 3649 | + // 获取天、时、分、秒 | |
| 3650 | + let day = parseInt(time / (60 * 60 * 24)); | |
| 3651 | + let hou = parseInt(time % (60 * 60 * 24) / 3600); | |
| 3652 | + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); | |
| 3653 | + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); | |
| 3654 | + obj = { | |
| 3655 | + day: this.timeFormat(day), | |
| 3656 | + hou: this.timeFormat(hou), | |
| 3657 | + min: this.timeFormat(min), | |
| 3658 | + sec: this.timeFormat(sec) | |
| 3659 | + } | |
| 3660 | + } else { | |
| 3661 | + //活动已结束,全部设置为'00' | |
| 3662 | + obj = { | |
| 3663 | + day: '00', | |
| 3664 | + hou: '00', | |
| 3665 | + min: '00', | |
| 3666 | + sec: '00' | |
| 3667 | + } | |
| 3668 | + } | |
| 3669 | + var txt = "timer[" + j + "]"; | |
| 3670 | + th.setData({ | |
| 3671 | + [txt]: obj | |
| 3672 | + }); | |
| 3673 | + } | |
| 3674 | + setTimeout(th.countDown2, 1000); | |
| 3675 | + }, | |
| 3676 | + //-- 跳转参加团 -- | |
| 3677 | + go_cj_team: function (e) { | |
| 3678 | + var ind = e.currentTarget.dataset.ind; | |
| 3679 | + var item = this.data.teamgroup[ind]; | |
| 3680 | + var goods_id = e.currentTarget.dataset.goodsid; | |
| 3681 | + var id = item.id; | |
| 3682 | + var th = this; | |
| 3683 | + | |
| 3684 | + getApp().request.get("/api/weshop/rechargeServicelist/page", { | |
| 3685 | + data: { | |
| 3686 | + prom_type: 6, | |
| 3687 | + prom_id: item.team_id, | |
| 3688 | + user_id: oo.user_id, | |
| 3689 | + store_id: os.stoid, | |
| 3690 | + pageSize: 1, | |
| 3691 | + page: 1 | |
| 3692 | + }, | |
| 3693 | + success: function (e) { | |
| 3694 | + if (e.data.code != 0) { | |
| 3695 | + getApp().my_warnning("读取订单失败", 0, th); | |
| 3696 | + return fasle; | |
| 3697 | + } | |
| 3698 | + //--跳转到已经购买的情况-- | |
| 3699 | + if (e.data.data.pageData.length > 0) { | |
| 3700 | + var odr = e.data.data.pageData[0]; | |
| 3701 | + //还未支付 | |
| 3702 | + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { | |
| 3703 | + wx.showModal({ | |
| 3704 | + title: "您已经购买了该商品待支付中", | |
| 3705 | + success: function (a) { | |
| 3706 | + if (a.confirm) { | |
| 3707 | + wx.navigateTo({ | |
| 3708 | + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, | |
| 3709 | + }); | |
| 3710 | + } | |
| 3711 | + } | |
| 3712 | + }); | |
| 3713 | + } else if (odr.pt_status == 1 && odr.order_status == 1) { | |
| 3714 | + | |
| 3715 | + if (this.data.is_go_to_team_show) return false; | |
| 3716 | + this.data.is_go_to_team_show = 1; | |
| 3717 | + wx.showLoading(); | |
| 3718 | + | |
| 3719 | + getApp().goto("/packageA/pages/serviceCard_pd/team_success/team_success?ordersn=" + odr.order_sn); | |
| 3720 | + | |
| 3721 | + } else { | |
| 3722 | + console.log(222, goods_id) | |
| 3723 | + wx.navigateTo({ | |
| 3724 | + url: "/packageA/pages/serviceCard_pd/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, | |
| 3725 | + }); | |
| 3726 | + } | |
| 3727 | + } | |
| 3728 | + //--跳转到参团-- | |
| 3729 | + else { | |
| 3730 | + console.log(1111, th.data.goods_id) | |
| 3731 | + wx.navigateTo({ | |
| 3732 | + url: "/packageA/pages/serviceCard_pd/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, | |
| 3733 | + }); | |
| 3734 | + } | |
| 3735 | + } | |
| 3736 | + }) | |
| 3737 | + | |
| 3738 | + }, | |
| 3739 | + | |
| 3740 | + //-- 跳到团更多 -- | |
| 3741 | + go_t_more: function () { | |
| 3742 | + var team_id = this.data.prom_id; | |
| 3743 | + wx.navigateTo({ | |
| 3744 | + url: "/packageA/pages/serviceCard_pd/team_more/team_more?team_id=" + team_id, | |
| 3745 | + }); | |
| 3746 | + }, | |
| 3747 | + | |
| 3748 | + //-------跳转pt商品------- | |
| 3749 | + go_to_nopay: function () { | |
| 3750 | + var th = this; | |
| 3751 | + var url = "/packageA/pages/details_serviceCard/details_serviceCard?order_id=" + th.data.buy_order.order_id; | |
| 3752 | + getApp().goto(url); | |
| 3753 | + | |
| 3754 | + }, | |
| 3755 | + | |
| 3756 | + | |
| 3757 | + //--调用更新阶梯团的接口-- | |
| 3758 | + update_jiti: function (id) { | |
| 3759 | + var th = this; | |
| 3760 | + //--更新阶梯团-- | |
| 3761 | + getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { | |
| 3762 | + success: function (ee) { | |
| 3763 | + //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- | |
| 3764 | + if (ee.data.code == 0) { | |
| 3765 | + th.setData({ | |
| 3766 | + user_order_pt_state: 3, | |
| 3767 | + }); | |
| 3768 | + } else if (ee.data.code == -1) { | |
| 3769 | + th.setData({ | |
| 3770 | + user_order_pt_state: 2, | |
| 3771 | + }); | |
| 3772 | + } | |
| 3773 | + } | |
| 3774 | + }) | |
| 3775 | + }, | |
| 3776 | + | |
| 4327 | 3777 | }); |
| 4328 | 3778 | |
| 4329 | 3779 | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.json
| 1 | 1 | { |
| 2 | - "navigationBarTitleText": "商品详情", | |
| 2 | + "navigationBarTitleText": "卡项详情", | |
| 3 | 3 | "enablePullDownRefresh": false, |
| 4 | 4 | "usingComponents": { |
| 5 | 5 | "nav_box": "/components/nav_box/nav_box", |
| 6 | 6 | "warn": "/components/long_warn/long_warn", |
| 7 | - "goods_recommend": "/components/goods_list/goods_list", | |
| 8 | - "share": "/components/share/share" | |
| 7 | + "serviceCard_recommend": "/components/serviceCard_list/serviceCard_list", | |
| 8 | + "share": "/components/share/share" | |
| 9 | 9 | } |
| 10 | 10 | } |
| 11 | 11 | \ No newline at end of file | ... | ... |
packageA/pages/serviceCard_pd/goodsInfo/goodsInfo.wxss
| ... | ... | @@ -361,20 +361,6 @@ image { |
| 361 | 361 | |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | -.join-cart > view { | |
| 365 | - /* width: 29%; */ | |
| 366 | -} | |
| 367 | - | |
| 368 | -.join-cart .new_split { | |
| 369 | - /* width: 13%; */ | |
| 370 | - /* text-align: center; */ | |
| 371 | - /* padding: 20rpx; */ | |
| 372 | - /* box-sizing: border-box; */ | |
| 373 | - /* flex-shrink: 0; */ | |
| 374 | - /* padding: 0; | |
| 375 | - margin: 0; */ | |
| 376 | -} | |
| 377 | - | |
| 378 | 364 | .cart-ico { |
| 379 | 365 | font-size: 24rpx; |
| 380 | 366 | color: #333; |
| ... | ... | @@ -422,10 +408,7 @@ image { |
| 422 | 408 | .join-btn { |
| 423 | 409 | background-color: #ffb03f; |
| 424 | 410 | height: 70rpx; |
| 425 | -/* border-radius: 55rpx 0rpx 0rpx 55rpx; | |
| 426 | -margin-top: 16rpx; */ | |
| 427 | - | |
| 428 | - | |
| 411 | + border-radius: 55rpx 0rpx 0rpx 55rpx; | |
| 429 | 412 | } |
| 430 | 413 | |
| 431 | 414 | view.cart-btn-lg { |
| ... | ... | @@ -435,8 +418,7 @@ view.cart-btn-lg { |
| 435 | 418 | .buy-btn { |
| 436 | 419 | background-color: #f23030; |
| 437 | 420 | height: 70rpx; |
| 438 | -/* border-radius: 0 56rpx 55rpx 0; */ | |
| 439 | - | |
| 421 | + border-radius: 0 56rpx 55rpx 0; | |
| 440 | 422 | } |
| 441 | 423 | |
| 442 | 424 | .buy-btn-all{ |
| ... | ... | @@ -868,7 +850,7 @@ left:31rpx;} |
| 868 | 850 | .juzhong .xq .hs1{font-size: 28rpx; color: #ab8f9e} |
| 869 | 851 | .juzhong .xq .title .close{position: absolute;top: 0; right: 0; width: 45rpx; height: 45rpx;} |
| 870 | 852 | |
| 871 | -.pt_qd{margin-top: 40rpx; height: auto;} | |
| 853 | +.pt_qd{margin: 40rpx 0; height: auto;} | |
| 872 | 854 | .spec-cart-btn.w100{width: 95%; margin-left: 0; height: 75rpx; line-height:75rpx;margin: auto; } |
| 873 | 855 | |
| 874 | 856 | .sto_v{color: #333;} |
| ... | ... | @@ -2575,7 +2557,7 @@ line-height: 38rpx; |
| 2575 | 2557 | } |
| 2576 | 2558 | /* 门店分类列表 */ |
| 2577 | 2559 | .sort_store_list{ |
| 2578 | - height: 82%; | |
| 2560 | + max-height: 700rpx; | |
| 2579 | 2561 | overflow: hidden; |
| 2580 | 2562 | overflow-y: scroll; |
| 2581 | 2563 | width: 95%; |
| ... | ... | @@ -2969,4 +2951,14 @@ button.custom-service::after{ |
| 2969 | 2951 | top: -1000px; |
| 2970 | 2952 | } |
| 2971 | 2953 | |
| 2954 | +.join-cart>view { | |
| 2955 | + width: 29%; | |
| 2956 | +} | |
| 2957 | + | |
| 2958 | +.join-cart>.new_split { | |
| 2959 | + width: 13%; | |
| 2960 | + text-align: center; | |
| 2961 | + padding: 0; | |
| 2962 | + margin: 0; | |
| 2963 | +} | |
| 2972 | 2964 | ... | ... |