diff --git a/packageA/pages/profile/profile.js b/packageA/pages/profile/profile.js index e6e0813..d376715 100644 --- a/packageA/pages/profile/profile.js +++ b/packageA/pages/profile/profile.js @@ -79,6 +79,11 @@ Page({ loading: 0, oldBirtthDayLength:0, //生日日期个数 oldbirthday:'',//生日日期 + + all_pick_list:null, //所有的门店的集合 + old_all_sto:null, + keyword:'', //搜索门店的关键字 + sec_i:-1 }, //通过路径跳转到其他页面 goto: function (e) { @@ -267,8 +272,8 @@ Page({ if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { var ishas_cate = 0; - for (let i in e) { - let item = e[i]; + for (let i in e.data.data.pageData) { + let item = e.data.data.pageData[i]; if (item.category_id > 0) { ishas_cate = 1; break; @@ -286,6 +291,10 @@ Page({ e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 } + th.setData({ + all_pick_list: e.data.data.pageData + }); + //单总量超出5个的时候 if (e.data.data.total > 10 && ishas_cate) { i.get("/api/weshop/storagecategory/page", { @@ -465,7 +474,8 @@ Page({ sort_store: 0, choice_sort_store: 1, sec_sto: item, - sec_pick_index: 0 + sec_pick_index: 0, + sec_i: index, }); }, // 返回按钮 @@ -1547,5 +1557,106 @@ Page({ }) }, + //获取搜索门店输入的值 + input_store: function (e) { + this.setData({ + keyword: e.detail.value + }) + }, + + //搜索门店 + searchfn() { + let choice_sort_store = this.data.choice_sort_store + if (choice_sort_store == 0) { //全局搜索 + let all_pick_list = this.data.all_pick_list + let def_pickpu_list = this.data.def_pickpu_list + let keyword = this.data.keyword + if (keyword) { + let arr = all_pick_list.filter(item => { + let i = item.pickup_name.indexOf(keyword) + if (i > -1) { + return true + } else { + return false + } + }) + if (arr && arr.length > 0) { + if (this.data.is_show_sto_cat == 1) { + this.setData({ + def_pickpu_list: arr + }) + } else { + this.setData({ + only_pk: arr + }) + } + } else { + wx.showToast({ + title: '没有搜索到门店', + icon: 'none', + duration: 2000 + }) + } + } else { + if (this.data.is_show_sto_cat == 1) { + this.setData({ + def_pickpu_list: all_pick_list.slice(0, 10) + }) + } else { + this.setData({ + only_pk: all_pick_list + }) + } + + } + } else { //分类下搜索 + let sec_i = this.data.sec_i + let all_sto = this.data.all_sto + let old_all_sto = this.data.old_all_sto + if (!old_all_sto) { + this.setData({ + old_all_sto:JSON.parse(JSON.stringify(all_sto)) + }) + } + let sec_sto = this.data.sec_sto + let sec_arr = this.data.old_all_sto[sec_i].s_arr + let keyword = this.data.keyword + let text = 'sec_sto.s_arr' + if (keyword) { + let arr = sec_arr.filter(item => { + let i = item.pickup_name.indexOf(keyword) + if (i > -1) { + return true + } else { + return false + } + }) + if (arr && arr.length > 0) { + this.setData({ + [text]: arr + }) + } else { + wx.showToast({ + title: '没有搜索到门店', + icon: 'none', + duration: 2000 + }) + } + } else { + if(this.data.old_all_sto){ + this.setData({ + [text]: this.data.old_all_sto[sec_i].s_arr + }) + }else{ + this.setData({ + [text]: all_sto[sec_i].s_arr + }) + } + } + + + } + }, + }); \ No newline at end of file diff --git a/packageA/pages/profile/profile.wxml b/packageA/pages/profile/profile.wxml index a479371..fe78c56 100644 --- a/packageA/pages/profile/profile.wxml +++ b/packageA/pages/profile/profile.wxml @@ -232,6 +232,14 @@ + + + + + 搜索 + + + diff --git a/packageA/pages/profile/profile.wxss b/packageA/pages/profile/profile.wxss index 66821d4..d402f98 100644 --- a/packageA/pages/profile/profile.wxss +++ b/packageA/pages/profile/profile.wxss @@ -723,3 +723,28 @@ checkbox .wx-checkbox-input.wx-checkbox-input-checked::before { content: '*'; color: #C4182E; } + + +.searchbar { + height: 95rpx; + border-bottom: 2rpx solid rgb(238, 238, 238); +} +.storeListpadd { + padding: 0rpx 31rpx; +} +.search { + width: 125rpx; + height: 45rpx; + line-height: 45rpx; + background-color: rgb(219, 27, 52); + border-radius: 30rpx; + color: rgb(255, 255, 255); +} +.inputstore { + width: 510rpx; + height: 43rpx; + line-height: 43rpx; + border-radius: 30rpx; + border: 2rpx solid rgb(238, 238, 238); + padding-left: 30rpx; +} \ No newline at end of file diff --git a/packageG/pages/user/userinfo/userinfo.js b/packageG/pages/user/userinfo/userinfo.js index b4b0803..afd3a80 100644 --- a/packageG/pages/user/userinfo/userinfo.js +++ b/packageG/pages/user/userinfo/userinfo.js @@ -81,6 +81,10 @@ Page({ showvipcode:false, + all_pick_list:null, //所有的门店的集合 + old_all_sto:null, + keyword:'', //搜索门店的关键字 + sec_i:-1 }, //通过路径跳转到其他页面 goto: function(e) { @@ -350,6 +354,11 @@ Page({ } e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加 } + + + th.setData({ + all_pick_list: e.data.data.pageData + }); //单总量超出5个的时候 if (e.data.data.total > 10) { @@ -527,7 +536,8 @@ Page({ sort_store: 0, choice_sort_store: 1, sec_sto: item, - sec_pick_index: 0 + sec_pick_index: 0, + sec_i: index, }); }, // 返回按钮 @@ -1111,7 +1121,108 @@ Page({ } } }); - } + }, + + //获取搜索门店输入的值 + input_store: function (e) { + this.setData({ + keyword: e.detail.value + }) + }, + + //搜索门店 + searchfn() { + let choice_sort_store = this.data.choice_sort_store + if (choice_sort_store == 0) { //全局搜索 + let all_pick_list = this.data.all_pick_list + let def_pickpu_list = this.data.def_pickpu_list + let keyword = this.data.keyword + if (keyword) { + let arr = all_pick_list.filter(item => { + let i = item.pickup_name.indexOf(keyword) + if (i > -1) { + return true + } else { + return false + } + }) + if (arr && arr.length > 0) { + if (this.data.is_show_sto_cat == 1) { + this.setData({ + def_pickpu_list: arr + }) + } else { + this.setData({ + only_pk: arr + }) + } + } else { + wx.showToast({ + title: '没有搜索到门店', + icon: 'none', + duration: 2000 + }) + } + } else { + if (this.data.is_show_sto_cat == 1) { + this.setData({ + def_pickpu_list: all_pick_list.slice(0, 10) + }) + } else { + this.setData({ + only_pk: all_pick_list + }) + } + + } + } else { //分类下搜索 + let sec_i = this.data.sec_i + let all_sto = this.data.all_sto + let old_all_sto = this.data.old_all_sto + if (!old_all_sto) { + this.setData({ + old_all_sto:JSON.parse(JSON.stringify(all_sto)) + }) + } + let sec_sto = this.data.sec_sto + let sec_arr = this.data.old_all_sto[sec_i].s_arr + let keyword = this.data.keyword + let text = 'sec_sto.s_arr' + if (keyword) { + let arr = sec_arr.filter(item => { + let i = item.pickup_name.indexOf(keyword) + if (i > -1) { + return true + } else { + return false + } + }) + if (arr && arr.length > 0) { + this.setData({ + [text]: arr + }) + } else { + wx.showToast({ + title: '没有搜索到门店', + icon: 'none', + duration: 2000 + }) + } + } else { + if(this.data.old_all_sto){ + this.setData({ + [text]: this.data.old_all_sto[sec_i].s_arr + }) + }else{ + this.setData({ + [text]: all_sto[sec_i].s_arr + }) + } + } + + + } + }, }); \ No newline at end of file diff --git a/packageG/pages/user/userinfo/userinfo.wxml b/packageG/pages/user/userinfo/userinfo.wxml index 00744c9..e9724f7 100644 --- a/packageG/pages/user/userinfo/userinfo.wxml +++ b/packageG/pages/user/userinfo/userinfo.wxml @@ -344,6 +344,14 @@ + + + + + 搜索 + + + diff --git a/packageG/pages/user/userinfo/userinfo.wxss b/packageG/pages/user/userinfo/userinfo.wxss index 1369b89..99316f2 100644 --- a/packageG/pages/user/userinfo/userinfo.wxss +++ b/packageG/pages/user/userinfo/userinfo.wxss @@ -674,4 +674,29 @@ input { align-items: center; justify-content: center; /* margin-top: 20rpx; */ +} + + +.searchbar { + height: 95rpx; + border-bottom: 2rpx solid rgb(238, 238, 238); +} +.storeListpadd { + padding: 0rpx 31rpx; +} +.search { + width: 125rpx; + height: 45rpx; + line-height: 45rpx; + background-color: rgb(219, 27, 52); + border-radius: 30rpx; + color: rgb(255, 255, 255); +} +.inputstore { + width: 510rpx; + height: 43rpx; + line-height: 43rpx; + border-radius: 30rpx; + border: 2rpx solid rgb(238, 238, 238); + padding-left: 30rpx; } \ No newline at end of file diff --git a/pages/goods/goodsList/goodsList.js b/pages/goods/goodsList/goodsList.js index 1d139b6..d69db67 100644 --- a/pages/goods/goodsList/goodsList.js +++ b/pages/goods/goodsList/goodsList.js @@ -45,9 +45,12 @@ Page({ gr_fir:0, //分组第一次 share_imgurl:'', //分享图片 add_purchase:false, + + pro_good:null, //优惠促销活动 + pro_good_err:null, //优惠促销活动 }, - onLoad: function(t) { + onLoad: async function(t) { //----------商品分组自定义分享图片---------- if (t.gid || t.group_id) { let id = t.gid || t.group_id @@ -75,31 +78,29 @@ Page({ var th=this; var url = this.data.baseUrl; - //优惠活动的凑单 - if(t.prom_type==3){ - if (0 != t.prom_id && t.prom_id != undefined) { url += "&prom_id=" + t.prom_id; } - if (0 != t.prom_type && t.prom_type != undefined) { url += "&prom_type=" + t.prom_type; } - //-- 获取 -- - getApp().request.promiseGet("/api/weshop/promgoodslist/list",{ - data:{prom_id:t.prom_id } - }).then(res=>{ - if(res.data.code==0){ - var arr= res.data.data; - th.set_prom_list(arr); - } - }) - if (t.prom_id) { - this.getprom(t.prom_id) - } - } + if (0 != t.prom_id && t.prom_id != undefined) { url += "&prom_id=" + t.prom_id; } + if (0 != t.prom_type && t.prom_type != undefined) { url += "&prom_type=" + t.prom_type; } //先查看一下是不是系统会员 - getApp().waitfor_login(()=> { + getApp().waitfor_login(async ()=> { if (!getApp().globalData.user_id) { ut.new_user_go(oo.stoid, first_leader); } + await th.get_prom_act(t); + if(t.prom_type==3 && !th.data.pro_good){ + if(th.data.pro_good_err.indexOf("无权限")>-1){ + ut.m_toast('您无权限参与优惠促销活动'); + }else{ + ut.m_toast('未找到优惠促销活动'); + } + setTimeout(()=>{ + getApp().goto('/pages/index/index/index'); + },1500) + return false + } + this.data.is_new=t.is_new; this.data.is_hot=t.is_hot; if (0 != t.cat_id && t.cat_id != undefined) { @@ -257,6 +258,31 @@ Page({ }) }, + + async get_prom_act(t){ + var th=this; + //优惠活动的凑单 + if(t.prom_type==3){ + if (t.prom_id) { + await this.getprom(t.prom_id); + if(!th.data.pro_good){ + return false; + } + } + + //-- 获取 -- + getApp().request.promiseGet("/api/weshop/promgoodslist/list",{ + data:{prom_id:t.prom_id } + }).then(res=>{ + if(res.data.code==0){ + var arr= res.data.data; + th.set_prom_list(arr); + } + }) + + } + }, + onShow:function () { getApp().check_can_share(); }, @@ -274,14 +300,20 @@ Page({ }, //获取优惠活动 async getprom(prom_id){ - await getApp().request.promiseGet("/api/weshop/promgoods/get/" + oo.stoid + "/" + prom_id, {}).then(res => { + let th=this; + var uid=getApp().globalData.user_id || 0; + await getApp().request.promiseGet("/api/weshop/promgoods/getUser/" + oo.stoid + "/" + prom_id+"/"+uid, {}).then(res => { if (res.data.code == 0) { let prom = res.data.data; + th.data.pro_good=prom; let limit_num =prom.limit_num this.setData({ limit_num }) + }else{ + th.data.pro_good_err=res.data.msg; } + }) }, //设置优惠券的