Commit 11ac3a02ab236c3bb200d70696efde960a05b14b

Authored by yvan.ni
1 parent 99173cb0

优惠活动,订单优惠,搭配购

... ... @@ -27,7 +27,6 @@ App({
27 27 to_group:null, //参团传递的数据
28 28 wxapp_buy_obj:null, //微信小程序购买的Object
29 29 pk_store:null, //选择的门店
30   -
31 30 },
32 31 auth: o,
33 32 request: a,
... ... @@ -368,6 +367,8 @@ App({
368 367 data: {
369 368 store_id: th.globalData.setting.stoid,
370 369 user_id: th.globalData.user_id,
  370 + state:0,
  371 + is_gift:0
371 372 },
372 373 success: function(e) {
373 374 var num = 0;
... ... @@ -396,15 +397,14 @@ App({
396 397 },1000);
397 398 }
398 399 },
399   -
400   -
  400 +
401 401 //------定时等待某个值,有值才进行运算--------
402 402 waitfor2:function(page,key,pop_value_key,func){
403 403 var n=0;
404 404 if(!page.data[key]){
405 405 page.data[key]=setInterval(function(){
406 406 console.log(page.data[key]);n++;
407   - if(page.data[pop_value_key]) {
  407 + if(page.data[pop_value_key] && Object.keys(page.data[pop_value_key]).length>0) {
408 408 clearInterval(page.data[key]);
409 409 func();
410 410 }
... ...
app.json
1 1 {
2   - "pages": [
  2 + "pages": [
3 3 "pages/index/index/index",
4 4 "pages/goods/categoryList/categoryList",
5 5 "pages/cart/cart/cart",
... ... @@ -85,11 +85,14 @@
85 85 "pages/video/index",
86 86 "pages/template/index",
87 87 "pages/store/index"
88   -
89 88 ],
90 89  
  90 + "subPackages": [{
  91 + "root": "packageA/",
  92 + "name":"pack1",
  93 + "pages": ["pages/prom_list/prom_list"]
  94 + }],
91 95  
92   -
93 96 "permission": {
94 97 "scope.userLocation": {
95 98 "desc": "获取你的位置信息"
... ...
packageA/pages/prom_list/filter.wxs 0 → 100644
  1 +var is_has = function (text,val) {
  2 + if(text.indexOf(","+val+",")==-1) return false;
  3 + return true
  4 +}
  5 +
  6 +function get_guige(color,spece){
  7 + if(color=="" && spece==""){return "规格1"}
  8 + if(spece!="" && color==""){return spece}
  9 + if(spece=="" && color!=""){return color}
  10 + if(spece!="" && color!=""){return spece+"/"+color}
  11 + return "";
  12 +}
  13 +
  14 +module.exports = {
  15 + is_has: is_has,
  16 + get_guige:get_guige
  17 +}
... ...
packageA/pages/prom_list/g_filter.wxs 0 → 100644
  1 +var g_filters = {
  2 + //-- 判断是不是有等级价 --
  3 + is_has_rank:function(rank_switch,item){
  4 + if(!rank_switch) return false;
  5 + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
  6 + return false;
  7 + },
  8 +
  9 + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
  10 + get_card_price:function(goods,all_card,type){
  11 + var price1=parseFloat(goods['cardprice1']);
  12 + var price2=parseFloat(goods['cardprice2']);
  13 + var price3=parseFloat(goods['cardprice3']);
  14 + if(!all_card){
  15 + if(type==0) return 0;
  16 + return "";
  17 + }
  18 +
  19 + var arr=[];
  20 + var min_price= 0;
  21 + var min_name="";
  22 +
  23 + var min_price=null;
  24 + var min_name=null;
  25 + //---设置对应的价格名字----
  26 + for(var i=0;i<3;i++) {
  27 + var vl=all_card[i];
  28 + if(!vl) continue;
  29 + if(vl['CorrPrice']=="Price1" && price1>0)
  30 + {
  31 + if(min_price==null) {
  32 + min_price=price1;min_name=vl['CardName'];
  33 + }
  34 + else if(price1<min_price) {
  35 + min_price=price1;min_name=vl['CardName'];
  36 + }
  37 + }
  38 + if(vl['CorrPrice']=="Price2" && price2>0)
  39 + {
  40 + if(min_price==null) {
  41 + min_price=price2;min_name=vl['CardName'];
  42 + }
  43 + else if(price2<min_price) {
  44 + min_price=price2;min_name=vl['CardName'];
  45 + }
  46 + }
  47 +
  48 + if(vl['CorrPrice']=="Price3" && price3>0)
  49 + {
  50 + if(min_price==null) {
  51 + min_price=price3;min_name=vl['CardName'];
  52 + }
  53 + else if(price3<min_price) {
  54 + min_price=price3;min_name=vl['CardName'];
  55 + }
  56 + }
  57 +
  58 + }
  59 + if(min_price==null){
  60 + if(type==0) return 0;
  61 + return "";
  62 + }
  63 +
  64 + //if(type==0) return arr.length;
  65 + //--进行排序,升序---
  66 + /*---
  67 + arr.sort(function(a,b){
  68 + if (a.price < b.price) {
  69 + return -1;
  70 + } else if (a.fee == b.fee) {
  71 + return 0;
  72 + } else {
  73 + return 1;
  74 + }
  75 + })--*/
  76 + //-- 获取最下价钱,和相应的卡的名称 --
  77 + //min_price=min.price;
  78 + //min_name=min.name;
  79 + if(type==0) return min_price.toFixed(2);
  80 + if(min_name.length>4 ) min_name=min_name.substring(0, 4);
  81 + return min_name;
  82 + },
  83 +}
  84 +module.exports = {
  85 + is_has_rank:g_filters.is_has_rank,
  86 + get_card_price:g_filters.get_card_price,
  87 +}
0 88 \ No newline at end of file
... ...
packageA/pages/prom_list/prom_list.js 0 → 100644
  1 +var t = require("../../../utils/util.js"),
  2 + ut = t,
  3 + e = require("../../../utils/common.js"),
  4 + a = require("../../../utils/wxParse/wxParse.js"),
  5 + s = getApp(),
  6 + i = s.request,
  7 + rq = i,
  8 + oo = s.globalData,
  9 + o = s.globalData.setting,
  10 + os = o;
  11 +var utils = require('../../../utils/util.js'),ut=utils;
  12 +var regeneratorRuntime = require('../../../utils/runtime.js');
  13 +
  14 +
  15 +Page({
  16 + data: {
  17 + gid: "",
  18 + stoid: o.stoid,
  19 + url: o.url,
  20 + resourceUrl: o.resourceUrl,
  21 + iurl: o.imghost,
  22 + defaultAvatar: o.resourceUrl + "/static/images/user68.jpg",
  23 + data: null,
  24 + openSpecModal: !1,
  25 + openPromModal: !1,
  26 + supportPageScroll: !1,
  27 +
  28 + //联系电话
  29 + mobile: '',
  30 + bconfig:null,
  31 + sales_rules:1,
  32 +
  33 + t_time:null,
  34 + card_field:"",
  35 + dp_price:0,
  36 + cut_price:0,
  37 + open_ind_store:1,
  38 + goodsInputNum:1,
  39 + g_buy_num: null,
  40 + sele_collocation:null,
  41 + },
  42 +
  43 + //------初始化加载----------
  44 + onLoad: function(t) {
  45 + var goods_id=t.goods_id;
  46 + this.setData({gid:goods_id});
  47 + var ee=this,th=ee,that=ee;
  48 + //----获取系统参数,并判断等级价格-----
  49 + getApp().getConfig2(function(e) {
  50 + var json_d = JSON.parse(e.switch_list);
  51 + ee.setData({
  52 + store_config: e,
  53 + bconfig: e,
  54 + sys_switch:json_d,
  55 + is_closecoupon: json_d.is_closecoupon,
  56 + is_newsales_rules:json_d.is_newsales_rules,
  57 + sales_rules:e.sales_rules
  58 + });
  59 + //------几人评价-------
  60 + //计算等级价相关
  61 + var swithc_list=e.switch_list;
  62 + var sw_arr=JSON.parse(swithc_list);
  63 + //---如果后台又开等级卡的开关---
  64 + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){
  65 + th.data.rank_switch=true;
  66 + }
  67 + });
  68 +
  69 + //获取用户的默认门店
  70 + getApp().get_user_store(function(ee) {
  71 + if(!ee) {
  72 + th.data.fir_def_store={}; //赋值空对象
  73 + return false;
  74 + }
  75 + var appd=getApp().globalData;
  76 + var w_time = setInterval(function() {
  77 + if (that.data.is_get_local_ok == 0) return false;
  78 + clearInterval(w_time);
  79 + var distance = null;
  80 + var e=JSON.parse(JSON.stringify(ee));
  81 +
  82 + //如果有开启近距离的话,同时距离优不一样了
  83 + if (that.data.lat != null) {
  84 + //如果经纬度有变化的话
  85 + if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
  86 + that.data.fir_def_store=e;
  87 + that.setData({
  88 + def_pick_store: e,
  89 + sto_sele_name: e.pickup_name,
  90 + sto_sele_id: e.pickup_id,
  91 + sto_sele_distr: e.distr_type
  92 + })
  93 + }else{
  94 + //要用接口是获取距离,js的计算不准
  95 + getApp().request.promiseGet("/api/weshop/pickup/list",{
  96 + data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
  97 + }).then(res=>{
  98 + if(res.data.code==0){
  99 + e=res.data.data.pageData[0];
  100 + if (e){
  101 + appd.pk_store=e;
  102 + that.data.fir_def_store=e;
  103 + that.setData({
  104 + def_pick_store: e,
  105 + sto_sele_name: e.pickup_name,
  106 + sto_sele_id: e.pickup_id,
  107 + sto_sele_distr: e.distr_type
  108 + })
  109 + }
  110 +
  111 + }
  112 + })
  113 + }
  114 +
  115 + //e.distance = distance;
  116 + appd.lat=that.data.lat;
  117 + appd.lon=that.data.lon;
  118 +
  119 + }else{
  120 + if (e) {
  121 + e.distance = null;
  122 + that.data.fir_def_store=e;
  123 + that.setData({
  124 + def_pick_store: e,
  125 + sto_sele_name: e.pickup_name,
  126 + sto_sele_id: e.pickup_id,
  127 + sto_sele_distr: e.distr_type
  128 + })
  129 + }
  130 + }
  131 +
  132 + }, 500)
  133 + });
  134 +
  135 + },
  136 +
  137 + //---展示---
  138 + onShow: function() {
  139 + var ee=this,th=ee,that=ee;
  140 + var gid = this.data.gid,i = getApp().request;
  141 + ee.data.g_buy_num = new Map();
  142 + this.wait_for_store_config();
  143 + setTimeout(function(){
  144 + i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
  145 + failRollback: !0,
  146 + success: function(t) {
  147 + if (t.data.code == 0) {
  148 + if (t.data.data.is_on_sale != 1) {
  149 + wx.showModal({
  150 + title: '商品已经下架',
  151 + showCancel: !1,
  152 + complete: function() {
  153 + wx.navigateBack();
  154 + }
  155 + });
  156 + }
  157 +
  158 + var timestamp = Date.parse(new Date());
  159 + timestamp = timestamp / 1000;
  160 + if (t.data.data.on_time > timestamp) {
  161 + wx.showModal({
  162 + title: '商品还未上架',
  163 + showCancel: !1,
  164 + complete: function() {
  165 + wx.navigateBack();
  166 + }
  167 + });
  168 + }
  169 +
  170 + if (t.data.data.down_time > 0) {
  171 + if (t.data.data.down_time < timestamp) {
  172 + wx.showModal({
  173 + title: '商品已经到期下架',
  174 + showCancel: !1,
  175 + complete: function() {
  176 + wx.navigateBack();
  177 + }
  178 + });
  179 + }
  180 + }
  181 +
  182 + t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
  183 + var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2);
  184 + t.data.data['disc'] = txt;
  185 +
  186 + if (t.data.data.original_img.indexOf(o.imghost) == -1)
  187 + t.data.data.original_img = o.imghost + t.data.data.original_img;
  188 + if (t.data.data.goods_content == null) t.data.data.goods_content = "";
  189 +
  190 + //计算商品的规格
  191 + var gg = "";
  192 + if(t.data.data.goods_spec=="null" || t.data.data.goods_spec==null) t.data.data.goods_spec="";
  193 + if(t.data.data.goods_color=="null" || t.data.data.goods_color==null) t.data.data.goods_color="";
  194 +
  195 + if (t.data.data.goods_spec != "" && t.data.data.goods_color != "") {
  196 + gg = t.data.data.goods_spec + "/" + t.data.data.goods_color;
  197 + } else if (t.data.data.goods_spec != "" || t.data.data.goods_color != "") {
  198 + gg = t.data.data.goods_spec + t.data.data.goods_color;
  199 + } else {
  200 + gg = "规格1";
  201 + }
  202 + t.data.data.gg = gg;
  203 +
  204 +
  205 + //--看一下有没有开启等级卡---
  206 + if(ee.data.rank_switch){
  207 + //---回调卡的列表---
  208 + th.getPlusCardType(function(ob){
  209 + var user = getApp().globalData.userInfo;
  210 + if(user){
  211 + if(user.card_field ){
  212 + var str = user['card_expiredate'].replace(/-/g, '/');
  213 + var end = new Date(str);
  214 + end = Date.parse(end) / 1000;
  215 + var now = ut.gettimestamp();
  216 + //--- 判断是等级会员,且在有效期范围内 ---
  217 + if(user.card_field && now<end){
  218 + var card_name=ob.name_map.get(user.card_field);
  219 + if(card_name.length>5) card_name=card_name.substring(0,5);
  220 + th.setData({card_field:user.card_field,card_name:card_name});
  221 + if(t.data.data[user.card_field]>0) t.data.data.shop_price=t.data.data[user.card_field];
  222 + }
  223 + }
  224 + }
  225 + ee.setData({ data: t.data.data, });
  226 + })
  227 + }else{
  228 + ee.setData({ data: t.data.data, });
  229 + }
  230 +
  231 + /*---获取活动的重表---*/
  232 + //调用接口判断订单优惠,
  233 + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+ee.data.gid+"/2", {}).then(res => {
  234 + if(res.data.code==0){
  235 + var r_data=res.data.data;
  236 + th.loop_promise(0,r_data.collocationList,function(){
  237 + ee.setData({
  238 + collocationGoods:r_data.collocationPromList,
  239 + collocationList:r_data.collocationList,
  240 + })
  241 + })
  242 + }
  243 + })
  244 +
  245 + //获取统一条形码,普通商品和优惠促销的商品
  246 + if ( t.data.data.prom_type == 5){
  247 + //默认门店要拿下门店库存
  248 + if(that.data.sales_rules==2 && that.data.is_newsales_rules){
  249 + //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
  250 + getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
  251 + if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
  252 + var lock=0,plist=null;
  253 + //先读取门店的lock,采用链式写法,少用await
  254 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
  255 + data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
  256 + }).then(res=>{
  257 + if(res.data.code==0 && res.data.data.total>0){
  258 + for(var i in res.data.data.pageData)
  259 + lock+=res.data.data.pageData[i].outQty
  260 + }
  261 + //---通过接口获取门店的线下库存信息--
  262 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
  263 + data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
  264 + })
  265 + }).then(res=>{
  266 + if(res.data.code==0 && res.data.data.total>0){
  267 + plist=res.data.data.pageData[0];
  268 + }
  269 + if(plist && plist.CanOutQty-lock>0){
  270 + that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
  271 + }else{
  272 + that.data.fir_def_store.CanOutQty=0;
  273 + }
  274 + //--给门店赋值线下库存--
  275 + th.setData({def_pick_store:that.data.fir_def_store});
  276 + //获取门店
  277 + ee.get_sto();
  278 + })
  279 + }else{
  280 + //--获取门店--
  281 + ee.get_sto();
  282 + }
  283 + })
  284 + }else{
  285 + //获取门店
  286 + ee.get_sto();
  287 + }
  288 +
  289 + }
  290 + else {
  291 + return getApp().my_warnning("商品没有搭配购的活动",0,th)
  292 + }
  293 + }
  294 + }
  295 + });
  296 + },1000)
  297 + },
  298 +
  299 + onUnload: function() {},
  300 + onHide: function() {
  301 + clearInterval(this.data.t_time);
  302 + },
  303 + //--滚动到顶部--
  304 + doScrollTop: function() {
  305 + wx.pageScrollTo({
  306 + scrollTop: 0
  307 + });
  308 + },
  309 + //------------加入购物车--------------
  310 + addCart: function(t) {
  311 + var th = this;
  312 + th.add_cart_func(t);
  313 +
  314 + },
  315 + //加入购物的函数
  316 + add_cart_func: function(t) {
  317 + var i = getApp().request;
  318 + if (oo.user_id == null) {
  319 + return s.my_warnning("还未登录!", 0, this);
  320 + }
  321 + var e = this,
  322 + th = e,
  323 + a = 0,
  324 + o = this.data.data;
  325 + a = o.goods_id;
  326 +
  327 + //----------添加到购物车时,要判断限购数量,--------
  328 + e.get_buy_num(o, function(ee) {
  329 + //---判断商品是否超出限购---
  330 + if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
  331 + if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.data.goods_id) > th.data.data.viplimited) {
  332 + wx.showModal({
  333 + title: '提示',
  334 + content: '超出商品限购'
  335 + });
  336 + return false;
  337 + }
  338 + }
  339 + //---判断商品是否超出活动限购---
  340 + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
  341 + if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
  342 + wx.showModal({
  343 + title: '提示',
  344 + content: '超出商品活动限购'
  345 + });
  346 + return false;
  347 + }
  348 + }
  349 +
  350 + if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
  351 + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
  352 + this.setData({
  353 + sto_sele_name: ""
  354 + });
  355 + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
  356 +
  357 + //--------------此时操作的数据------------
  358 + var newd = {
  359 + goods_id: o.goods_id,
  360 + goods_num: th.data.goodsInputNum,
  361 + pick_id: th.data.sto_sele_id,
  362 + user_id: oo.user_id,
  363 + store_id: th.data.stoid,
  364 + goods_price: o.shop_price,
  365 + member_goods_price: o.shop_price,
  366 + goods_name: o.goods_name,
  367 + goods_sn: o.goods_sn,
  368 + sku: o.sku,
  369 + prom_type: 5,
  370 + prom_id:o.prom_id
  371 + };
  372 +
  373 + //-----如果是秒杀,团购,积分购,拼团-----
  374 + if (th.data.data.prom_type != 5) {
  375 + return s.my_warnning("商品不是搭配活动!", 0, th);
  376 + }else{
  377 + //---如果是线下门店销售的时候---
  378 + if(th.data.sales_rules==2){
  379 + var pick=th.get_pick_from_list(th.data.sto_sele_id)
  380 + //---通过接口获取门店的线下库存信息--
  381 + getApp().request.get("/api/weshop/goods/getWareStorages",{
  382 + data:{storageNos:pick.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid},
  383 + success:function(res){
  384 + if(res.data.code==0){
  385 + if(res.data.data.pageData.length>0){
  386 + var CanOutQty=res.data.data.pageData[0].CanOutQty;
  387 + if(CanOutQty<e.data.goodsInputNum){
  388 + return s.my_warnning("库存不足!", 0, th);
  389 + }
  390 + //在调一次接口,读取商品的预出库的数量,lock
  391 + getApp().request.get("/api/weshop/order/ware/lock/page",{
  392 + data:{store_id:os.stoid,wareId:th.data.data.goods_id,storageId:pick.pickup_id,pageSize:1000},
  393 + success:function(res_data){
  394 + if(res_data.data.code==0 && res_data.data.data.total>0){
  395 + var lock=0;
  396 + for(var i in res_data.data.data.pageData){
  397 + lock+=res_data.data.data.pageData[i].outQty;
  398 + }
  399 +
  400 + if(CanOutQty<=lock){
  401 + return s.my_warnning("库存不足!", 0, th);
  402 + }
  403 + th.add_cart_next(e,t,a,o,newd,CanOutQty-lock);
  404 + }else{
  405 + th.add_cart_next(e,t,a,o,newd,CanOutQty);
  406 + }
  407 + }
  408 + })
  409 + }else{
  410 + return s.my_warnning("库存不足!", 0, th);
  411 + }
  412 +
  413 + }
  414 + }
  415 + })
  416 + }else{
  417 + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
  418 + if (o.store_count <e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th);
  419 + th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
  420 + }
  421 + }
  422 + })
  423 + },
  424 +
  425 + //---加入购物车的最后一步---
  426 + add_cart_next(e,t,a,o,newd,CanOutQty){
  427 + var th=this;
  428 + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
  429 + if(o.prom_type!=1 && o.prom_type!=6){
  430 + var conf=th.data.bconfig;
  431 + if (conf.switch_list && getApp().globalData.userInfo['card_field']){
  432 + var s_list=JSON.parse(conf.switch_list);
  433 + var now=ut.gettimestamp();
  434 + var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/');
  435 + var end = new Date(str);
  436 + end = Date.parse(end) / 1000;
  437 +
  438 + //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下--
  439 + if(parseInt(s_list.rank_switch)==2 && end>now){
  440 + var card_price=o[getApp().globalData.userInfo['card_field']];
  441 + //如果会员有等级价
  442 + if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
  443 + && getApp().globalData.userInfo['card_field']!="" && card_price>0){
  444 + newd.goods_price=card_price;
  445 + }
  446 + }
  447 + }
  448 + }
  449 +
  450 + newd['pick_name'] = th.data.sto_sele_name;
  451 + newd['pick_dis'] = th.data.sto_sele_distr;
  452 + newd["collocation_goods"]=th.data.sele_collocation;
  453 +
  454 + th.buyNow(newd);
  455 +
  456 + },
  457 +
  458 + //----------立即购买-----------
  459 + buyNow: function(e) {
  460 + s.set_b_now(e);
  461 + wx.redirectTo({
  462 + url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
  463 + });
  464 + },
  465 +
  466 + //----------增加购买数量-----------
  467 + addCartNum: function(t) {
  468 + this.checkCartNum(this.data.goodsInputNum + 1);
  469 + },
  470 + //----------减少购买数量-----------
  471 + subCartNum: function(t) {
  472 + this.checkCartNum(this.data.goodsInputNum - 1);
  473 + },
  474 + //----------输入框输入购买数量-----------
  475 + inputCartNum: function(t) {
  476 + this.checkCartNum(Number(t.detail.value));
  477 + },
  478 +
  479 + //------检查数量是不是超出限购------
  480 + checkCartNum: function(t) {
  481 + var th = this;
  482 + this.get_buy_num(this.data.data, async function() {
  483 +
  484 + //--判断商品是否超出限购--
  485 + if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
  486 +
  487 + var gd_buy_num=th.data.g_buy_num.get(th.data.data.goods_id);
  488 +
  489 + if (t + gd_buy_num > th.data.data.viplimited) {
  490 + wx.showModal({
  491 + title: '超出商品限购',
  492 + });
  493 +
  494 + var num= th.data.data.viplimited-gd_buy_num;
  495 + if(num<0) num=0;
  496 + th.setData({goodsInputNum:num})
  497 + return false;
  498 + }
  499 + }
  500 +
  501 + //--判断商品是否超出活动限购--
  502 + if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
  503 + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
  504 + wx.showModal({
  505 + title: '超出商品活动限购',
  506 + });
  507 +
  508 + var num=th.data.prom_buy_limit- th.data.prom_buy_num ;
  509 + if(num<0) num=0;
  510 + th.setData({goodsInputNum:num})
  511 + return false;
  512 + }
  513 + }
  514 +
  515 + if (th.data.data.prom_type == 1 || th.data.data.prom_type == 6) {
  516 + var redis_num = 0;
  517 + //------判断活动是否抢光-----
  518 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  519 + os.stoid + "/" + th.data.data.prom_type + "/" + th.data.data.prom_id, {
  520 + 1: 1
  521 + }).then(res => {
  522 + redis_num = res.data.data;
  523 + });
  524 +
  525 + if (t > redis_num) {
  526 + wx.showModal({
  527 + title: '超出商品活动库存',
  528 + });
  529 + th.setData({goodsInputNum:redis_num})
  530 + return false;
  531 + }
  532 +
  533 + }
  534 +
  535 + var e = th.data.data.store_count;
  536 + if(th.data.sales_rules==2){
  537 + if(!th.data.def_pick_store){
  538 + wx.showModal({ title: '请选择门店', });
  539 + return false;
  540 + }else{
  541 + e=th.data.def_pick_store.CanOutQty;
  542 + }
  543 + }
  544 +
  545 + //库存不足,不增加
  546 + if(e<t){ wx.showModal({ title: '库存不足', });
  547 + if(e<0) e=0;
  548 + th.setData({ goodsInputNum: e }); return false;
  549 + }
  550 + t > e || 0 == e ? t = e : t < 1 && (t = 1);
  551 + th.setData({ goodsInputNum: t });
  552 +
  553 + })
  554 + },
  555 +
  556 + closeSpecModal: function() {
  557 + var th=this;
  558 + this.setData({
  559 + openSpecModal: !1,
  560 + openSpecModal_pt: !1
  561 + });
  562 + },
  563 + openSpecModel: function(t) {
  564 + var th = this;
  565 + this.setData({
  566 + store: 0,
  567 + choice_sort_store: 0,
  568 + sort_store: 0,
  569 + })
  570 + //--先判断会员状态--
  571 + var user_info = getApp().globalData.userInfo;
  572 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  573 + wx.navigateTo({
  574 + url: '/pages/getphone/getphone',
  575 + })
  576 + return false;
  577 + }
  578 +
  579 + var collocationList=this.data.collocationList;
  580 + this.data.sele_collocation=null;
  581 + for(var i in collocationList){
  582 + if(collocationList[i].sele){
  583 + collocationList[i].goods_num=1;
  584 + collocationList[i].prom_type=5;
  585 + collocationList[i].prom_id=th.data.data.prom_id;
  586 + collocationList[i].goods_price=collocationList[i].price;
  587 + collocationList[i].is_collocation=1;
  588 + if(!th.data.sele_collocation) th.data.sele_collocation=new Array();
  589 + th.data.sele_collocation.push(collocationList[i]);
  590 + }
  591 + }
  592 + if(!th.data.sele_collocation){
  593 + return s.my_warnning("请选择搭配商品!", 0, th);
  594 + }
  595 +
  596 +
  597 + this.setData({
  598 + openSpecModal: !0,
  599 + });
  600 + },
  601 + closePromModal: function() {
  602 + this.setData({
  603 + openPromModal: !1
  604 + });
  605 + },
  606 +
  607 + openPromModal: function() {
  608 + this.setData({
  609 + openPromModal: !0
  610 + });
  611 + },
  612 +
  613 + //--点击分享事件---
  614 + onShareAppMessage: function(t) {
  615 + var th = this;
  616 + var price = th.data.data.shop_price;
  617 + if (th.data.prom_act) {
  618 + price = th.data.prom_act.price;
  619 + }
  620 + var title= th.data.data.goods_name;
  621 + var img=th.data.data.original_img;
  622 + if(th.data.prom_type==6){
  623 + title=th.data.prom_act.share_title;
  624 + img=th.data.iurl+th.data.prom_act.share_imgurl;
  625 + }
  626 +
  627 + return {
  628 + title: price + "元 " +title,
  629 + path: "/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid,
  630 + imageUrl: img,
  631 + }
  632 +
  633 + },
  634 +
  635 + //-----图片失败,默认图片-----
  636 + bind_bnerr: function(e) {
  637 + var _errImg = e.target.dataset.errorimg;
  638 + var _errObj = {};
  639 + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif";
  640 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  641 + },
  642 +
  643 + //-----图片失败,默认图片-----
  644 + bind_bnerr2: function(e) {
  645 +
  646 + var _errImg = e.target.dataset.errorimg;
  647 + var _errObj = {};
  648 + _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png"
  649 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  650 + },
  651 +
  652 + //---------拿出门店分类和门店------------
  653 + get_sto(e) {
  654 + var th = this,that=this;
  655 + var timer_get = setInterval(function() {
  656 + if (th.data.is_get_local_ok == 0) return false;
  657 + var dd = null,
  658 + i = getApp().request;
  659 + var g_distr_type = th.data.data.distr_type;
  660 + if (g_distr_type != 0) {
  661 + dd = {
  662 + store_id: o.stoid,
  663 + distr_type: g_distr_type,
  664 + isstop: 0,
  665 + pageSize: 2000
  666 + }
  667 + } else {
  668 + dd = {
  669 + store_id: o.stoid,
  670 + isstop: 0,
  671 + pageSize: 2000
  672 + }
  673 + }
  674 + //如果有距离的话
  675 + if (th.data.lat != null) {
  676 + dd.lat = th.data.lat;
  677 + dd.lon = th.data.lon;
  678 + }
  679 + clearInterval(timer_get);
  680 + //----------获取门店----------------
  681 + getApp().request.promiseGet("/api/weshop/pickup/list", {
  682 + data: dd,
  683 + }).then(res => {
  684 + var e = res;
  685 + if (e.data.code == 0) {
  686 +
  687 + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
  688 + if(dd.lat && !th.data.def_pick_store && th.data.bconfig.is_sort_storage){
  689 + th.setData({
  690 + def_pick_store:e.data.data.pageData[0],
  691 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  692 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  693 + sto_sele_distr: e.data.data.pageData[0].distr_type
  694 + });
  695 + th.data.fir_def_store=e.data.data.pageData[0];
  696 + }
  697 +
  698 + //-- 如果有默认选择门店的时候,要把默认门店放在第一位 --
  699 + if (th.data.def_pick_store) {
  700 + for (var k = 0; k < e.data.data.pageData.length; k++) {
  701 + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
  702 + e.data.data.pageData.splice(k, 1); //删除
  703 + break;
  704 + }
  705 + }
  706 + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
  707 + }
  708 +
  709 +
  710 + th.setData({all_pick_list:e.data.data.pageData});
  711 +
  712 + //--获取线下库存,而且不是新的门店规则,同时不能是活动--
  713 + if(th.data.sales_rules==2 && !th.data.is_newsales_rules && th.data.prom_type!=1 && th.data.prom_type!=6){
  714 + setTimeout(function(){
  715 + th.deal_pickup_dline(e);
  716 + },800)
  717 + }else{
  718 + setTimeout(function(){
  719 + th.deal_pickup(e); //--普通门店排版--
  720 + },800)
  721 + }
  722 + }
  723 + })
  724 + }, 200)
  725 + },
  726 +
  727 + //------------处理门店---------------
  728 + deal_pickup(e){
  729 + var th=this;
  730 + //单总量超出5个的时候
  731 + if (e.data.data.total > 5) {
  732 + getApp().request.get("/api/weshop/storagecategory/page", {
  733 + data: {
  734 + store_id: o.stoid,
  735 + is_show: 1,
  736 + pageSize: 1000
  737 + },
  738 + success: function(ee) {
  739 + if (ee.data.code == 0) {
  740 + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
  741 + var def_arr = new Array();
  742 + var ishas = 0;
  743 + //-- 开始就看5个门店 --
  744 + for (var k = 0; k < 5; k++) {
  745 + if (k == e.data.data.pageData.length) break;
  746 + def_arr.push(e.data.data.pageData[k]);
  747 + }
  748 +
  749 + th.setData({
  750 + def_pickpu_list: def_arr,
  751 + pickpu_list: ee.data.data.pageData
  752 + });
  753 + var sto_cate = ee.data.data.pageData;
  754 + var sto_arr = e.data.data.pageData;
  755 + var newarr = new Array();
  756 + var qita = new Array();
  757 +
  758 + //----要进行门店分组--------
  759 + for (var i = 0; i < sto_arr.length; i++) {
  760 + //找一下这个门店有没有在分类数组内
  761 + var find2 = 0,
  762 + find2name = "";
  763 + for (var m = 0; m < sto_cate.length; m++) {
  764 + if (sto_arr[i].category_id == sto_cate[m].cat_id) {
  765 + find2 = sto_cate[m].cat_id;
  766 + find2name = sto_cate[m].cat_name;
  767 + break;
  768 + }
  769 + }
  770 +
  771 + if (newarr.length > 0) {
  772 + var find = 0;
  773 + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
  774 + if (find2 != 0) {
  775 + for (var ii = 0; ii < newarr.length; ii++) {
  776 + if (sto_arr[i].category_id == newarr[ii].cat_id) {
  777 + newarr[ii].s_arr.push(sto_arr[i]);
  778 + find = 1;
  779 + break;
  780 + }
  781 + }
  782 + if (find == 0) {
  783 + var arr0 = new Array();
  784 + arr0.push(sto_arr[i]);
  785 + var item = {
  786 + cat_id: find2,
  787 + name: find2name,
  788 + s_arr: arr0
  789 + };
  790 + newarr.push(item);
  791 + }
  792 + } else {
  793 + qita.push(sto_arr[i]);
  794 + }
  795 + } else {
  796 + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
  797 + if (find2 != 0) {
  798 + var arr0 = new Array();
  799 + arr0.push(sto_arr[i]);
  800 + var item = {
  801 + cat_id: find2,
  802 + name: find2name,
  803 + s_arr: arr0
  804 + };
  805 + newarr.push(item);
  806 + } else {
  807 + qita.push(sto_arr[i]);
  808 + }
  809 + }
  810 + }
  811 +
  812 + //----安排其他的分类-----
  813 + if (qita.length > 0) {
  814 + var item = {
  815 + cat_id: -1,
  816 + name: "其他",
  817 + s_arr: qita
  818 + };
  819 + newarr.push(item);
  820 + }
  821 + th.setData({
  822 + is_show_sto_cat: 1,
  823 + all_sto: newarr
  824 + });
  825 +
  826 + } else {
  827 + th.setData({
  828 + is_show_sto_cat: -1,
  829 + only_pk: e.data.data.pageData
  830 + });
  831 + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
  832 + if (!th.data.def_pick_store) {
  833 + th.setData({def_pick_store:e.data.data.pageData[0]})
  834 + }
  835 + }
  836 + } else {
  837 + th.setData({
  838 + is_show_sto_cat: -1,
  839 + only_pk: e.data.data.pageData
  840 + });
  841 + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
  842 + if (!th.data.def_pick_store) {
  843 + th.setData({def_pick_store:e.data.data.pageData[0]})
  844 + }
  845 +
  846 + }
  847 + }
  848 + });
  849 + } else {
  850 + th.setData({
  851 + is_show_sto_cat: 0,
  852 + only_pk: e.data.data.pageData
  853 + });
  854 + //-----如果没有默认门店,要取第一个门店作为默认店------
  855 + if (!th.data.def_pick_store && th.data.bconfig.is_sort_storage) {
  856 + th.setData({
  857 + def_pick_store:e.data.data.pageData[0],
  858 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  859 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  860 + sto_sele_distr: e.data.data.pageData[0].distr_type
  861 + })
  862 + }
  863 + }
  864 +
  865 + },
  866 + //------------处理线下门店库存--------
  867 + deal_pickup_dline(e){
  868 + var pkno=[],th=this;
  869 + if(this.data.def_pick_store){
  870 + pkno.push(this.data.def_pick_store.pickup_no);
  871 + }
  872 + for(var i in e.data.data.pageData){
  873 + var item=e.data.data.pageData[i];
  874 + if(pkno.indexOf(item.pickup_no)<0)
  875 + pkno.push(item.pickup_no);
  876 + }
  877 + var pkno_str=pkno.join(",");
  878 + var o_plist=e.data.data.pageData;
  879 + var new_list=[];
  880 + var is_find_def_store=0;
  881 +
  882 + var lock=[];
  883 + //先读取门店的lock,采用链式写法,少用await
  884 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
  885 + data:{store_id:os.stoid,wareId:th.data.data.goods_id,pageSize:1000}
  886 + }).then(res=>{
  887 + if(res.data.code==0 && res.data.data.total>0){
  888 + lock=res.data.data.pageData
  889 + }
  890 + //---通过接口获取门店的线下库存信息--
  891 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
  892 + data:{storageNos:pkno_str,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
  893 + })
  894 + }).then(res=>{
  895 + if(res.data.code==0){
  896 + if(res.data.data.pageData){
  897 + var plist=res.data.data.pageData;
  898 + var def_pick_store=th.data.def_pick_store;
  899 + //以原来的数组为外循环,保证距离的顺序
  900 + for(var kk in o_plist){
  901 + for(var ii in plist){
  902 + //线下的门店小心
  903 + var n_item=plist[ii];
  904 + if(n_item.StorageNo==o_plist[kk].pickup_no){
  905 +
  906 + //拿到锁库的数量
  907 + var lock_num=th.find_lock_num(o_plist[kk].pickup_id,lock);
  908 + //可出库数大于预出库库存的数量,可以判断为有库存
  909 + if(n_item.CanOutQty>lock_num){
  910 + o_plist[kk].CanOutQty=n_item.CanOutQty-lock_num;
  911 + new_list.push(o_plist[kk]);
  912 + //如果找到默认门店
  913 + if(th.data.fir_def_store && n_item.StorageNo==th.data.fir_def_store.pickup_no){
  914 + th.data.fir_def_store.CanOutQty=n_item.CanOutQty-lock_num;
  915 + if(def_pick_store.pickup_id==th.data.fir_def_store.pickup_id)
  916 + th.setData({def_pick_store:th.data.fir_def_store})
  917 + is_find_def_store=1;
  918 + }
  919 + }
  920 + break;
  921 + }
  922 + }
  923 + }
  924 +
  925 + //数据组装下
  926 + var em={};em.data={};em.data.data={};
  927 + em.data.data.total=new_list.length;
  928 + em.data.data.pageData=new_list;
  929 +
  930 + if(th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id){
  931 + th.data.fir_def_store.CanOutQty=0;
  932 + //--当选择的门店是客户默认的门店的时候--
  933 + if(th.data.def_pick_store && th.data.fir_def_store.pickup_id==th.data.def_pick_store.pickup_id) {
  934 + th.setData({def_pick_store:th.data.fir_def_store});
  935 + em.data.data.pageData.unshift(th.data.def_pick_store);
  936 + }else{
  937 + em.data.data.pageData.splice(1,0,th.data.fir_def_store);
  938 + }
  939 + }
  940 +
  941 + //---把数组组装进去---
  942 + th.deal_pickup(em);
  943 + }else{
  944 + th.setData({def_pick_store:null,all_sto:null,only_pk:null})
  945 + }
  946 + }else{
  947 + th.setData({def_pick_store:null,all_sto:null,only_pk:null})
  948 + }
  949 + })
  950 + },
  951 +
  952 + find_lock_num(pick_id,lock){
  953 + var lock_num=0;
  954 + if(!lock) return 0;
  955 + if(lock.length<0) return 0;
  956 + for(var i in lock){
  957 + if(pick_id==lock[i].pickupId){
  958 + lock_num+=lock[i].outQty;
  959 + }
  960 + }
  961 + return lock_num;
  962 + },
  963 +
  964 + //----------取货门店被点击的效果------
  965 + getmendian: function(t) {
  966 + this.setData({
  967 + ismend: 1,
  968 + });
  969 + },
  970 + //----------隐藏取货门店,选取门店----------
  971 + hidemend: function(e) {
  972 + var pid = e.target.dataset.p_id;
  973 + var pname = e.target.dataset.p_name;
  974 + var p_distr_t = e.target.dataset.p_dis;
  975 + this.setData({
  976 + ismend: 0,
  977 + is_sec_mend: 0,
  978 + sto_sele_id: pid,
  979 + sto_sele_name: pname,
  980 + sto_sele_distr: p_distr_t
  981 + });
  982 + },
  983 + //------显示取货2级----------
  984 + show_sec: function(t) {
  985 + var index = t.target.dataset.index;
  986 + var item = this.data.all_sto[index];
  987 + this.setData({
  988 + is_sec_mend: 1,
  989 + sec_sto: item
  990 + });
  991 + },
  992 + //------隐藏取货门店2级----
  993 + hide_sec_mend: function() {
  994 + this.setData({
  995 + is_sec_mend: 0,
  996 + });
  997 + },
  998 +
  999 + //加载更多是靠这个函数
  1000 + onReachBottom: function() {
  1001 +
  1002 + },
  1003 + //--------检查是搭配促销活动是不是结束-------
  1004 + async check_prom(gid, prom_type, prom_id) {
  1005 +
  1006 + },
  1007 +
  1008 + //-------------获取购买数量的总函数----------------
  1009 + get_buy_num: function(gd, func) {
  1010 + var map = this.data.g_buy_num,
  1011 + th = this,
  1012 + user_id = getApp().globalData.user_id;
  1013 + if (user_id == null) {
  1014 + map.set(gd.goods_id, 0);
  1015 + th.setData({
  1016 + g_buy_num: map,
  1017 + prom_buy_num: 0,
  1018 + });
  1019 + "function" == typeof func && func();
  1020 + return false;
  1021 + }
  1022 +
  1023 + if (map.has(gd.goods_id)) {
  1024 + "function" == typeof func && func();
  1025 + } else {
  1026 + //----获取商品购买数----
  1027 + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  1028 + data: {
  1029 + store_id: os.stoid,
  1030 + user_id: user_id,
  1031 + goods_id: gd.goods_id
  1032 + },
  1033 + success: function(t) {
  1034 + if (t.data.code == 0) {
  1035 + var g_buy_num = t.data.data.goodsbuynum;
  1036 + if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) {
  1037 + //----获取活动购买数----
  1038 + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  1039 + data: {
  1040 + store_id: os.stoid,
  1041 + user_id: user_id,
  1042 + goods_id: gd.goods_id,
  1043 + prom_type: gd.prom_type,
  1044 + prom_id: gd.prom_id
  1045 + },
  1046 + //-----获取-----
  1047 + success: function(tt) {
  1048 + if (tt.data.code == 0) {
  1049 + map.set(gd.goods_id, g_buy_num);
  1050 + th.setData({
  1051 + g_buy_num: map,
  1052 + prom_buy_num: tt.data.data.goodsbuynum,
  1053 + });
  1054 + "function" == typeof func && func();
  1055 + }
  1056 + }
  1057 + });
  1058 + } else {
  1059 + map.set(gd.goods_id, g_buy_num);
  1060 + th.setData({
  1061 + g_buy_num: map
  1062 + });
  1063 + "function" == typeof func && func();
  1064 + }
  1065 + }
  1066 + }
  1067 + });
  1068 + }
  1069 + },
  1070 +
  1071 + //--跳转到商品详情页面--
  1072 + go_goods: function(e) {
  1073 + var gid = e.currentTarget.dataset.gid;
  1074 + var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
  1075 + getApp().goto(url);
  1076 + },
  1077 +
  1078 + // 选择门店
  1079 + choice_store: function(ee) {
  1080 + var th = this;
  1081 + var ind=ee.currentTarget.dataset.ind;
  1082 + var bconfig = th.data.bconfig;
  1083 +
  1084 + if(!th.data.only_pk && !th.data.def_pickpu_list){
  1085 + getApp().confirmBox("门店库存不足", null, 25000, !1);
  1086 + return false;
  1087 + }
  1088 +
  1089 + if(th.data.only_pk && !th.data.only_pk.length){
  1090 + getApp().confirmBox("门店库存不足", null, 25000, !1);
  1091 + return false;
  1092 + }
  1093 + if(th.data.def_pickpu_list && !th.data.def_pickpu_list.length){
  1094 + getApp().confirmBox("门店库存不足", null, 25000, !1);
  1095 + return false;
  1096 + }
  1097 +
  1098 +
  1099 + if (bconfig.is_sort_storage) {
  1100 + wx.getLocation({
  1101 + type: 'wgs84',
  1102 + success: function(res) {
  1103 +
  1104 + th.data.lat = res.latitude;
  1105 + th.data.lon = res.longitude;
  1106 + th.data.is_get_local_ok = 1;
  1107 + th.setData({
  1108 + is_gps: 1
  1109 + });
  1110 + //th.onShow();
  1111 + //th.get_sto();
  1112 + },
  1113 + fail: function(res) {
  1114 + //th.onShow();
  1115 + th.data.is_get_local_ok = 1;
  1116 + th.get_sto();
  1117 + if (res.errCode == 2) {
  1118 + th.setData({
  1119 + is_gps: 0
  1120 + });
  1121 + if (th.data.is_gps == 0) {
  1122 + getApp().confirmBox("请开启GPS定位", null, 25000, !1);
  1123 + }
  1124 + } else {
  1125 + th.setData({
  1126 + is_gps: "3"
  1127 + });
  1128 + }
  1129 +
  1130 + }
  1131 + })
  1132 + }else{
  1133 + th.data.is_get_local_ok = 1;
  1134 + }
  1135 +
  1136 + if(ind!=undefined && ind!=null ){
  1137 + this.setData({
  1138 + open_ind_store: ind,
  1139 + store: 1,
  1140 + openSpecModal: !1,
  1141 + openSpecModal_pt: !1
  1142 + })
  1143 + }else{
  1144 + this.setData({
  1145 + store: 1,
  1146 + openSpecModal: !1,
  1147 + openSpecModal_pt: !1
  1148 + })
  1149 + }
  1150 + },
  1151 + //关闭选择门店
  1152 + close_popup: function(e) {
  1153 + var th=this;
  1154 + this.setData({
  1155 + store: 0,
  1156 + choice_sort_store: 0,
  1157 + sort_store: 0,
  1158 + fir_pick_index:0,
  1159 + sec_pick_index:0
  1160 + })
  1161 +
  1162 + var openindstore=this.data.open_ind_store;
  1163 + if (openindstore == 1) {
  1164 + th.setData({
  1165 + openSpecModal: !0,
  1166 + openSpecModal_ind: openindstore,
  1167 + });
  1168 + } else if (openindstore == 2) {
  1169 + th.setData({
  1170 + openSpecModal: !0,
  1171 + openSpecModal_ind: openindstore,
  1172 + });
  1173 + }
  1174 + else if (openindstore == 4) { //4就是拼团
  1175 + th.setData({
  1176 + openSpecModal_pt: 1, //打开拼团购买界面
  1177 + store: 0, //关闭门店
  1178 + choice_sort_store: 0, //关闭门店2级
  1179 + sort_store: 0, //关闭门店2级
  1180 + });
  1181 + }
  1182 + else {
  1183 + th.setData({
  1184 + store: 0,
  1185 + choice_sort_store: 0,
  1186 + sort_store: 0
  1187 + })
  1188 + }
  1189 +
  1190 + },
  1191 +
  1192 + //选择更多门店
  1193 + more_store: function() {
  1194 + this.setData({
  1195 + sort_store: 1
  1196 + });
  1197 + },
  1198 +
  1199 + //---选择分类门店---
  1200 + choice_sort_store: function(e) {
  1201 + var index = e.currentTarget.dataset.index;
  1202 + var region_name = e.currentTarget.dataset.region;
  1203 + var item = this.data.all_sto[index];
  1204 + this.setData({
  1205 + region_name: region_name,
  1206 + sort_store: 0,
  1207 + choice_sort_store: 1,
  1208 + sec_sto: item,
  1209 + sec_pick_index: 0
  1210 + });
  1211 + },
  1212 +
  1213 + choose_for_store_fir: function(e) {
  1214 + var index_c = e.currentTarget.dataset.ind;
  1215 + var th=this;
  1216 + th.setData({
  1217 + fir_pick_index: index_c
  1218 + })
  1219 +
  1220 + },
  1221 +
  1222 + //如果开启线下库存,已经急速库存才会使用
  1223 + async check_the_pick(item,func){
  1224 + var th=this;
  1225 + var goodsinfo=th.data.data;
  1226 + var erpwareid=goodsinfo.erpwareid;
  1227 + var plist=null;
  1228 + var lock=0;
  1229 +
  1230 + //---如果是活动的时候---
  1231 + if(th.data.prom_type==1 || th.data.prom_type==6){
  1232 + func(); return false;
  1233 + }
  1234 +
  1235 + if(this.data.sales_rules!=2){
  1236 + func();
  1237 + }else{
  1238 +
  1239 + //先读取门店的lock
  1240 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
  1241 + data:{store_id:os.stoid,wareId:goodsinfo.goods_id,storageId:item.pickup_id,pageSize:1000}
  1242 + }).then(res=>{
  1243 + if(res.data.code==0 && res.data.data.total>0){
  1244 + for(var i in res.data.data.pageData )
  1245 + lock+=res.data.data.pageData[i].outQty;
  1246 + }
  1247 + })
  1248 + //读取线下的门店库存
  1249 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
  1250 + data:{storageNos:item.pickup_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
  1251 + }).then(res=>{
  1252 + if(res.data.code==0 && res.data.data.total>0){
  1253 + plist=res.data.data.pageData[0];
  1254 + }
  1255 + })
  1256 +
  1257 + if(plist && plist.CanOutQty-lock>0){
  1258 + item.CanOutQty=plist.CanOutQty-lock;
  1259 + func();
  1260 + return false;
  1261 + }
  1262 + getApp().my_warnning(item.pickup_name+"库存不足!", 0, th);
  1263 +
  1264 + }
  1265 + },
  1266 +
  1267 + //确定def_pick为选择的门店
  1268 + sure_pick: function(e) {
  1269 + var th = this;
  1270 + var item = null;
  1271 + var openindstore = th.data.open_ind_store;
  1272 +
  1273 + if (th.data.choice_sort_store == 0) {
  1274 + var index = th.data.fir_pick_index;
  1275 + if (th.data.is_show_sto_cat == 1) {
  1276 + item = th.data.def_pickpu_list[index];
  1277 + } else {
  1278 + item = th.data.only_pk[index]; //当没有门店分类的时候
  1279 + }
  1280 +
  1281 + } else {
  1282 + var index = th.data.sec_pick_index;
  1283 + item = th.data.sec_sto.s_arr[index];
  1284 + }
  1285 +
  1286 + //--回调函数的用法--
  1287 + th.check_the_pick(item,function(){
  1288 + th.setData({
  1289 + def_pick_store: item,
  1290 + sto_sele_name: item.pickup_name,
  1291 + sto_sele_id: item.pickup_id,
  1292 + sto_sele_distr: item.distr_type,
  1293 + store: 0,
  1294 + choice_sort_store: 0,
  1295 + fir_pick_index: 0
  1296 + });
  1297 +
  1298 + if (openindstore == 1) {
  1299 + th.setData({
  1300 + openSpecModal: !0,
  1301 + openSpecModal_ind: openindstore,
  1302 + });
  1303 + } else if (openindstore == 2) {
  1304 + th.setData({
  1305 + openSpecModal: !0,
  1306 + openSpecModal_ind: openindstore,
  1307 + });
  1308 + }
  1309 + else if (openindstore == 4) { //4就是拼团
  1310 + th.setData({
  1311 + openSpecModal_pt: 1, //打开拼团购买界面
  1312 + store: 0, //关闭门店
  1313 + choice_sort_store: 0, //关闭门店2级
  1314 + sort_store: 0, //关闭门店2级
  1315 + });
  1316 + }
  1317 + else {
  1318 + th.setData({
  1319 + store: 0,
  1320 + choice_sort_store: 0,
  1321 + sort_store: 0
  1322 + })
  1323 + }
  1324 + })
  1325 + },
  1326 + //---点击二级之后的选择---
  1327 + choose_for_store: function(e) {
  1328 + var index_c = e.currentTarget.dataset.ind;
  1329 + var th=this;
  1330 + th.setData({
  1331 + sec_pick_index: index_c,
  1332 + fir_pick_index: index_c
  1333 + })
  1334 + },
  1335 +
  1336 + //把选择的门店设置成默认的门店def_pick
  1337 + set_def_pick: function(e) {
  1338 + var th = this;
  1339 + var item = null;
  1340 + if (th.data.choice_sort_store == 0) {
  1341 + var index = th.data.fir_pick_index;
  1342 + if (th.data.is_show_sto_cat == 1) {
  1343 + item = th.data.def_pickpu_list[index];
  1344 + } else {
  1345 + item = th.data.only_pk[index]; //当没有门店分类的时候
  1346 + }
  1347 + } else {
  1348 + var index = th.data.sec_pick_index;
  1349 + item = th.data.sec_sto.s_arr[index];
  1350 + }
  1351 +
  1352 + //先设置之前,要判断是不是有库存
  1353 + th.check_the_pick(item,function(){
  1354 + var store_id = o.stoid;
  1355 + var user_id = getApp().globalData.user_id;
  1356 + var def_pickup_id = item.pickup_id;
  1357 +
  1358 + getApp().request.put('/api/weshop/users/update', {
  1359 + data: {
  1360 + user_id,
  1361 + def_pickup_id
  1362 + },
  1363 + success: function(res) {
  1364 + if (res.data.code == 0) {
  1365 + if (th.data.choice_sort_store == 0) th.setData({
  1366 + fir_pick_index: 0
  1367 + });
  1368 + getApp().globalData.pk_store = item;
  1369 + } else {
  1370 + //s.showWarning("设置默认门店地址失败", null, 500, !1);
  1371 + getApp().my_warnning("设置默认门店地址失败",0,th)
  1372 + }
  1373 +
  1374 + }
  1375 + });
  1376 +
  1377 + th.setData({
  1378 + def_pick_store: item,
  1379 + sto_sele_name: item.pickup_name,
  1380 + sto_sele_id: item.pickup_id,
  1381 + sto_sele_distr: item.distr_type,
  1382 + store: 0,
  1383 + choice_sort_store: 0
  1384 + });
  1385 +
  1386 + var openindstore = th.data.open_ind_store;
  1387 + if (openindstore == 1) {
  1388 + th.setData({
  1389 + openSpecModal: !0,
  1390 + openSpecModal_ind: openindstore,
  1391 + store: 0,
  1392 + choice_sort_store: 0,
  1393 + sort_store: 0,
  1394 + });
  1395 + } else if (openindstore == 2) {
  1396 + th.setData({
  1397 + openSpecModal: !0,
  1398 + openSpecModal_ind: openindstore,
  1399 + store: 0,
  1400 + choice_sort_store: 0,
  1401 + sort_store: 0,
  1402 + });
  1403 + }
  1404 + else if (openindstore == 4) { //4就是拼团
  1405 + th.setData({
  1406 + openSpecModal_pt: 1, //打开拼团购买界面
  1407 + store: 0, //关闭门店
  1408 + choice_sort_store: 0, //关闭门店2级
  1409 + sort_store: 0, //关闭门店2级
  1410 + });
  1411 + }
  1412 +
  1413 + else {
  1414 + th.setData({
  1415 + store: 0,
  1416 + choice_sort_store: 0,
  1417 + sort_store: 0,
  1418 + })
  1419 + }
  1420 + })
  1421 + },
  1422 +
  1423 + wait_for_store_config: function() {
  1424 + var th = this;
  1425 + th.data.t_time = setInterval(function() {
  1426 + if (th.data.bconfig == null) false;
  1427 + var e = th.data.bconfig;
  1428 + if (e.is_sort_storage) {
  1429 + wx.getLocation({
  1430 + type: 'wgs84',
  1431 + success: function(res) {
  1432 + th.data.lat = res.latitude;
  1433 + th.data.lon = res.longitude;
  1434 + th.data.is_get_local_ok = 1;
  1435 + },
  1436 + fail: function(res) {
  1437 + if (res.errCode == 2) {
  1438 + th.setData({
  1439 + is_gps: 0
  1440 + });
  1441 + if (th.data.is_gps == 0) {
  1442 + getApp().confirmBox("请开启GPS定位", null, 10000, !1);
  1443 + }
  1444 +
  1445 + } else {
  1446 + th.setData({
  1447 + is_gps: "3"
  1448 + });
  1449 + }
  1450 + th.data.is_get_local_ok = 1;
  1451 + }
  1452 + })
  1453 + } else {
  1454 + th.data.is_get_local_ok = 1;
  1455 + }
  1456 + clearInterval(th.data.t_time);
  1457 + }, 500)
  1458 + },
  1459 +
  1460 + //-- 根据ID拿出门店 --
  1461 + get_pick_from_list(pid){
  1462 + var all_pick_list=this.data.all_pick_list;
  1463 + for(var i in all_pick_list){
  1464 + var item=all_pick_list[i];
  1465 + if(item.pickup_id==pid){
  1466 + return item;
  1467 + }
  1468 + }
  1469 + },
  1470 +
  1471 + //--- 获取卡类列表 ---
  1472 + getPlusCardType: function (func) {
  1473 + var storid = os.stoid;
  1474 + var th = this;
  1475 + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
  1476 + var plusCard = res.data.data;
  1477 + var arr = [1219, 2089, 3031];
  1478 + var new_arr = new Array();
  1479 + var card_name_map=new Map();
  1480 + for (var i = 0; i < plusCard.length; i++) {
  1481 + var name="card"+plusCard[i].CorrPrice.toLowerCase();
  1482 + card_name_map.set(name,plusCard[i].CardName);
  1483 + }
  1484 +
  1485 + var ob={"card_list":plusCard,"name_map":card_name_map};
  1486 + func(ob);
  1487 + })
  1488 + },
  1489 +
  1490 + //递归获取商品
  1491 + loop_promise:function(x,arr,func){
  1492 + var th=this;
  1493 + getApp().request.promiseGet("/api/weshop/goods/get/" + o.stoid + "/" + arr[x].goods_id, {}).then(res => {
  1494 + arr[x].goods_spec=res.data.data.goods_spec;
  1495 + arr[x].goods_color=res.data.data.goods_color;
  1496 + arr[x].original_img=res.data.data.original_img;
  1497 + arr[x].shop_price=res.data.data.shop_price;
  1498 + if(x==arr.length-1){
  1499 + func(arr); //循环再最后
  1500 + }else{
  1501 + ++x;
  1502 + th.loop_promise(x,arr,func);
  1503 + }
  1504 + })
  1505 + },
  1506 +
  1507 + //图片失败,默认图片
  1508 + bind_bnerr3: function(e) {
  1509 + var _errImg = e.target.dataset.errorimg;
  1510 + var _errObj = {};
  1511 + _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
  1512 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1513 + },
  1514 +
  1515 + set_sele:function (e) {
  1516 + var index=e.currentTarget.dataset.ind;
  1517 + var set=e.currentTarget.dataset.set;
  1518 + var text="collocationList["+index+"].sele";
  1519 + var ob={};
  1520 + ob[text]= parseInt(set);
  1521 + this.setData(ob);
  1522 +
  1523 + var price=parseFloat(this.data.collocationList[index].price);
  1524 + var cut_pirce=this.data.collocationList[index].shop_price-price;
  1525 + if(set==1){
  1526 + this.data.dp_price=parseFloat(this.data.dp_price)+price;
  1527 + this.data.cut_pirce=this.data.cut_pirce+cut_pirce;
  1528 + }else{
  1529 + this.data.dp_price=parseFloat(this.data.dp_price)-price;
  1530 + this.data.cut_pirce=this.data.cut_pirce-cut_pirce;
  1531 + }
  1532 + price=price.toFixed(2);
  1533 + cut_pirce=cut_pirce.toFixed(2);
  1534 + this.setData({dp_price: this.data.dp_price,cut_price:this.data.dp_price});
  1535 + }
  1536 +
  1537 +
  1538 +
  1539 +});
