diff --git a/app.js b/app.js
index f4fc4b8..82afd1c 100644
--- a/app.js
+++ b/app.js
@@ -51,7 +51,7 @@ App({
config2: null, //门店配置
code: null,
heigth:0,
- user_id:null,// 3674923,// 4379287,// null,// 5682068,
+ user_id:null,//13324010,//4755274,
buy_now:null,
picklist:null, //门店列表
wuliuprice: null, //物流价格表
@@ -618,6 +618,7 @@ App({
this.globalData.config2=null; //清除config2的缓存
this.globalData.config=null; //清除config的缓存
this.globalData.gr_index=0; //商品分组的序列
+ this.globalData.pk_store=null;
},
@@ -726,7 +727,9 @@ App({
},
-
+
+
+
});
diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js
index 82834e8..998c2b7 100644
--- a/packageB/pages/zuhegou/index/index.js
+++ b/packageB/pages/zuhegou/index/index.js
@@ -2,6 +2,7 @@ const app = getApp();
let self = null;
var os = app.globalData.setting;
var ut = require("../../../../utils/util.js");
+var regeneratorRuntime = require('../../../../utils/runtime.js');
var oo = app.globalData;
@@ -105,7 +106,7 @@ Page({
page: 1, //第一页
no_more: 0, //没有更多
loading: 0, //加载中
- list: [], //商品列表的显示
+ list:null, //商品列表的显示
act: null, //组合活动
all_price: 0, //合计价格
all_num: 0, //全部数量
@@ -179,8 +180,8 @@ Page({
}
//等待活动值
- this.waitfor2(10, 'act', function () {
- if(!th.data.act) return false;
+ this.waitfor2(10, 'list', function () {
+ if(!th.data.list) return false;
if(ut.gettimestamp()
= 2) {
var check_num = num - 1;
@@ -615,7 +622,7 @@ Page({
if(th.data.s_cart_num){
var updata = {
id: th.data.sele_g.cart_id,
- goods_num:h.data.s_cart_num ,
+ goods_num:th.data.s_cart_num ,
store_id: os.stoid
}
getApp().request.put("/api/weshop/cart/update", {
@@ -643,7 +650,7 @@ Page({
if (res.data.code == 0) {
var title = '移除购物车成功';
th.setData({
- [txt1]: 1,
+ [txt1]: 0,
[txt2]: false,
[txt]: false,
});
@@ -1599,7 +1606,7 @@ Page({
data: updata,
success: function (t) {
th.setData({
- [txt1]: updata.goods_num,
+ [txt1]: th.data.goodsInputNum,
[txt2]: true,
[txt]: true,
});
@@ -1784,7 +1791,7 @@ Page({
}
//看一下剩下的数量有没有满足组合购的要求,以及要不要倍增
- if (this.data.act.is_bz && no_in_arr.length > this.data.act.zhbuyqty) {
+ if (this.data.act.is_bz && no_in_arr.length >= this.data.act.zhbuyqty) {
//看一下是几倍
var be = parseInt(no_in_arr.length / this.data.act.zhbuyqty);
aprice += be * aprice;
@@ -1810,13 +1817,100 @@ Page({
})
if(all_num<=0){
- th.data.sele_store = 0; //什么都没有选,就没有选择了门店
+ this.data.sele_store = 0; //什么都没有选,就没有选择了门店
}
},
go_cart:function () {
getApp().goto("/pages/cart/cart/cart");
+ },
+
+ //获取购物车中,相应的门店已购买的商品
+ get_cart_val:function (e) {
+ var th=this;
+ var user_id=getApp().globalData.user_id;
+ var req={
+ user_id: user_id,
+ store_id: os.stoid,
+ pageSize: 600,
+ state:0,
+ prom_type:7,
+ prom_id:this.data.act.id
+ };
+ //获取购物车列表
+ getApp().request.get("/api/weshop/cart/list",{
+ data:req,
+ success: async function(e) {
+ if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length) {
+ var map={};
+ var mlist=e.data.data.pageData;
+ for(let i in mlist){
+ let item=mlist[i];
+ if(item.prom_type!=7) continue;
+ if(item.prom_id!=th.data.act.id) continue;
+ map[item.goods_id]=item;
+ }
+ for(let j in th.data.list){
+ let item_j=th.data.list[j];
+ item_j.current_price=item_j.shop_price;
+
+ var card_price=0;
+ //如果会员有等级价
+ if (th.data.card_field) {
+ card_price = item_j[th.data.card_field];
+ if (card_price > 0) {
+ item_j.current_price=card_price;
+ }
+ }
+
+
+ if(map[item_j.goods_id]){
+ var cart_num=map[item_j.goods_id].goods_num;
+ item_j.num=cart_num;
+ item_j.cart_num=cart_num;
+ item_j.cart_id=map[item_j.goods_id].id;
+ if(item_j.buyqty>0){
+ var g_buy_num=0;
+ var promgoodsbuynum=0;
+ //----获取商品购买数----
+ await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
+ data: {
+ store_id: os.stoid,
+ user_id: user_id,
+ goods_id: item_j.goods_id,
+ prom_type: 7,
+ prom_id: th.data.act.id
+ },
+ }).then(res2=>{
+ if (res2.data.code == 0) {
+ var buy_num_data = res2.data.data;
+ if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
+ g_buy_num = buy_num_data.goodsbuynum;
+ }
+ })
+
+ if(item_j.viplimited>0){
+ var cby=item_j.viplimited-g_buy_num;
+ if(cby<=0) continue;//不能买就continue下一个
+ item_j.num=cby>item_j.num?item_j.num:cby;
+ }
+ if(item_j.buyqty>0){
+ var cby=item_j.buyqty-promgoodsbuynum;
+ if(cby<=0) continue;//不能买就continue下一个
+ item_j.num=cby>item_j.num?item_j.num:cby;
+ }
+ }
+
+ item_j.haveAdded=1;
+ item_j.showNum=true;
+ }
+ }
+ th.setData({list:th.data.list});
+ th.re_sum_price();
+ }
+ }
+ });
}
})
\ No newline at end of file
diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js
index da1e3fd..a626a1a 100644
--- a/pages/cart/cart/cart.js
+++ b/pages/cart/cart/cart.js
@@ -468,7 +468,16 @@ Page({
var list=arr[i];
await th.set_offline(list);
}
- }
+ }else{
+ //-- 此时要实时更新线下取价价格 --
+ for(var i=0;i0) {
isok = 0;
gname = val.goods_name;
throw "商品价格已经变化";
diff --git a/pages/cart/cart/zh_calculate.js b/pages/cart/cart/zh_calculate.js
index ddb81fc..ad2fc1a 100644
--- a/pages/cart/cart/zh_calculate.js
+++ b/pages/cart/cart/zh_calculate.js
@@ -119,11 +119,11 @@ module.exports = {
item.offline_price=get_num(item).offline_price;
var cart_num=get_num(item).goods_num;
var zh_b_num=get_num2(item).zh_b_num;
+ if(!cart_num) continue;
item.cart_num =cart_num;
//-- 当商品有购买的时候,以及有限购的时候 --
- if(zh_b_num>0 && item.buyqty>0){
-
+ if(item.buyqty>0){
var cbuy=item.buyqty-zh_b_num;
//当可买的数量为0
if(cbuy<=0){
diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js
index 7778475..9fe8737 100644
--- a/pages/cart/cart2/cart2.js
+++ b/pages/cart/cart2/cart2.js
@@ -419,6 +419,28 @@ Page({
for (var i = 0; i < carr.length; i++) {
var item1 = carr[i];
+ //把已经购买了多少见的内容填入
+
+ var goodsbuynum=0,promgoodsbuynum=0;
+ //--要获得商品,该用户买了多少件,同步应用--
+ await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
+ data: {
+ store_id: os.stoid,
+ user_id: getApp().globalData.user_id,
+ goods_id: item1.goods_id,
+ prom_type: item1.prom_type,
+ prom_id: item1.prom_id
+ },
+ }).then(res => {
+ var buy_num_data = res.data.data;
+ if (buy_num_data.promgoodsbuynum) {
+ promgoodsbuynum = buy_num_data.promgoodsbuynum;
+ }
+ goodsbuynum = buy_num_data.goodsbuynum;
+ })
+ //如果有购买活动
+ item1.promgoodsbuynum=promgoodsbuynum;
+
//要把优惠活动加入,prom_goods_map中,赠品不要运算
if (item1.prom_type == 3 && item1.is_gift != 1) {
await th.add_prom_goods_map(item1);
@@ -482,19 +504,20 @@ Page({
}
item.original_img = oo.imghost + item.original_img;
+
+ var car_item=item;
/*----接口要弄出来的,先顶着-----*/
- var pcid = item.pick_id;
+ var pcid = car_item.pick_id;
var find = 0;
//----如果有就加进去,没有就新增一个----
//-----------循环查找门店-------------
if (arr.length > 0) {
for (var j = 0; j < arr.length; j++) {
if (arr[j].pickup_id == pcid) {
- arr[j].goods.push(item);
//if(item.is_gift!=1){
//确定配送方式
if (arr[j].distr_t == 0) {
- arr[j].distr_t = item.distr_type;
+ arr[j].distr_t = car_item.distr_type;
}
var e_t = 0
switch (arr[j].distr_t) {
@@ -514,7 +537,9 @@ Page({
//}
//-- 把等级卡会优惠多少钱装进去 --
- if (item.cut_price) arr[j].card_cut_price += item.cut_price;
+ if (car_item.cut_price1) arr[j].card_cut_price += car_item.cut_price1;
+
+ arr[j].goods.push(car_item);
find = 1;
break;
}
@@ -554,7 +579,7 @@ Page({
if (e_t == 0) th.setData({is_all_zt: 0});
var narr = new Array();
- narr.push(item);
+ narr.push(car_item);
//-----------拼装购物车结算的数组,如果有默认物流时要用默认物流编号,计算默认的物流,不管是不是自提都算一下-----------------
var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
@@ -584,7 +609,7 @@ Page({
};
//-- 把等级卡会优惠多少钱装进去 --
- if (item.cut_price1) ie.card_cut_price += item.cut_price1;
+ if (car_item.cut_price1) ie.card_cut_price += car_item.cut_price1;
arr.push(ie);
}
@@ -610,8 +635,11 @@ Page({
var offline_price = 0;
var offline_num = 0;
for (var c = 0; c < item.length; c++) {
+ if(th.data.sales_rules!=2){
+ item[c].offline_price=0;
+ }
//-- 如果这个商品是线下取价的时候 --
- if (item[c].offline_price > 0 && item[c].prom_type != 7) {
+ if (item[c].offline_price > 0 && item[c].prom_type != 7 ) {
offline_price += (item[c].goods_price - item[c].offline_price) * item[c].goods_num;
offline_num += item[c].goods_num;
}
@@ -2470,7 +2498,13 @@ Page({
}, function () {
//支付失败
setTimeout(function () {
- wx.navigateBack({delta: 1})
+ var cps=getCurrentPages();
+ if(cps.length>1){
+ wx.navigateBack({delta: 1})
+ }else{
+ getApp().goto("/pages/index/index/index");
+ }
+
}, 1000)
}, oo.stoid);
diff --git a/pages/cart/cart2/cart2.wxml b/pages/cart/cart2/cart2.wxml
index c20f022..3f88339 100644
--- a/pages/cart/cart2/cart2.wxml
+++ b/pages/cart/cart2/cart2.wxml
@@ -105,8 +105,7 @@
-
-
+
diff --git a/pages/cart/cart2/zh_calculate.js b/pages/cart/cart2/zh_calculate.js
index d27dc1f..9839b8c 100644
--- a/pages/cart/cart2/zh_calculate.js
+++ b/pages/cart/cart2/zh_calculate.js
@@ -22,6 +22,18 @@ module.exports = {
let need_to_buy = 0;
let all_zhqty = 0; //所有商品要求起购数之和
let no_in_arr = []; //剩余的未加入组合购
+ let out_arr=[]; //超出活动限购的商品放入
+
+ //-- 寻找一下 --
+ function get_num2(ite) {
+ for (let v2 in goods) {
+ var vh = goods[v2];
+ if (vh.goods_id == ite.goods_id) {
+ return vh;
+ }
+ }
+ return 0;
+ }
for (let j in act_goos) {
let item = act_goos[j];
@@ -32,6 +44,27 @@ module.exports = {
if (item_j) {
act_goos[j].num = item_j.goods_num;
act_goos[j].goods_price = item_j.goods_price;
+ var cart_num=item.cart_num =item_j.goods_num;
+ var zh_b_num=item_j.promgoodsbuynum;
+ if(item.buyqty>0){
+ var cbuy=item.buyqty-zh_b_num;
+ //当可买的数量为0
+ if(cbuy<=0){
+ item.num=0;
+ out_arr.push({
+ price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num
+ })
+ }else{
+ if(cbuy>=cart_num) item.num =cart_num;
+ else{
+ item.num =cbuy;
+ out_arr.push({
+ price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,num:cart_num-cbuy
+ })
+ }
+ }
+ }
+
all_num += item.num;
//当有起购数的控制的时候
if (item.zhqty) {
@@ -86,9 +119,10 @@ module.exports = {
}
}
+
+ let goods_map = {};
//算一下剩余的商品
- if (no_in_arr.length) {
- let goods_map = {};
+ if(no_in_arr.length) {
for (let ii in no_in_arr) {
let item = no_in_arr[ii];
if (item.offline_price) {
@@ -102,6 +136,27 @@ module.exports = {
goods_map[item.goods_id] = 1;
}
}
+ }
+
+ //超量的部分也要计算一下
+ if(out_arr.length){
+ for (var m in out_arr) {
+ var item = out_arr[m];
+ if (item.offline_price) {
+ offline_price += (item.price - item.offline_price)*item.num;
+ offline_num += item.num;
+ }
+ if (goods_map[item.goods_id]) {
+ var num = goods_map[item.goods_id];
+ num+=item.num
+ goods_map[item.goods_id] =num;
+ } else {
+ goods_map[item.goods_id] = item.num;
+ }
+ }
+ }
+
+ if(Object.keys(goods_map).length) {
//这里就开始拆分提交订单时的列表
for (let j in goods_map) {
//map中存的就是商品的数量
@@ -118,6 +173,8 @@ module.exports = {
goods.push(new_g);
}
}
+
+
//-- 只统计是参与活动的商品 --
for(var ij in goods){
var iter=goods[ij];
diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js
index f09f3f9..3d720c7 100644
--- a/pages/goods/goodsInfo/goodsInfo.js
+++ b/pages/goods/goodsInfo/goodsInfo.js
@@ -1588,6 +1588,12 @@ Page({
// this.data.shippingCost < 0 || this.data.select.stock <= 0 || (Object.assign(e, {
// action: "buy_now"
// }),
+ this.setData({
+ openSpecModal:0,
+ openSpecModal_inte:0,
+ openSpecModal_inte_normal:0,
+ openSpecModal_pt:0,
+ })
if(e.prom_type==4){
s.set_b_now(e);
@@ -1602,16 +1608,20 @@ Page({
e.prom_id=res.cat_id
}
s.set_b_now(e);
+ /*--
wx.redirectTo({
url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
- });
+ });--*/
+ getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
})
}else{
s.set_b_now(e);
+ /*--
wx.redirectTo({
url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
- });
+ });--*/
+ getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
}
}
@@ -3192,7 +3202,7 @@ Page({
});
//----------查看阶梯团------------
- if (t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) {
+ if (t.data.data.ct_rylist != "null" && t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) {
t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist);
var max_num = 0;
t.data.data.ct_rylist.forEach(function(val, ind) {
@@ -3521,10 +3531,13 @@ Page({
if(this.data.is_go_to_team_show) return false;
this.data.is_go_to_team_show=1;
wx.showLoading();
-
+
+ /*---
wx.redirectTo({
url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
- });
+ });--*/
+ getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn);
+
} else {
th.setData({
is_normal: ind,
@@ -3753,9 +3766,11 @@ Page({
var th = this;
var url="/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn;
+ /*--
wx.redirectTo({
url:url,
- })
+ })--*/
+ getApp().goto(url);
},
@@ -3840,10 +3855,13 @@ Page({
if(this.data.is_go_to_team_show) return false;
this.data.is_go_to_team_show=1;
wx.showLoading();
-
+ /*--
wx.redirectTo({
url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn,
- });
+ });--*/
+
+ getApp().goto("/pages/team/team_success/team_success?ordersn=" + odr.order_sn);
+
} else {
wx.navigateTo({
url: "/pages/team/team_show/team_show?tg_id=" + id,