diff --git a/app.wxss b/app.wxss index 4071e99..486c77d 100644 --- a/app.wxss +++ b/app.wxss @@ -63,6 +63,9 @@ button { .t-c { text-align: center; } +.ai_and{ + align-items: flex-end; +} .cover-layer { position: fixed; left: 0; @@ -206,7 +209,12 @@ position:fixed; .ai-bas{ align-items: baseline; } - +.ai-center{ +align-items: center; +} +.jc-center{ + justify-content: center; +} /* 垂直居中 中间等距两边贴边 7.13*/ .flex-vertical-between{ diff --git a/components/goods_list/g_filter.wxs b/components/goods_list/g_filter.wxs new file mode 100644 index 0000000..297810c --- /dev/null +++ b/components/goods_list/g_filter.wxs @@ -0,0 +1,57 @@ +var g_filters = { + //-- 判断是不是有等级价 -- + is_has_rank:function(rank_switch,item){ + if(!rank_switch) return false; + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} + return false; + }, + + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- + get_card_price:function(goods,all_card,type){ + var price1=parseInt(goods['cardprice1']); + var price2=parseInt(goods['cardprice2']); + var price3=parseInt(goods['cardprice3']); + if(!all_card){ + if(type==0) return 0; + return ""; + } + + var arr=[]; + var min_price= 0; + var min_name=""; + //---设置对应的价格名字---- + for(var i=0;i<3;i++) { + var vl=all_card[i]; + if(vl['CorrPrice']=="Price1" && price1>0) + arr.push({'price':price1, 'name':vl['CardName']}); + if(vl['CorrPrice']=="Price2" && price2>0) + arr.push({'price':price2, 'name':vl['CardName']}); + if(vl['CorrPrice']=="Price3" && price3>0) + arr.push({'price':price3, 'name':vl['CardName']}); + } + if(arr.length==0){ + if(type==0) return 0; + return ""; + } + //--进行排序,升序--- + arr.sort(function(a,b){ + if (a.price < b.price) { + return -1; + } else if (a.fee == b.fee) { + return 0; + } else { + return 1; + } + }) + //-- 获取最下价钱,和相应的卡的名称 -- + min_price=arr[0].price; + min_name=arr[0].name; + if(type==0) return min_price; + if(min_name.length>4 ) min_name=min_name.substring(0, 4); + return min_name; + }, +} +module.exports = { + is_has_rank:g_filters.is_has_rank, + get_card_price:g_filters.get_card_price, +} \ No newline at end of file diff --git a/components/goods_list/goods_list.js b/components/goods_list/goods_list.js index 810ad76..04e4275 100644 --- a/components/goods_list/goods_list.js +++ b/components/goods_list/goods_list.js @@ -1,34 +1,63 @@ -// pages/user/yhq/qr_code/qr_code.js - - -var - t = getApp(), a = t.request, o = t.globalData.setting, os = o, +var t = getApp(), a = t.request, o = t.globalData.setting, os = o, i = require("../../utils/util.js"), ut = i, s = require("../../utils/common.js"); - Component({ data: { url: o.imghost, object: null, curPage:1, is_no_more:1,//加载完所有数据的控制器 - load_complete:0//加载完成 + load_complete:0,//加载完成, + rank_switch:false, + card_field:"", + card_name:"", + max_card_field:"", + card_list:null }, properties: { // 这里定义了innerText属性,属性值可以在组件使用时指定 }, ready: function () { + var th=this; + getApp().getConfig2(function(e){ + var swithc_list=e.switch_list; + var sw_arr=JSON.parse(swithc_list); + //---如果后台又开等级卡的开关--- + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ + th.setData({rank_switch:true}); + var user=getApp().globalData.userInfo; + var ti=setInterval(function(){ + if(!user) return false; + clearInterval(ti); + //---回调卡的列表--- + th.getPlusCardType(function(ob){ + th.setData({card_list:ob.card_list}); + if(user.card_field ){ + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + + //--- 判断是等级会员,且在有效期范围内 --- + if(user.card_field && now4) card_name=card_name.substring(0,4); + th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list}); + } + } + }) + },500) + } + }) + }, methods: { - get_list:function(){ - + get_list:function(){ var that = this; if(that.data.is_no_more==0) return false; - - var curPage = that.data.curPage; getApp().request.get('/api/weshop/goods/page?page',{ data: { is_mainshow: 1, isonsale: 1, @@ -45,8 +74,7 @@ Component({ }else{ that.data.curPage++; } - - + //加载完成 if (data.data.pageData) { that.setData({load_complete:1}); @@ -60,26 +88,40 @@ Component({ } }) }, + bind_bnerr_xc: function (e) { - var _errImg = e.target.dataset.errorimg; - var _errurl = e.target.dataset.url; - + var _errImg = e.target.dataset.errorimg; + var _errurl = e.target.dataset.url; var _errObj = {}; _errObj[_errImg] = "/miniapp/images/default_g_img.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; }, reset:function(){ curPage=1; }, - - - + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = o.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map=new Map(); + for (var i = 0; i < plusCard.length; i++) { + var name="card"+plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name,plusCard[i].CardName); + } + + var ob={"card_list":plusCard,"name_map":card_name_map}; + func(ob); + }) + }, + }, - - - - - + + + }) \ No newline at end of file diff --git a/components/goods_list/goods_list.wxml b/components/goods_list/goods_list.wxml index 1f8dfd5..bfbb243 100644 --- a/components/goods_list/goods_list.wxml +++ b/components/goods_list/goods_list.wxml @@ -1,5 +1,6 @@ + @@ -10,19 +11,108 @@ {{item.goods_name}} - - - - - - {{filter.toFix(item.shop_price,2)}} - - - - - {{item.market_price}} - - + + + + + + + + + + + + {{filter.toFix(item[card_field],2)}} + {{card_name}} + + + + + + + {{item.market_price}} + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + {{item.market_price}} + + + + + + + + {{filter.toFix(g_filter.get_card_price(item,card_list,0),2)}} + {{g_filter.get_card_price(item,card_list,1)}} + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + + + + + + + + + + {{filter.toFix(item.shop_price,2)}} + + + + + + + {{item.market_price}} + + + + diff --git a/components/goods_list/goods_list.wxss b/components/goods_list/goods_list.wxss index 28e2283..9adcbbe 100644 --- a/components/goods_list/goods_list.wxss +++ b/components/goods_list/goods_list.wxss @@ -4,9 +4,27 @@ .ib{ display: inline-block; } +.fs20{ + font-size: 20rpx; +} +.fs22{ + font-size: 22rpx; +} .fs24{ font-size: 24rpx; } +.fs26{ + font-size: 26rpx; +} +.fs28{ + font-size: 28rpx; +} +.fs35{ + font-size:35rpx; +} + + + .flex-center{ display:flex; justify-content:center; @@ -16,18 +34,16 @@ align-items:center; color: #d60021; } -.fs22{ - font-size: 22rpx; -} + + + .xc-ash{ color: #b9b9b9; } .choice_box .choice_list .choice_footer .price { color: #f23030; height: 10px } -.fs35{ - font-size:35rpx; -} + .flex{display: flex} .ellipsis-2 { overflow: hidden; @@ -48,13 +64,11 @@ color: #b9b9b9; margin: auto; padding-left: 21rpx; } -.fs28{ - font-size: 28rpx; -} + .hang .collect { width: 347rpx; - height: 495rpx; + height: 520rpx; border-radius: 25rpx; border: 1rpx solid rgb(214, 214, 214); overflow: hidden; @@ -72,8 +86,8 @@ color: #b9b9b9; } .collect .money { - margin-top: 30rpx; - margin-bottom: 18rpx; + margin-top: 28rpx; + margin-bottom: 8rpx; line-height: 28rpx; align-items: baseline; } @@ -134,4 +148,9 @@ color: #b9b9b9; width: 80rpx; height: 2rpx; background-color: rgb(138, 138, 138); -} \ No newline at end of file +} + +.line_th{ text-decoration: line-through} +.card_bg {display: flex; width: 106rpx;height: 28rpx; align-items: center; border-radius: 26rpx; font-size: 19rpx; +background: #333; color: #fff; justify-content: center; margin-left: 2rpx;} +.card_bg image{ width: 19rpx; height: 19rpx; margin-right: 1rpx;} \ No newline at end of file diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index db77217..2377685 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -2,7 +2,8 @@ var t = getApp(), a = t.request, oo = t.globalData.setting, app = getApp(), - rq = t.request; + rq = t.request, + ut = require("../../../utils/util.js"); var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ @@ -23,6 +24,8 @@ Page({ up_dating: 0, //更新中 isreduce: 0, //商品数量是否可减 isadd: 0, //是否可以加商品数量 + + card_field:"", }, onLoad: function() { @@ -73,6 +76,28 @@ Page({ } else { th.get_cart(); } + + //要获取会员是不是等级会员 + getApp().getConfig2(function(conf){ + //--- 看后台是不是有开通等级卡 --- + if(conf.switch_list){ + var s_list=JSON.parse(conf.switch_list); + //如果后台有开启等级价的功能 + if(parseInt(s_list.rank_switch)==2){ + var user=getApp().globalData.userInfo; + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + //--- 判断是等级会员,且在有效期范围内 --- + if(user.card_field && now0 && val.prom_type==0 ){ + + }else{ + if (g_arr[i].goods_price != val.shop_price && g_arr[i].goods_price != val.prom_price) { + isok = 0; + gname = val.goods_name; + throw "商品价格已经变化"; + } + } + + rq.put("/api/weshop/cart/update", { data: { id: g_arr[i].id, diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index af75385..55ba3ec 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -415,9 +415,10 @@ Page({ case 3: case 4: case 6: - //--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的, - // 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券-- - + //--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的, + // 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券-- + t.data.data.shop_price=gg.goods_price; + th.data.ckeck_quan_price=t.data.data.shop_price*gg.goods_num; th.data.check_quan_price_list=t.data.data.shop_price*gg.goods_num+""; th.data.check_quan_ware_list=t.data.data.erpwareid+""; diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index cde3db4..c3ce082 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -158,7 +158,8 @@ Page({ et = 0; break; } - + + t.data.data.shop_price=gg.goods_price; //--如果是普通购买的时候-- if(gg.is_normal==1){ t.data.data.prom_id = 0; diff --git a/pages/getphone/getphone.js b/pages/getphone/getphone.js index 6896cac..0cebb37 100644 --- a/pages/getphone/getphone.js +++ b/pages/getphone/getphone.js @@ -63,7 +63,7 @@ Page({ }, save_the_data:function (r,e,sessionKey,openid) { - var app=getApp(),a=app; + var app=getApp(),a=app,th=this; var dd = { oauth: "miniapp", nickname: r.nickName, diff --git a/pages/goods/categoryList/categoryList.wxml b/pages/goods/categoryList/categoryList.wxml index 867df8c..5d394f9 100644 --- a/pages/goods/categoryList/categoryList.wxml +++ b/pages/goods/categoryList/categoryList.wxml @@ -229,10 +229,11 @@ + {{goods.items.name}} 更多 - + diff --git a/pages/goods/goodsInfo/g_filter.wxs b/pages/goods/goodsInfo/g_filter.wxs new file mode 100644 index 0000000..2b77cdb --- /dev/null +++ b/pages/goods/goodsInfo/g_filter.wxs @@ -0,0 +1,57 @@ +var g_filters = { + //-- 判断是不是有等级价 -- + is_has_rank:function(rank_switch,item){ + if(!rank_switch) return false; + if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true} + return false; + }, + + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- + get_card_price:function(goods,all_card,type){ + var price1=parseInt(goods['cardprice1']); + var price2=parseInt(goods['cardprice2']); + var price3=parseInt(goods['cardprice3']); + if(!all_card){ + if(type==0) return 0; + return ""; + } + + var arr=[]; + var min_price= 0; + var min_name=""; + //---设置对应的价格名字---- + for(var i=0;i<3;i++) { + var vl=all_card[i]; + if(vl['CorrPrice']=="Price1" && price1>0) + arr.push({'price':price1, 'name':vl['CardName']}); + if(vl['CorrPrice']=="Price2" && price2>0) + arr.push({'price':price2, 'name':vl['CardName']}); + if(vl['CorrPrice']=="Price3" && price3>0) + arr.push({'price':price3, 'name':vl['CardName']}); + } + if(arr.length==0){ + if(type==0) return 0; + return ""; + } + //--进行排序,升序--- + arr.sort(function(a,b){ + if (a.price < b.price) { + return -1; + } else if (a.fee == b.fee) { + return 0; + } else { + return 1; + } + }) + //-- 获取最下价钱,和相应的卡的名称 -- + min_price=arr[0].price; + min_name=arr[0].name; + if(type==0) return min_price; + if(min_name.length>5 ) min_name=min_name.substring(0, 5); + return min_name; + }, +} +module.exports = { + is_has_rank:g_filters.is_has_rank, + get_card_price:g_filters.get_card_price, +} \ No newline at end of file diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 102ece0..4e4a732 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -287,6 +287,40 @@ Page({ th.requestCardNum(), wx.pageScrollTo && th.setData({ supportPageScroll: !0 }); + + //计算等级价相关 + var swithc_list=e.switch_list; + var sw_arr=JSON.parse(swithc_list); + //---如果后台又开等级卡的开关--- + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ + th.setData({rank_switch:true}); + var user=getApp().globalData.userInfo; + var ti=setInterval(function(){ + if(!user) return false; + clearInterval(ti); + //---回调卡的列表--- + th.getPlusCardType(function(ob){ + th.setData({card_list:ob.card_list}); + if(user.card_field ){ + var str = user['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + var now = ut.gettimestamp(); + //--- 判断是等级会员,且在有效期范围内 --- + if(user.card_field && now5) card_name=card_name.substring(0,5); + + var is_near_date=0; + if(end-now<60*60*30*24) is_near_date=1; //如果小于30天 + th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list,is_near_date:is_near_date}); + } + } + }) + },500) + } + + }); @@ -802,6 +836,24 @@ Page({ newd.prom_type = 0; newd.prom_id = 0; } + + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ + if(o.prom_type!=1 && o.prom_type!=6){ + var conf=th.data.bconfig; + if(conf.switch_list){ + var s_list=JSON.parse(conf.switch_list); + //如果后台有开启等级价的功能 + if(parseInt(s_list.rank_switch)==2){ + var card_price=o[getApp().globalData.userInfo['card_field']]; + //如果会员有等级价 + if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null + && getApp().globalData.userInfo['card_field']!="" && card_price>0){ + newd.goods_price=card_price; + } + } + } + } + //if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d); if ("add" == t.currentTarget.dataset.action) { @@ -2113,20 +2165,23 @@ Page({ } var redis_num = 0 - //-------判断活动是否抢光--------- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { - 1: 1 - }).then(res => { - redis_num = res.data.data; - }) - - if (th.data.goodsInputNum > redis_num) { - wx.showModal({ - title: '提示', - content: '超出商品活动库存' - }); - return false; - } + //不是普通购买的时候 + if(th.data.is_normal!=1){ + //-------判断活动是否抢光--------- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { + 1: 1 + }).then(res => { + redis_num = res.data.data; + }) + + if (th.data.goodsInputNum > redis_num) { + wx.showModal({ + title: '提示', + content: '超出商品活动库存' + }); + return false; + } + } if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); if (th.data.goodsInputNum > o.store_count) return s.my_warnning("超出商品库存", 0, th); @@ -2147,9 +2202,28 @@ Page({ goods_sn: o.goods_sn, sku: o.sku, }; - - //-----如果是秒杀,团购,积分购,拼团----- - if (th.data.prom_type == 6) { + + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ + + if(th.data.is_normal == 1){ + var conf=th.data.bconfig; + if(conf.switch_list){ + var s_list=JSON.parse(conf.switch_list); + //如果后台有开启等级价的功能 + if(parseInt(s_list.rank_switch)==2){ + var card_price=o[getApp().globalData.userInfo['card_field']]; + //如果会员有等级价 + if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null + && getApp().globalData.userInfo['card_field']!="" && card_price>0){ + newd.goods_price=card_price; + } + } + } + } + + + //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- + if (th.data.prom_type == 6 && th.data.is_normal!= 1) { newd.goods_price = th.data.prom_price; newd.prom_type = th.data.prom_type; newd.prom_id = th.data.prom_id; @@ -2159,7 +2233,7 @@ Page({ if (newd.kt_type > 1) { newd.is_pt_tz = 1; //开团类型 } - if (newd.kt_type == 3 && th.data.is_normal != 1) { + if (newd.kt_type == 3) { th.data.sto_sele_distr = 1; } @@ -3265,6 +3339,32 @@ Page({ comments: that.data.comments }) }, + + //--- 获取卡类列表 --- + getPlusCardType: function (func) { + var storid = os.stoid; + var th = this; + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + var plusCard = res.data.data; + var arr = [1219, 2089, 3031]; + var new_arr = new Array(); + var card_name_map=new Map(); + for (var i = 0; i < plusCard.length; i++) { + var name="card"+plusCard[i].CorrPrice.toLowerCase(); + card_name_map.set(name,plusCard[i].CardName); + } + + var ob={"card_list":plusCard,"name_map":card_name_map}; + func(ob); + }) + }, + + go_plus:function(){ + getApp().goto("/pages/user/plus/plus"); + }, + go_card_info:function(){ + getApp().goto("/pages/user/cardinfo/cardinfo"); + } }); \ No newline at end of file diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index f0f0176..a4bff08 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -1,21 +1,21 @@ + - - + {{item.name}} - + - - @@ -80,7 +78,6 @@ - @@ -228,15 +225,21 @@ - - {{ filters.toFix(data.shop_price,2)}} - - 原价:¥{{data.market_price}} - + + + + {{card_name}} + + {{filters.toFix(data[card_field],2)}} + + + {{ filters.toFix(data.shop_price,2)}} + 原价:¥{{data.market_price}} + @@ -245,8 +248,70 @@ - - + + + + + + {{g_filters.get_card_price(data,card_list,1)}} + + {{g_filters.get_card_price(data,card_list,0)}} + + + + + + + + + + + 成为黄钻卡会员立省{{data.market_price-g_filters.get_card_price(data,card_list,0)}} + 开通会员 尽享更多优惠 + + + + 立即开卡 + + + + + + + + + + + + 成为{{card_name}}立省{{data.market_price-data[card_field]}} + 开通会员 尽享更多优惠 + + + + 立即续费 + + + + + + + + + + + + + + + + + {{data.goods_name}} @@ -254,7 +319,7 @@ - 销量:{{data.sales_sum}}件 + 销量:{{data.sales_sum}}件 折扣:{{data.disc}}折 {{categories3[0].num}}人评价 @@ -273,7 +338,7 @@ - + {{data.goods_name}} @@ -300,37 +365,6 @@ - - - - - - - - 选择门店 - - - 更多门店 - - - - - - - - {{def_pick_store.pickup_name}} - - - 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}} - - - - 地址:{{def_pick_store.fulladdress}} - - - - - @@ -372,16 +406,16 @@ - + - {{item.is_anonymous!=1?item.username:'匿名'}} + {{item.username}} - - {{item.content?item.content:''}} + + {{item.content?item.content:''}} {{item.add_time}} @@ -389,8 +423,7 @@ - - + @@ -464,7 +497,7 @@ 规格 - {{filters.show_gui_ge(data.goods_spec,data.goods_color)}} + {{data.goods_spec==""?"规格1":data.goods_spec}} @@ -513,7 +546,7 @@ - +