... ...
packageA/pages/prom_list/prom_list.json 0 → 100644
  1 +{
  2 + "navigationBarTitleText": "搭配促销商品",
  3 + "enablePullDownRefresh": false,
  4 + "usingComponents": {
  5 + "nav_box": "/components/nav_box/nav_box",
  6 + "warn": "/components/long_warn/long_warn"
  7 + }
  8 +}
0 9 \ No newline at end of file
... ...
packageA/pages/prom_list/prom_list.wxml 0 → 100644
  1 +<wxs module="filters" src="../../../utils/filter.wxs"></wxs>
  2 +<wxs module="g_filters" src="g_filter.wxs"></wxs>
  3 +<wxs module="tool" src="filter.wxs"></wxs>
  4 +
  5 +<view class="head" style="font-size: 34rpx">搭配商品</view>
  6 +<view class="goods_list" wx:if="{{data && data.goods_name}}">
  7 + <view class="item flex ai-center">
  8 + <view style="width:80rpx;height: 100%" class="flex ai-center jc-center"><icon type="success" size="18"></icon></view>
  9 + <view class="r_box flex">
  10 + <view><image class="r_box_img" src="{{data.original_img}}"></image></view>
  11 + <view class="flex jc_sb">
  12 + <view class="fs30" style="margin: 18rpx">
  13 + <view>{{data.goods_name}}</view>
  14 + <view>规格:{{tool.get_guige(data.goods_spec,data.goods_color)}}</view>
  15 + <view>¥{{data.shop_price}}</view>
  16 + </view>
  17 + <view></view>
  18 + </view>
  19 + </view>
  20 + </view>
  21 +
  22 + <!-- 搭配的商品 -->
  23 + <view class="item flex ai-center" wx:for="{{collocationList}}">
  24 + <view style="width:80rpx;height: 100%" class="flex ai-center jc-center">
  25 + <icon bindtap="set_sele" wx:if="{{item.sele}}" data-ind="{{index}}" data-set="0" type="success" size="18"></icon>
  26 + <icon bindtap="set_sele" wx:else data-ind="{{index}}" data-set="1" type="success" size="18" color="#adadad"></icon>
  27 +
  28 + </view>
  29 + <view class="r_box flex">
  30 + <view><image class="r_box_img" src="{{iurl+item.original_img}}" binderror="bind_bnerr3" data-errorimg="collocationList[{{index}}].original_img"></image></view>
  31 + <view class="flex jc_sb">
  32 + <view class="fs30" style="margin: 18rpx">
  33 + <view>{{item.goods_name}}</view>
  34 + <view>规格:{{tool.get_guige(item.goods_spec,item.goods_color)}}</view>
  35 + <view>¥{{item.price}}</view>
  36 + </view>
  37 + <view></view>
  38 + </view>
  39 + </view>
  40 + </view>
  41 +
  42 +</view>
  43 +
  44 +<!-------------------底部按钮-------------------->
  45 +<view class="join-cart jc_sb ai-center fs30">
  46 + <!-- 左边 -->
  47 + <view style="text-align: left; padding-left: 20rpx">
  48 + <view class="co-red"><text class="f_hei">搭配价</text>¥{{filters.toFix(data.shop_price+dp_price,2)}}</view>
  49 + <view class="co-red"><text class="f_hei">已省</text>¥{{cut_price}}</view>
  50 + </view>
  51 + <!-- 右边 -->
  52 + <view bindtap="openSpecModel" class="buy_btn ">立即购买</view>
  53 +</view>
  54 +
  55 +<!----弹起来,选择规格数量,普通商品购买和秒杀------>
  56 +<view hidden="{{!openSpecModal}}">
  57 + <view bindtap="closeSpecModal" class="cover-layer"></view>
  58 + <view class="spec-model">
  59 + <view class="pding">
  60 + <icon bindtap="closeSpecModal" class="modal-close" color="black" size="22" type="cancel"></icon>
  61 + <view class="spec-goods">
  62 + <image class="wh100 spec-img xc-distance-bottom" src="{{data.original_img}}" binderror="pop_err_img" data-errorimg="data.original_img"></image>
  63 + <view class="spec-goods-info">
  64 + <view class="spec-goods-name ellipsis-1">{{data.goods_name}}</view>
  65 + <view class="flex ai_end xc-val-money">
  66 + <view class="spec-goods-price" >
  67 + <text class="fs20">¥</text>
  68 + <!-- 如果是等级会员,且有等级价 -->
  69 + <block wx:if="{{card_field && data[card_field]>0}}">
  70 + {{data[card_field]}}
  71 + </block>
  72 + <block wx:else>
  73 + {{data.shop_price}}
  74 + </block>
  75 + </view>
  76 +
  77 + </view>
  78 + <block>
  79 + <view class="flex">
  80 + <view class="spec-goods-stock">已售:{{data.sales_sum}}</view>
  81 + <block wx:if="{{sales_rules==2}}">
  82 + <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view>
  83 + <view class="spec-goods-stock" wx:else>可售:0</view>
  84 + </block>
  85 + <block wx:else>
  86 + <view class="spec-goods-stock">可售:{{data.store_count}}</view>
  87 + </block>
  88 +
  89 + </view>
  90 + </block>
  91 + </view>
  92 + <view style="clear: both"></view>
  93 + <!-- 选择门店模块 -->
  94 + <view class="flex-space-between address ai_end xc-width ">
  95 + <view class="flex ai_end" wx:if="{{def_pick_store}}">
  96 + <text class="fs30 xc-black3 shop_name">{{def_pick_store.pickup_name}}</text>
  97 + <view class="distance fs24 xc-ash"wx:if="{{def_pick_store.distance!=null}}">
  98 + 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}}
  99 +
  100 + </view>
  101 + </view>
  102 +
  103 + <!-- 没有门店的时候 -->
  104 + <view class="flex" bindtap="choice_store" wx:else>
  105 + <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
  106 + <view class="fs28 xc-ash-9f">选择门店</view>
  107 + </view>
  108 +
  109 + <view class="red-co fs28" bindtap="choice_store" >
  110 + 更多门店
  111 + <text class="right-arrow"></text>
  112 + </view>
  113 + </view>
  114 + <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
  115 + <block wx:else>
  116 + <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view>
  117 + <block wx:else>
  118 + <view wx:if="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}">(库存不足)</view>
  119 + </block>
  120 + </block>
  121 +
  122 + <view class="fs24 xc-ash-9f xc-distance-top "wx:if="{{def_pick_store}}">地址:{{def_pick_store.fulladdress}}</view>
  123 + </view>
  124 +
  125 + <!----商品的属性项目---->
  126 + <view class="xc-goods-attribute">
  127 + <view class="spec-name">商品属性</view>
  128 + <view style="max-height: 120rpx;overflow-y: auto;">
  129 + <view class="spec_bt act" data-gid='{{item.goods_id}}'>
  130 + {{data.gg}}
  131 + </view>
  132 + </view>
  133 + </view>
  134 +
  135 +
  136 + <view class="b_num">
  137 + <view>购买数量</view>
  138 + <view class="count">
  139 + <view bindtap="subCartNum" class="sub">-</view>
  140 + <input bindblur="inputCartNum" type="number" value="{{goodsInputNum}}"></input>
  141 + <view bindtap="addCartNum" class="add">+</view>
  142 + </view>
  143 + </view>
  144 + </view>
  145 + <view class="spec-cart-btns">
  146 + <!-- 根本就找不到门店 -->
  147 + <block wx:if="{{!only_pk && !def_pickpu_list}}">
  148 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">库存不足</view>
  149 + </block>
  150 + <block wx:else>
  151 +
  152 +
  153 + <block wx:if="{{only_pk.length && !only_pk.length}}">
  154 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">库存不足</view>
  155 + </block>
  156 + <block wx:else>
  157 + <block wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">
  158 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">库存不足</view>
  159 + </block>
  160 + <block wx:else>
  161 + <block wx:if="{{!def_pick_store}}">
  162 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">请先选择门店</view>
  163 + </block>
  164 + <block wx:else>
  165 + <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 -->
  166 + <block wx:if="{{sales_rules==2}}">
  167 + <block wx:if="{{!def_pick_store.CanOutQty}}">
  168 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">库存不足</view>
  169 + </block>
  170 + <block wx:else>
  171 + <view bindtap="addCart" data-openSpecModal_ind="2"
  172 + class="spec-cart-btn spec-buy" data-action="buy">立即购买</view>
  173 + </block>
  174 + </block>
  175 + <!-- 线上销售 -->
  176 + <block wx:else>
  177 + <block wx:if="{{data.store_count<=0}}">
  178 + <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999">库存不足</view>
  179 + </block>
  180 + <block wx:else>
  181 + <view bindtap="addCart"data-openSpecModal_ind="2"
  182 + class="spec-cart-btn spec-buy" data-action="buy">立即购买</view>
  183 + </block>
  184 + </block>
  185 +
  186 + </block>
  187 + </block>
  188 + </block>
  189 + </block>
  190 +
  191 + </view>
  192 +
  193 + <view class="clear"></view>
  194 +
  195 + </view>
  196 +</view>
  197 +
  198 +
  199 +<!-- 选择门店的弹框,1.1版最新的 -->
  200 +<block wx:if="{{store==1}}">
  201 + <view class="mongolia-layer" bindtap="close_popup"></view>
  202 + <view class="popup-frame">
  203 + <block wx:if="{{sort_store==0}}">
  204 + <!-- 头部 标题 -->
  205 + <view class="popup-top flex-space-between">
  206 + <text class="fs32 nearby_store">{{choice_sort_store==0?'附近的门店':region_name}}</text>
  207 + <view>
  208 + <view>
  209 + <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
  210 + </view>
  211 + <view class="felx choose_more" bindtap="more_store">
  212 + <text class="fs26 red-co" wx:if="{{is_show_sto_cat}}">{{choice_sort_store==0?'更多门店':'返回'}}</text>
  213 + <view class="bg_rights" wx:if="{{is_show_sto_cat}}"></view>
  214 + </view>
  215 + </view>
  216 + </view>
  217 + <!-- 门店列表,最外层的门店列表,一开始 -->
  218 + <view class="store-list">
  219 + <!--如果还没有点击更多门店的时候 -->
  220 + <block wx:if="{{choice_sort_store==0}}">
  221 + <!-- 需要for循环 -->
  222 + <block wx:if="{{is_show_sto_cat==1}}">
  223 + <view class="store_choose flex" wx:for="{{def_pickpu_list}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
  224 + <view class="store flex-vertical">
  225 + <!-- 需要点击事件 -->
  226 + <block wx:if="{{index==fir_pick_index}}">
  227 + <view class="circle white xc-hook fs20 red-b">Г</view>
  228 + </block>
  229 + <block wx:else>
  230 + <view class="circle xc-hooks"></view>
  231 + </block>
  232 + <view class="address-frame xc-ash">
  233 + <view class="flex-vertical-between butttem5">
  234 + <view class="flex xc-ash">
  235 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view>
  236 + </view>
  237 + <view>
  238 + <view class="distance fs24 address-val"wx:if="{{item.distance!=null}}">
  239 + 距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+'km':filters.toFix(item.distance,0)+"m"}}</view>
  240 + </view>
  241 + </view>
  242 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  243 + </view>
  244 + </view>
  245 + </view>
  246 + </block>
  247 + <block wx:else>
  248 + <view class="store_choose flex" wx:for="{{only_pk}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
  249 + <view class="store flex-vertical">
  250 + <!-- 需要点击事件 -->
  251 + <block wx:if="{{index==fir_pick_index}}" >
  252 + <view class="circle white xc-hook fs20 red-b">Г</view>
  253 + </block>
  254 + <block wx:else>
  255 + <view class="circle xc-hooks"></view>
  256 + </block>
  257 +
  258 + <view class="address-frame xc-ash">
  259 + <view class="flex-vertical-between ">
  260 + <view class="flex xc-ash">
  261 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view>
  262 + </view>
  263 + <view>
  264 + <view class="distance fs24 address-val"
  265 + wx:if="{{item.distance!=null}}">距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}}
  266 + </view>
  267 + </view>
  268 + </view>
  269 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  270 + </view>
  271 + </view>
  272 + </view>
  273 + </block>
  274 + </block>
  275 + <block wx:else> <!-- 如果是点击选择门店分类后显示分类下的门店 -->
  276 + <view class="store_choose flex" wx:for="{{sec_sto.s_arr}}" data-ind="{{index}}" bindtap="choose_for_store">
  277 + <view class="store flex-vertical">
  278 + <!-- 需要点击事件 -->
  279 + <block wx:if="{{index==sec_pick_index}}">
  280 + <view class="circle white xc-hook fs20 red-b">Г</view>
  281 + </block>
  282 + <block wx:else>
  283 + <view class="circle xc-hooks"></view>
  284 + </block>
  285 +
  286 + <view class="address-frame xc-ash">
  287 + <view class="flex-vertical-between ">
  288 + <view class="flex xc-ash">
  289 + <view class="fs28 xc-black3 address_name">{{item.pickup_name}}</view>
  290 + </view>
  291 + <view>
  292 + <view class="distance fs24 address-val"wx:if="{{item.distance!=null}}">
  293 + 距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}}</view>
  294 + </view>
  295 + </view>
  296 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  297 + </view>
  298 + </view>
  299 + </view>
  300 + </block>
  301 +
  302 + </view>
  303 +
  304 + <!-- 门店列表底部 -->
  305 + <view class="store-bottom-frame">
  306 + <view class="store-bottom flex-vertical-between">
  307 + <view class="determine red-b fs28 white t-c" bindtap="sure_pick"
  308 + data-openindstore="{{open_ind_store}}">确定</view>
  309 + <view class="default t-c fs28" bindtap="set_def_pick"data-openindstore="{{open_ind_store}}">设为默认</view>
  310 + </view>
  311 + </view>
  312 +
  313 + </block>
  314 +
  315 +
  316 + <block wx:else>
  317 + <view class="popup-top flex-space-between">
  318 + <text class="fs32 nearby_store">门店分类选择</text>
  319 + <view>
  320 + <view>
  321 + <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
  322 + </view>
  323 + <view class="felx choose_mores" bindtap="returns">
  324 + <text class="fs26 red-co">返回</text>
  325 + </view>
  326 + </view>
  327 + </view>
  328 + <view class="sort_store_list">
  329 +
  330 + <view class="sort-store-frame" wx:for="{{all_sto}}" data-index="{{index}}" bindtap="choice_sort_store" data-region="{{item.name}}">
  331 + <view class="sort-store flex-vertical-between" >
  332 + <view class="fs30" di>{{item.name}}</view>
  333 + <view class="black_rights-frame">
  334 + <view class="black_rights"></view>
  335 + </view>
  336 + </view>
  337 + </view>
  338 +
  339 + </view>
  340 + </block>
  341 + </view>
  342 +</block>
  343 +
  344 +<warn id="warn"></warn>
  345 +
