diff --git a/app.js b/app.js index 8df8c61..459ae59 100644 --- a/app.js +++ b/app.js @@ -9,8 +9,8 @@ App({ setting: t, wechatUser: null, userInfo: null, - config: null, - config2: null, + config: null, //门店参数 + config2: null, //门店配置 code: null, heigth:0, user_id: null,// 4379287,// null,// 5682068, @@ -19,13 +19,14 @@ App({ wuliuprice: null, //物流价格表 wuliu: null, //物流公司 baddr:null, - mobile: null, //记录手机 - getu:null, //记录会员信息 + mobile: null, //记录手机 + getu:null, //记录会员信息 sessionKey: null,//记录会员信息 openid: null, //记录会员信息 - to_group:null, //参团传递的数据 - wxapp_buy_obj:null,//微信小程序购买的Object + to_group:null, //参团传递的数据 + wxapp_buy_obj:null, //微信小程序购买的Object + pk_store:null, //选择的门店 }, auth: o, @@ -47,7 +48,6 @@ App({ app.globalData.user_id= app.globalData.userInfo.user_id; } } - }, //---初始化第三方---- @@ -58,6 +58,8 @@ App({ var t = wx.getExtConfigSync(), o = this.globalData.setting; console.log(t); t.appName ? (o.appName = t.appName, o.stoid = t.stoid) : tt=1; + + }, //首页的第一次登录 @@ -109,7 +111,7 @@ App({ success: function (o) { console.log('getConfig2'); if (o.data.code == 0) { - e.globalData.config = o.data.data, "function" == typeof t && t(e.globalData.config); + e.globalData.config2 = o.data.data, "function" == typeof t && t(e.globalData.config2); } } }); @@ -287,10 +289,64 @@ App({ }, //显示提示,word提示内容,type 0失败,提示 1成功 - my_warnning(word,type,that){ + my_warnning(word,type,that,width){ var warn = that.selectComponent("#warn"); //组件的id - warn.open(word,type); + warn.open(word,type,width); return 1; - } + }, + + //获取会员门店 + get_user_store:function (func) + { + var th=this; + //---空会员的情况--- + if(!th.globalData.userInfo){ + return func(null); + } + if(!this.globalData.pk_store){ + var pick_id=0; + //先找一个会员是否有设置默认的地址 + if(th.globalData.userInfo.def_pickup_id){ + pick_id= th.globalData.userInfo.def_pickup_id + } + //查找会员的注册的地址 + else if(th.globalData.userInfo.pickup_id){ + pick_id= th.globalData.userInfo.pickup_id + } + //---如果会员没有设置默认门店,同时也没有再注册的时候选择门店-- + if(pick_id==0) return func(null); + //获取用户注册时候的门店 + th.request.get("/api/weshop/pickup/get/"+os.stoid+"/"+this.globalData.userInfo.pickup_id,{ + data:{}, + success:function (res) { + th.globalData.pk_store=res.data.data; + func(th.globalData.pk_store); + } + }) + }else{ + func(this.globalData.pk_store); + } + }, + + //-------获取购物车数量---------- + requestCardNum: function() { + var th = this; + th.request.get("/api/weshop/cart/page", { + data: { + store_id: th.globalData.setting.stoid, + user_id: th.globalData.user_id, + }, + success: function(e) { + var num = 0; + for (var i = 0; i < e.data.data.pageData.length; i++) { + num += e.data.data.pageData[i].goods_num; + } + wx.setTabBarBadge({ //tabbar右上角添加文本 + index: 2, ////tabbar下标 + text: '' + num //显示的内容 + }); + } + }); + }, }); diff --git a/app.json b/app.json index 190518b..58e6904 100644 --- a/app.json +++ b/app.json @@ -68,10 +68,16 @@ "pages/user/user_spsy/user_spsy", "pages/user/user_fw/user_fw", "pages/user/user_coupon/user_coupon", - "pages/user/grow_value/grow_value" + "pages/user/grow_value/grow_value", + "pages/payment/pay_success/pay_success" ], - "window": { + "permission": { + "scope.userLocation": { + "desc": "获取你的位置信息" + } + }, + "window": { "backgroundTextStyle": "light", "navigationBarTextStyle": "black", "navigationBarTitleText": "加载中...", @@ -84,6 +90,7 @@ "selectedColor": "#f23030", "borderStyle": "white", "backgroundColor": "#ffffff", + "list": [ { "pagePath": "pages/index/index/index", diff --git a/app.wxss b/app.wxss index 5677590..352c091 100644 --- a/app.wxss +++ b/app.wxss @@ -77,7 +77,7 @@ button { .modal-close { position: absolute; right: 25rpx; - top: 25rpx; + top:40rpx; } .no-data { width: 100%; @@ -220,7 +220,7 @@ justify-content:space-around; border-right: 2rpx solid ; transform: rotate(45deg); display:inline-block; - width:18rpx;height:18rpx;border-color:#da0b31;margin-top:6rpx; + width:18rpx;height:18rpx;border-color:#da0b31; } /*********************** 7.15 */ @@ -308,6 +308,17 @@ justify-content:space-around; .xc-ash{ color: #b9b9b9; } +.xc-ash-9f{ + color: #9fa1a0; + +} + +.xc-ash_c999{ +color: #999; +} +.xc-ash-b{ +background: #b9b9b9; +} .xc-black{ color: #000; } @@ -315,6 +326,9 @@ color: #b9b9b9; color: #333; } +.xc-black3{ +color: #333; +} .xc-fixed{ position: fixed; @@ -326,6 +340,9 @@ position: fixed; .yellow-co{ color: #ffb03f; } +.yellow{ + background-color: #ffb03f; +} .green{ background-color: #16ba63; } @@ -358,6 +375,9 @@ background: #ffe3e2; .fs40 { font-size: 40rpx; } -.ai_and{ - align-items:flex-end; +.ai_end{ + align-items: flex-end; } +.flex-wrap{ + flex-wrap:wrap; +} \ No newline at end of file diff --git a/components/long_warn/long_warn.js b/components/long_warn/long_warn.js index 00bb68f..0431c7a 100644 --- a/components/long_warn/long_warn.js +++ b/components/long_warn/long_warn.js @@ -8,12 +8,17 @@ Component({ is_show:0, type:0, //0 提示,失败 1成功 iurl:t.globalData.setting.imghost, + width:0, }, methods: { - open:function (e,type) { + open:function (e,type,width) { var that=this; - this.setData({is_show:1,val:e,type:type}); + if(width!=undefined) { + this.setData({is_show:1,val:e,type:type,width:width}); + }else{ + this.setData({is_show:1,val:e,type:type}); + } setTimeout(function () { that.setData({is_show:0}); },2000); diff --git a/components/long_warn/long_warn.wxml b/components/long_warn/long_warn.wxml index ebd4096..2eef76d 100644 --- a/components/long_warn/long_warn.wxml +++ b/components/long_warn/long_warn.wxml @@ -1,6 +1,6 @@ - + diff --git a/components/qr_code/qr_code.js b/components/qr_code/qr_code.js index fbdf7c9..c46b356 100644 --- a/components/qr_code/qr_code.js +++ b/components/qr_code/qr_code.js @@ -37,7 +37,9 @@ Component({ barcode('barcode'+this.data.index,val, 620, 160,this); qrcode('qrcode'+this.data.index, val, 520, 520,this); } - } + }, + + }) \ No newline at end of file diff --git a/components/qr_code/qr_code.wxml b/components/qr_code/qr_code.wxml index 7db5902..216521c 100644 --- a/components/qr_code/qr_code.wxml +++ b/components/qr_code/qr_code.wxml @@ -1,14 +1,17 @@ + - + + + - + {{object.val}} - + {{object.content}} 有效时间:{{object.now}} 至 {{object.validay}} @@ -18,7 +21,9 @@ + + \ No newline at end of file diff --git a/components/qr_code/qr_code.wxss b/components/qr_code/qr_code.wxss index 8ff3862..e58dcd3 100644 --- a/components/qr_code/qr_code.wxss +++ b/components/qr_code/qr_code.wxss @@ -6,7 +6,11 @@ display:flex; justify-content:center; align-items:center; + } +/* page{ + overflow-y: hidden; +} */ .xc-obscuration{ position: fixed; @@ -33,28 +37,36 @@ align-items:center; height: auto; padding-bottom:20rpx; left:35rpx; + overflow: hidden; + + } /* 二维码和条形码的边框 */ .barqrcode{ width: 100%; - height: auto; + height: 100%; margin-top:30rpx; +position: relative; +top: 0rpx; +left: 0rpx; } /* 点击条形 */ .barcode { height:150rpx; width: 620rpx; - padding-left:30rpx; + text-align:center; + position:absolute; + left: 30rpx } canvas{ width:100%; height:55px; display:block; -position:relative; + } .q_code{ font-size:28rpx; @@ -66,10 +78,13 @@ letter-spacing:6rpx; /* 二维码边框*/ .qrcode_rim { width: 550rpx; - height:580rpx; + height:520rpx; display:flex; flex-direction:column; -margin-left:74rpx; + +position: absolute; +left: 74rpx; +top: 130rpx; } @@ -82,7 +97,8 @@ margin-left:74rpx; } .r-code{ font-size:28rpx; - text-align: center + padding-left: 25rpx; + } .shut{ diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 9b8e343..db77217 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -1,86 +1,133 @@ -var t = getApp(), a = t.request, oo = t.globalData.setting, app = getApp(), rq = t.request; +var t = getApp(), + a = t.request, + oo = t.globalData.setting, + app = getApp(), + rq = t.request; var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ - data: { - url: t.globalData.setting.url, - resourceUrl: t.globalData.setting.resourceUrl, - requestData: null, - checkAllToggle: 0, - total_fee:0, - allsto:null, - imgUrl:t.globalData.setting.imghost, - }, - onLoad: function() { - - wx.setNavigationBarTitle({ title: "购物车",}) - - var a = this; - t.auth.hadAuth() && t.getUserInfo(function() { - a.getCardList(); + data: { + url: t.globalData.setting.url, + resourceUrl: t.globalData.setting.resourceUrl, + iurl: t.globalData.setting.imghost, + requestData: null, + checkAllToggle: 0, + total_fee: 0, //结算金额 + total_num: 0, //结算数量 + all_num: 0, //购物车中所有商品数量 + allsto: null, + imgUrl: t.globalData.setting.imghost, + is_has_flash: 0, //是否又秒杀活动 + is_edit: 0, //是否编辑 + is_load: 0, //是否已加载 + up_dating: 0, //更新中 + isreduce: 0, //商品数量是否可减 + isadd: 0, //是否可以加商品数量 + }, + + onLoad: function() { + wx.setNavigationBarTitle({ + title: "购物车", + }) + var a = this; + //判断是否有登陆 + t.auth.hadAuth() && t.getUserInfo(function() { + a.getCardList(); + }); + }, + onShow: function() { + var th = this; + this.getCardList(); + if(getApp().globalData.user_id) getApp().requestCardNum(); + //--获取是否又秒杀活动-- + getApp().request.promiseGet("/api/ms/flash_sale/spikepage", { + data: { + store_id: oo.stoid, + timetype: 2, + is_end: 0, + is_show: 1, + pageSize: 1 + }, + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.pageData.length > 0) { + th.setData({ + is_has_flash: 1 + }) + } + }); + + }, + + //-------------获取购物车列表,要安装门店进行分类订单----------- + getCardList: function() { + var th = this; + //如果门店还未读出来的时候 + if (th.data.allsto == null) { + //读取门店 + app.get_allsto(function(e) { + th.setData({ + allsto: e }); - }, - onShow: function() { - this.getCardList(); - }, - - //-------------获取购物车列表,要安装门店进行分类订单----------- - getCardList: function () { - var th = this; - //如果门店还未读出来的时候 - if (th.data.allsto==null){ - //读取门店 - app.get_allsto(function(e){ - th.setData({ allsto: e}); - th.get_cart(); - }) - }else{ th.get_cart();} + th.get_cart(); + }) + } else { + th.get_cart(); + } }, //-----真的获取购物车-------- - get_cart:function(){ - var th=this; + get_cart: function() { + var th = this; var rd = Math.random().toString(36).substr(2, 15); getApp().request.get("/api/weshop/cart/list", { data: { - user_id: app.globalData.user_id, rd: rd, - store_id: oo.stoid,pageSize:600}, - success: function (su) { - console.log("333"); - console.log(th.data.allsto); - + user_id: app.globalData.user_id, + rd: rd, + store_id: oo.stoid, + pageSize: 600 + }, + success: function(su) { //按门店分类的数组 - var arr = new Array(); - var carr = su.data.data.pageData; + var arr = new Array(), + carr = su.data.data.pageData; + var all_num = 0; + for (var i = 0; i < carr.length; i++) { var item = carr[i]; + all_num += item.goods_num; item.original_img = oo.imghost + item.original_img; + item.selected = 0; - item.selected=0; - var pcid = item.pick_id; var find = 0; //---------循环查找门店--- - if (arr.length>0){ - for (var j = 0; j < arr.length; j++) { - if (arr[j].pid == pcid) { - arr[j].goods.push(item); - find = 1; - break; - } + if (arr.length > 0) { + for (var j = 0; j < arr.length; j++) { + if (arr[j].pid == pcid) { + arr[j].goods.push(item); + find = 1; + break; } + } } //------如果没有找到----- if (find == 0) { var pikname = ''; //找到门店名称 - for (var k=0;k= a.store_count)) { - var e = { - goods_num: a.goods_num + 1, - id: a.id, - goods_id:a.goods_id, - store_id:oo.stoid - }; - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); - } - }, - //-------------减数量--------------------- - subNum: function(t) { - var a = t.currentTarget.dataset.item; - var b = t.currentTarget.dataset.pitems; - a = this.data.requestData[b].goods[a]; - - if(a.goods_num - 1<0) return false; - - if (1 != a.goods_num) { - var e = { - goods_num: a.goods_num - 1, - id: a.id, - goods_id: a.goods_id, - store_id:oo.stoid - }; - this.postCardList(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); + }); } - }, - //---------------全选,全选的时候要判断是否门店的匹配方式一致-------------- - checkAll: function() { - var e = this, dda = e.data.requestData, tfeel = 0,text_arr=""; - for (var i = 0; i < dda.length; i++) { - var item=dda[i].goods; - if (!e.data.checkAllToggle){ - var txt = "requestData[" +i+ "].selected"; - e.setData({ [txt]:0,}); + } + }); + }, + + //-----------------点击输入修改商品数量--------------- + valueToNum: function(t) { + var a = t.currentTarget.dataset.item; + var b = t.currentTarget.dataset.pitems; + a = this.data.requestData[b].goods[a]; + var e = a; + if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { + var s = { + goods_num: a, + goods_id: e.goods_id, + id: e.id, + store_id: oo.stoid + }; + this.postCardList(s, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems); + } + }, + + //-------------加数量--------------------- + addNum: function(t) { + if (this.data.up_dating == 1) return false; + this.data.up_dating = 1; + + var a = t.currentTarget.dataset.item; + var b = t.currentTarget.dataset.pitems; + a = this.data.requestData[b].goods[a]; + + if (a.goods_num 0 ){ - - console.log(item); - for (var i = 0; i < iarr.length; i++) { - if (iarr[i].distr_type != 0) { - if (fir == 0) { fir = iarr[i].distr_type; } - else { - if (fir != iarr[i].distr_type && iarr[i].distr_type!=0 ) { isok = 0; break; } + if (text_arr != "") { + wx.showModal({ + title: '提示', + content: text_arr + '不能与门店中其他商品一起结算,配送方式不一致' + }); + return false; + } else { + e.setData({ + checkAllToggle: !e.data.checkAllToggle, + total_fee: tfeel.toFixed(2), + total_num: t_num, + }); + } + }, + + //------门店全选按钮,要判断是否门店的匹配方式一致--------- + check_th_all_item: function(ele) { + var e = this, + pitems = ele.currentTarget.dataset.pitems, + item = this.data.requestData[pitems].goods, + sele = this.data.requestData[pitems].selected; + + var isok = 1, + fir = 0, + iarr = item; + if (!sele && item.length > 0) { + for (var i = 0; i < iarr.length; i++) { + if (iarr[i].distr_type != 0) { + if (fir == 0) { + fir = iarr[i].distr_type; + } else { + if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) { + isok = 0; + break; } } } - } + } + } - if (!isok) { - wx.showModal({ title: '提示', content: '同一门店自提和物流的商品不能同时结算' }); return false; - } + if (!isok) { + wx.showModal({ + title: '提示', + content: '同一门店自提和物流的商品不能同时结算' + }); + return false; + } - for(var i=0;i 1 && !a.selected){ - for (var i = 0; i < iarr.length;i++){ - //---当不是本身选择项目---- - var sel = iarr[i].selected; - if (iarr[i].distr_type != 0 && (sel || iarr[i].id==a.id)) { - if (fir == 0) { fir = iarr[i].distr_type; } - else { - if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) { isok = 0; break; } - } - } + for (var i = 0; i < item.length; i++) { + var txt = "requestData[" + pitems + "].goods[" + i + "].selected"; + e.setData({ + [txt]: Number(!sele), + }); + } + var txt = "requestData[" + pitems + "].selected"; + e.setData({ + [txt]: Number(!sele), + }); + this.doCheckAll(); + }, + + //---------------单选,也要判断门店的配送方式是否一致-------------- + check_th_item: function(t) { + var e = this, + item = t.currentTarget.dataset.item, + pitems = t.currentTarget.dataset.pitems; + a = this.data.requestData[pitems].goods[item]; + var isok = 1, + fir = 0; + var iarr = e.data.requestData[pitems].goods; + + + //当数量大于1,且是选择的时候 + if (iarr.length > 1 && !a.selected) { + for (var i = 0; i < iarr.length; i++) { + //---当不是本身选择项目---- + var sel = iarr[i].selected; + if (iarr[i].distr_type != 0 && (sel || iarr[i].id == a.id)) { + if (fir == 0) { + fir = iarr[i].distr_type; + } else { + if (fir != iarr[i].distr_type && iarr[i].distr_type != 0) { + isok = 0; + break; + } } } - if(!isok){ - wx.showModal({ title: '提示', content: '同一门店自提和物流的商品不能同时结算' }); - }else{ - var txt = "requestData[" + pitems + "].goods[" + item + "].selected"; - e.setData({ - [txt]: Number(!a.selected), - }); - this.doCheckAll(); + } + } + if (!isok) { + wx.showModal({ + title: '提示', + content: '同一门店自提和物流的商品不能同时结算' + }); + } else { + var txt = "requestData[" + pitems + "].goods[" + item + "].selected"; + e.setData({ + [txt]: Number(!a.selected), + }); + this.doCheckAll(); + } + }, + //----------检查是否全选--------- + doCheckAll: function() { + var th = this, + tfeel = 0, + t_num = 0, + ischeck = 1, + car = this.data.requestData, + all_num = 0; + + for (var a = 0; a < car.length; a++) { + var item = car[a].goods, + is_s_sele = 1; + for (var c = 0; c < item.length; c++) { + all_num += item[c].goods_num; + if (item[c].selected == 0) { + ischeck = 0; + is_s_sele = 0; + } else { + tfeel += item[c].goods_num * item[c].goods_price; + t_num += item[c].goods_num; } - }, - //----------检查是否全选--------- - doCheckAll: function() { - var th=this,tfeel=0,ischeck = 1,car = this.data.requestData; - for (var a = 0; a < car.length; a++) { - var item = car[a].goods; - var is_s_sele=1; - for (var c = 0; c < item.length;c++){ - if(item[c].selected==0){ - ischeck=0; - is_s_sele=0; - } - else{ tfeel += item[c].goods_num * item[c].goods_price; } - } + } + + var txt = "requestData[" + a + "].selected"; + th.setData({ + [txt]: Number(is_s_sele) + }); + + } + this.setData({ + checkAllToggle: ischeck, + total_fee: tfeel.toFixed(2), + all_num: all_num, + total_num: t_num + }); + }, - var txt = "requestData[" + a+ "].selected"; - th.setData({ - [txt]: Number(is_s_sele), + //----------------------更新购物数量,加减,调用接口--------------------- + postCardList: function(t, item, pitem) { + var e = this; + var user_id = getApp().globalData.user_id; + console.log('update'); + console.log(t); + rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, { + isShowLoading: 0, + async success(d) { + var limit = d.data.data.viplimited; + var store_count = d.data.data.store_count; + + var goodsinfo = e.data.requestData[pitem].goods[item]; + var promgoodsbuynum = 0; + var goodsbuynum = 0; + + //--要获得商品,该用户买了多少件,同步应用-- + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: oo.stoid, + user_id: user_id, + goods_id: goodsinfo.goods_id, + prom_type: goodsinfo.prom_type, + prom_id: goodsinfo.prom_id + }, + }).then(res => { + var buy_num_data = res.data.data; + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; + goodsbuynum = buy_num_data.goodsbuynum; + }) + + var buyed_mum2 = t.goods_num + goodsbuynum; + if (buyed_mum2 > limit && limit > 0) { + wx.showModal({ + title: '提示', + content: '购买数量超出商品限购' }); + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + var cbuy = limit - buyed_mum; + e.setData({ + [txt]: cbuy > 0 ? cbuy : 0, + }); + e.doCheckAll(); + return false; + } + if (t.goods_num > store_count) { + wx.showModal({ + title: '提示', + content: '购买数量超出商品库存' + }); + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + e.setData({ + [txt]: store_count + }); + e.doCheckAll(); + return false; } - this.setData({ - checkAllToggle: ischeck, - total_fee: tfeel.toFixed(2), - }); - }, - - //----------------------更新购物数量,加减,调用接口--------------------- - postCardList: function (t, item, pitem) { - var e = this; - var user_id=getApp().globalData.user_id; - console.log('update'); - console.log(t); - rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, { - async success(d) { - var limit = d.data.data.viplimited; - var store_count = d.data.data.store_count; - - var goodsinfo=e.data.requestData[pitem ].goods[item]; - var promgoodsbuynum=0; - var goodsbuynum=0; - //--要获得商品,该用户买了多少件,同步应用-- - await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum",{ - data: { - store_id: oo.stoid, - user_id: user_id, - goods_id: goodsinfo.goods_id, - prom_type:goodsinfo.prom_type, - prom_id:goodsinfo.prom_id - }, - }).then(res=>{ - var buy_num_data=res.data.data; - if(buy_num_data.promgoodsbuynum) promgoodsbuynum=buy_num_data.promgoodsbuynum; - goodsbuynum=buy_num_data.goodsbuynum; - }) - - var buyed_mum2 = t.goods_num + goodsbuynum; - if (buyed_mum2>limit && limit>0){ - wx.showModal({ title: '提示', content: '购买数量超出商品限购'}); - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; - var cbuy = limit - buyed_mum; - e.setData({ [txt]: cbuy > 0 ? cbuy:0, }); - return false; - } - if (t.goods_num > store_count) { - wx.showModal({ title: '提示', content: '购买数量超出商品库存' }); - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; - e.setData({ [txt]: store_count }); - return false; - } + if (goodsinfo.prom_type == 1) { + //读取秒杀 + rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, { + isShowLoading: 0, + success: function(res_d) { + var false_data = res_d.data.data; + + //--判断库存-- + if (t.goods_num > false_data.goods_num - false_data.buy_num) { + wx.showModal({ + title: '提示', + content: '购买数量超出活动库存' + }); + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + e.setData({ + [txt]: false_data.goods_num - false_data.buy_num + }); + e.doCheckAll(); + return false; + } - if(goodsinfo.prom_type==1){ - //读取秒杀 - rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, { - success: function (res_d) { - var false_data=res_d.data.data; - - //--判断库存-- - if (t.goods_num > false_data.goods_num-false_data.buy_num){ - wx.showModal({ title: '提示', content: '购买数量超出活动库存' }); - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; - e.setData({ [txt]: false_data.goods_num-false_data.buy_num }); - return false; - } - - //--判断redis数量是否已经超出-- - if(t.goods_num >false_data.redisnum){ - wx.showModal({ title: '提示', content: '购买数量超出商品库存' }); - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; - e.setData({ [txt]: false_data.redisnum }); - return false; - } - - //--活动的限购是不是要判断-- - if(t.goods_num+promgoodsbuynum >false_data.buy_limit && false_data.buy_limit>0){ - wx.showModal({ title: '提示', content: '购买数量超出秒杀限购' }); - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; - e.setData({ [txt]: false_data.false_data.buy_limit }); - return false; - } - - e.update_cart(t,pitem,item); - } - }) - }else{ - e.update_cart(t,pitem,item); - } + //--判断redis数量是否已经超出-- + if (t.goods_num > false_data.redisnum) { + wx.showModal({ + title: '提示', + content: '购买数量超出商品库存' + }); + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + e.setData({ + [txt]: false_data.redisnum + }); + e.doCheckAll(); + return false; } - }); - }, - - //更新购物车 - update_cart:function(t,pitem,item){ - var e=this; - getApp().request.put("/api/weshop/cart/update", { - data: t, - success: function (ee) { - var txt = "requestData[" + pitem + "].goods[" + item+"].goods_num"; + + //--活动的限购是不是要判断-- + if (t.goods_num + promgoodsbuynum > false_data.buy_limit && false_data.buy_limit > 0) { + wx.showModal({ + title: '提示', + content: '购买数量超出秒杀限购' + }); + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; e.setData({ - [txt]: t.goods_num, + [txt]: false_data.false_data.buy_limit }); e.doCheckAll(); + return false; + } + e.update_cart(t, pitem, item); } + }) + } else { + e.update_cart(t, pitem, item); + } + } + }); + }, + + //更新购物车 + update_cart: function(t, pitem, item) { + var e = this; + getApp().request.put("/api/weshop/cart/update", { + data: t, + success: function(ee) { + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + e.data.up_dating = 0 + e.setData({ + [txt]: t.goods_num, }); - }, - - //-------下拉刷新--------- - onPullDownRefresh: function(t) { - this.getCardList(); - }, - - //--------------去结算------------ - async checkout() { - var glist=""; //用逗号隔开的 - var map=new Map(); //使用map值键进行运算 - var map_limit=new Map(); //使用map值键进行存储限购 - var g_arr = new Array(); //已选的商品列表 - var user_id=getApp().globalData.user_id; - var th=this; - - var ab = 0;//选中 - console.log('checkout'); - for (var i=0;i{ - var buy_num_data=res.data.data; - if(buy_num_data.promgoodsbuynum) promgoodsbuynum=buy_num_data.promgoodsbuynum; - goodsbuynum=buy_num_data.goodsbuynum; - }) - var ie={promgoodsbuynum:promgoodsbuynum,goodsbuynum:goodsbuynum}; - map_limit.set(val.goods_id + "", ie); - } - - try{ - ddata.forEach(function(val,ind){ - var num = map.get(val.goods_id+""); - if (num<=0) { - isok = 0; gname = val.goods_name; - throw "购买数量不能为0";return false; - } - if ( num>val.store_count) { - isok = 0; gname = val.goods_name; - throw "超出库存"; return false; - } - if ( num>val.redisnum && val.redisnum) { - isok = 0; gname = val.goods_name; - throw "超出活动库存"; return false; - } - if ( num>val.goods_num-val.buy_num && val.goods_num) { - isok = 0; gname = val.goods_name; - throw "超出活动库存";return false; - } - - var buyed=map_limit.get(val.goods_id+""); - if (num+buyed.goodsbuynum>val.viplimited && val.viplimited>0) { - isok = 0; gname = val.goods_name; - throw "超出商品限购";return false; - } - - if (num+buyed.promgoodsbuynum>val.buy_limit && val.buy_limit>0) { - isok = 0; gname = val.goods_name; - throw "超出活动限购";return false; - } - - for (var i = 0; i < g_arr.length;i++){ - if (g_arr[i].goods_id==val.goods_id){ - 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, selected: 1,store_id:oo.stoid }, - success: function (ee) { - console.log(ee); - } - }); - } - } - - }) - } catch (e) { err=e;} - if (isok==0){ - if (gname.length > 10) { - gname = gname.substr(0, 10); gname+="..."; - } - t.confirmBox(gname+":"+ err); return false; + } + } + if (ab == 0) { + t.my_warnning("未选择商品", 0, th); + return false; + } + + glist = glist.substring(0, glist.length - 1); + //--取一下商品的限购 以及活动的限购,redis数量-- + rq.get("/api/weshop/goods/getGoodsListNum", { + data: { + goodsidlist: glist, + store_id: oo.stoid + }, + async success(ee) { + console.log(ee); + if (ee.data.code == 0) { + var ddata = ee.data.data, + isok = 1, + gname = "", + err = ""; + //--组装-- + for (var ij = 0; ij < ddata.length; ij++) { + var val = ddata[ij]; + var obj = map_limit.get(val.goods_id + ""); + if (obj) continue; + + var promgoodsbuynum = 0; + var goodsbuynum = 0; + //--要获得商品,该用户买了多少件,同步应用-- + await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { + data: { + store_id: oo.stoid, + user_id: user_id, + goods_id: val.goods_id, + prom_type: val.prom_type, + prom_id: val.prom_id + }, + }).then(res => { + var buy_num_data = res.data.data; + if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum; + goodsbuynum = buy_num_data.goodsbuynum; + }) + var ie = { + promgoodsbuynum: promgoodsbuynum, + goodsbuynum: goodsbuynum + }; + map_limit.set(val.goods_id + "", ie); + } + + try { + ddata.forEach(function(val, ind) { + var num = map.get(val.goods_id + ""); + if (num <= 0) { + isok = 0; + gname = val.goods_name; + throw "购买数量不能为0"; + return false; + } + if (num > val.store_count) { + isok = 0; + gname = val.goods_name; + throw "超出库存"; + return false; + } + if (num > val.redisnum && val.redisnum) { + isok = 0; + gname = val.goods_name; + throw "超出活动库存"; + return false; + } + if (num > val.goods_num - val.buy_num && val.goods_num) { + isok = 0; + gname = val.goods_name; + throw "超出活动库存"; + return false; + } + + var buyed = map_limit.get(val.goods_id + ""); + if (num + buyed.goodsbuynum > val.viplimited && val.viplimited > 0) { + isok = 0; + gname = val.goods_name; + throw "超出商品限购"; + return false; + } + + if (num + buyed.promgoodsbuynum > val.buy_limit && val.buy_limit > 0) { + isok = 0; + gname = val.goods_name; + throw "超出活动限购"; + return false; + } + + for (var i = 0; i < g_arr.length; i++) { + if (g_arr[i].goods_id == val.goods_id) { + 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, + selected: 1, + store_id: oo.stoid + }, + success: function(ee) { + console.log(ee); } - wx.navigateTo({ - url: "/pages/cart/cart2/cart2" - }); + }); } + } + + }) + } catch (e) { + err = e; } - }); - }, - - //结算到最后一个商品 - set_last: function (ab, isok, gname){ - if (isok == 0) { - t.my_warnning(gname + "商品超出库存",0,this); - } else { - ab ? wx.navigateTo({ - url: "/pages/cart/cart2/cart2" - }) : t.my_warnning("还没有选中商品",0,this); + if (isok == 0) { + t.confirmBox(gname + ":" + err); + return false; + } + wx.navigateTo({ + url: "/pages/cart/cart2/cart2" + }); + } } - }, + }); + }, + + //结算到最后一个商品 + set_last: function(ab, isok, gname) { + if (isok == 0) { + t.my_warnning(gname + "商品超出库存", 0, this); + } else { + ab ? wx.navigateTo({ + url: "/pages/cart/cart2/cart2" + }) : t.my_warnning("还没有选中商品", 0, this); + } + }, //图片失败,默认图片 - bind_bnerr2: function (e) { + bind_bnerr2: function(e) { var _errImg = e.target.dataset.errorimg; var _errurl = e.target.dataset.url; var ii = _errurl.indexOf(oo.imghost); if (ii != -1) { this.setData({ - [_errImg]: oo.imghost+"/miniapp/images/default_g_img.gif", + [_errImg]: oo.imghost + "/miniapp/images/default_g_img.gif", }) } + }, + //设置点击按钮为true或者false + radio_chick: function(checked, num) { + var th = this; + var requestData = th.data.requestData; + }, + + //点击编辑后的效果 + edit_cart: function(e) { + var type = parseFloat(e.currentTarget.dataset.type); + this.setData({ + is_edit: type + }); + }, + + //--多个删除购物车商品--- + check_del: function() { + var glist = ""; //用逗号隔开的 + var user_id = getApp().globalData.user_id; + var th = this; + + var ab = 0; //选中 + for (var i = 0; i < this.data.requestData.length; i++) { + var i_arr = this.data.requestData[i].goods; + for (var j = 0; j < i_arr.length; j++) { + if (i_arr[j].selected) { + glist += i_arr[j].id + ","; + ab = 1; + } + } + } + + if (ab == 0) { + t.my_warnning("未选择商品", 0, th); + return false; + } + glist = glist.substring(0, glist.length - 1); + //要删除购物车中的商品 + var url = '/api/weshop/cart/delIds/' + oo.stoid + '/' + user_id + "/" + glist; + getApp().request.delete(url, { + success: function(t) { + th.getCardList(); + } + }); + }, + //跳到首页 + goto: function(e) { + wx.switchTab({ + url: '/pages/index/index/index', + }) } -}); +}); \ No newline at end of file diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index 7f8d9b3..695a6d2 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -1,57 +1,116 @@ + + + + - + + + + + + + + + 全选 + - - - - - 总计 : {{total_fee}} - - 不包含运费 + + + + 合计: + ¥{{total_fee}} + + + 不含运费 + - - - - 购物车暂无商品 - 去逛逛 + + + + + + + + + + + + + 购物车竟然是空的 + + + 去首页逛逛 + + + \ No newline at end of file diff --git a/pages/cart/cart/cart.wxss b/pages/cart/cart/cart.wxss index 2a62032..904cf00 100644 --- a/pages/cart/cart/cart.wxss +++ b/pages/cart/cart/cart.wxss @@ -1,144 +1,296 @@ page { - background-color: #fff; + background-color: rgb(245, 245, 245); + font-family: crosoft yahei; +} + +.padding { + padding: 0rpx 30rpx; +} + +.alend { + align-items: flex-end; +} + +.goods-price { + font-size: 18rpx; +} + +.baseline { + display: flex; + align-items: baseline; +} + +.picture { + width: 100%; + height: 220rpx; } .container { - display: flex; - height: 100%; - align-items: center; - justify-content: center; - background-color: #fff; - padding-bottom: 100rpx; + display: flex; + height: 100%; + align-items: center; + justify-content: center; + background-color: rgb(255, 255, 255); + margin-bottom: 99rpx; +} + +radio { + transform: scale(0.8); } .login-in { - width: 100%; - box-sizing: border-box; + width: 100%; + box-sizing: border-box; + background-color: rgb(255, 255, 255); } .order-item { - display: flex; - justify-content: space-around; - height: 200rpx; - padding: 10rpx 0; - border-bottom: 1px solid #ddd; + display: flex; + height: 246rpx; + border-top: 3rpx solid rgb(245, 245, 245); + align-items: center; + padding-right: 30rpx; } .goods-ico { - display: flex; - align-items: center; + display: flex; + align-items: center; + padding: 0rpx 30rpx; +} + +.order-raido { + height: 100%; + padding-left: 30rpx; + padding-right: 25rpx; } .goods-img { - width: 180rpx; - height: 180rpx; - font-size: 0; - margin-top: 10rpx; + width: 180rpx; + height: 180rpx; + font-size: 0; + overflow: hidden; + border: 2rpx solid rgb(236, 236, 236); } .goods-cont { - position: relative; - width: 430rpx; - height: 200rpx; - font-size: 28rpx; + width: 385rpx; + height: 165rpx; + font-size: 28rpx; + margin-left: 35rpx; + padding-top: 7rpx; + padding-bottom: 5rpx; } .goods-name { - width: 370rpx; - height: 64rpx; - margin: 8rpx 0; - line-height: 32rpx; - color: #333; - + line-height: 32rpx; + color: #333; + height: 125rpx; } .goods-attribute { - max-height: 52rpx; - line-height: 26rpx; - font-size: 24rpx; - color: #999; -} - -.goods-price { - height: 40rpx; - line-height: 40rpx; - margin-top: 10rpx; + max-height: 52rpx; + line-height: 26rpx; + font-size: 24rpx; + color: #999; } .btn-del { - position: absolute; - right: 0; - top: 8rpx; - width: 34rpx; - height: 34rpx; + position: absolute; + right: 0; + top: 8rpx; + width: 34rpx; + height: 34rpx; } .count { - position: absolute; - right: 0; - bottom: 5rpx; - width: 156rpx; - height: 50rpx; - border: 1px solid #ddd; + display: flex; + bottom: 5rpx; + border: 2rpx solid rgb(236, 236, 236); + margin-bottom: 3rpx; +} + +.count>view, .count>input { + width: 50rpx; + height: 40rpx; + line-height: 40rpx; + text-align: center; + display: flex; + font-size: 18rpx; + justify-content: center; + min-height: 35rpx; } -.count>view,.count>input { - float: left; - width: 50rpx; - height: 50rpx; - line-height: 50rpx; - text-align: center; +.count>.goodadd { + width: 67rpx; + font-size: 24rpx; +} + +.count>.add { + font-size: 32rpx; } .sub { - border-right: 1px solid #ddd; + border-right: 2rpx solid rgb(236, 236, 236); } .add { - border-left: 1px solid #ddd; + border-left: 2rpx solid rgb(236, 236, 236); } .pay-for { - width: 100%; - height: 100rpx; - position: fixed; - left: 0; - bottom: 0; - font-size: 28rpx; - color: #666; - background-color: #f0f2f5; + + width: 100%; + height: 100rpx; + position: fixed; + left: 0; + bottom: 0; + font-size: 28rpx; + color: #666; + background-color: rgb(255, 255, 255); + z-index: 2; + border-top: 1rpx solid rgb(236, 236, 236); + border-bottom: 1rpx solid rgb(236, 236, 236); + } .pay-for .pay-btn { - float: right; - width: 200rpx; - height: 100rpx; - line-height: 100rpx; - text-align: center; - background-color: #f23030; - color: #fff; - border-radius: 0; + width: 220rpx; + height: 100rpx; + line-height: 100rpx; + background-color: rgb(219, 27, 52); + color: #fff; + border-radius: 0; + font-size: 31rpx; } .pay-for .consumer { - float: right; - margin-right: 20rpx; - line-height: 50rpx; + margin-right: 23rpx; + color: rgb(0, 0, 0); + letter-spacing: 1rpx; +} + +.pay-for .consumer .total { + color: rgb(0, 0, 0); +} + +.pay-for .consumer .tips { + color: rgb(153, 153, 153); } .pay-for .checkbox { - float: left; - padding-left: 40rpx; - line-height: 100rpx; - display: flex; - align-items: center; + float: left; + padding-left: 40rpx; + line-height: 100rpx; + display: flex; + align-items: center; } .pay-for .ico-check { - display: flex; - align-items: center; - margin-right: 20rpx; + display: flex; + align-items: center; + margin-right: 20rpx; +} + +.shmd_m { + height: 80rpx; + line-height: 80rpx; + display: flex; +} + +.shmd_m image { + height: 50rpx; + width: 55rpx; + margin-left: -10rpx; } -.shmd_m{margin-left: 5rpx; height: 80rpx; line-height: 80rpx; display: flex;border-bottom: 1rpx solid #ddd} -.shmd_m .goods-ico icon{margin-top: 26rpx;} -.shmd{margin-left: 20rpx;} \ No newline at end of file + +.shmd_m .goods-ico icon { + margin-top: 26rpx; +} + +.shmd { + margin-left: 5rpx; +} + +.store { + border-bottom: 7rpx solid rgb(245, 245, 245); +} + +.login-in .Storenum { + height: 80rpx; + color: rgb(51, 51, 51); +} + +.login-in .goods_num { + margin-left: 13rpx; +} + +.allradio { + width: 600rpx; + height: 100%; +} + +.allradio .all { + color: rgb(0, 0, 0); +} + +.specifications { + padding: 3rpx 8rpx; + margin-top: 8rpx; + font-size: 22rpx; + max-width: 356rpx; + width: auto; + height: 30rpx; + line-height: 29rpx; + background-color: rgb(236, 236, 236); + border-radius: 8rpx; + white-space: nowrap; + color: rgb(63, 63, 63); + display: inline-block; + +} + +.ellipsis-2 { + max-height: 64rpx; +} + +.abs { + top: 15rpx; + left: -39rpx; + width: 154rpx; + height: 40rpx; + background-color: rgb(16, 202, 220); + transform: rotate(320deg); + color: rgb(255, 255, 255); + line-height: 40rpx; +} + +/* 购物车为空 */ + +.empty_order image { + width: 329rpx; + height: 229rpx; + margin-top: 140rpx; +} + +.empty_order .xc-ash { + margin-top: 25rpx; + font-weight: 600px; +} + +.empty_order navigator { + margin-top: 60rpx; + border-radius: 40rpx; +} + +.empty_order navigator view { + width: 247rpx; + height: 56rpx; + background-color: rgb(255, 72, 72); + border-radius: 40rpx; +} + +.icon_no_sele{ display: inline-block; width: 39rpx; height: 39rpx; border: 1rpx solid #ddd; border-radius: 50%} +.icon_no_sele2{width: 39rpx; height: 39rpx; border: 1rpx solid #ddd; border-radius: 50%; margin-top: 20rpx; + margin-left: 30rpx; margin-right: 25rpx} + +.mlr{ margin-left: 25rpx; margin-right: 20rpx} diff --git a/pages/cart/cart2/c_filter.wxs b/pages/cart/cart2/c_filter.wxs new file mode 100644 index 0000000..6a74c7e --- /dev/null +++ b/pages/cart/cart2/c_filter.wxs @@ -0,0 +1,63 @@ +var filters = { + toFix:function(val,count){ + return val.toFixed(count) + }, + format_time:function(ts,isFull) { + var d = getDate(ts*1000) + var fm=[d.getFullYear(), d.getMonth()+1, d.getDate()].join('-'); + if(isFull==1) + fm=fm + ' '+ [d.getHours(), d.getMinutes(), d.getSeconds()].join(':') + return fm; + }, + setcolor:function(ind){ + if (ind == 0 || ind ==null) return "red"; + if(ind==1 ) return "green"; + if(ind==2) return "blue"; + if(ind==11) return "green"; + if(ind==12) return "blue"; + return ""; + }, + setbgcolor: function (ind) { + if (ind == 0 || ind == null) return "#ffa1b9"; + if (ind == 1) return "#59e1d2"; + if (ind == 2) return "#a3bcff"; + if (ind == 11) return "#59e1d2"; + if (ind == 12) return "#a3bcff"; + return ""; + }, + + get_type:function(ind){ + if (ind == 0 || ind == null) return "全场通用"; + if (ind == 1) return "品牌"; + if (ind == 2) return "品类"; + if (ind == 11) return "用途"; + if (ind == 12) return "分类1"; + return ""; + }, + get_type_card:function(ind){ + if (ind == 0 || ind == null) return "全场通用"; + if (ind == 1) return "指定品牌"; + if (ind == 2) return "指定品类"; + if (ind == 11) return "指定用途"; + if (ind == 12) return "指定分类1"; + return ""; + }, + format_huiche:function (text) { + if (!text) { + return ""; + } + var reg = getRegExp('\\\\n', 'g') + return text.replace(reg, '\n') + } +} + +module.exports = { + toFix: filters.toFix, + format_time:filters.format_time, + setcolor:filters.setcolor, + setbgcolor: filters.setbgcolor, + get_type: filters.get_type, + get_split_name: filters.get_split_name, + get_type_card: filters.get_type_card, + format_huiche: filters.format_huiche, +} \ No newline at end of file diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index a98daa6..1bda41a 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -2,10 +2,11 @@ var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); var oo=t.globalData.setting; var regeneratorRuntime = require('../../../utils/runtime.js'); +var util_pay = require("../../../utils/pay.js"); -Page({ +Page({ data: { - url: t.globalData.setting.url, + url: t.globalData.setting.url, resourceUrl: t.globalData.setting.resourceUrl, imgUrl: t.globalData.setting.imghost, goods: null, @@ -51,6 +52,7 @@ Page({ /*----------物流选择--------*/ wu_arr:null, index:0, + w_sele_index:0, //判断页面是返回回来的还是 首次进入的 isclose:1, @@ -71,10 +73,17 @@ Page({ //选择的券列表 selected_quan_list:null, //选择的券的门店 - selected_quan_pick:null, + selected_quan_pick:null, is_close_quan:0, disabled:0, - + open_express:0,//控制选择物流名列表 的属性 + + is_express:0, //选中物流的属性 + expres_name:"", //点击选定 + isopen:0, //券的说明 + is_coupon:null, //选择券的控制属性 + is_shipping_code:"",//插入用户默认地址 + wu_arr_txt:"", //要更新的物流的字段 }, onLoad: function(t) { @@ -89,21 +98,20 @@ Page({ } }); - //先获取是否有关闭使用优惠券 - getApp().getConfig2(function (ee) { - var json_d = JSON.parse(ee.switch_list); - th.setData({ is_close_quan: json_d.is_close_quan }); - //-----先获取物流,再获取用户信息,再展示页面----- - th.get_wuliu(th.get_info(th.show_page)); - }) + //先获取是否有关闭使用优惠券 + getApp().getConfig2(function (ee) { + var json_d = JSON.parse(ee.switch_list); + th.setData({ is_close_quan: json_d.is_close_quan }); + //-----先获取物流,再获取用户信息,再展示页面----- + th.get_wuliu(th.get_info(th.show_page)); + }) + }, onUnload: function () { this.setData({ isclose: 1 })}, //----------子页返回父页触发---------- onShow: function() { - console.log('onshow'); var th=this; - console.log(th.data.isclose); if (th.data.isclose==0){ /*--- wx.navigateTo({ @@ -115,7 +123,7 @@ Page({ }) }else{ - this.getuser_addr(function(ie){ + this.getuser_addr(function(ie){ console.log("getuser_addr") console.log(ie) @@ -137,15 +145,20 @@ Page({ },500) }); + //--更新默认地址--,看一下是不是跳到地址页面 + if(!getApp().globalData.is_cart2_old){ + this.update_code(); + }else{ + getApp().globalData.is_cart2_old=0; + } } }, //-------------------获取物流--------------- get_wuliu(func) { + var th = this; to.getwuliu(function (e) { - console.log("ws"); - console.log(e); th.setData({ wu_arr: e }) typeof func == "function" && func(); }) @@ -223,7 +236,7 @@ Page({ }); }, - //-----真的获取购物车-------- + //-----真的获取购物车,入口-------- get_cart: function () { var th = this,app=getApp(); a.get("/api/weshop/cart/list", { @@ -277,9 +290,17 @@ Page({ //如果是物流的话,全部自提的控制要弄成0 if (e_t == 0) th.setData({ is_all_zt:0}); var narr = new Array(); narr.push(item); - //-----------拼装购物车结算的数组----------------- + + //-----------拼装购物车结算的数组,如果有默认物流时要用默认物流编号----------------- + var m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; + if(e_t==0 && def_exp_code){ + for(var k=0;k{ if(res.data.code==0) quanlist=res.data.data.pageData; + + }) } @@ -416,9 +447,9 @@ Page({ t.data.data.prom_id = 0; t.data.data.prom_type = 0; - + th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, bn_pick: gg.pick_id, bn_t_exp_t: distr_t,selected_quan_list:quanlist }); //计算价格 @@ -462,8 +493,9 @@ Page({ } } } + th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, bn_pick: gg.pick_id, bn_t_exp_t: distr_t,selected_quan_list:quanlist }); //计算价格 @@ -574,8 +606,7 @@ Page({ th.data.cartlist[i].shipping_price=0; } - th.data.cartlist[i].shipping_price.toFixed(2); - + th.data.cartlist[i].shipping_price=th.data.cartlist[i].shipping_price.toFixed(2); //---如果有选择优惠券的情况下--- var quan_price=0; var coupon_price=0,bn_pick=th.data.bn_pick,pickid=cart_item.pickup_id; @@ -627,7 +658,7 @@ Page({ } }else{ th.data.cartlist[i].user_money=0; - } + } th.data.cartlist[i].user_money = parseFloat(th.data.cartlist[i].user_money).toFixed(2); @@ -637,16 +668,17 @@ Page({ th.data.cartlist[i].goods_price = o_price.toFixed(2); th.data.cartlist[i].order_amount= th.data.cartlist[i].order_amount- th.data.cartlist[i].user_money; //会员使用余额 - all_price += parseFloat(o_price); - all_total_m += parseFloat(th.data.cartlist[i].total_amount); - all_shipping_m += parseFloat(th.data.cartlist[i].shipping_price); - all_order_m += parseFloat(th.data.cartlist[i].order_amount); - all_user_m += parseFloat(th.data.cartlist[i].user_money); - all_coupon_price_m+= parseFloat(th.data.cartlist[i].coupon_price); + all_price += parseFloat(o_price); + all_total_m += parseFloat(th.data.cartlist[i].total_amount); + all_shipping_m += parseFloat(th.data.cartlist[i].shipping_price); + all_order_m += parseFloat(th.data.cartlist[i].order_amount); + all_user_m += parseFloat(th.data.cartlist[i].user_money); + all_coupon_price_m+= parseFloat(th.data.cartlist[i].coupon_price); } + all_shipping_m=parseFloat(all_shipping_m).toFixed(2); all_total_m = parseFloat(all_total_m).toFixed(2); all_order_m = parseFloat(all_order_m).toFixed(2); all_price = parseFloat(all_price).toFixed(2); @@ -758,6 +790,7 @@ Page({ //--------------如果使用余额--------------------- if (th.data.bn_use_money == 1) { if (amoney> order_m) { + order_m = order_m.toFixed(2); th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price }) }else{ order_m =parseFloat(order_m - amoney); @@ -949,6 +982,7 @@ Page({ } console.log(pdata); } + if (pdata.length==0) return; var str = JSON.stringify(pdata); wx.showLoading({title: "加载中"}); @@ -983,9 +1017,24 @@ Page({ //要进行判断,如果是用微信支付,就要跳转到支付界面 if (order_amount > 0) { th.setData({ isclose: 0 }); - void e.jumpToCart4({ - order_sn: data.data, - }, 1); + //void e.jumpToCart4({ + // order_sn: data.data, + //}, 1); + util_pay.pay(data.data, function() { + //app.my_warnning("支付成功",1,th); + //setTimeout(function () { + wx.navigateTo({ + url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data + }) + //},1000) + + }, function () { + //支付失败 + setTimeout(function () { + wx.navigateBack({ delta: 1 }) + },1000) + },oo.stoid); + } else { var dd = { parent_sn: data.data, @@ -997,13 +1046,13 @@ Page({ success: function (t) { //console.log(t); if(t.data.code==0){ - app.my_warnning("支付成功",1,th); - setTimeout(function () { + //app.my_warnning("支付成功",1,th); + //setTimeout(function () { th.setData({ isclose: 0 }); wx.navigateTo({ - url: "/pages/user/order_list/order_list" + url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data, }) - }, 1000) + //}, 1000) } }, fail:function () { @@ -1049,17 +1098,22 @@ Page({ }); }, enterAddressPage: function() { + getApp().globalData.is_cart_old=1; this.data.enterAddressPage = !0, wx.navigateTo({ - url: "/pages/user/address_list/address_list?is_back=1" + url: "/pages/user/address_list/address_list" }); }, - //--------立即购买时,选择自提和物流----------- + //--------购物车购买时,选择自提和物流----------- setexptype_w:function(t){ - var th=this; - var ty = t.currentTarget.dataset.t,txt = t.currentTarget.dataset.txt; + var def_exp_code= getApp().globalData.userInfo.def_exp_code,th=this; + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt, + wl_txt = t.currentTarget.dataset.wl_txt, + ont = t.currentTarget.dataset.ont; + th.setData({ [txt]: ty }); var iszt=1; + if(ty==0){ th.setData({ is_all_zt: 0 }); }else{ @@ -1067,22 +1121,48 @@ Page({ var item = th.data.cartlist[i]; if (item.exp_type==0){ iszt=0;break;} } + th.setData({ is_all_zt: iszt }); } + //判断有没有默认的物流地址值 + if (def_exp_code != "" && def_exp_code != null && def_exp_code !=undefined) { + var wu_arr=this.data.wu_arr; + if (wu_arr!= null && wu_arr!=""){ + for(var i=0;i + +
- - + + - + + - - 门店:{{item.pname}} + + + 门店:{{item.pname}} @@ -40,70 +48,116 @@ {{items.goods_name}} - - {{items.goods_spec}}/ - {{items.goods_color==null?"":items.goods_color}} + + + + {{items.goods_spec}} + {{items.goods_color==null || items.goods_color=='' ?"":"/"+items.goods_color}} + - - - - ¥{{items.goods_price}} + + + + + {{filters.toFix(items.goods_price,2)}} x{{items.goods_num}} + + - 使用优惠券 + 优惠券 不使用 - {{using_quan[item.pickup_id].money}}元优惠券 + ¥{{using_quan[item.pickup_id].money}}元优惠券 + - {{order.store_prom}} + + + {{order.store_prom}} - - - + + + + + + + + + + + + + + 门店自提 - - - 快递邮寄 + + + + + + + + + + + 快递邮寄 + + + + + {{wu_arr[item.wind].name}} + + - - - 用户备注(50字) + + + + 留言 - - {{maxWord}}/50 + + + + - - - 使用余额 :¥{{yuer}} - + + + 使用余额 :¥{{yuer}} + + + 门店:{{bn_pickname}} @@ -113,14 +167,18 @@ {{bn_goods.goods_name}} - - {{bn_goods.goods_spec}}/{{bn_goods.goods_color}} - - - - ¥{{bn_goods.shop_price}} + + + 商品属性: + {{bn_goods.goods_spec}}/{{bn_goods.goods_color}} + + + + {{filters.toFix(bn_goods.shop_price,2)}} x{{bn_goods.buynum}} + + {{order.store_prom}} @@ -130,48 +188,32 @@ wx:if="{{selected_quan_list && selected_quan_list.length>0}}"> - 使用优惠券 + 优惠券 不使用 - {{using_quan[bn_pick].money}}元优惠券 + ¥{{using_quan[bn_pick].money}}元优惠券 - - + + + 自提 - + 物流 + + + {{wu_arr[index].name}} + - - - @@ -179,14 +221,13 @@ 使用余额 :¥{{yuer}} - - - 用户备注(50字) + + 留言 - - {{maxWord}}/50 + + @@ -238,53 +279,192 @@ - 选择优惠券 + 优惠券使用 × + + + 可使用的优惠券 + + 不使用优惠券 + + + Γ + + + + + + + - - - 不使用优惠券 - - - - - - - - - - - - {{item.Sum}}元 - 订单满{{item.BuySum?item.BuySum:0}}元使用 - 使用期限 - - {{filters.replace_time(item.BeginDate)}}至{{filters.replace_time(item.ValidDate)}} - - : 无限制 - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{item.Sum}} - + + + + + 满{{item.BuySum}}元可用 + + 满0元可用 + + + + + + + + + + + + + {{filter.get_type_card(item.UseObjectType)}} + + {{item.Sum}}元优惠券 + + + {{filters.replace_time2(item.BeginDate)}}至{{filters.replace_time2(item.BillDate)}} + + + + + + Γ + + + + + + + + + + + 优惠券使用说明 + + + + + + + + + + + {{util.format(item.Remark)}} + + 仅{{item.UseObjectName}}使用 + 全场通用 + + + + + + + + + + + - 确定 + 确定 + + + + + + + + + + + + + + 选择物流名字 + + + × + + + + + + + Γ + + + + + {{express_list.name}} + + + + + + + 确定 + + + 设为默认 + + + + \ No newline at end of file diff --git a/pages/cart/cart2/cart2.wxss b/pages/cart/cart2/cart2.wxss index f1710ad..4cfebae 100644 --- a/pages/cart/cart2/cart2.wxss +++ b/pages/cart/cart2/cart2.wxss @@ -5,25 +5,26 @@ color: #444; } .user-contact { - padding: 24rpx 80rpx; + padding: 24rpx 70rpx; + font-weight: 600; } - + .location { position: relative; - padding: 0 80rpx 24rpx; + padding: 0 70rpx 24rpx; } .pos-icon { position: absolute; - left: 30rpx; - top: 0; + left: 22rpx; + top: 9rpx; width: 32rpx; - height: 32.5rpx; + height: 37.5rpx; } .border-img { width: 100%; - height: 16rpx; + height: 12rpx; } .update-logistics { @@ -50,23 +51,23 @@ .order-detail { padding: 30rpx 0; - border-bottom: 1px solid #ddd; + border-bottom: 6rpx solid #eee; color: #777; - min-height: 100rpx; + min-height: 190rpx; background-color: #fff; } .goods-img { float: left; - width: 100rpx; - height: 100rpx; + width: 191rpx; + height: 191rpx; margin: 0 20rpx; } .order-cont { float: left; - width: 400rpx; + width: 438rpx; } .goods-name { @@ -75,6 +76,8 @@ overflow: hidden; margin-bottom: 16rpx; font-size: 28rpx; + color: #333; + } .goods-color { @@ -82,29 +85,27 @@ } .order-num { - float: right; + margin-top: 25rpx; font-size: 24rpx; - margin-top: 10rpx; - margin-right: 20rpx; - text-align: right; line-height: 42rpx; } -.set-mes{background-color: #fff; margin-bottom: 20rpx;} +.set-mes{background-color: #fff; } .use-item{ display: flex; align-items: center; - height: 92rpx; + height: 80rpx; border-bottom: 1px solid #ddd; font-size: 30rpx; - padding-left: 20rpx; - + width:95%; +margin:auto; + } .use-item>view{ - display: flex;margin-right: 20rpx; + display: flex;margin-right: 12rpx; } .use-item.bfff{ background-color: #fff;} -.use-item .dp{width: 56rpx; height: 56rpx;} +.use-item .dp{width: 56rpx; height: 56rpx; margin-left: -5rpx} .set-item { justify-content: space-between; @@ -134,11 +135,14 @@ } .coupon-mes { - margin-bottom: 20rpx; + height:95rpx; padding: 0 20rpx; background-color: #fff; font-size: 30rpx; color: #444; + width: 100%; + + } .coupon-title { @@ -165,15 +169,17 @@ .leave-word { position: relative; - margin: 20rpx 0; + font-size: 24rpx; + margin-left: 20rpx; + } .word-box { - border: 1px solid #ddd; - width: 690rpx; + + width: 600rpx; padding: 10rpx; - height: 120rpx; + height: 28rpx; line-height: 40rpx; } @@ -201,7 +207,9 @@ .btn-wrap { height: 100rpx; width: 100%; background-color: #fff; - position: fixed; bottom: 0;left: 0 + position: fixed; bottom: 0;left: 0; + border-top:1rpx solid #dee + } .tips-btn { @@ -269,18 +277,20 @@ .add_new{height: 60rpx; line-height: 60rpx;} .addr_jia{width: 45rpx; height: 45rpx; border: 1rpx solid #ddd; margin-right: 15rpx; margin-left: 20rpx; vertical-align: middle;} -.yu_er{margin-left: 15rpx;} .wuliu{margin-left: 20rpx;} +.yu_er{margin-left: 10rpx;margin-right: 60rpx;} .wuliu{margin-left: 20rpx;} /*---- 优惠券列表 -----*/ .xc-coupon-frame{ width: 100%; height: 92rpx; - border-bottom:1px solid #ddd; + } .xc-coupon-frame .work-frame{ - width: 94%; + width: 100%; height: 100%; + border-bottom:3rpx solid #eee; + } .xc-right{ @@ -290,36 +300,41 @@ border-right:2rpx solid #000; transform:rotate(45deg); display:inline-block; - margin-top:30rpx; + } -.xc-coupon-frame .work-frame .work{ font-size: 30rpx; line-height: 92rpx; color: #d81e06;} +.xc-coupon-frame .work-frame .work{ font-size: 30rpx; line-height: 92rpx; } .xc-right-frame{font-size: 30rpx;line-height: 92rpx; margin-right: 10rpx } /* 自定义弹出窗口 */ .cx-popup{ width:100%; - height: 775rpx; + height:920rpx; background: #fff; z-index: 35; - border-top-left-radius: 10rpx; - border-top-right-radius: 10rpx; + border-top-left-radius: 20rpx; + border-top-right-radius: 20rpx; position:fixed; bottom:0; + padding-bottom: 25rpx; + } .cx-popup .top{ - width:100%; + width:95%; height:100rpx; border-bottom:3rpx solid #ddd; - + margin: auto; + margin-top: 30rpx; } .xc-top-content{ - width: 88%; + width: 93%; height:85rpx; - padding-top: 20rpx; - font-size: 36rpx; + padding-top: 30rpx; + font-size: 34rpx; + font-weight: 600; + } @@ -331,35 +346,29 @@ } .xc-frame{ width: 100%; - height: 465rpx; - margin-top:20rpx; - + height:68.9%; } .xc-frame .list-frame{ - width: 90%; + width: 95%; height: 100%; overflow-y:scroll; } .xc-close-frame{ - margin-top:10rpx; - width:1%; + margin-top:-10rpx; + } .xc-close{ - width: 46rpx; -height: 46rpx; + width: 37rpx; +height: 37rpx; border-radius: 50%; -border: 5rpx solid #a5a5a7; +border: 3rpx solid #333; text-align: center; -line-height: 46rpx; -font-size: 34rpx; -font-weight: bolder; -color: #a5a5a7; -margin-top: 5rpx; - - +line-height: 34rpx; +font-size: 29rpx; +color: #333; } .xc-money{ @@ -422,16 +431,14 @@ margin-top: 5rpx; } .xc-confirm { - width: 90%; - height: 75rpx; + width: 48%; + border-radius: 50rpx; + height: 50rpx; margin:0 auto; - background:#c41830; + background:#d60021; color:#fff; - border-radius:10rpx; - font-size:30rpx; - margin-top: 50rpx; - - + font-size:28rpx; + margin-top: 28rpx; } .up{ animation: up .7s; } @@ -446,3 +453,373 @@ height: 40rpx; } +.xc-close-express{ + width: 40rpx; +height: 40rpx; +border-radius: 50%; +border: 3rpx solid #333; +text-align: center; +font-size:32rpx; +line-height: 38rpx; +color: #333; +margin-top: 5rpx; +} +.cx-popup .tops{ + width: 100%; +height: 145rpx; +border-bottom: 3rpx solid #eee; + +} +.top-content { + width: 82%; +padding-top: 33px; +height: 100%; +padding-left: 40rpx; +} +.close-frame{ + margin-top: 30rpx; + +} +.cx-popup.radius{ + +height: 650rpx; + +} +.xc-hook { +width: 33rpx; +height: 33rpx; +transform: rotate(-135deg); +line-height: 35rpx; +text-align: center; +margin-right: 20rpx + + +} +.xc-hooks { +width: 30rpx; +height: 30rpx; +border: 1rpx solid #999; +margin-right: 20rpx; +} +.express_list_frame{ + display: flex; +height: 80rpx; +align-items: center; +padding-left: 40rpx; +border-bottom: 1rpx solid #eee; + +} +.express_list{ + width: 100%; + height: 65%; + overflow-y: scroll; + overflow: hidden; +} +.xc-confirms { + width: 40%; + border-radius: 50rpx; + height: 55rpx; + margin:0 auto; + font-size:28rpx; + background: #fff; + color: #333; + border: 2rpx solid #333; + +} + + +/* 优惠券的改版样式 */ +.xc-coupon-frame{ + width: 710rpx; + height:auto; + margin: 0 auto; + +} +.xc-coupon-frame .coupon-frame{ + width: 99%; + height: 200rpx; + margin-top:10rpx; + border-bottom: 1rpx solid #eee; + +} +.xc-coupon-frame .coupon-frame .coupon-left{ + width: 215rpx; + height:100%; + overflow: hidden; +} +.xc-money-frames{ + width:96%; + margin-top: -10px; +} + +.xc-rmb-symbol{ + font-size:40rpx; + +} + +.xc-rmb-val{ + font-size:60rpx; + +} +.coupon-explain{ + font-size:25rpx; +width:100%; + + +} +.xc-valuer{ + margin-top:39rpx; + margin-left:28rpx; + font-size:25rpx; +} +.coupon-frame .oval{ + width:155rpx; + height:83rpx; + border-radius: 50%; + right:-78rpx; + top:-37rpx; +} +.coupon-right{ + width:490rpx; + height: 99%; + border-top: 1rpx solid #eaeaea; + /* //border-bottom: 1rpx solid #eaeaea; */ + border-right: 1rpx solid #eaeaea; + +} +.coupon-annotation{ + width: 95%; + height: 100%; + +} +.xc-brand{ + width:100rpx; + height:35rpx; + line-height: 35rpx; + font-size:21rpx; + border-radius:10rpx; position: relative; top:-1px; + margin-right: 8rpx +} +.top-frame{ + width:82%; + height: 75rpx; + margin-top:10rpx; +} +.top-frame .coupon-wode{ + font-size: 25rpx; + margin-left:10rpx; + width:340rpx; + height:88rpx; +} +.coupon-code{ + width:60rpx; + height:60rpx; + margin-top:5rpx; + +} +.frame{ + width: 100% +} +.coupon-time{ + font-size: 23rpx; + line-height:33rpx; + color: #333; +} + +.clik-get{ + width:125rpx; + height:45rpx; + border-radius: 25rpx; + line-height: 45rpx; + font-size:25rpx; + bottom:67rpx; + right:6px; +} + +.code-img{ + margin-left:20rpx; +} +.bottmo-explain{ +top:145rpx; +width:94%; +border-top:1rpx dashed #eee; +padding-top:8rpx; +height:38rpx; +line-height: 51rpx; + +} +.font-word{ + font-size: 22rpx; +} +.circle-size{ + background: #a0a0a0; + width: 27rpx; + height: 27rpx; + margin-top:13rpx; +margin-left:8rpx; +display: flex; + +align-items: center; +} +.xc-jiantou{ + /* width: 9rpx; + height: 9rpx; */ + /* border-top: 2rpx solid #fff; + border-right: 2rpx solid #fff; */ + transform: rotate(-90deg); + color: #fff; + font-size: 15rpx; + /* display:inline-block; + margin-top: 6.5rpx; */ + text-align: center; +width: 24rpx; +} +.xc-buttom{ + width:99%; +min-height:76rpx; +height:auto; +line-height:40rpx; +border-left:1rpx solid #eee; +border-right:1rpx solid #eee; +border-bottom:1rpx solid #eee; +margin-left: 6rpx; + +} + +.goods-num{ + font-size: 28rpx; + color: #333; +} + +.explain-coupon{ + font-size:25rpx; + padding: 10rpx 10rpx +} +.circle-frame{ + width: 20rpx; + height: auto; + z-index:1; + left:210rpx; + +} +.circle-sawtooth{ + width: 11rpx; + height: 11rpx; + background: #fff; +} + +.red{background-color: #fe7496;} +.green{ background-color: #22c7c1;} +.blue{background-color:#5e82e3;} +.g_gray{background-color: #aaaaaa} + +.f_text{text-align: center; height:96rpx; } +.xc-hook.sn { + margin-top:12%; +width:45rpx; +height:45rpx; +font-size:28rpx; +line-height:44rpx; + + +} +.xc-hooks.on{ + margin-top:12%; +width:42rpx; +height:42rpx; +} +.may_use_coupon{ + width: 95%; + height: 68rpx; + line-height:78rpx; + margin: auto; +} +.determine-frame{ + width: 100%; + height: 130rpx; + +} +.xc-determine{ + height: 55rpx; + width: 40%; + border-radius: 50rpx; +background: #d60021; +color: #fff; +font-size: 28rpx; +margin: 0 auto; + +} +.click-buttem{ +width: 90%; +margin: auto; +} +.logistics-name{ + margin-right:20rpx; +} +.xc-border{ + border-top:8rpx solid #eee; +width: 100% +} +.main-top{ +margin-top: 20rpx; + +} +.xc-hookts{ +border: 1rpx solid #999; + +} +.xc-hookts.on{ + width:30rpx; +height:30rpx; + +} +.xc-hookt.sn{ + width: 32rpx; +height: 32rpx; +font-size: 28rpx; +line-height: 34rpx; +} +.xc-hookt{ + transform: rotate(-135deg); +text-align: center; + +} +.main-bottom{ + margin-bottom: 20rpx; + +} +.xc-hookst{ + border: 1rpx solid #999; + +} +.xc-hookst.ons{ + width: 42rpx; +height: 42rpx; +margin-left: 20rpx; + +} +.is_use_coupon{ + width: 65%; +justify-content: flex-end; +padding-top: 10rpx; + + +} +.xc-hooka{ + transform: rotate(-135deg); +text-align: center; + +} +.xc-hooka.sn{ + width: 45rpx; +height: 45rpx; +font-size: 28rpx; +line-height: 44rpx; +margin-left: 20rpx; + +} +.color-gray{ + color: #808080; +} + +.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx } \ No newline at end of file diff --git a/pages/cart/cart2/filter.wxs b/pages/cart/cart2/filter.wxs new file mode 100644 index 0000000..c0e8d13 --- /dev/null +++ b/pages/cart/cart2/filter.wxs @@ -0,0 +1,11 @@ +var format = function (text) { + if (!text) { + return + } + var reg = getRegExp('\\\\n', 'g') + return text.replace(reg, '\n') +} + +module.exports = { + format: format +} diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 2e733c3..cde3db4 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -2,6 +2,7 @@ var t = getApp(),app=t, a = t.request, e = require("../../../utils/common.js"), s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); var oo=t.globalData.setting; var regeneratorRuntime = require('../../../utils/runtime.js'); +var util_pay = require("../../../utils/pay.js"); Page({ data: { @@ -54,7 +55,8 @@ Page({ is_pt_tz:0,//是否开团团长 qh:'', //期号 pt_listno:'',//期号 - is_normal:0 + is_normal:0, + is_express:0,//选择物流的控制器 }, onLoad: function(t) { console.log("onLoad_pt_cart"); @@ -212,18 +214,21 @@ Page({ //----------子页返回父页触发---------- onShow: function() { - console.log('onshow'); var th=this; - console.log(th.data.isclose); if (th.data.isclose==0){ wx.switchTab({ url: "/pages/index/index/index" }) - }else{ - this.getuser_addr(function(ie){ - th.setData({user_addr: ie }); - }) + this.getuser_addr(function(ie){ + th.setData({user_addr: ie }); + }) + //--更新默认地址--,看一下是不是跳到地址页面 + if(!getApp().globalData.is_cart2_old){ + this.update_code(); + }else{ + getApp().globalData.is_cart2_old=0; + } } }, //---------------检查是否有收货地址------------------- @@ -333,10 +338,8 @@ Page({ }); }); }, - //--------------------提交订单----------------------- submitForm:function(t){ - if(this.data.is_summit_ing==1) return false; //--提交中退出-- this.data.is_summit_ing=1; @@ -457,11 +460,25 @@ Page({ }) //要进行判断,如果是用微信支付,就要跳转到支付界面 if (order_amount > 0) { - th.setData({ isclose: 0 }); - void e.jumpToCart4({ - order_sn: data.data, - type:1, - }, 1); + th.setData({ isclose: 0 }); + //void e.jumpToCart4({ + // order_sn: data.data, + // type:1, + // }, 1); + util_pay.pay(data.data, function() { + setTimeout(function () { + wx.navigateTo({ + url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, + }) + },1000) + }, function () { + //支付失败 + setTimeout(function () { + wx.navigateBack({ delta: 1 }) + },1000) + + },oo.stoid,1); + } else { var dd = { parent_sn: data.data, @@ -478,9 +495,12 @@ Page({ th.setData({ isclose: 0 }); if(th.data.is_normal==1){ + /*-- wx.navigateTo({ url: "/pages/user/order_list/order_list", - }) + })--*/ + var url="/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data; + getApp().goto(url); }else{ wx.navigateTo({ url: "/pages/team/team_success/team_success?ordersn=" + data.data, @@ -521,8 +541,9 @@ Page({ }); }, enterAddressPage: function() { + getApp().globalData.is_cart_old=1; this.data.enterAddressPage = !0, wx.navigateTo({ - url: "/pages/user/address_list/address_list?operate=select" + url: "/pages/user/address_list/address_list" }); }, @@ -646,6 +667,65 @@ Page({ var ob = {}; ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; this.setData(ob); - } + }, + + //// 开启物流的弹窗 + show_wu_arr:function(e){ + this.setData({ open_express: 1}); + }, + + //更新下默认,在onshow里面 + update_code(){ + var th=this,m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code; + + var uii=setInterval(function () { + if(th.data.wu_arr){ + clearInterval(uii); + for (var k = 0; k < th.data.wu_arr.length; k++) { + var item = th.data.wu_arr[k]; + if (def_exp_code == item.code) { + m_wind = k; + } + } + //--如果是立即购买-- + th.setData({ index: m_wind, is_express: m_wind}); + } + },500) + }, + + // 关闭物流的弹窗 + close_express:function(){ + this.setData({ open_express:0 }); + }, + // 选择物流 + click_express_name:function(e){ + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; + var index=e.currentTarget.dataset.idxe; + var ob={ is_express: index, is_shipping_code: shippingcode,index:index}; + this.setData(ob); + }, + + //点击确定物流 + determine_expres:function(e){ + this.setData({ open_express: 0}); + this.calculatePrice2(); + }, + //设置默认物流 + select_default_logistics: function () { + var th=this; + var is_shipping_code=this.data.is_shipping_code + getApp().request.put("/api/weshop/users/update",{ + data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code}, + success:function(rse){ + if (rse.data.code==0){ + getApp().globalData.userInfo.def_exp_code=is_shipping_code; + th.setData({ open_express: 0 }); + //----计算此时购物车的价格---- + if(th.data.is_b_now==1) th.calculatePrice2(); + else th.calculatePrice(); + } + } + }) + }, }); diff --git a/pages/cart/cart2_pt/cart2_pt.wxml b/pages/cart/cart2_pt/cart2_pt.wxml index ed4506d..488abcb 100644 --- a/pages/cart/cart2_pt/cart2_pt.wxml +++ b/pages/cart/cart2_pt/cart2_pt.wxml @@ -1,14 +1,15 @@ + + + + + + + + + + + 选择物流名字 + + + + × + + + + + + + + Γ + + + + + {{express_list.name}} + + + + + + + 确定 + + + 设为默认 + + + + + diff --git a/pages/cart/cart2_pt/cart2_pt.wxss b/pages/cart/cart2_pt/cart2_pt.wxss index ef34fd0..753ef7b 100644 --- a/pages/cart/cart2_pt/cart2_pt.wxss +++ b/pages/cart/cart2_pt/cart2_pt.wxss @@ -5,20 +5,22 @@ color: #444; } .user-contact { - padding: 24rpx 80rpx; + padding: 24rpx 70rpx; + font-weight: 600; + } .location { position: relative; - padding: 0 80rpx 24rpx; + padding: 0 70rpx 24rpx; } .pos-icon { position: absolute; - left: 30rpx; - top: 0; + left: 22rpx; + top: 20rpx; width: 32rpx; - height: 32.5rpx; + height: 40rpx; } .border-img { @@ -50,17 +52,17 @@ .order-detail { padding: 30rpx 0; - border-bottom: 1px solid #ddd; + border-bottom: 7rpx solid #eee; color: #777; - min-height: 100rpx; + min-height: 190rpx; background-color: #fff; } .goods-img { float: left; - width: 100rpx; - height: 100rpx; + width: 190rpx; + height: 190rpx; margin: 0 20rpx; } @@ -75,6 +77,8 @@ overflow: hidden; margin-bottom: 16rpx; font-size: 28rpx; + color: #333; + } .goods-color { @@ -90,21 +94,21 @@ line-height: 42rpx; } -.set-mes{background-color: #fff; margin-bottom: 20rpx;} +.set-mes{background-color: #fff; } .use-item{ display: flex; align-items: center; height: 92rpx; border-bottom: 1px solid #ddd; font-size: 30rpx; - padding-left: 20rpx; - + width: 95%; + margin: auto; } .use-item>view{ - display: flex;margin-right: 20rpx; + display: flex;margin-right: 10rpx; } .use-item.bfff{ background-color: #fff;} -.use-item .dp{width: 56rpx; height: 56rpx;} +.use-item .dp{width: 56rpx; height: 56rpx; margin-left: -5rpx} .set-item { justify-content: space-between; @@ -134,11 +138,15 @@ } .coupon-mes { - margin-bottom: 20rpx; + height:95rpx; padding: 0 20rpx; background-color: #fff; font-size: 30rpx; color: #444; + width: 100%; + border-bottom: 6rpx solid #eee; + margin-bottom: 20rpx; + } .coupon-title { @@ -165,15 +173,16 @@ .leave-word { position: relative; - margin: 20rpx 0; font-size: 24rpx; + margin-left: 20rpx; + } .word-box { - border: 1px solid #ddd; - width: 690rpx; + + width: 600rpx; padding: 10rpx; - height: 120rpx; + height: 28rpx; line-height: 40rpx; } @@ -269,5 +278,291 @@ .add_new{height: 60rpx; line-height: 60rpx;} .addr_jia{width: 45rpx; height: 45rpx; border: 1rpx solid #ddd; margin-right: 15rpx; margin-left: 20rpx; vertical-align: middle;} -.yu_er{margin-left: 15rpx;} .wuliu{margin-left: 20rpx;} +.yu_er{margin-left: 15rpx;} .wuliu{margin-left: 20rpx;} + + +/* 自定义弹出窗口 */ +.cx-popup{ + width:100%; + height:920rpx; + background: #fff; + z-index: 35; + border-top-left-radius: 20rpx; + border-top-right-radius: 20rpx; + position:fixed; + bottom:0; + padding-bottom: 25rpx; + +} + +.cx-popup .top{ + width:95%; + height:100rpx; + border-bottom:3rpx solid #ddd; + margin: auto; + margin-top: 30rpx; + +} +.xc-top-content{ + width: 93%; + height:85rpx; + padding-top: 30rpx; + font-size: 34rpx; + font-weight: 600; + +} + + +.xc-valid-coupon{ + width: 90%; + height:40rpx; + padding-top: 24rpx; + overflow: hidden; +} +.xc-frame{ + width: 100%; + height:68.9%; +} + +.xc-frame .list-frame{ + width: 95%; + height: 100%; + overflow-y:scroll; + +} +.xc-close-frame{ + margin-top:-10rpx; + +} + +.xc-close{ + width: 37rpx; + height: 37rpx; + border-radius: 50%; + border: 3rpx solid #333; + text-align: center; + line-height: 34rpx; + font-size: 29rpx; + color: #333; + +} +.xc-money{ + color: #af2346; + font-size: 35rpx; +} + +.xc-money-frame{ + margin-left:35rpx; + +} +.xc-coupon-effect{ + width: 99%; + min-height: 100rpx; + border-bottom:3rpx solid #ddd; + + +} +.xc-goods-coupon{ + width: 85%; + height:100%; + +} +.xc-title{ + width:50%; + margin-left:222rpx; + +} +.xc-coupon-money0{ + color: #c91e31; + font-size: 35rpx; + line-height: 40rpx; + +} +.xc-coupon-money{ + color: #c91e31; + font-size: 35rpx; + line-height: 40rpx; + padding-top: 10px; + +} +.xc-coupon-money1{ + color: #444; + font-size: 28rpx; + line-height: 60rpx; + + +} +.xc-coupon-time{ + height: 50rpx; + font-size: 27rpx; + color: #a4a4a4; +} +.xc-coupon-time .time{ + margin-left: 15rpx; + font-size: 27rpx; +} +.xc-coupon-selection{ + height:100%; +} + +.xc-confirm { + width: 48%; + border-radius: 50rpx; + height: 50rpx; + margin:0 auto; + background:#d60021; + color:#fff; + font-size:28rpx; + margin-top: 28rpx; +} + +.up{ animation: up .7s; } +.down{ animation: down 1s; } +@keyframes up { 0% { transform: translateY(550rpx); } 100% { transform: translateY(0); } } +@keyframes down { 0% { transform: translateY(0); } 100% { transform: translateY(550rpx); } } + +.xc-not-Selection{ + width: 40rpx; + height: 40rpx; + background: #eeeeee; +} + + +.xc-close-express{ + width: 40rpx; + height: 40rpx; + border-radius: 50%; + border: 3rpx solid #333; + text-align: center; + font-size:32rpx; + line-height: 38rpx; + color: #333; + margin-top: 5rpx; +} +.cx-popup .tops{ + width: 100%; + height: 145rpx; + border-bottom: 3rpx solid #eee; + +} +.top-content { + width: 82%; + padding-top: 33px; + height: 100%; + padding-left: 40rpx; +} +.close-frame{ + margin-top: 30rpx; + +} +.cx-popup.radius{ + + height: 650rpx; + +} +.xc-hook { + width: 33rpx; + height: 33rpx; + transform: rotate(-135deg); + line-height: 35rpx; + text-align: center; + margin-right: 20rpx + + +} +.xc-hooks { + width: 30rpx; + height: 30rpx; + border: 1rpx solid #999; + margin-right: 20rpx; +} +.express_list_frame{ + display: flex; + height: 80rpx; + align-items: center; + padding-left: 40rpx; + border-bottom: 1rpx solid #eee; + +} +.express_list{ + width: 100%; + height: 65%; + overflow-y: scroll; + overflow: hidden; +} +.xc-confirms { + width: 40%; + border-radius: 50rpx; + height: 55rpx; + margin:0 auto; + font-size:28rpx; + background: #fff; + color: #333; + border: 2rpx solid #333; + +} + +.xc-right{ + width:20rpx; + height:20rpx; + border-top:2rpx solid #000; + border-right:2rpx solid #000; + transform:rotate(45deg); + display:inline-block; + margin-right: 5rpx; + margin-left: 10rpx; + +} + + +.xc-left{ + margin-left: 45rpx; +} +.xc-border{ + border-top:8rpx solid #eee; +width: 100% +} +.main-top{ +margin-top: 20rpx; + +} +.order-num { + margin-top: 25rpx; + font-size: 24rpx; + line-height: 42rpx; + width: 95%; + +} +.goods-num{ + font-size: 28rpx; +color: #333; + +} +.click-buttem{ +width: 90%; +margin: auto; +} +.xc-determine{ + height: 55rpx; + width: 40%; + border-radius: 50rpx; +background: #d60021; +color: #fff; +font-size: 28rpx; +margin: 0 auto; + +} +.xc-hookts{ +border: 1rpx solid #999; + +} +.xc-hookts.on{ + width:30rpx; +height:30rpx; + +} +.color-gray{ + color: #808080; +} +.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx } \ No newline at end of file diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 355498f..c4302ed 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -541,7 +541,7 @@ Page({ //------支付成功页面-------- jumpPaymentPage: function(order_sn,order_amount) { wx.setStorageSync("order:order_list:update", !0), wx.redirectTo({ - url: "/pages/payment/payment/payment?order_sn=" + order_sn + "&order_amount=" + order_amount + url: "/pages/payment/pay_success/pay_success?order_sn=" + order_sn + "&type=1", }); }, diff --git a/pages/goods/categoryList/categoryList.js b/pages/goods/categoryList/categoryList.js index 4b20b70..89c9478 100644 --- a/pages/goods/categoryList/categoryList.js +++ b/pages/goods/categoryList/categoryList.js @@ -22,14 +22,31 @@ Page({ // 导航字母 letters: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], - + //控制新旧分类版本 + is_used_share:0, + //国家的控制属性 + is_country:1, + //品牌的控制属性 + is_brand:1, + //选择分类的控制属性 + select_classify_on:223, + index:223, + classify_name:"国家",//项目类型 + brand_list:null,//品牌列表 + + one_level_classify:[],// 新的版本左边的边分类1级 + is_level_three:0,//判断有没有3级 + cat_id:0, + pl_timer: null,//只有品类的定时器 + is_pl_time:0, + }, onLoad: function(tt) { const res = wx.getSystemInfoSync(), letters = this.data.letters; var that = this; - this.requestFirstCategoris(); + this.setData({ abc: t.globalData.heigth-88-88-16, windowHeight: res.windowHeight, @@ -55,25 +72,69 @@ Page({ } this.setData({ lettersPosition: temp - }) - + }); + + if (this.data.is_used_share==0){ + this.get_nation(); + } }, onShow:function(){ var that=this; - + //this.requestFirstCategoris(); + if(getApp().globalData.user_id) getApp().requestCardNum(); getApp().getConfig2(function (e) { + + var data=e; + var switch_list_data = data.switch_list; + var switch_list = JSON.parse(switch_list_data); + var is_newsgoodstype = switch_list.is_newsgoodstype; + that.setData({ is_used_share :is_newsgoodstype}); if (e.categoryset.indexOf("," + 1 + ",") != -1) { that.setData({ is_show_pl: 1 }); } if (e.categoryset.indexOf("," + 3 + ",") != -1) { that.setData({ is_show_pp: 1 }); } if (e.categoryset.indexOf("," + 2 + ",") != -1) { that.setData({ is_show_gb: 1 }); } that.setData({ store_config: e,is_do:1 }); + //---有勾品类--- + if (that.data.is_show_pl){ + that.requestFirstCategoris(); + } + if (that.data.is_show_gb != 1 && that.data.is_show_pp != 1 && that.data.is_show_pl){ + that.data.pl_timer = setInterval(function () { + if (that.data.one_level_classify.length>0){ + var item=that.data.one_level_classify[0],arr=item.array; + //----如果有下级的时候----- + if(item.array && item.array.length>0){ + var is_lev_thr=0 + for(var i=0;i0) {is_lev_thr=1;break; } + } + that.setData({ is_level_three: is_lev_thr }); + if (is_lev_thr!=1) { + that.setData({ select_classify_on: 0, index: 0, classify_name: item.items.name, goodslist: item.array }); + } else { + that.setData({ select_classify_on: 0, index: 0, goodslist: arr }); + } + } + else{ + that.setData({ select_classify_on: 0, index: 0, goodslist: null,classify_name:item.items.name,is_level_three: 0}); + } + clearInterval(that.data.pl_timer); + } + },1000); + + } else if (that.data.is_show_gb != 1 && that.data.is_show_pp ){ + that.setData({ select_classify_on: 220, classify_name: "品牌" }); + } + + + var one_level_classify = that.data.one_level_classify; + if (that.data.is_show_pl) that.setData({ currentTab: 0 }); else if (that.data.is_show_gb){ that.setData({ currentTab: 1 });that.get_nation(); } else if (that.data.is_show_pp) {that.setData({ currentTab: 2 });that.get_brand(); } - //----求传参过来的控制----- if (getApp().globalData.cat_type == 1 && that.data.is_show_gb ) { that.setData({ currentTab: 1 }); @@ -84,12 +145,9 @@ Page({ } else if (that.data.is_show_pl) { that.setData({ currentTab: 0 }); } - }) - }, - //---------------分类请求接口,数据进行拼装------------------ requestFirstCategoris: function() { var t = this; @@ -98,13 +156,17 @@ Page({ success: function(e) { var arr=new Array(); var dda = e.data.data.pageData; - console.log(dda.length); + if (dda != null && dda !=""&&dda!=undefined){ + t.setData({is_pl_time:1}); + } + + if (t.data.is_used_share == 0) {//is_used_share控制新旧版本 for(var i=0;i0){ + + if (parseInt(need_to_insert.parent_id) == parseInt(two_item[pp].items.id)) { + + arr[dd].array[pp].arrays.push(need_to_insert); arr.ishaf_three = 0; break; + } + } + } + } + } + + } + + console.log("现在是1级与2级所有的数据", arr) + t.setData({one_level_classify:arr}); + + } } }); }, @@ -132,6 +238,7 @@ Page({ } }); }, + switchFirstCategory: function(t) { this.requestCategories(t.currentTarget.dataset.id); }, @@ -220,9 +327,10 @@ Page({ //跳转到分类的商品列表 go_cate:function(t){ - var cid= t.currentTarget.dataset.cid; - var pid = t.currentTarget.dataset.pid; - var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; + var cid= t.currentTarget.dataset.cid; + var pid = t.currentTarget.dataset.pid; + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid; + lurl+="&pid="+pid; wx.navigateTo({ url: lurl}); }, @@ -239,10 +347,6 @@ Page({ var lurl = "/pages/goods/goodsList/goodsList?nation_id=" + cid; wx.navigateTo({ url: lurl }); }, - - - - //获取国别 get_nation:function(){ var s = this; @@ -254,10 +358,10 @@ Page({ }, success: function (e) { var dda = e.data.data.pageData; + console.log("国家的数据", dda); s.setData({ nationlist:dda}) } }); - }, //获取品牌 @@ -284,10 +388,11 @@ Page({ success: function (e) { var arr=new Array(); var dda = e.data.data.pageData; + console.log("商品数据",dda); + s.setData({brand_list:dda}); for (var i = 0; i < dda.length; i++) { dda[i].logo = oo.imghost+dda[i].logo; - if (arr.length>0){ var find = 0; //寻找字母在arr数组中是否存在,不存在就要添加,存在就在要这个数组添加元素 @@ -321,7 +426,21 @@ Page({ var _errImg = e.target.dataset.errorimg; var _errObj = {}; _errObj[_errImg] = this.data.iurl+"/miniapp/images/default_g_img.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + //图片失败,默认图片 + bind_bnerr_pp: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = this.data.iurl+"/miniapp/images/no_brand_def.jpg\n"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + //商品图片失败,默认图片 + goods_bnerr: function (e) { + var _errImg = e.target.dataset.err; + var _errObj = {}; + _errObj[_errImg] = this.data.iurl + "/miniapp/images/no_cate_def.png"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; }, goseach:function(){ @@ -339,7 +458,75 @@ Page({ _errObj[_errImg] = "/public/images/category.png"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } + }, + // 新的版本分类点击一级分类 + click_classify:function(e){ + this.data.ishaf_three=0; + var indexs=e.currentTarget.dataset.index; + var name = e.currentTarget.dataset.name; + var cid = e.currentTarget.dataset.cid; + var pid = e.currentTarget.dataset.pid; + var arr = e.currentTarget.dataset.arr; + + if (indexs==220){ this.get_brand();} + if (arr!="undefined" && arr!=undefined){ + if (arr.length==0){ + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, + goodslist: null,is_level_three: 0 }); + return false; + } + if (arr.length != 0){ + var is_lev_thr=0 + for(var i=0;i0) {is_lev_thr=1;break; } + } + this.setData({ is_level_three: is_lev_thr }); + if (this.data.is_level_three!=1) { + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, goodslist: arr }); + } else { + this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr }); + } + } + } + this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid}); + + }, + + + //图片失败 + bind_bnerr_xc: function (e) { + 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) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + //选择更多 + select_more:function(e){ + var cid = e.currentTarget.dataset.cid; + var pid = e.currentTarget.dataset.pid; + console.log("选择更多"+cid); + var lurl = "/pages/goods/goodsList/goodsList?cat_id=" + cid + "&pid=" + pid; + wx.navigateTo({ url: lurl }); + + }, +//扫一扫 + getScancode:function(){ + var _this = this; + // 允许从相机和相册扫码 + wx.scanCode({ + success: (res) => { + var result = res.result; + wx.navigateTo({ + url: "/pages/goods/search/search?s_key="+result, + }); + } + }) + }, + onUnload: function () { + this.destroyActivityTimer(); + }, }); \ No newline at end of file diff --git a/pages/goods/categoryList/categoryList.wxml b/pages/goods/categoryList/categoryList.wxml index 49b6bbf..5f55063 100644 --- a/pages/goods/categoryList/categoryList.wxml +++ b/pages/goods/categoryList/categoryList.wxml @@ -1,5 +1,5 @@ - - + + 分类 @@ -7,10 +7,9 @@ data-current="1" bindtap="clickTab">国家 品牌 - + - - + @@ -18,17 +17,15 @@ - - + - - + {{fitem.items.name}} @@ -36,9 +33,7 @@ bindtap="go_cate" data-cid="{{item.id}}" data-pid="{{item.parent_id}}">{{item.name}} - - - + @@ -51,7 +46,7 @@ {{bitem.name}} - enname + {{bitem.enname}} @@ -67,8 +62,9 @@ - + @@ -89,11 +85,181 @@ 去逛逛 - - + 商家暂未设置分类 去逛逛 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{ishaf_three==1?good_list.name:classify_name}} + + + + + + + + {{bitem.name}} + + + {{bitem.enname}} + + + + + + + + + + + + {{classify_name}} + + + + + + + + + + + {{user.name}} + + + + + + + + + + + + + {{classify_name}} + + 更多 + + + + + + + + + + {{goods.items.name}} + + + + + 该类别无子级 + + + + + + + + + + + + + {{goods.items.name}} + + 更多 + + + + + + + + + {{item.name}} + + + + + + + + + + + + + + + + 商家暂未设置分类 + 去逛逛 + + + + \ No newline at end of file diff --git a/pages/goods/categoryList/categoryList.wxss b/pages/goods/categoryList/categoryList.wxss index a9d23f1..86708c4 100644 --- a/pages/goods/categoryList/categoryList.wxss +++ b/pages/goods/categoryList/categoryList.wxss @@ -10,6 +10,7 @@ page{height: 100%; background: #fff;} flex-flow: row; justify-content: center; margin-left: 15%; + } .swiper-tab-item{ width: 30%; @@ -51,7 +52,7 @@ swiper{ border-radius: 29rpx; background-color: #fff; position: relative; - top:15rpx; + top: 15rpx; } .search-img { @@ -151,4 +152,238 @@ swiper{ .user-name { padding-left: 30rpx; } -.fenlei-list{z-index: -1;} \ No newline at end of file +.fenlei-list{z-index: -1;} + + + + + +/* 商品分类新的版本 */ +/* 分享样式*/ +.xc-search-box { + width: 100%; + height: 120rpx; + z-index: 10; + background: #fff; + border-top: 4rpx solid #eee; + border-bottom: 1rpx solid #eee; + +} + +.share-height{ + line-height: 20rpx; +margin-right: 15rpx; +margin-top: 8rpx; + +} +.scanning_black-img{ + width:50rpx; + height: 45rpx; + margin-bottom: 5rpx; + +} +.search-img.left{ + margin-left: 35rpx; +} + +.xc-search-inner { + display: flex; + align-items: center; + + width: 600rpx; + height: 58rpx; + border-radius: 29rpx; + background-color: #f2f2f2; +} +.project_height{ + height: 90%; + +} +.project_type{ + width: 33%; + height: 100%; + border-right: 1rpx solid #eee; + white-space: nowrap; +overflow: hidden; +overflow-y: scroll; + +} +.share_type{ + margin: auto; + width: 58%; + margin-top: 40rpx; +overflow: hidden; + +} +.xc-letter-spacing{ +padding-left: 29rpx; +padding-right: 29rpx; +width: 51%; +margin: auto; +margin-top: 40rpx; + + +} +.world_sn{ +white-space: nowrap; +overflow: hidden; +width: 58%; +/* letter-spacing: 60rpx; */ +margin: auto; +margin-top: 35rpx; +} +.select_classify{ + background: #d60021; +border-radius: 30rpx; +color: #fff; +height: 48rpx; +line-height: 45rpx; + +} +.select_classify.width80{ + width: 74.5%; +} + .select_classify.width80.text-indent{ + text-indent: 38rpx; + padding-right: 20px; +width: 60%; + + } + .classify_name{ + width: 90%; + margin: auto; + height: 70rpx; + border-bottom: 1rpx solid #eee; + line-height: 85rpx; + font-weight: 600; + + + } + .classify_content{ + width: 67% + + } + .classify_content-frame{ + width: 90%; + margin: auto; + flex-wrap:wrap; + max-height: 90%; + overflow-y:scroll; + overflow: hidden scroll; + padding-bottom: 25rpx; + + + } + .country_img-frame{ + width: 48%; + height: 140rpx; + + } + .country_img{ + width: 100%; + height: 100%; + } + .outer_location{ + top:0rpx; + left: 0rpx; + margin-top: 20rpx; + + } + .nation_box.box{ + top: 16%; +width:80%; +height:70%; +left: 70.5%; +overflow: hidden; + + } + .nt_1.line-height{ + line-height: 65rpx; + height: 72rpx; +margin-top: -5rpx; + + } + .nt_1_t.height{ + height: 54rpx; + } + .nt_1.height{ + height: 56rpx; +line-height: 65rpx; + } + .nt_2.line-height{ + height: 0rpx; + line-height: 0rpx; + + } + .nt_1_t.fs24{ + font-size: 24rpx; + } + .nt_2.fs24{ + font-size: 24rpx; + } + .brand_img_frame{ + width: 45%; + margin-top: 18rpx; + margin-right: 15rpx; + height: 160rpx; + } + .brand_img{ + width:200rpx; + height:86rpx; + margin-bottom: 10rpx; + margin-top: 10rpx; + + } + .type_img_frame{ + width: 30%; + height: 140rpx; + margin-top: 18rpx; + margin-right: 15rpx; + + + } + + + + .type_img{ + width:80rpx; + height:80rpx; + margin-bottom: 10rpx; + margin-top: 10rpx; + + } + .brand_img-name{ + width: 100%; + height: 80rpx; + } + .select_classify.width80.text3{ +padding-right: 20rpx; +padding-left: 20rpx; +width: 62%; + + } + .width_height{ + width: 13rpx; + height: 13rpx; + margin-top:12rpx; + } + .select_more{ +line-height: 37rpx; +height: 35rpx; +margin-top: 24rpx; + } + .divider_line{ + width: 100%; + border-bottom: 6rpx solid #eee; + } + .sort-name{ + width: 132rpx; +overflow: hidden; +margin: auto; + +} + +.nation_z_name{ max-width: 130rpx} +.nation_y_name{ max-width: 130rpx; color: #888} + +.no_child_lev{width: 100%; text-align: center; color: #adadad; padding-top: 30rpx} \ No newline at end of file diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index b7a0545..ee23483 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -21,10 +21,10 @@ var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ data: { - start_stop:2,//秒杀开始 结束 的控制(1正在进行,2即将开始) - color_type:0,//线条控制 - color_type_one:0, - color_type_two:1, + start_stop: 2, //秒杀开始 结束 的控制(1正在进行,2即将开始) + color_type: 0, //线条控制 + color_type_one: 0, + color_type_two: 1, gid: "", stoid: o.stoid, @@ -50,7 +50,8 @@ Page({ activeCategoryId: 0, supportPageScroll: !1, address: { - address: "", district: 0 + address: "", + district: 0 }, shipping: "", shippingCost: 0, @@ -75,29 +76,30 @@ Page({ }], activeCategoryId3: 1, categories3: [{ - name: "全部", - id: 1, - num: 0 - }, - { + name: "全部", + id: 1, + num: 0 + }, + { name: "有图", id: 5, num: 0 }, { - name: "好评", - id: 2, - num: 0 - }, { - name: "中评", - id: 3, - num: 0 - }, { - name: "差评", - id: 4, - num: 0 - }, ], + name: "好评", + id: 2, + num: 0 + }, { + name: "中评", + id: 3, + num: 0 + }, { + name: "差评", + id: 4, + num: 0 + }, + ], select: { price: 0, @@ -119,7 +121,12 @@ Page({ is_show_sto_cat: 1, //是否显示门店分类 only_pk: null, all_sto: null, - sec_sto: null, + sec_sto: null, //选择了的门店分类 + pickpu_list: null, //读出的所有门店list + def_pickpu_list: null, //一开始5个门店list + sec_pick_index: 0, //第二级门店选择ID + fir_pick_index: 0, //第一级门店选择ID + //同一条形码的所有商品 sku_g: null, sku_g_pt: null, //---拼单的普通购买--- @@ -142,17 +149,17 @@ Page({ prom_start_time: null, prom_act: null, pd_xx: 0, - is_normal: 0, //是否普通购买 - teamgroup:null, //有多少人开团 - grounp_tatal:0, //有几个人开团 - timer:[], + is_normal: 0, //是否普通购买 + teamgroup: null, //有多少人开团 + grounp_tatal: 0, //有几个人开团 + timer: [], //商品的购买次数 prom_buy_num: -1, g_buy_num: null, - prom_goods_num:0, //活动商品数量 - prom_buy_num:0, //活动商品购买数量 - prom_redis_num:0, //活动商品redis数量 + prom_goods_num: 0, //活动商品数量 + prom_buy_num: 0, //活动商品购买数量 + prom_redis_num: 0, //活动商品redis数量 //拼单的规则显示 is_show_gz: 0, @@ -164,99 +171,168 @@ Page({ openSpecModal_ind: 0, //---计时器开关---- - is_timer:1, - isshow:0, - bconfig:null, //基础配置 + is_timer: 1, + isshow: 0, + bconfig: null, //基础配置 - fir_comments:null, //详情页上的评价 - fir_quan:null, //详情页上的券 - quan_list:null, //券列表 + fir_comments: null, //详情页上的评价 + fir_quan: null, //详情页上的券 + quan_list: null, //券列表 - coupon:0, + coupon: 0, //会员分享的头像 - share_head:"", - share_goods_img:"", + share_head: "", + share_goods_img: "", //----------视频图片data参数--------- - current: 0,//图片计数 - swiperCurrent:0,//轮播的下标 - hiddenn:0,//控制轮播计数显示 + current: 0, //图片计数 + swiperCurrent: 0, //轮播的下标 + hiddenn: 0, //控制轮播计数显示 - currentTab: 0,// 选择器控制参数 + currentTab: 0, // 选择器控制参数 mapurl: "", - mapurl_f_img:"", - videopicture: 0,//视频图片的控制 + mapurl_f_img: "", + videopicture: 0, //视频图片的控制 - video: 0,//视频图片切换器 + video: 0, //视频图片切换器 index: 0, - noon: 0,//开始视频的隐藏 + noon: 0, //开始视频的隐藏 - screenWidth:0, - canvasHidden:1, + screenWidth: 0, + canvasHidden: 1, //--推荐-- - recommend_list:[], - store_config:null, - is_show_pl:0, //是否品类 - is_show_pp:0, //是否品牌 - is_show_gb:0, //是否国别 - is_closecoupon:0, + recommend_list: [], + store_config: null, + is_show_pl: 0, //是否品类 + is_show_pp: 0, //是否品牌 + is_show_gb: 0, //是否国别 + is_closecoupon: 0, //是否点赞中 iszaning: 0, + + select_store: 0, //选择更多 + index: 1, + more_store: 0, //选择门店 + sort_store: 0, //门店分类 + choice_sort_store: 0, //选择分类门店 + new_user: 0, //新用户 + + def_pick_store: null, // 默认的门店 + lat: null, //维度 + lon: null, //经度 + + is_get_local_ok: 0, //获取坐标是否完成 + region_name: "门店分类", //区域的名字 + is_gps: 1, + open_ind_store: 0, //哪里打开的门店列表的控制属性 + default_store: {}, //创建添加默认门店地址的对象 + + comments_no_more:0, + get_c:0, //获取评价是不是成 + is_collect_load:0, //是不是处理 }, //------初始化加载---------- onLoad: function(t) { - wx.setNavigationBarTitle({ title: "商品详情",}) - var ee = this, that=ee,th=ee, + wx.setNavigationBarTitle({ + title: "商品详情", + }) + var ee = this, + that = ee, + th = ee, gid = t.goods_id; - //如果tg_id是空的话,分享回来 + //---获取手机地址坐标-- + //--如果tg_id是空的话,分享回来-- if (gid == undefined || gid == null || gid == "") { gid = decodeURIComponent(t.scene); } - ee.setData({ gid: gid }); - getApp().getConfig2(function (e) { - if (e.categoryset.indexOf("," + 1 + ",") != -1) { ee.setData({ is_show_pl: 1 }); } - if (e.categoryset.indexOf("," + 3 + ",") != -1) { ee.setData({ is_show_pp: 1 }); } - if (e.categoryset.indexOf("," + 2 + ",") != -1) { ee.setData({ is_show_gb: 1 }); } - - var json_d = JSON.parse(e.switch_list); - ee.setData({ store_config: e, is_closecoupon: json_d.is_closecoupon }); - ee.init(gid); - //------几人评价------- - n.init(th, "", "comments"); - th.requestCardNum(), wx.pageScrollTo && th.setData({ - supportPageScroll: !0 + //----获取系统参数----- + getApp().getConfig2(function(e) { + ee.setData({ + bconfig: e + }); + + if (e.categoryset.indexOf("," + 1 + ",") != -1) { + ee.setData({ + is_show_pl: 1 + }); + } + if (e.categoryset.indexOf("," + 3 + ",") != -1) { + ee.setData({ + is_show_pp: 1 }); + } + if (e.categoryset.indexOf("," + 2 + ",") != -1) { + ee.setData({ + is_show_gb: 1 + }); + } - }) + var json_d = JSON.parse(e.switch_list); + ee.setData({ + store_config: e, + is_closecoupon: json_d.is_closecoupon + }); + ee.init(gid); + //------几人评价------- + //n.init(th, "", "comments"); + + th.requestCardNum(), wx.pageScrollTo && th.setData({ + supportPageScroll: !0 + }); + }); //获取用户设备信息,屏幕宽度 wx.getSystemInfo({ success: res => { - that.setData({ screenWidth: res.screenWidth }) + that.setData({ + screenWidth: res.screenWidth + }) } - }) + }); + + //获取用户的默认门店 + getApp().get_user_store(function(e) { + var w_time = setInterval(function() { + if (that.data.is_get_local_ok == 0) return false; + var distance = null; + if (that.data.lat != null && e.distance == undefined) { + //distance=Math.sqrt((e.lat-th.data.lat)*(e.lat-th.data.lat)+(e.lon-th.data.lon)* (e.lon-th.data.lon)); + var distance = ut.getDistance(e.lat, th.data.lat, e.lon, th.data.lon); + e.distance = distance; + } + if (e) that.setData({ + def_pick_store: e, + sto_sele_name: e.pickup_name, + sto_sele_id: e.pickup_id, + sto_sele_distr: e.distr_type + }) + clearInterval(w_time); + }, 500) + }); + }, //------------程序初始化入口------------- async init(gid) { - var ee = this,th=ee, + var ee = this, + th = ee, gallery = null, is_collect = 0, collect_id = 0, categories3 = ee.data.categories3, - fir_com=null, - fir_quan=null, - mapurl=null, - mapurl_f_img=null; + fir_com = null, + fir_quan = null, + mapurl = null, + mapurl_f_img = null; //------图片滚动---------- @@ -335,42 +411,43 @@ Page({ goods_id: gid, pageSize: 3, parent_id: 0, - page:1 + page:1, + is_show:1, }, }).then(res => { - fir_com=res.data.data.pageData; + fir_com = res.data.data.pageData; }) - if(fir_com){ - for(var ind in fir_com){ - if(fir_com[ind].head_pic=="") fir_com[ind].head_pic= ee.data.iurl+"/miniapp/images/hui_hear_pic.png"; - if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); - } + if (fir_com) { + for (var ind in fir_com) { + if (fir_com[ind].head_pic == "") fir_com[ind].head_pic = ee.data.iurl + "/miniapp/images/hui_hear_pic.png"; + if (fir_com[ind].img) fir_com[ind].img = ut.unserialize(fir_com[ind].img); + if (fir_com[ind].weapp_img) fir_com[ind].weapp_img = JSON.parse(fir_com[ind].weapp_img); + } } - if (th.data.is_closecoupon!=1){ + if (th.data.is_closecoupon != 1) { //----获取详情页的券的数量---- await getApp().request.promiseGet("/api/weshop/prom/coupon/page", { data: { store_id: os.stoid, - type:1, + type: 1, pageSize: 3, - page:1, + page: 1, }, }).then(res1 => { - fir_quan=res1.data.data.pageData; + fir_quan = res1.data.data.pageData; }) } - //--------获取视频图片--------- - await getApp().request.promiseGet("/api/weshop/goodsVideos/get/"+os.stoid+"/"+ee.data.gid, { - 1:1 + await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, { + 1: 1 }).then(res1 => { - if(res1.data.code==0){ - mapurl=res1.data.data.video_url; - mapurl_f_img=res1.data.data.video_img; - } + if (res1.data.code == 0) { + mapurl = res1.data.data.video_url; + mapurl_f_img = res1.data.data.video_img; + } }) ee.setData({ @@ -378,19 +455,12 @@ Page({ is_collect: is_collect, collect_id: collect_id, categories3: categories3, - fir_quan:fir_quan, - fir_comments:fir_com, - mapurl_f_img:mapurl_f_img, - mapurl:mapurl, + fir_quan: fir_quan, + fir_comments: fir_com, + mapurl_f_img: mapurl_f_img, + mapurl: mapurl, }); - //获取系统参数 - getApp().getConfig2(function (conf) { - ee.setData({ - bconfig:conf, - }) - }); - ee.requestRecommend(); }, @@ -398,8 +468,13 @@ Page({ //---展示--- onShow: function() { - this.data.is_timer=1; - var ee = this,gid = this.data.gid,i=getApp().request; + this.data.is_timer = 1; + var ee = this, + gid = this.data.gid, + i = getApp().request; + + this.wait_for_store_config(); + i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { failRollback: !0, success: function(t) { @@ -445,7 +520,7 @@ Page({ if (t.data.data.original_img.indexOf(o.imghost) == -1) t.data.data.original_img = o.imghost + t.data.data.original_img; - if(t.data.data.goods_content==null) t.data.data.goods_content=""; + if (t.data.data.goods_content == null) t.data.data.goods_content = ""; //-----商品详情--- a.wxParse("content", "html", t.data.data.goods_content, ee, 6); @@ -474,12 +549,14 @@ Page({ t.data.data.gg = gg; var uu = []; uu.push(t.data.data); - ee.setData({ sku_g: uu,}); + ee.setData({ + sku_g: uu, + }); } ee.data.g_buy_num = new Map(); ee.check_prom(gid, ee.data.data.prom_type, ee.data.data.prom_id); - var th=ee; + var th = ee; if (ee.data.cat_name == '') { //过去国别,分类,品牌的名称 i.get("/api/weshop/goodscategory/get/" + o.stoid + "/" + th.data.data.cat_id, { @@ -521,6 +598,8 @@ Page({ }); this.data.enterAddressPage && (this.data.enterAddressPage = !1); + + }, enterAddress: function() { this.data.enterAddressPage = !0, wx.navigateTo({ @@ -528,8 +607,8 @@ Page({ }); }, onUnload: function() {}, - onHide:function(){ - this.data.is_timer=0; + onHide: function() { + this.data.is_timer = 0; }, //----------三个选项按钮----------- tabClick: function(t) { @@ -550,9 +629,9 @@ Page({ e.data.c_curr_p = 1; this.setData({ activeCategoryId3: t.currentTarget.id, - comments: null + comments: null,comments_no_more:0,get_c:0, }); - this.requestComments(); + this.requestComments_new(); } }, @@ -564,13 +643,14 @@ Page({ tabComment: function() { this.setData({ - activeCategoryId: 2 - }), this.data.comments || this.requestComments(); + activeCategoryId: 2,comments_no_more:0,get_c:0 + }), this.data.comments || this.requestComments_new(); }, //商品详情的时候调用 tabGoodsContent: function() { - var th = this,i=getApp().request; + var th = this, + i = getApp().request; this.setData({ activeCategoryId: 1 }); @@ -613,14 +693,16 @@ Page({ }, //获取redis中的数量 - async getactLen(func){ - var r_num=0,prom_type=this.data.prom_type,prom_id=this.data.prom_id; - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { + async getactLen(func) { + var r_num = 0, + prom_type = this.data.prom_type, + prom_id = this.data.prom_id; + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { 1: 1 }).then(res => { var em = res; if (em.data.code == 0) { - r_num=em.data.data; + r_num = em.data.data; } }) func(r_num); @@ -628,29 +710,36 @@ Page({ //------------加入购物车-------------- addCart: function(t) { - var th=this; + var th = this; + var ind = t.currentTarget.dataset.openSpecModal_ind; + th.setData({ + open_ind_store: ind + }); //如果是秒杀的话,要看redis够不够 - if(this.data.prom_type==1){ - this.getactLen(function (num) { - if(num o.store_count) return s.my_warnning("超出商品库存",0,th); + 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); if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) this.setData({ sto_sele_name: "" }); - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店",0,th); + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); //--------------此时操作的数据------------ var newd = { @@ -701,8 +790,8 @@ Page({ //-----如果是秒杀,团购,积分购,拼团----- if (th.data.prom_type == 1) { newd.goods_price = th.data.prom_price; - newd.member_goods_price= th.data.prom_price, - newd.prom_type = th.data.prom_type; + newd.member_goods_price = th.data.prom_price, + newd.prom_type = th.data.prom_type; newd.prom_id = th.data.prom_id; } else if (th.data.prom_type == 3) { newd.prom_type = 0; @@ -723,43 +812,34 @@ Page({ //-------如果购物车中有相关的数据--------- if (re.data.data.total > 0) { var item = re.data.data.pageData[0]; - - var updata = { id: item.id, goods_num: e.data.goodsInputNum + item.goods_num, - goods_price: newd.shop_price, + goods_price: newd.goods_price, + store_id: th.data.stoid, }; i.put("/api/weshop/cart/update", { data: updata, success: function(t) { - wx.showModal({ - title: "添加成功!", - cancelText: "去购物车", - confirmText: "再逛逛", - success: function(t) { - t.cancel ? wx.switchTab({ - url: "/pages/cart/cart/cart" - }) : e.requestCardNum(); - } + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num }); + th.closeSpecModal(); } }); } else { i.post("/api/weshop/cart/save", { data: newd, success: function(t) { - wx.showModal({ - title: "添加成功!", - cancelText: "去购物车", - confirmText: "再逛逛", - success: function(t) { - t.cancel ? wx.switchTab({ - url: "/pages/cart/cart/cart" - }) : e.requestCardNum(); - } + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num }); + th.closeSpecModal(); } }); } @@ -797,7 +877,7 @@ Page({ // action: "buy_now" // }), s.set_b_now(e); - wx.navigateTo({ + wx.redirectTo({ url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id, }); }, @@ -815,11 +895,10 @@ Page({ this.checkCartNum(Number(t.detail.value)); }, - //------检查数量是不是超出限购------ checkCartNum: function(t) { var th = this; - this.get_buy_num(this.data.sele_g,async function() { + this.get_buy_num(this.data.sele_g, async function() { //--判断商品是否超出限购-- if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { @@ -833,7 +912,7 @@ Page({ //--判断商品是否超出活动限购-- if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) { - if (t + th.data.prom_buy_num >th.data.prom_buy_limit) { + if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { wx.showModal({ title: '超出商品活动限购', }); @@ -841,20 +920,22 @@ Page({ } } - if(th.data.sele_g.prom_type==1 || th.data.sele_g.prom_type==6 ){ - var redis_num=0; - //------判断活动是否抢光----- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" - + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { - 1:1 + if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { + var redis_num = 0; + //------判断活动是否抢光----- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { + 1: 1 }).then(res => { - redis_num=res.data.data; - }); + redis_num = res.data.data; + }); - if(t>redis_num){ - wx.showModal({ title: '超出商品活动库存', }); - return false; - } + if (t > redis_num) { + wx.showModal({ + title: '超出商品活动库存', + }); + return false; + } } @@ -866,7 +947,6 @@ Page({ }) }, - closeSpecModal: function() { this.setData({ openSpecModal: !1, @@ -874,10 +954,20 @@ Page({ }); }, openSpecModel: function(t) { + var open_store = t.currentTarget.dataset.ind; + + this.setData({ + store: 0, + choice_sort_store: 0, + sort_store: 0, + open_ind_store: open_store, + }) //--先判断会员状态-- - var user_info=getApp().globalData.userInfo; - if(user_info==null || user_info.mobile==undefined || user_info.mobile=="" || user_info.mobile==null){ - wx.navigateTo({ url: '/pages/getphone/getphone', }) + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/getphone/getphone', + }) return false; } @@ -889,19 +979,26 @@ Page({ }, //---------点击收藏和不收藏------------ collectGoods: function() { - var t = this,i=getApp().request; + var t = this, + i = getApp().request; var user_id = s.globalData.user_id; if (user_id == '') { - getApp().getUserFir(function () {}); + getApp().getUserFir(function() {}); getApp().showWarning("未登录"); return false; } else { + + if(t.data.is_collect_load) return false; + t.data.is_collect_load=1; + if (t.data.is_collect == 1) { //删除收藏 i.delete("/api/weshop/goodscollect/del/" + o.stoid + "/" + t.data.collect_id, { success: function(e) { + t.data.is_collect_load=0; if (e.data.code == 0) { t.setData({ - is_collect: 0,collect_id: 0, + is_collect: 0, + collect_id: 0, }); } } @@ -918,6 +1015,7 @@ Page({ i.post("/api/weshop/goodscollect/save", { //添加收藏 data: d, success: function(e) { + t.data.is_collect_load=0; if (e.data.code == 0) { t.setData({ is_collect: 1, @@ -933,21 +1031,21 @@ Page({ //---------联系客服------------ contactService: function() { s.getConfig(function(t) { - if(t.store_tel==undefined){ - getApp().request.get("/api/weshop/store/get/" + os.stoid,{ - isShowLoading:1, - data:{}, - success:function (rs) { - getApp().globalData.config = rs.data.data; - if(rs.data.data.store_tel==null && rs.data.data.store_tel==undefined ){ - getApp().my_warnning("商家未设置电话",0,th); - return false; - } - s.confirmBox("请联系客服:" + rs.data.data.store_tel); - } - }) - }else{ - s.confirmBox("请联系客服:" + t.store_tel); + if (t.store_tel == undefined) { + getApp().request.get("/api/weshop/store/get/" + os.stoid, { + isShowLoading: 1, + data: {}, + success: function(rs) { + getApp().globalData.config = rs.data.data; + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) { + getApp().my_warnning("商家未设置电话", 0, th); + return false; + } + s.confirmBox("请联系客服:" + rs.data.data.store_tel); + } + }) + } else { + s.confirmBox("请联系客服:" + t.store_tel); } }); }, @@ -970,6 +1068,7 @@ Page({ } }); }, + previewCommentImgs: function(t) { var e = this.data.comments[t.currentTarget.dataset.cidx].img; wx.previewImage({ @@ -977,6 +1076,15 @@ Page({ urls: e }); }, + + previewCommentImgs_w: function(t) { + var e = this.data.comments[t.currentTarget.dataset.cidx].weapp_img; + wx.previewImage({ + current: e[t.currentTarget.dataset.id], + urls: e + }); + }, + previewGoodsCommentImgs: function(t) { var e = this, a = this.data.data.comment[t.currentTarget.dataset.cidx].img; @@ -1025,7 +1133,7 @@ Page({ bind_bnerr: function(e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; - _errObj[_errImg] = this.data.iurl+"/miniapp/images/default_g_img.gif"; + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; }, @@ -1034,7 +1142,7 @@ Page({ var _errImg = e.target.dataset.errorimg; var _errObj = {}; - _errObj[_errImg] = this.data.iurl+"/miniapp/images/hui_hear_pic.png" + _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png" this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; }, @@ -1095,77 +1203,132 @@ Page({ //-----------选择属性的按钮事件---------- sele_spec: function(e) { var gid = e.currentTarget.dataset.gid; - var sku_g=this.data.sku_g; - var item=null; - for(var i in sku_g){ - if(sku_g[i].goods_id==gid){item=sku_g[i]; break} + var sku_g = this.data.sku_g; + var item = null; + for (var i in sku_g) { + if (sku_g[i].goods_id == gid) { + item = sku_g[i]; + break + } } - if(item) this.setData({sele_g:item,gid:gid}); + if (item) this.setData({ + sele_g: item, + gid: gid + }); }, //---------拿出门店分类和门店------------ - async get_sto(e) { - var th = this, dd = null,i=getApp().request; - var g_distr_type = this.data.data.distr_type; - if (g_distr_type != 0) { - dd = { - store_id: o.stoid, - distr_type: g_distr_type, - isstop: 0, - pageSize: 300 + get_sto(e) { + var th = this; + var timer_get = setInterval(function() { + if (th.data.is_get_local_ok == 0) return false; + var dd = null, + i = getApp().request; + var g_distr_type = th.data.data.distr_type; + if (g_distr_type != 0) { + dd = { + store_id: o.stoid, + distr_type: g_distr_type, + isstop: 0, + pageSize: 300 + } + } else { + dd = { + store_id: o.stoid, + isstop: 0, + pageSize: 300 + } } - } else { - dd = { - store_id: o.stoid, - isstop: 0, - pageSize: 300 + //如果有距离的话 + if (th.data.lat != null) { + dd.lat = th.data.lat; + dd.lon = th.data.lon; } - } - //----------获取门店---------------- - await getApp().request.promiseGet("/api/weshop/pickup/list", { - data: dd, - }).then(res => { - var e = res; - if (e.data.code == 0) { - //单总量超出5个的时候 - if (e.data.data.total > 5) { - i.get("/api/weshop/storagecategory/page", { - data: { - store_id: o.stoid, - is_show: 1, - pageSize: 300 - }, - success: function(ee) { - if (ee.data.code == 0) { - if (ee.data.data.pageData.length > 0) { - var sto_cate = ee.data.data.pageData; - var sto_arr = e.data.data.pageData; - var newarr = new Array(); - var qita = new Array(); - //----要进行门店分组-------- - for (var i = 0; i < sto_arr.length; i++) { - //找一下这个门店有没有在分类数组内 - var find2 = 0, - find2name = ""; - for (var m = 0; m < sto_cate.length; m++) { - if (sto_arr[i].category_id == sto_cate[m].cat_id) { - find2 = sto_cate[m].cat_id; - find2name = sto_cate[m].cat_name; - break; - } + clearInterval(timer_get); + //----------获取门店---------------- + getApp().request.promiseGet("/api/weshop/pickup/list", { + data: dd, + }).then(res => { + var e = res; + if (e.data.code == 0) { + //-- 如果有默认选择门店的时候,要把默认门店放在第一位 -- + if (th.data.def_pick_store) { + for (var k = 0; k < e.data.data.pageData.length; k++) { + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) { + e.data.data.pageData.splice(k, 1); //删除 + break; + } + } + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 + } + + //单总量超出5个的时候 + if (e.data.data.total > 5) { + i.get("/api/weshop/storagecategory/page", { + data: { + store_id: o.stoid, + is_show: 1, + pageSize: 300 + }, + success: function(ee) { + if (ee.data.code == 0) { + if (ee.data.data.pageData.length > 0) { + var def_arr = new Array(); + var ishas = 0; + //-- 开始就看5个门店 -- + for (var k = 0; k < 5; k++) { + if (k == e.data.data.pageData.length) break; + def_arr.push(e.data.data.pageData[k]); } - if (newarr.length > 0) { - var find = 0; - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 - if (find2 != 0) { - for (var ii = 0; ii < newarr.length; ii++) { - if (sto_arr[i].category_id == newarr[ii].cat_id) { - newarr[ii].s_arr.push(sto_arr[i]); - find = 1; - break; + th.setData({ + def_pickpu_list: def_arr, + pickpu_list: ee.data.data.pageData + }); + var sto_cate = ee.data.data.pageData; + var sto_arr = e.data.data.pageData; + var newarr = new Array(); + var qita = new Array(); + + //----要进行门店分组-------- + for (var i = 0; i < sto_arr.length; i++) { + //找一下这个门店有没有在分类数组内 + var find2 = 0, + find2name = ""; + for (var m = 0; m < sto_cate.length; m++) { + if (sto_arr[i].category_id == sto_cate[m].cat_id) { + find2 = sto_cate[m].cat_id; + find2name = sto_cate[m].cat_name; + break; + } + } + + if (newarr.length > 0) { + var find = 0; + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 + if (find2 != 0) { + for (var ii = 0; ii < newarr.length; ii++) { + if (sto_arr[i].category_id == newarr[ii].cat_id) { + newarr[ii].s_arr.push(sto_arr[i]); + find = 1; + break; + } + } + if (find == 0) { + var arr0 = new Array(); + arr0.push(sto_arr[i]); + var item = { + cat_id: find2, + name: find2name, + s_arr: arr0 + }; + newarr.push(item); } + } else { + qita.push(sto_arr[i]); } - if (find == 0) { + } else { + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 + if (find2 != 0) { var arr0 = new Array(); arr0.push(sto_arr[i]); var item = { @@ -1174,63 +1337,51 @@ Page({ s_arr: arr0 }; newarr.push(item); + } else { + qita.push(sto_arr[i]); } - } else { - qita.push(sto_arr[i]); - } - } else { - //如果有找到,那门店就在这个分组内,否则,分类就要排在其他 - if (find2 != 0) { - var arr0 = new Array(); - arr0.push(sto_arr[i]); - var item = { - cat_id: find2, - name: find2name, - s_arr: arr0 - }; - newarr.push(item); - } else { - qita.push(sto_arr[i]); } } - } - //----安排其他的分类----- - if (qita.length > 0) { - var item = { - cat_id: -1, - name: "其他", - s_arr: qita - }; - newarr.push(item); - } - th.setData({ - is_show_sto_cat: 1, - all_sto: newarr - }); + //----安排其他的分类----- + if (qita.length > 0) { + var item = { + cat_id: -1, + name: "其他", + s_arr: qita + }; + newarr.push(item); + } + th.setData({ + is_show_sto_cat: 1, + all_sto: newarr + }); + } else { + th.setData({ + is_show_sto_cat: -1, + only_pk: e.data.data.pageData + }); + } } else { th.setData({ - is_show_sto_cat: 0, + is_show_sto_cat: -1, only_pk: e.data.data.pageData }); } - } else { - th.setData({ - is_show_sto_cat: 0, - only_pk: e.data.data.pageData - }); } - } - }); - } else { - th.setData({ - is_show_sto_cat: 0, - only_pk: e.data.data.pageData - }); + }); + } else { + th.setData({ + is_show_sto_cat: 0, + only_pk: e.data.data.pageData + }); + } } - } - }) + }) + }, 200) + + }, //----------取货门店被点击的效果------ @@ -1272,59 +1423,77 @@ Page({ }, //评论的调用 - requestComments: function() { - var e = this, th = e; - var tp = e.data.activeCategoryId3; + requestComments_new: async function(){ + var e = this, th = e,ee=e; var tp = e.data.activeCategoryId3; var t = '/api/weshop/comment/pageComment?page=' + e.data.c_curr_p; - var req_where={ - store_id: o.stoid, - pageSize: 5, - parent_id: 0, - goods_id: th.data.gid, - commenttype: tp, - + wx.showLoading(); + var req_where = { + store_id: o.stoid, pageSize: 5,is_show:1, + parent_id: 0, goods_id: th.data.gid, commenttype: tp, } - if(getApp().globalData.userInfo){ - req_where.userId=getApp().globalData.userInfo.user_id; + if (getApp().globalData.userInfo) { + req_where.userId = getApp().globalData.userInfo.user_id; } - n.request(t, async function(ee) { - var tot = ee.data.data.total; - e.setData({ - com_num: tot,get_c:1 - }); + var rs_data=null; + await getApp().request.promiseGet(t, { data: req_where}).then(res=>{ + var tot = res.data.data.total; e.data.c_curr_p++; + e.setData({ + com_num: tot, //已经有加载 + }); + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ + rs_data=res.data.data.pageData; + }else{ + th.setData({comments_no_more:1,auto:1}); + } + }) - var cda = th.data.comments; - for(var ind in cda){ - var ep= cda[ind]; - if(ep.is_req!=1){ - await getApp().request.promiseGet("/api/weshop/comment/pageComment",{ - data:{store_id:o.stoid ,parent_id:ep.comment_id} - }).then(res=>{ - cda[ind].is_req=1; - if(cda[ind].head_pic==''){ - cda[ind].head_pic= th.data.iurl+"/miniapp/images/hui_hear_pic.png"; - } - if(res.data.data.pageData && res.data.data.pageData.length>0){ - cda[ind].replay_list=res.data.data.pageData; - } - }) - } + if (rs_data){ + //var cda = th.data.comments; + var cda = rs_data,com_data=th.data.comments; + for (var ind in cda) { + var ep = cda[ind]; + if (cda[ind].head_pic == '') { + cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; + } + if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { + cda[ind].weapp_img = JSON.parse(ep.weapp_img); + } + if (ep.img != "" && ut.isString(ep.img)) { + cda[ind].img = ut.unserialize(ep.img); + } + + //--测量多有字的宽带,计算有多少行-- + var widh=ut.measureText(ep.content,30); + var lines=widh/712; + cda[ind].seeMore=false; + if(lines>3) cda[ind].seeMore=true; + + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { + data: {store_id: o.stoid, parent_id: ep.comment_id } + }).then(res => { + if (res.data.data.pageData && res.data.data.pageData.length > 0) { + cda[ind].replay_list = res.data.data.pageData; + } + }) } - th.setData({ - comments: cda - }); + if (!com_data) com_data = cda; + else com_data = com_data.concat(cda); - }, null,req_where); + th.setData({ comments: com_data}); + } + th.setData({get_c: 1}); + wx.hideLoading(); }, //加载更多是靠这个函数 onReachBottom: function() { - if (this.data.activeCategoryId == 2) - n.canloadMore() && this.requestComments(); + if (this.data.activeCategoryId == 2){ + if(!this.data.comments_no_more) this.requestComments_new(); + } }, //--------检查是否活动,活动是否开始,或者是否结束------- @@ -1333,7 +1502,8 @@ Page({ th = ee; if (prom_type == 3 || prom_type == 0) { this.setData({ - prom_type: prom_type,isshow:1, + prom_type: prom_type, + isshow: 1, }); return false; } @@ -1356,7 +1526,8 @@ Page({ success: function(t) { if (t.data.code != 0) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1364,25 +1535,28 @@ Page({ //----已经结束----- if (t.data.data.is_end == 1) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; } //----已经过期----- var now = ut.gettimestamp(); - if (t.data.data.end_time < now ) { + if (t.data.data.end_time < now) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; } /*-- 还没有开始预热的也不显示 --*/ - if (t.data.data.show_time >now) { + if (t.data.data.show_time > now) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1400,7 +1574,7 @@ Page({ prom_act: t.data.data, prom_end_time: prom_end_time, prom_start_time: prom_start_time, - isshow:1, + isshow: 1, }); @@ -1452,7 +1626,8 @@ Page({ success: function(t) { if (t.data.code != 0) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1460,7 +1635,8 @@ Page({ //----已经结束----- if (t.data.data.is_end == 1) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1469,7 +1645,8 @@ Page({ var now = ut.gettimestamp(); if (t.data.data.end_time < now) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1478,7 +1655,8 @@ Page({ /*-- 还没有开始预热的也不显示 --*/ if (t.data.data.show_time > now) { ee.setData({ - prom_type: 0,isshow:1, + prom_type: 0, + isshow: 1, }); ee.get_sku(os.stoid, ee.data.data.sku, gid); return false; @@ -1499,51 +1677,55 @@ Page({ th.data.buy_order = odr; if (odr.pt_status == 0 && odr.order_status == 1) { th.setData({ - user_order_pt_state: 1 + user_order_pt_state: 1 }); } if (odr.pt_status == 1 && odr.order_status == 1) { - if (odr.is_zsorder == 4){ - getApp().request.promiseGet("/api/weshop/teamgroup/page/", { - data: { store_id: os.stoid, team_id: odr.pt_prom_id, listno: odr.pt_listno } - }).then(res => { - var now=ut.gettimestamp(); - var tgr = res.data.data.pageData[0]; - //如果团的时间已经到了 - if (now >= tgr.kt_end_time){ - th.update_jiti(tgr.id); - }else{ - th.setData({ - user_order_pt_state: 2 - }); - } - }) - - }else{ - th.setData({ - user_order_pt_state: 2 - }); - } - } - - if (odr.pt_status == 2 && odr.is_zsorder == 4) { + if (odr.is_zsorder == 4) { + getApp().request.promiseGet("/api/weshop/teamgroup/page/", { + data: { + store_id: os.stoid, + team_id: odr.pt_prom_id, + listno: odr.pt_listno + } + }).then(res => { + var now = ut.gettimestamp(); + var tgr = res.data.data.pageData[0]; + //如果团的时间已经到了 + if (now >= tgr.kt_end_time) { + th.update_jiti(tgr.id); + } else { + th.setData({ + user_order_pt_state: 2 + }); + } + }) + + } else { th.setData({ - user_order_pt_state: 3, + user_order_pt_state: 2 }); - th.data.wk_order_id=odr.order_id; + } + } + + if (odr.pt_status == 2 && odr.is_zsorder == 4) { + th.setData({ + user_order_pt_state: 3, + }); + th.data.wk_order_id = odr.order_id; } } }, }); //----------查看阶梯团------------ - if (t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined){ - t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); - var max_num=0; - t.data.data.ct_rylist.forEach(function (val,ind) { - if(val.rynum>max_num) max_num=val.rynum; - }) - t.data.data.max_ct_num=max_num; + if (t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { + t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); + var max_num = 0; + t.data.data.ct_rylist.forEach(function(val, ind) { + if (val.rynum > max_num) max_num = val.rynum; + }) + t.data.data.max_ct_num = max_num; } var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); @@ -1556,7 +1738,7 @@ Page({ prom_act: t.data.data, prom_end_time: prom_end_time, prom_start_time: prom_start_time, - isshow:1, + isshow: 1, }); var newTime = now; @@ -1588,40 +1770,51 @@ Page({ }, //--获取有多少人在开团-- - async get_team_group(prom_id){ - var teamgroup=[],th=this,grounp_tatal=0; - //如果活动是开团不是商家团 - if(this.data.prom_act.kttype>1) { - //获取活动从表信息team_id - await getApp().request.promiseGet("/api/weshop/teamgroup/page", { + async get_team_group(prom_id) { + var teamgroup = [], + th = this, + grounp_tatal = 0; + //如果活动是开团不是商家团 + if (this.data.prom_act.kttype > 1) { + //获取活动从表信息team_id + await getApp().request.promiseGet("/api/weshop/teamgroup/page", { + data: { + store_id: os.stoid, + pageSize: 3, + page: 1, + state: 2, + team_id: prom_id + } + }).then(res => { + teamgroup = res.data.data.pageData; + grounp_tatal = res.data.data.total; + }) + //获取订单的总数这个接口不能用 + for (i = 0; i < teamgroup.length; i++) { + await getApp().request.promiseGet("/api/weshop/order/page", { data: { - store_id: os.stoid, pageSize: 3, page: 1, - state: 2, - team_id: prom_id + store_id: os.stoid, + pt_status: 1, + pt_listno: teamgroup[i].listno } }).then(res => { - teamgroup = res.data.data.pageData; - grounp_tatal = res.data.data.total; + var order = res.data.data.pageData; + teamgroup[i].open_num = order.length; }) - //获取订单的总数这个接口不能用 - for (i = 0; i < teamgroup.length; i++) { - await getApp().request.promiseGet("/api/weshop/order/page", { - data: { store_id: os.stoid, pt_status: 1, pt_listno: teamgroup[i].listno } - }).then(res => { - var order = res.data.data.pageData; - teamgroup[i].open_num = order.length; - }) - await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { - var user = res.data.data; - teamgroup[i].user = user; - }) - } + await getApp().request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + teamgroup[i].openvipid, {}).then(res => { + var user = res.data.data; + teamgroup[i].user = user; + }) + } - if (teamgroup.length > 0) { - th.setData({ teamgroup: teamgroup, grounp_tatal: grounp_tatal }); - th.countDown2(); - } + if (teamgroup.length > 0) { + th.setData({ + teamgroup: teamgroup, + grounp_tatal: grounp_tatal + }); + th.countDown2(); } + } }, //---小于10的格式化函数---- @@ -1631,7 +1824,7 @@ Page({ //----倒计时函数----- countDown(time, prom_st) { - if(!this.data.is_timer) return false; + if (!this.data.is_timer) return false; var th = this; // 获取当前时间,同时得到活动结束时间数组 var endTime = time; @@ -1736,8 +1929,8 @@ Page({ if (tt.data.code == 0) { map.set(gd.goods_id, g_buy_num); th.setData({ - g_buy_num: map, - prom_buy_num: tt.data.data.goodsbuynum, + g_buy_num: map, + prom_buy_num: tt.data.data.goodsbuynum, }); "function" == typeof func && func(); } @@ -1778,10 +1971,17 @@ Page({ //--点击弹起拼单-- openSpecModel_pt: function(e) { + + + this.setData({ open_ind_store: 4});//拼团直接给4 + + //--先判断会员状态-- - var user_info=getApp().globalData.userInfo; - if(user_info==null || user_info.mobile==undefined || user_info.mobile=="" || user_info.mobile==null){ - wx.navigateTo({ url: '/pages/getphone/getphone', }) + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/getphone/getphone', + }) return false; } @@ -1814,7 +2014,7 @@ Page({ pageSize: 1, page: 1 }, - success: function (e) { + success: function(e) { //--跳转到已经购买的情况-- if (e.data.data.pageData.length > 0) { var odr = e.data.data.pageData[0]; @@ -1823,12 +2023,12 @@ Page({ wx.showModal({ title: "您已经购买了该商品待支付中", success: function(a) { - if(a.confirm){ - wx.navigateTo({ - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, - }); - } - } + if (a.confirm) { + wx.navigateTo({ + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, + }); + } + } }); } else if (odr.pt_status == 1 && odr.order_status == 1) { wx.navigateTo({ @@ -1841,8 +2041,7 @@ Page({ }); } - } - else{ + } else { th.setData({ is_normal: ind, openSpecModal_pt: 1 @@ -1855,30 +2054,33 @@ Page({ //-----------------拼单生成方法--------------------- addCart_pt: function() { - var th=this; - if(this.data.is_normal==0){ - //看一下有没有起购数,如果有起购数,要计算起购数 - var qnum=parseFloat(th.data.prom_act.minbuynum); - if(qnum>0 && th.data.goodsInputNum 0 && th.data.goodsInputNum < qnum) { + getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); + return false; + } - th.addcart_pt_func(); - }else{ + th.addcart_pt_func(); + } else { th.addcart_pt_func(); } }, - addcart_pt_func:function(){ + addcart_pt_func: function() { if (oo.user_id == null) { - s.my_warnning("还未登录!",0,this);return; + s.my_warnning("还未登录!", 0, this); + return; } - var e = this, th = e,o = this.data.sele_g; - if (o.store_count <= 0) return s.my_warnning("库存已为空!",0,th); + var e = this, + th = e, + o = this.data.sele_g; + if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); //----------添加到购物车时,要判断限购数量,-------- - e.get_buy_num(o,async function(ee) { + e.get_buy_num(o, async function(ee) { //---判断商品是否超出限购--- if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { @@ -1901,28 +2103,29 @@ 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; - }) + 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.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); + 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); if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) this.setData({ sto_sele_name: "" }); - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店",0,th); + if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th); //--------------此时操作的数据------------ var newd = { goods_id: o.goods_id, @@ -1947,8 +2150,8 @@ Page({ if (newd.kt_type > 1) { newd.is_pt_tz = 1; //开团类型 } - if (newd.kt_type == 3 && th.data.is_normal!=1){ - th.data.sto_sele_distr=1; + if (newd.kt_type == 3 && th.data.is_normal != 1) { + th.data.sto_sele_distr = 1; } } else if (th.data.prom_type == 3) { @@ -1973,14 +2176,14 @@ Page({ //-------跳转pt商品------- go_to_nopay: function() { - var th=this; + var th = this; wx.navigateTo({ url: "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id, }); }, //-------跳转pt teamshow------- go_to_team_show: function() { - var th=this; + var th = this; wx.navigateTo({ url: "/pages/team/team_success/team_success?ordersn=" + th.data.buy_order.order_sn, }); @@ -1988,7 +2191,7 @@ Page({ //---拼团倒计时--- countDown2() { - if(!this.data.is_timer) return false; + if (!this.data.is_timer) return false; var th = this; // 获取当前时间,同时得到活动结束时间数组 var newTime = ut.gettimestamp(); @@ -2014,7 +2217,10 @@ Page({ } else { //活动已结束,全部设置为'00' obj = { - day: '00',hou: '00',min: '00', sec: '00' + day: '00', + hou: '00', + min: '00', + sec: '00' } } var txt = "timer[" + j + "]"; @@ -2025,11 +2231,11 @@ Page({ setTimeout(th.countDown2, 1000); }, //跳转参加团 - go_cj_team:function (e) { - var ind=e.currentTarget.dataset.ind; - var item=this.data.teamgroup[ind]; - var id=item.id; - var th=this; + go_cj_team: function(e) { + var ind = e.currentTarget.dataset.ind; + var item = this.data.teamgroup[ind]; + var id = item.id; + var th = this; getApp().request.get("/api/weshop/order/page", { data: { @@ -2040,205 +2246,231 @@ Page({ page: 1 }, success: function(e) { - if (e.data.code != 0) { - getApp().my_warnning("读取订单失败",0,th); - return fasle; - } - //--跳转到已经购买的情况-- - if ( e.data.data.pageData.length > 0) { - var odr = e.data.data.pageData[0]; - //还未支付 - if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0) ) { - wx.showModal({ - title: "您已经购买了该商品待支付中", - success: function(a) { - if(a.confirm){ - wx.navigateTo({ - url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, - }); - } - } - }); - }else if (odr.pt_status == 1 && odr.order_status == 1){ - wx.navigateTo({ - url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, - }); - }else{ - wx.navigateTo({ - url: "/pages/team/team_show/team_show?tg_id="+id, - }); - } - } - //--跳转到参团-- - else{ + if (e.data.code != 0) { + getApp().my_warnning("读取订单失败", 0, th); + return fasle; + } + //--跳转到已经购买的情况-- + if (e.data.data.pageData.length > 0) { + var odr = e.data.data.pageData[0]; + //还未支付 + if (odr.pt_status == 0 && (odr.order_status == 1 || odr.order_status == 0)) { + wx.showModal({ + title: "您已经购买了该商品待支付中", + success: function(a) { + if (a.confirm) { + wx.navigateTo({ + url: "/pages/user/order_detail/order_detail?order_id=" + odr.order_id, + }); + } + } + }); + } else if (odr.pt_status == 1 && odr.order_status == 1) { wx.navigateTo({ - url: "/pages/team/team_show/team_show?tg_id="+id, + url: "/pages/team/team_success/team_success?ordersn=" + odr.order_sn, + }); + } else { + wx.navigateTo({ + url: "/pages/team/team_show/team_show?tg_id=" + id, }); } + } + //--跳转到参团-- + else { + wx.navigateTo({ + url: "/pages/team/team_show/team_show?tg_id=" + id, + }); + } } }) }, - //跳到团更多 - go_t_more:function(){ - var team_id=this.data.prom_id; - wx.navigateTo({ - url: "/pages/team/team_more/team_more?team_id="+team_id, - }); - }, + //跳到团更多 + go_t_more: function() { + var team_id = this.data.prom_id; + wx.navigateTo({ + url: "/pages/team/team_more/team_more?team_id=" + team_id, + }); + }, - //--点赞功能-- - click_zan:function (e) { - var com_id=e.currentTarget.dataset.com_id; - var item_id=e.currentTarget.dataset.item_id; - var app=getApp(),th=this; + //--点赞功能-- + click_zan: function(e) { + var com_id = e.currentTarget.dataset.com_id; + var item_id = e.currentTarget.dataset.item_id; + var app = getApp(), + th = this; - if(app.globalData.userInfo==null || app.globalData.userInfo==undefined ){ - app.confirmBox("您还未登录"); - return false; - } + if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { + app.confirmBox("您还未登录"); + return false; + } - var iszan=th.data.comments[item_id].userZanNum; - if(this.data.iszaning) return false; - this.data.iszaning=1; + var iszan = th.data.comments[item_id].userZanNum; + if (this.data.iszaning) return false; + this.data.iszaning = 1; + + + app.request.post("/api/weshop/commentZan/save", { + data: { + store_id: o.stoid, + user_id: app.globalData.user_id, + goods_id: th.data.gid, + comment_id: com_id + }, + success: function(ee) { + if (ee.data.code == "-1") { + app.my_warnning("不能给自己点赞", 0, th); + th.data.iszaning = 0; + return; + } - app.request.post("/api/weshop/commentZan/save",{ - data:{store_id:o.stoid,user_id:app.globalData.user_id,goods_id:th.data.gid,comment_id:com_id}, - success:function (ee) { + if (ee.data.code == 0 && iszan != 1) { + var num = th.data.comments[item_id].zan_num; + num++; + var text = "comments[" + item_id + "].zan_num"; + var text1 = "comments[" + item_id + "].userZanNum"; + var _errObj = {}; + _errObj[text] = num; + _errObj[text1] = 1; + th.setData(_errObj); - if (ee.data.code == "-1") { - app.my_warnning("不能给自己点赞", 0, th); - th.data.iszaning=0; - return; - } + } else { + var num = th.data.comments[item_id].zan_num; + num--; + var text = "comments[" + item_id + "].zan_num"; + var text1 = "comments[" + item_id + "].userZanNum"; + var _errObj = {}; + _errObj[text] = num; + _errObj[text1] = 0; + th.setData(_errObj); + } - if(ee.data.code==0 && iszan!=1){ - var num=th.data.comments[item_id].zan_num; num++; - var text="comments["+item_id+"].zan_num"; - var text1="comments["+item_id+"].userZanNum"; - var _errObj = {}; - _errObj[text]=num; - _errObj[text1]=1; - th.setData(_errObj); - - }else{ - var num=th.data.comments[item_id].zan_num; num--; - var text="comments["+item_id+"].zan_num"; - var text1="comments["+item_id+"].userZanNum"; - var _errObj = {}; - _errObj[text]=num; - _errObj[text1]=0; - th.setData(_errObj); - } + setTimeout(function() { + th.data.iszaning = 0; + }, 500) - setTimeout(function(){ - th.data.iszaning = 0; - },500) - - } - }) - }, + } + }) + }, /*----券的开关---*/ - switchCoupon:async function(event){ + switchCoupon: async function(event) { var coupon = event.currentTarget.dataset.coupon; - var app=getApp(); - var url="/api/weshop/prom/coupon/pageCouponList"; - var quan_list=this.data.quan_list; - var th=this; + var app = getApp(); + var url = "/api/weshop/prom/coupon/pageCouponList"; + var quan_list = this.data.quan_list; + var th = this; //当开启,且列表为空的情况下要 - if(!quan_list && coupon=="1") { - wx.showLoading(); - await app.request.promiseGet(url, { - data: { - store_id: os.stoid, - type: 1, - pageSize: 100, - page: 1, - user_id:app.globalData.user_id - } - }).then(res => { - wx.hideLoading(); - quan_list = res.data.data.pageData; - }) + if (!quan_list && coupon == "1") { + wx.showLoading(); + await app.request.promiseGet(url, { + data: { + store_id: os.stoid, + type: 1, + pageSize: 100, + page: 1, + user_id: app.globalData.user_id + } + }).then(res => { + wx.hideLoading(); + quan_list = res.data.data.pageData; + }) - if(quan_list){ - for(var ind in quan_list){ - var ep=quan_list[ind]; - var start=ut.formatTime(ep.use_start_time,"yyyy-MM-dd"); - var end=ut.formatTime(ep.use_end_time,"yyyy-MM-dd"); - start=start.replace("00:00:00",""); - end=end.replace("00:00:00",""); - quan_list[ind].start=start; - quan_list[ind].end=end; - } + if (quan_list) { + for (var ind in quan_list) { + var ep = quan_list[ind]; + var start = ut.formatTime(ep.use_start_time, "yyyy-MM-dd"); + var end = ut.formatTime(ep.use_end_time, "yyyy-MM-dd"); + start = start.replace("00:00:00", ""); + end = end.replace("00:00:00", ""); + quan_list[ind].start = start; + quan_list[ind].end = end; } + } - th.setData({coupon: coupon, quan_list: quan_list}); - }else{ - th.setData({coupon: coupon}); + th.setData({ + coupon: coupon, + quan_list: quan_list + }); + } else { + th.setData({ + coupon: coupon + }); } }, //--查看评价-- - look_pj:function () { - this.tabComment(); this.doScrollTop(); + look_pj: function() { + this.tabComment(); + this.doScrollTop(); }, //-----领取券----- - get_quan:function (e) { - var cid=e.currentTarget.dataset.cid; - var index=e.currentTarget.dataset.ind; - var item=this.data.quan_list[index]; - + get_quan: function(e) { + var cid = e.currentTarget.dataset.cid; + var index = e.currentTarget.dataset.ind; + var item = this.data.quan_list[index]; + //如果券还在领取中,不能再点 - if (item.linging==1){ + if (item.linging == 1) { getApp().my_warnning('领取中..', 0, this); return false; } //如果领取的次数到了 - if(item.everyone_num>0 && item.lqnum>=item.everyone_num){ - getApp().my_warnning('领取失败,您已领完该券',0,this); + if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) { + getApp().my_warnning('领取失败,您已领完该券', 0, this); return false; } - var lq_num=item.lqnum; - - var pdata={'uid':oo.user_id,'cid':cid,'store_id':os.stoid,'type':5}; - var app=getApp(),th=this; - app.request.post("/api/weshop/couponList/saveCouponList",{ - data:pdata, - success:function (res) { - if(res.data.code==0){ - app.my_warnning("领取成功",1,th); - lq_num++; - var text="quan_list["+index+"].lqnum"; - var text2 = "quan_list[" + index + "].linging"; - var obj = {}; obj[text] = lq_num; obj[text2] = 0; - th.setData(obj); - }else{ - app.confirmBox(res.data.msg); - var text2 = "quan_list[" + index + "].linging"; - var obj = {}; obj[text2] = 0; - th.setData(obj); - } + var lq_num = item.lqnum; + + var pdata = { + 'uid': oo.user_id, + 'cid': cid, + 'store_id': os.stoid, + 'type': 5 + }; + var app = getApp(), + th = this; + app.request.post("/api/weshop/couponList/saveCouponList", { + data: pdata, + success: function(res) { + if (res.data.code == 0) { + app.my_warnning("领取成功", 1, th); + lq_num++; + var text = "quan_list[" + index + "].lqnum"; + var text2 = "quan_list[" + index + "].linging"; + var obj = {}; + obj[text] = lq_num; + obj[text2] = 0; + th.setData(obj); + } else { + app.confirmBox(res.data.msg); + var text2 = "quan_list[" + index + "].linging"; + var obj = {}; + obj[text2] = 0; + th.setData(obj); } + } }) }, //--定义的保存图片方法,分享团--- - saveImageToPhotosAlbum: function () { + saveImageToPhotosAlbum: function() { //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 var type = this.data.prom_type; if (type == 6) type = 2; if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; - wx.showLoading({ title: '生成中...', }) - var that = this, th = that; + wx.showLoading({ + title: '生成中...', + }) + var that = this, + th = that; //设置画板显示,才能开始绘图 that.setData({ canvasHidden: false @@ -2255,9 +2487,9 @@ Page({ //读取文件成功则OK-- wx.getImageInfo({ src: path3, - success: function (res) { + success: function(res) { //回调写法 - th.get_head_temp(th.get_goods_temp, function () { + th.get_head_temp(th.get_goods_temp, function() { var vpath = res.path; var context = wx.createCanvasContext('share'); //先画背景 @@ -2272,14 +2504,14 @@ Page({ var tj_path = "../../../images/share/q_tj.png"; context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit); context.setFontSize(16 * unit) - context.setLineJoin('round'); //交点设置成圆角 + context.setLineJoin('round'); //交点设置成圆角 context.setFillStyle("white") context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 76 * unit); //---产品名称--- //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 console.log("ssssssss", th.data.data.goods_name); - + context.setFillStyle("black"); context.setFontSize(21.3 * unit) th.draw_Text(context, th.data.data.goods_name, @@ -2308,7 +2540,7 @@ Page({ context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit); //-------大图后面就不一样了----------- switch (type) { - case 0: //普通商品的展示 + case 0: //普通商品的展示 //中间的几个字 var g_path = "../../../images/share/s_gou.png"; context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); @@ -2338,7 +2570,7 @@ Page({ //---二维吗图--- context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); break; - case 1: //秒杀商品的展示 + case 1: //秒杀商品的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit) @@ -2346,7 +2578,7 @@ Page({ context.stroke(); //画秒杀的图片 - var miaos_path='../../../images/share/miao_share.png'; + var miaos_path = '../../../images/share/miao_share.png'; context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); //---文字--- @@ -2358,7 +2590,7 @@ Page({ context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); break; - case 2://会员团和商家团的展示 + case 2: //会员团和商家团的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit) @@ -2393,7 +2625,7 @@ Page({ //---二维吗图--- context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); break - case 3://阶梯团的展示 + case 3: //阶梯团的展示 //---画线--- context.setLineWidth(1 * unit) context.moveTo(32 * unit, 670 * unit) @@ -2448,35 +2680,37 @@ Page({ context.restore(); //把画板内容绘制成图片,并回调 画板图片路径 - context.draw(false, function () { - setTimeout(function () { - wx.canvasToTempFilePath({ - x: 0, y: 0, - width: 750, - height: 1217, - destWidth: 1.2 * 750 * 750 / that.data.screenWidth, - destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, - canvasId: 'share', - success: function (res) { - that.setData({ - shareImgPath: res.tempFilePath, canvasHidden: true - }) - if (!res.tempFilePath) { - wx.showModal({ - title: '提示', - content: '图片绘制中,请稍后重试', - showCancel: false - }) - return false; - } - wx.previewImage({ - //将图片预览出来 - urls: [that.data.shareImgPath] - }); - wx.hideLoading(); - } - }) - },500) + context.draw(false, function() { + setTimeout(function() { + wx.canvasToTempFilePath({ + x: 0, + y: 0, + width: 750, + height: 1217, + destWidth: 1.2 * 750 * 750 / that.data.screenWidth, + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth, + canvasId: 'share', + success: function(res) { + that.setData({ + shareImgPath: res.tempFilePath, + canvasHidden: true + }) + if (!res.tempFilePath) { + wx.showModal({ + title: '提示', + content: '图片绘制中,请稍后重试', + showCancel: false + }) + return false; + } + wx.previewImage({ + //将图片预览出来 + urls: [that.data.shareImgPath] + }); + wx.hideLoading(); + } + }) + }, 500) }); }); @@ -2486,21 +2720,21 @@ Page({ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth,unit) { + draw_Text: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { var lineWidth = 0; var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - var han=0; + var han = 0; for (let i = 0; i < str.length; i++) { - if(han==2) return; + if (han == 2) return; //lineWidth += ctx.measureText(str[i]).width; lineWidth += ut.measureText(str[i], 21.3 * unit); if (lineWidth > canvasWidth) { han++; - - if (han==2) - ctx.fillText(str.substring(lastSubStrIndex, i)+'...', leftWidth, initHeight); //绘制截取部分 + + if (han == 2) + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 else - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); initHeight += 22; //22为字体的高度 lineWidth = 0; @@ -2515,15 +2749,17 @@ Page({ // ----视频图片---- // 图片计数器 - swiperChange: function (e) { + swiperChange: function(e) { var that = this; - if (e.detail.current>0){ + if (e.detail.current > 0) { that.setData({ - hiddenn:1, videopicture:1, + hiddenn: 1, + videopicture: 1, }) - }else{ + } else { that.setData({ - hiddenn:0,videopicture:0, + hiddenn: 0, + videopicture: 0, }) } if (e.detail.source == 'touch') { @@ -2534,18 +2770,24 @@ Page({ }, /*---视频相关--*/ - videopicture: function (e) { + videopicture: function(e) { var vipi = e.currentTarget.dataset.vipi; - this.setData({ videopicture: vipi, swiperCurrent:vipi, noon: 0,current:1 }); + this.setData({ + videopicture: vipi, + swiperCurrent: vipi, + noon: 0, + current: 1 + }); }, - videoPlay: function (e) { + videoPlay: function(e) { var _index = e.currentTarget.id this.setData({ - _index: _index, noon: 1 + _index: _index, + noon: 1 }) - setTimeout(function () { + setTimeout(function() { //将点击视频进行播放 var videoContext = wx.createVideoContext(_index) videoContext.play(); @@ -2554,46 +2796,59 @@ Page({ //--加载更多商品-- - requestRecommend: function () { - var e = this, t = '/api/weshop/goods/page?page=1'; - var th_recommend_list=e.data.recommend_list; - getApp().request.get(t,{ - data: { is_mainshow: 1, isonsale: 1, is_recommend:1, is_on_sale: 1, store_id: os.stoid, pageSize: 6 }, - success:function (ee) { - var recommend_list=ee.data.data.pageData; - if(recommend_list && recommend_list.length>0){ - var dd=[...th_recommend_list,...recommend_list]; - e.setData({recommend_list,dd}); - e.data.currentPage++; - }else{ - e.setData({nomore:1}); + requestRecommend: function() { + var e = this, + t = '/api/weshop/goods/page?page=1'; + var th_recommend_list = e.data.recommend_list; + getApp().request.get(t, { + data: { + is_mainshow: 1, + isonsale: 1, + is_recommend: 1, + is_on_sale: 1, + store_id: os.stoid, + pageSize: 6 + }, + success: function(ee) { + var recommend_list = ee.data.data.pageData; + if (recommend_list && recommend_list.length > 0) { + var dd = [...th_recommend_list, ...recommend_list]; + e.setData({ + recommend_list, + dd + }); + e.data.currentPage++; + } else { + e.setData({ + nomore: 1 + }); } } }) }, //--获取头像的本地缓存,回调写法-- - get_head_temp:function (tt,func) { - var ee=this; - if(ee.data.share_head){ + get_head_temp: function(tt, func) { + var ee = this; + if (ee.data.share_head) { tt(func); return false; } //---获取分享图片的本地地址,头像和商品图片---- var path2 = getApp().globalData.userInfo.head_pic; - if(path2==""){ - ee.data.share_head ="../../../images/share/hui_hear_pic.png"; + if (path2 == "") { + ee.data.share_head = "../../../images/share/hui_hear_pic.png"; tt(func); - }else { - path2=path2.replace("http://thirdwx.qlogo.cn","https://wx.qlogo.cn"); + } else { + path2 = path2.replace("http://thirdwx.qlogo.cn", "https://wx.qlogo.cn"); wx.getImageInfo({ src: path2, - success: function (res) { + success: function(res) { //res.path是网络图片的本地地址 ee.data.share_head = res.path; - tt(func);; + tt(func); }, - fail: function (res) { + fail: function(res) { ee.data.share_head = "../../../images/share/hui_hear_pic.png"; //分享的图片不能用网络的 tt(func); } @@ -2601,74 +2856,406 @@ Page({ } }, //--获取商品图片的本地缓存,回调写法-- - get_goods_temp:function (tt) { - var ee=this; - if(ee.data.share_goods_img) { + get_goods_temp: function(tt) { + var ee = this; + if (ee.data.share_goods_img) { tt(); return false; } //获取商品是分享图信息 wx.getImageInfo({ - src: ee.data.data.original_img, - success: function (res) { + src: ee.data.data.original_img, + success: function(res) { //res.path是网络图片的本地地址 ee.data.share_goods_img = res.path; tt(); }, - fail: function (res) { - ee.data.share_goods_img= "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 + fail: function(res) { + + ee.data.share_goods_img = "../../../images/share/default_g_img.gif"; //分享的图片不能用网络的 tt(); } }); }, //--外侧评价的点击效果--- - clik_evaluate:function(e){ - var val=e.currentTarget.dataset.val; + clik_evaluate: function(e) { + var val = e.currentTarget.dataset.val; this.setData({ - activeCategoryId: 2, activeCategoryId3: val , comments: null + activeCategoryId: 2, + activeCategoryId3: val, + comments: null }); - this.requestComments(); + this.requestComments_new(); }, //--跳转到商品详情页面-- - go_goods: function (e) { + go_goods: function(e) { var gid = e.currentTarget.dataset.gid; var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid; getApp().goto(url); }, //--跳转到支付尾款界面-- - go_pay_wk:function () { - var url = "/pages/cart/cart_wk/cart_wk?order_id="+ this.data.wk_order_id; + go_pay_wk: function() { + var url = "/pages/cart/cart_wk/cart_wk?order_id=" + this.data.wk_order_id; getApp().goto(url); }, - pop_err_img:function(e){ - var txt = e.currentTarget.dataset.errorimg; - var ob={}; - ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; - this.setData(ob); + pop_err_img: function(e) { + var txt = e.currentTarget.dataset.errorimg; + var ob = {}; + ob[txt] = this.data.iurl + "/miniapp/images/default_g_img.gif"; + this.setData(ob); }, //--调用更新阶梯团的接口-- - update_jiti:function(id){ - var th=this; + update_jiti: function(id) { + var th = this; //--更新阶梯团-- - getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/"+os.stoid+"/"+id, { - success: function (ee) { - //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- - if (ee.data.code==0) { - th.setData({ - user_order_pt_state: 3, - }); - }else if(ee.data.code==-1){ - th.setData({ - user_order_pt_state: 2, - }); + getApp().request.put("/api/weshop/teamgroup/updateTeamOrder/" + os.stoid + "/" + id, { + success: function(ee) { + //--等于0是要去支付尾款,接口调用失败,就要去查看参团详情-- + if (ee.data.code == 0) { + th.setData({ + user_order_pt_state: 3, + }); + } else if (ee.data.code == -1) { + th.setData({ + user_order_pt_state: 2, + }); + } + } + }) + }, + // 选择门店 + choice_store: function(ee) { + var th = this; + //var ind=ee.currentTarget.dataset.ind; + var bconfig = th.data.bconfig; + + if (bconfig.is_sort_storage) { + wx.getLocation({ + type: 'wgs84', + success: function(res) { + + th.data.lat = res.latitude; + th.data.lon = res.longitude; + th.data.is_get_local_ok = 1; + th.setData({ + is_gps: 1 + }); + //th.onShow(); + th.get_sto(); + }, + fail: function(res) { + //th.onShow(); + th.get_sto(); + if (res.errCode == 2) { + th.setData({ + is_gps: 0 + }); + if (th.data.is_gps == 0) { + getApp().confirmBox("请开启GPS定位", null, 25000, !1); + } + } else { + th.setData({ + is_gps: "3" + }); + } + + th.data.is_get_local_ok = 1; + } + }) + }else{ + th.get_sto(); + } + + this.setData({ + //open_ind_store: ind, + store: 1, + openSpecModal: !1, + openSpecModal_pt: !1 + }) + }, + //关闭选择门店 + close_popup: function(e) { + + this.setData({ + store: 0, + choice_sort_store: 0, + sort_store: 0 + }) + }, + //选择更多门店 + more_store: function() { + this.setData({ + sort_store: 1 + }); + }, + sort_store: function() { + + }, + // 返回按钮 + returns: function() { + this.setData({ + sort_store: 0, + choice_sort_store: 0 + }); + }, + //---选择分类门店--- + choice_sort_store: function(e) { + var index = e.currentTarget.dataset.index; + var region_name = e.currentTarget.dataset.region; + var item = this.data.all_sto[index]; + this.setData({ + region_name: region_name, + sort_store: 0, + choice_sort_store: 1, + sec_sto: item, + sec_pick_index: 0 + }); + }, + + + + choose_for_store_fir: function(e) { + var index_c = e.currentTarget.dataset.ind; + + this.setData({ + fir_pick_index: index_c + }) + }, + + //确定def_pick为选择的门店 + sure_pick: function(e) { + var th = this; + var item = null; + var openindstore = th.data.open_ind_store; + + if (th.data.choice_sort_store == 0) { + var index = th.data.fir_pick_index; + if (th.data.is_show_sto_cat == 1) { + item = th.data.def_pickpu_list[index]; + } else { + item = th.data.only_pk[index]; //当没有门店分类的时候 + } + + } else { + var index = th.data.sec_pick_index; + item = th.data.sec_sto.s_arr[index]; + } + + //th.setData({fir_pick_index:0}); + console.log("选择门店刷新", "def_pick_store", item); + th.setData({ + def_pick_store: item, + sto_sele_name: item.pickup_name, + sto_sele_id: item.pickup_id, + sto_sele_distr: item.distr_type, + store: 0, + choice_sort_store: 0, + fir_pick_index: 0 + }); + + if (openindstore == 1) { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: openindstore, + }); + } else if (openindstore == 2) { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: openindstore, + }); + } + else if (openindstore == 4) { //4就是拼团 + th.setData({ + openSpecModal_pt: 1, //打开拼团购买界面 + store: 0, //关闭门店 + choice_sort_store: 0, //关闭门店2级 + sort_store: 0, //关闭门店2级 + }); + } + + else { + th.setData({ + store: 0, + choice_sort_store: 0, + sort_store: 0 + }) + } + + }, + //---点击二级之后的选择--- + choose_for_store: function(e) { + var index_c = e.currentTarget.dataset.ind; + + this.setData({ + sec_pick_index: index_c, + fir_pick_index: index_c + }) + }, + //把选择的门店设置成默认的门店def_pick + set_def_pick: function(e) { + var th = this; + var item = null; + + if (th.data.choice_sort_store == 0) { + + var index = th.data.fir_pick_index; + + if (th.data.is_show_sto_cat == 1) { + item = th.data.def_pickpu_list[index]; + } else { + item = th.data.only_pk[index]; //当没有门店分类的时候 + + } + } else { + var index = th.data.sec_pick_index; + item = th.data.sec_sto.s_arr[index]; + } + + var store_id = o.stoid; + var user_id = getApp().globalData.user_id; + var def_pickup_id = item.pickup_id; + + getApp().request.put('/api/weshop/users/update', { + data: { + user_id, + def_pickup_id + }, + success: function(res) { + if (res.data.code == 0) { + if (th.data.choice_sort_store == 0) th.setData({ + fir_pick_index: 0 + }); + //s.showWarning("设置门店地址成功", null, 500, !1); + getApp().globalData.pk_store = item; + } else { + console.log("门店地址失败"); + //s.showWarning("设置默认门店地址失败", null, 500, !1); + getApp().my_warnning("设置默认门店地址失败",0,th) + } + + } + }); + + th.setData({ + def_pick_store: item, + sto_sele_name: item.pickup_name, + sto_sele_id: item.pickup_id, + sto_sele_distr: item.distr_type, + store: 0, + choice_sort_store: 0 + }); + + + var openindstore = th.data.open_ind_store; + if (openindstore == 1) { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: openindstore, + store: 0, + choice_sort_store: 0, + sort_store: 0, + }); + } else if (openindstore == 2) { + th.setData({ + openSpecModal: !0, + openSpecModal_ind: openindstore, + store: 0, + choice_sort_store: 0, + sort_store: 0, + }); + } + else if (openindstore == 4) { //4就是拼团 + th.setData({ + openSpecModal_pt: 1, //打开拼团购买界面 + store: 0, //关闭门店 + choice_sort_store: 0, //关闭门店2级 + sort_store: 0, //关闭门店2级 + }); + } + + else { + th.setData({ + store: 0, + choice_sort_store: 0, + sort_store: 0, + }) + } + + }, + + wait_for_store_config: function() { + var th = this; + var t_time = setInterval(function() { + if (th.data.bconfig == null) false; + var e = th.data.bconfig; + if (e.is_sort_storage) { + wx.getLocation({ + type: 'wgs84', + success: function(res) { + th.data.lat = res.latitude; + th.data.lon = res.longitude; + th.data.is_get_local_ok = 1; + }, + fail: function(res) { + if (res.errCode == 2) { + th.setData({ + is_gps: 0 + }); + if (th.data.is_gps == 0) { + getApp().confirmBox("请开启GPS定位", null, 10000, !1); + } + + } else { + th.setData({ + is_gps: "3" + }); } - } + + th.data.is_get_local_ok = 1; + } + }) + } else { + th.data.is_get_local_ok = 1; + } + clearInterval(t_time); + }, 500) + }, + //显示全部 + toggleHandler: function(e) { + var that = this, + index = e.currentTarget.dataset.index; + for (var i = 0; i < that.data.comments.length; i++) { + if (index == i) { + for (var i = 0; i < that.data.comments.length; i++) { + that.data.comments[index].auto = true; + that.data.comments[index].seeMore = false; + } + } + } + that.setData({ + comments: that.data.comments }) - } + }, + + //收起更多 + toggleContent: function(e) { + var that = this, + index = e.currentTarget.dataset.index; + for (var i = 0; i < that.data.comments.length; i++) { + if (index == i) { + that.data.comments[index].auto = true; + that.data.comments[index].seeMore = true; + } + } + that.setData({ + comments: that.data.comments + }) + }, + }); \ No newline at end of file diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 2910be3..3112e58 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -2,13 +2,14 @@ + {{item.name}} - + @@ -43,7 +44,7 @@
- + 视频 @@ -253,7 +254,7 @@ - 销量:{{data.sales_sum}}件 + 销量:{{data.sales_sum}}件 折扣:{{data.disc}}折 {{categories3[0].num}}人评价 @@ -272,7 +273,7 @@
- + {{data.goods_name}} @@ -299,6 +300,37 @@
+ + + + + + + + 选择门店 + + + 更多门店 + + + + + + + + {{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}} + + + + + @@ -340,16 +372,16 @@ - + - {{item.username}} + {{item.is_anonymous!=1?item.username:'匿名'}} - - {{item.content?item.content:''}} + + {{item.content?item.content:''}} {{item.add_time}} @@ -357,7 +389,8 @@ - + + @@ -480,7 +513,7 @@ - +