diff --git a/app.js b/app.js index 8df8c61..74e3774 100644 --- a/app.js +++ b/app.js @@ -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, @@ -287,10 +288,43 @@ 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); + } } }); diff --git a/app.json b/app.json index 190518b..34e5b0b 100644 --- a/app.json +++ b/app.json @@ -71,7 +71,12 @@ "pages/user/grow_value/grow_value" ], - "window": { + "permission": { + "scope.userLocation": { + "desc": "获取你的位置信息" + } + }, + "window": { "backgroundTextStyle": "light", "navigationBarTextStyle": "black", "navigationBarTitleText": "加载中...", @@ -84,6 +89,7 @@ "selectedColor": "#f23030", "borderStyle": "white", "backgroundColor": "#ffffff", + "list": [ { "pagePath": "pages/index/index/index", diff --git a/app.wxss b/app.wxss index 5677590..bdd56a3 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%; @@ -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; @@ -358,6 +372,8 @@ background: #ffe3e2; .fs40 { font-size: 40rpx; } -.ai_and{ - align-items:flex-end; + +.ai_end{ + align-items: flex-end; } + diff --git a/components/goods_list/goods_list.js b/components/goods_list/goods_list.js index 810ad76..90a593c 100644 --- a/components/goods_list/goods_list.js +++ b/components/goods_list/goods_list.js @@ -73,7 +73,10 @@ Component({ reset:function(){ curPage=1; }, - + go_url:function(e){ + var url=e.currentTarget.dataset.url; + t.goto(url); + }, }, diff --git a/components/goods_list/goods_list.wxml b/components/goods_list/goods_list.wxml index 1f8dfd5..cad4791 100644 --- a/components/goods_list/goods_list.wxml +++ b/components/goods_list/goods_list.wxml @@ -3,13 +3,17 @@ + + - + - {{item.goods_name}} + + {{item.goods_name}} + @@ -24,7 +28,7 @@ - + diff --git a/components/goods_list/goods_list.wxss b/components/goods_list/goods_list.wxss index 28e2283..0b42b70 100644 --- a/components/goods_list/goods_list.wxss +++ b/components/goods_list/goods_list.wxss @@ -37,17 +37,16 @@ color: #b9b9b9; -webkit-line-clamp: 2; } .goods_name{ - height: 62rpx; + height: 62rpx; margin-top: 6rpx; - line-height: 30rpx; - - + line-height: 30rpx } .hang { width: 100%; margin: auto; padding-left: 21rpx; } + .fs28{ font-size: 28rpx; } @@ -55,6 +54,11 @@ color: #b9b9b9; .hang .collect { width: 347rpx; height: 495rpx; +} + +.hang .collect { + width: 347rpx; + height: 571rpx; border-radius: 25rpx; border: 1rpx solid rgb(214, 214, 214); overflow: hidden; @@ -72,7 +76,7 @@ color: #b9b9b9; } .collect .money { - margin-top: 30rpx; + margin-top: 60rpx; margin-bottom: 18rpx; line-height: 28rpx; align-items: baseline; 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/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index 7f8d9b3..7518033 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -35,7 +35,7 @@ - + @@ -45,7 +45,8 @@ 不包含运费 - + + diff --git a/pages/cart/cart/cart.wxss b/pages/cart/cart/cart.wxss index 2a62032..7274c90 100644 --- a/pages/cart/cart/cart.wxss +++ b/pages/cart/cart/cart.wxss @@ -107,6 +107,7 @@ page { font-size: 28rpx; color: #666; background-color: #f0f2f5; + z-index: 9999999 } .pay-for .pay-btn { diff --git a/pages/cart/cart2/cart2.wxss b/pages/cart/cart2/cart2.wxss index f1710ad..972ae94 100644 --- a/pages/cart/cart2/cart2.wxss +++ b/pages/cart/cart2/cart2.wxss @@ -201,7 +201,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 { diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index b7a0545..c5e07d3 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,167 @@ 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, }, //------初始化加载---------- 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 +410,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 +454,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 +467,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 +519,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 +548,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 +597,8 @@ Page({ }); this.data.enterAddressPage && (this.data.enterAddressPage = !1); + + }, enterAddress: function() { this.data.enterAddressPage = !0, wx.navigateTo({ @@ -528,8 +606,8 @@ Page({ }); }, onUnload: function() {}, - onHide:function(){ - this.data.is_timer=0; + onHide: function() { + this.data.is_timer = 0; }, //----------三个选项按钮----------- tabClick: function(t) { @@ -550,9 +628,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 +642,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 +692,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 +709,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 +789,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 +811,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(); } }); } @@ -815,11 +894,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 +911,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 +919,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 +946,6 @@ Page({ }) }, - closeSpecModal: function() { this.setData({ openSpecModal: !1, @@ -874,10 +953,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,10 +978,11 @@ 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 { @@ -901,7 +991,8 @@ Page({ success: function(e) { if (e.data.code == 0) { t.setData({ - is_collect: 0,collect_id: 0, + is_collect: 0, + collect_id: 0, }); } } @@ -933,21 +1024,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 +1061,7 @@ Page({ } }); }, + previewCommentImgs: function(t) { var e = this.data.comments[t.currentTarget.dataset.cidx].img; wx.previewImage({ @@ -977,6 +1069,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 +1126,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 +1135,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 +1196,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 +1330,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 +1416,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 +1495,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 +1519,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 +1528,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 +1567,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 +1619,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 +1628,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 +1638,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 +1648,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 +1670,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 +1731,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 +1763,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 +1817,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 +1922,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 +1964,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 +2007,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 +2016,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 +2034,7 @@ Page({ }); } - } - else{ + } else { th.setData({ is_normal: ind, openSpecModal_pt: 1 @@ -1855,30 +2047,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 +2096,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 +2143,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 +2169,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 +2184,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 +2210,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 +2224,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 +2239,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) { + 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; - } + if (ee.data.code == "-1") { + app.my_warnning("不能给自己点赞", 0, th); + th.data.iszaning = 0; + return; + } - 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); - } + 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); - setTimeout(function(){ - th.data.iszaning = 0; - },500) - - } - }) - }, + } 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) + + } + }) + }, /*----券的开关---*/ - 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 +2480,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 +2497,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 +2533,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 +2563,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 +2571,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 +2583,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 +2618,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 +2673,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 +2713,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 +2742,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 +2763,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 +2789,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 +2849,409 @@ 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(); }, //--跳转到商品详情页面-- - 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, + + openSpecModal_pt:1 + }); + } + + 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); + } + + } + }); + + 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..2e3fd81 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 @@ - + 确定 + + + + + + + + + {{choice_sort_store==0?'附近的门店':region_name}} + + + + + + {{choice_sort_store==0?'更多门店':'返回'}} + + + + + + + + + + + + + + + Г + + + + + + + + {{item.pickup_name}} + + + + 距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+'km':filters.toFix(item.distance,0)+"m"}} + + + 地址:{{item.fulladdress}} + + + + + + + + + + Г + + + + + + + + + {{item.pickup_name}} + + + 距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}} + + + + 地址:{{item.fulladdress}} + + + + + + + + + + + Г + + + + + + + + + {{item.pickup_name}} + + + 距离:{{item.distance>1000?filters.toFix(item.distance/1000,2)+"km":filters.toFix(item.distance,0)+"m"}} + + + 地址:{{item.fulladdress}} + + + + + + + + + + + 确定 + 设为默认 + + + + + + + + + 门店分类选择 + + + + + + 返回 + + + + + + + + {{item.name}} + + + + + + + + + + + + - - \ No newline at end of file diff --git a/pages/goods/goodsInfo/goodsInfo.wxss b/pages/goods/goodsInfo/goodsInfo.wxss index c619b24..f35dc7d 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxss +++ b/pages/goods/goodsInfo/goodsInfo.wxss @@ -26,6 +26,9 @@ image { } .type-navbar-item { border-bottom: 4rpx solid #fff; + display: flex; + justify-content: center; + width: 100%; } .type-item-on { border-bottom: 4rpx solid #333; @@ -282,6 +285,7 @@ image { width: 150rpx; height: 150rpx; margin-top: 8rpx; + margin-right: 10rpx; } .comment-btn { @@ -321,6 +325,9 @@ image { height: 100rpx; background-color: #fff; text-align: center; + z-index: 9; + border-top: 4rpx solid #eee; + } .join-cart>view { @@ -355,7 +362,7 @@ image { .cart-num { position: absolute; left: 50%; - top: 0; + top: 1rpx; width: 40rpx; height: 40rpx; line-height: 40rpx; @@ -368,11 +375,19 @@ image { .cart-btn { font-size: 28rpx; color: #fff; - line-height: 100rpx; + line-height: 70rpx; + margin-top: 16rpx; + + } .join-btn { background-color: #ffb03f; + height: 70rpx; +border-radius: 55rpx 0rpx 0rpx 55rpx; +margin-top: 16rpx; + + } view.cart-btn-lg { @@ -381,6 +396,9 @@ view.cart-btn-lg { .buy-btn { background-color: #f23030; + height: 70rpx; +border-radius: 0 56rpx 55rpx 0; + } .toTop { @@ -505,24 +523,23 @@ view.cart-btn-lg { /* padding: 0 30rpx; */ font-size: 32rpx; box-sizing: border-box; - + border-radius: 20rpx; + height: 72%; } .spec-model .pding{padding: 0 30rpx;} .spec-goods { - padding: 15rpx 0 10rpx; + padding: 30rpx 0 20rpx; float: left; width: 100%; - border-bottom: 1px solid #f8f8f8; + border-bottom:2rpx solid #eee; } .spec-img { float: left; height: 186rpx; width: 186rpx; - position: relative; - top:-40rpx; border: 4rpx solid #eee } @@ -542,7 +559,7 @@ view.cart-btn-lg { } .spec-goods-price { - color: #ec5151; + color: #d60021; font-size: 33rpx; font-weight: bold; } @@ -551,6 +568,7 @@ view.cart-btn-lg { margin-top: 3rpx; font-size: 24rpx; color: #999999; + margin-right: 15rpx; } .spec-name { @@ -568,7 +586,7 @@ view.cart-btn-lg { position: fixed; display: flex; height: 50rpx; - border: 1rpx solid #f8f8f8; + border: 1rpx solid #000; font-size: 28rpx; right: 30rpx; } @@ -581,15 +599,15 @@ view.cart-btn-lg { text-align: center; } .spec_bt{ - background: fff;color: #333; margin-left: 10rpx;padding: 8rpx 12rpx; border-radius: 5px;font-size: 24rpx;border: 1rpx solid #ccc; + background: fff;color: #333; margin-left: 10rpx;padding: 4rpx 15rpx 4rpx; border-radius:30rpx;font-size: 24rpx;border: 1rpx solid #ccc; } -.spec_bt.act{background: #C4182E;color: #fff;border: 1rpx solid #C4182E;} +.spec_bt.act{background: #d60021;color: #fff;border: 1rpx solid #d60021;} .sub { - border-right: 1px solid #ddd; + border-right: 1px solid #000; } .add { - border-left: 1px solid #ddd; + border-left: 1px solid #000; } .spec-btn { @@ -611,22 +629,24 @@ view.cart-btn-lg { } .spec-cart-btns { - /* background-color: #f8f8f8; - margin: 40rpx -30rpx 0; - padding: 20rpx 34rpx; */ - float: left; - width: 100%; - line-height: 80rpx; - margin-top: 40rpx; + width: 92%; + line-height: 70rpx; + margin: 0rpx auto; + margin-top: 160rpx; + border-radius: 20rpx; +position: fixed; +bottom: 50rpx; +left: 4%; + } .spec-cart-btn { - float: left; - width: 100%; + + width:100%; font-size: 30rpx; text-align: center; color: white; - border-radius: 4rpx; + border-radius: 40rpx; } .spec-add-cart { @@ -718,7 +738,8 @@ left:31rpx;} .pt_fir .pt_fir_title .js{padding: 0 15rpx;height: 40rpx;background:#e9030d; text-align: center; border-radius: 8rpx; color: #fff; margin-left: 10rpx;} .pt_fir .pt_fir_title .tuannum{color: #e9030d; position: absolute; right: 20rpx; font-size: 26rpx;} -.pding{padding-top: 20rpx;padding-left: 20rpx; padding-right: 20rpx;font-size: 26rpx;color: #ea120f} +.pding{padding-top: 20rpx;padding-left: 20rpx;height: 81%; + padding-right: 20rpx;font-size: 26rpx;color: #ea120f} .pdres{margin-left: 10rpx;color: #8f8f94} .ptgz{position: relative;font-size: 30rpx;padding-left: 20rpx;margin-top: 10rpx; overflow: hidden } .shuxian{width: 6rpx;height: 28rpx; background: #ea120f; display: inline-block;top: 5rpx;position: relative; margin-right: 5rpx} @@ -741,7 +762,7 @@ left:31rpx;} .wf .item .item_txy.hs{ background: #cbcbcb;} .po{margin-bottom: 20rpx;} -.cart-btn.line-h{ line-height: 40rpx;} +.cart-btn.line-h{ line-height: 26rpx;} .cart-btn .fir-v{ margin-top: 10rpx;} .hyt{ padding: 0 20rpx; font-size: 30rpx; display: flex; align-items:center; margin-top: 10rpx;} @@ -777,7 +798,7 @@ left:31rpx;} .juzhong .xq .title .close{position: absolute;top: 0; right: 0; width: 45rpx; height: 45rpx;} .pt_qd{margin-top: 40rpx; height: auto;} -.spec-cart-btn.w100{width: 100%; margin-left: 0; height: 80rpx; line-height: 80rpx;} +.spec-cart-btn.w100{width: 95%; margin-left: 0; height: 75rpx; line-height:75rpx;margin: auto; } .sto_v{color: #333;} .ellipsis{overflow: hidden; white-space: nowrap; text-overflow: ellipsis;} @@ -927,14 +948,13 @@ left:31rpx;} border-bottom: 3rpx solid #eee; border-top: 3rpx solid #eee; line-height: 100rpx } .bb_view{ display: flex;align-items: center;justify-content: space-between; padding: 0 34rpx; color: #333; - font-size: 32rpx; height: 104rpx; line-height: 104rpx; overflow: hidden; padding-right:31rpx } + font-size: 32rpx; height: 104rpx; line-height: 104rpx; overflow: hidden; padding-right:26rpx } .red_bb{ color: #d70026; min-width:158rpx;width: auto;} .bg_jj{ width: 18rpx; height:18rpx; border-top: 2rpx solid #d70026; border-right: 2rpx solid #d70026; transform: rotate(45deg);display:inline-block; margin-bottom:3rpx; - } /* 顶部边框 */ .topframe{ @@ -952,7 +972,7 @@ left:31rpx;} margin-bottom: 36rpx; color: #7d7d7d; padding-left: 20rpx; - font-size: 28rpx; + font-size: 32rpx; } /*评价人数量*/ .topframe .topframe-top .topframe-top-val{ @@ -980,7 +1000,7 @@ left:31rpx;} .buttem-list .item{ min-width: 17%; - font-size: 23rpx; + font-size: 24rpx; border-radius: 20rpx; background:#ffe3e2; height:38rpx; @@ -996,16 +1016,11 @@ left:31rpx;} /* 用户评价 */ .middle{ - width: 95%; - height:auto; - margin:0 auto; - - } .middle-img-frame{ - height:65rp; + height:65rpx; display: flex; margin-top: 32rpx; @@ -1035,11 +1050,13 @@ left:31rpx;} text-align: center; margin-bottom:20rpx; margin-left:5rpx; - +} +.xc-pirces{ + margin-top: 14rpx; } /* 评价文字 */ .middle-font{ - font-size: 24rpx; + font-size: 30rpx; } .iddle-goods-img{ @@ -1065,11 +1082,12 @@ left:31rpx;} height: 45rpx; display:flex; line-height: 45rpx; + margin-top: 20rpx; margin-bottom: 14rpx; justify-content : space-between; } .parameter-font{ - font-size: 24rpx; + font-size: 26rpx; } /* 规格 */ @@ -1091,13 +1109,13 @@ left:31rpx;} } /* 点赞图片 */ .parameter-img{ - width: 25rpx; - height: 25rpx; + width: 27rpx; + height: 27rpx; margin-top: 3rpx; } .parameter-val{ margin-left:25rpx; - font-size: 24rpx; + font-size: 26rpx; color: #999; } /* 回复 */ @@ -1170,7 +1188,7 @@ left:31rpx;} width: 524rpx; margin-left: 34rpx; border-radius: 25rpx; - border: 1rpx solid #d6d4d5; + border: 2rpx solid #d6d4d5; overflow: hidden; } @@ -1197,19 +1215,20 @@ left:31rpx;} margin-right: 5rpx } .xc_comment-font{ - height: 85rpx; + height: 75rpx; margin-left: 22rpx; white-space:normal; overflow: hidden; margin-top: 8rpx; + } .xc_comment-val{ width: 88%; height: 30rpx; margin-left: 22rpx; display: flex; - margin-top: 28rpx; - margin-bottom:8rpx; + margin-top: 15rpx; + margin-bottom:15rpx; } .xc_comment-time{ @@ -1266,7 +1285,7 @@ left:31rpx;} height: 100%; line-height: 100rpx; overflow: hidden; - margin-left: 7rpx; + margin-left: 10rpx; } .xc-coupon-fram{ position: relative; @@ -1306,7 +1325,7 @@ left:31rpx;} padding-left:15rpx; color: #d70025; position: absolute; - right: 7rpx; + right: 5rpx; } /* 自定义弹出窗口 */ @@ -2221,9 +2240,247 @@ right:17rpx; top:55rpx; .pd_top1{padding-top: 10rpx} .s_ms_bth{margin-top: 85rpx} -.xc-pirces{ - height:40rpx; - line-height:15rpx; + +.no_pj_list{text-align: center; width: 100%; color: #999; margin: 30rpx 0; display: inline-block; font-size: 28rpx} +/* 门店地址 */ +.xc-address_frame{ + border-top:1rpx solid #eee; + width: 100%; + height: auto; +} +.on_height{ +height: 90rpx; +} +.sn_height{ + height: 170rpx; +} +.xc-address_frame .address_frame{ + width: 92%; +padding-left: 10rpx; +margin: auto; + +} +.shop_name{ + +} +.stores-img{ +width: 40rpx; + height: 35rpx; + margin-right: 10rpx; +} +.shop_name{ + margin-right: 10rpx; +} +.address{ + width: 87%; + margin-top: 5rpx; + margin-bottom: 5rpx; +} +.distance{ + padding-left: 15rpx; + padding-right: 15rpx; + background: #eee; + border-radius: 20rpx; + margin-right: 5rpx; + color: #999; + height: 38rpx; +line-height: 38rpx; + +} +/* 选择门店的弹窗 */ +.mongolia-layer{ + position: fixed; +left: 0; +top: 0; +right: 0; +bottom: 0; +z-index: 11; +background: rgba(0,0,0,0.4); +width: 100%; +height: 91.9%; + +} +.popup-frame{ + position: fixed; +bottom:99rpx; +z-index: 20; +background: white; +width: 100%; +border-radius: 20rpx 20rpx 0 0; +height: 72%; +} +.popup-top{ + border-bottom: 1rpx solid #eee; + height: 155rpx; + width: 95%; + margin: auto; + line-height: 155rpx; + +} +.bg_rights{ + border-top: 2rpx solid ; + border-right: 2rpx solid ; + transform: rotate(45deg); + display:inline-block; + width:15rpx;height:15rpx; + border-color:#da0b31; +} +.modal-closes { + position: absolute; + right: 30rpx; + top: -15rpx; + height: 25rpx; + +} +.choose_more{ + margin-top: 40rpx; + margin-right: 20rpx; + +} +.choose_mores{ + margin-top: 30rpx; + margin-right: 15rpx; + +} +.store-list{ + width: 95%; + height: 72%; + overflow-y: scroll; + margin: auto; +} +.store-list .store_choose{ + width: 100%; + height: 120rpx; + line-height: 125rpx; + border-bottom: 1rpx solid #eee; + +} +.store-list .store_choose .store{ +width: 100%; +margin: auto; +line-height: 37rpx; +padding-left: 20rpx; + +} +.xc-hook{ + width: 35rpx; + height: 35rpx; + transform: rotate(-145deg); +line-height: 37rpx; +text-align: center; +} + .xc-hooks{ + width: 30rpx; + height: 30rpx; + border: 1rpx solid #999; + } + .address-frame{ + width: 93%; +margin-left: 7rpx; + + } + .nearby_store{ +margin-left: 17rpx; + } + .address_name{ + margin-right: 10rpx; + + } + .address-val{ + height: 38rpx; +line-height: 38rpx; + + } + .store-bottom{ + width: 85%; + margin: auto; + height: 70rpx; + } + .determine{ + width: 260rpx; + height: 55rpx; + border-radius: 50rpx; + line-height: 55rpx; + } + .default{ + width: 260rpx; + height: 55rpx; + border:3rpx solid #c8c8c8; + border-radius: 50rpx; + line-height: 55rpx; + } + .store-bottom-frame{ + width: 95%; + margin: auto; + + } + /* 门店分类列表 */ +.sort_store_list{ + height: 82%; + overflow: hidden; + overflow-y: scroll; + width: 95%; + margin: auto; +} +.sort_store_list .sort-store-frame{ + width: 100%; +height: 100rpx; +line-height:100rpx; +border-bottom: 1rpx solid #eee; + +} +.sort_store_list .sort-store-frame .sort-store{ + width: 94.5%; + margin: auto; +} +.black_rights-frame{ +width: 50%; +} +.black_rights-frame .black_rights{ + border-top: 3rpx solid; +border-right: 3rpx solid; +transform: rotate(45deg); +display: inline-block; +width: 20rpx; +height: 20rpx; +} +.xc-val-money{ + height:80rpx; +} + +.xc-distance-bottom{ + margin-bottom: 40rpx; +} +.xc-distance-top{ +margin-top: 10rpx; +} +.xc-width{ + width: 100%; +} +.right-arrow{ width: 15rpx; height:15rpx; + border-top: 2rpx solid #d70026; + border-right: 2rpx solid #d70026; + transform: rotate(45deg);display:inline-block; + margin-bottom:3rpx; +} +.xc-goods-attribute{ + border-bottom: 1px solid #eee; +padding-bottom: 15px; +margin-bottom:40rpx; +} +.xc-val-fream{ + width: 105rpx; +} +.is_stock{ +width: 58%; +height: 70rpx; +border-radius: 55rpx; +} +.select_store_height{ + height: 50rpx; +} +.butttem5{ + margin-bottom: 5rpx; } .no_pj_list{text-align: center; width: 100%; color: #999; margin-top: 30rpx; display: inline-block; font-size: 28rpx} @@ -2233,3 +2490,4 @@ right:17rpx; top:55rpx; width: 58%; background-color: #adadad; } +.s_btn{ margin-top: 25rpx; } diff --git a/pages/index/index/index.js b/pages/index/index/index.js index a9818b4..1bebb37 100644 --- a/pages/index/index/index.js +++ b/pages/index/index/index.js @@ -1,6 +1,6 @@ var e = function (e) { return e && e.__esModule ? e : { - default: e + default: e }; }(require("../../../utils/LoadMore.js")), t = getApp(), a = t.request, o = t.globalData.setting, os = o, i = require("../../../utils/util.js"), ut = i, s = require("../../../utils/common.js"), n = new e.default(); diff --git a/pages/user/add_comment/add_comment.js b/pages/user/add_comment/add_comment.js index a7af5d9..ba233b8 100644 --- a/pages/user/add_comment/add_comment.js +++ b/pages/user/add_comment/add_comment.js @@ -1,130 +1,217 @@ -var t = getApp(),oo=t.globalData, a = t.globalData.setting,os=a, e = t.request, s = require("../../../utils/util.js"), - i = require("../../../utils/selectFiles.js"); +var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../utils/util.js"), + i = require("../../../utils/selectFiles.js"); var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ - data: { - url: a.url, - resourceUrl: a.resourceUrl, - iurl: a.imghost, - defaultPhoto: a.resourceUrl + "/static/images/camera.png", - filePaths: [], - uploadPath: [], - maxWord: 0, - is_anonymous: !1, - goods_rank: 0, - service_rank: 0, - deliver_rank: 0, - content: "", - options: null, - isLongPress: !1, - userinfo:null, - }, - onLoad:async function(a) { - var th=this; - console.log('onLoad'); - console.log(a); + data: { + url: a.url, + resourceUrl: a.resourceUrl, + iurl: a.imghost, + defaultPhoto: a.resourceUrl + "/static/images/camera.png", - await getApp().request.promiseGet("/api/weshop/goods/get/"+os.stoid+"/"+a.goods_id,{1:1}).then(res=>{ - a.img=th.data.iurl+res.data.data.original_img - }) + uploadPath: [], //上传后文件路径 + maxWord: 0, + is_anonymous: !1, + goods_rank: 0, + service_rank: 0, + deliver_rank: 0, + content: "", + options: null, + isLongPress: !1, + userinfo: null, + imgs: [], //本地文件再上传时的路径 + lenMore:0 + }, + onLoad: async function (a) { + var th = this; + await getApp().request.promiseGet("/api/weshop/ordergoods/pageGoods", { data:{store_id:os.stoid,goods_id:a.goods_id, order_id:a.order_id}}).then(res => { - - this.setData({options: a}); - t.getUserInfo(function(e){ - console.log(e); - th.setData({ - userinfo:e - }) - }) - }, - keyUpChangeNum: function(t) { - this.setData({ - maxWord: t.detail.value.length - }), this.data.content = t.detail.value; - }, - checkAnonymous: function() { - this.setData({ - is_anonymous: !this.data.is_anonymous - }); - }, - checkGoodsRank: function(t) { - this.setData({ - goods_rank: parseInt(t.currentTarget.dataset.i) + 1 - }); - }, - checkServiceRank: function(t) { - this.setData({ - service_rank: parseInt(t.currentTarget.dataset.i) + 1 + a.img = th.data.iurl + res.data.data.pageData[0].original_img; + a.goods_name=res.data.data.pageData[0].goods_name; + a.goods_num=res.data.data.pageData[0].goods_num; + }) + this.setData({ options: a }); + t.getUserInfo(function (e) { + console.log(e); + th.setData({userinfo: e}) + }) + }, + keyUpChangeNum: function (t) { + this.setData({ + maxWord: t.detail.value.length + }), this.data.content = t.detail.value; + }, + checkAnonymous: function () { + this.setData({ + is_anonymous: !this.data.is_anonymous + }); + }, + checkGoodsRank: function (t) { + this.setData({ + goods_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + checkServiceRank: function (t) { + this.setData({ + service_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + checkDeliverRank: function (t) { + this.setData({ + deliver_rank: parseInt(t.currentTarget.dataset.i) + 1 + }); + }, + selectPhotos: function (t) { + if (this.data.isLongPress) this.data.isLongPress = !1; else { + var a = this; + i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function (t) { + a.setData({ + filePaths: t }); - }, - checkDeliverRank: function(t) { - this.setData({ - deliver_rank: parseInt(t.currentTarget.dataset.i) + 1 - }); - }, - selectPhotos: function(t) { - if (this.data.isLongPress) this.data.isLongPress = !1; else { - var a = this; - i.selectPhotos(this.data.filePaths, t.currentTarget.dataset.idx, function(t) { - a.setData({ - filePaths: t - }); - }); + }); + } + }, + removePhoto: function (t) { + var a = this; + this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function (t) { + a.setData({ + filePaths: t + }); + }); + }, + submitComment: function () { + var a = this; + if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) + return getApp().my_warnning("请先打分",0,a); + if(a.data.content=="") + return getApp().my_warnning("请填写评价内容",0,a); + + //this.uploadPhotos(function () { + var p_data= { + email: ' ', + is_show: 1, + goods_rank: a.data.goods_rank, + service_rank: a.data.service_rank, + deliver_rank: a.data.deliver_rank, + content: a.data.content, + goods_id: a.data.options.goods_id, + order_id: a.data.options.order_id, + user_id: oo.user_id, + store_id: os.stoid, + username: a.data.userinfo.nickname, + source_type:1 + } + if(a.data.uploadPath){ + p_data['weapp_img']=JSON.stringify(a.data.uploadPath); + } + if(a.data.is_anonymous){ + p_data['is_anonymous']=1; + } + + e.post("/api/weshop/comment/savecomment", { + data:p_data, + success: function (a) { + wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function () { + wx.navigateBack(); + }); } - }, - removePhoto: function(t) { - var a = this; - this.data.isLongPress = !0, i.removePhoto(this.data.filePaths, t.currentTarget.dataset.idx, function(t) { - a.setData({ - filePaths: t - }); - }); - }, - submitComment: function() { - var a = this; - if (!a.data.service_rank || !a.data.goods_rank || !a.data.deliver_rank) return t.showWarning("请先打完分~"); - this.uploadPhotos(function() { - e.post("/api/weshop/comment/savecomment", { - data: { - email:' ', - is_show:1, - goods_rank: a.data.goods_rank, - service_rank: a.data.service_rank, - deliver_rank: a.data.deliver_rank, - content: a.data.content, - goods_id: a.data.options.goods_id, - order_id: a.data.options.order_id, - user_id: oo.user_id, - store_id:os.stoid, - username: a.data.userinfo.nickname - }, - success: function(a) { - wx.setStorageSync("user:comment:update", !0), t.showSuccess("评论成功", function() { - wx.navigateBack(); - }); - } - }); - }); - }, - uploadPhotos: function(t, a) { - if (0 == this.data.filePaths.length) return t(); - if ("number" != typeof a) a = 0; else if (a >= this.data.filePaths.length) return t(); - var s = this; - e.uploadFile("/api/user/upload_comment_img", { - filePath: s.data.filePaths[a], - name: "img_file", - success: function(e) { - s.data.uploadPath[a] = e.data.result, s.uploadPhotos(t, a + 1); - } - }); - }, + }); + //}); + }, + - //图片失败,默认图片 - bind_bnerr2: function (e) { + uploadPhotos: function (t, a) { + if (0 == this.data.imgs.length) return t(); + if ("number" != typeof a) a = 0; else if (a >= this.data.imgs.length) return t(); + var s = this; + e.uploadFile("/api/weshop/comment/uploadCommentImg", { + filePath: s.data.imgs[a], + name: "file", + success: function (e) { + console.log("uploadPhotos"); + console.log(e.data); + if(e.data.code==0) + s.data.uploadPath[a] = e.data.data, s.uploadPhotos(t, a + 1); + } + }); + }, + + //图片失败,默认图片 + bind_bnerr2: function (e) { var _errImg = e.target.dataset.errorimg; var _errObj = {}; - _errObj[_errImg] = a.imghost+"/public/images/default_goods_image_240.gif"; + _errObj[_errImg] = a.imghost + "/public/images/default_goods_image_240.gif"; this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } + }, + // 上传图片 + chooseImg: function (e) { + var that = this; + var imgs = this.data.imgs; + if (imgs.length >= 3){ + if(this.data.lenMore==0){ + this.setData({ lenMore: 1 }); + } + return false; + } + + var imgs = this.data.imgs; + + wx.chooseImage({ + count: 1, // 默认9 + sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 + sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 + success: function (res) { + // 返回选定照片的本地文件路径列表,tempFilePath可以作为img标签的src属性显示图片 + var tempFilePaths = res.tempFilePaths; + + getApp().request.uploadFile("/api/weshop/comment/uploadCommentImg", { + filePath: tempFilePaths[0], + name: "file", + success: function (e) { + if(e.data.code==0) { + that.data.uploadPath.push(e.data.data); + imgs.push(tempFilePaths[0]); + that.setData({ + imgs: imgs + }); + } + } + }); + } + }); + }, + // 删除图片 + deleteImg: function (e) { + var imgs = this.data.imgs; + var index = e.currentTarget.dataset.index; + imgs.splice(index, 1); + this.setData({ + imgs: imgs + }); + }, + // 预览图片 + previewImg: function (e) { + //获取当前图片的下标 + var index = e.currentTarget.dataset.index; + //所有图片 + var imgs = this.data.imgs; + wx.previewImage({ + //当前显示图片 + current: imgs[index], + //所有图片 + urls: imgs + }) + }, + + txtInpt:function (e) { + this.setData({ + content: e.detail.value + }) + }, + + onUnload: function () { + wx.navigateBack({ delta:1 }) + }, + + }); \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.json b/pages/user/add_comment/add_comment.json index 1387a9a..401e4e6 100644 --- a/pages/user/add_comment/add_comment.json +++ b/pages/user/add_comment/add_comment.json @@ -1,4 +1,7 @@ { - "navigationBarTitleText": "评价晒单", - "enablePullDownRefresh": false + "navigationBarTitleText": "评价宝贝", + "enablePullDownRefresh": false, + "usingComponents": { + "warn": "/components/long_warn/long_warn" + } } \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.wxml b/pages/user/add_comment/add_comment.wxml index 8c24cca..e4f7f9f 100644 --- a/pages/user/add_comment/add_comment.wxml +++ b/pages/user/add_comment/add_comment.wxml @@ -1,51 +1,114 @@ - - - - - - {{options.goods_name}} - ¥{{options.price}} - - - - - {{maxWord}}/500 - + + + + + + + + + {{options.goods_name}} + + + + + + {{options.price}} + + + + + x + {{options.goods_num}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + 添加图片 + {{imgs.length>0?imgs.length:0}}/3 + + + + - - - - - - 评分 - 满意请给5分哦 + + + + + + + + 宝贝评分 - - 商品符合度 - - + + + + + 描述相符 + + + + - - - 店家服务态度 - - + + + + 物流服务 + + + + - - - 物流发货速度 - - + + + 服务态度 + + + + + + + + + - - 提 交 + + + + + + 匿名评价 + + + + 提交评价 + + + + \ No newline at end of file diff --git a/pages/user/add_comment/add_comment.wxss b/pages/user/add_comment/add_comment.wxss index c6f31b8..43c1670 100644 --- a/pages/user/add_comment/add_comment.wxss +++ b/pages/user/add_comment/add_comment.wxss @@ -1,122 +1,162 @@ -.goods-mes { - height: 100rpx; - display: flex; - padding: 30rpx; - justify-content: space-between; +page{ + overflow-x: hidden; +} +/* 商品详情和评价 */ +.commoditymax{ + overflow-x: hidden; +} +.commodity { + height: 715rpx; + border-top: 6rpx solid rgb(245, 245, 245); + border-bottom: 6rpx solid rgb(245, 245, 245); + padding: 0rpx 30rpx; +} + +.commodity .information { + height: 286rpx; +} + +.commodity .information image { + width: 186rpx; + height: 186rpx; +} + +.information .goods_name { + width: 480rpx; + margin-left: 25rpx; + height: 186rpx; +} + +.information .goods_name .ellipsis-2 { + line-height: 40rpx; + height: 80rpx; } -.goods-img { - width: 100rpx; - height: 100rpx; - overflow: hidden; +.information .goods_name .jc_sb { + margin-top: 60rpx; + color: rgb(212, 28, 52); + margin-right: 7rpx; } -.goods-des { - width: 560rpx; +.information .goods_name .jc_sb .fs32 { + line-height: 40rpx; } -.goods-des>view { - width: 100%; - height: 32rpx; - line-height: 1; - font-size: 32rpx; - color: #444; +.information .goods_name .jc_sb .sum { + margin-right: 5rpx; } -.goods-package { - margin-top: 36rpx; +.balin { + align-items: baseline; } -.evaluation { - padding: 30rpx 30rpx; - position: relative; - font-size: 28rpx; +.addComment { + height: 345rpx; + width: 690rpx; + background-color: rgb(248, 248, 248); + padding: 32rpx 0rpx 21rpx 0rpx; } -.word-box { - color: #444; - line-height: 40rpx; - width: 100%; - height: 200rpx; +.addComment textarea { + padding: 0rpx 18rpx; + height: 175rpx; + width: 654rpx; } -.words-num { - position: absolute; - right: 30rpx; - bottom: 30rpx; - color: #777; +.addComment .addimages { + padding: 0rpx 18rpx; + margin-top: 20rpx; + align-items: flex-end; + width: 652rpx; } -.pic-list { - padding: 40rpx 20rpx 20rpx; - display: flex; - justify-content: space-around; +.addComment .addimages .images { + height: 140rpx; } -.share-pic { - width: 126rpx; - height: 126rpx; - border: 1px solid #ddd; - overflow: hidden; +.addComment .addimages .images .rel { + width: 140rpx; + height: 100%; + overflow: visible; + margin-right: 15rpx; } -.anonymous { - height: 60rpx; - padding: 0 20rpx 20rpx; - background-color: #fff; - display: flex; - align-items: center; - font-size: 30rpx; - color: #777; +.addComment .addimages .images image .abs { + width: 30rpx; + height: 30rpx; + top: -7rpx; + right: -7rpx; } -.anonymous>icon { - margin-right: 20rpx; +.addComment .addimage { + width: 139rpx; + height: 139rpx; + border: 2rpx dashed rgb(196, 196, 196); + font-size: 16rpx; + margin-left: 6rpx; } -.score-list { - margin-top: 20rpx; +.addComment .addimage image { + width: 60rpx; + height: 58rpx; } -.score-list>view { - display: flex; - justify-content: space-between; - font-size: 30rpx; - color: #444; +.Grade { + width: 100%; + height: 310rpx; + border-bottom: 6rpx solid rgb(245, 245, 245); + padding-left: 45rpx; } -.score-title { - height: 90rpx; - line-height: 90rpx; - border-bottom: 1px solid #eee; +.Grade .title { + width: 100%; + height: 105rpx; } -.score-item { - align-items: center; - height: 80rpx; +.Grade .title .column { + height: 30rpx; + border-left: 6rpx solid rgb(211, 27, 58); + margin-right: 12rpx; } -.stars { - display: flex; +.Grade .score-item { + height: 55rpx; + line-height: 55rpx; } -.stars image { - width: 44rpx; - height: 40rpx; +.Grade .score-item .stars { + margin-left: 83rpx; +} +.Grade .score-item .stars view{ + width: 60rpx; + height: 55rpx; +} + +.Grade .score-item .stars image { + width: 35rpx; + height: 35rpx; +} +.Whether { + padding:0rpx 31rpx; +} +.Whether .flex-right-vertical { + height: 67rpx; } -.btn-wrap { - padding: 20rpx 0; - background-color: #fff; - border-top: 1px solid #eee; +.Whether .flex-right-vertical .radio { + margin-right: 15rpx; } -.submit-btn { - width: 320rpx; - height: 80rpx; - line-height: 80rpx; - text-align: center; - background-color: #f15353; - color: #fff; - margin: auto; -} \ No newline at end of file +.Whether .Submission { + margin: 40rpx 0 40rpx 0; +} + +.Whether .white { + width: 364rpx; + height: 58rpx; + background-color: rgb(212, 28, 52); + border-radius: 40rpx; + line-height: 58rpx; +} + + diff --git a/pages/user/collect_list/collect_list.js b/pages/user/collect_list/collect_list.js index fcd4668..0cc324b 100644 --- a/pages/user/collect_list/collect_list.js +++ b/pages/user/collect_list/collect_list.js @@ -1,56 +1,285 @@ var t = function(t) { return t && t.__esModule ? t : { - default: t + default: t }; -}(require("../../../utils/LoadMore.js")), e = getApp(), a = e.request, o = new t.default(); -var oo = e.globalData.setting, app_d = e.globalData; + }(require("../../../utils/LoadMore.js")), + e = getApp(), + a = e.request, + o = new t.default(); +var oo = e.globalData.setting, + app_d = e.globalData; Page({ - data: { - url: e.globalData.setting.imghost, - resourceUrl: e.globalData.setting.resourceUrl, - iurl: e.globalData.setting.imghost, - collects: null, - currentPage: 1 - }, - onLoad: function() { - o.init(this, "", "collects"), this.requestCollectList(); - }, - requestCollectList: function() { - var t = this, e = "/api/weshop/goodscollect/list?pageSize=10&user_id=" - +app_d.user_id+"&store_id=" + oo.stoid+"&page=" + t.data.currentPage; - o.request(e, function(e) { - console.log("requestCollectList"); - console.log(e); - t.data.currentPage++; - }); - }, - onReachBottom: function() { - o.canloadMore() && this.requestCollectList(); - }, - cancelCollect: function(t) { - var e = t.currentTarget.dataset.id, o = this; - a.delete("/api/weshop/goodscollect/del/" + oo.stoid+"/"+e, { - success: function(t) { - o.deleteItemData(e); - } + data: { + url: e.globalData.setting.imghost, + resourceUrl: e.globalData.setting.resourceUrl, + iurl: e.globalData.setting.imghost, + collects: null, + currentPage: 1, + curpage: 1, + ismore: 0, + iscollects: 0, + editEd: 0, //商品编辑按钮是否点击 + isall: false, //是否全选 + sum: 0, + total_collects: 0, + is_goods: 0, + pageSize: 8, //分页数量 + isdelete: 0 + }, + onLoad: function() { + o.init(this, "", "collects"), + this.requestCollectList(); + }, + requestCollectList: function() { + var th = this; + e = "/api/weshop/goodscollect/list?" + "pageSize=" + th.data.pageSize + "&user_id=" + + app_d.user_id + "&store_id=" + oo.stoid + "&page=" + th.data.currentPage; + o.request(e, function(e) { + th.data.currentPage++; + if (th.data.total_collects == 0) { + th.setData({ + iscollects: 1, + total_collects: e.data.data.total + }) + } + if (th.data.total_collects < th.data.pageSize) { + + th.setData({ + is_goods: 1 + }) + var goods_list = th.selectComponent("#goods_recommend"); //组件的id + goods_list.get_list(); + + + } + }); + }, + + //--到底部刷新--- + onReachBottom: function() { + if ((this.data.currentPage - 1) * this.data.pageSize < this.data.total_collects) { + this.requestCollectList(); + } else { + if (this.data.is_goods == 0) this.setData({ + is_goods: 1 + }); + var goods_list = this.selectComponent("#goods_recommend"); //组件的id + goods_list.get_list(); + } + + }, + + //--取消收藏--- + cancelCollect: function(t) { + var e = t.currentTarget.dataset.id, + o = this; + a.delete("/api/weshop/goodscollect/del/" + oo.stoid + "/" + e, { + success: function(t) { + o.deleteItemData(e); + } + }); + }, + deleteItemData: function(t) { + for (var e = 0; e < this.data.collects.length; e++) + if (this.data.collects[e].collect_id == t) { + this.data.collects.splice(e, 1), this.setData({ + collects: this.data.collects }); - }, - deleteItemData: function(t) { - for (var e = 0; e < this.data.collects.length; e++) if (this.data.collects[e].collect_id== t) { - this.data.collects.splice(e, 1), this.setData({ - collects: this.data.collects - }); - break; + break; + } + }, + //图片失败,默认图片 + bind_bnerr: function(e) { + var _errImg = e.currentTarget.dataset.errimg; + var _errObj = {}; + _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + + }, + + requestList: function() { + + var e = this; + a.get("/api/weshop/goods/page", { + isShowLoading: 0, + data: { + store_id: 1, + user_id: oo.user_id, + page: e.data.curpage, + pageSize: 10 + }, + success: function(t) { + e.data.curpage++; + var arr1 = e.data.collects_Recommend; + var arr2 = t.data.data.pageData; + var arr3 = [...arr1, ...arr2]; + + var ismore = 0; + if (arr3.length == t.data.data.total) ismore = 1 + + e.setData({ + collects_Recommend: arr3, + total_goods: t.data.data.total, + ismore_goods: ismore, + loadName: null + }), wx.stopPullDownRefresh(); + } + }); + }, + + + goto: function(ee) { + wx.switchTab({ + url: '/pages/index/index/index', + }) + }, + //编辑商品显示 + editcollects: function() { + var th = this.data; + var t = this; + if (th.editEd == 0) { + t.select_checked(false, null) + t.setData({ + editEd: 1, + isall:0 + }) + } else { + t.select_checked(false, null) + t.setData({ + editEd: 0 + }) + } + }, + iconClick: function(e) { + var th = this.data; + var index = e.currentTarget.dataset.index; + var collect = "collects[" + index + "].checked"; + if (this.data.collects[index].checked == true) { + this.setData({ + [collect]: false, + isall: 0, + sum: --th.sum + }) + } else { + var id = th.collects[index].collect_id; + this.setData({ + [collect]: true, + sum: ++th.sum + }) + if (th.sum == th.collects.length) { + this.setData({ + isall: 1 + }) + } + } + }, + //全选为收藏商品checked为true + allClick: function() { + var th = this; + var list = th.data.collects; + //判断是否全选 + if (th.data.isall) { + for (var i = 0; i < list.length; i++) { + list[i].checked = false; + } + this.setData({ + sum: 0, + isall: 0, + collects: list + }) + } else { + for (var i = 0; i < list.length; i++) { + list[i].checked = true; + } + this.setData({ + sum: th.data.collects.length, + collects: list, + isall: 1 + }) + } + }, + + //分页删除 + alldelete: function(e) { + + var th = this; + if (th.data.isdelete) return false; + // 全选的话直接删除 + if (th.data.isall) { + a.delete("/api/weshop/goodscollect/removeUser/" + oo.stoid + "/" + app_d.user_id, { + isShowLoading: 0, + success: function(e) { + th.setData({ + collects: [], + total_collects: 0, + isdelete:0 + }) + getApp().my_warnning("取消成功", 1, th); + } - }, - - //图片失败,默认图片 - bind_bnerr2: function (e) { - var _errImg = e.target.dataset.errorimg; - var th=this; - this.setData({ - [_errImg]: th.data.iurl+"/miniapp/images/default_g_img.gif", + }) + } else { //按照多个id删除收藏商品 + + var new_colls = []; + var collectId = th.data.collects; + + var str = ""; + for (var i = 0; i < th.data.collects.length; i++) { + if (collectId[i].checked) { + str += collectId[i].collect_id + ","; + } else { + new_colls.push(collectId[i]); + } + } + if(str.length==""){ + getApp().my_warnning("请选择商品", 0, th); + return false; + } + th.setData({ + isdelete: 1 + }) + str = str.substr(0, str.length - 1); + var url = "/api/weshop/goodscollect/removeByIds/" + oo.stoid + "/" + app_d.user_id + "/" + str; + + a.delete(url, { + isShowLoading: 0, + success: function(e) { + th.setData({ + collects: new_colls, + sum: 0, + total_collects: new_colls.length, + isdelete: 0 }) + // th.select_checked(false,null); + getApp().my_warnning("取消收藏成功", 1, th); + } + + }) + + } + }, + select_checked: function(check, sum) { + var th = this; + if (sum == null) { + for (var i = 0; i < this.data.collects.length; i++) { + var collect = "collects[" + i + "].checked"; + th.setData({ + [collect]: check, + sum:0 + }) + } + } else { + var collect = "collects[" + sum + "].checked"; + th.setData({ + [collect]: check + }) } + }, + + go_to: function(e) { + var th = this; + var url = e.currentTarget.dataset.url; + getApp().goto(url); + } }); \ No newline at end of file diff --git a/pages/user/collect_list/collect_list.json b/pages/user/collect_list/collect_list.json index a7944ac..64db42e 100644 --- a/pages/user/collect_list/collect_list.json +++ b/pages/user/collect_list/collect_list.json @@ -1,4 +1,8 @@ { "navigationBarTitleText": "我的收藏", - "enablePullDownRefresh": false + "enablePullDownRefresh": false, + "usingComponents": { + "warn": "/components/long_warn/long_warn", + "goods_recommend": "/components/goods_list/goods_list" + } } \ No newline at end of file diff --git a/pages/user/collect_list/collect_list.wxml b/pages/user/collect_list/collect_list.wxml index 226ecfc..3fbf540 100644 --- a/pages/user/collect_list/collect_list.wxml +++ b/pages/user/collect_list/collect_list.wxml @@ -1,21 +1,109 @@ - - - - - - - {{item.goods_name}} - - ¥{{item.shop_price}} - 删除 - 看相似 + + + + + + 当前暂无收藏 + + + 去首页逛逛 + + + + + + + + + + 共{{total_collects}}件商品 + {{editEd==1?'完成':'编辑'}} + + + + + + + + + + + + + + + + + + + {{item.goods_name}} + + + + + + + + + {{item.shop_price}} + + + + 零售价: + ¥{{item.market_price}} + + + + + + 找相似 + + + + + + + + + + + + + + + + + + + + 好物推荐 + + + + + + + + + + + + + + + 全选 - - - 没有相关的数据 - 去逛逛 + + + 已选 + {{sum>0?sum:'0'}} + + + {{isdelete==0?'删除':'删除中'}} + + + \ No newline at end of file diff --git a/pages/user/collect_list/collect_list.wxss b/pages/user/collect_list/collect_list.wxss index 0e86f34..bac30c9 100644 --- a/pages/user/collect_list/collect_list.wxss +++ b/pages/user/collect_list/collect_list.wxss @@ -1,4 +1,4 @@ -.collect-ul { +/* .collect-ul { width: 100%; background-color: #f0f2f5; } @@ -46,4 +46,475 @@ border-radius: 5rpx; color: #686868; font-size: 30rpx; +} */ + +page { + width: 100%; + background-color: rgb(245, 245, 245); + overflow-x: hidden; +} + +.Collection { + overflow-x: hidden; +} + +/* vip开卡框架 */ + +.vip { + width: 100%; + height: 70rpx; + background-color: rgb(250, 242, 219); + font-size: 25rpx; + padding: 0rpx 31rpx; +} + +.vip .vip_image { + width: 40rpx; + height: 40rpx; + background-color: rgb(55, 45, 13); + border-radius: 50%; + line-height: 70rpx; +} + +.vip .vip_image image { + width: 25rpx; + height: 25rpx; + line-height: 70rpx; +} + +.vip .vip_describe { + width: 502prx; + margin-left: 20rpx; + padding-right: 172rpx; + line-height: 70rpx; + border-right: 4rpx solid #000; + height: 25rpx; +} + +.vip .vip_describe .vip_province_money { + color: rgb(254, 0, 0); +} + +.vip .vip_card { + margin-left: 17rpx; + line-height: 70rpx; +} + +.vip .vip_card .vip_go_image { + margin-left: 10rpx; +} + +.vip .vip_card .vip_immediately { + color: rgb(56, 47, 14); +} + +.vip .vip_card .vip_go_image image { + width: 35rpx; + height: 35rpx; +} + +.commodity { + width: 100%; +} + +/* 无收藏样式 */ + +.noCollection image { + width: 329rpx; + height: 229rpx; + margin-top: 202rpx; +} + +.noCollection .xc-ash { + margin-top: 41rpx; + font-weight: 600px; +} + +.noCollection navigator { + margin-top: 73rpx; + border-radius: 40rpx; +} + +.noCollection navigator view { + width: 247rpx; + height: 56rpx; + background-color: rgb(255, 72, 72); + border-radius: 40rpx; +} + +/* 商品详情 */ + +.commodity .sum { + font-size: 28rpx; + height: 70rpx; + background-color: rgb(245, 245, 245); + padding-left: 31rpx; + color: rgb(131, 131, 131); +} + +.commodity .sum view { + height: 100%; + letter-spacing: 1rpx; +} + +.commodity .sum .editEd { + width: 100rpx; + padding-right: 31rpx; +} + +.colls_max { + padding-left: 30rpx; +} + +.commodity .collects_max .collect { + width: 100%; + height: 244rpx; + border-bottom: 4rpx solid rgb(245, 245, 245); + background-color: rgb(255, 255, 255); + padding-right: 31rpx; +} + +.commodity .collects_max .collect .collect_image { + height: 183rpx; + width: 183rpx; + margin-left: 31rpx; +} + +.commodity .collects_max .collect .iconrp { + margin-left: 0rpx; +} + +.commodity .collects_max .collect .collect_image image { + width: 100%; + height: 100%; +} + +.commodity .collects_max .collect .attribute { + line-height: 68rpx; + height: 183rpx; + margin-left: 21rpx; +} + +.commodity .collects_max .collect .attribute .attribute_name { + height: 68rpx; + align-items: center; + width: 474rpx; +} + +.commodity .collects_max .collect .attribute .attribute_name .name { + line-height: 35rpx; +} + +.commodity .collects_max .collect .attribute .attribute_money { + margin-top: 60rpx; + display: flex; + justify-content: space-between; + height: 50rpx; + align-items: flex-end; +} + +.commodity .collects_max .money_left { + height: 54rpx; +} + +.commodity .collects_max .collect .attribute .attribute_money .money_left .price { + font-weight: 1000rpx; + color: rgb(212, 28, 52); + margin-right: 10rpx; + align-items: baseline; +} + +.commodity .collects_max .collect .attribute .attribute_money .money_right { + align-items: flex-end; + padding-bottom: 1rpx; +} + +.commodity .collects_max .collect .attribute .attribute_money .money_right .similar { + width: 97rpx; + height: 35rpx; + border-radius: 21rpx; + border: 1rpx solid rgb(162, 162, 162); + margin-right: 22rpx; + color: rgb(110,110, 110); + align-items: center; +} + +.commodity .collects_max .collect .attribute .attribute_money .money_right view { + height: 30rpx; + line-height: 30rpx; +} + +.commodity .collects_max .collect .attribute .attribute_money .money_right image { + width: 35rpx; + height: 35rpx; + margin-right: 10rpx; + margin-bottom: 1rpx; +} + +.line { + align-items: baseline; +} + +.title .collect { + background-color: rgb(255, 255, 255); +} + +/* 热门好物 */ + +/* .title .China { + width: 100%; + margin-top: 50rpx; + margin-bottom: 10rpx; + line-height: 0rpx; +} + +.title .China .lin view { + width: 2rpx; +} + +.title .China .le { + height: 40rpx; + color: rgb(51,51, 51); +} + +.title .China .line .one { + height: 23rpx; + background-color: #000; + margin-left: 5rpx; +} + +.title .China .line .two { + height: 15rpx; + background-color: #000; + margin-left: 5rpx; +} + +.title .China .line .three { + height: 18rpx; + background-color: #000; + margin-left: 5rpx; +} + +.title .China .Recommend { + margin: 0rpx 20rpx; + font-size: 28rpx; + line-height: 39rpx; + font-weight: bold; +} + +.title .english .silk { + width: 214rpx; + height: 2rpx; + background-color: #000; +} + +.title .english .esh { + margin: 0rpx 15rpx; +} */ + +/* .collects { + margin-top: 40rpx; +} */ + +.Recommend { + height: 80rpx; + padding-top: 7rpx; +} + +.Recommend .lin { + width: 210rpx; + height: 2rpx; + background-color: rgb(167, 167, 167); +} + +.Recommend .flex-center { + margin: 0 20rpx; + color: rgb(51, 51, 51); + font-weight: bold; +} + +.Recommend .flex-center image { + margin-right: 5rpx; + width: 32rpx; + height: 29rpx; +} + +.hang { + width: 100%; + margin: auto; + padding-left: 31rpx; +} + +.hang .collect { + width: 335rpx; + height: 503rpx; + border-radius: 23rpx; + border: 1rpx solid rgb(214, 214, 214); + overflow: hidden; + margin-right: 14rpx; + margin-bottom: 10rpx; +} + +.collect .bottom { + padding: 0rpx 16rpx; +} + +.collect .bottom .goods_name { + height: 68rpx; +} + +.collect .sp { + width: 100%; + height: 315rpx; +} + +.collect .money { + margin-top: 40rpx; + line-height: 28rpx; + align-items: baseline; +} + +.collect .money view { + display: flex; + align-items: baseline; + font-weight: 1000rpx; +} + +.collect .Discount { + width: 156rpx; + height: 28rpx; + border-radius: 20rpx; + background-color: rgb(56, 56, 56); + font-size: 18rpx; + color: rgb(255, 255, 255); +} + +.collect .Discount image { + height: 18rpx; + width: 18rpx; + line-height: 28rpx; + margin-right: 3rpx; +} + +.collect.ml20 { + margin-left: 13rpx; +} + +.fs24.dollar { + padding: 0rpx; +} + +.through { + text-decoration: line-through; + color: rgb(155, 155, 155); + margin-left: 7rpx; +} + +.money .price { + margin-left: 12rpx; + text-decoration: line-through; +} + +.money .price view { + display: flex; + align-items: flex-end; +} + +.province { + line-height: 28rpx; +} + +.nothing { + height: 75rpx; + width: 100%; +} + +.nothing .no_content { + margin: 0rpx 11rpx; + color: rgb(138, 138, 138); +} + +.nothing .Foil { + width: 80rpx; + height: 2rpx; + background-color: rgb(138, 138, 138); +} + +.iconUn { + margin-left: 15rpx; + margin-right: 21rpx; + transform: scale(1.0); +} + +.Un { + margin-left: 0rpx; +} + +.iconClick { + margin-left: 21rpx; + margin-right: 16rpx; +} + +.radioCheck { + height: 100%; + display: flex; + align-items: center; + width: 65rpx; + justify-content: center; +} + +.scale { + transform: scale(0.8); +} + +.load { + width: 100%; + height: 80rpx; + padding: 0rpx 31rpx; +} + +.abs { + position: fixed; + left: 0rpx; + bottom: 0rpx; + height: 100rpx; + background-color: rgb(255, 255, 255); + width: 100%; + border-top: 1rpx solid #eee; +} + +.abs .left { + display: flex; + justify-content: space-between; + width: 515rpx; + padding-left: 31rpx; +} + +.abs .allClick { + margin-left: 31rpx; +} + +.abs icon { + margin-right: 31rpx; +} + +.abs .delete { + width: 235rpx; + height: 100%; + background-color: rgb(219, 27, 52); +} +.abs .Deleting{ + background-color: rgb(131, 131, 131); +} +.abs .Number { + margin-right: 18rpx; + letter-spacing: 0rpx; + font-size: 32rpx; + height: 55rpx; + +} +.goods_num{ + height: 55rpx; +line-height: 55rpx; + } \ No newline at end of file diff --git a/pages/user/comment/comment.js b/pages/user/comment/comment.js index ee5d117..daef162 100644 --- a/pages/user/comment/comment.js +++ b/pages/user/comment/comment.js @@ -1,119 +1,155 @@ +var ut = require("../../../utils/util.js"); var t = function(t) { return t && t.__esModule ? t : { - default: t + default: t }; -}(require("../../../utils/LoadMore.js")), e = getApp(), rq = e.request, a = new t.default(), - s = require("../../../utils/util.js"), oo = e.globalData, os = e.globalData.setting; + }(require("../../../utils/LoadMore.js")), + e = getApp(), + rq = e.request, + a = new t.default(), + s = require("../../../utils/util.js"), + oo = e.globalData, + os = e.globalData.setting; +var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ - data: { - url: e.globalData.setting.url, - resourceUrl: e.globalData.setting.imghost, - iurl: e.globalData.setting.imghost, - categories: [ { - name: "全部评价", - status: 2 - }, { - name: "待评价", - status: 0 - }, { - name: "已评价", - status: 1 - } ], - activeStatus: 0, - comments: null, - currentPage: 1 - }, - onLoad: function(t) { - var e = void 0 === t.status ? this.data.activeStatus : t.status; - a.init(this, "", "comments"), this.requestComments(e); - }, - onShow: function() { - wx.getStorageSync("user:comment:update") && (wx.setStorageSync("user:comment:update", !1), - this.resetData(), this.requestComments(this.data.activeStatus)); - }, - changeTab: function(t) { - this.resetData(), this.requestComments(t.currentTarget.dataset.status); - }, - requestComments: function(t) { - var e = this, th=e,n = os.url + "/api/weshop/comment/list?page=" + e.data.currentPage; - console.log('requestComments'); - console.log(n); - console.log(t); + data: { + url: e.globalData.setting.url, + resourceUrl: e.globalData.setting.imghost, + iurl: e.globalData.setting.imghost, + categories: [{ + name: "全部评价", + status: 2 + }, { + name: "待评价", + status: 0 + }, { + name: "已评价", + status: 1 + }], + activeStatus: 0, + comments: null, + currentPage: 1, + isloaded: 0, + order_id:0, + is_no_more:0, + }, + onLoad: function(t) { + var e = void 0 === t.status ? this.data.activeStatus : t.status; + this.data.order_id=t.order_id; + + //a.init(this, "", "comments"), + //this.requestComments(e); + this.requestComments_new(e); + }, + onShow: function() { + wx.getStorageSync("user:comment:update") && (wx.setStorageSync("user:comment:update", !1), + this.resetData(), this.requestComments_new(this.data.activeStatus)); + }, + changeTab: function(t) { + var e = this; + if (this.data.activeStatus == t.currentTarget.dataset.status) + return false; + this.resetData(), this.requestComments_new(t.currentTarget.dataset.status); + }, + + requestComments_new:async function(t){ + var e = this, th = e, n = os.url + "/api/weshop/comment/list?page=" + e.data.currentPage; this.setData({ activeStatus: t }); - if(t==2){ - a.request(n, function (t) { - e.data.currentPage++; - var da = th.data.comments; - /*-- - da.forEach(function(em,ind){ - rq.get("/api/weshop/goods/get/" + os.stoid + "/" + em.goods_id, { - success: function (tt) { - var gd = tt.data.data.original_img; - da[ind]['original_img'] = gd; - th.setData({ comments: da, }) - }, - }); - })---*/ - - - }, null, { store_id: os.stoid, user_id: oo.user_id }), - wx.stopPullDownRefresh(); - }else{ - a.request(n, function(t) { - e.data.currentPage++; - var da = th.data.comments; - /*-- - da.forEach(function (em, ind) { - rq.get("/api/weshop/goods/get/" + os.stoid + "/" + em.goods_id, { - success: function (tt) { - var gd = tt.data.data.original_img; - da[ind]['original_img'] = gd; - th.setData({ comments: da, }) - }, - }); - });--*/ - - }, null, {is_comment:t, store_id: os.stoid,user_id: oo.user_id }), - wx.stopPullDownRefresh(); - } - - }, - onReachBottom: function() { - a.canloadMore() && this.requestComments(this.data.activeStatus); - }, - onPullDownRefresh: function(t) { - this.resetData(), this.requestComments(this.data.activeStatus); - }, - resetData: function() { - this.data.comments = null, this.data.currentPage = 1, a.resetConfig(); - }, - /*-----评论-----*/ - comment: function(t) { - for (var e = t.currentTarget.dataset.recid, a = this.data.comments, s = 0; s < a.length && a[s].rec_id != e; s++) ; - if (!(s >= a.length)) { + if(e.data.order_id) n+="&order_id="+e.data.order_id; + var rq_data={store_id: os.stoid, user_id: oo.user_id}; + if (t!= 2) {rq_data['is_comment']=t;} + + var rs_data=null,com_data=this.data.comments; + await getApp().request.promiseGet(n,{data:rq_data}).then(res=>{ + e.data.currentPage++ + if(res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ + rs_data=res.data.data.pageData; + }else{ + th.setData({ is_no_more: 1, }) + } + }) - console.log("comment"); - console.log(a[s]); + if(rs_data){ + for(var ind in rs_data ){ + var em=rs_data[ind] + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { + data:{ store_id: os.stoid, goods_id: em.goods_id, + pageSize: 3, parent_id: em.comment_id, page:1} + }).then(res=>{ + if(res.data.data && res.data.data.pageData && res.data.data.pageData.length>0) + rs_data[ind].replay_list=res.data.data.pageData; + }) + if (em.img != undefined && em.img != null && ut.isString(em.img)) rs_data[ind].img = ut.unserialize(em.img); + var str = em.weapp_img; + if (str != "" && ut.isString(str)) rs_data[ind].weapp_img = JSON.parse(str); + rs_data[ind].original_img=this.data.iurl+rs_data[ind].original_img; + } - var n = "?order_id=" + a[s].order_id; - n += "&goods_id=" + a[s].goods_id, n += "&goods_name=" + a[s].goods_name, n += "&price=" + a[s].goods_price, - n += "&img=" + a[s].original_img, - wx.navigateTo({ - url: "/pages/user/add_comment/add_comment" + n - }); + if(!com_data) com_data=rs_data; + else com_data= com_data.concat(rs_data); + th.setData({ comments: com_data, isloaded: 1, }) } }, - //图片失败,默认图片 - bind_bnerr2: function (e) { - var _errImg = e.target.dataset.errorimg; - var _errObj = {}; - _errObj[_errImg] = this.data.iurl+"/public/images/default_goods_image_240.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - } + onReachBottom: function() { + if(this.data.is_no_more) return false; + //a.canloadMore() && this.requestComments(this.data.activeStatus); + this.requestComments_new(this.data.activeStatus); + }, + + + onPullDownRefresh: function(t) { + this.resetData(), this.requestComments_new(this.data.activeStatus); + }, + resetData: function() { + this.data.comments = null, this.data.currentPage = 1, this.data.is_no_more=0, a.resetConfig(); + }, + /*-----评论-----*/ + comment: function(t) { + for (var e = t.currentTarget.dataset.recid, a = this.data.comments, s = 0; s < a.length && a[s].rec_id != e; s++); + if (!(s >= a.length)) { + var n = "?order_id=" + a[s].order_id; + n += "&goods_id=" + a[s].goods_id, n += "&price=" + a[s].goods_price; + wx.navigateTo({ + url: "/pages/user/add_comment/add_comment" + n + }); + } + }, + + //图片失败,默认图片 + bind_bnerr2: function(e) { + var _errImg = e.currentTarget.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = os.imghost + "/public/images/default_goods_image_240.gif"; + //this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + //预览图片 + previewImg: function(e) { + var index = e.currentTarget.dataset.index; + var sindex = e.currentTarget.dataset.sindex; + var name = e.currentTarget.dataset.name; + var imgArr = this.data.comments; + var image = null; + if (name == "img") { + image = imgArr[index].img[sindex]; + } else { + image = imgArr[index].weapp_img[sindex]; + } + wx.previewImage({ + current: image, + //当前图片地址 + urls: imgArr[index].weapp_img, //所有要预览的图片的地址集合 数组形式 + }) + }, + //跳到首页 + goto: function(ee) { + wx.switchTab({ + url: '/pages/index/index/index', + }) + }, }); \ No newline at end of file diff --git a/pages/user/comment/comment.wxml b/pages/user/comment/comment.wxml index 849e952..8e578e2 100644 --- a/pages/user/comment/comment.wxml +++ b/pages/user/comment/comment.wxml @@ -1,39 +1,121 @@ + - - - - {{item.name}} - - + + + {{item.name}} - - - - - - - - {{item.goods_name}} - {{item.spec_key_name}} - 购买时间:{{item.order_add_time}} - - - + + + + + + + 当前暂无评价 + + + 去首页逛逛 + + + + + + + + + + + 订单编号:{{item.order_sn}} + + {{item.comment_id>0?'已评价':'待评价'}} + + + + + + + + + + + + + + {{item.goods_name}} + + + {{item.goods_color+item.goods_spec.length>-1?item.goods_color+item.goods_spec:'规格1'}} + + + + + + + + {{filter.toFix(item.goods_price,2)}} + + x{{item.goods_num}} + + + + + + + + 评价: + + + + + + {{item.content.length>0?item.content:'此用户没有填写评论'}} + + + + + + + + + + 店家回复: + + {{r_item.content}} + + + + + + {{item.comment_addtime}} - + + + + + 共{{item.goods_num}}件商品 + + + 合计: + + + {{filter.toFix(item.goods_price,2)}} + + + + 查看订单 + + + 去评价 + + - - - - 没有找到相关的记录 - 去逛逛 - - + + + 已经加载到底部 + + \ No newline at end of file diff --git a/pages/user/comment/comment.wxss b/pages/user/comment/comment.wxss index 1f02621..cd0a6ca 100644 --- a/pages/user/comment/comment.wxss +++ b/pages/user/comment/comment.wxss @@ -1,87 +1,189 @@ +.padding { + padding: 0rpx 27rpx; +} + +.container { + background-color: rgb(255, 255, 255); +} + .type-navbar { - white-space: nowrap; - display: flex; - width: 100%; - height: 80rpx; - background-color: #fff; + white-space: nowrap; + display: flex; + height: 80rpx; + background-color: #fff; + border-top: 2rpx solid rgb(221, 221, 221); + justify-content: space-between; + color: rgb(51, 51, 51); } .type-box { - width: 33.3333333333%; - box-sizing: border-box; - font-size: 32rpx; - line-height: 76rpx; - padding: 0 20rpx; - text-align: center; - display: inline-block; - overflow: hidden; + box-sizing: border-box; + line-height: 76rpx; + text-align: center; + display: inline-block; + overflow: hidden; } .type-navbar-item { - border-bottom: 4rpx solid #fff; + border-bottom: 4rpx solid #fff; } .type-item-on { - border-bottom: 4rpx solid #e64340; + /* width: 146rpx; */ + border-bottom: 7rpx solid #e64340; +} + +.border_bottom { + border-bottom: 3rpx solid rgb(245, 245, 245); +} +/* 无评价 */ + +.noCollection image { + width: 329rpx; + height: 229rpx; + margin-top: 202rpx; +} + +.noCollection .xc-ash { + margin-top: 10rpx; + font-weight: 600px; +} + +.noCollection navigator { + margin-top: 60rpx; + border-radius: 40rpx; +} + +.noCollection navigator view { + width: 247rpx; + height: 56rpx; + background-color: rgb(255, 72, 72); + border-radius: 40rpx; +} + +/* 待评价栏 */ + +.Commodity_number { + height: 70rpx; + border-top: 13rpx solid rgb(245, 245, 245); +} + +/* 文字基线对齐 */ + +.baseline { + display: flex; + align-items: baseline; +} + +/* 单个商品框架 */ + +.detail_commodity { + height: 231rpx; +} + +.detail_commodity image { + width: 185rpx; + height: 185rpx; } -.goods-container { - /*--margin: 20rpx 0;--*/ - margin-top: 20rpx; - background-color: #fff; +.detail_commodity .goods_name { + width: 485rpx; + /* height: 75rpx; */ + line-height: 37rpx; } -.goods-box { - - position: relative; - padding: 20rpx 30rpx 0; - font-size: 28rpx; - clear: both; +.Commodity_content { + height: 185rpx; + margin-left: 21rpx; } -.goods-img { - float: left; - height: 100rpx; - width: 100rpx; +.Commodity_content .Commodity_goods { + height: 150rpx; } -.goods-desc { - float: left; - width: 570rpx; - margin-left: 20rpx; +.Commodity_content .Commodity_money { + font-size: 16rpx; } -.goods-name { - height: 44rpx; - line-height: 44rpx; - overflow: hidden; +/* 商品评价按钮框架 */ + +.commodity_evaluate { + height: 110rpx; + padding-top: 15rpx; } -.buy-time { - margin-top: 20rpx; - font-size: 26rpx; - color: #b3b3b3; +.commodity_evaluate .commodity_smy .commodity_money { + margin-left: 29rpx; + letter-spacing: 1rpx; } -.comment-button { - font-size: 30rpx; - color: #f23030; - float: right; - padding: 8rpx 10rpx; - border: 1rpx #f23030 solid; - margin-bottom: 20rpx; +.commodity_evaluate .commodity_To_evaluate { + width: 128rpx; + height: 39rpx; + border-radius: 9rpx; +} +.commodity_evaluate .commodity_To_evaluate view{ + height: 39rpx; + line-height: 39rpx; +} +.commodity_evaluate .comment_go{ + margin-top: 10rpx; + background-color: rgb(211, 28, 52); + color: rgb(255, 255, 255); } -.change-order { - color: #c2c2c2; - border: 1rpx #c2c2c2 solid; +.Commodity_spec { + width: 106rpx; + background-color: rgb(236, 236, 236); + border-radius: 7rpx; + font-size: 18rpx; + margin-top: 10rpx; } -.button-icon { height: 26rpx; width: 26rpx;} -.start_c{ - height: 42rpx; width: 230rpx; - top: 6rpx; position: relative; +.Commodity_spec view { + height: 28rpx; + align-items: center; +} + +.Commodity_evaluation .Comment_content { + color: rgb(153, 153, 153); + letter-spacing: 1rpx; +} +.Commodity_evaluation .starss{ + height: 58rpx; + /* // line-height: 58rpx; */ + align-items: center; +} +.Commodity_evaluation .commen{ + height: 58rpx; + line-height: 58rpx; +} +.Commodity_evaluation .starss .stars{ + line-height: 58rpx; +} +.Commodity_evaluation .starss .stars image { + width: 29rpx; + height: 26rpx; + margin-right: 5rpx; +} + +.Commodity_evaluation .Comment_images image { + width: 100rpx; + height: 100rpx; + margin-right: 8rpx; + margin-top: 18rpx; + border-radius: 6rpx; + border: 3rpx solid rgb(245, 245, 245); +} +.commodity_evaluate .View_evaluation{ + border:2rpx solid rgb(179, 179, 179); + color:rgb(0, 0, 0); + background-color: rgb(255, 255, 255); +} +.comment_addtime{ + height: 50rpx; } -.clear{clear: both; border-top: 1rpx solid #eee; font-size: 30rpx; padding-left: 30rpx} -.clear view{margin-bottom: 10rpx;} -.clear .fview{margin-top: 10rpx;} \ No newline at end of file +.title_width{ width: 146rpx; text-align:center } +.shop-font{ color: rgb(153, 153, 153);} +.reply{ margin-top: 10rpx} +.get_bottom{ text-align: center; color: #999; margin-bottom: 20rpx} \ No newline at end of file diff --git a/utils/request.js b/utils/request.js index 351a1be..affbf49 100644 --- a/utils/request.js +++ b/utils/request.js @@ -43,7 +43,10 @@ module.exports = { filePath: e.filePath, name: e.name, success: function(t) { - i.hideLoading(), console.log("app.request", t), t.data = JSON.parse(i.filterJsonData(t.data)), + i.hideLoading(); + if(t.statusCode==200) + t.data = JSON.parse(i.filterJsonData(t.data)); + else { t={code:-1,msg:'调用接口失败'};} i.doSuccess(e, t); }, fail: function(t) { diff --git a/utils/util.js b/utils/util.js index 169e371..1e0deb7 100644 --- a/utils/util.js +++ b/utils/util.js @@ -258,6 +258,17 @@ function get_rand_item(arr){ return arr[ind]; } +function getDistance(lat1, lng1, lat2, lng2){ + var radLat1 = lat1*Math.PI / 180.0; + var radLat2 = lat2*Math.PI / 180.0; + var a = radLat1 - radLat2; + var b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0; + var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); + s = s *6378.137 ;// EARTH_RADIUS; + return s; +} + module.exports = { formatTime: function(e, r) { var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) { @@ -347,6 +358,6 @@ module.exports = { sub_last: sub_last,//去掉末尾一个字符 measureText: measureText,//画布需要的函数 check_mobile: check_mobile,//验证手机 - get_rand_item:get_rand_item, //随机获取元素 - + get_rand_item:get_rand_item, //随机获取元素 + getDistance:getDistance //获取俩个经纬网度之间的距离 };