diff --git a/components/diy_live/diy_live.js b/components/diy_live/diy_live.js index 2fb8f34..6c513d1 100644 --- a/components/diy_live/diy_live.js +++ b/components/diy_live/diy_live.js @@ -24,7 +24,8 @@ Component({ data: { // 弹窗显示控制 showHongbao:false, - showHongbaoSmall: false, + showHongbaoSmall: false, + imghost:getApp().globalData.setting.imghost }, /** diff --git a/components/diy_live/diy_live.wxml b/components/diy_live/diy_live.wxml index 3a73ee2..ffefe69 100644 --- a/components/diy_live/diy_live.wxml +++ b/components/diy_live/diy_live.wxml @@ -3,7 +3,7 @@ - + 直播 diff --git a/images/share/default_g_img.gif b/images/share/default_g_img.gif deleted file mode 100644 index fd72ed1..0000000 --- a/images/share/default_g_img.gif +++ /dev/null diff --git a/packageA/pages/activity_share/activity_share.js b/packageA/pages/activity_share/activity_share.js index f954081..940e4e5 100644 --- a/packageA/pages/activity_share/activity_share.js +++ b/packageA/pages/activity_share/activity_share.js @@ -1203,9 +1203,17 @@ Page({ ee.data.share_goods_img = res.path; tt(); }, - fail: function(res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + fail: function(res) { + + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.url+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) + } }); }, diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index b9d642a..cd8b892 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -2444,9 +2444,15 @@ Page({ tt(); }, fail: function(res) { + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); } }); }, diff --git a/packageA/pages/goods_share/goods_share.js b/packageA/pages/goods_share/goods_share.js index a16e3d8..15f3333 100644 --- a/packageA/pages/goods_share/goods_share.js +++ b/packageA/pages/goods_share/goods_share.js @@ -806,8 +806,16 @@ Page({ tt(); }, fail: function(res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.url+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) + } }); }, diff --git a/packageA/pages/service_share/service_share.js b/packageA/pages/service_share/service_share.js index 747fa0e..e498c8e 100644 --- a/packageA/pages/service_share/service_share.js +++ b/packageA/pages/service_share/service_share.js @@ -784,9 +784,15 @@ Page({ ee.data.share_goods_img = res.path; tt(); }, - fail: function(res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + fail: function(res) { + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.url+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/packageB/pages/zuhegou/index/index.js b/packageB/pages/zuhegou/index/index.js index 8e81cd1..69f769b 100644 --- a/packageB/pages/zuhegou/index/index.js +++ b/packageB/pages/zuhegou/index/index.js @@ -116,7 +116,9 @@ Page({ sort_store: 0, //门店分类 choice_sort_store: 0, //选择分类门店 fir_pick_index: 0, //门店选择的下标 - sec_pick_index: 0 //门店选择的下标,地区选择之后的内页 + sec_pick_index: 0, //门店选择的下标,地区选择之后的内页 + + sales_map:{}, //线下销售的map }, /** @@ -311,7 +313,6 @@ Page({ getApp().getConfig2(function (e) { ee.setData({ bconfig: e, - sales_rules: e.sales_rules, }); //设置基本参数 th.wait_for_store_config(e); @@ -533,6 +534,9 @@ Page({ //说明是加入购物车是时候 this.data.is_zuhe_addcart = 1; if (!haveAdded) { + + + th.data.sele_g = this.data.list[index]; if (!th.data.sele_g.num) th.data.goodsInputNum = 1; @@ -567,11 +571,14 @@ Page({ } return false; } else { - th.setData({ - is_no_pipei: 0 - }); - th.check_is_in_cart(function () { - th.add_cart_func(); + //先判断一下线下库存 + th.check_pk_store_conut(function(){ + th.setData({ + is_no_pipei: 0 + }); + th.check_is_in_cart(function () { + th.add_cart_func(); + }) }) } } else { @@ -648,6 +655,109 @@ Page({ }, + //在启用线下的时候,要判断一下是不是有库存 + async check_pk_store_conut(func,is_no_msg,gd,by_num){ + var th=this; + if(this.data.sales_rules!=2){ + func(); + } + //门店库存no + var pkno= gd && gd.pickup_no?gd.pickup_no:this.data.def_pick_store.pickup_no; + var pickup_id=gd && gd.pick_id?gd.pick_id:this.data.def_pick_store.pickup_id; + var lock = []; + var plist=null; + var good=gd || th.data.sele_g; + var buy_num=by_num || th.data.goodsInputNum; + + if(this.data.sales_map[good.goods_id]){ + + var mp=this.data.sales_map[good.goods_id]; + var lock_num=mp.lock_num; + var CanOutQty=mp.CanOutQty; + if (CanOutQty < lock_num +buy_num) { + + if(!is_no_msg) { + wx.showToast({ + title: "门店库存不足", + icon: 'none', + duration: 2000 + }) + } + return false; + } + if(is_no_msg) return true; + func(); + + }else { + //先读取门店的lock,采用链式写法,少用await + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { + data: {store_id: os.stoid, wareId: good.goods_id, pageSize: 1000} + }).then(res => { + if (res.data.code == 0 && res.data.data.total > 0) { + lock = res.data.data.pageData + } + + }) + //---通过接口获取门店的线下库存信息-- + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", { + data: { + storageNos: pkno, + wareIds: encodeURIComponent(good.erpwareid), + storeId: os.stoid, + pageSize: 2000 + } + }).then(res => { + if (ut.ajax_ok(res)) { + plist = res.data.data.pageData[0]; + } + }) + + if(!plist){ + if(!is_no_msg) { + wx.showToast({ + title: "该商品在门店未找到库存", + icon: 'none', + duration: 2000 + }) + } + return false; + } + + var lock_num = th.find_lock_num(pickup_id, lock); + this.data.sales_map[good.goods_id]={ + CanOutQty:plist.CanOutQty, + lock_num:lock_num + } + + if (plist.CanOutQty < lock_num + buy_num) { + if(!is_no_msg) { + wx.showToast({ + title: "该商品在门店未找到库存", + icon: 'none', + duration: 2000 + }) + } + return false; + } + if(is_no_msg) return true; + func(); + } + + }, + + find_lock_num(pick_id, lock) { + var lock_num = 0; + if (!lock) return 0; + if (lock.length < 0) return 0; + for (var i in lock) { + if (pick_id == lock[i].pickupId) { + lock_num += lock[i].outQty; + } + } + return lock_num; + }, + + /** * 增加数量 */ @@ -664,13 +774,17 @@ Page({ this.data.changing = 1; var index = e.currentTarget.dataset.index; - this.data.sele_g = this.data.list[index]; + this.data.sele_g = th.data.list[index]; this.data.sele_index = index; - th.data.goodsInputNum = this.data.sele_g.num + 1; - if (this.data.sele_g.cart_num) { - th.data.s_cart_num = this.data.sele_g.cart_num + 1; - } - th.add_cart_func(); + th.data.goodsInputNum = th.data.sele_g.num + 1; + + th.check_pk_store_conut(function(){ + if (th.data.sele_g.cart_num) { + th.data.s_cart_num = th.data.sele_g.cart_num + 1; + } + th.add_cart_func(); + }) + }, /** @@ -1581,11 +1695,19 @@ Page({ //只是单纯的选择门店 if (this.data.only) { this.data.only = 0; + this.data.sales_map={}; + return false; } - th.check_is_in_cart(function () { - th.add_cart_func(); + + //-- 判断一下库存 -- + th.check_pk_store_conut(function(){ + th.check_is_in_cart(function () { + th.add_cart_func(); + }) }) + + }, @@ -2116,7 +2238,7 @@ Page({ 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) { + if(ut.ajax_ok(e)) { var map = {}; var mlist = e.data.data.pageData; th.data.cart_list = mlist; @@ -2127,6 +2249,8 @@ Page({ 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; @@ -2144,6 +2268,16 @@ Page({ if (map[item_j.goods_id]) { var cart_num = map[item_j.goods_id].goods_num; item_j.num = cart_num; + item_j.pickup_no = map[item_j.goods_id].pickup_no; + item_j.pick_id = map[item_j.goods_id].pick_id; + + //判断库存是不是存在 + var can_qty=await th.check_pk_store_conut(null,1,item_j,cart_num); + if(!can_qty){ + item_j.num=0; + continue; + } + item_j.cart_num = cart_num; item_j.cart_id = map[item_j.goods_id].id; if (item_j.buyqty > 0) { diff --git a/packageC/pages/luckyGo/luckyGo_details/luckyGo_details.js b/packageC/pages/luckyGo/luckyGo_details/luckyGo_details.js index 4b14fcc..cf05702 100644 --- a/packageC/pages/luckyGo/luckyGo_details/luckyGo_details.js +++ b/packageC/pages/luckyGo/luckyGo_details/luckyGo_details.js @@ -952,8 +952,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_img_localpath= "../../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: os.imghost+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_img_localpath = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 7b03c7e..2c13749 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -5375,8 +5375,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index ffa4834..0ee31fa 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -3166,8 +3166,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/packageC/pages/presell/pregoodsInfo/goodsInfo.js b/packageC/pages/presell/pregoodsInfo/goodsInfo.js index d72e20a..5625eb8 100644 --- a/packageC/pages/presell/pregoodsInfo/goodsInfo.js +++ b/packageC/pages/presell/pregoodsInfo/goodsInfo.js @@ -3115,8 +3115,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index fbd7473..1b51ae9 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -2080,7 +2080,7 @@ Page({ function normal_check(store_count, goodsinfo, wareIds) { //--- 看一下是不是线下库存 --- - if (th.data.sales_rules == 2 && goodsinfo.prom_type != 7 && !goodsinfo.whsle_id) { + if (th.data.sales_rules == 2 && !goodsinfo.whsle_id) { th.check_down_line(t, pitem, item, wareIds); } else { if (t.goods_num > store_count) { diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index 2646e3e..4254171 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -1126,8 +1126,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 5a0fc2f..6c6eee2 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -5736,8 +5736,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: ee.data.iurl+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_goods_img = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/pages/team/team_success/team_success.js b/pages/team/team_success/team_success.js index 81cf88e..945c203 100644 --- a/pages/team/team_success/team_success.js +++ b/pages/team/team_success/team_success.js @@ -794,8 +794,14 @@ Page({ tt(); }, fail: function (res) { - ee.data.share_img_localpath= "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 - tt(); + //获取默认空白图 + wx.getImageInfo({ + src: os.imghost+'/miniapp/images/default_g_img.gif', + success: function(res) { + ee.data.share_img_localpath = res.path; //分享的图片不能用网络的 + tt(); + } + }) } }); }, diff --git a/pages/user/cardinfo/cardinfo.js b/pages/user/cardinfo/cardinfo.js index 4b140d0..2492876 100644 --- a/pages/user/cardinfo/cardinfo.js +++ b/pages/user/cardinfo/cardinfo.js @@ -673,7 +673,7 @@ Page({ tt(); }, fail: function (res) { - ee.data.head_pic = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 + ee.data.head_pic = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 tt(); } });