diff --git a/components/diy_heatImg/diy_heatImg.js b/components/diy_heatImg/diy_heatImg.js new file mode 100644 index 0000000..5188c81 --- /dev/null +++ b/components/diy_heatImg/diy_heatImg.js @@ -0,0 +1,40 @@ +// components/diy_heatImg/diy_heatImg.js +Component({ + /** + * 组件的属性列表 + */ + properties: { + object: { + type: Object, + value: null, + }, + }, + + /** + * 组件的初始数据 + */ + data: { + + }, + + /** + * 组件的方法列表 + */ + methods: { + //---智能跳转--- + go_url: function (e) { + var url = e.currentTarget.dataset.url; + getApp().goto(url); + }, + nv_void(e) { + var feedId = e.currentTarget.dataset.feedid; + var finderUserName = e.currentTarget.dataset.finderUserName; + var video_type = e.currentTarget.dataset.video_type; + getApp().openChannelsActivity({ + feedId, + finderUserName, + video_type + }) + }, + } +}) diff --git a/components/diy_heatImg/diy_heatImg.json b/components/diy_heatImg/diy_heatImg.json new file mode 100644 index 0000000..e8cfaaf --- /dev/null +++ b/components/diy_heatImg/diy_heatImg.json @@ -0,0 +1,4 @@ +{ + "component": true, + "usingComponents": {} +} \ No newline at end of file diff --git a/components/diy_heatImg/diy_heatImg.wxml b/components/diy_heatImg/diy_heatImg.wxml new file mode 100644 index 0000000..7bd07cb --- /dev/null +++ b/components/diy_heatImg/diy_heatImg.wxml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/components/diy_heatImg/diy_heatImg.wxss b/components/diy_heatImg/diy_heatImg.wxss new file mode 100644 index 0000000..e68751e --- /dev/null +++ b/components/diy_heatImg/diy_heatImg.wxss @@ -0,0 +1,12 @@ +/* components/diy_heatImg/diy_heatImg.wxss */ +.imgbox{ + width: 100%; + position: relative; + overflow: hidden; +} +.img{ + width: 750rpx; +} +.item{ + position: absolute; +} \ No newline at end of file diff --git a/packageA/pages/jfbuy/jfbuy.wxml b/packageA/pages/jfbuy/jfbuy.wxml index ff7e727..bd8f825 100644 --- a/packageA/pages/jfbuy/jfbuy.wxml +++ b/packageA/pages/jfbuy/jfbuy.wxml @@ -67,7 +67,7 @@ {{item.integral}}积分 + ¥{{item.addmoney}} - ¥{{item.shop_price}} + ¥{{item.shop_price}} 销量:{{item.buy_num+item.virtual}} diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml index aba0c02..5fcb35b 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml @@ -200,7 +200,7 @@ 请先选择门店 - + 库存不足 diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 12a15d4..1d48410 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -297,7 +297,11 @@ Page({ nav_backgroundColor: "#ffffff", nav_type: 2, //导航类型 istop: 0, //是否置顶风格为1 - searchbox_transparent: 1 + searchbox_transparent: 1, + + front_g:null, + fir_set_sto:1, //最初始的一下,获取门店 + front_pick:null, //在详情页面上显示的门店 }, @@ -1040,7 +1044,11 @@ Page({ this.wait_for_store_config(); - i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { + if(ee.data.front_g){ + gid=ee.data.front_g.goods_id; + } + + i.get("/api/weshop/goods/get/" + o.stoid + "/" + gid, { failRollback: !0, success: function (t) { console.log(t); @@ -1145,7 +1153,8 @@ Page({ ee.setData({ data: t.data.data, sele_g: t.data.data, - userInfo: getApp().globalData.userInfo + userInfo: getApp().globalData.userInfo, + front_g:ut.deep_cp(t.data.data) }); @@ -2332,12 +2341,11 @@ Page({ if (this.data.openSpecModal_pt && this.data.is_normal) { this.get_sto(); this.setData({ - sele_g: this.data.data, - gid: this.data.data.goods_id + sele_g: this.data.front_g, + gid: this.data.front_g.goods_id }) this.sele_spec_chech_activity(); - } this.setData({ @@ -3369,6 +3377,27 @@ Page({ } }, + + //-- 处理首页的显示门店 --- + deal_front_pk(){ + var th=this; + if(this.data.fir_set_sto==1){ + this.data.fir_set_sto=0; + var cp_data=null + if(th.data.def_pick_store && th.data.def_pick_store.pickup_id){ + cp_data=JSON.parse(JSON.stringify(th.data.def_pick_store)); + } + th.setData({ + front_pick:cp_data, + front_only_pk:th.data.only_pk, + front_def_pickpu_list:th.data.def_pickpu_list, + front_pickpu_listt:th.data.pickpu_list, + front_all_sto:th.data.all_sto, + front_is_show_sto_cat:th.data.is_show_sto_cat, + }) + } + }, + //------------处理门店--------------- deal_pickup(e) { var th = this; @@ -3502,15 +3531,21 @@ Page({ th.setData({ def_pick_store: e.data.data.pageData[0] }) } } + + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); + } else { - th.setData({ - is_show_sto_cat: -1, - only_pk: e.data.data.pageData - }); - //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ - if (!th.data.def_pick_store) { - th.setData({ def_pick_store: e.data.data.pageData[0] }) - } + th.setData({ + is_show_sto_cat: -1, + only_pk: e.data.data.pageData + }); + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------ + if (!th.data.def_pick_store) { + th.setData({ def_pick_store: e.data.data.pageData[0] }) + } + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); } } @@ -3529,6 +3564,9 @@ Page({ sto_sele_distr: e.data.data.pageData[0].distr_type }) } + + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); } }, @@ -3998,6 +4036,7 @@ Page({ } if(prom_type==9){ + ee.get_sto(); this.setData({ isshow: 1, }); } @@ -4500,6 +4539,7 @@ Page({ var th = this; var ind = parseInt(e.currentTarget.dataset.ind); + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); //ind == 1是普通购买 if (ind == 1) { @@ -5940,7 +5980,10 @@ Page({ var th = this; var ind = ee.currentTarget.dataset.ind; + var isfront = ee.currentTarget.dataset.isfront; var bconfig = th.data.bconfig; + th.data.isfront=0; + if(isfront) th.data.isfront=1; //如果开启了,则不在选择门店 if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ @@ -6187,6 +6230,10 @@ Page({ if (!th.data.sele_g) return false; //判断门店的配送方式是不是匹配 var g_distr_type = th.data.sele_g.distr_type; + if(th.data.isfront==1){ + g_distr_type = th.data.data.distr_type; + } + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { wx.showToast({ title: "门店配送方式不匹配", @@ -6208,6 +6255,12 @@ Page({ fir_pick_index: 0 }); + if(th.data.isfront){ + th.setData({ + front_pick: ut.deep_cp(item) + }) + } + if (openindstore == 1) { th.setData({ openSpecModal: !0, @@ -6314,6 +6367,12 @@ Page({ choice_sort_store: 0 }); + if(th.data.isfront){ + th.setData({ + front_pick: ut.deep_cp(item) + }) + } + var openindstore = th.data.open_ind_store; if (openindstore == 1) { th.setData({ diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml index af99e3e..efa5522 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml @@ -418,8 +418,8 @@ - - + + @@ -427,30 +427,30 @@ - + - {{def_pick_store.pickup_name}} + {{front_pick.pickup_name}} - - 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}} + + 距离:{{front_pick.distance>1000?filters.toFix(front_pick.distance/1000,2)+"km":filters.toFix(front_pick.distance,0)+"m"}} - (库存不足) + (库存不足) - + (库存不足) - + (配送不匹配) - + (库存不足) - 地址:{{def_pick_store.fulladdress}} + 地址:{{front_pick.fulladdress}} diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index 4abcba1..ffc6a5a 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -1510,6 +1510,11 @@ Page({ item1.is_post_temp=1; //如果是秒杀,团购的时候,优惠促销和搭配购的时候 if([1,2,3,5,6,7,10].indexOf(item1.prom_type)>-1){ + + if(item1.prom_type==1 || item1.prom_type==6) { + item1.is_quan=0; + } + var url= "/api/weshop/activitylist/getSJGoodsPriceNew/" + os.stoid + "/" + item1.goods_id + "/"+item1.prom_type+"/" + item1.prom_id + "/" + app.globalData.user_id; await app.request.promiseGet(url,{}).then(res=>{ @@ -1522,6 +1527,11 @@ Page({ }else item1.is_order_yh=0; item1.is_post_temp=res.data.data.is_post_temp; + + if(item1.prom_type==1 || item1.prom_type==6) { + item1.is_quan=res.data.data.is_quan; + } + } }) } @@ -2008,7 +2018,6 @@ Page({ //t.data.data.shop_price = tt.data.data.prom_price; gd.shop_price=t.data.data.shop_price = tt.data.data.prom_user_price; th.data.ckeck_quan_price = 0; - gd.is_xz_yh = 1; t.data.data.fir_rate = tt.data.data.fir_rate; t.data.data.sec_rate = tt.data.data.sec_rate; @@ -2046,6 +2055,14 @@ Page({ } + if (tt.data.data.is_quan) { + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; + } else { + gd.is_xz_yh = 1; + } + th.setData({ bn_goods: gd, @@ -3911,6 +3928,7 @@ Page({ is_by_quan = 1; } } + if (!is_by_quan) { var user_addr = th.data.user_addr; var req_d = { @@ -6410,7 +6428,7 @@ Page({ for (var i in goodlist) { var gd = goodlist[i]; //--如果是秒杀就跳出,如果是赠品,如果是组合购限制使用优惠券-- - if (gd.whsle_id == 1 || gd.prom_type == 1 || gd.is_gift || (gd.prom_type == 7 && gd.act && gd.act.is_xz_yh) || gd.is_xz_yh == 1) { + if (gd.whsle_id == 1 || gd.is_gift || (gd.prom_type == 7 && gd.act && gd.act.is_xz_yh) || gd.is_xz_yh == 1) { continue; } @@ -6421,6 +6439,10 @@ Page({ } } + //--如果是秒杀,要判断有没有限制使用优惠券 + if (gd.prom_type == 1 && !gd.is_quan) { + continue; + } //--如果是团购,要判断有没有限制使用优惠券 if (gd.prom_type == 2) { diff --git a/packageE/pages/cart/cart2/cart2.wxss b/packageE/pages/cart/cart2/cart2.wxss index 0bc2a23..e7eb654 100644 --- a/packageE/pages/cart/cart2/cart2.wxss +++ b/packageE/pages/cart/cart2/cart2.wxss @@ -278,7 +278,8 @@ page { padding: 0 42rpx; border-radius: 36rpx; margin-left: 0; - margin-right: 0; + margin-right: 0; + border: none; } .pay-amount { } diff --git a/packageE/pages/cart/cart2_pt/cart2_pt.js b/packageE/pages/cart/cart2_pt/cart2_pt.js index bd364bf..b8effa4 100644 --- a/packageE/pages/cart/cart2_pt/cart2_pt.js +++ b/packageE/pages/cart/cart2_pt/cart2_pt.js @@ -77,6 +77,19 @@ Page({ bconfig:null, showFold:true, template_id:[], + + //--更优惠券抵用有关,立即购买的,如果是购物车,就要把相应的值,写入cartlist数组中-- + ckeck_quan_price: 0, + check_quan_price_list: '', + check_quan_ware_list: '', + + // 设计一个数组来存放已经选择了的券编号,coupon_no是券号,money是面值,coupon_price是真正优惠的价格,数组的下标是pickid + //using_quan[11]={coupon_no:"1212121",money:"20",coupon_price:"45"} + using_quan: {}, + //如果是全场包邮了,或者是全场不包邮了,就不要选包邮券 + is_no_by: {}, + is_by: {}, + is_quan_by: {}, }, @@ -483,6 +496,10 @@ Page({ } else { + th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; + th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; + th.data.check_quan_ware_list = t.data.data.erpwareid + ""; + gd.prom_id=gg.prom_id; //--阶梯团很特殊,不能用总表来拿价格-- getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { @@ -510,6 +527,15 @@ Page({ t.data.data.commission = tt.data.data.commission; + if (!tt.data.data.is_quan || pt_data.kttype == 3) { + + th.data.ckeck_quan_price = 0; + th.data.check_quan_price_list = ""; + th.data.check_quan_ware_list = ""; + gd.is_xz_yh = 1; + } + + if (pt_data.kttype == 3) { t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买 @@ -566,14 +592,15 @@ Page({ } - th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et - }); + th.setData({ + bn_goods: t.data.data, bn_pickname: gg.pick_name, + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et + }); - //计算价格 - th.calculatePrice2(); + //计算价格 + th.calculatePrice2(); + th.get_buy_now_quan(); } }); } @@ -631,11 +658,13 @@ Page({ this.getuser_addr(function (ie) { //更换地址回来要重新调用计算价钱的接口 - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { + if (!th.data.user_addr || !ie || th.data.user_addr.address_id != ie.address_id) { th.setData({ add_back: 1,same_ok:1 }); //if (th.data.bn_goods) th.calculatePrice2(); } th.setData({ user_addr: ie,show_btn:0 }); + + th.data.isget_by_quan = {}; }) //--更新默认地址--,看一下是不是跳到地址页面 if (!getApp().globalData.is_cart_old) { @@ -764,9 +793,45 @@ Page({ var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 + + + + //---如果有选择优惠券的情况下--- + var quan_price = 0, bn_pick = th.data.bn_pick; + var quan_no = null; + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) + quan_no = th.data.using_quan[bn_pick].coupon_no; + + if (quan_no) { + //如果是一件代发就不要找商品 + if (th.data.using_quan[bn_pick].isby != 1) { + //---获取优惠券优惠--- + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", { + data: { + storeId: oo.stoid, + CashRepNo: quan_no, + WaresSum: th.data.ckeck_quan_price, + WareIds: th.data.check_quan_ware_list + } + }).then(res => { + + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + quan_price = res.data.data[0].WareCashSum; + + allpice=allpice-quan_price; + + } + }) + } + } + //-- 判断订单优惠的叠加 -- var ord_prom=null; var o_condition=allpice; + var pickid = th.data.bn_pick; + + + if(th.data.bn_is_order_yh && th.data.kt_type != 3 ){ await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { @@ -781,6 +846,40 @@ Page({ //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + //看是不是有调用过包邮券 + if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { + + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { + data: { + store_id: os.stoid, + isuse: 0, + condition: o_condition, + user_id: getApp().globalData.user_id, + pageSize: 2000 + } + }).then(res => { + if (res.data.code == 0 && res.data.data.total > 0) { + //此时要循环判断包邮的地区,不包邮商品是不是符合 + var arr = [], quanlist = res.data.data.pageData; + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1); + for (var i in quanlist) { + var item = quanlist[i]; + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域 + if (item.goods_list) { + var no_goods_arr = item.goods_list.split(","); + if (ut.isContained(no_goods_arr, gd_arr_list)) continue; //如果是不包邮商品 + } + arr.push(item); + } + if (arr) { + th.setData({ get_by_quan_list: arr }); + } + th.data.isget_by_quan[th.data.bn_pick] = 1; + } + }) + } + if(good.is_free_shipping){ var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: 0 }) @@ -791,6 +890,7 @@ Page({ wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid } var back_data = null; + var quan_no_goods_arr=null; if(!ord_prom || ord_prom.is_post_temp) { if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) { @@ -802,108 +902,146 @@ Page({ } } - var gd_arr_list = []; - gd_arr_list.push(good); - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; - - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + var is_by_quan = 0; + //如果是包邮券的时候,要看看券的情况,判断一下包邮有没有不包邮模板 + if (quan_no && th.data.using_quan[pickid].isby == 1) { + var quan = th.data.using_quan[pickid]; + if (quan.goods_list) { + quan_no_goods_arr = quan.goods_list.split(","); + } else { + is_by_quan = 1; + } + } - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - cut_good_weight += item['weight'] * item['buynum']; - goods_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - continue; + //如果有包邮券的不包邮商品的时候 + if (quan_no_goods_arr) { + if (back_data && back_data.no_free_goods) { + back_data['is_by_all'] = 1; + var arr3 = back_data.no_free_goods.filter(item => { + return quan_no_goods_arr.includes(item) + }) + back_data.no_free_goods = null; + if (arr3.length) { + back_data.no_free_goods = arr3; } + } + if (!back_data || !back_data.no_free_goods) { + if (!back_data) back_data = {}; + back_data['is_by_all'] = 1; + back_data['no_free_goods'] = quan_no_goods_arr; + } + } + + + if(!is_by_quan){ + var gd_arr_list = []; + gd_arr_list.push(good); + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; - - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } + goods_weight += item['weight'] * item['buynum']; } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; - } - } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; + } - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } + } + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; - if(!th.data.wu_arr){ - wx.hideLoading(); - wx.showToast({ - title: "物流配置未启用物流公司", icon: 'none', duration: 2000 - }) - //th.setData({ show_submit:0, }); - th.setData({show_submit:1, submit: 0,same_ok:0 }) - return false; - } - var code = th.data.wu_arr[th.data.index].code; - - //--------------开始计算物流------------------ - var shipping_price = 0; - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); - - var w_data = { - store_id: os.stoid, code: code, - o_shipping_price: o_shipping_price, - goods_weight: goods_weight, - out_of_weight: out_of_weight, goods_piece: goods_piece, - user_addr_province: th.data.user_addr.province, - user_addr_city: th.data.user_addr.city, - user_addr_district: th.data.user_addr.district, - is_by_all: back_data && back_data.is_by_all ? 1 : 0, - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, - } + if(!th.data.wu_arr){ + wx.hideLoading(); + wx.showToast({ + title: "物流配置未启用物流公司", icon: 'none', duration: 2000 + }) + //th.setData({ show_submit:0, }); + th.setData({show_submit:1, submit: 0,same_ok:0 }) + return false; + } - var is_ok = 0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { - data: w_data, - is_json: 1 - }).then(res => { - if (res.data.code == 0) { - shipping_price = res.data.data; - is_ok = 1; + var code = th.data.wu_arr[th.data.index].code; + + //--------------开始计算物流------------------ + var shipping_price = 0; + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, } - }) - if (!is_ok) { - wx.hideLoading(); - wx.showToast({ - title: "计算物流错误", icon: 'none', duration: 2000 + + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { + data: w_data, + is_json: 1 + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + is_ok = 1; + } }) - //th.setData({ show_submit:0 }); - th.setData({show_submit:1, submit: 0,same_ok:0 }) + if (!is_ok) { + wx.hideLoading(); + wx.showToast({ + title: "计算物流错误", icon: 'none', duration: 2000 + }) + //th.setData({ show_submit:0 }); + th.setData({show_submit:1, submit: 0,same_ok:0 }) + + return false; + } - return false; - } + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: shipping_price, }) - shipping_price = parseFloat(shipping_price).toFixed(2); + } + else{ var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) + th.setData({ [wl_txt]: 0, }) + } } } else if (th.data.bn_exp_type == 1) { var wl_txt = "formData.shipping_price"; @@ -1140,6 +1278,9 @@ Page({ } + + var txt3 = "formData.coupon_price"; + if (th.data.bn_use_commission) { order_m = (parseFloat(order_m) - parseFloat(th.data.bn_goods.use_commission)).toFixed(2); th.setData({ [txt4]: th.data.bn_goods.use_commission }) @@ -1148,14 +1289,14 @@ Page({ //--------------如果使用余额--------------------- if (th.data.bn_use_money == 1 && th.data.yuer > 0) { if (parseFloat(th.data.yuer) > parseFloat(order_m)) { - th.setData({ [txt]: order_m, [txt2]: 0, submit: 0, show_btn: 1 }) + th.setData({ [txt]: order_m, [txt2]: 0, [txt3]:quan_price,submit: 0, show_btn: 1 }) } else { order_m = parseFloat(order_m) - parseFloat(th.data.yuer); order_m = order_m.toFixed(2); - th.setData({ [txt]: th.data.yuer, [txt2]: order_m, submit: 0, show_btn: 1 }) + th.setData({ [txt]: th.data.yuer, [txt2]: order_m,[txt3]:quan_price, submit: 0, show_btn: 1 }) } } else { - th.setData({ [txt]: 0, [txt2]: order_m, submit: 0, show_btn: 1 }) + th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:quan_price, submit: 0, show_btn: 1 }) } wx.hideLoading(); @@ -1268,6 +1409,17 @@ Page({ item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name; } + + //组装优惠券的钱 + if (parseFloat(th.data.formData.coupon_price) > 0) { + item.coupon_price = th.data.formData.coupon_price; + item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no; + } + if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].coupon_no && th.data.using_quan[th.data.bn_pick].isby) { + item.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no; + item.coupon_price = 0; + } + if (!th.data.bn_goods.is_normal) { item.is_zsorder = th.data.kt_type + 1; //开团类型 } @@ -1681,5 +1833,428 @@ Page({ buycard: function () { getApp().goto("/pages/user/plus/plus"); getApp().globalData.plus_buy_back = 1; - } + }, + + //------ 获取立即购买的购物车的劵 -------- + get_buy_now_quan: function () { + var quanlist = null, th = this, frozenQuan = null; + var good = this.data.bn_goods; + + //一件代发商品不使用优惠券 + if (good.whsle_id) return false; + if(!th.data.check_quan_ware_list) return false; + + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券-- + if (th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh != 1 && th.data.check_quan_ware_list) { + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; + var url = "/api/weshop/couponList/getUseCouponList"; + app.request.promiseGet(url0, { 1: 1 }).then(res => { + if (res.data.code == 0) { + frozenQuan = res.data.data; + th.data.frozenQuan = frozenQuan; + } + app.request.time_limit_get(6, url, { + data: { + storeId: oo.stoid, + userId: app.globalData.user_id, + BuySum: th.data.ckeck_quan_price, + WareIds: encodeURIComponent(th.data.check_quan_ware_list), + pageSize: 100 + }, + success: function (res) { + if (res.data.code == 0) { + quanlist = res.data.data.pageData; + if (quanlist) { + quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); + th.setData({ selected_quan_list: quanlist }) + } + } + } + }) + }) + } + }, + + //--验证是否已经冻结-- + check_is_frozenQuan: function (quanlist, frozenQuan, isby) { + console.log("券列表", quanlist); + if (!quanlist) return null; + if (!frozenQuan) return quanlist; + var arr = []; + for (var i = 0; i < quanlist.length; i++) { + var item = quanlist[i]; + var is_find = 0; + var Q_no = quanlist[i].CashRepNo; + if (isby) Q_no = quanlist[i].no; + for (var j = 0; j < frozenQuan.length; j++) { + var q_no = frozenQuan[j].cashRepNo; + if (Q_no == q_no) { + is_find = 1; + break; + } + } + if (!is_find) arr.push(item); + } + return arr; + }, + + /*----券的所有操作----*/ + open_coupon_list: function (e) { + var th = this; + var pickid = e.currentTarget.dataset.pickid; + var bn = e.currentTarget.dataset.bn; + var cindx = e.currentTarget.dataset.cind; + + if (bn == 1) { + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); + } else { + //---多单打开券的时候,就要判断券在其他门店是否有使用--- + var quanlist = th.data.cartlist[cindx].quan_list; + var exp_type = th.data.cartlist[cindx].exp_type; + + + //对于在其他门店已经选择了的券 要判断是否显示到界面 + var t_user = th.data.using_quan[pickid]; + + for (var i in quanlist) { + quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid); + if (t_user && quanlist[i].CashRepNo == t_user.coupon_no) + quanlist[i].show_red = 1; + else + quanlist[i].show_red = 0; + } + + if (get_by_quan_list_cart) { + for (var i in get_by_quan_list_cart) { + get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid); + if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no) + get_by_quan_list_cart[i].show_red = 1; + else + get_by_quan_list_cart[i].show_red = 0; + } + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); + } else { + th.setData({ by_quan_list_cart: null }); + } + + console.log("2222222券的列表", quanlist); + th.setData({ + sele_cart_ind: cindx, + sele_exp_type: exp_type, + open_quan: 1, + selected_quan_pick: pickid, + selected_quan_list: quanlist, + disabled: 1 + }); + } + }, + close_coupon: function (e) { + var th = this; + th.setData({ open_quan: 0, disabled: 0 }); + }, + + /*--点击选择券--*/ + sele_quan_item: function (e) { + + var ind = e.currentTarget.dataset.ind; + var quan_item = this.data.selected_quan_list[ind]; + var pickid = this.data.selected_quan_pick; //现在选择的是哪一个门店 + //--如果券是单品使用的时候-- + if (quan_item && quan_item.UseObjectType && quan_item.UseObjectType == "20") { + //---只有多件购买的时候才要计算,//购物车购买和搭配勾的时候--- + var gg = getApp().get_b_now(); + if (this.data.is_b_now == 0 || gg.prom_type == 5) { + var arr = this.data.order_prom_list_cart; + var t_pk_item = null; + for (var ii in arr) { + var ep = arr[ii]; + if (pickid == ep.pickup_id) { + t_pk_item = ep; + break; + } + } + //--寻找券指定的商品-- + var gd = null; + if (t_pk_item) { + var goods = t_pk_item.goods; + for (var gid in goods) { + if (quan_item.UseObjectID == goods[gid].erpwareid) { + gd = goods[gid]; + } + } + } + if (!gd) { + getApp().my_warnning("未找到指定商品使用", 0, this, 600); + return false; + } + //计算价格,如果有平摊的实收要计算实收的金额 + var item_price = gd.goods_price * gd.goods_num; + //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 -- + if (gd.account_fir != null && gd.account_fir != undefined) { + item_price = gd.account_fir * gd.goods_num; + } + + if (item_price < parseFloat(quan_item.BuySum)) { + getApp().my_warnning("该单品金额没有大于等于" + quan_item.BuySum + "元时不能使用优惠券", 0, this, 600); + return false; + } + } + } + + var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list; + //---所有的券的显示红色选择都清理一遍--- + for (var i in quanlist) { + quanlist[i].show_red = 0; + } + this.setData({ selected_quan_list: quanlist }); + var by_quanlist = this.data.get_by_quan_list; + if (by_quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var inb in by_quanlist) { + by_quanlist[inb].show_red = 0; + } + this.setData({ get_by_quan_list: by_quanlist }); + } + + var by_cart_list = this.data.by_quan_list_cart; + if (by_cart_list) { + //---所有的券的显示红色选择都清理一遍--- + for (var inc in by_cart_list) { + by_cart_list[inc].show_red = 0; + } + this.setData({ by_quan_list_cart: by_cart_list }); + } + + var using_quan = this.data.using_quan; + var th = this; + //---如果是不使用优惠券--- + if (no_use == 1) { + console.log("有进来吗券", no_use); + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 1; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; + } + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); + return; + } + + + var txt = "selected_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + if (quan_item.show_red) { + obj[txt] = 0; + } + this.setData(obj); + console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt); + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 0; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; + } + this.setData({ using_quan: using_quan }); + + }, + + /*----- 点击选择包邮券 -----*/ + sele_quan_item_by: function (e) { + var no_use = e.currentTarget.dataset.no; + //立即购买的包邮券 + var by_quanlist = this.data.get_by_quan_list; + if (by_quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var ind in by_quanlist) { + by_quanlist[ind].show_red = 0; + } + this.setData({ get_by_quan_list: by_quanlist }); + } + + //--购物车过来的包邮券-- + var by_cart_list = this.data.by_quan_list_cart; + if (by_cart_list) { + //---所有的券的显示红色选择都清理一遍--- + for (var ind in by_cart_list) { + by_cart_list[ind].show_red = 0; + } + this.setData({ by_quan_list_cart: by_cart_list }); + } + //普通券 + var quanlist = this.data.selected_quan_list; + if (quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var ind in quanlist) { + quanlist[ind].show_red = 0; + } + this.setData({ selected_quan_list: quanlist }); + } + + var th = this; + var using_quan = this.data.using_quan; + //---如果是不使用优惠券--- + if (no_use == 1) { + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 1; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; + } + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); + return; + } + + var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店 + var ind = e.currentTarget.dataset.ind; + //--如果是立即购买的部分-- + var txt = ""; + var txt1 = ""; + var quan_item = null; + if (th.data.is_b_now) { + quan_item = this.data.get_by_quan_list[ind]; + txt = "get_by_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + this.setData(obj); + } else { + txt = "by_quan_list_cart[" + ind + "].show_red"; + quan_item = th.data.by_quan_list_cart[ind]; + var obj = {}; + obj[txt] = 1; + this.setData(obj); + th.data.get_by_quan_list_cart[pickid] = JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组 + } + + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 0; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; + } + this.setData({ using_quan: using_quan }); + }, + + //--确认使用券--- + confirm_quan: function () { + var using_quan = this.data.using_quan; //正在使用中的券列表 + var pickid = this.data.selected_quan_pick; //选中的门店ID + var th = this; + var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表 + var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表 + var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表 + //选择了的券 + var sele_quan = null; + + //循环普通的券 + for (var i in selected_quan_list) { + var item = selected_quan_list[i]; + if (item.show_red) { + th.insert_into_using_quan(item, using_quan, pickid); + return; + } + } + //循环包邮的券,立即购买的 + for (var i in get_by_quan_list) { + var item = get_by_quan_list[i]; + if (item.show_red) { + if (th.data.is_no_by[pickid] == 1) { + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th); + return false; + } + if (th.data.is_by[pickid] == 1) { + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th); + return false; + } + + th.insert_into_using_quan(item, using_quan, pickid, 1); + return; + } + } + + //循环包邮的券 + for (var i in by_quan_list_cart) { + var item = by_quan_list_cart[i]; + if (item.show_red) { + if (th.data.is_no_by[pickid] == 1) { + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th); + return false; + } + if (th.data.is_by[pickid] == 1) { + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th); + return false; + } + th.insert_into_using_quan(item, using_quan, pickid, 1); + return; + } + } + + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 + if (using_quan[pickid]) { + if (using_quan[pickid].is_nouse_red == 1) { + using_quan[pickid] = { is_nouse_red: 1 }; + th.setData({ using_quan: using_quan }); + if (th.data.is_b_now == 1) { + th.calculatePrice2(); + } else { + th.calculatePrice(); + } + th.setData({ open_quan: 0 }); + return; + } + } + }, + + //----把券插入之后的操作,同时还要重新计算价格---- + insert_into_using_quan: async function (item, using_quan, pickid, isby) { + + + var th = this; + var old_quan = null; + if (isby == 1) { + using_quan[pickid] = { + coupon_no: item.no, + money: 0, + is_nouse_red: 0, + region_list: item.region_list, + goods_list: item.goods_list + }; + using_quan[pickid].isby = 1; + } else { + if (using_quan[pickid]) old_quan = using_quan[pickid]; + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; + using_quan[pickid].isby = 0; + } + this.setData({ using_quan: using_quan }); + if (th.data.is_b_now == 1) { + th.calculatePrice2(function () { + + if (old_quan) using_quan[pickid] = old_quan; + else using_quan[pickid] = null; + th.setData({ using_quan: using_quan, submit: 0 }); + wx.showToast({ + title: "不能使用优惠券,同城起送价不足", + icon: 'none', + duration: 2000 + }) + + }); + } else { + th.calculatePrice(function () { + if (old_quan) using_quan[pickid] = old_quan; + else using_quan[pickid] = null; + th.setData({ using_quan: using_quan, submit: 0 }); + wx.showToast({ + title: "不能使用优惠券,同城起送价不足", + icon: 'none', + duration: 2000 + }) + }); + } + th.setData({ open_quan: 0 }); + }, + + + + }); diff --git a/packageE/pages/cart/cart2_pt/cart2_pt.wxml b/packageE/pages/cart/cart2_pt/cart2_pt.wxml index d67ded0..2cd0b09 100644 --- a/packageE/pages/cart/cart2_pt/cart2_pt.wxml +++ b/packageE/pages/cart/cart2_pt/cart2_pt.wxml @@ -1,4 +1,5 @@ +
@@ -101,6 +102,24 @@ {{order.store_prom}} + + + + @@ -186,6 +205,12 @@ 配送费用 ¥ {{formData.shipping_price}}元 + + + 使用优惠券 + - ¥ {{formData.coupon_price}}元 + + 使用预存 @@ -256,4 +281,128 @@ - \ No newline at end of file + + + + + + + + + + + + 优惠券使用 + + + × + + + + 可使用的优惠券 + 不使用优惠券 + + Γ + + + + + + + + + + + + + + + + + + + {{item.Sum}} + 满{{item.BuySum}}元可用 + 满0元可用 + + + + + + + + + {{filter.get_type_card(item.UseObjectType)}} + {{item.Sum}}元优惠券 + + {{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}} + + + + Γ + + + + + + + + + + + + + + + + + + + + + + + 包邮券 + 满{{item.condition}}元可用 + 满0元可用 + + + + + + + + + {{filter.get_type_card(0)}} + 包邮券 + + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}} + + + + Γ + + + + + + + + + + + + + + + + + + + + + + 确定 + + + \ No newline at end of file diff --git a/packageE/pages/cart/cart2_pt/cart2_pt.wxss b/packageE/pages/cart/cart2_pt/cart2_pt.wxss index 24414fd..1a9f2f1 100644 --- a/packageE/pages/cart/cart2_pt/cart2_pt.wxss +++ b/packageE/pages/cart/cart2_pt/cart2_pt.wxss @@ -1,3 +1,5 @@ +/*@import "../cart2/cart2.wxss";*/ + .bdr_t-14 { border-top-left-radius: 14rpx; border-top-right-radius: 14rpx; diff --git a/packageE/pages/cart/cart_wk/cart_wk.js b/packageE/pages/cart/cart_wk/cart_wk.js index d121275..ae84794 100644 --- a/packageE/pages/cart/cart_wk/cart_wk.js +++ b/packageE/pages/cart/cart_wk/cart_wk.js @@ -1,6 +1,6 @@ // pages/cart/cart_wk/cart_wk.js var t = getApp(), - oo = t.globalData.setting, + oo = t.globalData.setting,app=t, os=oo; var ut=require("../../../../utils/util.js"); var util_pay=require("../../../../utils/pay.js"); @@ -53,8 +53,21 @@ Page({ paying:0, //支付中 same_ok:1, //同城配送的控制 formData:{ - order_prom_amount:0 - } + order_prom_amount:0, + coupon_price:0 + }, + + //--更优惠券抵用有关,立即购买的,如果是购物车,就要把相应的值,写入cartlist数组中-- + ckeck_quan_price: 0, + check_quan_price_list: '', + check_quan_ware_list: '', + + // 设计一个数组来存放已经选择了的券编号,coupon_no是券号,money是面值,coupon_price是真正优惠的价格,数组的下标是pickid + //using_quan[11]={coupon_no:"1212121",money:"20",coupon_price:"45"} + using_quan: {}, + isget_by_quan: {}, //是否调用了接口获取包邮券 + is_by:{}, + get_by_quan_list: null, //立即购买的 }, @@ -154,13 +167,8 @@ Page({ user_addr: addr, enterAddressPage: 0,same_ok:1 }); } - - if (th.data.exp_type == 0 && th.data.goods) { - th.calculate_wuliu(); - } - - if (th.data.exp_type == 2 && th.data.goods) { - th.calculate_same_city(); + if (th.data.goods) { + th.calculatePrice2(); } }) @@ -361,7 +369,7 @@ Page({ if (!goods) return false; - if(goods.is_minishop==1 && getApp().is_sp_hao()){ + if(goods.is_minishop==1 && getApp().is_sp_hao()){ if(goods.distr_type==1 || pickup.distr_type==1) { wx.showToast({ @@ -423,7 +431,6 @@ Page({ } - order.order_goods = order_goods; //-- 计算获得佣金的金额 -- @@ -446,12 +453,23 @@ Page({ } + if(teamlist.is_quan){ + let q_ch_money= parseFloat(price * order_goods.goods_num).toFixed(2); + th.data.ckeck_quan_price = q_ch_money; + th.data.check_quan_price_list = q_ch_money + ""; + th.data.check_quan_ware_list = goods.erpwareid + ""; + }else{ + goods.is_xz_yh = 1; + } + + this.setData({ order: order, distr_type: distr_type, pickup: pickup, + bn_pick: pickup.pickup_id, exp_type: exp_type, goods: goods, teamgroup: teamgroup, @@ -460,6 +478,7 @@ Page({ //--计算价格-- th.calculatePrice2(); + th.get_buy_now_quan(); }, @@ -469,6 +488,37 @@ Page({ th.setData({submit: 1}) var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; + + //---如果有选择优惠券的情况下--- + var quan_price = 0, bn_pick = th.data.bn_pick; + var quan_no = null; + if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) + quan_no = th.data.using_quan[bn_pick].coupon_no; + + if (quan_no) { + //如果是一件代发就不要找商品 + if (th.data.using_quan[bn_pick].isby != 1) { + //---获取优惠券优惠--- + await getApp().request.promiseGet("/api/weshop/couponList/getUseCouponPrice", { + data: { + storeId: oo.stoid, + CashRepNo: quan_no, + WaresSum: th.data.ckeck_quan_price, + WareIds: th.data.check_quan_ware_list + } + }).then(res => { + + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + quan_price = res.data.data[0].WareCashSum; + allpice=allpice-quan_price; + } + }) + } + } + + var order_prom_txt3 = "formData.coupon_price"; + th.setData({[order_prom_txt3]: quan_price}) + var o_condition = allpice; var ord_prom=null; var order_prom_amount=0; @@ -487,10 +537,10 @@ Page({ //--计算物流-- if (th.data.exp_type == 0) { - th.calculate_wuliu(); + th.calculate_wuliu(allpice); return false; }else if(th.data.exp_type == 2){ - th.calculate_same_city(); + th.calculate_same_city(allpice); return false; } else { @@ -521,6 +571,7 @@ Page({ //--订单优惠的显示-- var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; + if (order_prom_id > 0) { th.setData({[order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount}) } else { @@ -565,19 +616,10 @@ Page({ exp_type: type,same_ok:1 }); //--计算物流的值-- - if (type == 0) { - th.calculate_wuliu(); - } else if(type==1){ - var allpice = parseFloat(th.data.order.order_amount) - + parseFloat(th.data.order.user_money) - + parseFloat(th.data.order.tail_money); - allpice = allpice.toFixed(2); - this.setData({ - allpice: allpice, exp_price: 0,show_submit:1,submit:0 - }); - }else{ - th.calculate_same_city(); + if (th.data.goods) { + th.calculatePrice2(); } + }, //关闭支付 @@ -632,6 +674,18 @@ Page({ tail_pay_type: ind,//0微信支付 1余额支付 }; + //组装优惠券的钱 + if (parseFloat(th.data.formData.coupon_price) > 0) { + dd.coupon_price = th.data.formData.coupon_price; + dd.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no; + } + + if (th.data.using_quan[th.data.bn_pick] && th.data.using_quan[th.data.bn_pick].coupon_no && th.data.using_quan[th.data.bn_pick].isby) { + dd.coupon_no = th.data.using_quan[th.data.bn_pick].coupon_no; + dd.coupon_price = 0; + } + + if (th.data.exp_type == 0 || th.data.exp_type == 2) { var index = th.data.index; dd.shipping_code = th.data.wu_arr[index].code; @@ -774,7 +828,7 @@ Page({ }, //----计算物流的钱---- - async calculate_wuliu() { + async calculate_wuliu(p_allpice) { //让按钮变灰色 this.setData({submit: 1}); var to = getApp(), th = this; @@ -791,14 +845,54 @@ Page({ var order_prom_amount=0; //--全部金额-- var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; + if(p_allpice) allpice=p_allpice; // if(th.data.bn_use_commission){ // allpice-=th.data.goods.use_commission; // } + var pickid=th.data.bn_pick; var o_condition=allpice; + var quan_no = null; + + if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) + quan_no = th.data.using_quan[pickid].coupon_no; //-----------当地址不为空,且是物流时,计算物流费用---------- if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { + //看是不是有调用过包邮券 + if (!th.data.isget_by_quan[th.data.pickid] && good.is_xz_yh != 1) { + + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额,见到优惠券的钱--- + getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea", { + data: { + store_id: os.stoid, + isuse: 0, + condition: o_condition, + user_id: getApp().globalData.user_id, + pageSize: 2000 + } + }).then(res => { + if (res.data.code == 0 && res.data.data.total > 0) { + //此时要循环判断包邮的地区,不包邮商品是不是符合 + var arr = [], quanlist = res.data.data.pageData; + quanlist = th.check_is_frozenQuan(quanlist, th.data.frozenQuan, 1); + for (var i in quanlist) { + var item = quanlist[i]; + if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域 + if (item.goods_list) { + var no_goods_arr = item.goods_list.split(","); + if (ut.isContained(no_goods_arr, gd_arr_list)) continue; //如果是不包邮商品 + } + arr.push(item); + } + if (arr) { + th.setData({ get_by_quan_list: arr }); + } + th.data.isget_by_quan[th.data.bn_pick] = 1; + } + }) + } + //订单促销的包邮模板 和 活动的包邮模板要一起判断 if ((!ord_prom || ord_prom.is_post_temp) && th.data.bn_is_post_temp) { var user_addr = th.data.user_addr; @@ -814,98 +908,137 @@ Page({ }); } - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + var is_by_quan = 0; + var quan_no_goods_arr=null; - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - goods_weight += item['weight'] * item['buynum']; - cut_good_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + //如果是包邮券的时候,要看看券的情况,判断一下包邮有没有不包邮模板 + if (quan_no && th.data.using_quan[pickid].isby == 1) { + var quan = th.data.using_quan[pickid]; + if (quan.goods_list) { + quan_no_goods_arr = quan.goods_list.split(","); + } else { + is_by_quan = 1; + } + } + + //如果有包邮券的不包邮商品的时候 + if (quan_no_goods_arr) { + if (back_data && back_data.no_free_goods) { + back_data['is_by_all'] = 1; + var arr3 = back_data.no_free_goods.filter(item => { + return quan_no_goods_arr.includes(item) + }) + back_data.no_free_goods = null; + if (arr3.length) { + back_data.no_free_goods = arr3; } - continue; } + if (!back_data || !back_data.no_free_goods) { + if (!back_data) back_data = {}; + back_data['is_by_all'] = 1; + back_data['no_free_goods'] = quan_no_goods_arr; + } + } - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; + if(!is_by_quan){ + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { - cut_good_weight += item['weight'] * item['buynum']; + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + goods_weight += item['weight'] * item['buynum']; + cut_good_weight += item['weight'] * item['buynum']; + } if (back_data.weight_free > 0) { out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; } + continue; } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; - } - } - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } + } - if(!th.data.wu_arr){ - wx.hideLoading(); - wx.showToast({ - title: "物流配置未启用物流公司", icon: 'none', duration: 2000 - }) - //th.setData({ show_submit:0, }); - th.setData({show_submit:1, submit: 0,same_ok:0 }) - return false; - } - var code = th.data.wu_arr[th.data.index].code; - - //--------------开始计算物流------------------ - var shipping_price = 0; - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); - - var w_data = { - store_id: os.stoid, code: code, - o_shipping_price: o_shipping_price, - goods_weight: goods_weight, - out_of_weight: out_of_weight, goods_piece: goods_piece, - user_addr_province: th.data.user_addr.province, - user_addr_city: th.data.user_addr.city, - user_addr_district: th.data.user_addr.district, - is_by_all: back_data && back_data.is_by_all ? 1 : 0, - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, - } + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; + + if (!th.data.wu_arr) { + wx.hideLoading(); + wx.showToast({ + title: "物流配置未启用物流公司", icon: 'none', duration: 2000 + }) + //th.setData({ show_submit:0, }); + th.setData({show_submit: 1, submit: 0, same_ok: 0}) + return false; + } + var code = th.data.wu_arr[th.data.index].code; + + //--------------开始计算物流------------------ + var shipping_price = 0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, + } - var is_ok = 0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { - data: w_data, - is_json: 1 - }).then(res => { - if (res.data.code == 0) { - shipping_price = res.data.data; - is_ok = 1; - } else { - getApp().confirmBox("计算物流错误:" + res.data.msg); - } - }) - if (!is_ok) { - th.setData({show_submit:1, submit: 0,same_ok:0 }) - wx.hideLoading(); - return false; + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { + data: w_data, + is_json: 1 + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + is_ok = 1; + } else { + getApp().confirmBox("计算物流错误:" + res.data.msg); + } + }) + if (!is_ok) { + th.setData({show_submit: 1, submit: 0, same_ok: 0}) + wx.hideLoading(); + return false; + } } + + + + //-- 计算一下订单促销 -- if (ord_prom) { order_prom_id = ord_prom['id']; @@ -1026,7 +1159,7 @@ Page({ }, //----计算物流的钱--- - async calculate_same_city() { + async calculate_same_city(p_allpice) { //让按钮变灰色 this.setData({submit:1}); var th = this; @@ -1039,7 +1172,9 @@ Page({ var order_prom_amount=0; //--全部金额-- - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; + var allpice = p_allpice; + var o_condition=p_allpice; + //-----------当地址不为空,且是物流时,计算物流费用---------- if (th.data.user_addr != null) { @@ -1145,7 +1280,7 @@ Page({ } else { - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; + //-- 计算一下订单促销 -- if (ord_prom) { @@ -1339,6 +1474,397 @@ Page({ var th = this; th.setData({bn_use_commission: !th.data.bn_use_commission}); th.calculatePrice2(); - } + }, + + //------ 获取立即购买的购物车的劵 -------- + get_buy_now_quan: function () { + var quanlist = null, th = this, frozenQuan = null; + var good = this.data.goods; + + //一件代发商品不使用优惠券 + if (good.whsle_id) return false; + if(!th.data.check_quan_ware_list) return false; + + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券-- + if (th.data.is_close_quan != 1 && good.is_xz_yh != 1 && th.data.check_quan_ware_list) { + var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id; + var url = "/api/weshop/couponList/getUseCouponList"; + app.request.promiseGet(url0, { 1: 1 }).then(res => { + if (res.data.code == 0) { + frozenQuan = res.data.data; + th.data.frozenQuan = frozenQuan; + } + app.request.time_limit_get(6, url, { + data: { + storeId: oo.stoid, + userId: app.globalData.user_id, + BuySum: th.data.ckeck_quan_price, + WareIds: encodeURIComponent(th.data.check_quan_ware_list), + pageSize: 100 + }, + success: function (res) { + if (res.data.code == 0) { + quanlist = res.data.data.pageData; + if (quanlist) { + quanlist = th.check_is_frozenQuan(quanlist, frozenQuan); + th.setData({ selected_quan_list: quanlist }) + } + } + } + }) + }) + } + }, + + //--验证是否已经冻结-- + check_is_frozenQuan: function (quanlist, frozenQuan, isby) { + console.log("券列表", quanlist); + if (!quanlist) return null; + if (!frozenQuan) return quanlist; + var arr = []; + for (var i = 0; i < quanlist.length; i++) { + var item = quanlist[i]; + var is_find = 0; + var Q_no = quanlist[i].CashRepNo; + if (isby) Q_no = quanlist[i].no; + for (var j = 0; j < frozenQuan.length; j++) { + var q_no = frozenQuan[j].cashRepNo; + if (Q_no == q_no) { + is_find = 1; + break; + } + } + if (!is_find) arr.push(item); + } + return arr; + }, + + /*----券的所有操作----*/ + open_coupon_list: function (e) { + var th = this; + var pickid = e.currentTarget.dataset.pickid; + var bn = e.currentTarget.dataset.bn; + var cindx = e.currentTarget.dataset.cind; + + if (bn == 1) { + th.setData({ open_quan: 1, selected_quan_pick: pickid, disabled: 1 }); + } else { + //---多单打开券的时候,就要判断券在其他门店是否有使用--- + var quanlist = th.data.cartlist[cindx].quan_list; + var exp_type = th.data.cartlist[cindx].exp_type; + + + //对于在其他门店已经选择了的券 要判断是否显示到界面 + var t_user = th.data.using_quan[pickid]; + + for (var i in quanlist) { + quanlist[i].is_using = th.check_in_sele(quanlist[i].CashRepNo, pickid); + if (t_user && quanlist[i].CashRepNo == t_user.coupon_no) + quanlist[i].show_red = 1; + else + quanlist[i].show_red = 0; + } + + if (get_by_quan_list_cart) { + for (var i in get_by_quan_list_cart) { + get_by_quan_list_cart[i].is_using = th.check_in_sele(get_by_quan_list_cart[i].no, pickid); + if (t_user && get_by_quan_list_cart[i].no == t_user.coupon_no) + get_by_quan_list_cart[i].show_red = 1; + else + get_by_quan_list_cart[i].show_red = 0; + } + th.setData({ by_quan_list_cart: get_by_quan_list_cart }); + } else { + th.setData({ by_quan_list_cart: null }); + } + + console.log("2222222券的列表", quanlist); + th.setData({ + sele_cart_ind: cindx, + sele_exp_type: exp_type, + open_quan: 1, + selected_quan_pick: pickid, + selected_quan_list: quanlist, + disabled: 1 + }); + } + }, + close_coupon: function (e) { + var th = this; + th.setData({ open_quan: 0, disabled: 0 }); + }, + + /*--点击选择券--*/ + sele_quan_item: function (e) { + + var ind = e.currentTarget.dataset.ind; + var quan_item = this.data.selected_quan_list[ind]; + var pickid = this.data.selected_quan_pick; //现在选择的是哪一个门店 + //--如果券是单品使用的时候-- + if (quan_item && quan_item.UseObjectType && quan_item.UseObjectType == "20") { + //---只有多件购买的时候才要计算,//购物车购买和搭配勾的时候--- + var gg = getApp().get_b_now(); + if (this.data.is_b_now == 0 || gg.prom_type == 5) { + var arr = this.data.order_prom_list_cart; + var t_pk_item = null; + for (var ii in arr) { + var ep = arr[ii]; + if (pickid == ep.pickup_id) { + t_pk_item = ep; + break; + } + } + //--寻找券指定的商品-- + var gd = null; + if (t_pk_item) { + var goods = t_pk_item.goods; + for (var gid in goods) { + if (quan_item.UseObjectID == goods[gid].erpwareid) { + gd = goods[gid]; + } + } + } + if (!gd) { + getApp().my_warnning("未找到指定商品使用", 0, this, 600); + return false; + } + //计算价格,如果有平摊的实收要计算实收的金额 + var item_price = gd.goods_price * gd.goods_num; + //-- 如果有平摊下去,有实收价格的时候,就要用account_fir来计算价格 -- + if (gd.account_fir != null && gd.account_fir != undefined) { + item_price = gd.account_fir * gd.goods_num; + } + + if (item_price < parseFloat(quan_item.BuySum)) { + getApp().my_warnning("该单品金额没有大于等于" + quan_item.BuySum + "元时不能使用优惠券", 0, this, 600); + return false; + } + } + } + + var no_use = e.currentTarget.dataset.no, quanlist = this.data.selected_quan_list; + //---所有的券的显示红色选择都清理一遍--- + for (var i in quanlist) { + quanlist[i].show_red = 0; + } + this.setData({ selected_quan_list: quanlist }); + var by_quanlist = this.data.get_by_quan_list; + if (by_quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var inb in by_quanlist) { + by_quanlist[inb].show_red = 0; + } + this.setData({ get_by_quan_list: by_quanlist }); + } + + var by_cart_list = this.data.by_quan_list_cart; + if (by_cart_list) { + //---所有的券的显示红色选择都清理一遍--- + for (var inc in by_cart_list) { + by_cart_list[inc].show_red = 0; + } + this.setData({ by_quan_list_cart: by_cart_list }); + } + + var using_quan = this.data.using_quan; + var th = this; + //---如果是不使用优惠券--- + if (no_use == 1) { + console.log("有进来吗券", no_use); + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 1; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; + } + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); + return; + } + + + var txt = "selected_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + if (quan_item.show_red) { + obj[txt] = 0; + } + this.setData(obj); + console.log(this.data.selected_quan_list, "选中的券的下标", quan_item, "数据都在这里", txt); + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 0; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; + } + this.setData({ using_quan: using_quan }); + + }, + + /*----- 点击选择包邮券 -----*/ + sele_quan_item_by: function (e) { + var no_use = e.currentTarget.dataset.no; + //立即购买的包邮券 + var by_quanlist = this.data.get_by_quan_list; + if (by_quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var ind in by_quanlist) { + by_quanlist[ind].show_red = 0; + } + this.setData({ get_by_quan_list: by_quanlist }); + } + + //普通券 + var quanlist = this.data.selected_quan_list; + if (quanlist) { + //---所有的券的显示红色选择都清理一遍--- + for (var ind in quanlist) { + quanlist[ind].show_red = 0; + } + this.setData({ selected_quan_list: quanlist }); + } + + var th = this; + var using_quan = this.data.using_quan; + //---如果是不使用优惠券--- + if (no_use == 1) { + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 1; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 1 }; + } + this.setData({ using_quan: using_quan, is_coupon: th.is_coupon }); + return; + } + + var pickid = th.data.selected_quan_pick; //现在选择的是哪一个门店 + var ind = e.currentTarget.dataset.ind; + //--如果是立即购买的部分-- + var txt = ""; + var txt1 = ""; + var quan_item = null; + + quan_item = this.data.get_by_quan_list[ind]; + txt = "get_by_quan_list[" + ind + "].show_red"; + var obj = {}; + obj[txt] = 1; + this.setData(obj); + + + if (using_quan[th.data.selected_quan_pick]) { + using_quan[th.data.selected_quan_pick].is_nouse_red = 0; + } + else { + using_quan[th.data.selected_quan_pick] = { is_nouse_red: 0 }; + } + this.setData({ using_quan: using_quan }); + }, + + //--确认使用券--- + confirm_quan: function () { + var using_quan = this.data.using_quan; //正在使用中的券列表 + var pickid = this.data.selected_quan_pick; //选中的门店ID + var th = this; + var selected_quan_list = this.data.selected_quan_list; //选择了那个门店的券列表 + var get_by_quan_list = this.data.get_by_quan_list; //立即购买的包邮券列表 + var by_quan_list_cart = this.data.by_quan_list_cart; //购物车购买的包邮券列表 + //选择了的券 + var sele_quan = null; + + //循环普通的券 + for (var i in selected_quan_list) { + var item = selected_quan_list[i]; + if (item.show_red) { + th.insert_into_using_quan(item, using_quan, pickid); + return; + } + } + //循环包邮的券,立即购买的 + for (var i in get_by_quan_list) { + var item = get_by_quan_list[i]; + if (item.show_red) { + if (th.data.is_no_by[pickid] == 1) { + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th); + return false; + } + if (th.data.is_by[pickid] == 1) { + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th); + return false; + } + + th.insert_into_using_quan(item, using_quan, pickid, 1); + return; + } + } + + //循环包邮的券 + for (var i in by_quan_list_cart) { + var item = by_quan_list_cart[i]; + if (item.show_red) { + if (th.data.is_no_by[pickid] == 1) { + getApp().my_warnning("已全场不能包邮,不能选择包邮券", 0, th); + return false; + } + if (th.data.is_by[pickid] == 1) { + getApp().my_warnning("已全场包邮,不能选择包邮券", 0, th); + return false; + } + th.insert_into_using_quan(item, using_quan, pickid, 1); + return; + } + } + + //选择了的券,看是不是点击了不使用券,点击了不使用优惠券 + if (using_quan[pickid]) { + if (using_quan[pickid].is_nouse_red == 1) { + using_quan[pickid] = { is_nouse_red: 1 }; + th.setData({ using_quan: using_quan }); + th.calculatePrice2(); + th.setData({ open_quan: 0 }); + return; + } + } + }, + + //----把券插入之后的操作,同时还要重新计算价格---- + insert_into_using_quan: async function (item, using_quan, pickid, isby) { + + + var th = this; + var old_quan = null; + if (isby == 1) { + using_quan[pickid] = { + coupon_no: item.no, + money: 0, + is_nouse_red: 0, + region_list: item.region_list, + goods_list: item.goods_list + }; + using_quan[pickid].isby = 1; + } else { + if (using_quan[pickid]) old_quan = using_quan[pickid]; + using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; + using_quan[pickid].isby = 0; + } + this.setData({ using_quan: using_quan }); + + th.calculatePrice2(function () { + + if (old_quan) using_quan[pickid] = old_quan; + else using_quan[pickid] = null; + th.setData({ using_quan: using_quan, submit: 0 }); + wx.showToast({ + title: "不能使用优惠券,同城起送价不足", + icon: 'none', + duration: 2000 + }) + + }); + + th.setData({ open_quan: 0 }); + }, + + + }) \ No newline at end of file diff --git a/packageE/pages/cart/cart_wk/cart_wk.wxml b/packageE/pages/cart/cart_wk/cart_wk.wxml index 4c07a0b..ac8000d 100644 --- a/packageE/pages/cart/cart_wk/cart_wk.wxml +++ b/packageE/pages/cart/cart_wk/cart_wk.wxml @@ -1,4 +1,5 @@ + @@ -67,6 +68,23 @@ + + + 选择物流: @@ -103,6 +121,14 @@ ¥{{order.tail_money}} + + + 使用优惠券 + + - ¥ {{formData.coupon_price}}元 + + + 配送费用 @@ -134,7 +160,7 @@ 支付合计: ¥{{filters.toFix(order.tail_money+exp_price,2)}} --> - 支付合计:¥{{filters.toFix(order.tail_money+exp_price-(bn_use_commission?goods.use_commission:0)-(formData.order_prom_amount?formData.order_prom_amount:0) ,2)}} + 支付合计:¥{{filters.toFix(order.tail_money+exp_price-formData.coupon_price-(bn_use_commission?goods.use_commission:0)-(formData.order_prom_amount?formData.order_prom_amount:0) ,2)}} 支付尾款 @@ -201,3 +227,121 @@ + + + + + + + + 优惠券使用 + + + × + + + + 可使用的优惠券 + 不使用优惠券 + + Γ + + + + + + + + + + + + + + + + + + + {{item.Sum}} + 满{{item.BuySum}}元可用 + 满0元可用 + + + + + + + + + {{filter.get_type_card(item.UseObjectType)}} + {{item.Sum}}元优惠券 + + {{filters.replace_time2(item.BeginDate)}}至{{item.ValidDate?filters.replace_time2(item.ValidDate):'不限'}} + + + + Γ + + + + + + + + + + + + + + + + + + + + + + + 包邮券 + 满{{item.condition}}元可用 + 满0元可用 + + + + + + + + + {{filter.get_type_card(0)}} + 包邮券 + + {{filters.format_time(item.use_start_time)}}至{{item.use_end_time?filters.format_time(item.use_end_time):'不限'}} + + + + Γ + + + + + + + + + + + + + + + + + + + 确定 + + + diff --git a/packageE/pages/cart/cart_wk/cart_wk.wxss b/packageE/pages/cart/cart_wk/cart_wk.wxss index bd6b927..8b1375a 100644 --- a/packageE/pages/cart/cart_wk/cart_wk.wxss +++ b/packageE/pages/cart/cart_wk/cart_wk.wxss @@ -1,3 +1,5 @@ +@import "../cart2/cart2.wxss"; + page{ color: #333;} .bdr_t-14 { border-top-left-radius: 14rpx; diff --git a/packageE/pages/user/monthgiftbag/giftpackbuy/giftpackbuy.wxss b/packageE/pages/user/monthgiftbag/giftpackbuy/giftpackbuy.wxss index 660b7da..cd06d37 100644 --- a/packageE/pages/user/monthgiftbag/giftpackbuy/giftpackbuy.wxss +++ b/packageE/pages/user/monthgiftbag/giftpackbuy/giftpackbuy.wxss @@ -168,6 +168,7 @@ page { background: #d41c34; color: #fff; border-radius: 10rpx; + font-size:25rpx; } .foot_box { diff --git a/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.js b/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.js index 2b68e58..449040a 100644 --- a/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.js +++ b/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.js @@ -609,8 +609,9 @@ Page({ }, "put" ) - }, + + //界面跳转 goto: function (e) { var th = this; diff --git a/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.wxml b/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.wxml index a63526c..c1ccd4b 100644 --- a/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.wxml +++ b/packageE/pages/user/monthgiftbag/giftpacklist/giftpacklist.wxml @@ -152,7 +152,34 @@ - + + + + + + + 无核销商品 + + + + + 兑换未开始 + + + 立即使用 + + + 商品已核销 + + + 商品兑换时间已过 + + + + + + + - - - - - 无核销商品 - - - - - 兑换未开始 - - - 立即使用 - - - 商品已核销 - - - 商品兑换时间已过 - - - - + + + diff --git a/packageE/pages/user/monthgiftbag/monthgiftbag.js b/packageE/pages/user/monthgiftbag/monthgiftbag.js index dff32bc..ab6ffa9 100644 --- a/packageE/pages/user/monthgiftbag/monthgiftbag.js +++ b/packageE/pages/user/monthgiftbag/monthgiftbag.js @@ -3,9 +3,11 @@ var e = getApp(), a = e.globalData.setting, os = a, t = e.request, - d = e.globalData; + d = e.globalData,ut=i; + Page({ data: { + url: a.url, //接口网址 iurl: a.imghost, //图片前缀网址 getDate: "", getStorageID: '', @@ -118,7 +120,8 @@ Page({ user_id: th.data.getUserID, //用户ID page: th.data.curpage, pageSize: th.data.pageSize, - pay_state:1 + pay_state:1, + isdetail:1 }; if(this.data.sear_key){ @@ -157,6 +160,44 @@ Page({ // arr2[j].virtualsales=arr2[j].virtualSales // arr2[j].lbnum=arr2[j].lbNum + + + + if(!arr2[j].receive_ordersn){ + arr2[j].is_no_rev=1; + } + + arr2[j].is_detail=0; + if(arr2[j].detaillist){ + arr2[j].is_detail=1; + }else{ + continue; + } + + + + arr2[j].lbType=0; + if(arr2[j].detaillist.iswarelbtype){ + arr2[j].lbType=1; + } + //---获取日期的时间戳--- + var t_endtime = arr2[j].detaillist.endTime; + t_endtime = t_endtime.replace(/-/g, '/'); + var t_date = new Date(t_endtime) / 1000; + var t_now = ut.gettimestamp(); + + var t_starttime = arr2[j].detaillist.starTime; + t_starttime = t_starttime.replace(/-/g, '/'); + var t_sdate = new Date(t_starttime) / 1000; + + arr2[j].c_state=0 + if (arr2[j].detaillist.goodsUseState) + arr2[j].c_state=1 + else if (t_date <= t_now) + arr2[j].c_state=2 + else if (t_sdate > t_now) + arr2[j].c_state=-1 + } @@ -260,7 +301,101 @@ Page({ input_sear(e){ let value = e.detail; this.data.sear_key=value; - } + }, + + //-- 获取核销码 --- + getcode: function (e) { + var th = this; + let codeId = e.currentTarget.dataset.codeid; + let orderSn = e.currentTarget.dataset.ordersn; + var json = { + "storeId": a.stoid, + "orderSn": orderSn, + } + if (codeId && codeId !== "") { + json.id = codeId + } + var data = JSON.stringify(json); + var url = th.data.url + "/api/weshop/marketing/gift/goods/verify/code/get"; //预约接口地址 + getApp().request.json_post(url, json, + function (res) { + if (res.data.code == 0) { + th.setData({ + code: res.data.data + }) + th.code_show(); + } else { + getApp().my_warnning(res.data.msg, 0, th); + } + }, + function (res) { + + }, + "put" + ) + }, + + //显示核销码 + code_show: function (e) { + var th = this; + //--获取成功的时候-- + var no = th.data.code; + var qc_com = th.selectComponent("#qc_com"); //组件的id + var obj = { + val: no, + content: "请将二维码展示给核销员,收货更快捷" + }; + qc_com.open(obj) + }, + + getGift(e){ + var that=this; + if (that.data.islogin) { + return + } + that.setData({ + islogin:true + }) + + var record_list_id=e.currentTarget.dataset.record_list_id; + var index=e.currentTarget.dataset.index; + + var json = { + "id":record_list_id,// "记录Id", + "storeId": that.data.getStorageID, //商家Id + "userId": that.data.getUserID, //用户ID + }; + // var url ="/api/weshop/marketing/buy/receive/gift/record/insert"; + // var url ="/api/weshop/marketing/marketingMonthgiftbagRecord/createOrder"; + var url ="/api/weshop/marketing/marketingMonthgiftbagRecord/recordReceive"; + getApp().request.json_post(url, json, + function (res) { + console.log('领取礼包'); + console.log(res); + if (res.data.code == 0 && res.data.data) { + + var txt="wareCard["+index+"]is_receive"; + that.setData({ + [txt]:1 + }) + getApp().my_warnning("领取成功!", 1, that); + + } else { + that.setData({submit:0}) + getApp().my_warnning(res.data.msg, 0, that); + } + that.setData({ + islogin:false + }) + }, + function (res) { + that.setData({submit:0}) + } + ) + }, + + + }); \ No newline at end of file diff --git a/packageE/pages/user/monthgiftbag/monthgiftbag.json b/packageE/pages/user/monthgiftbag/monthgiftbag.json index 80007bc..66bbc8e 100644 --- a/packageE/pages/user/monthgiftbag/monthgiftbag.json +++ b/packageE/pages/user/monthgiftbag/monthgiftbag.json @@ -4,6 +4,7 @@ "usingComponents": { "warn": "/components/long_warn/long_warn", "my_confirm": "/components/my_confirm/my_confirm", - "lb_sear": "/components/lb_sear/lb_sear" + "lb_sear": "/components/lb_sear/lb_sear", + "qr_code": "/components/qr_code/qr_code" } } \ No newline at end of file diff --git a/packageE/pages/user/monthgiftbag/monthgiftbag.wxml b/packageE/pages/user/monthgiftbag/monthgiftbag.wxml index 2fe4634..db5585e 100644 --- a/packageE/pages/user/monthgiftbag/monthgiftbag.wxml +++ b/packageE/pages/user/monthgiftbag/monthgiftbag.wxml @@ -103,9 +103,40 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 已退款 @@ -134,4 +165,6 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/packageE/pages/user/monthgiftbag/monthgiftbag.wxss b/packageE/pages/user/monthgiftbag/monthgiftbag.wxss index f82a934..e460b16 100644 --- a/packageE/pages/user/monthgiftbag/monthgiftbag.wxss +++ b/packageE/pages/user/monthgiftbag/monthgiftbag.wxss @@ -184,8 +184,20 @@ background: #d41c34; color: #fff; line-height: 50rpx; + border-radius:10rpx; + border: none; } + + +.content_box_button button.white { + + background: #fff; + color: #666; + +} + + .foot_box { -webkit-align-content: center; align-content: center; @@ -251,3 +263,12 @@ page { .After_all .end { margin: 0rpx 15rpx; } + + +.content_box_button button.overdue{ + background: rgb(153,153,153); +} + +.content_box_button button.overdue::after{ + border: none; +} \ No newline at end of file diff --git a/pages/goods/goodsInfo/buy_com_pop.wxml b/pages/goods/goodsInfo/buy_com_pop.wxml index eb86ef4..4ab63e1 100644 --- a/pages/goods/goodsInfo/buy_com_pop.wxml +++ b/pages/goods/goodsInfo/buy_com_pop.wxml @@ -72,7 +72,7 @@ - + 库存不足 diff --git a/pages/goods/goodsInfo/buy_pt.wxml b/pages/goods/goodsInfo/buy_pt.wxml index 8d0de58..03015ca 100644 --- a/pages/goods/goodsInfo/buy_pt.wxml +++ b/pages/goods/goodsInfo/buy_pt.wxml @@ -85,7 +85,7 @@ diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index a4664d2..8493c46 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -151,10 +151,14 @@ Page({ prom_type: 0, prom_time_text: "", prom_price: null, + f_prom_price: null, //秒杀使用 prom_buy_limit: 0, djs: null, prom_st: 0, + f_prom_st: 0, prom_r_null: 0, + f_prom_r_null: 0, + prom_end_time: null, prom_start_time: null, prom_act: null, @@ -285,6 +289,9 @@ Page({ istop: 0, //是否置顶风格为1 searchbox_transparent: 1, template_id:[],//订阅消息id + + fir_set_sto:1, //最初始的一下,获取门店 + front_pick:null, //在详情页面上显示的门店 }, //------初始化加载---------- @@ -1020,6 +1027,10 @@ Page({ var ee = this, gid = this.data.gid, i = getApp().request; + if(this.data.front_g){ + gid = this.data.front_g.goods_id; + } + this.wait_for_store_config(); //先检验一下商品的活动情况 @@ -1192,7 +1203,8 @@ Page({ ee.setData({ data: t.data.data, sele_g: t.data.data, - userInfo: getApp().globalData.userInfo + userInfo: getApp().globalData.userInfo, + front_g: ut.deep_cp(t.data.data), }); //获取统一条形码,普通商品和优惠促销的商品 @@ -1224,8 +1236,13 @@ Page({ } ee.data.g_buy_num = new Map(); + + //再返回的时候,prom_id要以f_prom_act为准 + var c_prom_id=ee.data.data.prom_id; + if(ee.data.f_prom_act) c_prom_id=ee.data.f_prom_act.id; + //-- 增加相同的活动 -- - ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); + ee.check_prom(gid, ee.data.data.prom_type, c_prom_id); var th = ee; if (ee.data.cat_name == '') { @@ -1968,7 +1985,7 @@ Page({ // }) // } //要包含积分购的普通购买0 3,5,7,10, is_integral_normal积分普通购买字段 - else if ([0, 3, 5, 7, 10].indexOf(th.data.prom_type) > -1 || newd.is_integral_normal) { + else if ([0, 3, 5, 7, 10].indexOf(th.data.prom_type) > -1 || newd.is_integral_normal || newd.is_pd_normal) { newd.prom_type = 0; newd.prom_id = 0; @@ -2019,6 +2036,7 @@ Page({ return false; //return s.my_warnning("库存不足!", 0, th); } + th.add_cart_next(e, t, a, o, newd); //加入购物车下一步 } } @@ -2272,6 +2290,7 @@ Page({ openSpecModal_inte: 0, openSpecModal_inte_normal: 0, openSpecModal_pt: 0, + openSpecModal_flash_normal:0 }) if (e.prom_type == 4) { @@ -2710,11 +2729,11 @@ Page({ closeSpecModal: function () { if (this.data.openSpecModal_pt && this.data.is_normal) { - this.get_sto(); this.setData({ - sele_g: this.data.data, - gid: this.data.data.goods_id + sele_g: this.data.front_g, + gid: this.data.front_g.goods_id }) + this.get_sto(); this.sele_spec_chech_activity(1); } @@ -2738,6 +2757,8 @@ Page({ return false; } + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); + this.setData({ store: 0, choice_sort_store: 0, @@ -2754,6 +2775,7 @@ Page({ } var check_up = 0; + //-- 如果是当前商品的时候 -- if (th.data.more_flash) { for (var i in th.data.more_flash) { var item = th.data.more_flash[i]; @@ -3383,7 +3405,7 @@ Page({ return false; } - this.setData({sp_seleing:1}) + this.setData({sp_seleing:1,more_flash:null}) var that = this; var th = this; @@ -3466,8 +3488,9 @@ Page({ item['disc'] = txt; if (item) this.setData({ sele_g: item, - gid: gid, data: item, + //gid: gid, //只去掉gid的更新 + }); @@ -3914,21 +3937,23 @@ Page({ } if(func) func(); }else{ - if(func) func(); th.setData({sp_seleing:0}) wx.hideLoading(); + th.data.fir_set_sto=0; } } else { if(func) func(); th.setData({sp_seleing:0}) wx.hideLoading(); + th.data.fir_set_sto=0; } },err=>{ ut.m_toast('网络繁忙,请稍后重试'); if(func) func(); th.setData({sp_seleing:0}) wx.hideLoading(); + th.data.fir_set_sto=0; }) }, 200) @@ -4035,6 +4060,28 @@ Page({ } }, + + + //处理首页的显示门店 + deal_front_pk(){ + var th=this; + if(this.data.fir_set_sto==1){ + this.data.fir_set_sto=0; + var cp_data=null + if(th.data.def_pick_store && th.data.def_pick_store.pickup_id){ + cp_data=JSON.parse(JSON.stringify(th.data.def_pick_store)); + } + th.setData({ + front_pick:cp_data, + front_only_pk:th.data.only_pk, + front_def_pickpu_list:th.data.def_pickpu_list, + front_pickpu_listt:th.data.pickpu_list, + front_all_sto:th.data.all_sto, + front_is_show_sto_cat:th.data.is_show_sto_cat, + }) + } + }, + //------------处理门店--------------- deal_pickup(e) { var th = this; @@ -4227,6 +4274,11 @@ Page({ }) } } + + + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); + } else { th.setData({ is_show_sto_cat: -1, @@ -4242,6 +4294,9 @@ Page({ }) } + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); + } } }); @@ -4259,7 +4314,11 @@ Page({ sto_sele_distr: e.data.data.pageData[0].distr_type }) } + + //-- 设置商品详情页面的门店显示情况 --- + th.deal_front_pk(); } + }, //------------处理线下门店库存-------- @@ -4366,6 +4425,7 @@ Page({ } else { + th.data.fir_set_sto=0; th.setData({ all_sto: null, only_pk: null, @@ -4463,7 +4523,8 @@ Page({ th.deal_pickup(em); } else { - + + th.data.fir_set_sto=0; th.setData({ all_sto: null, only_pk: null, @@ -4473,6 +4534,7 @@ Page({ } else { + th.data.fir_set_sto=0; th.setData({ all_sto: null, only_pk: null, @@ -4749,7 +4811,9 @@ Page({ if (em.data.code == 0) { if (em.data.data <= 0) ee.setData({ - prom_r_null: 1,pro_null:1 + prom_r_null: 1, + f_prom_r_null: 1, + pro_null:1, }); //拿取价格并且判断时间-- getApp().request.get("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, { @@ -4784,10 +4848,12 @@ Page({ ee.setData({ prom_price: t.data.data.user_price, + f_prom_price: t.data.data.user_price, prom_type: 1, prom_id: prom_id, prom_buy_limit: t.data.data.buy_limit, prom_act: t.data.data, + f_prom_act: t.data.data, prom_end_time: prom_end_time, prom_start_time: prom_start_time, isshow: 1, @@ -4806,7 +4872,8 @@ Page({ if (endTime2 > newTime) { ee.setData({ prom_time_text: '距秒杀结束还有', - prom_st: 1 + prom_st: 1, + f_prom_st: 1 }) ee.countDown(endTime2); } @@ -5248,7 +5315,8 @@ Page({ var endTime2 = th.data.prom_act.end_time; th.setData({ prom_time_text: '距结束还剩:', - prom_st: 1 + prom_st: 1, + f_prom_st: 1, }) setTimeout(function () { th.countDown(endTime2) @@ -5265,7 +5333,8 @@ Page({ } th.setData({ prom_time_text: '活动已经结束:', - prom_st: 3 + prom_st: 3, + f_prom_st: 3 }) th.setData({ djs: obj @@ -5416,9 +5485,9 @@ Page({ //如果是拼单活动的普通购买 if (ind == 1) { - - //要把不匹配还原 - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ + if(th.data.front_pick){ + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); + }else if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ //要把不匹配还原 th.data.def_pick_store.is_no_dis_nor=0; th.setData({def_pick_store:th.data.def_pick_store}) } @@ -5870,6 +5939,14 @@ Page({ //----------立即购买_pt----------- buyNow_pt: function (e) { + this.setData({ + openSpecModal: 0, + openSpecModal_inte: 0, + openSpecModal_inte_normal: 0, + openSpecModal_pt: 0, + openSpecModal_flash_normal:0 + }) + wxlog.info(getApp().globalData.user_id+'-拼团立即购买:'+JSON.stringify(e)); s.set_b_now(e); @@ -5994,7 +6071,7 @@ Page({ } else { console.log(222, goods_id) wx.navigateTo({ - url: "/pages/team/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, + url: "/packageG/pages/team/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, }); } } @@ -6002,7 +6079,7 @@ Page({ else { console.log(1111, th.data.goods_id) wx.navigateTo({ - url: "/pages/team/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, + url: "/packageG/pages/team/team_show/team_show?tg_id=" + id + "&goods_id=" + goods_id, }); } } @@ -7299,6 +7376,11 @@ Page({ choice_store: function (ee) { var th = this; var ind = ee.currentTarget.dataset.ind; + var isfront = ee.currentTarget.dataset.isfront; + + th.data.isfront=0; + if(isfront) th.data.isfront=1; + var bconfig = th.data.bconfig; this.setData({ keyword:'' @@ -7318,40 +7400,92 @@ Page({ return false; } - if (!th.data.only_pk && !th.data.def_pickpu_list && !th.data.change) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } - th.data.change = 0; + if(th.data.isfront==1){ - if (th.data.only_pk && !th.data.only_pk.length) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } - if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { - // getApp().confirmBox("门店库存不足", null, 25000, !1); - wx.showToast({ - title: '门店库存不足', - icon: 'none', - }); - return false; - } + if (!th.data.front_only_pk && !th.data.front_def_pickpu_list && !th.data.change) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + th.data.change = 0; + + if (th.data.front_only_pk && !th.data.front_only_pk.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + if (th.data.front_def_pickpu_list && !th.data.front_def_pickpu_list.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + + //-- 把默认的数据拿过来,数据传递要用深拷贝 -- + th.setData({ + def_pick_store: ut.deep_cp(th.data.front_pick), + only_pk:ut.deep_cp(th.data.front_only_pk), + def_pickpu_list:ut.deep_cp(th.data.front_def_pickpu_list), + pickpu_list:ut.deep_cp(th.data.front_pickpu_listt), + all_sto:ut.deep_cp(th.data.front_all_sto), + is_show_sto_cat:th.data.front_is_show_sto_cat + }) + + + this.setData({ + open_ind_store: ind, + store: 1, + openSpecModal: !1, + openSpecModal_pt: !1, + openSpecModal_flash_normal: !1, + }) - //如果开启了,则不在选择门店 - if (th.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store) { return false; + + + }else{ + if (!th.data.only_pk && !th.data.def_pickpu_list && !th.data.change) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + th.data.change = 0; + + if (th.data.only_pk && !th.data.only_pk.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + if (th.data.def_pickpu_list && !th.data.def_pickpu_list.length) { + // getApp().confirmBox("门店库存不足", null, 25000, !1); + wx.showToast({ + title: '门店库存不足', + icon: 'none', + }); + return false; + } + } + + + if (bconfig && bconfig.is_sort_storage) { wx.getLocation({ type: 'gcj02', @@ -7496,12 +7630,18 @@ Page({ check_the_pick(item, func) { var th = this; var goodsinfo = th.data.sele_g; + + if(th.data.isfront){ + goodsinfo=this.data.front_g; + } + + var erpwareid = goodsinfo.erpwareid; var plist = null; var lock = 0; //---如果是活动的时候,同时不是普通购买--- - if (getApp().is_virtual(th.data.sele_g) || th.data.sele_g.whsle_id || ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) > -1 && !th.data.is_normal)) { + if (getApp().is_virtual(goodsinfo) || goodsinfo.whsle_id || ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) > -1 && !th.data.is_normal)) { func(); return false; } @@ -7630,6 +7770,10 @@ Page({ if (!th.data.sele_g) return false; //判断门店的配送方式是不是匹配 var g_distr_type = th.data.sele_g.distr_type; + if(th.data.isfront==1){ + g_distr_type = th.data.data.distr_type; + } + if (item.distr_type != 0 && g_distr_type != 0 && item.distr_type != g_distr_type) { wx.showToast({ title: "门店配送方式不匹配,请选择其他门店", @@ -7651,6 +7795,14 @@ Page({ fir_pick_index: 0 }); + + if(th.data.isfront){ + th.setData({ + front_pick: ut.deep_cp(item) + }) + } + + switch (openindstore) { case 1: th.setData({ @@ -7776,6 +7928,14 @@ Page({ choice_sort_store: 0 }); + if(th.data.isfront){ + th.setData({ + front_pick: ut.deep_cp(item) + }) + } + + + var openindstore = th.data.open_ind_store; if (openindstore == 1) { th.setData({ @@ -8138,11 +8298,23 @@ Page({ th.data.collocationGoods = r_data.collocationPromList; th.data.prom_goods = r_data.promGoodsLists; } else { - th.setData({ - order_prom: r_data.promOrder, - collocationGoods: r_data.collocationPromList, - prom_goods: r_data.promGoodsLists, - }) + + if(gid==th.data.front_g){ + th.setData({ + order_prom: r_data.promOrder, + f_order_prom: r_data.promOrder, + collocationGoods: r_data.collocationPromList, + prom_goods: r_data.promGoodsLists, + }) + }else{ + th.setData({ + order_prom: r_data.promOrder, + collocationGoods: r_data.collocationPromList, + prom_goods: r_data.promGoodsLists, + }) + } + + } @@ -8248,9 +8420,21 @@ Page({ //使用sort排序 ppdata.sort(comp); - th.setData({ - cx_prom_group: ppdata - }) + + //-- 如果是前端商品的时候 -- + if(th.data.sele_g.goods_id==th.data.front_g.goods_id){ + th.setData({ + cx_prom_group: ppdata, + f_cx_prom_group: ppdata, + }) + + }else{ + th.setData({ + cx_prom_group: ppdata + }) + } + + }) }, @@ -8345,8 +8529,12 @@ Page({ }, - //-- 积分购 -- + //-- 积分购购买弹出框 -- go_pay_integral: function () { + + //-- 在打开弹出框的时候,front_pk门店要赋值 -- + this.setData({def_pick_store: ut.deep_cp(this.data.front_pick)}); + this.data.g_buy_num = new Map(); this.get_sto(0) this.setData({ @@ -8355,14 +8543,15 @@ Page({ }); }, - //-- 积分购普通购买 -- + //-- 积分购普通购买弹出框 -- go_pay_integral_normal:async function () { this.data.g_buy_num = new Map(); var th = this; - //要把不匹配还原 - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ + if(th.data.front_pick){ + th.setData({def_pick_store: ut.deep_cp(th.data.front_pick)}); + }else if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){ //要把不匹配还原 th.data.def_pick_store.is_no_dis_nor=0; th.setData({def_pick_store:th.data.def_pick_store}) } @@ -8400,13 +8589,12 @@ Page({ this.setData({ openSpecModal_inte_normal: 0 }); - //要进行还原 - this.get_sto(); + //要进行还原 this.setData({ - sele_g: this.data.data, - gid: this.data.data.goods_id + sele_g: ut.deep_cp(this.data.front_g), + gid: this.data.front_g.goods_id }) - + this.get_sto(); this.sele_spec_chech_activity(); }, @@ -8701,9 +8889,20 @@ Page({ // th.data.prom_type = new_arr[0].prom_type; // } - th.setData({ - more_flash: new_arr - }); + //-- 如果是前端商品的时候 -- + if(gid==th.data.front_g.goods_id){ + th.setData({ + more_flash: new_arr, + f_more_flash: new_arr, + }); + + }else{ + th.setData({ + more_flash: new_arr + }); + } + + } }) }, @@ -8712,7 +8911,12 @@ Page({ go_more_flash: function (e) { var prom_id = e.currentTarget.dataset.id; var prom_type = e.currentTarget.dataset.prom_type; - var goods_id = this.data.data.goods_id; + var is_sele = e.currentTarget.dataset.is_sele; + var goods_id=this.data.front_g.goods_id; + if(is_sele){ + goods_id=this.data.sele_g.goods_id; + } + var url = ""; switch (parseInt(prom_type)) { diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index a11ce83..874237f 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -83,40 +83,41 @@ - + - + - 距活动结束还有 - 距活动开始还有 + 距活动结束还有 + 距活动开始还有 - + {{djs.day}} - + - + {{djs.hou}} - - + + {{djs.min}} - - + + {{djs.sec}} - + - + + ¥{{prom_price}} - 零售价:¥{{filters.toFix(data.market_price,2)}} - ¥{{filters.toFix(data.shop_price,2)}} + 零售价:¥{{filters.toFix(front_g.market_price,2)}} + ¥{{filters.toFix(front_g.shop_price,2)}} @@ -143,8 +144,8 @@ {{prom_price}} - 零售价:¥{{filters.toFix(data.market_price,2)}} - ¥{{filters.toFix(data.shop_price,2)}} + 零售价:¥{{filters.toFix(front_g.market_price,2)}} + ¥{{filters.toFix(front_g.shop_price,2)}} @@ -199,7 +200,7 @@ - {{data.goods_name}} + {{front_g.goods_name}}