Commit 6356e780a42a02d57c1a3bb82770f59bb09e338a

Authored by 前端开发-罗建龙
1 parent 3e245bf3

门店搜索

packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -257,6 +257,8 @@ Page({
257 257 hiddenCS: true,
258 258  
259 259 is_retail_price: 0,
  260 + keyword:'', //门店搜索
  261 + sec_i:-1,//选中分类门店 下标
260 262 },
261 263  
262 264 //------初始化加载----------
... ... @@ -2009,7 +2011,93 @@ Page({
2009 2011 }, 200)
2010 2012  
2011 2013 },
  2014 + //获取搜索门店输入的值
  2015 + input_store: function(e) {
  2016 + this.setData({
  2017 + keyword: e.detail.value
  2018 + })
  2019 + },
  2020 + //搜索门店
  2021 + searchfn(){
  2022 + let choice_sort_store = this.data.choice_sort_store
  2023 + if (choice_sort_store==0) { //全局搜索
  2024 + let all_pick_list = this.data.all_pick_list
  2025 + let def_pickpu_list = this.data.def_pickpu_list
  2026 + let keyword = this.data.keyword
  2027 + if (keyword) {
  2028 + let arr=all_pick_list.filter( item =>{
  2029 + let i = item.pickup_name.indexOf(keyword)
  2030 + if (i > -1) {
  2031 + return true
  2032 + }else{
  2033 + return false
  2034 + }
  2035 + })
  2036 + if (arr && arr.length>0) {
  2037 + if(this.data.is_show_sto_cat==1){
  2038 + this.setData({
  2039 + def_pickpu_list:arr
  2040 + })
  2041 + }else{
  2042 + this.setData({
  2043 + only_pk:arr
  2044 + })
  2045 + }
  2046 + }else{
  2047 + wx.showToast({
  2048 + title: '没有搜索到门店',
  2049 + icon: 'none',
  2050 + duration: 2000
  2051 + })
  2052 + }
  2053 + }else{
  2054 + if (this.data.is_show_sto_cat==1) {
  2055 + this.setData({
  2056 + def_pickpu_list:all_pick_list.slice(0,10)
  2057 + })
  2058 + }else{
  2059 + this.setData({
  2060 + only_pk:all_pick_list
  2061 + })
  2062 + }
  2063 +
  2064 + }
  2065 + }else{ //分类下搜索
  2066 + let sec_i=this.data.sec_i
  2067 + let all_sto = this.data.all_sto
  2068 + let sec_sto= this.data.sec_sto
  2069 + let sec_arr = sec_sto.s_arr
  2070 + let keyword = this.data.keyword
  2071 + let text='sec_sto.s_arr'
  2072 + if (keyword) {
  2073 + let arr=sec_arr.filter( item =>{
  2074 + let i = item.pickup_name.indexOf(keyword)
  2075 + if (i > -1) {
  2076 + return true
  2077 + }else{
  2078 + return false
  2079 + }
  2080 + })
  2081 + if (arr && arr.length>0) {
  2082 + this.setData({
  2083 + [text]:arr
  2084 + })
  2085 + }else{
  2086 + wx.showToast({
  2087 + title: '没有搜索到门店',
  2088 + icon: 'none',
  2089 + duration: 2000
  2090 + })
  2091 + }
  2092 + }else{
  2093 + this.setData({
  2094 + [text]:all_sto[sec_i].s_arr
  2095 + })
  2096 + }
  2097 +
2012 2098  
  2099 + }
  2100 + },
2013 2101  
2014 2102 //------------处理门店---------------
2015 2103 deal_pickup(e) {
... ... @@ -3886,6 +3974,7 @@ Page({
3886 3974 sort_store: 0,
3887 3975 choice_sort_store: 1,
3888 3976 sec_sto: item,
  3977 + sec_i:index,
3889 3978 sec_pick_index: 0
3890 3979 });
3891 3980 },
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -831,6 +831,12 @@
831 831 </view>
832 832 </view>
833 833 </view>
  834 + <view class="searchbar flex-vertical-between storeListpadd">
  835 + <input class="inputstore fs28" placeholder="输入要搜索的门店" value="{{keyword}}" placeholder-class="fs28" maxlength="16" bindinput="input_store" bindconfirm="searchfn" />
  836 + <view class="search flex-center" bindtap="searchfn">
  837 + <view class="fs28">搜索</view>
  838 + </view>
  839 + </view>
834 840 <!-- 门店列表,最外层的门店列表,一开始 -->
835 841 <view class="store-list">
836 842 <!-- 如果还没有点击更多门店的时候 -->
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxss
... ... @@ -2993,4 +2993,27 @@ button.custom-service::after{
2993 2993 top: -1000px;
2994 2994 }
2995 2995  
  2996 +.searchbar {
  2997 + height: 95rpx;
  2998 + border-bottom: 2rpx solid rgb(238, 238, 238);
  2999 +}
  3000 +.storeListpadd {
  3001 + padding: 0rpx 31rpx;
  3002 +}
  3003 +.search {
  3004 + width: 125rpx;
  3005 + height: 45rpx;
  3006 + line-height: 45rpx;
  3007 + background-color: rgb(219, 27, 52);
  3008 + border-radius: 30rpx;
  3009 + color: rgb(255, 255, 255);
  3010 +}
  3011 +.inputstore {
  3012 + width: 510rpx;
  3013 + height: 43rpx;
  3014 + line-height: 43rpx;
  3015 + border-radius: 30rpx;
  3016 + border: 2rpx solid rgb(238, 238, 238);
  3017 + padding-left: 30rpx;
  3018 +}