... ...
packageA/pages/prom_list/prom_list.wxss 0 → 100644
  1 +.head{ height: 100rpx; line-height: 100rpx; border-bottom: 1rpx solid #dddddd; padding: 0 20px }
  2 +.goods_list .item{ height:240rpx}
  3 +.r_box{width:670rpx;border-bottom: 1rpx solid #dddddd;height: 100%}
  4 +.r_box_img{ width:210rpx;height: 210rpx; margin: 17rpx 0 }
  5 +
  6 +
  7 +.join-cart {
  8 + position: fixed;
  9 + left: 0;
  10 + bottom: 0;
  11 + display: flex;
  12 + width: 100%;
  13 + height: 100rpx;
  14 + background-color: #fff;
  15 + text-align: center;
  16 + z-index: 9;
  17 + border-top: 4rpx solid #eee;
  18 +}
  19 +
  20 +.buy_btn{ width: 200rpx; height: 100%; background-color:#c4182e; line-height: 100rpx; color: #fff}
  21 +.f_hei{color: #333; font-size: 28rpx}
  22 +
  23 +.spec-model {
  24 + position: fixed;
  25 + bottom: 0;
  26 + z-index: 20;
  27 + background: white;
  28 + width: 100%;
  29 + /* padding: 0 30rpx; */
  30 + font-size: 32rpx;
  31 + box-sizing: border-box;
  32 + border-radius: 20rpx;
  33 + height: 72%;
  34 +}
  35 +
  36 +.spec-model .pding{padding: 0 30rpx;}
  37 +
  38 +.spec-goods {
  39 + padding: 30rpx 0 20rpx;
  40 + float: left;
  41 + width: 100%;
  42 + border-bottom:2rpx solid #eee;
  43 +}
  44 +
  45 +.spec-img {
  46 + float: left;
  47 + height: 186rpx;
  48 + width: 186rpx;
  49 + border: 4rpx solid #eee
  50 +}
  51 +
  52 +.spec-goods-info {
  53 + float: left;
  54 + padding: 0 25rpx;
  55 + width: 400rpx;
  56 +}
  57 +
  58 +.spec-goods-name {
  59 + font-size: 30rpx;
  60 + line-height: 35rpx;
  61 + height: 35rpx;
  62 + margin: 15rpx 20rpx 25rpx 0;
  63 + overflow: hidden;
  64 + text-overflow: ellipsis;color: #333;
  65 +}
  66 +
  67 +.spec-goods-price {
  68 + color: #d60021;
  69 + font-size: 33rpx;
  70 + font-weight: bold;
  71 +}
  72 +
  73 +.spec-goods-stock {
  74 + margin-top: 3rpx;
  75 + font-size: 24rpx;
  76 + color: #999999;
  77 + margin-right: 15rpx;
  78 +}
  79 +
  80 +.spec-name {
  81 + clear: both;
  82 + padding: 20rpx 0;
  83 + font-size: 30rpx;color: #333;
  84 +}
  85 +
  86 +.quhuo{font-size: 30rpx; color: #000}
  87 +.b_num{
  88 + display: flex;font-size: 30rpx; color: #333;
  89 +}
  90 +
  91 +.count {
  92 + position: fixed;
  93 + display: flex;
  94 + height: 50rpx;
  95 + border: 1rpx solid #000;
  96 + font-size: 28rpx;
  97 + right: 30rpx;
  98 +}
  99 +
  100 +
  101 +.count>view,.count>input {
  102 + width: 60rpx;
  103 + height: 50rpx;
  104 + line-height: 50rpx;
  105 + text-align: center;
  106 +}
  107 +.spec_bt{
  108 + background: fff;color: #333; margin-left: 10rpx;padding: 4rpx 15rpx 4rpx; display: inline-block;
  109 + border-radius:30rpx;font-size: 24rpx;border: 1rpx solid #ccc; margin: 10rpx; height: 40rpx; line-height: 40rpx;
  110 +}
  111 +.spec_bt.act{background: #d60021;color: #fff;border: 1rpx solid #d60021;}
  112 +.sub {
  113 + border-right: 1px solid #000;
  114 +}
  115 +
  116 +.add {
  117 + border-left: 1px solid #000;
  118 +}
  119 +
  120 +.spec-btn {
  121 + color: black;
  122 + background-color: white;
  123 + padding: 10rpx 10rpx;
  124 + font-size: 26rpx;
  125 + line-height: 28rpx;
  126 + float: left;
  127 + border: 1rpx solid #dedede;
  128 + margin: 4rpx 10rpx 4rpx 0;
  129 + border-radius: 4rpx;
  130 +}
  131 +
  132 +.spec-btn-click {
  133 + color: white;
  134 + background-color: #f23030;
  135 + border: 1rpx solid #f23030;
  136 +}
  137 +
  138 +.spec-cart-btns {
  139 + width: 92%;
  140 + line-height: 70rpx;
  141 + margin: 0rpx auto;
  142 + margin-top: 160rpx;
  143 + border-radius: 20rpx;
  144 + position: fixed;
  145 + bottom: 50rpx;
  146 + left: 4%;
  147 +}
  148 +
  149 +.spec-cart-btn {
  150 +
  151 + width:100%;
  152 + font-size: 30rpx;
  153 + text-align: center;
  154 + color: white;
  155 + border-radius: 40rpx;
  156 +}
  157 +
  158 +.spec-add-cart {
  159 + background-color: #ffb03f;
  160 +}
  161 +.spec-buy {
  162 + background-color: #f23030;
  163 + /* margin-left: 34rpx; */
  164 +}
  165 +.spec-cart-disable {
  166 + background: #bbbbbb;
  167 +}
  168 +
  169 +.spec-cart-btn-lg {
  170 + width: 614rpx;
  171 +}
  172 +.stores-img{
  173 + width: 40rpx;
  174 + height: 35rpx;
  175 + margin-right: 10rpx;
  176 +}
  177 +.shop_name{
  178 + margin-right: 10rpx;
  179 +}
  180 +.address{
  181 + width: 90%;
  182 + margin-top: 25rpx;
  183 + margin-bottom: 5rpx;
  184 +}
  185 +.distance{
  186 + padding-left: 15rpx;
  187 + padding-right: 15rpx;
  188 + background: #eee;
  189 + border-radius: 20rpx;
  190 + margin-right: 5rpx;
  191 + color: #999;
  192 + height: 38rpx;
  193 + line-height: 38rpx;
  194 +}
  195 +.sto_v .title,.sto_v .stitle{ border-top: 1rpx solid #dedede;border-bottom: 1rpx solid #dedede; height: 78rpx; line-height: 78rpx;}
  196 +.sto_v .title .tubiao,.sto_v .stitle .tubiao{width: 32rpx; height: 32rpx; margin-top: 23rpx;}
  197 +.itemlists .item{border-bottom: 1rpx solid #dedede; height: 72rpx; line-height: 72rpx;font-size: 28rpx; margin: 0 10rpx;}
  198 +
  199 +.store-list{
  200 + width: 95%;
  201 + height: 72%;
  202 + overflow-y: scroll;
  203 + margin: auto;
  204 +}
  205 +.store-list .store_choose{
  206 + width: 100%;
  207 + height: 120rpx;
  208 + line-height: 125rpx;
  209 + border-bottom: 1rpx solid #eee;
  210 +
  211 +}
  212 +.store-list .store_choose .store{
  213 + width: 100%;
  214 + margin: auto;
  215 + line-height: 37rpx;
  216 + padding-left: 20rpx;
  217 +
  218 +}
  219 +.xc-hook{
  220 + width: 35rpx;
  221 + height: 35rpx;
  222 + transform: rotate(-145deg);
  223 + line-height: 37rpx;
  224 + text-align: center;
  225 +}
  226 +.xc-hooks{
  227 + width: 30rpx;
  228 + height: 30rpx;
  229 + border: 1rpx solid #999;
  230 +}
  231 +.address-frame{
  232 + width: 93%;
  233 + margin-left: 7rpx;
  234 +
  235 +}
  236 +.nearby_store{
  237 + margin-left: 17rpx;
  238 +}
  239 +.address_name{
  240 + margin-right: 10rpx;
  241 +
  242 +}
  243 +.address-val{
  244 + height: 38rpx;
  245 + line-height: 38rpx;
  246 +
  247 +}
  248 +.store-bottom{
  249 + width: 85%;
  250 + margin: auto;
  251 + height: 70rpx;
  252 +}
  253 +.determine{
  254 + width: 260rpx;
  255 + height: 55rpx;
  256 + border-radius: 50rpx;
  257 + line-height: 55rpx;
  258 +}
  259 +.default{
  260 + width: 260rpx;
  261 + height: 55rpx;
  262 + border:3rpx solid #c8c8c8;
  263 + border-radius: 50rpx;
  264 + line-height: 55rpx;
  265 +}
  266 +.store-bottom-frame{
  267 + width: 95%;
  268 + margin: auto;
  269 +
  270 +}
  271 +/* 门店分类列表 */
  272 +.sort_store_list{
  273 + height: 82%;
  274 + overflow: hidden;
  275 + overflow-y: scroll;
  276 + width: 95%;
  277 + margin: auto;
  278 +}
  279 +.sort_store_list .sort-store-frame{
  280 + width: 100%;
  281 + height: 100rpx;
  282 + line-height:100rpx;
  283 + border-bottom: 1rpx solid #eee;
  284 +
  285 +}
  286 +.sort_store_list .sort-store-frame .sort-store{
  287 + width: 94.5%;
  288 + margin: auto;
  289 +}
  290 +.black_rights-frame{
  291 + width: 50%;
  292 +}
  293 +.black_rights-frame .black_rights{
  294 + border-top: 3rpx solid;
  295 + border-right: 3rpx solid;
  296 + transform: rotate(45deg);
  297 + display: inline-block;
  298 + width: 20rpx;
  299 + height: 20rpx;
  300 +}
  301 +
  302 +/* 选择门店的弹窗 */
  303 +.mongolia-layer{
  304 + position: fixed;
  305 + left: 0;
  306 + top: 0;
  307 + right: 0;
  308 + bottom: 0;
  309 + z-index: 11;
  310 + background: rgba(0,0,0,0.4);
  311 + width: 100%;
  312 + height: 91.9%;
  313 +}
  314 +
  315 +.popup-frame{
  316 + position: fixed;
  317 + bottom:99rpx;
  318 + z-index: 20;
  319 + background: white;
  320 + width: 100%;
  321 + border-radius: 20rpx 20rpx 0 0;
  322 + height: 72%;
  323 +}
  324 +.popup-top{
  325 + border-bottom: 1rpx solid #eee;
  326 + height: 155rpx;
  327 + width: 95%;
  328 + margin: auto;
  329 + line-height: 155rpx;
  330 +
  331 +}
  332 +.bg_rights{
  333 + border-top: 2rpx solid ;
  334 + border-right: 2rpx solid ;
  335 + transform: rotate(45deg);
  336 + display:inline-block;
  337 + width:15rpx;height:15rpx;
  338 + border-color:#da0b31;
  339 +}
  340 +.modal-closes {
  341 + position: absolute;
  342 + right: 30rpx;
  343 + top: -15rpx;
  344 + height: 25rpx;
  345 +
  346 +}
  347 +.choose_more{
  348 + margin-top: 40rpx;
  349 + margin-right: 20rpx;
  350 +
  351 +}
  352 +.choose_mores{
  353 + margin-top: 30rpx;
  354 + margin-right: 15rpx;
  355 +}
  356 +.xc-goods-attribute{
  357 + border-bottom: 1px solid #eee;
  358 + padding-bottom: 15px;
  359 + margin-bottom:40rpx;
  360 + }
0 361 \ No newline at end of file
... ...
pages/cart/cart/cart.js
... ... @@ -49,6 +49,9 @@ Page({
49 49 t.auth.hadAuth() && t.getUserInfo(function() {
50 50 a.getCardList();
51 51 });
  52 +
  53 +
  54 +
52 55 },
53 56 onShow: function() {
54 57 var th = this;
... ... @@ -121,7 +124,8 @@ Page({
121 124 user_id: app.globalData.user_id,
122 125 rd: rd,
123 126 store_id: oo.stoid,
124   - pageSize: 600
  127 + pageSize: 600,
  128 + state:0
125 129 },
126 130 success:async function(su) {
127 131 //按门店分类的数组
... ... @@ -136,18 +140,60 @@ Page({
136 140 good=res.data.data;
137 141 })
138 142 var tt=ut.gettimestamp();
139   - if((good.down_time>0 && good.down_time<tt) || good.is_on_sale==0 ){
  143 + //如果商品下架了,或者商品是赠品,一开始都要清除
  144 + if((good.down_time>0 && good.down_time<tt) || good.is_on_sale==0 || item.is_gift ){
140 145 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
141   - a.delete(url, {
  146 + getApp().request.delete(url, {
142 147 success: function(t) { }
143 148 });
144 149 //商品已经下架
145 150 continue;
146 151 }
  152 + //如果秒杀活动都去掉了,或者结束了,那么这个商品也没有必要留着
  153 + if(item.prom_type==1){
  154 + var prom=null;
  155 + await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+item.prom_id,{
  156 + }).then(res=>{
  157 + if(res.data.code==0) prom=res.data.data;
  158 + })
  159 + //---如果有活动,不算在一起---
  160 + if(!prom && prom.is_end==0 && prom.end_time>now && prom.start_time<now){
  161 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  162 + a.delete(url, {
  163 + success: function(t) { }
  164 + });
  165 + //商品已经下架
  166 + continue;
  167 + }
  168 + }
  169 + //--判断优惠活动有没有过期--
  170 + else if(item.prom_type==3){
  171 + var isok=1;
  172 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+item.goods_id+"/1", {}).then(res => {
  173 + if(res.data.code==0){
  174 + var r_data=res.data.data;
  175 + if(!r_data.promGoodsLists){
  176 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  177 + a.delete(url, {});
  178 + //商品已经下架
  179 + isok=0;
  180 + }
  181 + }
  182 + else{
  183 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  184 + a.delete(url, { });
  185 + //商品已经下架
  186 + isok=0;
  187 + }
  188 + })
  189 + if(!isok) continue;
  190 + }
  191 +
147 192 all_num += item.goods_num;
148 193 item.original_img = oo.imghost + item.original_img;
149 194 item.selected = 0;
150 195  
  196 +
151 197 var pcid = item.pick_id;
152 198 var find = 0;
153 199 //---------循环查找门店---
... ... @@ -183,6 +229,14 @@ Page({
183 229 }
184 230 }
185 231  
  232 + if(arr.length==0) {
  233 + setTimeout(function () {
  234 + var goods_list = th.selectComponent("#goods_list"); //组件的id
  235 + goods_list.init();
  236 + goods_list.get_list();
  237 + }, 800)
  238 + }
  239 +
186 240 th.setData({
187 241 requestData: arr,
188 242 all_num: all_num,
... ... @@ -292,6 +346,7 @@ Page({
292 346 }
293 347 var fir = 0;
294 348 for (var j = 0; j < item.length; j++) {
  349 + if(item[j].is_gift) continue;
295 350 if (fir == 0) {
296 351 fir = item[j].distr_type;
297 352 } else {
... ... @@ -324,6 +379,11 @@ Page({
324 379 total_fee: tfeel.toFixed(2),
325 380 total_num: t_num,
326 381 });
  382 +
  383 + for(var i in e.data.requestData){
  384 + e.check_prom_activity(i)
  385 + }
  386 +
327 387 }
328 388 },
329 389  
... ... @@ -370,6 +430,7 @@ Page({
370 430 e.setData({
371 431 [txt]: Number(!sele),
372 432 });
  433 + e.check_prom_activity(pitems);
373 434 this.doCheckAll();
374 435 },
375 436  
... ... @@ -379,8 +440,7 @@ Page({
379 440 item = t.currentTarget.dataset.item,
380 441 pitems = t.currentTarget.dataset.pitems;
381 442 a = this.data.requestData[pitems].goods[item];
382   - var isok = 1,
383   - fir = 0;
  443 + var isok = 1,fir = 0;
384 444 var iarr = e.data.requestData[pitems].goods;
385 445  
386 446  
... ... @@ -411,6 +471,12 @@ Page({
411 471 e.setData({
412 472 [txt]: Number(!a.selected),
413 473 });
  474 +
  475 + if(a.prom_type==3){
  476 + //判断商品是不是优惠活动
  477 + e.check_prom_activity(pitems);
  478 + }
  479 +
414 480 this.doCheckAll();
415 481 }
416 482 },
... ... @@ -427,6 +493,7 @@ Page({
427 493 var item = car[a].goods,
428 494 is_s_sele = 1;
429 495 for (var c = 0; c < item.length; c++) {
  496 + if(item[c].is_gift) continue;
430 497 all_num += item[c].goods_num;
431 498 if (item[c].selected == 0) {
432 499 ischeck = 0;
... ... @@ -701,6 +768,9 @@ Page({
701 768 e.setData({
702 769 [txt]: t.goods_num,
703 770 });
  771 + for(var i in e.data.requestData){
  772 + e.check_prom_activity(i)
  773 + }
704 774 e.doCheckAll();
705 775 }
706 776 });
... ... @@ -725,7 +795,7 @@ Page({
725 795 for (var i = 0; i < this.data.requestData.length; i++) {
726 796 var i_arr = this.data.requestData[i].goods;
727 797 for (var j = 0; j < i_arr.length; j++) {
728   - if (i_arr[j].selected) {
  798 + if (i_arr[j].selected && i_arr[j].is_gift!=1) {
729 799 //map 的key是不会重复,会覆盖,,
730 800 var ie = {
731 801 goods_id: i_arr[j].goods_id,
... ... @@ -742,8 +812,8 @@ Page({
742 812 }
743 813 glist += i_arr[j].goods_id + ",";
744 814 ab = 1;
745   - //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算---
746   - if(i_arr[j].prom_type==0 && th.data.sales_rules==2){
  815 + //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存---
  816 + if((i_arr[j].prom_type==0 || i_arr[j].prom_type==3 || i_arr[j].prom_type==5) && th.data.sales_rules==2 && i_arr[j].is_gift!=1){
747 817 //--获取商品的线下商品ID--
748 818 var gd=null;
749 819 await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + i_arr[j].goods_id,{}).then(res=>{
... ... @@ -759,9 +829,26 @@ Page({
759 829 wx.hideLoading();
760 830 return false;
761 831 }
  832 +
  833 + var is_ok=1;
  834 + //如果是优惠活动话,要看活动有没有过期
  835 + if(i_arr[j].prom_type==3){
  836 + //判断有没有活动
  837 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+i_arr[j].goods_id+"/1", {}).then(res => {
  838 + if(res.data.code==0){
  839 + if(!res.data.data.promGoodsLists){
  840 + t.my_warnning(i_arr[j].goods_name+"优惠活动已经过期", 0, th);
  841 + wx.hideLoading();
  842 + is_ok=0;
  843 + }
  844 + }
  845 + })
  846 + }
  847 + if(!is_ok){return false;}
762 848 }
763 849  
764 850 } else {
  851 + if(i_arr[j].is_gift==1) continue;
765 852 rq.put("/api/weshop/cart/update", {
766 853 data: {
767 854 id: i_arr[j].id,
... ... @@ -1006,7 +1093,140 @@ Page({
1006 1093 url: '/pages/index/index/index',
1007 1094 })
1008 1095 },
1009   -
1010   -
  1096 +
  1097 + //---加载更多是靠这个函数----
  1098 + onReachBottom: function() {
  1099 + if(this.data.requestData.length==0) {
  1100 + var goods_list = this.selectComponent("#goods_list"); //组件的id
  1101 + if (goods_list) goods_list.get_list();
  1102 + }
  1103 + },
  1104 +
  1105 + //检查莫个门店下的商品是不是优惠活动,有的话,看要不要送礼品,同时有没有倍增
  1106 + check_prom_activity:async function (cindex) {
  1107 + var th=this;
  1108 + var map=new Map();
  1109 + var list=this.data.requestData[cindex];
  1110 + //循环处理活动,看活动商品的数量,用map来出来存储,key为活动id,值是数量
  1111 + for(var i in list.goods){
  1112 + var item=list.goods[i];
  1113 + if(item.prom_type==3 && item.selected && !item.is_gift){
  1114 + if(map.has(item.prom_id+"")){
  1115 + var ob=map.get(item.prom_id+"");
  1116 + ob.num+=item.goods_num;
  1117 + ob.price+=item.goods_num*item.goods_price;
  1118 + map.set(item.prom_id+"",ob);
  1119 + }else{
  1120 + var ob={};
  1121 + ob.num=item.goods_num;
  1122 + ob.price=item.goods_num*item.goods_price;
  1123 + map.set(item.prom_id+"",ob);
  1124 + }
  1125 + }
  1126 + }
  1127 + var map2=new Map();
  1128 + //请那些是赠品,但是优惠活动并没有被选中的商品要删除,同时满足条件的要放到map2,
  1129 + for(var i in list.goods){
  1130 + var item=list.goods[i];
  1131 + if(item.is_gift){
  1132 + if(map.has(item.prom_id+"")){
  1133 + if(!map2.has(item.prom_id+"")){
  1134 + map2.set(item.prom_id+"",i)
  1135 + }
  1136 + }else{
  1137 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  1138 + list.goods.splice(i,1);
  1139 + getApp().request.delete(url, {});
  1140 + }
  1141 + }
  1142 + }
  1143 + for(let p_item of map.entries()){
  1144 + var prom=null;
  1145 + await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+p_item[0],{}).then(res=> {
  1146 + if(res.data.code==0){
  1147 + prom=res.data.data;
  1148 + }
  1149 + })
  1150 + //如果活动已经结束
  1151 + if(!prom || prom.is_end || prom.end_time<ut.gettimestamp() ){
  1152 + for(var ii in list.goods){
  1153 + var item=list.goods[ii];
  1154 + list.goods.splice(ii,1);
  1155 + if(item.prom_id==p_item[0] && item.prom_type==3){
  1156 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  1157 + getApp().request.delete(url, {});
  1158 + }
  1159 + }
  1160 + continue;
  1161 + }
  1162 + //---读取打折的详情---
  1163 + var ob=p_item[1];var discount=null;
  1164 + await getApp().request.promiseGet("/api/weshop/goods/getDiscount",{
  1165 + data: {
  1166 + price: ob.price,
  1167 + prom_id: p_item[0],
  1168 + goods_num: ob.num,
  1169 + user_id: getApp().globalData.user_id,
  1170 + is_bz: prom.is_bz
  1171 + }
  1172 + }).then(res=>{
  1173 + if(res.data.code==0) discount=res.data.data[0];
  1174 + })
  1175 + //---如果有打折的信息,赠送的信息---
  1176 + if(discount && discount['goods_id']){
  1177 + var o=discount.goodsinfo;
  1178 + var newd = {
  1179 + goods_id: o.goods_id,
  1180 + goods_num: discount.bs,
  1181 + pick_id: list.pid,
  1182 + user_id: app.globalData.user_id,
  1183 + store_id: os.stoid,
  1184 + goods_price: 0,
  1185 + member_goods_price: 0,
  1186 + goods_name: o.goods_name,
  1187 + goods_sn: o.goods_sn,
  1188 + sku: o.sku,
  1189 + is_gift: 1,
  1190 + prom_id:p_item[0],
  1191 + prom_type:3,
  1192 + selected:1,
  1193 + gift_id:discount.gift_id
  1194 + };
  1195 +
  1196 + if(map2.has(p_item[0]+"")){
  1197 + var index=map2.get(p_item[0]+"");
  1198 + if( list.goods[index].goods_num!=discount.bs){
  1199 + list.goods[index].goods_num=discount.bs;
  1200 + getApp().request.put("/api/weshop/cart/update", {
  1201 + data: {
  1202 + id: list.goods[index].id,
  1203 + selected: 1,
  1204 + store_id: oo.stoid,
  1205 + goods_num:discount.bs
  1206 + },
  1207 + success: function(ee) {
  1208 + console.log(ee);
  1209 + }
  1210 + });
  1211 + }
  1212 +
  1213 + }else{
  1214 + var add_data=null;
  1215 + await getApp().request.promisePost("/api/weshop/cart/save", { data: newd }).then(res=>{
  1216 + if(res.data.code==0){
  1217 + add_data=res.data.data;
  1218 + }
  1219 + })
  1220 + if(add_data){
  1221 + newd.id=add_data.id;
  1222 + list.goods.push(newd);
  1223 + }
  1224 + }
  1225 + }
  1226 + }
  1227 + //--更新购物车的前台渲染--
  1228 + var rq_text="requestData["+cindex+"]";
  1229 + this.setData({[rq_text]:list});
  1230 + }
1011 1231  
1012 1232 });
1013 1233 \ No newline at end of file
... ...
pages/cart/cart/cart.json
1 1 {
2 2 "navigationBarTitleText": "购物车",
3 3 "usingComponents": {
4   - "warn": "/components/long_warn/long_warn"
  4 + "warn": "/components/long_warn/long_warn",
  5 + "goods_recommend":"/components/goods_list/goods_list"
5 6 }
6 7 }
7 8 \ No newline at end of file
... ...
pages/cart/cart/cart.wxml
... ... @@ -32,16 +32,25 @@
32 32  
33 33 </view>
34 34 <view class="order-item" data-item="{{idx}}" wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{index}}">
35   - <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}">
  35 + <block wx:if="{{!items.is_gift}}">
  36 + <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}">
36 37 <!--<radio color="red" checked="{{checkAllToggle||items.selected}}"></radio>-->
37   - <icon wx:if="{{checkAllToggle||items.selected}}" color="red" size="20" type="success"></icon>
38   - <text wx:else class="icon_no_sele"></text>
39   - </view>
  38 + <icon wx:if="{{checkAllToggle||items.selected}}" color="red" size="20" type="success"></icon>
  39 + <text wx:else class="icon_no_sele"></text>
  40 + </view>
  41 + </block>
  42 + <block wx:else><view class="order-raido flex-vertical " style="width: 45rpx"></view></block>
  43 +
40 44 <navigator class="goods-img rel" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{items.goods_id}}">
41 45 <image class="wh100" src="{{items.original_img}}" binderror="bind_bnerr2" data-errorimg="requestData[{{pidx}}].goods[{{idx}}].original_img" data-url="{{items.original_img}}"></image>
42   - <view class="abs flex-center fs26" wx:if="{{items.distr_type==0}}">自选</view>
43   - <view class="abs flex-center fs26" wx:if="{{items.distr_type==1}}">自提</view>
44   - <view class="abs flex-center fs26" wx:if="{{items.distr_type==2}}">物流</view>
  46 + <block wx:if="{{items.is_gift}}">
  47 + <view style="background-color:red" class="abs flex-center fs26" wx:if="{{items.is_gift==1}}">赠品</view>
  48 + </block>
  49 + <block wx:else>
  50 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==0}}">自选</view>
  51 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==1}}">自提</view>
  52 + <view class="abs flex-center fs26" wx:if="{{items.distr_type==2}}">物流</view>
  53 + </block>
45 54  
46 55 </navigator>
47 56 <view class="goods-cont">
... ... @@ -53,9 +62,14 @@
53 62 {{items.goods_color}}{{items.goods_color?"/":''}}{{items.goods_spec}}</view>
54 63 <view wx:else>规格1</view>
55 64 </view>
  65 + <block wx:if="{{items.is_gift}}">
  66 + <view>{{items.goods_num}}件</view>
  67 + </block>
56 68 </view>
57 69  
58   - <view class="flex alend jc_sb">
  70 +
  71 + <block wx:if="{{!items.is_gift}}">
  72 + <view class="flex alend jc_sb">
59 73 <view class="goods-price co-red baseline ellipsis-1">
60 74 <view class="fs20">¥</view>
61 75 <view class="fs28">{{items.goods_price}}</view>
... ... @@ -66,6 +80,7 @@
66 80 <view class="add" bindtap="addNum" data-pitems="{{pidx}}" data-item="{{idx}}">+</view>
67 81 </view>
68 82 </view>
  83 + </block>
69 84 </view>
70 85 </view>
71 86 </view>
... ... @@ -113,4 +128,40 @@
113 128 </view>
114 129 </view>
115 130  
  131 +<!-- 好物推荐 -->
  132 +<view class="title" style="margin-top: 60rpx" wx:if="{{(!requestData|| requestData.length==0) && is_load}}">
  133 + <!-- 标题 -->
  134 + <view>
  135 + <!-- 中文名标题 -->
  136 + <view class="China flex-level">
  137 + <view class="line flex-vertical">
  138 + <view class="one"></view>
  139 + <view class="two"></view>
  140 + <view class="three"></view>
  141 + </view>
  142 +
  143 + <view class="Recommend flex-level" bindtap="requestList">好物推荐</view>
  144 +
  145 + <view class="line flex-vertical">
  146 + <view class="three"></view>
  147 + <view class="two"></view>
  148 + <view class="one"></view>
  149 + </view>
  150 + </view>
  151 +
  152 + <!-- 英文标题 -->
  153 + <view class="english flex-center">
  154 + <view class="silk"></view>
  155 + <view class="esh five-level-word">GOOD HOT THING</view>
  156 + <view class="silk"></view>
  157 + </view>
  158 +
  159 + </view>
  160 + <!-- 商品列表组件 -->
  161 + <goods_recommend id="goods_list"></goods_recommend>
  162 +</view>
  163 +
  164 +
  165 +
  166 +
116 167 <warn id="warn"></warn>
117 168 \ No newline at end of file
... ...
pages/cart/cart/cart.wxss
... ... @@ -267,9 +267,9 @@ radio {
267 267 /* 购物车为空 */
268 268  
269 269 .empty_order image {
270   - width: 329rpx;
271   - height: 229rpx;
272   - margin-top: 140rpx;
  270 + width: 129rpx;
  271 + height: 129rpx;
  272 + margin-top: 120rpx;
273 273 }
274 274  
275 275 .empty_order .xc-ash {
... ... @@ -278,7 +278,7 @@ radio {
278 278 }
279 279  
280 280 .empty_order navigator {
281   - margin-top: 60rpx;
  281 + margin-top: 20rpx;
282 282 border-radius: 40rpx;
283 283 }
284 284  
... ... @@ -294,3 +294,55 @@ radio {
294 294 margin-left: 30rpx; margin-right: 25rpx}
295 295  
296 296 .mlr{ margin-left: 25rpx; margin-right: 20rpx}
  297 +
  298 +/* 热门好物 */
  299 +
  300 +.title .China {
  301 + width: 100%;
  302 + margin-top: 10rpx;
  303 + margin-bottom: 10rpx;
  304 + line-height: 0rpx;
  305 +}
  306 +
  307 +.title .China .line view {
  308 + width: 2rpx;
  309 +}
  310 +
  311 +.title .China .line {
  312 + height: 40rpx;
  313 + color: rgb(51, 51, 51);
  314 +}
  315 +
  316 +.title .China .line view {
  317 + border-left: 3rpx solid #000;
  318 + margin-left: 5rpx;
  319 +}
  320 +
  321 +.title .China .line .one {
  322 + height: 23rpx;
  323 +}
  324 +
  325 +.title .China .line .two {
  326 + height: 15rpx;
  327 +}
  328 +
  329 +.title .China .line .three {
  330 + height: 18rpx;
  331 +}
  332 +
  333 +.title .China .Recommend {
  334 + margin: 0rpx 20rpx;
  335 + font-size: 28rpx;
  336 + line-height: 39rpx;
  337 + font-weight: bold;
  338 +}
  339 +
  340 +.title .english .silk {
  341 + width: 214rpx;
  342 + height: 2rpx;
  343 + background-color: #000;
  344 +}
  345 +
  346 +.title .english .esh {
  347 + margin: 0rpx 15rpx;
  348 +}
... ...
pages/cart/cart2/cart2.js
... ... @@ -34,6 +34,7 @@ Page({
34 34 },
35 35 /*-----------当是购物车结算的时候-------------*/
36 36 cartlist:null,
  37 + old_cartlist:null,
37 38 cartlist_y:null, //购物车原始列表
38 39 js_use_money: 0, //是否使用余额
39 40 is_all_zt:1, //是否全部都是自提
... ... @@ -95,6 +96,14 @@ Page({
95 96 is_no_by:{},
96 97 is_by:{},
97 98 is_quan_by:{},
  99 + //--购买赠送的商品--
  100 + buy_now_gift_goods:null,
  101 + //--订单优惠--
  102 + order_prom:{},
  103 + //-- 购物车优惠活动 --
  104 + prom_goods_map:{},
  105 + //-- order_prom_list --
  106 + order_prom_list_cart:null,
98 107  
99 108 },
100 109 onLoad: function(t) {
... ... @@ -143,10 +152,23 @@ Page({
143 152 console.log("getuser_addr")
144 153 console.log(ie)
145 154  
  155 + //地址切换要把包邮券清空
  156 + if( !th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
  157 + var using_quan=th.data.using_quan;
  158 + for(var i in using_quan){
  159 + var item=using_quan[i];
  160 + if(item.isby==1){
  161 + var ob={},txt="using_quan["+i+"]";ob[txt]={};
  162 + th.setData(ob);
  163 + }
  164 + }
  165 + th.data.isget_by_quan={};
  166 + }
  167 +
146 168 th.setData({user_addr: ie });
147 169 var going=0;
148   -
149 170 //使用计时器,避免空现象
  171 + /*---
150 172 var jishi= setInterval(function () {
151 173 if (th.data.is_b_now == 1 && going==0) {
152 174 if(th.data.bn_goods) {
... ... @@ -157,7 +179,7 @@ Page({
157 179 th.calculatePrice();going = 1; clearInterval(jishi);
158 180 }
159 181 }
160   - },500)
  182 + },500)--*/
161 183  
162 184 });
163 185 //--更新默认地址--,看一下是不是跳到地址页面
... ... @@ -171,7 +193,6 @@ Page({
171 193  
172 194 //-------------------获取物流---------------
173 195 get_wuliu(func) {
174   -
175 196 var th = this;
176 197 to.getwuliu(function (e) {
177 198 th.setData({ wu_arr: e })
... ... @@ -256,7 +277,7 @@ Page({
256 277 var th = this,app=getApp();
257 278 a.get("/api/weshop/cart/list", {
258 279 data: {
259   - user_id: to.globalData.user_id, selected:1,
  280 + user_id: to.globalData.user_id, selected:1,state:0,
260 281 store_id: oo.stoid, pageSize: 600 },
261 282 success:function (su) {
262 283 //按门店分类的数组
... ... @@ -266,8 +287,11 @@ Page({
266 287  
267 288 for (var i = 0; i < carr.length; i++) {
268 289 var item = carr[i];
  290 + //要把优惠活动加入,prom_goods_map中,赠品不要运算
  291 + if(item.prom_type==3 && item.is_gift!=1){
  292 + th.add_prom_goods_map(item);
  293 + }
269 294 item.original_img = oo.imghost + item.original_img;
270   -
271 295 /*----接口要弄出来的,先顶着-----*/
272 296 var pcid = item.pick_id;
273 297 var find = 0;
... ... @@ -320,13 +344,23 @@ Page({
320 344 arr.push(ie);
321 345 }
322 346 }
  347 + //深拷贝
  348 + th.data.old_cartlist= JSON.parse(JSON.stringify(arr));
323 349 th.setData({
324 350 cartlist: arr,
325   - }),
326   -
327   - th.calculatePrice();
  351 + });
328 352 //--- 获取一下看有没有优惠券 ----
329   - th.get_cart_quan();
  353 + setTimeout(function () {
  354 + var frozenQuan=null;
  355 + var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
  356 + app.request.promiseGet(url0,{1:1}).then(res=>{
  357 + if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
  358 + th.calculatePrice();
  359 + th.get_cart_quan();
  360 + })
  361 +
  362 + },500)
  363 +
330 364 }
331 365 });
332 366 },
... ... @@ -360,7 +394,6 @@ Page({
360 394 var item=th.data.wu_arr[k]; if(def_exp_code==item.code){ m_wind=k; }
361 395 }
362 396 }
363   -
364 397 switch (gd.prom_type){
365 398 case 0:
366 399 case 2:
... ... @@ -371,21 +404,97 @@ Page({
371 404 //--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的,
372 405 // 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券--
373 406 t.data.data.shop_price=gg.goods_price;
  407 + t.data.data.goods_price=gg.goods_price;
  408 + t.data.data.goods_num=gg.goods_num;
374 409 th.data.ckeck_quan_price=t.data.data.shop_price*gg.goods_num;
375 410 th.data.check_quan_price_list=t.data.data.shop_price*gg.goods_num+"";
376 411 th.data.check_quan_ware_list=t.data.data.erpwareid+"";
377 412  
378 413 t.data.data.prom_id = 0;
379 414 t.data.data.prom_type = 0;
380   -
381   - th.setData({
382   - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
383   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t
384   - });
385   - //计算价格
386   - th.calculatePrice2();
387   - //获取优惠券
388   - th.get_buy_now_quan();
  415 +
  416 + //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
  417 + if(gg.prom_type==3){
  418 + t.data.data.prom_id = gg.prom_id ;
  419 + t.data.data.prom_type =3;
  420 + //如果是优惠活动,就要调用活动,计算价格
  421 + th.buy_now_prom_goods(gg.prom_id, t.data.data,function (data) {
  422 + //判断一下购买商品的数量是不是超过
  423 + if(data.gift_goods_id){
  424 + var num=1;
  425 + if(data.is_bz==1){
  426 + num=data.bs;
  427 + if (num > data.gift_limitnum) num = 0;
  428 + }
  429 + //如果赠品数量超出礼品库存,就取消
  430 + if(num>data['gift_storecount']) num=0;
  431 + if(num>0){
  432 + var ob={};
  433 + ob.goods_id=data.gift_goods_id;
  434 + ob.goods_name=data.gift_goods_name;
  435 + ob.goods_color=data.gift_goods_color;
  436 + ob.goods_spec=data.gift_goods_spec;
  437 + ob.original_img=os.imghost+data.gift_original_img;
  438 + ob.market_price=data.gift_market_price;
  439 + ob.gift_id=data.gift_id;
  440 + ob.shop_price=0;
  441 + ob.buynum=num;
  442 + ob.weight=data.gift_weight; //商品的重量
  443 + ob.exp_sum_type=data.gift_exp_sum_type; //商品的物流计算方式
  444 + th.setData({buy_now_gift_goods:ob});
  445 + }
  446 + }
  447 +
  448 + th.setData({
  449 + bn_goods: data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
  450 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t
  451 + });
  452 +
  453 + //计算价格
  454 + th.calculatePrice2();
  455 + //获取优惠券
  456 + th.get_buy_now_quan();
  457 +
  458 + })
  459 +
  460 + }else{
  461 + //--看是不是搭配促销--
  462 + if(gg.prom_type==5){
  463 + t.data.data.prom_id = gg.prom_id ;
  464 + t.data.data.prom_type =5;
  465 + th.setData({collocation_goods:gg.collocation_goods});
  466 +
  467 + var cart_arr=new Array();
  468 + var narr=gg.collocation_goods;
  469 + narr.push(t.data.data);
  470 + var ie = {
  471 + pickup_id: gg.pick_id, pname: gg.pick_name, goods: narr, exp_type: et, wind: m_wind, distr_t: distr_t,
  472 + goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0};
  473 + cart_arr.push(ie);
  474 + th.data.old_cartlist=cart_arr;
  475 + }
  476 + th.setData({
  477 + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
  478 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t
  479 + });
  480 +
  481 + //--搭配促销也是按照购物车的方式来计算优惠券--
  482 + if(gg.prom_type==5){
  483 + var frozenQuan=null;
  484 + var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
  485 + app.request.promiseGet(url0,{1:1}).then(res=> {
  486 + if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
  487 + //计算价格
  488 + th.calculatePrice2();
  489 + th.get_cart_quan();
  490 + });
  491 + }else{
  492 + //计算价格
  493 + th.calculatePrice2();
  494 + //获取优惠券,
  495 + th.get_buy_now_quan();
  496 + }
  497 + }
389 498  
390 499 break;
391 500 case 1: //---秒杀-----
... ... @@ -461,14 +570,16 @@ Page({
461 570 to.getConfig2(function(ee){
462 571 to.getwuliuprice( async function (rs) {
463 572  
464   - var all_price=0; //所有的商品总价
465   - var all_shipping_m= 0; //所有的物流总价
466   - var all_total_m = 0; //所有的订单应付总价
467   - var all_order_m = 0; //所有的订单应付总价
468   - var all_user_m=0; //所有的订单用户使用金额
  573 + var all_price=0; //所有的商品总价
  574 + var all_shipping_m= 0; //所有的物流总价
  575 + var all_total_m = 0; //所有的订单应付总价
  576 + var all_order_m = 0; //所有的订单应付总价
  577 + var all_user_m=0; //所有的订单用户使用金额
469 578 var all_coupon_price_m=0; //所有的订单用户使用优惠券价格
470   - var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money;
  579 + var all_cutprice=0; //所有的优惠减件
  580 + var all_order_prom=0; //所有的订单优惠
471 581  
  582 + var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money;
472 583 var freight_free = ee.freight_free; //全场满多少包邮
473 584 var no_ex_id=ee.no_ex_id;
474 585 var no_ex_good=null;
... ... @@ -483,11 +594,25 @@ Page({
483 594 by_qc=res.data.data[0];
484 595 }
485 596 })
486   - }
487   -
488   - var c_arr=th.data.cartlist;
  597 + };
  598 + var c_arr=JSON.parse(JSON.stringify(th.data.old_cartlist));
489 599 //---循环购物车---
490 600 for(var i=0;i<c_arr.length;i++){
  601 + //因为搭配购买也是再这里计算,搭配购的is_b_now==1
  602 + if(th.data.is_b_now==0) {
  603 + //此时物流的选择方式要用th.data.cartlist;
  604 + c_arr[i].exp_type = th.data.cartlist[i].exp_type;
  605 + c_arr[i].wind = th.data.cartlist[i].wind;
  606 + c_arr[i].check_quan_price_list= th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
  607 + c_arr[i].check_quan_ware_list= th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
  608 + }else{
  609 + c_arr[i].exp_type = th.data.bn_exp_type; //配送方式
  610 + c_arr[i].wind = th.data.index; //立即购买选择的物流
  611 + if(th.data.cartlist) c_arr[i].check_quan_price_list= th.data.cartlist[i].check_quan_price_list; //优惠券优惠什么商品价格
  612 + if(th.data.cartlist) c_arr[i].check_quan_ware_list= th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品
  613 +
  614 + }
  615 +
491 616 var cart_item=c_arr[i];
492 617 var pickid=cart_item.pickup_id;
493 618 var o_price=0;
... ... @@ -499,13 +624,104 @@ Page({
499 624 for(var j=0;j<item.length;j++){
500 625 o_price += item[j].goods_price * item[j].goods_num;
501 626 }
502   -
503   - th.data.cartlist[i].goods_price = o_price.toFixed(2); //商品总费用
  627 + var f_o_price=o_price;
  628 + var prom_g=th.data.prom_goods_map[pickid];
  629 + //---如果该门店的相关活动,就要算一下减价--
  630 + if(th.data.prom_goods_map[pickid]){
  631 + var ob=th.data.prom_goods_map[pickid];
  632 + for(var ii in ob){
  633 + var item_map=ob[ii];
  634 + if(item_map.bs==undefined || item_map.bs==null) {
  635 + //等待,获取一下优惠活动的信息
  636 + await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
  637 + data: {
  638 + price: item_map.price, prom_id: item_map.prom_id,
  639 + goods_num: item_map.goods_num, user_id: getApp().globalData.user_id,
  640 + is_bz: item_map.is_bz
  641 + }
  642 + }).then(res => {
  643 + if (res.data.code == 0) {
  644 + var get_data = res.data.data[0];
  645 + item_map.is_bz = get_data.is_bz; //是不是倍增
  646 + item_map.is_xz_yh = get_data.is_xz_yh; //是不是优惠
  647 + item_map.bs = get_data.bs; //是不是倍数
  648 + item_map.is_past = get_data.is_past; //是不是包邮
  649 + item_map.prom_price = get_data.price?get_data.price:0;
  650 + item_map.s_intValue = get_data.intValue;
  651 + item_map.s_coupon_id = get_data.coupon_id;
  652 + item_map.s_coupon_num = get_data.coupon_num;
  653 + item_map.gift_id = get_data.gift_id;
  654 + item_map.gift_goods_id = get_data.goods_id;
  655 + item_map.gift_goods_name = get_data.goods_name;
  656 + item_map.gift_goods_color = get_data.goodsinfo.goods_color;
  657 + item_map.gift_goods_spec = get_data.goodsinfo.goods_spec;
  658 + item_map.gift_original_img = get_data.goodsinfo.original_img;
  659 + item_map.gift_limit_num = get_data.limit_num;
  660 + item_map.gift_storecount = get_data.gift_storecount;
  661 + item_map.gift_weight = get_data.goodsinfo.weight;
  662 + item_map.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
  663 + item_map.s_libao = get_data.libao;
  664 + item_map.s_lb_num = get_data.lb_num;
  665 + }
  666 + })
  667 + }
  668 + //--------循环计算商品是不是包邮,是不是使用优惠券-----------
  669 + for(var j=0;j<item.length;j++){
  670 + if(item[j].prom_type==3 && item[j].prom_id==item_map.prom_id){
  671 + item[j].is_xz_yh= item_map.is_xz_yh;
  672 + item[j].is_past= item_map.is_past;
  673 + }
  674 + }
  675 +
  676 + //--看有没有减价--
  677 + if(item_map.price-item_map.prom_price){
  678 + if(cart_item.prom_pt_json){
  679 + cart_item.prom_pt_json.push({"prom_id":item_map.prom_id,"dis":item_map.price-item_map.prom_price,"ispt":0})
  680 + }else{
  681 + cart_item.prom_pt_json=[{"prom_id":item_map.prom_id,"dis":item_map.price-item_map.prom_price,"ispt":0}];
  682 + }
  683 + }
  684 +
  685 + o_price-=(item_map.price-item_map.prom_price);
  686 + //--优惠多少钱--
  687 + if(!cart_item.cut_price) cart_item.cut_price=0;
  688 + cart_item.cut_price+=(item_map.price-item_map.prom_price);
  689 + //---如果有送积分---
  690 + if(item_map.s_intValue){
  691 + if(!cart_item.s_intValue) cart_item.s_intValue=0;
  692 + cart_item.s_intValue+=item_map.s_intValue;
  693 + }
  694 + //-- 如果有送优惠券的情况 --
  695 + if(item_map.s_coupon_id){
  696 + if(!cart_item.s_coupon_id) {
  697 + cart_item.s_coupon_id=item_map.s_coupon_id+"";
  698 + cart_item.g_coupon_num=[{'c_id':item_map.s_coupon_id,"num": item_map.s_coupon_num}];
  699 + }
  700 + else{
  701 + cart_item.s_coupon_id+=","+item_map.s_coupon_id;
  702 + cart_item.g_coupon_num.push({'c_id':item_map.s_coupon_id,"num": item_map.s_coupon_num})
  703 + }
  704 + }
  705 + //-- 如果有送优包邮券的情况 --
  706 + if(item_map.s_libao){
  707 + if(!cart_item.s_libao) {
  708 + cart_item.s_libao=item_map.s_libao+"";
  709 + cart_item.g_lb_num=[{'l_id':item_map.s_libao,"num": item_map.s_lb_num}];
  710 + }
  711 + else{
  712 + cart_item.s_libao+=","+item_map.s_libao;
  713 + cart_item.g_lb_num.push({'l_id':item_map.s_libao,"num": item_map.s_lb_num})
  714 + }
  715 + }
  716 + }
  717 + }
  718 +
  719 + cart_item.goods_price = o_price.toFixed(2); //商品总费用
504 720 //计算物流费用
505   - th.data.cartlist[i].shipping_price = 0;
  721 + cart_item.shipping_price = 0;
506 722  
507 723 //--有不包邮区域,且不免运费,全场的计算--
508   - if(no_ex_id && freight_free>0 && o_price>freight_free && c_arr[i].exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){
  724 + if(no_ex_id && freight_free>0 && o_price>freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){
509 725 //如果有设置不包邮区域的时候
510 726 if(by_qc.region_list!="" && by_qc.region_list!=null && by_qc.region_list!=undefined ){
511 727 if(th.check_by_area(by_qc.region_list)){
... ... @@ -519,12 +735,12 @@ Page({
519 735 }
520 736 }
521 737  
522   - //--如果是物流,且选择了地址,就要开始显示包邮券--
523   - if (c_arr[i].exp_type == 0 && th.data.user_addr != null) {
  738 + //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
  739 + if (cart_item.exp_type == 0 && th.data.user_addr != null) {
524 740 //看是不是有调用过包邮券
525 741 if(!th.data.isget_by_quan[pickid]){
526   - //--判断要不要显示包邮券,链式调用接口---
527   - getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
  742 + //--判断要不要显示包邮券,调用接口,因为有for循环---
  743 + await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
528 744 data:{store_id:os.stoid,isuse:0,condition:o_price,user_id:getApp().globalData.user_id,pageSize:2000}
529 745 }).then(res=>{
530 746 if(res.data.code==0 && res.data.data.total>0){
... ... @@ -538,7 +754,6 @@ Page({
538 754 for(var ii in goods){
539 755 g_arr.push(goods[ii].goods_id);
540 756 }
541   -
542 757 if(item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
543 758 if(item.goods_list){
544 759 var no_goods_arr=item.goods_list.split(",");
... ... @@ -548,7 +763,10 @@ Page({
548 763 }
549 764 if(arr){
550 765 th.data.get_by_quan_list_cart[pickid]=arr;
551   - th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
  766 + //th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
  767 + if(th.data.is_b_now){
  768 + th.setData({get_by_quan_list:arr});
  769 + }
552 770 }
553 771 th.data.isget_by_quan[pickid]=1;
554 772 }
... ... @@ -595,12 +813,19 @@ Page({
595 813 is_good_no_by=th.check_by_goods(no_ex_good,item[j].goods_id);
596 814 }
597 815 //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
598   - if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1) continue;
  816 + if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){
  817 + var i=1;
  818 + continue;
  819 + }
  820 +
599 821 //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
600   - if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by) continue;
  822 + if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){
  823 + var i=1;
  824 + continue;
  825 + }
601 826  
602 827 //----------------如果是选择了物流---------------------
603   - if (c_arr[i].exp_type == 0 && item[j].is_free_shipping==0){
  828 + if(cart_item.exp_type == 0 && item[j].is_free_shipping==0){
604 829 //如果地址不为空
605 830 if (th.data.user_addr!=null){
606 831 switch (item[j]['exp_sum_type']) {
... ... @@ -619,24 +844,24 @@ Page({
619 844 }
620 845 }
621 846 }
622   -
623   -
  847 +
  848 +
624 849 //计算物流价格
625 850 if (c_arr[i].exp_type == 0) {
626 851 freight_free=0; //后面不在进行判断
627 852 var code = th.data.wu_arr[c_arr[i].wind].code;
628   - th.data.cartlist[i].shipping_price =
  853 + cart_item.shipping_price =
629 854 th.calculatewuliu(code, o_shipping_price, goods_weight,
630 855 goods_piece,th.data.user_addr, freight_free, o_price, rs);
631 856  
632 857 if(!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby!=1){
633   - if( th.data.cartlist[i].shipping_price ==0) th.data.is_by[pickid]=0; //已经全场包邮,就不要选择券了
  858 + if( cart_item.shipping_price ==0) th.data.is_by[pickid]=1; //已经全场包邮,就不要选择券了
634 859 }
635 860 }else{
636   - th.data.cartlist[i].shipping_price=0;
  861 + cart_item.shipping_price=0;
637 862 }
638 863  
639   - th.data.cartlist[i].shipping_price=th.data.cartlist[i].shipping_price.toFixed(2);
  864 + cart_item.shipping_price=cart_item.shipping_price.toFixed(2);
640 865 //---如果有选择优惠券的情况下---
641 866 var quan_price=0;
642 867 var coupon_price=0;
... ... @@ -660,7 +885,7 @@ Page({
660 885 if (res.data.code == 0 && res.data.data.length > 0) {
661 886 var q_data = res.data.data;
662 887 //--存储商品优惠的内容--
663   - th.data.cartlist[i].quan_youhui_list = q_data;
  888 + cart_item.quan_youhui_list = q_data;
664 889 for (var k in q_data)
665 890 quan_price += q_data[k].WareCashSum;
666 891 }
... ... @@ -669,52 +894,81 @@ Page({
669 894 }
670 895  
671 896 //总价计算,总价不包含运费
672   - th.data.cartlist[i].order_amount= (o_price -quan_price).toFixed(2);
673   - th.data.cartlist[i].total_amount= o_price.toFixed(2);
  897 + cart_item.order_amount= (o_price -quan_price).toFixed(2);
  898 + cart_item.total_amount= f_o_price.toFixed(2);
  899 +
  900 + var order_prom_amount=0; var order_prom_id=0; var o_condition=cart_item.order_amount;
  901 + var order_m=0;
  902 + //---判断是不是有订单优惠---
  903 + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion",{
  904 + data:{store_id:os.stoid,orderAmount:cart_item.order_amount}
  905 + }).then(res=>{
  906 + if(res.data.code==0){
  907 + var ord_prom=res.data.data;
  908 + order_prom_id = ord_prom['id'];
  909 + switch (ord_prom['type']) {
  910 + case 0:
  911 + order_m = Math.round(o_condition * ord_prom['expression'])/100;//满额打折
  912 + order_prom_amount=(o_condition -order_m).toFixed(2);
  913 + break;
  914 + case 1:
  915 + //order_m = o_condition - ord_prom['expression'];//满额优惠金额
  916 + order_prom_amount= ord_prom['expression'];
  917 + break;
  918 + }
  919 + }
  920 + })
674 921  
  922 + cart_item.order_prom_amount=0;
  923 + //--订单优惠的显示--
  924 + if(order_prom_id>0){
  925 + cart_item.order_amount= (o_price -quan_price-order_prom_amount).toFixed(2);
  926 + cart_item.order_prom_id=order_prom_id;
  927 + cart_item.order_prom_amount=order_prom_amount;
  928 + }
675 929 coupon_price=quan_price;
676   - if( th.data.cartlist[i].order_amount<0){
677   - th.data.cartlist[i].order_amount=0;
  930 + if( cart_item.order_amount<0){
  931 + cart_item.order_amount=0;
678 932 coupon_price=o_price;
679 933 }
680 934  
681   - th.data.cartlist[i].total_amount= parseFloat(th.data.cartlist[i].total_amount)+parseFloat(th.data.cartlist[i].shipping_price); //总金额
682   - th.data.cartlist[i].order_amount=parseFloat(th.data.cartlist[i].order_amount)+parseFloat(th.data.cartlist[i].shipping_price); //总金额
683   -
684   - th.data.cartlist[i].total_amount= th.data.cartlist[i].total_amount.toFixed(2);
685   - th.data.cartlist[i].order_amount=th.data.cartlist[i].order_amount.toFixed(2);
  935 + cart_item.total_amount= parseFloat(cart_item.total_amount)+parseFloat(cart_item.shipping_price); //总金额
  936 + cart_item.order_amount=parseFloat(cart_item.order_amount)+parseFloat(cart_item.shipping_price); //总金额
  937 + cart_item.total_amount= cart_item.total_amount.toFixed(2);
  938 + cart_item.order_amount=cart_item.order_amount.toFixed(2);
686 939  
687 940 //--------------如果使用余额---------------------
688 941 if (th.data.js_use_money == 1) {
689   - if (umoney > th.data.cartlist[i].order_amount) {
690   - th.data.cartlist[i].user_money = th.data.cartlist[i].order_amount;
691   - umoney = umoney - th.data.cartlist[i].order_amount;
  942 + if (umoney > cart_item.order_amount) {
  943 + cart_item.user_money = cart_item.order_amount;
  944 + umoney = umoney - cart_item.order_amount;
692 945 }else {
693   - th.data.cartlist[i].user_money = umoney;
  946 + cart_item.user_money = umoney;
694 947 umoney=0;
695 948 }
696 949 }else{
697   - th.data.cartlist[i].user_money=0;
  950 + cart_item.user_money=0;
698 951 }
699 952  
700   - th.data.cartlist[i].user_money = parseFloat(th.data.cartlist[i].user_money).toFixed(2);
  953 + cart_item.user_money = parseFloat(cart_item.user_money).toFixed(2);
701 954  
702   - if (coupon_price>0) th.data.cartlist[i].coupon_price=coupon_price.toFixed(2);
703   - else th.data.cartlist[i].coupon_price = coupon_price
704   - if(quan_no) th.data.cartlist[i].quan_no = quan_no;
  955 + if (coupon_price>0) cart_item.coupon_price=coupon_price.toFixed(2);
  956 + else cart_item.coupon_price = coupon_price
  957 + if(quan_no) cart_item.quan_no = quan_no;
705 958  
706 959  
707   - th.data.cartlist[i].goods_price = o_price.toFixed(2);
708   - th.data.cartlist[i].order_amount= th.data.cartlist[i].order_amount- th.data.cartlist[i].user_money; //会员使用余额
709   -
710   -
711   - all_price += parseFloat(o_price);
712   - all_total_m += parseFloat(th.data.cartlist[i].total_amount);
713   - all_shipping_m += parseFloat(th.data.cartlist[i].shipping_price);
714   - all_order_m += parseFloat(th.data.cartlist[i].order_amount);
715   - all_user_m += parseFloat(th.data.cartlist[i].user_money);
716   - all_coupon_price_m+= parseFloat(th.data.cartlist[i].coupon_price);
717   -
  960 + cart_item.goods_price = o_price.toFixed(2);
  961 + cart_item.order_amount= cart_item.order_amount- cart_item.user_money; //会员使用余额
  962 +
  963 +
  964 + all_price += parseFloat(f_o_price);
  965 + all_total_m += parseFloat(cart_item.total_amount);
  966 + all_shipping_m += parseFloat(cart_item.shipping_price);
  967 + all_order_m += parseFloat(cart_item.order_amount);
  968 + all_user_m += parseFloat(cart_item.user_money);
  969 + all_coupon_price_m+= parseFloat(cart_item.coupon_price);
  970 + all_cutprice+=parseFloat(cart_item.cut_price);
  971 + all_order_prom+=parseFloat(cart_item.order_prom_amount);
718 972 }
719 973  
720 974 all_shipping_m=parseFloat(all_shipping_m).toFixed(2);
... ... @@ -724,6 +978,8 @@ Page({
724 978 all_user_m = parseFloat(all_user_m).toFixed(2);
725 979 all_total_m = parseFloat(all_total_m).toFixed(2);
726 980 all_coupon_price_m = parseFloat(all_coupon_price_m).toFixed(2);
  981 + all_cutprice=all_cutprice.toFixed(2);
  982 + all_order_prom=all_order_prom.toFixed(2);
727 983  
728 984 var atxt = "formData.total_amount";
729 985 var atxt1 = "formData.order_amount";
... ... @@ -731,37 +987,54 @@ Page({
731 987 var atxt3 = "formData.user_money";
732 988 var atxt4 = "formData.shipping_price";
733 989 var atxt5 = "formData.coupon_price";
  990 + var atxt6 = "formData.cut_price";
  991 + var atxt7 = "formData.order_prom_amount";
734 992  
735 993 th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m,
736   - [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, [atxt5]: all_coupon_price_m })
737   -
  994 + [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
  995 + [atxt5]: all_coupon_price_m,[atxt6]: all_cutprice,
  996 + [atxt7]: all_order_prom,
  997 + })
  998 + th.data.order_prom_list_cart=c_arr;
738 999  
739 1000 });
740 1001 });
741 1002 },
742 1003 //---------计算立即购买----------
743 1004 calculatePrice2: function () {
744   -
745 1005 var th = this, good = this.data.bn_goods;
  1006 + //搭配的计算要用购物的车计算方法
  1007 + if(good.prom_type==5){
  1008 + th.calculatePrice();
  1009 + return false;
  1010 + }
746 1011 //-----------计算商品总价--------------
747 1012 var allpice = good.shop_price * good.buynum;
  1013 + var cut_price=0;
  1014 + if(good.prom_type==3 && good.prom_price){
  1015 + cut_price=allpice-good.prom_price;
  1016 + }
748 1017 allpice=parseFloat(allpice).toFixed(2);
749 1018 var txt = "formData.all_price";
750 1019 th.setData({ [txt]: allpice, });
751   - console.log(th.data.formData);
  1020 + if(cut_price){
  1021 + var c_txt="formData.cut_price";
  1022 + th.setData({ [c_txt]: cut_price, });
  1023 +
  1024 + }
752 1025  
753 1026 to.getConfig2(function (ee) {
754 1027 to.getwuliuprice(async function (rs) {
755 1028  
756 1029 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
757   - //-----------当地址不为空,且是物流时,计算物流费用----------
758   - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 ){
759   -
760   - //看是不是有调用过包邮券
761   - if(!th.data.isget_by_quan[th.data.bn_pick]){
762   - //--判断要不要显示包邮券,链式调用接口---
  1030 + //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
  1031 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1){
  1032 + //看是不是有调用过包邮券
  1033 + if(!th.data.isget_by_quan[th.data.bn_pick]){
  1034 + var condition=allpice-cut_price;
  1035 + //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额---
763 1036 getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
764   - data:{store_id:os.stoid,isuse:0,condition:allpice,user_id:getApp().globalData.user_id,pageSize:2000}
  1037 + data:{store_id:os.stoid,isuse:0,condition:condition,user_id:getApp().globalData.user_id,pageSize:2000}
765 1038 }).then(res=>{
766 1039 if(res.data.code==0 && res.data.data.total>0){
767 1040 //此时要循环判断包邮的地区,不包邮商品是不是符合
... ... @@ -776,7 +1049,7 @@ Page({
776 1049 if(arr){
777 1050 th.setData({get_by_quan_list:arr});
778 1051 }
779   - th.data.isget_by_quan[th.data.bn_pick]=1;
  1052 + th.data.isget_by_quan[th.data.bn_pick]=1;
780 1053 }
781 1054 })
782 1055 }
... ... @@ -799,14 +1072,18 @@ Page({
799 1072 var freight_free = ee.freight_free; //全场满多少包邮
800 1073 var no_ex_id=ee.no_ex_id;
801 1074 th.data.is_no_by[th.data.bn_pick]=0;
802   -
  1075 +
  1076 +
  1077 + var no_by_data=null;
  1078 + var gift_freight_free=freight_free;
803 1079 //有不包邮区域,且不免运费
804   - if(no_ex_id && freight_free>0 && freight_free<=allpice){
  1080 + if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){
805 1081 //-----------获取不包邮区域,不包邮商品-------
806 1082 await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{
807 1083 data:{store_id:os.stoid,id:no_ex_id}
808 1084 }).then(res=>{
809 1085 if(res.data.code==0){
  1086 + no_by_data=res.data.data[0];
810 1087 //如果有设置不包邮区域的时候
811 1088 if(res.data.data[0].region_list){
812 1089 if(th.check_by_area(res.data.data[0].region_list)){
... ... @@ -829,7 +1106,13 @@ Page({
829 1106 //--------------开始计算物流------------------
830 1107 var shipping_price=
831 1108 th.calculatewuliu(code, o_shipping_price, goods_weight,
832   - goods_piece, th.data.user_addr, freight_free, allpice, rs);
  1109 + goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs);
  1110 +
  1111 + //如果有赠品的时候,也要计算赠品的物流费用
  1112 + if(th.data.buy_now_gift_goods){
  1113 + shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, allpice-cut_price, rs,shipping_price,no_by_data);
  1114 + }
  1115 +
833 1116 if(shipping_price<=0){
834 1117 th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券
835 1118 }
... ... @@ -863,39 +1146,132 @@ Page({
863 1146 }
864 1147 })
865 1148 }
866   -
867 1149 }
868 1150 //-----------------支付价,优惠券不减物流-----------------
869 1151 var total_m = (parseFloat(allpice)).toFixed(2);
870   - var order_m = (parseFloat(allpice)-quan_price).toFixed(2);
871   -
  1152 + var order_m = (parseFloat(allpice-cut_price)-quan_price).toFixed(2);
872 1153 var coupon_price=quan_price; //优惠券优惠了多少钱
873 1154 if(order_m<0) {
874 1155 order_m=0;coupon_price=parseFloat(order_m).toFixed(2);
875 1156 }
  1157 + //--看一下有没有订单优惠--
  1158 + var o_condition=parseFloat(order_m);
  1159 + if(o_condition>0){
  1160 + th.check_is_order_prom(o_condition,function () {
  1161 + var order_prom_amount=0; var order_prom_id=0;
  1162 + if(th.data.order_prom[th.data.bn_pick]){
  1163 + var ord_prom=th.data.order_prom[th.data.bn_pick];
  1164 + order_prom_id = ord_prom['id'];
  1165 + switch (ord_prom['type']) {
  1166 + case 0:
  1167 + order_m = Math.round(o_condition * ord_prom['expression'])/100;//满额打折
  1168 + order_prom_amount=(o_condition -order_m).toFixed(2);
  1169 + break;
  1170 + case 1:
  1171 + order_m = o_condition - ord_prom['expression'];//满额优惠金额
  1172 + order_prom_amount= ord_prom['expression'];
  1173 + break;
  1174 + }
  1175 + }
  1176 + //--订单优惠的显示--
  1177 + if(order_prom_id>0){
  1178 + var order_prom_txt1="formData.order_prom_id";
  1179 + var order_prom_txt2="formData.order_prom_amount";
  1180 + th.setData({ [order_prom_txt1]: order_prom_id,[order_prom_txt2]: order_prom_amount})
  1181 + }
876 1182  
877   - total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
878   - order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
879   -
880   - var atxt= "formData.total_amount";
881   - th.setData({ [atxt]: total_m, })
882   -
883   - var txt = "formData.user_money";
884   - var txt2 = "formData.order_amount";
885   - var txt3="formData.coupon_price";
886   - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
887   - //--------------如果使用余额---------------------
888   - if (th.data.bn_use_money == 1) {
889   - if (amoney> order_m) {
890   - order_m = order_m.toFixed(2);
891   - th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
  1183 + total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
  1184 + order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
  1185 + var atxt= "formData.total_amount";
  1186 + th.setData({ [atxt]: total_m, })
  1187 +
  1188 + var txt = "formData.user_money";
  1189 + var txt2 = "formData.order_amount";
  1190 + var txt3="formData.coupon_price";
  1191 + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
  1192 + //--------------如果使用余额---------------------
  1193 + if (th.data.bn_use_money == 1) {
  1194 + if (amoney> order_m) {
  1195 + order_m = order_m.toFixed(2);
  1196 + th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
  1197 + }else{
  1198 + order_m =parseFloat(order_m - amoney);
  1199 + order_m = order_m.toFixed(2);
  1200 + th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
  1201 + }
  1202 + }else{
  1203 + th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
  1204 + }
  1205 + //优惠活动送积分
  1206 + if(good.s_intValue){
  1207 + txt = "formData.give_integral";
  1208 + th.setData({ [txt]:good.s_intValue });
  1209 + }
  1210 + //优惠送券
  1211 + if(good.s_coupon_id){
  1212 + var i_txt = "formData.give_coupon_id";
  1213 + //这个是json格式的
  1214 + var i_txt1 = "formData.g_coupon_num";
  1215 + var ob=[{"num":good.s_coupon_num,"c_id":good.s_coupon_id}];
  1216 + ob=JSON.stringify(ob);
  1217 + th.setData({ [i_txt]:good.s_coupon_id,[i_txt1]:ob });
  1218 + }
  1219 + //优惠礼包
  1220 + if(good.s_libao){
  1221 + var l_txt = "formData.give_lb_id";
  1222 + //这个是json格式的
  1223 + var l_txt1 = "formData.g_lb_num";
  1224 + var ob=[{"num":good.s_lb_num,"l_id":good.s_libao}];
  1225 + ob=JSON.stringify(ob);
  1226 + th.setData({ [l_txt]:good.s_libao,[l_txt1]:ob });
  1227 + }
  1228 + })
  1229 + }else{
  1230 + total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
  1231 + order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
  1232 + var atxt= "formData.total_amount";
  1233 + th.setData({ [atxt]: total_m, })
  1234 +
  1235 + var txt = "formData.user_money";
  1236 + var txt2 = "formData.order_amount";
  1237 + var txt3="formData.coupon_price";
  1238 + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
  1239 + //--------------如果使用余额---------------------
  1240 + if (th.data.bn_use_money == 1) {
  1241 + if (amoney> order_m) {
  1242 + order_m = order_m.toFixed(2);
  1243 + th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
  1244 + }else{
  1245 + order_m =parseFloat(order_m - amoney);
  1246 + order_m = order_m.toFixed(2);
  1247 + th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
  1248 + }
892 1249 }else{
893   - order_m =parseFloat(order_m - amoney);
894   - order_m = order_m.toFixed(2);
895   - th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
  1250 + th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
  1251 + }
  1252 + //优惠活动送积分
  1253 + if(good.s_intValue){
  1254 + txt = "formData.give_integral";
  1255 + th.setData({ [txt]:good.s_intValue });
  1256 + }
  1257 + //优惠送券
  1258 + if(good.s_coupon_id){
  1259 + var i_txt = "formData.give_coupon_id";
  1260 + //这个是json格式的
  1261 + var i_txt1 = "formData.g_coupon_num";
  1262 + var ob=[{"num":good.s_coupon_num,"c_id":good.s_coupon_id}];
  1263 + ob=JSON.stringify(ob);
  1264 + th.setData({ [i_txt]:good.s_coupon_id,[i_txt1]:ob });
  1265 + }
  1266 + //优惠礼包
  1267 + if(good.s_libao){
  1268 + var l_txt = "formData.give_lb_id";
  1269 + //这个是json格式的
  1270 + var l_txt1 = "formData.g_lb_num";
  1271 + var ob=[{"num":good.s_lb_num,"l_id":good.s_libao}];
  1272 + ob=JSON.stringify(ob);
  1273 + th.setData({ [l_txt]:good.s_coupon_id,[l_txt1]:ob });
896 1274 }
897   - }else{
898   - th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
899 1275 }
900 1276  
901 1277 });
... ... @@ -909,8 +1285,7 @@ Page({
909 1285 var th=this,pdata=new Array();
910 1286 var ff=true;
911 1287 //------------立即购买-------------
912   - if (th.data.is_b_now==1){
913   - console.log("buy_new");
  1288 + if (th.data.is_b_now==1 && th.data.bn_goods.prom_type!=5){
914 1289  
915 1290 if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){
916 1291 ff = false; getApp().my_warnning("请选择收货地址",0,th);
... ... @@ -920,17 +1295,12 @@ Page({
920 1295 var addr = th.data.user_addr;
921 1296 if (th.data.bn_exp_type == 1) addr=null;
922 1297  
923   - console.log(th.data.formData);
924   - console.log(th.data.wu_arr);
925   - console.log(th.data.bn_exp_type);
926   -
927 1298 if(th.data.bn_exp_type==0)
928 1299 if(th.data.wu_arr==null || th.data.wu_arr.length<=0){
929 1300 getApp().my_warnning("读取物流失败",0,th);
930 1301 return false;
931 1302 }
932 1303  
933   -
934 1304 var item={
935 1305 'user_id': to.globalData.user_id,
936 1306 'consignee': addr == null ? "" : addr.consignee,
... ... @@ -957,8 +1327,37 @@ Page({
957 1327 'exp_type': th.data.bn_exp_type, //配送方式
958 1328 'order_goods':new Array(),
959 1329 };
  1330 +
  1331 + var order_prom_list={};
  1332 + //--判断有没有优惠活动--
  1333 + if(th.data.order_prom[item.pickup_id]){
  1334 + if(th.data.formData.order_prom_amount>0){
  1335 + order_prom_list.order_prom_id=th.data.formData.order_prom_id;
  1336 + order_prom_list.order_prom_amount=th.data.formData.order_prom_amount;
  1337 + }
  1338 + }
  1339 +
  1340 + //--判断优惠活动的提交--
  1341 + if(th.data.formData.cut_price>0){
  1342 + order_prom_list.discount_amount=th.data.formData.cut_price;
  1343 + var ob=[{"prom_id":th.data.bn_goods.prom_id,"dis":th.data.formData.cut_price,"ispt":0}]
  1344 + order_prom_list.prom_pt_json=JSON.stringify(ob);
  1345 + }
  1346 + if(th.data.formData.give_integral>0){
  1347 + order_prom_list.give_integral=th.data.formData.give_integral;
  1348 + }
  1349 + if(th.data.formData.give_coupon_id>0){
  1350 + order_prom_list.give_coupon_id=th.data.formData.give_coupon_id;
  1351 + order_prom_list.give_coupon_id=th.data.formData.g_coupon_num;
  1352 + }
  1353 + if(th.data.formData.give_lb_id>0){
  1354 + order_prom_list.give_lb_id=th.data.formData.give_lb_id;
  1355 + order_prom_list.g_lb_num=th.data.formData.g_lb_num;
  1356 + }
  1357 + item.order_prom_list=order_prom_list;
  1358 +
960 1359 //组装优惠券的钱
961   - if(th.data.formData.coupon_price){
  1360 + if(parseFloat(th.data.formData.coupon_price)>0){
962 1361 item.coupon_price=th.data.formData.coupon_price;
963 1362 item.coupon_no=th.data.using_quan[th.data.bn_pick].coupon_no;
964 1363 }
... ... @@ -992,7 +1391,6 @@ Page({
992 1391 return false;
993 1392 }
994 1393 }
995   -
996 1394 //--组装优惠券的钱--
997 1395 if(th.data.formData.coupon_price){
998 1396 item.coupon_price=th.data.formData.coupon_price;
... ... @@ -1000,8 +1398,25 @@ Page({
1000 1398 goods.quan_num=th.data.formData.coupon_price;
1001 1399 goods.quan_no= item.coupon_no;
1002 1400 }
1003   -
1004 1401 item.order_goods.push(goods);
  1402 +
  1403 + //--如果有赠品的时候,赠品也要提交---
  1404 + if(th.data.buy_now_gift_goods){
  1405 + var gift_gg=th.data.buy_now_gift_goods;
  1406 + var g_goods={
  1407 + 'goods_id': gift_gg.goods_id,
  1408 + 'goods_name': gift_gg.goods_name,
  1409 + 'goods_sn': gift_gg.goods_sn,
  1410 + 'goods_num': gift_gg.buynum,
  1411 + 'market_price': gift_gg.market_price,
  1412 + 'goods_price': 0,
  1413 + 'member_goods_price': 0,
  1414 + 'store_id': oo.stoid,
  1415 + 'is_gift':1,
  1416 + 'gift_id':gift_gg.gift_id,
  1417 + };
  1418 + item.order_goods.push(g_goods);
  1419 + }
1005 1420 pdata.push(item);
1006 1421  
1007 1422 console.log(pdata);
... ... @@ -1022,8 +1437,10 @@ Page({
1022 1437 return false;
1023 1438 }
1024 1439  
1025   - for (var i = 0; i < th.data.cartlist.length;i++){
1026   - var t_item = th.data.cartlist[i];
  1440 + var order_prom_list_cart=th.data.order_prom_list_cart;
  1441 + //--组装推送数据--
  1442 + for (var i = 0; i < order_prom_list_cart.length;i++){
  1443 + var t_item = order_prom_list_cart[i];
1027 1444 var item = {
1028 1445 'user_id': to.globalData.user_id,
1029 1446 'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee,
... ... @@ -1054,12 +1471,35 @@ Page({
1054 1471 if(t_item.coupon_price) {
1055 1472 item.coupon_price = t_item.coupon_price;
1056 1473 item.coupon_no = th.data.using_quan[t_item.pickup_id].coupon_no;
1057   - }
1058   - if(t_item.quan_no) {
  1474 + }else if(t_item.quan_no) {
1059 1475 item.coupon_no = t_item.quan_no;
1060 1476 item.coupon_price = 0;
1061 1477 }
1062 1478  
  1479 + var order_prom_list={};
  1480 + //--判断有没有优惠活动--
  1481 + if(t_item.order_prom_amount>0){
  1482 + order_prom_list.order_prom_id=t_item.order_prom_id;
  1483 + order_prom_list.order_prom_amount=t_item.order_prom_amount;
  1484 + }
  1485 + //--判断优惠活动的提交--
  1486 + if(t_item.cut_price>0){
  1487 + order_prom_list.discount_amount=t_item.cut_price;
  1488 + order_prom_list.prom_pt_json=JSON.stringify(t_item.prom_pt_json);
  1489 + }
  1490 + if(t_item.s_intValue>0){
  1491 + order_prom_list.give_integral=t_item.s_intValue;
  1492 + }
  1493 + if(t_item.s_coupon_id>0){
  1494 + order_prom_list.give_coupon_id=t_item.s_coupon_id;
  1495 + order_prom_list.g_coupon_num= JSON.stringify(t_item.g_coupon_num);
  1496 + }
  1497 + if(t_item.s_libao>0){
  1498 + order_prom_list.give_lb_id=t_item.s_libao;
  1499 + order_prom_list.g_lb_num=JSON.stringify(t_item.g_lb_num);
  1500 + }
  1501 + if(Object.keys(order_prom_list).length>0)
  1502 + item.order_prom_list=order_prom_list;
1063 1503 //-------------让商品添加到商品列表--------------------
1064 1504 for (var k = 0; k < t_item.goods.length;k++){
1065 1505 var g_item = t_item.goods[k];
... ... @@ -1085,14 +1525,31 @@ Page({
1085 1525 }
1086 1526 }
1087 1527  
1088   - //如果是秒杀,团购,积分购,拼团
1089   - if (g_item.prom_type==1){
1090   - goods.prom_type = g_item.prom_type;
1091   - goods.prom_id = g_item.prom_id;
1092   - }else{
1093   - goods.prom_type = 0;goods.prom_id =0;
  1528 + //--判断活动的类型--
  1529 + switch (g_item.prom_type) {
  1530 + case 1:
  1531 + goods.prom_type = g_item.prom_type;
  1532 + goods.prom_id = g_item.prom_id;
  1533 + break;
  1534 + case 3:
  1535 + goods.prom_type=3;
  1536 + goods.prom_id=g_item.prom_id;
  1537 + if(g_item.is_gift){
  1538 + goods.is_gift=g_item.is_gift;
  1539 + goods.gift_id=g_item.gift_id;
  1540 + }
  1541 + break;
  1542 + case 5:
  1543 + goods.prom_type=5;
  1544 + goods.prom_id=g_item.prom_id;
  1545 + if(g_item.is_collocation){
  1546 + goods.is_collocation=g_item.is_collocation;
  1547 + }
  1548 + break
  1549 + default:
  1550 + goods.prom_type = 0;goods.prom_id =0;
1094 1551 }
1095   -
  1552 +
1096 1553 //如果不立即购买或者秒杀,如果是线下库存购买的时候
1097 1554 if(goods.prom_type==0 && th.data.sales_rules==2){
1098 1555 var isok=1;
... ... @@ -1115,6 +1572,7 @@ Page({
1115 1572  
1116 1573 if (pdata.length==0) return;
1117 1574 var str = JSON.stringify(pdata);
  1575 +
1118 1576 wx.showLoading({title: "加载中"});
1119 1577 wx.request({
1120 1578 url: oo.url + '/api/weshop/order/createWxdOrder',
... ... @@ -1458,14 +1916,12 @@ Page({
1458 1916  
1459 1917 //对于在其他门店已经选择了的券 要判断是否显示到界面
1460 1918 for(var i in quanlist){
1461   - var is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
1462   - if(is_using) quanlist[i].is_using=1;
  1919 + quanlist[i].is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
1463 1920 }
1464 1921  
1465   - if(get_by_quan_list_cart){
  1922 + if(get_by_quan_list_cart){
1466 1923 for(var i in get_by_quan_list_cart){
1467   - var is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
1468   - if(is_using) quanlist[i].is_using=1;
  1924 + get_by_quan_list_cart[i].is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
1469 1925 }
1470 1926 th.setData({by_quan_list_cart:get_by_quan_list_cart});
1471 1927 }
... ... @@ -1604,31 +2060,23 @@ Page({
1604 2060 return;
1605 2061 }
1606 2062  
  2063 + var pickid=th.data.selected_quan_pick; //现在选择的是哪一个门店
1607 2064 var ind = e.currentTarget.dataset.ind;
1608 2065 //--如果是立即购买的部分--
1609 2066 var txt="";var txt1=""; var quan_item=null;
1610 2067 if(th.data.is_b_now){
1611 2068 quan_item = this.data.get_by_quan_list[ind];
1612 2069 txt = "get_by_quan_list[" + ind + "].show_red";
  2070 + var obj = {}; obj[txt] = 1;
  2071 + this.setData(obj);
1613 2072 }else{
1614   - txt = "by_quan_list_cart[" + ind + "].show_red";
1615   - quan_item = th.data.by_quan_list_cart[ind]
1616   -
1617   - }
1618   - var obj = {}; obj[txt] = 1;
1619   - if (quan_item.show_red) {
1620   - obj[txt] = 0;
1621   - }
1622   -
1623   - //购物车购买过来的商品
1624   - if(txt1){
1625   - obj[txt1] = 1;
1626   - if (quan_item.show_red) {
1627   - obj[txt1] = 0;
1628   - }
  2073 + txt= "by_quan_list_cart[" + ind + "].show_red";
  2074 + quan_item = th.data.by_quan_list_cart[ind];
  2075 + var obj = {}; obj[txt] = 1;
  2076 + this.setData(obj);
  2077 + th.data.get_by_quan_list_cart[pickid]=JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
1629 2078 }
1630 2079  
1631   - this.setData(obj);
1632 2080 if(using_quan[th.data.selected_quan_pick]){
1633 2081 using_quan[th.data.selected_quan_pick].is_nouse_red=0;
1634 2082 }
... ... @@ -1640,12 +2088,12 @@ Page({
1640 2088  
1641 2089 //--确认使用券---
1642 2090 confirm_quan:function () {
1643   - var using_quan=this.data.using_quan
1644   - var pickid=this.data.selected_quan_pick;
  2091 + var using_quan=this.data.using_quan; //正在使用中的券列表
  2092 + var pickid=this.data.selected_quan_pick; //选中的门店ID
1645 2093 var th=this;
1646   - var selected_quan_list=this.data.selected_quan_list;
1647   - var get_by_quan_list=this.data.get_by_quan_list;
1648   - var by_quan_list_cart=this.data.by_quan_list_cart;
  2094 + var selected_quan_list=this.data.selected_quan_list; //选择了那个门店的券列表
  2095 + var get_by_quan_list=this.data.get_by_quan_list; //立即购买的包邮券列表
  2096 + var by_quan_list_cart=this.data.by_quan_list_cart; //购物车购买的包邮券列表
1649 2097 //选择了的券
1650 2098 var sele_quan=null;
1651 2099  
... ... @@ -1868,68 +2316,94 @@ Page({
1868 2316 },
1869 2317 //-----获取购物车进来的劵-------
1870 2318 get_cart_quan:function () {
1871   - var arr=this.data.cartlist,th=this;
1872   - //------------开始计算使用优惠券相关------------
1873   - for(var ind in arr){
1874   - var ep=arr[ind];
1875   - var goodlist=ep.goods;
1876   - //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
1877   - //就要把相应的值,写入cartlist数组中--
1878   - var ckeck_quan_price=0,
1879   - check_quan_price_list='',
1880   - check_quan_ware_list='';
1881   -
1882   - for(var i in goodlist){
1883   - var gd=goodlist[i];
1884   - //--如果是秒杀就跳出--
1885   - if(gd.prom_type==1){ continue; }
1886   - var item_price=gd.goods_price*gd.goods_num;
1887   - ckeck_quan_price+=item_price;
1888   -
1889   - //--组装价格list--
1890   - if (check_quan_price_list) {
1891   - check_quan_price_list += "," +item_price;
1892   - } else {
1893   - check_quan_price_list = item_price;
1894   - }
1895   - //--组装商品的线下erpwareid--
1896   - if (check_quan_ware_list) {
1897   - check_quan_ware_list += "," +gd['erpwareid'];
1898   - } else {
1899   - check_quan_ware_list = gd['erpwareid'];
1900   - }
1901   - }
  2319 + var th=this;
  2320 + //等待值的出现
  2321 + getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
  2322 + var arr=th.data.order_prom_list_cart;
  2323 + //如果系统有限制使用优惠券
  2324 + if(th.data.is_close_quan) return false;
  2325 + //------------开始计算使用优惠券相关------------
  2326 + for(var ind in arr){
  2327 + var ep=arr[ind];
  2328 + var goodlist=ep.goods;
  2329 + var pickup_id=ep.pickup_id;
  2330 + //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
  2331 + //就要把相应的值,写入cartlist数组中--
  2332 + var ckeck_quan_price=0,
  2333 + check_quan_price_list='',
  2334 + check_quan_ware_list='';
  2335 +
  2336 + for(var i in goodlist){
  2337 + var gd=goodlist[i];
  2338 + //--如果是秒杀就跳出,如果是赠品,如果是限制使用优惠券--
  2339 + if(gd.prom_type==1 || gd.is_gift ){ continue; }
  2340 + //如果有限制使用优惠券,就要返回
  2341 + if(gd.prom_type==3){
  2342 + if(th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
  2343 + th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele=1;
  2344 + }
  2345 + var item_price=gd.goods_price*gd.goods_num;
  2346 + ckeck_quan_price+=item_price;
  2347 + //--组装价格list--
  2348 + if (check_quan_price_list) {
  2349 + check_quan_price_list += "," +item_price;
  2350 + } else {
  2351 + check_quan_price_list = item_price;
  2352 + }
  2353 + //--组装商品的线下erpwareid--
  2354 + if (check_quan_ware_list) {
  2355 + check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
  2356 + } else {
  2357 + check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
  2358 + }
  2359 + }
  2360 + //优惠券优惠的金额要控制到优惠券的选择条件
  2361 + var cut_price=0;
  2362 + for(var i in th.data.prom_goods_map[pickup_id]){
  2363 + var obj=th.data.prom_goods_map[pickup_id][i];
  2364 + if(obj.coupon_sele){
  2365 + cut_price+=obj.price-obj.prom_price;
  2366 + }
  2367 + }
  2368 +
  2369 + arr[ind].ckeck_quan_price=ckeck_quan_price-cut_price;
  2370 + arr[ind].check_quan_ware_list=check_quan_ware_list;
  2371 + arr[ind].check_quan_price_list=check_quan_price_list;
  2372 +
  2373 + //是否关闭使用优惠券
  2374 + if (th.data.is_close_quan != 1) {
  2375 + //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
  2376 + var url="/api/weshop/couponList/getUseCouponList";
  2377 + await app.request.promiseGet(url,{ data:{storeId:oo.stoid,userId:app.globalData.user_id,BuySum:ckeck_quan_price,WareIds:check_quan_ware_list,pageSize:100}}).then(res=>{
  2378 + if (res.data.code == 0) {
  2379 + var quan_list = res.data.data.pageData;
  2380 + arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
  2381 + }
  2382 + })
  2383 + }
  2384 + }
  2385 +
  2386 + //如果是搭配购的立即购买的时候
  2387 + if(th.data.is_b_now){
  2388 + var quanlist=arr[0].quan_list;
  2389 + th.setData({selected_quan_list:quanlist,cartlist:arr})
  2390 + }else{
  2391 + th.setData({cartlist:arr })
  2392 + }
  2393 +
  2394 +
  2395 + })
  2396 + },
1902 2397  
1903   - arr[ind].ckeck_quan_price=ckeck_quan_price;
1904   - arr[ind].check_quan_ware_list=check_quan_ware_list;
1905   - arr[ind].check_quan_price_list=check_quan_price_list;
1906   -
1907   - //是否关闭使用优惠券
1908   - if (th.data.is_close_quan != 1) {
1909   - var frozenQuan=null;
1910   - var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
1911   - app.request.promiseGet(url0,{1:1}).then(res=>{
1912   - if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
1913   - //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
1914   - var url="/api/weshop/couponList/getUseCouponList";
1915   - app.request.time_limit_get(6,url,{
1916   - data:{storeId:oo.stoid,userId:app.globalData.user_id,BuySum:ckeck_quan_price,WareIds:check_quan_ware_list,pageSize:100},
1917   - success:function (res) {
1918   - if (res.data.code == 0) {
1919   - arr[ind].quan_list = res.data.data.pageData;
1920   - arr[ind].quan_list = th.check_is_frozenQuan(arr[ind].quan_list, frozenQuan);
1921   - th.setData({cartlist:arr })
1922   - }
1923   - }
1924   - })
1925   - })
1926   - }
1927   - }
1928   - },
1929 2398 //------ 获取立即购买的购物车的劵 --------
1930 2399 get_buy_now_quan:function () {
1931 2400 var quanlist=null,th=this,frozenQuan = null;
1932   - if(th.data.is_close_quan != 1)
  2401 + var good = this.data.bn_goods;
  2402 + if(good.prom_price){
  2403 + th.data.ckeck_quan_price=good.prom_price;
  2404 + }
  2405 + //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
  2406 + if(th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh!=1)
1933 2407 {
1934 2408 var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
1935 2409 var url="/api/weshop/couponList/getUseCouponList";
... ... @@ -1956,9 +2430,9 @@ Page({
1956 2430 }
1957 2431 })
1958 2432 })
1959   -
1960 2433 }
1961 2434 },
  2435 +
1962 2436 //检查区域是不是包邮
1963 2437 check_area:function(arr){
1964 2438 var user_addr=this.data.user_addr;
... ... @@ -1990,7 +2464,147 @@ Page({
1990 2464 var arr=goods_list.split(",");
1991 2465 var check=this.check_good(arr,goods_id);
1992 2466 return !check;
1993   - }
  2467 + },
  2468 +
  2469 + //立即购买获取优惠活动的内容
  2470 + buy_now_prom_goods:function (prom_id,arr,func) {
  2471 + var price=arr.shop_price*arr.goods_num;
  2472 + getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+prom_id,{}).then(res=>{
  2473 + if(res.data.code==0){
  2474 + var prom=res.data.data;
  2475 + return getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
  2476 + data: {
  2477 + price: price,
  2478 + prom_id: prom_id,
  2479 + goods_num: arr.goods_num,
  2480 + user_id: getApp().globalData.user_id,
  2481 + is_bz: prom.is_bz
  2482 + }
  2483 + })
  2484 + }else {
  2485 + func(arr);
  2486 + }
  2487 + }).then(res=>{
  2488 + if(res.data.code==0){
  2489 + var get_data=res.data.data[0];
  2490 + arr.is_bz=get_data.is_bz; //是不是倍增
  2491 + arr.is_xz_yh=get_data.is_xz_yh; //是不是优惠
  2492 + arr.bs=get_data.bs; //是不是倍数
  2493 + arr.is_past=get_data.is_past; //是不是包邮
  2494 + arr.prom_price=get_data.price;
  2495 + arr.s_intValue=get_data.intValue;
  2496 + arr.s_coupon_id=get_data.coupon_id;
  2497 + arr.s_coupon_num=get_data.coupon_num;
  2498 + arr.gift_id=get_data.gift_id;
  2499 + arr.gift_goods_id=get_data.goods_id;
  2500 + arr.gift_goods_name=get_data.goods_name;
  2501 + arr.gift_goods_color=get_data.goodsinfo.goods_color;
  2502 + arr.gift_goods_spec=get_data.goodsinfo.goods_spec;
  2503 + arr.gift_original_img=get_data.goodsinfo.original_img;
  2504 + arr.gift_weight=get_data.goodsinfo.weight;
  2505 + arr.gift_exp_sum_type=get_data.goodsinfo.exp_sum_type;
  2506 + arr.gift_limit_num=get_data.limit_num;
  2507 + arr.gift_storecount=get_data.gift_storecount;
  2508 + arr.s_libao=get_data.libao;
  2509 + arr.s_lb_num=get_data.lb_num;
  2510 + }
  2511 + func(arr);
  2512 + })
  2513 + },
  2514 + //--检查订单优惠--
  2515 + check_is_order_prom:function (condition,func,pick) {
  2516 + var th=this;
  2517 + if(this.data.is_b_now==1) pick=this.data.bn_pick;
  2518 + //---获取订单优惠---
  2519 + getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion",{
  2520 + data:{store_id:os.stoid,orderAmount:condition}
  2521 + }).then(res=>{
  2522 + if(res.data.code==0) {
  2523 + var data = res.data.data;
  2524 + th.data.order_prom[pick]=data;
  2525 + }
  2526 + func();
  2527 + })
  2528 + },
  2529 +
  2530 + //--- 加入优惠活动的映射中 ---
  2531 + add_prom_goods_map:async function (item) {
  2532 + var th=this;
  2533 + var pickid=item.pick_id;
  2534 + var map=th.data.prom_goods_map;
  2535 + if(map[pickid]){
  2536 + if(map[pickid][item.prom_id]){
  2537 + var ob=map[pickid][item.prom_id];
  2538 + ob.price+=item.goods_price;
  2539 + ob.goods_num+=item.goods_num;
  2540 + }else{
  2541 + var prom=null;
  2542 + await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+item.prom_id,{}).then(res=>{
  2543 + if(res.data.code==0){ prom=res.data.data; }
  2544 + })
  2545 + var ob={};
  2546 + ob.prom_id=item.prom_id;
  2547 + ob.price=item.goods_price;
  2548 + ob.goods_num=item.goods_num;
  2549 + ob.is_bz=prom.is_bz;
  2550 + map[pickid][item.prom_id]=ob;
  2551 + }
  2552 + }else{
  2553 + var ob={};
  2554 + var prom=null;
  2555 + await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+item.prom_id,{}).then(res=>{
  2556 + if(res.data.code==0){ prom=res.data.data; }
  2557 + })
  2558 + ob.prom_id=item.prom_id;
  2559 + ob.price=item.goods_price;
  2560 + ob.goods_num=item.goods_num;
  2561 + ob.is_bz=prom.is_bz;
  2562 + var obj={};
  2563 + obj[item.prom_id]=ob;
  2564 + map[pickid]=obj;
  2565 + }
  2566 + },
  2567 +
  2568 + //计算立即购买赠品的物流费用
  2569 + get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) {
  2570 + var good=this.data.buy_now_gift_goods;
  2571 + var goods_weight=-1, goods_piece=-1;
  2572 + var gift_shipping_price=0;
  2573 + switch (good['exp_sum_type']) {
  2574 + case 1:
  2575 + //统一运费
  2576 + gift_shipping_price += good['uniform_exp_sum']; break;
  2577 + case 2:
  2578 + if (goods_weight < 0) goods_weight = 0;
  2579 + //累积商品重量 每种商品的重量 * 数量
  2580 + goods_weight += good['weight'] * good['buynum'];break;
  2581 + case 3:
  2582 + if (goods_piece < 0) goods_piece = 0;
  2583 + //累积商品数量
  2584 + goods_piece += good['buynum']; break;
  2585 + }
  2586 +
  2587 + //如果有设置不包邮区域的时候
  2588 + if(no_by_data && no_by_data.region_list){
  2589 + if(th.check_by_area(no_by_data.region_list)){
  2590 + gift_freight_free=0;
  2591 + th.data.is_no_by[th.data.bn_pick]=1;
  2592 + }
  2593 + }
  2594 + //如果有设置不包邮商品
  2595 + if(no_by_data && no_by_data.goods_list && freight_free){
  2596 + if(th.check_by_goods(no_by_data.goods_list)){
  2597 + gift_freight_free=0;
  2598 + th.data.is_no_by[th.data.bn_pick]=1;
  2599 + }
  2600 + }
  2601 + var t_shipping_price=
  2602 + this.calculatewuliu(code, gift_shipping_price, goods_weight,
  2603 + goods_piece, user_addr, gift_freight_free, allpice, rs);
  2604 + return t_shipping_price+shipping_price;
  2605 +
  2606 + }
  2607 +
1994 2608  
1995 2609  
1996 2610 });
... ...
pages/cart/cart2/cart2.wxml
... ... @@ -41,7 +41,8 @@
41 41 <image class="dp" src='{{imgUrl}}/miniapp/images/goodscategory/new_store.png'> </image> <view>门店:{{item.pname}}</view></view>
42 42 <view class="order-detail" wx:for="{{item.goods}}" wx:for-index="idx" wx:for-item="items">
43 43 <!----商品图片----->
44   - <view class="goods-img">
  44 + <view class="goods-img" style="position: relative">
  45 + <image wx:if="{{items.is_gift}}" src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
45 46 <image class="wh100" src="{{items.original_img}}" binderror='cart_set_err'
46 47 data-err='cartlist[{{pidx}}].goods[{{idx}}].original_img' ></image>
47 48 </view>
... ... @@ -69,10 +70,10 @@
69 70 </navigator>
70 71  
71 72 </view>
72   -
  73 + <view style="display: none;">!!!!---{{item.quan_list.length}}---!!!</view>
73 74 <!-----使用优惠券------>
74 75 <view class="xc-coupon-frame flex-center" data-bn="0" bindtap="open_coupon_list"
75   - wx:if="{{item.quan_list && item.quan_list.length>0 }}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
  76 + wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
76 77 <view class="work-frame flex-space-between">
77 78 <view class="work">优惠券</view>
78 79 <view class="xc-right-frame">
... ... @@ -190,14 +191,62 @@
190 191 <view class="goods-num">x{{bn_goods.buynum}}</view>
191 192 </view>
192 193 </navigator>
193   -
  194 +
194 195 </view>
195   - <view class="set-mes">
  196 + <!-- 赠品的显示 -->
  197 + <view class="order-detail" wx:if="{{buy_now_gift_goods}}">
  198 + <view class="goods-img" style="position: relative">
  199 + <image src="{{imgUrl}}/miniapp/images/giveaway.png" class="gift_image"></image>
  200 +
  201 + <image class="wh100" src="{{buy_now_gift_goods.original_img}}" binderror='cart_set_err' data-err="buy_now_gift_goods.original_img"></image>
  202 + </view>
  203 + <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{buy_now_gift_goods.goods_id}}">
  204 + <view class="goods-name">{{buy_now_gift_goods.goods_name}}</view>
  205 + <!-- 商品属性 -->
  206 + <view class="flex-vertical fs28 xc-ash color-gray n_guige">
  207 + <view class="goods-color">
  208 + <block><text>{{filters.show_gui_ge(buy_now_gift_goods.goods_spec,buy_now_gift_goods.goods_color)}}</text></block>
  209 + </view>
  210 + </view>
  211 + <!-----商品名称规格------>
  212 + <view class="order-num flex-space-between">
  213 + <view class="co-red">¥<text class="fs36">0</text></view>
  214 + <view class="goods-num">x{{buy_now_gift_goods.buynum}}</view>
  215 + </view>
  216 + </navigator>
  217 + </view>
  218 +
  219 +
  220 + <block wx:if="{{collocation_goods}}">
  221 + <!-- 搭配购买的功能实现 -->
  222 + <view class="order-detail" wx:for="{{collocation_goods}}">
  223 + <view class="goods-img">
  224 + <image class="wh100" src="{{imgUrl+item.original_img}}" binderror='err_img_collocation' data-err="item.original_img"></image>
  225 + </view>
  226 + <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}">
  227 + <view class="goods-name">{{item.goods_name}}</view>
  228 + <!-- 商品属性 -->
  229 + <view class="flex-vertical fs28 xc-ash color-gray n_guige">
  230 + <view class="goods-color">
  231 + <block><text>{{filters.show_gui_ge(item.goods_spec,item.goods_color)}}</text></block>
  232 + </view>
  233 + </view>
  234 + <!-----商品名称规格------>
  235 + <view class="order-num flex-space-between">
  236 + <view class="co-red">¥<text class="fs36">{{item.price}}</text></view>
  237 + <view class="goods-num">x{{item.goods_num}}</view>
  238 + </view>
  239 + </navigator>
  240 + </view>
  241 + </block>
  242 +
  243 +
  244 + <view class="set-mes">
196 245 <view wx:if="{{order.store_prom}}"><icon color="#f23030" size="16" type="info"></icon>{{order.store_prom}}
197 246 </view>
198 247  
199 248 <view class="xc-coupon-frame flex-center" data-bn="1" bindtap="open_coupon_list" data-pickid="{{bn_pick}}"
200   - wx:if="{{selected_quan_list && selected_quan_list.length>0}}">
  249 + wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
201 250 <view class="work-frame flex-space-between">
202 251 <view class="work">
203 252 优惠券
... ... @@ -224,11 +273,10 @@
224 273 <view class="yu_er">物流</view>
225 274 </view>
226 275 </view>
227   - <block wx:if="{{bn_exp_type==0}}">
  276 + <block wx:if="{{bn_exp_type==0}}">
228 277 <view class="flex-vertical" bindtap="show_wu_arr" data-txt='index'><view class="logistics-name">{{wu_arr[index].name}}</view><view class="xc-right"></view></view>
229   - </block>
  278 + </block>
230 279 </view>
231   -
232 280 </view>
233 281  
234 282 <!-----使用余额------>
... ... @@ -256,24 +304,24 @@
256 304 <view>配送费用</view>
257 305 <view class="co-red">¥ {{formData.shipping_price}}元</view>
258 306 </view>
259   -
260 307 <view class="item" wx:if="{{formData.coupon_price>0}}">
261 308 <view>使用优惠券</view>
262 309 <view class="co-red">- ¥ {{formData.coupon_price}}元</view>
263 310 </view>
264   - <!--
265   - <view class="item">
266   - <view>使用积分</view>
267   - <view class="co-red">- ¥ {{orderPrices.integral_money}}元</view>
268   - </view> -->
  311 + <!-- 优惠活动优惠金额 -->
  312 + <view class="item" wx:if="{{formData.cut_price>0}}">
  313 + <view>优惠活动</view>
  314 + <view class="co-red">- ¥ {{formData.cut_price}}元</view>
  315 + </view>
  316 + <!-- 订单优惠优惠金额 -->
  317 + <view class="item" wx:if="{{formData.order_prom_amount>0}}">
  318 + <view>订单优惠</view>
  319 + <view class="co-red">- ¥ {{formData.order_prom_amount}}元</view>
  320 + </view>
269 321 <view class="item">
270 322 <view>使用余额</view>
271 323 <view class="co-red">- ¥ {{formData.user_money}}元</view>
272 324 </view>
273   - <!-- <view class="item">
274   - <view>优惠活动</view>
275   - <view class="co-red">- ¥ {{orderPrices.order_prom_amount}}元</view>
276   - </view> -->
277 325 </view>
278 326 </view>
279 327  
... ... @@ -426,7 +474,6 @@
426 474 <view class="determine-frame"><view class="xc-confirm flex-center" bindtap="confirm_quan"> 确定 </view></view>
427 475 </view>
428 476 </view>
429   -
430 477 <!----弹起选择物流名的列表---->
431 478 <view wx:if='{{open_express==1}}' >
432 479 <view class="cover-layer flex-center " bindtap='close_express'>
... ... @@ -470,6 +517,4 @@
470 517 </view >
471 518 </view>
472 519  
473   -
474   -
475 520 <warn id="warn"></warn>
476 521 \ No newline at end of file
... ...
pages/cart/cart2/cart2.wxss
... ... @@ -512,8 +512,9 @@ border-bottom: 1rpx solid #eee;
512 512 .express_list{
513 513 width: 100%;
514 514 height: 65%;
515   - overflow-y: scroll;
516   - overflow: hidden;
  515 + overflow-y: auto;
  516 + margin-bottom: 10rpx;
  517 +
517 518 }
518 519 .xc-confirms {
519 520 width: 40%;
... ... @@ -821,5 +822,5 @@ margin-left: 20rpx;
821 822 .color-gray{
822 823 color: #808080;
823 824 }
824   -
825   -.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
826 825 \ No newline at end of file
  826 +.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
  827 +.gift_image{ width: 60rpx; height: 60rpx; position: absolute; top: 0; left: 0}
827 828 \ No newline at end of file
... ...
pages/cart/cart_wk/cart_wk.js
... ... @@ -384,14 +384,18 @@ Page({
384 384 getApp().my_warnning("支付失败",0,th);
385 385 })
386 386 }else {
387   - //---用余额支付---
388   - getApp().my_warnning("支付成功",1,th);
389   - setTimeout(function () {
390   - th.setData({ isclose: 0 });
391   - wx.navigateTo({
392   - url: "/pages/user/order_list/order_list"
393   - })
394   - }, 1000)
  387 + if(t.data.code==0){
  388 + //---用余额支付---
  389 + getApp().my_warnning("支付成功",1,th);
  390 + setTimeout(function () {
  391 + th.setData({ isclose: 0 });
  392 + wx.navigateTo({
  393 + url: "/pages/user/order_list/order_list"
  394 + })
  395 + }, 1000)
  396 + }else{
  397 + getApp().my_warnning(t.data.msg,1,th);
  398 + }
395 399 }
396 400 }
397 401 });
... ...
pages/goods/goodsInfo/filter.wxs
... ... @@ -2,7 +2,13 @@ var is_has = function (text,val) {
2 2 if(text.indexOf(","+val+",")==-1) return false;
3 3 return true
4 4 }
5   -
  5 +function format_tt(ts) {
  6 + if(ts==null || ts==undefined || ts=='') return "";
  7 + var d = getDate(ts*1000)
  8 + var fm=(d.getMonth()+1)+"月"+ d.getDate()+"日";
  9 + return fm;
  10 +}
6 11 module.exports = {
7   - is_has: is_has
  12 + is_has: is_has,
  13 + format_tt:format_tt
8 14 }
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -236,6 +236,10 @@ Page({
236 236 sales_rules:1, //默认是线上销售
237 237  
238 238 wait_for_user_store:null,
  239 +
  240 + prom_goods:null, //商品优惠列表
  241 + order_prom:null, //订单优惠
  242 + collocationGoods:null, //搭配购
239 243  
240 244 },
241 245  
... ... @@ -547,11 +551,11 @@ Page({
547 551 mapurl: mapurl,
548 552 });
549 553  
550   -
551 554 },
552 555  
553 556 //---展示---
554 557 onShow: function() {
  558 +
555 559 var goods_list = null,th = this,that=this;
556 560 var ui = setInterval(function () {
557 561 goods_list = th.selectComponent("#goods_list");
... ... @@ -608,6 +612,8 @@ Page({
608 612 }
609 613 }
610 614  
  615 + ee.check_is_youhui(ee.data.gid);
  616 +
611 617 t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
612 618 var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2);
613 619 t.data.data['disc'] = txt;
... ... @@ -631,43 +637,40 @@ Page({
631 637 //获取统一条形码,普通商品和优惠促销的商品
632 638 if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 2 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 4 || ee.data.data.prom_type == 5){
633 639 //默认门店要拿下门店库存
634   - if(that.data.sales_rules==2 && that.data.is_newsales_rules){
635   - //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
636   - getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
637   - if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
638   - var lock=0,plist=null;
639   - //先读取门店的lock,采用链式写法,少用await
640   - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
641   - data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
642   - }).then(res=>{
643   - if(res.data.code==0 && res.data.data.total>0){
644   - for(var i in res.data.data.pageData)
645   - lock+=res.data.data.pageData[i].outQty
646   - }
647   - //---通过接口获取门店的线下库存信息--
648   - return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
649   - data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
650   - })
651   - }).then(res=>{
652   - if(res.data.code==0 && res.data.data.total>0){
653   - plist=res.data.data.pageData[0];
654   - }
655   - if(plist && plist.CanOutQty-lock>0){
656   - that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
657   - }else{
658   - that.data.fir_def_store.CanOutQty=0;
659   - }
660   - //--给门店赋值线下库存--
661   - th.setData({def_pick_store:that.data.fir_def_store});
662   - //获取门店
663   - ee.get_sto();
664   - })
665   - }else{
666   - //--获取门店--
667   - ee.get_sto();
668   - }
669   - })
670   - }else{
  640 + if(that.data.sales_rules==2 && that.data.is_newsales_rules){
  641 + //获取门店
  642 + ee.get_sto();
  643 + //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
  644 + getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
  645 + if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
  646 + var lock=0,plist=null;
  647 + //先读取门店的lock,采用链式写法,少用await
  648 + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
  649 + data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
  650 + }).then(res=>{
  651 + if(res.data.code==0 && res.data.data.total>0){
  652 + for(var i in res.data.data.pageData)
  653 + lock+=res.data.data.pageData[i].outQty
  654 + }
  655 + //---通过接口获取门店的线下库存信息--
  656 + return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
  657 + data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
  658 + })
  659 + }).then(res=>{
  660 + if(res.data.code==0 && res.data.data.total>0){
  661 + plist=res.data.data.pageData[0];
  662 + }
  663 + if(plist && plist.CanOutQty-lock>0){
  664 + that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
  665 + }else{
  666 + that.data.fir_def_store.CanOutQty=0;
  667 + }
  668 + //--给门店赋值线下库存--
  669 + th.setData({def_pick_store:that.data.fir_def_store});
  670 + })
  671 + }
  672 + })
  673 + }else{
671 674 //获取门店
672 675 ee.get_sto();
673 676 }
... ... @@ -938,9 +941,11 @@ Page({
938 941  
939 942 th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
940 943  
941   - } else if ( th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
  944 + }
  945 + else if ( th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
942 946 newd.prom_type = 0;
943 947 newd.prom_id = 0;
  948 +
944 949 //---如果是线下门店销售的时候---
945 950 if(th.data.sales_rules==2){
946 951 var pick=th.get_pick_from_list(th.data.sto_sele_id)
... ... @@ -992,7 +997,7 @@ Page({
992 997  
993 998 //---加入购物车的最后一步---
994 999 add_cart_next(e,t,a,o,newd,CanOutQty){
995   - var th=this;
  1000 + var th=this,i=getApp().request;
996 1001 //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
997 1002 if(o.prom_type!=1 && o.prom_type!=6){
998 1003 var conf=th.data.bconfig;
... ... @@ -1010,13 +1015,22 @@ Page({
1010 1015 if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
1011 1016 && getApp().globalData.userInfo['card_field']!="" && card_price>0){
1012 1017 newd.goods_price=card_price;
  1018 + newd.member_goods_price=card_price;
1013 1019 }
1014 1020 }
1015 1021 }
1016 1022 }
1017   -
  1023 +
  1024 +
  1025 +
1018 1026 //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d);
1019 1027 if ("add" == t.currentTarget.dataset.action) {
  1028 +
  1029 + if(th.data.prom_goods){
  1030 + newd.prom_type = 3;
  1031 + newd.prom_id = th.data.prom_goods[0].prom_id;
  1032 + }
  1033 +
1020 1034 //----先看会员在购物车中是否加入了该商品-----
1021 1035 i.get("/api/weshop/cart/page", {
1022 1036 data: {
... ... @@ -1043,12 +1057,12 @@ Page({
1043 1057 }
1044 1058 }
1045 1059  
1046   -
1047   -
  1060 +
1048 1061 var updata = {
1049 1062 id: item.id,
1050 1063 goods_num: e.data.goodsInputNum + item.goods_num,
1051 1064 goods_price: newd.goods_price,
  1065 + member_goods_price:newd.goods_price,
1052 1066 store_id: th.data.stoid,
1053 1067 };
1054 1068  
... ... @@ -1081,6 +1095,30 @@ Page({
1081 1095 }
1082 1096 //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);
1083 1097 else {
  1098 +
  1099 + if(th.data.prom_goods){
  1100 + var prom_d=th.data.prom_goods;
  1101 + for(var i in prom_d){
  1102 + //判断活动有俩种条件,0元 1件
  1103 + var condition_t=prom_d[i].prom_type;
  1104 + switch(condition_t) {
  1105 + case 0: //按钱
  1106 + if(newd.goods_price>=condition_t){
  1107 + newd.prom_type = 3;
  1108 + newd.prom_id = prom_d[i].prom_id;
  1109 + }
  1110 + break
  1111 + case 1://按购买数量
  1112 + if(newd.goods_num>=condition_t){
  1113 + newd.prom_type = 3;
  1114 + newd.prom_id = prom_d[i].prom_id;
  1115 + }
  1116 + break;
  1117 + }
  1118 + }
  1119 +
  1120 + }
  1121 +
1084 1122 newd['pick_name'] = th.data.sto_sele_name;
1085 1123 newd['pick_dis'] = th.data.sto_sele_distr;
1086 1124 th.buyNow(newd);
... ... @@ -1317,6 +1355,8 @@ Page({
1317 1355 data: {
1318 1356 store_id: o.stoid,
1319 1357 user_id: s.globalData.user_id,
  1358 + state:0,
  1359 + is_gift:0
1320 1360 },
1321 1361 success: function(e) {
1322 1362 var num = 0;
... ... @@ -1515,8 +1555,11 @@ Page({
1515 1555 if (item) this.setData({
1516 1556 sele_g: item,
1517 1557 gid: gid
1518   - });
1519   -
  1558 + });
  1559 +
  1560 + that.check_is_youhui(gid)
  1561 +
  1562 +
1520 1563 this.get_sto();
1521 1564 //默认门店要拿下门店库存
1522 1565 if(that.data.sales_rules==2 && that.data.def_pick_store){
... ... @@ -3921,12 +3964,14 @@ Page({
3921 3964 getPlusCardType: function (func) {
3922 3965 var storid = os.stoid;
3923 3966 var th = this;
  3967 + var user=getApp().globalData.userInfo;
3924 3968 getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
3925 3969 var plusCard = res.data.data;
3926 3970 var arr = [1219, 2089, 3031];
3927 3971 var new_arr = new Array();
3928 3972 var card_name_map=new Map();
3929 3973 for (var i = 0; i < plusCard.length; i++) {
  3974 + if((user.card_field==null || user.card_field=="") && plusCard[i].IsStopBuy==true) continue;
3930 3975 var name="card"+plusCard[i].CorrPrice.toLowerCase();
3931 3976 card_name_map.set(name,plusCard[i].CardName);
3932 3977 }
... ... @@ -3951,9 +3996,51 @@ Page({
3951 3996 return item;
3952 3997 }
3953 3998 }
3954   - }
3955   -
  3999 + },
  4000 + //-----显示优惠券的时候情况-----
  4001 + show_more_cx:function () {
  4002 + if(this.data.is_more_cx){
  4003 + this.setData({is_more_cx:0});
  4004 + }else{
  4005 + this.setData({is_more_cx:1});
  4006 + }
  4007 + },
  4008 +
  4009 + //----跳转到搭配购买----
  4010 + go_prom_list:function () {
  4011 + wx.navigateTo({ url: "../../../packageA/pages/prom_list/prom_list?goods_id="+this.data.gid, })
  4012 + },
  4013 +
  4014 + //---检查有没有优惠活动---
  4015 + check_is_youhui:function(gid){
  4016 + var th=this;
  4017 + //调用接口判断订单优惠,
  4018 + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+gid+"/0", {}).then(res => {
  4019 + if(res.data.code==0){
  4020 + var r_data=res.data.data;
  4021 + var max=0,min=0;
  4022 + if(r_data.collocationList){
  4023 + for(var i in r_data.collocationList){
  4024 + if(max==0) max=r_data.collocationList[i].price;
  4025 + if(min==0) min=r_data.collocationList[i].price;
  4026 +
  4027 + if(max<parseFloat(r_data.collocationList[i].price)) max=r_data.collocationList[i].price;
  4028 + if(min>parseFloat(r_data.collocationList[i].price)) min=r_data.collocationList[i].price;
  4029 + }
  4030 + r_data.collocationPromList.max=(max+th.data.data.shop_price).toFixed(2);
  4031 + r_data.collocationPromList.min=(min+th.data.data.shop_price).toFixed(2);
  4032 + }
  4033 + th.setData({
  4034 + order_prom:r_data.promOrder,
  4035 + collocationGoods:r_data.collocationPromList,
  4036 + prom_goods:r_data.promGoodsLists,
  4037 + })
  4038 + }
  4039 + })
  4040 + }
3956 4041  
  4042 +
  4043 +
3957 4044  
3958 4045  
3959 4046 });
... ...
pages/goods/goodsInfo/goodsInfo.wxml
1 1 <import src="../../../utils/wxParse/wxParse.wxml"></import>
2 2 <wxs module="filters" src="../../../utils/filter.wxs"></wxs>
3 3 <wxs module="g_filters" src="g_filter.wxs"></wxs>
4   -<wxs module="" src="filter.wxs"></wxs>
  4 +<wxs module="tool" src="filter.wxs"></wxs>
  5 +
5 6 <!-- 商品内容区域,普通商品,秒杀,拼团 -->
6 7 <block wx:if="{{isshow}}">
7 8 <view class="container">
... ... @@ -434,11 +435,77 @@
434 435 </view>
435 436 </view>
436 437 </view>
  438 +
  439 + <!-- 要判断是不是有促销活动 -->
  440 + <block wx:if="{{prom_goods}}">
  441 + <view class="cx-frame flex" style="position: relative; height: auto" >
  442 + <view class="cx-sizs wsize">促销</view>
  443 + <!-- 中间显示层 -->
  444 + <view style="margin-top: 36rpx">
  445 + <view class="cx_show_view flex fs28" wx:for="{{prom_goods}}">
  446 + <view class="prom_condition">消费满{{item.condition}}件</view>
  447 + <view class="word {{is_more_cx?'':'ellipsis-1'}}">
  448 + <text wx:if="{{item.money>0}}">减价{{item.money}}元;</text>
  449 + <text wx:if="{{item.sale>0}}">打{{item.sale}}折;</text>
  450 + <text wx:if="{{item.past==1}}">包邮;</text>
  451 + <text wx:if="{{item.int>0}}">送{{tem.int}}积分;</text>
  452 + <text wx:if="{{item.coupon_id>0}}">送{{item.coupon}}元优惠券;</text>
  453 + <text wx:if="{{item.gift_id>0}}">送商品{{item.goods_name}};</text>
  454 + <text wx:if="{{item.lb_id>0}}">送{{item.lbtitle}};</text>
  455 + </view>
  456 + </view>
  457 +
  458 + </view>
  459 + <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize">
  460 + <text class="bg_jj {{is_more_cx?'down1':''}}"></text>
  461 + </view>
  462 + </view>
  463 + </block>
  464 +
  465 + <!-- 要判断是不是有订单优惠 -->
  466 + <block wx:if="{{order_prom}}">
  467 + <view class="cx-frame flex" style="position: relative; height: auto" >
  468 + <view class="cx-sizs wsize" style="width: 144rpx">订单优惠</view>
  469 + <!-- 中间显示层 -->
  470 + <view class="flex ai-center">
  471 + <image class="hui_img" src="{{iurl}}/miniapp//images/hui.png"></image>
  472 + <view class="order_hui">
  473 + <view class="fs28 ellipsis-1">{{order_prom.name}}</view>
  474 + <view class="fs26" >(活动时间:{{tool.format_tt(order_prom.start_time)}} - {{tool.format_tt(order_prom.end_time)}})</view>
  475 + </view>
  476 + </view>
  477 + </view>
  478 + </block>
  479 +
  480 +
437 481 <view class="bz_view one_elli" wx:if="{{bconfig}}">
438 482 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image>
439 483 <text>{{bconfig.service_bz}}</text>
440 484 </view>
441 485  
  486 +
  487 + <!--- 搭配促销 ---->
  488 + <view class="dp_cx_view" wx:if="{{collocationGoods}}">
  489 + <view class="bb_view">
  490 + <view>优惠热配</view>
  491 + <view class="red_bb" bindtap="go_prom_list">查看全部
  492 + <text class="bg_jj"></text>
  493 + </view>
  494 + </view>
  495 +
  496 + <!-- 搭配的显示 -->
  497 + <view class="flex" bindtap="go_prom_list">
  498 + <image class="dp_img" src="{{iurl+collocationGoods.img_url}}"></image>
  499 + <view class="act_content">
  500 + <view class="fs32">{{collocationGoods.title}}</view>
  501 + <view class="fs30 color_b" wx:if="{{collocationGoods.max!=collocationGoods.min}}">搭配价¥{{collocationGoods.min}}-{{collocationGoods.max}}</view>
  502 + <view class="fs30 color_b" wx:else>搭配价¥{{collocationGoods.min}}</view>
  503 + <view class="fs30 color-gray">活动至{{filters.format_time(collocationGoods.end_time,1)}}</view>
  504 + </view>
  505 + </view>
  506 + </view>
  507 +
  508 +
442 509 <!--- 宝贝评价 ---->
443 510 <view style="overflow: hidden">
444 511 <view class="bb_view">
... ... @@ -1029,6 +1096,8 @@
1029 1096 </view>
1030 1097  
1031 1098 </view>
  1099 +
  1100 +
1032 1101 <!----弹起来,选择规格数量,拼单商品购买------>
1033 1102 <view hidden="{{!openSpecModal_pt}}">
1034 1103 <view bindtap="closeSpecModal" class="cover-layer"></view>
... ...
pages/goods/goodsInfo/goodsInfo.wxss
... ... @@ -957,6 +957,8 @@ left:31rpx;}
957 957 transform: rotate(45deg);display:inline-block;
958 958 margin-bottom:3rpx;
959 959 }
  960 +.bg_jj.down1{transform: rotate(135deg);}
  961 +
960 962 /* 顶部边框 */
961 963 .topframe{
962 964 width: 100%;
... ... @@ -2302,6 +2304,7 @@ width: 100%;
2302 2304 height: 91.9%;
2303 2305  
2304 2306 }
  2307 +
2305 2308 .popup-frame{
2306 2309 position: fixed;
2307 2310 bottom:99rpx;
... ... @@ -2567,4 +2570,29 @@ button.custom-service { line-height: normal; border: 0;}
2567 2570 button.custom-service::after{
2568 2571 border: 0;
2569 2572 }
2570   -.no_store{color:#d60021; font-size: 26rpx;}
2571 2573 \ No newline at end of file
  2574 +.no_store{color:#d60021; font-size: 26rpx;}
  2575 +.cx_show_view{ width: 580rpx; line-height: 30rpx; margin-bottom: 20rpx; }
  2576 +.cx_show_view .word{ width: 400rpx}
  2577 +.prom_condition {
  2578 + color: #d60021;
  2579 + width: 180rpx;
  2580 + height: 30rpx;
  2581 + font-size: 20rpx;
  2582 + padding-top: 0.01rpx;
  2583 + display: flex;
  2584 + justify-content: center;
  2585 + align-items: center;
  2586 + border: #d60021 solid 1rpx;
  2587 + border-radius: 10rpx;
  2588 + margin-right:10rpx ;
  2589 + margin-left: 10rpx;
  2590 +
  2591 +}
  2592 +.hui_img{ width: 44rpx; height: 44rpx; margin-right: 8rpx}
  2593 +.order_hui{color: #444; width: 420rpx}
  2594 +.order_hui view{ height: 34rpx; line-height: 34rpx;}
  2595 +.dp_img{width: 240rpx; height: 240rpx; margin: 0 40rpx}
  2596 +.dp_cx_view{border-bottom: 0.02rpx solid #eee; padding-bottom: 40rpx}
  2597 +.act_content{ margin-top: 40rpx}
  2598 +.act_content view{ margin-bottom: 12rpx}
  2599 +.color_b{color: #ff9c00}
2572 2600 \ No newline at end of file
... ...