Commit a4e94ec2eab8789455c120a87d6b7dc831918d40
1 parent
912c8c00
搜索框优化
Showing
3 changed files
with
537 additions
and
397 deletions
pages/goods/search/search.js
| 1 | -var t = function (t) { | 1 | +var t = function(t) { |
| 2 | return t && t.__esModule ? t : { | 2 | return t && t.__esModule ? t : { |
| 3 | default: t | 3 | default: t |
| 4 | }; | 4 | }; |
| 5 | }(require("../../../utils/LoadMore.js")), ut = require("../../../utils/util.js"), | 5 | }(require("../../../utils/LoadMore.js")), ut = require("../../../utils/util.js"), |
| 6 | - a = getApp(), e = new t.default(), rq = a.request, oo = a.globalData.setting; | 6 | + a = getApp(), e = new t.default(), rq = a.request, oo = a.globalData.setting; |
| 7 | 7 | ||
| 8 | Page({ | 8 | Page({ |
| 9 | data: { | 9 | data: { |
| @@ -18,157 +18,147 @@ Page({ | @@ -18,157 +18,147 @@ Page({ | ||
| 18 | requestUrl: "", | 18 | requestUrl: "", |
| 19 | //hotWords: [ [ "手机", "小米", "iphone" ], [ "三星", "华为", "冰箱" ] ] | 19 | //hotWords: [ [ "手机", "小米", "iphone" ], [ "三星", "华为", "冰箱" ] ] |
| 20 | hotWords: null, | 20 | hotWords: null, |
| 21 | - is_no_plus:1, | 21 | + |
| 22 | tabname: "sort", //排序的字段 | 22 | tabname: "sort", //排序的字段 |
| 23 | adname: "asc", //升降的字段 | 23 | adname: "asc", //升降的字段 |
| 24 | - rq_data: null, | ||
| 25 | - searchRecord: [], | ||
| 26 | - keyword: '', | ||
| 27 | - is_his: 0, | 24 | + rq_data:null, |
| 25 | + | ||
| 26 | + | ||
| 27 | + searchRecord: [], | ||
| 28 | + keyword: '', | ||
| 29 | + is_his:0, | ||
| 30 | + | ||
| 31 | + hiddenClear: true, | ||
| 28 | }, | 32 | }, |
| 29 | - | ||
| 30 | - onLoad: function (t) { | ||
| 31 | - this.data.rq_data = t; | 33 | + |
| 34 | + onLoad: function(t) { | ||
| 35 | + this.data.rq_data=t; | ||
| 32 | //接受有没有导购的参数 | 36 | //接受有没有导购的参数 |
| 33 | - var first_leader = t.first_leader; | ||
| 34 | - if (first_leader) { | ||
| 35 | - getApp().globalData.first_leader = first_leader; | 37 | + var first_leader=t.first_leader; |
| 38 | + if(first_leader){ | ||
| 39 | + getApp().globalData.first_leader=first_leader; | ||
| 36 | //调用接口判断是不是会员 | 40 | //调用接口判断是不是会员 |
| 37 | - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + oo.stoid + "/" + first_leader, {}).then(res => { | ||
| 38 | - if (res.data.code == 0) { | ||
| 39 | - getApp().globalData.guide_id = res.data.data.id; | 41 | + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+oo.stoid+"/"+first_leader,{}).then(res=>{ |
| 42 | + if(res.data.code==0){ | ||
| 43 | + getApp().globalData.guide_id=res.data.data.id; | ||
| 40 | } | 44 | } |
| 41 | }) | 45 | }) |
| 42 | } | 46 | } |
| 43 | - var th = this; | ||
| 44 | - //调用接口判断商家plus有没有过期 | ||
| 45 | - rq.promiseGet("/store/storemoduleendtime/page?store_id=" + oo.stoid + "&type=3", {}).then(res => { | ||
| 46 | - if (res.data.code == 0) { | ||
| 47 | - var arr = res.data.data.pageData; | ||
| 48 | - if (arr.length > 0) { | ||
| 49 | - var item = arr[0]; | ||
| 50 | - if (item.is_sy == 0) { | ||
| 51 | - var now = Date.parse(new Date()); now = now / 1000; | ||
| 52 | - if (item.end_time < now) { | ||
| 53 | - th.setData({ is_no_plus: 0 }) | ||
| 54 | - } | ||
| 55 | - } | ||
| 56 | - } | ||
| 57 | - } | ||
| 58 | - }) | ||
| 59 | - a.getConfig2(function (rs) { | ||
| 60 | - console.log('getConfig2', rs); | ||
| 61 | - var arr = new Array(), arr2 = new Array(); | ||
| 62 | - if (rs.hot_keywords != null && ut.trim(rs.hot_keywords) != "") { | ||
| 63 | - var arr1 = rs.hot_keywords.split('|'); | ||
| 64 | - for (var i = 0; i < arr1.length; i++) { | ||
| 65 | - if (i % 5 == 0 && i != 0) { | ||
| 66 | - arr.push(arr2); | ||
| 67 | - arr2 = []; | ||
| 68 | - } else { | ||
| 69 | - arr2.push(arr1[i]); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - if (arr2.length > 0) arr.push(arr2); | ||
| 73 | - th.setData({ hotWords: arr }); | ||
| 74 | - } | ||
| 75 | - | ||
| 76 | - | ||
| 77 | - //计算等级价相关 | ||
| 78 | - var swithc_list = rs.switch_list; | ||
| 79 | - var sw_arr = JSON.parse(swithc_list); | ||
| 80 | - console.log('sw_arr', sw_arr); | ||
| 81 | - //---如果后台又开等级卡的开关--- | ||
| 82 | - if (sw_arr.rank_switch && sw_arr.rank_switch == "2") { | ||
| 83 | - th.setData({ rank_switch: true }); | ||
| 84 | - var user = getApp().globalData.userInfo; | ||
| 85 | - var ti = setInterval(function () { | ||
| 86 | - if (!user) return false; | ||
| 87 | - clearInterval(ti); | ||
| 88 | - //---回调卡的列表--- | ||
| 89 | - th.getPlusCardType(function (ob) { | ||
| 90 | - th.setData({ card_list: ob.card_list }); | ||
| 91 | - if (user.card_field) { | ||
| 92 | - var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 93 | - var end = new Date(str); | ||
| 94 | - end = Date.parse(end) / 1000; | ||
| 95 | - var now = ut.gettimestamp(); | ||
| 96 | 47 | ||
| 97 | - //--- 判断是等级会员,且在有效期范围内 --- | ||
| 98 | - if (user.card_field && now < end) { | ||
| 99 | - var card_name = ob.name_map.get(user.card_field); | ||
| 100 | - if (card_name.length > 7) card_name = card_name.substring(0, 8); | ||
| 101 | - th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list }); | ||
| 102 | - } | ||
| 103 | - } | ||
| 104 | - }) | ||
| 105 | - }, 500) | 48 | + var th=this; |
| 49 | + a.getConfig2(function(rs) { | ||
| 50 | + var arr=new Array(),arr2=new Array(); | ||
| 51 | + if (rs.hot_keywords != null && ut.trim(rs.hot_keywords)!="" ){ | ||
| 52 | + var arr1 = rs.hot_keywords.split('|'); | ||
| 53 | + for (var i = 0; i < arr1.length;i++){ | ||
| 54 | + if(i%5==0 && i!=0){ | ||
| 55 | + arr.push(arr2); | ||
| 56 | + arr2=[]; | ||
| 57 | + }else{ | ||
| 58 | + arr2.push(arr1[i]); | ||
| 59 | + } | ||
| 106 | } | 60 | } |
| 107 | - | ||
| 108 | - | ||
| 109 | - | 61 | + if (arr2.length > 0) arr.push(arr2); |
| 62 | + th.setData({ hotWords: arr}); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + | ||
| 66 | + //计算等级价相关 | ||
| 67 | + var swithc_list=rs.switch_list; | ||
| 68 | + var sw_arr=JSON.parse(swithc_list); | ||
| 69 | + //---如果后台又开等级卡的开关--- | ||
| 70 | + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ | ||
| 71 | + th.setData({rank_switch:true}); | ||
| 72 | + var user=getApp().globalData.userInfo; | ||
| 73 | + var ti=setInterval(function(){ | ||
| 74 | + if(!user) return false; | ||
| 75 | + clearInterval(ti); | ||
| 76 | + //---回调卡的列表--- | ||
| 77 | + th.getPlusCardType(function(ob){ | ||
| 78 | + th.setData({card_list:ob.card_list}); | ||
| 79 | + if(user.card_field ){ | ||
| 80 | + var str = user['card_expiredate'].replace(/-/g, '/'); | ||
| 81 | + var end = new Date(str); | ||
| 82 | + end = Date.parse(end) / 1000; | ||
| 83 | + var now = ut.gettimestamp(); | ||
| 84 | + | ||
| 85 | + //--- 判断是等级会员,且在有效期范围内 --- | ||
| 86 | + if(user.card_field && now<end){ | ||
| 87 | + var card_name=ob.name_map.get(user.card_field); | ||
| 88 | + if(card_name.length>7) card_name=card_name.substring(0,8); | ||
| 89 | + th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list}); | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + }) | ||
| 93 | + },500) | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + }) | ||
| 99 | + //e.init(this, "", "requestData"); | ||
| 100 | + var url = this.data.baseUrl; | ||
| 101 | + | ||
| 102 | + //扫一扫过来,显示搜索的内容 | ||
| 103 | + var s_key = t.s_key; | ||
| 104 | + if (s_key){ | ||
| 105 | + s_key=s_key.trim(); | ||
| 106 | + this.search(s_key); this.openSearchModal(); | ||
| 107 | + return; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + if (0 != t.brand_id && t.brand_id!=undefined){ url += "&brand_id=" + t.brand_id;} | ||
| 111 | + if (0 != t.nation_id && t.nation_id!=undefined) { url += "&nation_id=" + t.nation_id;} | ||
| 112 | + if (0 != t.max_price && t.max_price!=undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price;} | ||
| 113 | + if (0 != t.ladder_id && t.ladder_id != undefined) { | ||
| 114 | + url += "&ladder_id=" + t.ladder_id; | ||
| 115 | + this.setData({ | ||
| 116 | + baseUrl:url, | ||
| 110 | }) | 117 | }) |
| 111 | - //e.init(this, "", "requestData"); | ||
| 112 | - var url = this.data.baseUrl; | ||
| 113 | - | ||
| 114 | - //扫一扫过来,显示搜索的内容 | ||
| 115 | - var s_key = t.s_key; | ||
| 116 | - if (s_key) { | ||
| 117 | - s_key = s_key.trim(); | ||
| 118 | - this.search(s_key); this.openSearchModal(); | ||
| 119 | - return; | ||
| 120 | - } | ||
| 121 | - | ||
| 122 | - if (0 != t.brand_id && t.brand_id != undefined) { url += "&brand_id=" + t.brand_id; } | ||
| 123 | - if (0 != t.nation_id && t.nation_id != undefined) { url += "&nation_id=" + t.nation_id; } | ||
| 124 | - if (0 != t.max_price && t.max_price != undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price; } | ||
| 125 | - if (0 != t.ladder_id && t.ladder_id != undefined) { | ||
| 126 | - url += "&ladder_id=" + t.ladder_id; | ||
| 127 | - this.setData({ | ||
| 128 | - baseUrl: url, | ||
| 129 | - | ||
| 130 | - }) | ||
| 131 | - } | ||
| 132 | - if (url != this.data.baseUrl) return this.requestSearch(url); | ||
| 133 | - this.openSearchModal(); | 118 | + } |
| 119 | + if (url != this.data.baseUrl) return this.requestSearch(url); | ||
| 120 | + this.openSearchModal(); | ||
| 134 | // 获取历史搜索记录 | 121 | // 获取历史搜索记录 |
| 135 | - this.getHistorySearch(); | 122 | + this.getHistorySearch(); |
| 136 | }, | 123 | }, |
| 137 | - changeTab: function (t) { | ||
| 138 | - var ord = t.currentTarget.dataset.href; | ||
| 139 | - var ad = t.currentTarget.dataset.ad; | ||
| 140 | - | ||
| 141 | - var url = this.data.requestUrl; | ||
| 142 | - | ||
| 143 | - if (this.data.tabname != ord) { | ||
| 144 | - this.setData({ tabname: ord, adname: "desc" }); | ||
| 145 | - } else { | ||
| 146 | - ad = ad == "desc" ? "asc" : "desc"; | ||
| 147 | - this.setData({ adname: ad }); | ||
| 148 | - } | ||
| 149 | - this.resetData(), this.requestSearch(url); | 124 | + |
| 125 | + | ||
| 126 | + changeTab: function(t) { | ||
| 127 | + var ord = t.currentTarget.dataset.href; | ||
| 128 | + var ad = t.currentTarget.dataset.ad; | ||
| 129 | + | ||
| 130 | + var url = this.data.requestUrl; | ||
| 131 | + | ||
| 132 | + if (this.data.tabname != ord) { | ||
| 133 | + this.setData({ tabname: ord, adname: "desc" }); | ||
| 134 | + } else { | ||
| 135 | + ad = ad == "desc" ? "asc" : "desc"; | ||
| 136 | + this.setData({ adname: ad }); | ||
| 137 | + } | ||
| 138 | + this.resetData(), this.requestSearch(url); | ||
| 150 | 139 | ||
| 151 | }, | 140 | }, |
| 152 | 141 | ||
| 153 | //-----------真的调用地址进行搜索------------ | 142 | //-----------真的调用地址进行搜索------------ |
| 154 | - requestSearch: function (t) { | ||
| 155 | - if (this.data.loading) return false; | ||
| 156 | - this.data.loading = 1; | ||
| 157 | - var e = this, th = e; | ||
| 158 | - if (getApp().globalData.userInfo) { | ||
| 159 | - t += "&user_id=" + getApp().globalData.userInfo.user_id; | ||
| 160 | - } | 143 | + requestSearch: function(t) { |
| 144 | + console.log('t===>', t); | ||
| 145 | + if(this.data.loading) return false; | ||
| 146 | + this.data.loading=1; | ||
| 147 | + var e = this,th=e; | ||
| 148 | + if(getApp().globalData.userInfo) { | ||
| 149 | + t += "&user_id=" + getApp().globalData.userInfo.user_id; | ||
| 150 | + } | ||
| 161 | this.data.requestUrl = t; | 151 | this.data.requestUrl = t; |
| 162 | 152 | ||
| 163 | - var user_id = getApp().globalData.user_id; | ||
| 164 | - if (!user_id) user_id = 0; | 153 | + var user_id=getApp().globalData.user_id; |
| 154 | + if(!user_id) user_id=0; | ||
| 165 | 155 | ||
| 166 | - getApp().request.promiseGet(t, { data: { is_mainshow: 1, isonsale: 1, store_id: oo.stoid, orderField: e.data.tabname, orderType: e.data.adname, page: e.data.currentPage } }).then(async res => { | ||
| 167 | - th.data.loading = 0; | ||
| 168 | - if (ut.ajax_ok(res)) { | ||
| 169 | - if (!e.data.requestData) e.data.requestData = []; | ||
| 170 | - for (let i in res.data.data.pageData) { | ||
| 171 | - let item = res.data.data.pageData[i]; | 156 | + getApp().request.promiseGet(t, {data:{is_mainshow: 1, isonsale: 1, store_id: oo.stoid,orderField: e.data.tabname, orderType: e.data.adname, page: e.data.currentPage}}).then(async res=>{ |
| 157 | + th.data.loading=0; | ||
| 158 | + if(ut.ajax_ok(res)){ | ||
| 159 | + if(!e.data.requestData) e.data.requestData=[]; | ||
| 160 | + for(let i in res.data.data.pageData){ | ||
| 161 | + let item=res.data.data.pageData[i]; | ||
| 172 | item.original_img = th.data.url + item.original_img; | 162 | item.original_img = th.data.url + item.original_img; |
| 173 | 163 | ||
| 174 | /*-- | 164 | /*-- |
| @@ -185,48 +175,48 @@ Page({ | @@ -185,48 +175,48 @@ Page({ | ||
| 185 | })--*/ | 175 | })--*/ |
| 186 | 176 | ||
| 187 | var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 | 177 | var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 |
| 188 | - var prom_id = item.prom_id; | ||
| 189 | - var now = ut.gettimestamp(); | 178 | + var prom_id=item.prom_id; |
| 179 | + var now=ut.gettimestamp(); | ||
| 190 | var url = ""; | 180 | var url = ""; |
| 191 | - switch (prom_type) { | 181 | + switch (prom_type){ |
| 192 | case 1: | 182 | case 1: |
| 193 | - url = "/api/ms/flash_sale/getNew/" + oo.stoid + "/" + user_id + "/" + prom_id; | 183 | + url = "/api/ms/flash_sale/getNew/" +oo.stoid + "/" +user_id+"/"+ prom_id; |
| 194 | break; | 184 | break; |
| 195 | case 2: | 185 | case 2: |
| 196 | - url = "/api/weshop/goods/groupBuy/getActInfo/" + oo.stoid + "/" + item.goods_id + "/" + prom_id | 186 | + url ="/api/weshop/goods/groupBuy/getActInfo/" +oo.stoid + "/" +item.goods_id+"/"+ prom_id |
| 197 | break; | 187 | break; |
| 198 | case 4: | 188 | case 4: |
| 199 | - url = "/api/weshop/integralbuy/get/" + oo.stoid + "/" + prom_id; | 189 | + url ="/api/weshop/integralbuy/get/"+oo.stoid +"/"+prom_id; |
| 200 | break; | 190 | break; |
| 201 | case 6: | 191 | case 6: |
| 202 | url = "/api/weshop/teamlist/get/" + oo.stoid + "/" + prom_id; | 192 | url = "/api/weshop/teamlist/get/" + oo.stoid + "/" + prom_id; |
| 203 | - await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1", { | ||
| 204 | - data: { | ||
| 205 | - store_id: oo.stoid, | ||
| 206 | - is_end: 0, | ||
| 207 | - is_show: 1, | ||
| 208 | - user_id: getApp().globalData.user_id, | ||
| 209 | - pageSize: 1000, | 193 | + await getApp().request.promiseGet("/api/weshop/teamlist/pageteam/1",{ |
| 194 | + data:{ | ||
| 195 | + store_id: oo.stoid, | ||
| 196 | + is_end: 0, | ||
| 197 | + is_show: 1, | ||
| 198 | + user_id: getApp().globalData.user_id, | ||
| 199 | + pageSize:1000, | ||
| 210 | } | 200 | } |
| 211 | - }).then(pd => { | ||
| 212 | - let pd_list = pd.data.data.pageData; | ||
| 213 | - if (res.data.code == 0 && pd_list.length > 0) { | ||
| 214 | - var flag = pd_list.some(pd => { | ||
| 215 | - return pd.goods_id == item.goods_id | ||
| 216 | - }) | ||
| 217 | - | ||
| 218 | - if (!flag) { | ||
| 219 | - item.prom_type = 0; | ||
| 220 | - item.prom_id = 0; | ||
| 221 | - item.prom_price = null; | ||
| 222 | - } | 201 | + }).then(pd=>{ |
| 202 | + let pd_list=pd.data.data.pageData; | ||
| 203 | + if(res.data.code==0 && pd_list.length>0){ | ||
| 204 | + var flag = pd_list.some(pd=>{ | ||
| 205 | + return pd.goods_id==item.goods_id | ||
| 206 | + }) | ||
| 207 | + | ||
| 208 | + if(!flag){ | ||
| 209 | + item.prom_type=0; | ||
| 210 | + item.prom_id=0; | ||
| 211 | + item.prom_price=null; | ||
| 212 | + } | ||
| 223 | } | 213 | } |
| 224 | - }) | 214 | + }) |
| 225 | break; | 215 | break; |
| 226 | case 8: | 216 | case 8: |
| 227 | var presell_id = prom_id; | 217 | var presell_id = prom_id; |
| 228 | var url1 = "/api/weshop/marketing/marketingPresellList/list"; | 218 | var url1 = "/api/weshop/marketing/marketingPresellList/list"; |
| 229 | - var rd = { | 219 | + var rd= { |
| 230 | store_id: oo.stoid, | 220 | store_id: oo.stoid, |
| 231 | presell_id: presell_id, | 221 | presell_id: presell_id, |
| 232 | goods_id: item.goods_id | 222 | goods_id: item.goods_id |
| @@ -238,247 +228,269 @@ Page({ | @@ -238,247 +228,269 @@ Page({ | ||
| 238 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | 228 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { |
| 239 | var arr = res.data.data[0]; | 229 | var arr = res.data.data[0]; |
| 240 | item.prom_price = arr.luck_goods_price; | 230 | item.prom_price = arr.luck_goods_price; |
| 241 | - item.sales_sum = arr.buy_goodnum + (arr.virtual_qty ? arr.virtual_qty : 0); | 231 | + item.sales_sum=arr.buy_goodnum+(arr.virtual_qty?arr.virtual_qty:0); |
| 242 | } | 232 | } |
| 243 | }) | 233 | }) |
| 244 | break; | 234 | break; |
| 245 | default: | 235 | default: |
| 246 | - break | ||
| 247 | - } | ||
| 248 | - if (url != null && url != '') { | 236 | + break; |
| 237 | + }; | ||
| 238 | + if(url!=null && url!=''){ | ||
| 249 | await getApp().request.promiseGet(url, {}).then(async res => { | 239 | await getApp().request.promiseGet(url, {}).then(async res => { |
| 250 | - var prom = null; | ||
| 251 | - if (res.data.code == 0 && res.data.data) { | ||
| 252 | - prom = res.data.data; | 240 | + var prom =null; |
| 241 | + if(res.data.code==0 && res.data.data){ | ||
| 242 | + prom=res.data.data; | ||
| 253 | 243 | ||
| 254 | - if (prom != null && prom.is_end == 0 && prom.end_time > now && (prom.start_time < now || (prom.show_time && prom.show_time < now))) { | 244 | + if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) { |
| 255 | item.prom_price = res.data.data.price; | 245 | item.prom_price = res.data.data.price; |
| 256 | - if (res.data.data.user_price) item.prom_price = res.data.data.user_price; | ||
| 257 | - var vNum = prom.virtual_num ? prom.virtual_num : 0; | ||
| 258 | - var vNum1 = prom.virtualNum ? prom.virtualNum : 0; | ||
| 259 | - var vNum2 = prom.virtual ? prom.virtual : 0; | ||
| 260 | - item.sales_sum = prom.buy_num + (vNum + vNum1 + vNum2); | ||
| 261 | - } else { | ||
| 262 | - item.prom_type = 0; | ||
| 263 | - item.prom_id = 0; | ||
| 264 | - item.prom_price = null; | 246 | + if(res.data.data.user_price) item.prom_price=res.data.data.user_price; |
| 247 | + var vNum=prom.virtual_num?prom.virtual_num:0; | ||
| 248 | + var vNum1=prom.virtualNum?prom.virtualNum:0; | ||
| 249 | + var vNum2=prom.virtual?prom.virtual:0; | ||
| 250 | + item.sales_sum=prom.buy_num+(vNum+vNum1+vNum2); | ||
| 251 | + }else{ | ||
| 252 | + item.prom_type=0; | ||
| 253 | + item.prom_id=0; | ||
| 254 | + item.prom_price=null; | ||
| 265 | } | 255 | } |
| 266 | - | ||
| 267 | - | ||
| 268 | } | 256 | } |
| 269 | }) | 257 | }) |
| 270 | - } | ||
| 271 | - if (!th.data.requestData) th.data.requestData = []; | 258 | + }; |
| 259 | + if(!th.data.requestData) th.data.requestData=[]; | ||
| 272 | th.data.requestData.push(item); | 260 | th.data.requestData.push(item); |
| 273 | - e.setData({ requestData: e.data.requestData }); | 261 | + e.setData({requestData: e.data.requestData}); |
| 274 | } | 262 | } |
| 275 | } | 263 | } |
| 276 | e.closeSearchModal(); | 264 | e.closeSearchModal(); |
| 277 | }) | 265 | }) |
| 278 | }, | 266 | }, |
| 279 | - onReachBottom: function () { | 267 | + onReachBottom: function() { |
| 268 | + console.log('触发上滑加载事件'); | ||
| 280 | this.data.currentPage++ | 269 | this.data.currentPage++ |
| 270 | + console.log('触发上滑加载事件currentPage',this.data.currentPage); | ||
| 281 | this.data.openSearchModal || e.canloadMore() && this.requestSearch(this.data.requestUrl); | 271 | this.data.openSearchModal || e.canloadMore() && this.requestSearch(this.data.requestUrl); |
| 282 | }, | 272 | }, |
| 283 | - openFilterModal: function () { | 273 | + |
| 274 | + | ||
| 275 | + openFilterModal: function() { | ||
| 284 | this.setData({ | 276 | this.setData({ |
| 285 | openFilterModal: !0 | 277 | openFilterModal: !0 |
| 286 | }); | 278 | }); |
| 287 | }, | 279 | }, |
| 288 | - closeFilterModal: function () { | 280 | + closeFilterModal: function() { |
| 289 | this.setData({ | 281 | this.setData({ |
| 290 | openFilterModal: !1 | 282 | openFilterModal: !1 |
| 291 | }); | 283 | }); |
| 292 | }, | 284 | }, |
| 293 | - filterGoods: function (t) { | 285 | + filterGoods: function(t) { |
| 294 | this.resetData(), this.requestSearch(t.currentTarget.dataset.href), this.closeFilterModal(); | 286 | this.resetData(), this.requestSearch(t.currentTarget.dataset.href), this.closeFilterModal(); |
| 295 | }, | 287 | }, |
| 296 | - resetData: function () { | 288 | + |
| 289 | + | ||
| 290 | + | ||
| 291 | + resetData: function() { | ||
| 297 | e.resetConfig(), this.data.requestData = null, this.data.currentPage = 1; | 292 | e.resetConfig(), this.data.requestData = null, this.data.currentPage = 1; |
| 298 | }, | 293 | }, |
| 299 | 294 | ||
| 300 | //---回复最初的设置---显示全部分类-- | 295 | //---回复最初的设置---显示全部分类-- |
| 301 | - restoreData: function () { | 296 | + restoreData: function() { |
| 302 | this.setData({ | 297 | this.setData({ |
| 303 | requestData: this.data.allData, | 298 | requestData: this.data.allData, |
| 304 | }); | 299 | }); |
| 305 | - this.data.currentPage = 2; | 300 | + this.data.currentPage=2; |
| 306 | }, | 301 | }, |
| 307 | - openSearchModal: function () { | 302 | + openSearchModal: function() { |
| 308 | this.setData({ | 303 | this.setData({ |
| 309 | openSearchModal: !0 | 304 | openSearchModal: !0 |
| 310 | }); | 305 | }); |
| 311 | }, | 306 | }, |
| 312 | - closeSearchModal: function () { | 307 | + closeSearchModal: function() { |
| 313 | this.setData({ | 308 | this.setData({ |
| 314 | openSearchModal: !1 | 309 | openSearchModal: !1 |
| 315 | }); | 310 | }); |
| 316 | }, | 311 | }, |
| 317 | - submitSearch: function (t) { | ||
| 318 | - console.log(111, t); | ||
| 319 | - var val = t.detail.value.word; | ||
| 320 | - if (val == undefined) val = t.detail.value; | ||
| 321 | - val = val ? val.trim() : ''; | ||
| 322 | - if (!val) { | ||
| 323 | - a.showWarning("请输入搜索关键词"); | ||
| 324 | - } | ||
| 325 | - this.search(val); | ||
| 326 | - | 312 | + |
| 313 | + submitSearch: function(t) { | ||
| 314 | + var val=t.detail.value.word; | ||
| 315 | + if(val==undefined) val=t.detail.value; | ||
| 316 | + val=val?val.trim():''; | ||
| 317 | + if(!val){ | ||
| 318 | + a.showWarning("请输入搜索关键词"); | ||
| 319 | + } | ||
| 320 | + this.search(val); | ||
| 327 | }, | 321 | }, |
| 328 | 322 | ||
| 329 | //热搜关键字 | 323 | //热搜关键字 |
| 330 | - searchHotWord: function (t) { | ||
| 331 | - | ||
| 332 | - var word = t.currentTarget.dataset.word; | ||
| 333 | - this.historyRecord(word); | ||
| 334 | - this.search(word); | 324 | + searchHotWord: function(t) { |
| 325 | + var word = t.currentTarget.dataset.word; | ||
| 326 | + this.historyRecord(word); | ||
| 327 | + this.search(word); | ||
| 335 | }, | 328 | }, |
| 336 | 329 | ||
| 337 | //-----点击搜索按钮---- | 330 | //-----点击搜索按钮---- |
| 338 | - search: function (t) { | 331 | + search: function(t) { |
| 339 | if ("string" != typeof t || "" == t) return a.showWarning("请输入搜索关键词"); | 332 | if ("string" != typeof t || "" == t) return a.showWarning("请输入搜索关键词"); |
| 340 | - this.data.key_str = t; | ||
| 341 | - this.historyRecord(); | ||
| 342 | - this.resetData(), this.requestSearch(this.data.baseUrl + "&key_str=" + encodeURIComponent(t)); | 333 | + this.data.key_str=t; |
| 334 | + this.resetData(); | ||
| 335 | + this.requestSearch(this.data.baseUrl + "&key_str=" + encodeURIComponent(t)); | ||
| 336 | + this.historyRecord(); | ||
| 343 | }, | 337 | }, |
| 344 | 338 | ||
| 345 | //---------分享配置-------- | 339 | //---------分享配置-------- |
| 346 | onShareAppMessage: function (e) { | 340 | onShareAppMessage: function (e) { |
| 347 | - var curPage = this; | 341 | + var curPage=this; |
| 348 | var pagePath = curPage.route; //当前页面url | 342 | var pagePath = curPage.route; //当前页面url |
| 349 | if (pagePath.indexOf('/') != 0) { | 343 | if (pagePath.indexOf('/') != 0) { |
| 350 | pagePath = '/' + pagePath; | 344 | pagePath = '/' + pagePath; |
| 351 | } | 345 | } |
| 352 | 346 | ||
| 353 | - if (this.data.key_str) { | 347 | + if(this.data.key_str) { |
| 354 | pagePath += "?s_key=" + this.data.key_str; | 348 | pagePath += "?s_key=" + this.data.key_str; |
| 355 | } | 349 | } |
| 356 | 350 | ||
| 357 | - if (getApp().globalData.user_id) { | 351 | + if(getApp().globalData.user_id){ |
| 358 | 352 | ||
| 359 | - if (pagePath.indexOf("?") > 0) { | ||
| 360 | - pagePath += "&first_leader=" + getApp().globalData.user_id; | ||
| 361 | - } else { | ||
| 362 | - pagePath += "?first_leader=" + getApp().globalData.user_id; | 353 | + if(pagePath.indexOf("?")>0){ |
| 354 | + pagePath+="&first_leader="+getApp().globalData.user_id; | ||
| 355 | + }else{ | ||
| 356 | + pagePath+="?first_leader="+getApp().globalData.user_id; | ||
| 363 | } | 357 | } |
| 364 | } | 358 | } |
| 365 | 359 | ||
| 366 | - console.log("11-11" + pagePath); | 360 | + // console.log("11-11"+pagePath); |
| 367 | return { | 361 | return { |
| 368 | title: "商品搜索", | 362 | title: "商品搜索", |
| 369 | - path: pagePath, | 363 | + path:pagePath, |
| 370 | } | 364 | } |
| 371 | }, | 365 | }, |
| 372 | 366 | ||
| 373 | 367 | ||
| 374 | //---------图片失败,默认图片-------- | 368 | //---------图片失败,默认图片-------- |
| 375 | bind_bnerr: function (e) { | 369 | bind_bnerr: function (e) { |
| 376 | - var _errImg = e.target.dataset.errorimg; | ||
| 377 | - var _errObj = {}; | ||
| 378 | - _errObj[_errImg] = this.data.url + "/miniapp/images/default_g_img.gif"; | ||
| 379 | - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | 370 | + var _errImg = e.target.dataset.errorimg; |
| 371 | + var _errObj = {}; | ||
| 372 | + _errObj[_errImg] = this.data.url+ "/miniapp/images/default_g_img.gif"; | ||
| 373 | + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; | ||
| 380 | }, | 374 | }, |
| 381 | - | ||
| 382 | - //--- 获取卡类列表 --- | ||
| 383 | - getPlusCardType: function (func) { | ||
| 384 | - var storid = oo.stoid; | ||
| 385 | - var th = this; | ||
| 386 | - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 387 | - var plusCard = res.data.data; | ||
| 388 | - var arr = [1219, 2089, 3031]; | ||
| 389 | - var new_arr = new Array(); | ||
| 390 | - var card_name_map = new Map(); | ||
| 391 | - var user = getApp().globalData.userInfo; | ||
| 392 | - | ||
| 393 | - for (var i = 0; i < plusCard.length; i++) { | ||
| 394 | - if ((!user || user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) { | ||
| 395 | - continue; | ||
| 396 | - } | ||
| 397 | - var name = "card" + plusCard[i].CorrPrice.toLowerCase(); | ||
| 398 | - card_name_map.set(name, plusCard[i].CardName); | ||
| 399 | - new_arr.push(plusCard[i]); | ||
| 400 | - | ||
| 401 | - } | ||
| 402 | - | ||
| 403 | - var ob = { "card_list": new_arr, "name_map": card_name_map }; | ||
| 404 | - func(ob); | ||
| 405 | - }) | ||
| 406 | - }, | ||
| 407 | - | ||
| 408 | - | ||
| 409 | - getInput(e) { | ||
| 410 | - this.setData({ | ||
| 411 | - keyword: e.detail.value | ||
| 412 | - }); | ||
| 413 | - }, | ||
| 414 | - | ||
| 415 | - historyRecord(w) { | ||
| 416 | - let keyword = w; | ||
| 417 | - let self = this; | ||
| 418 | - if (!keyword) { | ||
| 419 | - keyword = this.data.key_str.trim(); | ||
| 420 | - } | ||
| 421 | - let searchRecord = this.data.searchRecord; | ||
| 422 | - if (!searchRecord || searchRecord.length == 0) searchRecord = wx.getStorageSync('searchRecord') || []; | ||
| 423 | - | ||
| 424 | - if (keyword) { | ||
| 425 | - | ||
| 426 | - var index = searchRecord.indexOf(keyword); | ||
| 427 | - if (index > -1) { | ||
| 428 | - // 已经存在该值 | ||
| 429 | - searchRecord.splice(index, 1); | ||
| 430 | - searchRecord.unshift(keyword); | ||
| 431 | - | ||
| 432 | - // 将历史记录添加到缓存中 | ||
| 433 | - wx.setStorage({ | ||
| 434 | - key: 'searchRecord', | ||
| 435 | - data: searchRecord, | ||
| 436 | - success: function (res) { | ||
| 437 | - self.setData({ | ||
| 438 | - searchRecord, | ||
| 439 | - }) | ||
| 440 | - } | ||
| 441 | - }) | ||
| 442 | - | ||
| 443 | - return; | ||
| 444 | - } else { | ||
| 445 | - if (searchRecord.length >= 10) { | ||
| 446 | - searchRecord.pop(); // 删除最早的一条记录 | ||
| 447 | - }; | ||
| 448 | - searchRecord.unshift(keyword); | ||
| 449 | - | ||
| 450 | - // // 将历史记录添加到缓存中 | ||
| 451 | - wx.setStorage({ | ||
| 452 | - key: 'searchRecord', | ||
| 453 | - data: searchRecord, | ||
| 454 | - success: function (res) { | ||
| 455 | - self.setData({ | ||
| 456 | - searchRecord, | ||
| 457 | - }) | ||
| 458 | - } | ||
| 459 | - }) | ||
| 460 | - }; | ||
| 461 | - }; | ||
| 462 | - }, | ||
| 463 | - | ||
| 464 | - | ||
| 465 | - | ||
| 466 | - | ||
| 467 | - getHistorySearch() { | ||
| 468 | - this.setData({ | ||
| 469 | - searchRecord: wx.getStorageSync('searchRecord') || [] //若无存储则为空 | ||
| 470 | - }); | ||
| 471 | - }, | ||
| 472 | - | ||
| 473 | - clearSearchRecord() { | ||
| 474 | - wx.clearStorageSync('searchRecord'); | ||
| 475 | - this.setData({ | ||
| 476 | - searchRecord: [] | ||
| 477 | - }); | ||
| 478 | - }, | ||
| 479 | - | ||
| 480 | - go_url: function (e) { | ||
| 481 | - var url = e.currentTarget.dataset.url; | 375 | + |
| 376 | + //--- 获取卡类列表 --- | ||
| 377 | + getPlusCardType: function (func) { | ||
| 378 | + var storid = oo.stoid; | ||
| 379 | + var th = this; | ||
| 380 | + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => { | ||
| 381 | + var plusCard = res.data.data; | ||
| 382 | + var arr = [1219, 2089, 3031]; | ||
| 383 | + var new_arr = new Array(); | ||
| 384 | + var card_name_map=new Map(); | ||
| 385 | + var user = getApp().globalData.userInfo; | ||
| 386 | + | ||
| 387 | + for (var i = 0; i < plusCard.length; i++) { | ||
| 388 | + if ((!user || user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) { | ||
| 389 | + continue; | ||
| 390 | + } | ||
| 391 | + var name="card"+plusCard[i].CorrPrice.toLowerCase(); | ||
| 392 | + card_name_map.set(name,plusCard[i].CardName); | ||
| 393 | + new_arr.push(plusCard[i]); | ||
| 394 | + | ||
| 395 | + } | ||
| 396 | + | ||
| 397 | + var ob={"card_list":new_arr,"name_map":card_name_map}; | ||
| 398 | + func(ob); | ||
| 399 | + }) | ||
| 400 | + }, | ||
| 401 | + | ||
| 402 | + | ||
| 403 | + getInput(e) { | ||
| 404 | + let val = e.detail.value; | ||
| 405 | + if(val) { | ||
| 406 | + this.setData({ | ||
| 407 | + keyword: e.detail.value, | ||
| 408 | + hiddenClear: false, | ||
| 409 | + }); | ||
| 410 | + } else { | ||
| 411 | + this.setData({ | ||
| 412 | + hiddenClear: true, | ||
| 413 | + }); | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + }, | ||
| 417 | + | ||
| 418 | + historyRecord(w) { | ||
| 419 | + let keyword =w; | ||
| 420 | + let self = this; | ||
| 421 | + if(!keyword){ | ||
| 422 | + keyword = this.data.key_str.trim(); | ||
| 423 | + } | ||
| 424 | + let searchRecord = this.data.searchRecord; | ||
| 425 | + if(!searchRecord || searchRecord.length==0) searchRecord=wx.getStorageSync('searchRecord') || []; | ||
| 426 | + | ||
| 427 | + if(keyword) { | ||
| 428 | + | ||
| 429 | + var index=searchRecord.indexOf(keyword); | ||
| 430 | + if(index > -1) { | ||
| 431 | + // 已经存在该值 | ||
| 432 | + searchRecord.splice(index,1); | ||
| 433 | + searchRecord.unshift(keyword); | ||
| 434 | + | ||
| 435 | + // 将历史记录添加到缓存中 | ||
| 436 | + wx.setStorage({ | ||
| 437 | + key: 'searchRecord', | ||
| 438 | + data: searchRecord, | ||
| 439 | + success: function(res) { | ||
| 440 | + self.setData({ | ||
| 441 | + searchRecord, | ||
| 442 | + }) | ||
| 443 | + } | ||
| 444 | + }) | ||
| 445 | + | ||
| 446 | + return; | ||
| 447 | + } else { | ||
| 448 | + if(searchRecord.length >= 10) { | ||
| 449 | + searchRecord.pop(); // 删除最早的一条记录 | ||
| 450 | + }; | ||
| 451 | + searchRecord.unshift(keyword); | ||
| 452 | + | ||
| 453 | + // // 将历史记录添加到缓存中 | ||
| 454 | + wx.setStorage({ | ||
| 455 | + key: 'searchRecord', | ||
| 456 | + data: searchRecord, | ||
| 457 | + success: function(res) { | ||
| 458 | + self.setData({ | ||
| 459 | + searchRecord, | ||
| 460 | + }) | ||
| 461 | + } | ||
| 462 | + }) | ||
| 463 | + }; | ||
| 464 | + }; | ||
| 465 | + }, | ||
| 466 | + | ||
| 467 | + | ||
| 468 | + | ||
| 469 | + // 获取历史搜索记录 | ||
| 470 | + getHistorySearch() { | ||
| 471 | + this.setData({ | ||
| 472 | + searchRecord: wx.getStorageSync('searchRecord') || [] //若无存储则为空 | ||
| 473 | + }); | ||
| 474 | + }, | ||
| 475 | + | ||
| 476 | + // 清除历史搜素记录 | ||
| 477 | + clearSearchRecord() { | ||
| 478 | + wx.clearStorageSync('searchRecord'); | ||
| 479 | + this.setData({ | ||
| 480 | + searchRecord: [] | ||
| 481 | + }); | ||
| 482 | + }, | ||
| 483 | + | ||
| 484 | + go_url:function (e) { | ||
| 485 | + var url=e.currentTarget.dataset.url; | ||
| 482 | getApp().goto(url); | 486 | getApp().goto(url); |
| 483 | - } | 487 | + }, |
| 488 | + | ||
| 489 | + clearInput() { | ||
| 490 | + this.setData({ | ||
| 491 | + keyword: '', | ||
| 492 | + hiddenClear: true, | ||
| 493 | + openSearchModal: true, | ||
| 494 | + }); | ||
| 495 | + } | ||
| 484 | }); | 496 | }); |
| 485 | \ No newline at end of file | 497 | \ No newline at end of file |
pages/goods/search/search.wxml
| 1 | <wxs module="g_filter" src="g_filter.wxs"></wxs> | 1 | <wxs module="g_filter" src="g_filter.wxs"></wxs> |
| 2 | + | ||
| 2 | <view class="container"> | 3 | <view class="container"> |
| 3 | - <view class="nav"> | ||
| 4 | - <navigator bindtap="changeTab" class="nav-item" data-href="sort" data-ad="{{adname}}">综合 | ||
| 5 | - <view class="ico-dg" wx:if="{{tabname=='sort'}}"> | ||
| 6 | - <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 7 | - <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 8 | - </view> | ||
| 9 | - </navigator> | ||
| 10 | - <navigator bindtap="changeTab" class="nav-item" data-href="sales_sum" data-ad="{{adname}}">销量 | ||
| 11 | - <view class="ico-dg" wx:if="{{tabname=='sales_sum'}}"> | ||
| 12 | - <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 13 | - <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 14 | - </view> | ||
| 15 | - </navigator> | ||
| 16 | - <navigator bindtap="changeTab" class="nav-item" data-href="final_price" data-ad="{{adname}}">价格 | ||
| 17 | - <view class="ico-dg" wx:if="{{tabname=='final_price'}}"> | ||
| 18 | - <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 19 | - <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 20 | - </view> | ||
| 21 | - </navigator> | ||
| 22 | - <!-- <navigator bindtap="openFilterModal" class="nav-item">筛选<view class="ico-filter"> | ||
| 23 | - <image class="wh100" src="{{url}}/miniapp/images/xx.png"></image> | ||
| 24 | - </view> | ||
| 25 | - </navigator> --> | ||
| 26 | - <navigator bindtap="openSearchModal" class="nav-item nav-search"> | ||
| 27 | - <image class="wh100 search-img" src="{{url}}/miniapp/images/search.png"></image> | ||
| 28 | - </navigator> | ||
| 29 | - </view> | 4 | + <!-- 搜索框 --> |
| 5 | + <view class="search-bar"> | ||
| 6 | + <form bindsubmit="submitSearch"> | ||
| 7 | + <view class="pdh20 pdv10 flex ai_c jc_sb"> | ||
| 8 | + <view class="input-box"> | ||
| 9 | + <input autoFocus class="input-search" name="word" placeholder="搜索商品" bindconfirm="submitSearch" bindinput="getInput" value="{{keyword}}"/> | ||
| 10 | + <text class="iconfont icon-guan" hidden="{{hiddenClear}}" catchtap="clearInput"></text> | ||
| 11 | + </view> | ||
| 12 | + <button class="btn" formType="submit" hover-class="none">搜索</button> | ||
| 13 | + </view> | ||
| 14 | + </form> | ||
| 15 | + </view> | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + <view wx:if="{{openSearchModal}}"> | ||
| 19 | + <view class="pd20"> | ||
| 20 | + <view class="" wx:if="{{searchRecord.length != 0}}"> | ||
| 21 | + <view class="flex jc_sb ai_c"> | ||
| 22 | + <text class="fs28 bold">历史搜索</text> | ||
| 23 | + <text class="iconfont icon-shanchu c-6" bindtap="clearSearchRecord" wx:if="{{searchRecord.length != 0}}"></text> | ||
| 24 | + </view> | ||
| 25 | + <block wx:if="{{searchRecord.length>0}}"> | ||
| 26 | + <view class="hot-row flex flex-wrap" wx:key="{{index}}"> | ||
| 27 | + <view class="hot-item history ellipsis-1" bindtap="searchHotWord" data-word="{{item}}" wx:for="{{searchRecord}}" wx:key="{{index}}">{{item}}</view> | ||
| 28 | + </view> | ||
| 29 | + </block> | ||
| 30 | + <view wx:else class="fs24">暂无历史搜索记录</view> | ||
| 31 | + </view> | ||
| 32 | + | ||
| 33 | + <view class="" wx:if="{{hotWords.length>0}}"> | ||
| 34 | + <view class="fs28 bold">热门搜索</view> | ||
| 35 | + <block wx:if="{{hotWords.length>0}}"> | ||
| 36 | + <view class="hot-row" wx:for="{{hotWords}}" wx:key="{{index}}"> | ||
| 37 | + <view bindtap="searchHotWord" class="hot-item" data-word="{{item}}" wx:for="{{item}}" wx:key="{{index}}">{{item}}</view> | ||
| 38 | + </view> | ||
| 39 | + </block> | ||
| 40 | + </view> | ||
| 41 | + </view> | ||
| 42 | + </view> | ||
| 43 | + | ||
| 44 | + | ||
| 45 | + | ||
| 46 | + <block wx:if="{{!openSearchModal}}"> | ||
| 47 | + | ||
| 48 | + | ||
| 49 | + <view class="nav flex"> | ||
| 50 | + <navigator bindtap="changeTab" class="nav-item f1" data-href="sort" data-ad="{{adname}}">综合 | ||
| 51 | + <view class="ico-dg" wx:if="{{tabname=='sort'}}"> | ||
| 52 | + <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 53 | + <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 54 | + </view> | ||
| 55 | + </navigator> | ||
| 56 | + <navigator bindtap="changeTab" class="nav-item f1" data-href="sales_sum" data-ad="{{adname}}">销量 | ||
| 57 | + <view class="ico-dg" wx:if="{{tabname=='sales_sum'}}"> | ||
| 58 | + <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 59 | + <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 60 | + </view> | ||
| 61 | + </navigator> | ||
| 62 | + <navigator bindtap="changeTab" class="nav-item f1" data-href="final_price" data-ad="{{adname}}">价格 | ||
| 63 | + <view class="ico-dg" wx:if="{{tabname=='final_price'}}"> | ||
| 64 | + <image class="wh100" src="{{url}}/miniapp/images/dg.png" wx:if="{{adname=='desc'}}"></image> | ||
| 65 | + <image class="wh100" src="{{url}}/miniapp/images/up_s.png" wx:if="{{adname=='asc'}}"></image> | ||
| 66 | + </view> | ||
| 67 | + </navigator> | ||
| 68 | + <!-- <navigator bindtap="openFilterModal" class="nav-item">筛选<view class="ico-filter"> | ||
| 69 | + <image class="wh100" src="{{url}}/miniapp/images/xx.png"></image> | ||
| 70 | + </view> | ||
| 71 | + </navigator> --> | ||
| 72 | + <!-- <navigator bindtap="openSearchModal" class="nav-item nav-search"> | ||
| 73 | + <image class="wh100 search-img" src="{{url}}/miniapp/images/search.png"></image> | ||
| 74 | + </navigator> --> | ||
| 75 | + </view> | ||
| 76 | + | ||
| 77 | + | ||
| 78 | + | ||
| 30 | <view class="choice_list"> | 79 | <view class="choice_list"> |
| 31 | <navigator class="choice_item flex ai-center" url="{{g_filter.get_goods_url(item)}}" wx:for="{{requestData}}" wx:key="{{index}}"> | 80 | <navigator class="choice_item flex ai-center" url="{{g_filter.get_goods_url(item)}}" wx:for="{{requestData}}" wx:key="{{index}}"> |
| 32 | <view class="img-wrap"> | 81 | <view class="img-wrap"> |
| @@ -38,10 +87,10 @@ | @@ -38,10 +87,10 @@ | ||
| 38 | <block wx:if="{{(item.prom_price>0 || item.prom_integral) && item.prom_id>0 && item.prom_type!=7}}"> | 87 | <block wx:if="{{(item.prom_price>0 || item.prom_integral) && item.prom_id>0 && item.prom_type!=7}}"> |
| 39 | <!-- 活动价 --> | 88 | <!-- 活动价 --> |
| 40 | <view class="price"> | 89 | <view class="price"> |
| 41 | - <text wx:if="{{item.prom_integral}}">{{item.prom_integral}}积分</text> | ||
| 42 | - <text wx:if="{{item.prom_integral && item.prom_price}}">+</text> | ||
| 43 | - <text wx:if="{{item.prom_price}}">¥{{item.prom_price}}</text> | ||
| 44 | - </view> | 90 | + <text wx:if="{{item.prom_integral}}">{{item.prom_integral}}积分</text> |
| 91 | + <text wx:if="{{item.prom_integral && item.prom_price}}">+</text> | ||
| 92 | + <text wx:if="{{item.prom_price}}">¥{{item.prom_price}}</text> | ||
| 93 | + </view> | ||
| 45 | <view class="comment flex jc_sb"> | 94 | <view class="comment flex jc_sb"> |
| 46 | <view class="word-line xc-ash">¥{{item.market_price}}</view> | 95 | <view class="word-line xc-ash">¥{{item.market_price}}</view> |
| 47 | <view>评论{{item.comment_count}} 已售{{item.sales_sum}}</view> | 96 | <view>评论{{item.comment_count}} 已售{{item.sales_sum}}</view> |
| @@ -49,7 +98,7 @@ | @@ -49,7 +98,7 @@ | ||
| 49 | </block> | 98 | </block> |
| 50 | <block wx:else> | 99 | <block wx:else> |
| 51 | <!-- 商品价格,先判断下是后又等级价--> | 100 | <!-- 商品价格,先判断下是后又等级价--> |
| 52 | - <block wx:if="{{g_filter.is_has_rank(rank_switch,item) && is_no_plus}}"> | 101 | + <block wx:if="{{g_filter.is_has_rank(rank_switch,item)}}"> |
| 53 | <!-- 当会员是等级卡的时候 --> | 102 | <!-- 当会员是等级卡的时候 --> |
| 54 | <block wx:if="{{card_field}}"> | 103 | <block wx:if="{{card_field}}"> |
| 55 | <!-- 等级价>0 --> | 104 | <!-- 等级价>0 --> |
| @@ -57,9 +106,9 @@ | @@ -57,9 +106,9 @@ | ||
| 57 | <view class="flex ai_center"> | 106 | <view class="flex ai_center"> |
| 58 | <view class="price">¥{{item[card_field]}}</view> | 107 | <view class="price">¥{{item[card_field]}}</view> |
| 59 | <view class="card_bg flex ai-center"> | 108 | <view class="card_bg flex ai-center"> |
| 60 | - <image src="{{url}}/miniapp/images/plus/dj_icon.png"></image> | ||
| 61 | - <!-- <view class="card_name ellipsis-1">{{card_name}}</view> --> | ||
| 62 | - <text class="ellipsis-1">{{card_name}}</text> | 109 | + <image src="{{url}}/miniapp/images/plus/dj_icon.png"></image> |
| 110 | + <!-- <view class="card_name ellipsis-1">{{card_name}}</view> --> | ||
| 111 | + <text class="ellipsis-1">{{card_name}}</text> | ||
| 63 | </view> | 112 | </view> |
| 64 | </view> | 113 | </view> |
| 65 | <view class="comment flex jc_sb"> | 114 | <view class="comment flex jc_sb"> |
| @@ -85,10 +134,10 @@ | @@ -85,10 +134,10 @@ | ||
| 85 | <view class="flex ai_center"> | 134 | <view class="flex ai_center"> |
| 86 | <view class="">¥{{g_filter.get_card_price(item,card_list,0)}}</view> | 135 | <view class="">¥{{g_filter.get_card_price(item,card_list,0)}}</view> |
| 87 | <view class="card_bg flex"> | 136 | <view class="card_bg flex"> |
| 88 | - <view class="flex ai-center"> | ||
| 89 | - <image src="{{url}}/miniapp/images/plus/dj_icon.png" class=""></image> | ||
| 90 | - <text class="ellipsis-1">{{g_filter.get_card_price(item,card_list,1)}}</text> | ||
| 91 | - </view> | 137 | + <view class="flex ai-center"> |
| 138 | + <image src="{{url}}/miniapp/images/plus/dj_icon.png" class=""></image> | ||
| 139 | + <text class="ellipsis-1">{{g_filter.get_card_price(item,card_list,1)}}</text> | ||
| 140 | + </view> | ||
| 92 | </view> | 141 | </view> |
| 93 | </view> | 142 | </view> |
| 94 | <view>评论{{item.comment_count}} 已售{{item.sales_sum}}</view> | 143 | <view>评论{{item.comment_count}} 已售{{item.sales_sum}}</view> |
| @@ -117,12 +166,22 @@ | @@ -117,12 +166,22 @@ | ||
| 117 | <!-- 有商品列表的时候,要有分享攻击 --> | 166 | <!-- 有商品列表的时候,要有分享攻击 --> |
| 118 | <share_box id="share"></share_box> | 167 | <share_box id="share"></share_box> |
| 119 | </view> | 168 | </view> |
| 120 | - <view class="no-data" wx:if="{{!requestData||requestData.length==0}}"> | ||
| 121 | - <image class="cart-image" src="{{url}}/miniapp/images/cart-null.png"></image> | ||
| 122 | - <view class="no-data-title">没有相关的数据</view> | ||
| 123 | - <navigator bindtap="go_url" class="lookat" data-url="/pages/index/index/index"> 去逛逛 </navigator> | ||
| 124 | - </view> | 169 | + |
| 170 | + <!-- 无数据提示 --> | ||
| 171 | + <view class="no-data" wx:if="{{!requestData||requestData.length==0}}"> | ||
| 172 | + <image class="cart-image" src="{{url}}/miniapp/images/cart-null.png"></image> | ||
| 173 | + <view class="no-data-title">没有相关的数据</view> | ||
| 174 | + <navigator bindtap="go_url" class="lookat" data-url="/pages/index/index/index"> 去逛逛 </navigator> | ||
| 175 | + </view> | ||
| 176 | + | ||
| 177 | + </block> | ||
| 178 | + | ||
| 179 | + | ||
| 180 | + | ||
| 125 | </view> | 181 | </view> |
| 182 | + | ||
| 183 | + | ||
| 184 | + | ||
| 126 | <view hidden="{{!openFilterModal}}"> | 185 | <view hidden="{{!openFilterModal}}"> |
| 127 | <view bindtap="closeFilterModal" class="cover-layer"></view> | 186 | <view bindtap="closeFilterModal" class="cover-layer"></view> |
| 128 | <view class="filter-modal"> | 187 | <view class="filter-modal"> |
| @@ -158,7 +217,10 @@ | @@ -158,7 +217,10 @@ | ||
| 158 | </view> | 217 | </view> |
| 159 | </view> | 218 | </view> |
| 160 | </view> | 219 | </view> |
| 161 | -<view wx:if="{{openSearchModal}}"> | 220 | + |
| 221 | + | ||
| 222 | + | ||
| 223 | +<!-- <view wx:if="{{openSearchModal}}"> | ||
| 162 | <view class="search-modal"> | 224 | <view class="search-modal"> |
| 163 | <view class="search-bar"> | 225 | <view class="search-bar"> |
| 164 | <form bindsubmit="submitSearch"> | 226 | <form bindsubmit="submitSearch"> |
| @@ -176,17 +238,17 @@ | @@ -176,17 +238,17 @@ | ||
| 176 | </view> | 238 | </view> |
| 177 | </block> | 239 | </block> |
| 178 | </view> | 240 | </view> |
| 179 | - <view class="search-hot"> | ||
| 180 | - <view class="hot-title flex jc_sb ai_c"> | ||
| 181 | - <text>历史搜索</text> | ||
| 182 | - <text class="iconfont icon-shanchu xc-ash" bindtap="clearSearchRecord" wx:if="{{searchRecord.length != 0}}"></text> | ||
| 183 | - </view> | ||
| 184 | - <block wx:if="{{searchRecord.length>0}}"> | ||
| 185 | - <view class="hot-row flex flex-wrap" wx:key="{{index}}"> | ||
| 186 | - <view class="hot-item history ellipsis-1" bindtap="searchHotWord" data-word="{{item}}" wx:for="{{searchRecord}}" wx:key="{{index}}">{{item}}</view> | ||
| 187 | - </view> | ||
| 188 | - </block> | ||
| 189 | - <view wx:else class="fs24">暂无历史搜索记录</view> | ||
| 190 | - </view> | 241 | + <view class="search-hot"> |
| 242 | + <view class="hot-title flex jc_sb ai_c"> | ||
| 243 | + <text>历史搜索</text> | ||
| 244 | + <text class="iconfont icon-shanchu xc-ash" bindtap="clearSearchRecord" wx:if="{{searchRecord.length != 0}}"></text> | ||
| 245 | + </view> | ||
| 246 | + <block wx:if="{{searchRecord.length>0}}"> | ||
| 247 | + <view class="hot-row flex flex-wrap" wx:key="{{index}}"> | ||
| 248 | + <view class="hot-item history ellipsis-1" bindtap="searchHotWord" data-word="{{item}}" wx:for="{{searchRecord}}" wx:key="{{index}}">{{item}}</view> | ||
| 249 | + </view> | ||
| 250 | + </block> | ||
| 251 | + <view wx:else class="fs24">暂无历史搜索记录</view> | ||
| 252 | + </view> | ||
| 191 | </view> | 253 | </view> |
| 192 | -</view> | ||
| 193 | \ No newline at end of file | 254 | \ No newline at end of file |
| 255 | +</view> --> | ||
| 194 | \ No newline at end of file | 256 | \ No newline at end of file |
pages/goods/search/search.wxss
| 1 | .container { | 1 | .container { |
| 2 | color: #666; | 2 | color: #666; |
| 3 | + overflow: visible; | ||
| 3 | } | 4 | } |
| 4 | 5 | ||
| 5 | .nav-item { | 6 | .nav-item { |
| 6 | - float: left; | 7 | + /* float: left; |
| 7 | width: 30%; | 8 | width: 30%; |
| 8 | height: 90rpx; | 9 | height: 90rpx; |
| 9 | - line-height: 90rpx; | 10 | + line-height: 90rpx; */ |
| 11 | + padding: 14rpx 10rpx; | ||
| 10 | display: flex; | 12 | display: flex; |
| 11 | align-items: center; | 13 | align-items: center; |
| 12 | justify-content: center; | 14 | justify-content: center; |
| 13 | - font-size: 32rpx; | 15 | + font-size: 28rpx; |
| 14 | border-bottom: 2rpx solid #E6E6E6; | 16 | border-bottom: 2rpx solid #E6E6E6; |
| 15 | background-color: #fff; | 17 | background-color: #fff; |
| 16 | } | 18 | } |
| @@ -160,7 +162,7 @@ | @@ -160,7 +162,7 @@ | ||
| 160 | } | 162 | } |
| 161 | 163 | ||
| 162 | .search-modal { | 164 | .search-modal { |
| 163 | - position: fixed; | 165 | + /* position: fixed; |
| 164 | top: 0; | 166 | top: 0; |
| 165 | right: 0; | 167 | right: 0; |
| 166 | left: 0; | 168 | left: 0; |
| @@ -170,12 +172,16 @@ | @@ -170,12 +172,16 @@ | ||
| 170 | overflow-x: hidden; | 172 | overflow-x: hidden; |
| 171 | padding: 80rpx 30rpx; | 173 | padding: 80rpx 30rpx; |
| 172 | font-size: 30rpx; | 174 | font-size: 30rpx; |
| 173 | - color: #555; | 175 | + color: #555; */ |
| 174 | } | 176 | } |
| 175 | 177 | ||
| 176 | .search-bar { | 178 | .search-bar { |
| 177 | - width: 100%; | ||
| 178 | - box-sizing: border-box; | 179 | + /* width: 100%; |
| 180 | + box-sizing: border-box; */ | ||
| 181 | + background-color: white; | ||
| 182 | + position: sticky; | ||
| 183 | + top: 0; | ||
| 184 | + z-index: 1; | ||
| 179 | } | 185 | } |
| 180 | 186 | ||
| 181 | .search-input { | 187 | .search-input { |
| @@ -212,21 +218,21 @@ | @@ -212,21 +218,21 @@ | ||
| 212 | .hot-title { | 218 | .hot-title { |
| 213 | font-size: 35rpx; | 219 | font-size: 35rpx; |
| 214 | color: black; | 220 | color: black; |
| 215 | - margin-bottom: 30rpx; | 221 | + /* margin-bottom: 30rpx; */ |
| 216 | } | 222 | } |
| 217 | 223 | ||
| 218 | .hot-row { | 224 | .hot-row { |
| 219 | display: flex; | 225 | display: flex; |
| 220 | /*--justify-content: space-between---*/ | 226 | /*--justify-content: space-between---*/ |
| 221 | - padding: 15rpx 10rpx; | 227 | + padding: 10rpx 0; |
| 222 | } | 228 | } |
| 223 | 229 | ||
| 224 | .hot-item { | 230 | .hot-item { |
| 225 | - padding: 8rpx 8rpx; | ||
| 226 | - border: 1rpx solid #e0e0e0; | ||
| 227 | - border-radius: 10rpx; | 231 | + padding: 6rpx 20rpx; |
| 232 | + border: 2rpx solid #e0e0e0; | ||
| 233 | + border-radius: 40rpx; | ||
| 228 | font-size: 28rpx; | 234 | font-size: 28rpx; |
| 229 | - margin-left: 15rpx; | 235 | + margin-right: 16rpx; |
| 230 | } | 236 | } |
| 231 | 237 | ||
| 232 | /* .card_bg { | 238 | /* .card_bg { |
| @@ -303,9 +309,69 @@ | @@ -303,9 +309,69 @@ | ||
| 303 | background-color: #f0f0f0; | 309 | background-color: #f0f0f0; |
| 304 | color: #7b7b7b; | 310 | color: #7b7b7b; |
| 305 | border: none; | 311 | border: none; |
| 306 | - margin-bottom: 8rpx; | 312 | + margin-bottom: 16rpx; |
| 307 | } | 313 | } |
| 308 | 314 | ||
| 309 | .history:first-of-type { | 315 | .history:first-of-type { |
| 316 | + /* margin-left: 0; */ | ||
| 317 | +} | ||
| 318 | + | ||
| 319 | +.input-box { | ||
| 320 | + position: relative; | ||
| 321 | + flex: 1; | ||
| 322 | + padding-left: 50rpx; | ||
| 323 | + padding-right: 70rpx; | ||
| 324 | + background-color: #f0f0f0; | ||
| 325 | + border-radius: 60rpx; | ||
| 326 | +} | ||
| 327 | + | ||
| 328 | +.input-box::before { | ||
| 329 | + font-family: iconfont; | ||
| 330 | + position: absolute; | ||
| 331 | + left: 20rpx; | ||
| 332 | + top: 50%; | ||
| 333 | + transform: translateY(-50%); | ||
| 334 | + content: '\e618'; | ||
| 335 | +} | ||
| 336 | + | ||
| 337 | +.input-search { | ||
| 338 | + position: relative; | ||
| 339 | + padding: 10rpx; | ||
| 340 | + font-size: 28rpx; | ||
| 341 | +} | ||
| 342 | + | ||
| 343 | + | ||
| 344 | +.btn { | ||
| 310 | margin-left: 0; | 345 | margin-left: 0; |
| 346 | + margin-right: 0; | ||
| 347 | + line-height: 1; | ||
| 348 | + padding: 20rpx; | ||
| 349 | + font-size: 30rpx; | ||
| 350 | +} | ||
| 351 | + | ||
| 352 | +.btn::after { | ||
| 353 | + border: none; | ||
| 311 | } | 354 | } |
| 355 | + | ||
| 356 | +.icon-guan { | ||
| 357 | + font-size: 20rpx; | ||
| 358 | + padding: 10rpx; | ||
| 359 | + position: absolute; | ||
| 360 | + right: 20rpx; | ||
| 361 | + top: 50%; | ||
| 362 | + transform: translateY(-50%); | ||
| 363 | +} | ||
| 364 | + | ||
| 365 | +.lookat { | ||
| 366 | + display: inline-block; | ||
| 367 | + color: #FF6768; | ||
| 368 | + border: 2rpx solid #FF6768; | ||
| 369 | + border-radius: 80rpx; | ||
| 370 | + font-size: 30rpx; | ||
| 371 | +} | ||
| 372 | + | ||
| 373 | +.no-data .no-data-title { | ||
| 374 | + font-size: 28rpx; | ||
| 375 | + color: #999; | ||
| 376 | +} | ||
| 377 | + |