diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js index cc1ecde..82834e8 100644 --- a/packageB/pages/zuhegou/index/index.js +++ b/packageB/pages/zuhegou/index/index.js @@ -472,34 +472,61 @@ Page({ var txt2 = "list[" + index + "].showNum"; th.data.sele_g = this.data.list[index]; - wx.showModal({ title: '温馨提示', - content: '确定将该商品移出购物车?', + content: "确定取消该商品参与活动?", success (res) { if (res.confirm) { console.log('用户点击确定'); + if(th.data.sele_g.cart_num){ - var url = '/api/weshop/cart/del/' + os.stoid + '/' + th.data.sele_g.cart_id; - getApp().request.delete(url, { - success:function (res) { - - if(res.data.code==0) { - title = '移除购物车成功'; - th.setData({ - [txt1]: 1, - [txt2]: false, - [txt]: false, - }); - wx.showToast({ - title: title, - icon: 'success', - }); - - th.re_sum_price(); - } + var updata = { + id: th.data.sele_g.cart_id, + goods_num: th.data.sele_g.cart_num - th.data.sele_g.num, + store_id: os.stoid } - }); + getApp().request.put("/api/weshop/cart/update", { + data: updata, + success:function (rs) { + if(rs.data.code==0) { + title = '取消成功'; + th.setData({ + [txt1]: 0, + [txt2]: false, + [txt]: false, + }); + wx.showToast({ + title: title, + icon: 'success', + }); + th.re_sum_price(); + } + } + }) + + }else{ + var url = '/api/weshop/cart/del/' + os.stoid + '/' + th.data.sele_g.cart_id; + getApp().request.delete(url, { + success:function (res) { + + if(res.data.code==0) { + title = '取消成功'; + th.setData({ + [txt1]: 0, + [txt2]: false, + [txt]: false, + }); + wx.showToast({ + title: title, + icon: 'success', + }); + + th.re_sum_price(); + } + } + }); + } + } else if (res.cancel) { console.log('用户点击取消') self.setData({ @@ -551,6 +578,7 @@ Page({ var index = e.currentTarget.dataset.index; var item = this.data.list[index]; let num = item.num; + th.data.s_cart_num = this.data.sele_g.cart_num - 1; if (num >= 2) { var check_num = num - 1; @@ -569,7 +597,7 @@ Page({ th.data.sele_g = item; th.data.sele_index = index; th.data.goodsInputNum = check_num; - th.data.s_cart_num = this.data.sele_g.cart_num - 1; + th.sub_updata_cart(); return false; } @@ -580,27 +608,54 @@ Page({ wx.showModal({ title: '温馨提示', - content: '确定将该商品移出购物车?', + content: '确定取消该商品参与活动?', success (res) { if (res.confirm) { - var url = '/api/weshop/cart/del/' + os.stoid + '/' + item.cart_id; - getApp().request.delete(url, { - success:function (res) { - if(res.data.code==0) { - var title = '移除购物车成功'; - th.setData({ - [txt1]: 1, - [txt2]: false, - [txt]: false, - }); - wx.showToast({ - title: title, - icon: 'success', - }); - th.re_sum_price();//重新统计数量和总金额 - } + + if(th.data.s_cart_num){ + var updata = { + id: th.data.sele_g.cart_id, + goods_num:h.data.s_cart_num , + store_id: os.stoid } - }); + getApp().request.put("/api/weshop/cart/update", { + data: updata, + success:function (rs) { + if(rs.data.code==0) { + var title = '取消成功'; + th.setData({ + [txt1]: 0, + [txt2]: false, + [txt]: false, + }); + wx.showToast({ + title: title, + icon: 'success', + }); + th.re_sum_price(); + } + } + }) + }else { + var url = '/api/weshop/cart/del/' + os.stoid + '/' + item.cart_id; + getApp().request.delete(url, { + success: function (res) { + if (res.data.code == 0) { + var title = '移除购物车成功'; + th.setData({ + [txt1]: 1, + [txt2]: false, + [txt]: false, + }); + wx.showToast({ + title: title, + icon: 'success', + }); + th.re_sum_price();//重新统计数量和总金额 + } + } + }); + } } else if (res.cancel) { console.log('用户点击取消') @@ -844,6 +899,10 @@ Page({ goods_sn: o.goods_sn, }; + if(th.data.s_cart_num){ + newd.goods_num=th.data.s_cart_num; + } + //---是不是从收藏夹出来的--- if (th.data.c_guide_id) { newd['guide_id'] = th.data.c_guide_id; @@ -951,6 +1010,12 @@ Page({ }); th.data.adding = 0; th.data.sele_store = 1; + + if(th.data.s_cart_num){ + var txt_temp = "list[" + index + "].cart_num"; + th.setData({[txt_temp]:th.data.s_cart_num}) + } + th.re_sum_price();//重新统计数量和总金额 } }); @@ -1470,8 +1535,8 @@ Page({ store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, - prom_type: gd.prom_type, - prom_id: gd.prom_id + prom_type: 7, + prom_id: th.data.act.id }, }).then(res2=>{ var g_buy_num=0; @@ -1540,6 +1605,11 @@ Page({ }); th.data.adding = 0; th.data.sele_store = 1; + if(th.data.s_cart_num){ + var txt_temp = "list[" + index + "].cart_num"; + th.setData({[txt_temp]:th.data.s_cart_num}) + } + th.re_sum_price();//重新统计数量和总金额 } }); @@ -1594,7 +1664,7 @@ Page({ if(check_obj.prom_buybum && check_obj.prom_buybum>0) prom_buybum=check_obj.prom_buybum; if(check_obj){ - if(check_obj.prom_buybum && check_obj.prom_buybum>th.data.sele_g.buyqty && + if(check_obj.prom_buybum && check_obj.prom_buybum>=th.data.sele_g.buyqty && th.data.sele_g.buyqty>0 ){ wx.showToast({ @@ -1604,7 +1674,7 @@ Page({ }); return false; } - if(check_obj.gd_buynum && check_obj.gd_buynum>th.data.sele_g.viplimited && + if(check_obj.gd_buynum && check_obj.gd_buynum>=th.data.sele_g.viplimited && th.data.sele_g.viplimited>0 ){ wx.showToast({ @@ -1616,12 +1686,12 @@ Page({ } } - item.cbuy=-1; - var cbuy=th.data.sele_g.viplimited>0?th.data.sele_g.viplimited-gd_buynum:-1; - if(cbuy>-1) item.cbuy=cbuy; - var cbuy2=th.data.sele_g.buyqty>0?th.data.sele_g.buyqty-prom_buybum:-1; - if(cbuy2>-1){ - if(item.cbuy==-1 || item.cbuy>cbuy2) item.cbuy=cbuy2; + item.cbuy='no'; + var cbuy=th.data.sele_g.viplimited>0?th.data.sele_g.viplimited-gd_buynum:'no'; + if(cbuy!='no') item.cbuy=cbuy; + var cbuy2=th.data.sele_g.buyqty>0?th.data.sele_g.buyqty-prom_buybum:'no'; + if(cbuy2!='no'){ + if(item.cbuy=='no' || item.cbuy>cbuy2) item.cbuy=cbuy2; } var num=item.goods_num; @@ -1637,17 +1707,12 @@ Page({ [txt5]: item.goods_num, }); - if(item.cbuy>-1){ - th.setData({ - [txt5]: item.cbuy, - }); - } - var updata = { id: item.id, prom_type: 7, goods_price: cur_price, - prom_id: th.data.act.id + prom_id: th.data.act.id, + store_id: os.stoid, }; if (getApp().globalData.guide_id) { updata['guide_id'] = getApp().globalData.guide_id; diff --git a/pages/activity/seckill_list/seckill_list.js b/pages/activity/seckill_list/seckill_list.js index 68b6117..aa8bd4b 100644 --- a/pages/activity/seckill_list/seckill_list.js +++ b/pages/activity/seckill_list/seckill_list.js @@ -17,9 +17,13 @@ Page({ //------初始化加载---------- onLoad: function(t) { - wx.setNavigationBarTitle({ title: "商品秒杀",}) - + wx.setNavigationBarTitle({ title: "商品秒杀",}) var first_leader = t.first_leader; + var type=t.type; + if(type!=undefined){ + this.setData({type:type}); + } + var th=this; console.log("------------"); @@ -129,8 +133,17 @@ Page({ }); if(plist.length<=0){ + getApp().showWarning("没有更多数据"); th.data.ismore=0; + if(e.data.currentPage==1 && this.data.type==1){ + setTimeout(function () { + th.data.ismore=1; + th.setData({type:0}); + th.requestSalelist(); + },1000); + } + return false; } //--循环读取接口--- @@ -147,7 +160,7 @@ Page({ alllist.push(plist[i]); } e.data.currentPage++; - console.log("秒杀商品列表", alllist); + console.log("秒杀商品列表", alllist); th.setData({goodlist:alllist,isshow:1}); }, diff --git a/pages/activity/seckill_list/seckill_list.wxml b/pages/activity/seckill_list/seckill_list.wxml index 0037753..cb8a935 100644 --- a/pages/activity/seckill_list/seckill_list.wxml +++ b/pages/activity/seckill_list/seckill_list.wxml @@ -84,11 +84,11 @@ + src="{{url}}{{type==1?'/miniapp/images/fire-red.png':'/miniapp/images/fire-black.png'}}"> 火热进行中 + src="{{url}}{{type==0?'/miniapp/images/clock-rad.png':'/miniapp/images/clock-black.png'}}"> 即将开始 diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 7e212fd..8a8bf0f 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -198,6 +198,7 @@ Page({ get_cart: function() { var th = this; var rd = Math.random().toString(36).substr(2, 15); + var user_id=getApp().globalData.userInfo.user_id; getApp().request.get("/api/weshop/cart/list", { data: { user_id: app.globalData.user_id, @@ -249,6 +250,40 @@ Page({ //商品已经下架 continue; } + var goodsbuynum=0,promgoodsbuynum=0,limit=0; + + //--要获得商品,该用户买了多少件,同步应用-- + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: oo.stoid, + user_id: user_id, + goods_id: item.goods_id, + prom_type: item.prom_type, + prom_id: item.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; + }) + limit=good.viplimited; + //判断商品的限购 + if(item.goods_num+goodsbuynum>limit && limit>0){ + var cbuy=limit-goodsbuynum; + if(cbuy<=0){ + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; + a.delete(url, {}); + continue; + } + //-- 购物车更新 -- + var updata1={id: item.id,goods_num:cbuy }; + getApp().request.put("/api/weshop/cart/update", { + data: updata1, + }) + item.goods_num=cbuy; + } //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着 if (item.prom_type == 1) { @@ -266,6 +301,22 @@ Page({ //商品已经下架 continue; } + + //判断秒杀的限购 + if(item.goods_num+promgoodsbuynum>prom.buy_limit && prom.buy_limit>0){ + var cbuy=prom.buy_limit-promgoodsbuynum; + if(cbuy<=0){ + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id; + a.delete(url, {}); + continue; + } + //-- 购物车更新 -- + var updata1={id: item.id,goods_num:cbuy }; + getApp().request.put("/api/weshop/cart/update", { + data: updata1, + }) + item.goods_num=cbuy; + } } //--判断优惠活动有没有过期-- else if (item.prom_type == 3) { @@ -330,6 +381,25 @@ Page({ getApp().request.delete(url, {}); continue; } + item.zh_b_num=promgoodsbuynum; + + var url1 = "/api/weshop/prom/zhbuyGoods/page"; + var req_data = { + page: 1, + pageSize: 2000, + store_id: os.stoid, + zh_id: item.prom_id, + goods_id:item.goods_id + } + await getApp().request.promiseGet(url1, { + data: req_data + }).then(res => { + if (ut.ajax_ok(res)) { + gdlist = res.data.data.pageData[0]; + item.buyqty=gdlist.buyqty; + } + }) + } else if(item.prom_type == 0) { //如果有优惠活动,要更新活动 @@ -348,6 +418,7 @@ Page({ }) } + all_num += item.goods_num; item.original_img = oo.imghost + item.original_img; item.selected = 0; @@ -1373,7 +1444,7 @@ Page({ }) } else { //--- 看一下是不是线下库存 --- - if(th.data.sales_rules==2){ + if(th.data.sales_rules==2 && goodsinfo.prom_type!=7){ th.check_down_line(t, pitem, item,wareIds); }else{ if (t.goods_num > store_count) { @@ -1433,6 +1504,7 @@ Page({ //---检验线下库存的数量的子函数--- async check_down_line_next(t, pitem, item,erpwareid,func){ + var goodsinfo = this.data.requestData[pitem].goods[item]; var lock=0,pick_no,plist; //先读取门店的lock diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index 50880fc..6c5197b 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -88,12 +88,14 @@ 物流 - + - 还需购买{{items.zhqty-items.goods_num}}件 + + 活动剩余可购{{items.buyqty-items.zh_b_num>0?items.buyqty-items.zh_b_num:0}}件 + 还需购买{{items.zhqty-items.goods_num}}件 - 需购买{{items.zhqty}}件 + 需购买{{items.zhqty}}件 diff --git a/pages/cart/cart/zh_calculate.js b/pages/cart/cart/zh_calculate.js index 6eabebb..2aa98c8 100644 --- a/pages/cart/cart/zh_calculate.js +++ b/pages/cart/cart/zh_calculate.js @@ -58,7 +58,9 @@ module.exports = { offline_price = 0, offline_num = 0; var txt = "requestData[" + a + "].need_list"; - if (!car_item.zh_map) { + //活动的列表都存储在这里面,可以快速查询 + var zh_prom_goods=car_item.zh_prom_goods; + if (!car_item.zh_map && !zh_prom_goods) { var res = { tfeel: tfeel, offline_price: offline_price, @@ -69,9 +71,7 @@ module.exports = { }); return res; } - - //活动的列表都存储在这里面,可以快速查询 - var zh_prom_goods=car_item.zh_prom_goods; + //因为可能有多个组合购的活动 for (var i in car_item.zh_map) { var bitem = car_item.zh_map[i]; @@ -86,6 +86,11 @@ module.exports = { var title =""; //提示语; //var goods = bitem.goods; var goods = zh_prom_goods[act.id]; + + for (let v3 in car_item.goods) { + car_item.goods[v3].need_downlow_num=0; + } + //寻找一下 function get_num(ite) { for (let v1 in bitem.goods) { @@ -115,6 +120,7 @@ module.exports = { var cart_num=get_num(item).goods_num; var zh_b_num=get_num2(item).zh_b_num; + item.cart_num =cart_num; //-- 当商品有购买的时候,以及有限购的时候 -- if(zh_b_num>0 && item.buyqty>0){ @@ -139,13 +145,14 @@ module.exports = { item.num =cart_num; } - item.goods_price=get_num(item).goods_price; item.offline_price=get_num(item).offline_price; - + if(item.cart_num){ + all_price += item.cart_num * item.goods_price; + } if (item.num) { all_num += item.num; - all_price += item.num * item.goods_price; + //当有起购数的控制的时候 if (item.zhqty) { all_zhqty += item.zhqty; diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 2a28349..accff90 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -940,8 +940,8 @@ Page({ //计算价格 th.calculatePrice2(); - //获取优惠券 - th.get_buy_now_quan(); + //获取优惠券,如果有券的钱,就调用 + if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); } }); @@ -1258,8 +1258,8 @@ Page({ if(item[j].prom_type!=7){ o_price_no_zh += item[j].goods_price * item[j].goods_num; } - //组合购的商品,且没有订单优惠的叠加,is_orderyh就是优惠叠加 - if(zh_prom_goods[item[j].prom_id] && !zh_prom_goods[item[j].prom_id].act.is_orderyh ) + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 + else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh ) { o_price_no_zh += item[j].goods_price * item[j].goods_num; } @@ -1273,7 +1273,7 @@ Page({ o_price_no_zh-=c_arr[i].cut_price; } //如果有组合购优惠的钱,就要减价 - if (c_arr[i].zh_cut_price > 0){ + if (c_arr[i].zh_cut_price>0 || c_arr[i].zh_cut_price<0){ o_price -= c_arr[i].zh_cut_price; if(o_price_no_zh>0){ //找到那些可以订单优惠叠加的 @@ -2027,11 +2027,11 @@ Page({ } //--判断优惠活动的提交-- - if (th.data.formData.cut_price > 0) { + if (th.data.formData.cut_price > 0 ) { order_prom_list.discount_amount = th.data.formData.cut_price.toFixed(2); var ob = [{ "prom_id": th.data.bn_goods.prom_id, - "dis": th.data.formData.cut_price.toFixed(2), + "dis": parseFloat(th.data.formData.cut_price).toFixed(2), "ispt": 0 }] order_prom_list.prom_pt_json = JSON.stringify(ob); @@ -2266,12 +2266,12 @@ Page({ order_prom_list.discount_amount =0; //--判断优惠活动的提交-- if (t_item.cut_price > 0) { - order_prom_list.discount_amount += t_item.cut_price.toFixed(2); + order_prom_list.discount_amount += t_item.cut_price; order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json); } //--判断组合优惠活动的提交-- - if (t_item.zh_cut_price > 0) { - order_prom_list.discount_amount += t_item.zh_cut_price.toFixed(2); + if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { + order_prom_list.discount_amount += t_item.zh_cut_price; order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); } if (t_item.s_intValue > 0) { @@ -2285,8 +2285,14 @@ Page({ order_prom_list.give_lb_id = t_item.s_libao; order_prom_list.g_lb_num = JSON.stringify(t_item.g_lb_num); } - if (Object.keys(order_prom_list).length > 0) + if (Object.keys(order_prom_list).length > 0){ + if(order_prom_list.discount_amount) + order_prom_list.discount_amount= parseFloat(order_prom_list.discount_amount).toFixed(2); + if(order_prom_list.order_prom_amount) + order_prom_list.order_prom_amount= parseFloat(order_prom_list.order_prom_amount).toFixed(2); item.order_prom_list = order_prom_list; + } + //老会员成为分销下线需要的参数 if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { diff --git a/pages/cart/cart2/cart2.wxml b/pages/cart/cart2/cart2.wxml index 227ee14..c20f022 100644 --- a/pages/cart/cart2/cart2.wxml +++ b/pages/cart/cart2/cart2.wxml @@ -428,7 +428,7 @@ - ¥ {{filters.toFix(formData.cut_price,2)}}元 - + 组合购优惠 - ¥ {{filters.toFix(formData.zh_cut_price,2)}}元 diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 6afbe9d..f09f3f9 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -711,6 +711,11 @@ Page({ onShow: function() { console.log('djfijsaoifjoisadjfoij'); var goods_list = null,th = this,that=this; + var show_prew_img= this.data.show_prew_img + if(show_prew_img){ + show_prew_img=0; + return false; + } //优惠券要实时更新 getApp().getConfig2(function(e) { @@ -1303,10 +1308,10 @@ Page({ }else if(o.prom_type==7){ //判断进行中的活动,是不是要判断线下库存 - check_zh_acting(function (e) { + th.check_zh_acting(function (ee){ newd.prom_id = 0; newd.prom_type = 0; - if(e){ + if(ee){ newd.prom_id = th.data.zh_act.id; newd.prom_type = 7; if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); @@ -2061,6 +2066,7 @@ Page({ for(var i in b){ b[i] = this.data.iurl + e[i]; } + this.data.show_prew_img=1; wx.previewImage({ current: b[t.currentTarget.dataset.id], @@ -2074,6 +2080,7 @@ Page({ for (var i in b) { b[i] = this.data.iurl + e[i]; } + this.data.show_prew_img=1; wx.previewImage({ current: b[t.currentTarget.dataset.id], urls: b @@ -2089,6 +2096,7 @@ Page({ current: a[t.currentTarget.dataset.id], urls: a }); + this.data.show_prew_img=1; }, closePromModal: function() { this.setData({ @@ -5388,6 +5396,7 @@ Page({ }, previewImage() { + this.data.show_prew_img=1; wx.previewImage({ //将图片预览出来 urls: [this.data.shareImgPath] diff --git a/utils/pay.js b/utils/pay.js index c78040c..5725f43 100644 --- a/utils/pay.js +++ b/utils/pay.js @@ -53,6 +53,7 @@ module.exports = { }, weixinPay: function(n, e, a) { if(!n) return false; + /*-- wx.requestPayment({ timeStamp: String(n.timeStamp), nonceStr: n.nonceStr, @@ -67,6 +68,32 @@ module.exports = { t.confirmBox("支付失败:" + n.errMsg.substr("requestPayment:fail ".length)), "function" == typeof a && a(); } - }); + });--*/ + + wx.requestOrderPayment({ + timeStamp: String(n.timeStamp), + nonceStr: n.nonceStr, + package: n.packageValue, + signType: n.signType, + paySign: n.paySign, + orderInfo: n.orderInfo, // 需要新增的 订单 信息 + success (n) { + t.showSuccess("支付成功!", e); + }, + fail (n) { + if(!n.errMsg ) { + getApp().showWarning("支付失败"); + "function" == typeof fail && fail(); + return false; + } + + console.log(n), "requestOrderPayment:fail" == n.errMsg ? t.showWarning("支付失败") : "requestOrderPayment:fail cancel" == n.errMsg ? t.showWarning("您已取消支付") : + t.confirmBox("支付失败:" + n.errMsg.substr("requestOrderPayment:fail ".length)), + "function" == typeof a && a(); + } + }) + + + } }; \ No newline at end of file diff --git a/utils/wxParse/wxParse.js b/utils/wxParse/wxParse.js index d35ffaf..8f650c9 100644 --- a/utils/wxParse/wxParse.js +++ b/utils/wxParse/wxParse.js @@ -15,9 +15,10 @@ function t(e, t, a) { function a(e) { var t = this, a = e.target.dataset.src, i = e.target.dataset.from; + t.data.show_prew_img=1; void 0 !== i && i.length > 0 && wx.previewImage({ current: a, - urls: t.data[i].imageUrls + urls: t.data[i].imageUrls, }); } diff --git a/utils/wxParse/wxParse.wxml b/utils/wxParse/wxParse.wxml index 2251a18..90aa270 100644 --- a/utils/wxParse/wxParse.wxml +++ b/utils/wxParse/wxParse.wxml @@ -377,7 +377,7 @@