2996 3019  
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -269,6 +269,7 @@ Page({
269 269 base_nor_goods_id:0,
270 270 user_pre_buynum:0, //用户优惠促销参与次数
271 271 keyword:'', //门店搜索
  272 + sec_i:-1,//选中分类门店 下标
272 273 },
273 274  
274 275 //------初始化加载----------
... ... @@ -3595,12 +3596,7 @@ Page({
3595 3596 })
3596 3597  
3597 3598 },
3598   - //获取搜索门店输入的值
3599   - input_store: function(e) {
3600   - this.setData({
3601   - keyword: e.detail.value
3602   - })
3603   - },
  3599 +
3604 3600  
3605 3601  
3606 3602 //---------拿出门店分类和门店------------
... ... @@ -3650,10 +3646,7 @@ Page({
3650 3646 }
3651 3647 clearInterval(timer_get);
3652 3648  
3653   - //门店搜索关键字
3654   - if (th.data.keyword) {
3655   - dd.keyword=th.data.keyword
3656   - }
  3649 +
3657 3650  
3658 3651  
3659 3652 //如果会员是有默认的门店话
... ... @@ -3727,7 +3720,93 @@ Page({
3727 3720 }, 200)
3728 3721  
3729 3722 },
  3723 + //获取搜索门店输入的值
  3724 + input_store: function(e) {
  3725 + this.setData({
  3726 + keyword: e.detail.value
  3727 + })
  3728 + },
  3729 + //搜索门店
  3730 + searchfn(){
  3731 + let choice_sort_store = this.data.choice_sort_store
  3732 + if (choice_sort_store==0) { //全局搜索
  3733 + let all_pick_list = this.data.all_pick_list
  3734 + let def_pickpu_list = this.data.def_pickpu_list
  3735 + let keyword = this.data.keyword
  3736 + if (keyword) {
  3737 + let arr=all_pick_list.filter( item =>{
  3738 + let i = item.pickup_name.indexOf(keyword)
  3739 + if (i > -1) {
  3740 + return true
  3741 + }else{
  3742 + return false
  3743 + }
  3744 + })
  3745 + if (arr && arr.length>0) {
  3746 + if(this.data.is_show_sto_cat==1){
  3747 + this.setData({
  3748 + def_pickpu_list:arr
  3749 + })
  3750 + }else{
  3751 + this.setData({
  3752 + only_pk:arr
  3753 + })
  3754 + }
  3755 + }else{
  3756 + wx.showToast({
  3757 + title: '没有搜索到门店',
  3758 + icon: 'none',
  3759 + duration: 2000
  3760 + })
  3761 + }
  3762 + }else{
  3763 + if (this.data.is_show_sto_cat==1) {
  3764 + this.setData({
  3765 + def_pickpu_list:all_pick_list.slice(0,10)
  3766 + })
  3767 + }else{
  3768 + this.setData({
  3769 + only_pk:all_pick_list
  3770 + })
  3771 + }
  3772 +
  3773 + }
  3774 + }else{ //分类下搜索
  3775 + let sec_i=this.data.sec_i
  3776 + let all_sto = this.data.all_sto
  3777 + let sec_sto= this.data.sec_sto
  3778 + let sec_arr = sec_sto.s_arr
  3779 + let keyword = this.data.keyword
  3780 + let text='sec_sto.s_arr'
  3781 + if (keyword) {
  3782 + let arr=sec_arr.filter( item =>{
  3783 + let i = item.pickup_name.indexOf(keyword)
  3784 + if (i > -1) {
  3785 + return true
  3786 + }else{
  3787 + return false
  3788 + }
  3789 + })
  3790 + if (arr && arr.length>0) {
  3791 + this.setData({
  3792 + [text]:arr
  3793 + })
  3794 + }else{
  3795 + wx.showToast({
  3796 + title: '没有搜索到门店',
  3797 + icon: 'none',
  3798 + duration: 2000
  3799 + })
  3800 + }
  3801 + }else{
  3802 + this.setData({
  3803 + [text]:all_sto[sec_i].s_arr
  3804 + })
  3805 + }
  3806 +
3730 3807  
  3808 + }
  3809 + },
3731 3810  
3732 3811 //------------处理门店---------------
3733 3812 deal_pickup(e) {
... ... @@ -6969,6 +7048,7 @@ Page({
6969 7048 sort_store: 0,
6970 7049 choice_sort_store: 1,
6971 7050 sec_sto: item,
  7051 + sec_i:index,
6972 7052 sec_pick_index: 0
6973 7053 });
6974 7054 },
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -1601,8 +1601,8 @@
1601 1601 </view>
1602 1602 </view>
1603 1603 <view class="searchbar flex-vertical-between storeListpadd">
1604   - <input class="inputstore fs28" placeholder="{{keyword==''?'输入要搜索的门店':keyword}}" placeholder-class="fs28" maxlength="16" bindinput="input_store" bindconfirm="get_sto" />
1605   - <view class="search flex-center" bindtap="get_sto">
  1604 + <input class="inputstore fs28" placeholder="输入要搜索的门店" value="{{keyword}}" placeholder-class="fs28" maxlength="16" bindinput="input_store" bindconfirm="searchfn" />
  1605 + <view class="search flex-center" bindtap="searchfn">
1606 1606 <view class="fs28">搜索</view>
1607 1607 </view>
1608 1608 </view>
... ...