From 281cf283f9ad70a836e6923a130bd3df1d7bf2b1 Mon Sep 17 00:00:00 2001 From: taiwan Date: Fri, 14 Jan 2022 16:54:45 +0800 Subject: [PATCH] 卡项自定义模版修改 --- components/diy_serviceCard/diy_serviceCard.js | 1155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- components/diy_serviceCard/diy_serviceCard.wxml | 43 ++++++++++++++++++++----------------------- components/diy_serviceCard/diy_serviceCard.wxss | 23 ++++++++++++++--------- 3 files changed, 629 insertions(+), 592 deletions(-) diff --git a/components/diy_serviceCard/diy_serviceCard.js b/components/diy_serviceCard/diy_serviceCard.js index cf3ce1b..7b93b05 100644 --- a/components/diy_serviceCard/diy_serviceCard.js +++ b/components/diy_serviceCard/diy_serviceCard.js @@ -1,582 +1,617 @@ var t = getApp(), - a = t.request, - o = t.globalData.setting, - os = o, - i = require("../../utils/util.js"), - ut = i, - s = require("../../utils/common.js"); + a = t.request, + o = t.globalData.setting, + os = o, + i = require("../../utils/util.js"), + ut = i, + s = require("../../utils/common.js"); var regeneratorRuntime = require('../../utils/runtime.js'); Component({ options: { addGlobalClass: true, }, - properties: { - // 这里定义了innerText属性,属性值可以在组件使用时指定 - object: { - type: Object, - value: null, - }, - - }, - data: { - // 这里是一些组件内部数据 - group: false, - imghost: o.imghost, - is_recommend: 0, - is_hot: 0, - is_new: 0, - baseUrl: "/api/weshop/goods/page", - resourceUrl: t.globalData.setting.resourceUrl, - url: t.globalData.setting.imghost, - currentPage: 1, - requestData: null, - requestUrl: "", - goods_array: null, - total: null, - prom_id: 0, - classstyle_id: null, - g_id: null, - wgroup: null, - goods_btn: null, - loadText: '加载更多', - someData: {}, - goodscount: null, - firist_type_data: null, - firist_type_curr: 0, - is_nav:0, - nav_list:null, - title_index:0, - swiper_hei:0, - title_class:"", - }, - - ready: function () {}, - - lifetimes: { - attached: function() { - - - //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 - var nav_item=this.data.object; - var nav_list= this.data.object.nav_list; - - if(parseInt(nav_item.is_automore)){ - if(!getApp().globalData.func_list) getApp().globalData.func_list=[]; - getApp().globalData.func_list.push(this); - } - - - //最新的版本才有nav_list - if(nav_list){ - nav_item=nav_list[0]; - //要算一下商品goodsid - for(var ij in nav_list){ - var item=nav_list[ij]; - var idlist=""; - //如果商品有手动选择的时候 - if(item.data && item.data.length>0){ - for(var im in item.data){ - idlist+= item.data[im]+","; - } - } - if(idlist) idlist=ut.sub_last(idlist); - nav_list[ij].idlist=idlist; - } - this.setData({nav_list:nav_list,is_nav:parseInt(this.data.object.is_nav)}); - } - - // 在组件实例进入页面节点树时执行 - if(nav_item) { - this.data.classstyle_id = nav_item.classstyle; - this.data.wgroup =nav_item.wgroup; - } - - this.data.goodscount = this.data.object.goodscount; - - - var hei=280; - if(this.data.object.goodstit) hei+=80; - if(this.data.object.goodsprice) hei+=80; - if(this.data.object.goodsnum) hei+=80; - - if(this.data.object.title_color){ - this.data.title_class=`color:${this.data.object.title_color};` - } + properties: { + // 这里定义了innerText属性,属性值可以在组件使用时指定 + object: { + type: Object, + value: null, + }, - if(this.data.object.title_font_size){ - this.data.title_class=this.data.title_class.concat(`font-size:${this.data.object.title_font_size}px;`) - } - this.setData({ - swiper_hei:hei, - title_class:this.data.title_class, - }); - - if (nav_item && nav_item.goodsclass == 1) { - this.data.is_recommend = 1 - } - if (nav_item && nav_item.goodsclass == 2) { - this.data.is_hot = 1 - } - if (nav_item && nav_item.goodsclass == 3) { - this.data.is_new = 1 - } - - this.data.requestData = new Array(); - this.data.g_id = nav_item.data; - var arr = []; - - for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { - arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); - } - this.data.firist_type_data = arr; - this.init(this.data.classstyle_id, this.data.wgroup); - }, - detached: function() { - // 在组件实例被从页面节点树移除时执行 - }, - }, - - pageLifetimes: { - //游客登录后,只要更新卡的情况 - show: function () { - //--初始化卡类-- - this.card_init(); - }, - }, - - methods: { - // 这里是一个自定义方法 - init:async function (classstyle_id, wgroup) { - - this.setData({classstyle_id:classstyle_id}) - - var th = this; - var g_id = this.data.g_id; - var len=this.data.firist_type_data.length; - if (classstyle_id == 1) { - //---手动选择的时候--- - g_id = this.data.firist_type_data[th.data.firist_type_curr]; - th.data.firist_type_curr++; - } - - var th = this, - app = getApp(), - index = 0, - gdata = []; - - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; - - //--初始化卡类-- - th.card_init(); - var os=getApp().globalData.setting; - classstyle_id = classstyle_id + ""; - switch (classstyle_id) { - //---手动选择商品--- - case "1": - var str=""; - for (var i = 0; i < g_id.length; i++) { - str += g_id[i].goodsid + ","; - } - str=str.substring(0, str.length - 1); - - await app.request.get("/api/weshop/goods/getgoodslistOrdby?store_id=" + os.stoid + "&goodsidlist=" + str, { - data:{user_id:user_id}, - isShowLoading:false, - success: function(res) { - th.data.loading=0; - - if(res.data.code==0 && res.data.data){ - - var goods = res.data.data; - /*-- - var rData = th.data.requestData; - if (rData == null) rData=[]; - var now=ut.gettimestamp(); - - var new_arr=[]; - for (var ii in res.data.data){ - var item=res.data.data[ii]; - item.goods_img=th.data.imghost + item.original_img; - if(item.e_timenow) {item.prom_type=0; item.prom_price=0;} - new_arr.push(item); - } - rData = rData.concat(new_arr); - - th.data.requestData = rData; - - if(th.data.object.column==5){ - var arr = new Array(); - //--三个三个一组--- - for(var i=0;i< rData.length;i+=3){ - arr.push(rData.slice(i,i+3)); - } - th.setData({ goods_array: arr }); - }else{ - th.setData({ goods_array: rData }); - }--*/ - - th.set_good(goods); - - //---控制有没有加载更多的按钮--- - if (th.data.firist_type_curr >= len) {th.setData({ goods_btn: [] }); } - else th.setData({ goods_btn: [1,2]}); + }, + data: { + // 这里是一些组件内部数据 + group: false, + imghost: o.imghost, + is_recommend: 0, + is_hot: 0, + is_new: 0, + baseUrl: "/api/weshop/goods/page", + resourceUrl: t.globalData.setting.resourceUrl, + url: t.globalData.setting.imghost, + currentPage: 1, + requestData: null, + requestUrl: "", + goods_array: null, + total: null, + prom_id: 0, + classstyle_id: null, + g_id: null, + wgroup: null, + goods_btn: null, + loadText: '加载更多', + someData: {}, + goodscount: null, + firist_type_data: null, + firist_type_curr: 0, + is_nav: 0, + nav_list: null, + title_index: 0, + swiper_hei: 0, + title_class: "", + }, + + ready: function() {}, + + lifetimes: { + attached: function() { + //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 + var nav_item = this.data.object; + var nav_list = this.data.object.nav_list; + + if (parseInt(nav_item.is_automore)) { + if (!getApp().globalData.func_list) getApp().globalData.func_list = []; + getApp().globalData.func_list.push(this); + } + + + //最新的版本才有nav_list + if (nav_list) { + nav_item = nav_list[0]; + //要算一下商品goodsid + for (var ij in nav_list) { + var item = nav_list[ij]; + var idlist = ""; + //如果商品有手动选择的时候 + if (item.data && item.data.length > 0) { + for (var im in item.data) { + idlist += item.data[im] + ","; + } } + if (idlist) idlist = ut.sub_last(idlist); + nav_list[ij].idlist = idlist; } - - }) - - break; - case "2": - var item = {}; - var r_data={ - store_id: os.stoid , - pageSize: th.data.goodscount, - page: th.data.currentPage, - isonsale: 1, - orderField: "sort", - orderType: 'asc', - }; - if(th.data.is_recommend) r_data.is_recommend=th.data.is_recommend; - if(th.data.is_hot) r_data.is_hot=th.data.is_hot; - if(th.data.is_new) r_data.is_new=th.data.is_new; - - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; - r_data.user_id=user_id; - - await app.request.promiseGet("/api/weshop/goods/page", { - data:r_data - }).then(res => { - th.data.loading=0; - //商品地址 - var goods = res.data.data.pageData; - th.setData({ - goods_btn: res.data.data.pageData, - total: res.data.data.total - }) - th.data.currentPage++; - //设置商品熏染 - th.set_good(goods); - - }) - break; - case "3": - var item = {}; - await app.request.promiseGet("/api/weshop/goodsGroup/pageGoodsList", { - data: { - store_id:os.stoid , - gpid: wgroup, - pageSize: th.data.goodscount, - page: th.data.currentPage, - isonsale: 1, - orderField: "sort", - orderType: 'asc', - user_id:user_id - } - }).then(res => { - th.data.loading=0; - //商品地址 - var goods = res.data.data.pageData; - th.setData({ - goods_btn: res.data.data.pageData, total: res.data.data.total - }) - - th.data.currentPage++; - //设置商品熏染 - th.set_good(goods); - - }) - break; - } - }, - - setLoading: function () { - var that = this; - if(this.data.loading) return false; - this.data.loading=1; - that.init(that.data.classstyle_id, that.data.wgroup); - }, - - //图片失败,默认图片 - bind_bnerr3: function (e) { - var _errImg = e.target.dataset.errorimg; - var _errObj = {}; - _errObj[_errImg] = this.data.imghost + "/public/images/default_goods_image_240.gif"; - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; - }, - - //---卡的初始化---- - card_init: function() { - var th = this,os=getApp().globalData.setting; - if(!getApp().globalData.user_id) return false; - getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { - isShowLoading:false, - success: function(e) { - getApp().globalData.userInfo = e.data.data; - getApp().getConfig2(function(e) { - var swithc_list = e.switch_list; - var sw_arr = JSON.parse(swithc_list); - //---如果后台又开等级卡的开关--- - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { - th.setData({ - rank_switch: true - }); - //---回调卡的列表--- - th.getPlusCardType(function(ob) { - th.setData({ - card_list: ob.card_list - }); - var ti = setInterval(function() { - var user = getApp().globalData.userInfo; - if (!user) return false; - clearInterval(ti); - - if (user.card_field && user['card_expiredate']) { - var str = user['card_expiredate'].replace(/-/g, '/'); - var end = new Date(str); - end = Date.parse(end) / 1000; - var now = ut.gettimestamp(); - - //--- 判断是等级会员,且在有效期范围内 --- - if (user.card_field && now < end) { - var card_name = ob.name_map.get(user.card_field); - if (card_name.length > 4) card_name = card_name.substring(0, 4); - th.setData({ - card_field: user.card_field, - card_name: card_name, - card_list: ob.card_list - }); - } - - } - - }, 500) - }) - - } - }) - } - }) - - }, - - //--- 获取卡类列表 --- - getPlusCardType: function(func) { - var storid = o.stoid; - var th = this; - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { - var plusCard = res.data.data; - var arr = [1219, 2089, 3031]; - var new_arr = new Array(); - var card_name_map = new Map(); - - var user = getApp().globalData.userInfo; - - if(plusCard) { - - for (var i = 0; i < plusCard.length; i++) { - if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { - continue; - } - - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); - card_name_map.set(name, plusCard[i].CardName); - new_arr.push(plusCard[i]); + this.setData({ + nav_list: nav_list, + is_nav: parseInt(this.data.object.is_nav) + }); + } + + // 在组件实例进入页面节点树时执行 + if (nav_item) { + this.data.classstyle_id = nav_item.classstyle; + this.data.wgroup = nav_item.wgroup; + } + + this.data.goodscount = this.data.object.goodscount; + + + var hei = 280; + if (this.data.object.goodstit) hei += 80; + if (this.data.object.goodsprice) hei += 80; + if (this.data.object.goodsnum) hei += 80; + + if (this.data.object.title_color) { + this.data.title_class = `color:${this.data.object.title_color};` + } + + if (this.data.object.title_font_size) { + this.data.title_class = this.data.title_class.concat(`font-size:${this.data.object.title_font_size}px;`) + } + this.setData({ + swiper_hei: hei, + title_class: this.data.title_class, + }); + + if (nav_item && nav_item.goodsclass == 1) { + this.data.is_recommend = 1 + } + if (nav_item && nav_item.goodsclass == 2) { + this.data.is_hot = 1 + } + if (nav_item && nav_item.goodsclass == 3) { + this.data.is_new = 1 + } + + this.data.requestData = new Array(); + this.data.g_id = nav_item.data; + var arr = []; + + for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { + arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); } - } - - var ob = { - "card_list": new_arr, - "name_map": card_name_map - }; - func(ob); - }) + this.data.firist_type_data = arr; + this.init(this.data.classstyle_id, this.data.wgroup); + }, + detached: function() { + // 在组件实例被从页面节点树移除时执行 + }, }, - - //--- 点击tab的事件 --- - gr_set_nav:function(e){ - - var title_idx=e.currentTarget.dataset.index; - if(title_idx==this.data.title_index) return false; - wx.showLoading(); - - var nav_item=this.data.object.nav_list[title_idx]; - this.data.g_id =[]; - if(this.data.object.nav_list && this.data.object.nav_list[title_idx] && this.data.object.nav_list[title_idx].data) - this.data.g_id=this.data.object.nav_list[title_idx].data; - var arr = []; - for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { - arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); - } - this.data.firist_type_data = arr; - this.data.firist_type_curr=0; - this.data.requestData=[]; - - // 在组件实例进入页面节点树时执行 - if(nav_item){ - this.data.classstyle_id = nav_item.classstyle; - this.data.wgroup =nav_item.wgroup; - } - - - this.data.is_recommend = this.data.is_hot=this.data.is_new=0; - //推荐,热卖,新品 - if (nav_item && nav_item.goodsclass == 1) { - this.data.is_recommend = 1 - } - if (nav_item && nav_item.goodsclass == 2) { - this.data.is_hot = 1 - } - if (nav_item && nav_item.goodsclass == 3) { - this.data.is_new = 1 - } - - - this.data.currentPage=1; - this.setData({goods_array:null,total:null,title_index:title_idx}); - //初始化 - this.init(this.data.classstyle_id, this.data.wgroup); - setTimeout(function(){ wx.hideLoading();},1000) + + pageLifetimes: { + //游客登录后,只要更新卡的情况 + show: function() { + //--初始化卡类-- + // this.card_init(); + }, }, - //--- 设置 --- - set_good:async function(goods){ - var now=ut.gettimestamp(); - var th=this; - if(!goods || goods.length==0) return false; - var user_id=getApp().globalData.userInfo.user_id; - if(!user_id) user_id=0; - for(var i in goods){ - var val=goods[i]; - var item = {}; - var prom_id = null; - //app.request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + val.goods_id, {}).then(res => { - - var url="/api/weshop/activitylist/getGoodActInfo"; - var req_data={ - store_id:os.stoid,goodsidlist:val.goods_id,is_detail:1,user_id:user_id - }; - - //获取商品的实际活动 - await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ - if(res.data.code==0 && res.data.data && res.data.data.length==1){ - item.prom_type=res.data.data[0].prom_type; - item.prom_id=res.data.data[0].act_id; - } - }) - - item.goods_name = val.goods_name; - item.goods_img = th.data.imghost + val.original_img; - item.market_price = val.market_price; - item.shop_price = val.shop_price; - item.sales_sum = val.sales_sum; - item.goods_id = val.goods_id; - - item.cardprice1 = val.cardprice1; - item.cardprice2 = val.cardprice2; - item.cardprice3 = val.cardprice3; - item.prom_type = val.prom_type; - item.prom_id = val.prom_id; - - if(val.prom_price) item.prom_price = val.prom_price; - if(val.prom_integral) item.prom_integral = val.prom_integral; - - prom_id = val.prom_id; - - var prom_type = val.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 - - var url = ""; - - switch (prom_type){ - case 1: - var user_id=getApp().globalData.user_id; - if(!user_id) user_id=0; - url = "/api/ms/flash_sale/getNew/" +os.stoid + "/" +user_id+"/"+ prom_id; - break; - case 2: - url ="/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +val.goods_id+"/"+ prom_id - break; - case 4: - url ="/api/weshop/integralbuy/get/"+os.stoid +"/"+prom_id; - break; - case 6: - url = "/api/weshop/teamlist/get/" + os.stoid + "/" + prom_id; - break; - case 8: - var presell_id = prom_id; - var url1 = "/api/weshop/marketing/marketingPresellList/list"; - var rd= { - store_id: os.stoid, - presell_id: presell_id, - goods_id: val.goods_id - } - //------获取预售从表---------- - await getApp().request.promiseGet(url1, { - data: rd - }).then(res => { - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { - var arr = res.data.data[0]; - item.prom_price = arr.luck_goods_price; - item.sales_sum=arr.buy_goodnum+(arr.virtual_qty?arr.virtual_qty:0); - } - }) - break; - default: - break - } - - if(url!=null && url!=''){ - await getApp().request.promiseGet(url, {}).then(res => { - var prom =null; - if(res && res.data) prom=res.data.data; - if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time { + th.data.loading = 0; + //商品地址 + var goods = res.data.data.pageData; + th.setData({ + goods_btn: res.data.data.pageData, + total: res.data.data.total + }) + th.data.currentPage++; + //设置商品熏染 + th.set_good(goods); + + }) + break; + case "3": + var item = {}; + await app.request.promiseGet("/api/weshop/goodsGroup/pageGoodsList", { + data: { + store_id: os.stoid, + gpid: wgroup, + pageSize: th.data.goodscount, + page: th.data.currentPage, + isonsale: 1, + orderField: "sort", + orderType: 'asc', + user_id: user_id + } + }).then(res => { + th.data.loading = 0; + //商品地址 + var goods = res.data.data.pageData; + th.setData({ + goods_btn: res.data.data.pageData, + total: res.data.data.total + }) + + th.data.currentPage++; + //设置商品熏染 + th.set_good(goods); + + }) + break; } - } - - if(th.data.object.column==5){ - var arr = new Array(); - var rData=th.data.requestData; - //--三个三个一组--- - for(var i=0;i< rData.length;i+=3){ - arr.push(rData.slice(i,i+3)); - } - th.setData({ goods_array: arr,page: th.data.currentPage - 1, }); - }else{ - th.setData({ - goods_array: th.data.requestData, - page: th.data.currentPage - 1, + + }, + + setLoading: function() { + var that = this; + if (this.data.loading) return false; + this.data.loading = 1; + that.init(that.data.classstyle_id, that.data.wgroup); + }, + + //图片失败,默认图片 + bind_bnerr3: function(e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = this.data.imghost + "/public/images/default_goods_image_240.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + + //---卡的初始化---- + card_init: function() { + // var th = this, + // os = getApp().globalData.setting; + // if (!getApp().globalData.user_id) return false; + // getApp().request.get("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.user_id, { + // isShowLoading: false, + // success: function(e) { + // getApp().globalData.userInfo = e.data.data; + // getApp().getConfig2(function(e) { + // var swithc_list = e.switch_list; + // var sw_arr = JSON.parse(swithc_list); + // //---如果后台又开等级卡的开关--- + // if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { + // th.setData({ + // rank_switch: true + // }); + // //---回调卡的列表--- + // th.getPlusCardType(function(ob) { + // th.setData({ + // card_list: ob.card_list + // }); + // var ti = setInterval(function() { + // var user = getApp().globalData.userInfo; + // if (!user) return false; + // clearInterval(ti); + + // if (user.card_field && user['card_expiredate']) { + // var str = user['card_expiredate'].replace(/-/g, '/'); + // var end = new Date(str); + // end = Date.parse(end) / 1000; + // var now = ut.gettimestamp(); + + // //--- 判断是等级会员,且在有效期范围内 --- + // if (user.card_field && now < end) { + // var card_name = ob.name_map.get(user.card_field); + // if (card_name.length > 4) card_name = card_name.substring(0, 4); + // th.setData({ + // card_field: user.card_field, + // card_name: card_name, + // card_list: ob.card_list + // }); + // } + + // } + + // }, 500) + // }) + + // } + // }) + // } + // }) + + }, + + //--- 获取卡类列表 --- + getPlusCardType: function(func) { + // var storid = o.stoid; + // var th = this; + // getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { + // var plusCard = res.data.data; + // var arr = [1219, 2089, 3031]; + // var new_arr = new Array(); + // var card_name_map = new Map(); + + // var user = getApp().globalData.userInfo; + + // if (plusCard) { + + // for (var i = 0; i < plusCard.length; i++) { + // if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { + // continue; + // } + + // var name = "card" + plusCard[i].CorrPrice.toLowerCase(); + // card_name_map.set(name, plusCard[i].CardName); + // new_arr.push(plusCard[i]); + // } + // } + + // var ob = { + // "card_list": new_arr, + // "name_map": card_name_map + // }; + // func(ob); + // }) + }, + + + //--- 点击tab的事件 --- + gr_set_nav: function(e) { + + var title_idx = e.currentTarget.dataset.index; + if (title_idx == this.data.title_index) return false; + wx.showLoading(); + + var nav_item = this.data.object.nav_list[title_idx]; + this.data.g_id = []; + if (this.data.object.nav_list && this.data.object.nav_list[title_idx] && this.data.object.nav_list[title_idx].data) + this.data.g_id = this.data.object.nav_list[title_idx].data; + var arr = []; + for (var i = 0; i < this.data.g_id.length; i += this.data.goodscount) { + // for (var i = 0; i < this.data.g_id.length; i ++) { + arr.push(this.data.g_id.slice(i, i + this.data.goodscount)); + } + this.data.firist_type_data = arr; + this.data.firist_type_curr = 0; + this.data.requestData = []; + + // 在组件实例进入页面节点树时执行 + if (nav_item) { + this.data.classstyle_id = nav_item.classstyle; + this.data.wgroup = nav_item.wgroup; + } + + + this.data.is_recommend = this.data.is_hot = this.data.is_new = 0; + //推荐,热卖,新品 + if (nav_item && nav_item.goodsclass == 1) { + this.data.is_recommend = 1 + } + if (nav_item && nav_item.goodsclass == 2) { + this.data.is_hot = 1 + } + if (nav_item && nav_item.goodsclass == 3) { + this.data.is_new = 1 + } + + + this.data.currentPage = 1; + this.setData({ + goods_array: null, + total: null, + title_index: title_idx }); + //初始化 + this.init(this.data.classstyle_id, this.data.wgroup); + setTimeout(function() { + wx.hideLoading(); + }, 1000) + }, + + //--- 设置 --- + set_good: async function(goods) { + var now = ut.gettimestamp(); + var th = this; + if (!goods || goods.length == 0) return false; + var user_id = getApp().globalData.userInfo.user_id; + if (!user_id) user_id = 0; + for (var i in goods) { + var val = goods[i]; + var item = {}; + var prom_id = null; + //app.request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + val.goods_id, {}).then(res => { + + // var url = "/api/weshop/activitylist/getGoodActInfo"; + // var req_data = { + // store_id: os.stoid, + // goodsidlist: val.goods_id, + // is_detail: 1, + // user_id: user_id + // }; + + //获取商品的实际活动 + // await getApp().request.promiseGet(url, { + // data: req_data + // }).then(res => { + // if (res.data.code == 0 && res.data.data && res.data.data.length == 1) { + // item.prom_type = res.data.data[0].prom_type; + // item.prom_id = res.data.data[0].act_id; + // } + // }) + // console.log('val++++++<<<<<', val); + item.goods_name = val.serviceName; + item.goods_img = th.data.imghost + val.imgUrl; + item.market_price = val.show_price; + item.shop_price = val.money; + item.sales_sum = val.sales_sum; + item.goods_id = val.id; + + // item.cardprice1 = val.cardprice1; + // item.cardprice2 = val.cardprice2; + // item.cardprice3 = val.cardprice3; + // item.prom_type = val.prom_type; + // item.prom_id = val.prom_id; + + if (val.prom_price) item.prom_price = val.prom_price; + if (val.prom_integral) item.prom_integral = val.prom_integral; + + prom_id = val.prom_id; + + var prom_type = val.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 + + var url = ""; + + // switch (prom_type) { + // case 1: + // var user_id = getApp().globalData.user_id; + // if (!user_id) user_id = 0; + // url = "/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id; + // break; + // case 2: + // url = "/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + val.goods_id + "/" + prom_id + // break; + // case 4: + // url = "/api/weshop/integralbuy/get/" + os.stoid + "/" + prom_id; + // break; + // case 6: + // url = "/api/weshop/teamlist/get/" + os.stoid + "/" + prom_id; + // break; + // case 8: + // var presell_id = prom_id; + // var url1 = "/api/weshop/marketing/marketingPresellList/list"; + // var rd = { + // store_id: os.stoid, + // presell_id: presell_id, + // goods_id: val.goods_id + // } + // //------获取预售从表---------- + // await getApp().request.promiseGet(url1, { + // data: rd + // }).then(res => { + // if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + // var arr = res.data.data[0]; + // item.prom_price = arr.luck_goods_price; + // item.sales_sum = arr.buy_goodnum + (arr.virtual_qty ? arr.virtual_qty : 0); + // } + // }) + // break; + // default: + // break + // } + + if (url != null && url != '') { + await getApp().request.promiseGet(url, {}).then(res => { + var prom = null; + if (res && res.data) prom = res.data.data; + if (prom != null && prom.is_end == 0 && prom.end_time > now && (prom.start_time < now || (prom.show_time && + prom.show_time < now))) { + item.prom_price = res.data.data.price; + if (res.data.data.user_price) item.prom_price = res.data.data.user_price; + var vNum = res.data.data.virtual_num ? res.data.data.virtual_num : 0; + var vNum1 = res.data.data.virtualNum ? res.data.data.virtualNum : 0; + var vNum2 = res.data.data.virtual ? res.data.data.virtual : 0; + item.sales_sum = res.data.data.buy_num + (vNum + vNum1 + vNum2); + } else { + item.prom_type = 0; + item.prom_id = 0; + item.prom_price = null; + } + + th.data.requestData.push(item); + }) + } else { + th.data.requestData.push(item); + } + } + + if (th.data.object.column == 5) { + var arr = new Array(); + var rData = th.data.requestData; + //--三个三个一组--- + for (var i = 0; i < rData.length; i += 3) { + arr.push(rData.slice(i, i + 3)); + } + th.setData({ + goods_array: arr, + page: th.data.currentPage - 1, + }); + } else { + th.setData({ + goods_array: th.data.requestData, + page: th.data.currentPage - 1, + }); + } + + + // console.log('goods_array0000000000====>>>', th.data.goods_array); + + }, + + re_show: function() { + if (this.data.object.goodscount * this.data.page < this.data.total) { + this.setLoading() + } } - - }, - re_show:function () { - if(this.data.object.goodscount *this.data.page --> - + - 标题1 - 标题标题2 - 标题3 - 标题标题标题4 - 标题5 - 标题6 - 标题题7 - 标题8 - 标题题9 - 标题10 - 标题11 - 标题12222 + {{item.title}} - + - - + + - + @@ -68,7 +64,8 @@ - {{item.goods_name}} + + {{item.goods_name}} @@ -190,7 +187,7 @@ - + @@ -352,7 +349,7 @@ - + @@ -511,7 +508,7 @@ - + @@ -694,7 +691,7 @@ - + diff --git a/components/diy_serviceCard/diy_serviceCard.wxss b/components/diy_serviceCard/diy_serviceCard.wxss index 3b53fcb..19c0859 100644 --- a/components/diy_serviceCard/diy_serviceCard.wxss +++ b/components/diy_serviceCard/diy_serviceCard.wxss @@ -104,7 +104,7 @@ width: 56rpx; height: 56rpx; position: absolute; - left: 0rpx; + left: 10rpx; top: 10rpx; } @@ -112,7 +112,7 @@ width: 56rpx; height: 56rpx; position: absolute; - right: 0rpx; + right: 10rpx; top: 10rpx; } @@ -120,7 +120,7 @@ width: 56rpx; height: 56rpx; position: absolute; - left: 0rpx; + left: 10rpx; bottom: 10rpx; } @@ -128,7 +128,7 @@ width: 56rpx; height: 56rpx; position: absolute; - right: 20rpx; + right: 10rpx; bottom: 10rpx; } @@ -906,17 +906,22 @@ top: 10rpx; .scroll-view-item { flex-shrink: 0; - border: 2rpx solid #ddd; + border-width: 2rpx; + border-style: solid; + border-color: #ddd; border-radius: 80rpx; - padding: 10rpx 20rpx; + padding: 10rpx 30rpx; margin: 20rpx 10rpx; /* font-size: 28rpx; */ box-sizing: border-box; + text-align: center; + /* flex: 1; */ + flex-grow: 1; } .scroll-view-item.active { - color: red; - border-color: red; + color: #f2270c; + border-color: #f2270c !important; } @@ -925,7 +930,7 @@ top: 10rpx; padding-top: 20rpx; padding-left: 10rpx; padding-right: 10rpx; - flex: 1; + /* flex: 1; */ flex-basis: 50%; } -- libgit2 0.21.4