diff --git a/packageE/pages/cart/cart2_pt/cart2_pt.js b/packageE/pages/cart/cart2_pt/cart2_pt.js
index bd364bf..fc6f308 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,142 @@ 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);
- var wl_txt = "formData.shipping_price";
- th.setData({ [wl_txt]: shipping_price, })
+ }
}
} else if (th.data.bn_exp_type == 1) {
var wl_txt = "formData.shipping_price";
@@ -1140,6 +1274,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 +1285,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 +1405,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 +1829,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 @@