Commit cf91655ed197f791402390e0cf766307dbefe7c2

Authored by vking
1 parent 3855a551

new 2.0

1 // components/2.0/filter/filter-group.js 1 // components/2.0/filter/filter-group.js
2 import DA from '../../../pages/reserve/data'; 2 import DA from '../../../pages/reserve/data';
  3 +import util from '../../../utils/util'
3 Component({ 4 Component({
4 /** 5 /**
5 * 组件的属性列表 6 * 组件的属性列表
@@ -25,6 +26,7 @@ Component({ @@ -25,6 +26,7 @@ Component({
25 attached(){ 26 attached(){
26 this.init() 27 this.init()
27 this.filterParams= null 28 this.filterParams= null
  29 + this.paramsData={}//过滤参数集合
28 }, 30 },
29 /** 31 /**
30 * 组件的方法列表 32 * 组件的方法列表
@@ -40,6 +42,15 @@ Component({ @@ -40,6 +42,15 @@ Component({
40 this.setData({ 42 this.setData({
41 multiIndex: [e.detail] 43 multiIndex: [e.detail]
42 }) 44 })
  45 + if(e.detail>0){
  46 + DA.getCatesID(parseInt(e.detail) - 1).then(cuisine=>{
  47 + this.paramsData.cuisine=cuisine
  48 + this.eventPush()
  49 + })
  50 + }else{
  51 + this.paramsData.cuisine=""
  52 + this.eventPush()
  53 + }
43 this.hide() 54 this.hide()
44 }, 55 },
45 caixiShow() { 56 caixiShow() {
@@ -86,6 +97,36 @@ Component({ @@ -86,6 +97,36 @@ Component({
86 filterParams: this.filterParams, 97 filterParams: this.filterParams,
87 }) 98 })
88 } 99 }
  100 + this.paramsData.filterParams=this.filterParams
  101 + this.paramsData.average=""
  102 + if(this.filterParams){
  103 + let filterParams = this.filterParams.min + ',' + this.filterParams.max
  104 + if (this.filterParams.min == this.filterParams.max && this.filterParams.min == 300) {
  105 + filterParams = this.filterParams.min + ',' + parseInt(new Date() / 1000)
  106 + }
  107 + this.paramsData.average = filterParams
  108 + }
  109 + this.eventPush()
  110 + this.hide()
  111 + },
  112 + tagsChange(e) {
  113 + let id = util.attr(e, 'id');
  114 + let tags = this.data.tags;
  115 + let tagsIds=[];
  116 + tags.forEach(t => {
  117 + if (t.id == id) {
  118 + t.active = !t.active
  119 + }
  120 + if (t.active) {
  121 + tagsIds.push(t.id)
  122 + }
  123 + })
  124 + this.setData({
  125 + tags:tags,
  126 + })
  127 + this.paramsData.tags=tagsIds.toString()
  128 + this.eventPush()
  129 + this.hide()
89 }, 130 },
90 hide(){ 131 hide(){
91 this.selectComponent('#caixi').hide(); 132 this.selectComponent('#caixi').hide();
@@ -95,5 +136,9 @@ Component({ @@ -95,5 +136,9 @@ Component({
95 caixiOpened:false, 136 caixiOpened:false,
96 }) 137 })
97 }, 138 },
  139 + eventPush(){
  140 + this.triggerEvent('event',this.paramsData);
  141 + },
  142 +
98 } 143 }
99 }) 144 })
@@ -106,7 +106,7 @@ Component({ @@ -106,7 +106,7 @@ Component({
106 active:this.data.active||'', 106 active:this.data.active||'',
107 }, 107 },
108 }) 108 })
109 - this.close() 109 + this.hide()
110 }, 110 },
111 reset(){ 111 reset(){
112 this.selectComponent('#consume').changeVal(0,300); 112 this.selectComponent('#consume').changeVal(0,300);
@@ -115,7 +115,7 @@ Component({ @@ -115,7 +115,7 @@ Component({
115 consumeStr:'', 115 consumeStr:'',
116 }) 116 })
117 this.triggerEvent('event',{type:'clean'}) 117 this.triggerEvent('event',{type:'clean'})
118 - this.close() 118 + this.hide()
119 }, 119 },
120 } 120 }
121 }) 121 })
@@ -144,41 +144,15 @@ Page({ @@ -144,41 +144,15 @@ Page({
144 let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2 144 let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2
145 param.centre_pos = `${lat},${lng}` 145 param.centre_pos = `${lat},${lng}`
146 } 146 }
147 - /*  
148 - if (this.data.multiIndex[0] > 0) {  
149 - param.cuisine = await DA.getCatesID(this.data.multiIndex[0] - 1); 147 + if(this.filterGroupData.tags){
  148 + param.tags = this.filterGroupData.tags;
150 } 149 }
151 - let tags = [];  
152 - this.data.tags.forEach(t => {  
153 - if (t.active) {  
154 - tags.push(t.id)  
155 - }  
156 - })  
157 - if (tags.length > 0) {  
158 - param.tags = tags; 150 + if (this.filterGroupData.cuisine) {
  151 + param.cuisine = this.filterGroupData.cuisine;
159 } 152 }
160 - if (param.lat) {  
161 - param.centre_pos = `${param.lat},${param.lng}`  
162 - } else {  
163 - let lat = (this.mapData.region.southwest.latitude + this.mapData.region.northeast.latitude) / 2  
164 - let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2  
165 - param.centre_pos = `${lat},${lng}`  
166 - }  
167 - if (this.data.hasSuggestion) {  
168 - param.centre_pos = `${this.data.suggestion.latitude},${this.data.suggestion.longitude}` 153 + if(this.filterGroupData.average){
  154 + param.average = this.filterGroupData.average;
169 } 155 }
170 - if (this.findSellerData) {  
171 - param = Object.assign(param, this.findSellerData.paramObj)  
172 - }  
173 - if (this.filterParams) {//人均过滤  
174 - let filterParams = this.filterParams.min + ',' + this.filterParams.max  
175 - if (this.filterParams.min == this.filterParams.max && this.filterParams.min == 300) {  
176 - filterParams = this.filterParams.min + ',' + parseInt(new Date() / 1000)  
177 - }  
178 - param.average = filterParams  
179 - }  
180 - */  
181 - //this.selectComponent('#list').getList(param);  
182 this.param = param; 156 this.param = param;
183 App.Customer.SellerList(param).then(async res => { 157 App.Customer.SellerList(param).then(async res => {
184 if (res.ret == 200) { 158 if (res.ret == 200) {
@@ -288,6 +262,12 @@ Page({ @@ -288,6 +262,12 @@ Page({
288 }; 262 };
289 this.setData(obj) 263 this.setData(obj)
290 }, 264 },
  265 + filterGroupData:{},
  266 + filterGroupEvent(e){
  267 + console.log('filterGroupEvent',e.detail)
  268 + this.filterGroupData=e.detail
  269 + this.debounce(this.getSellers,500)
  270 + },
291 back:function() { 271 back:function() {
292 /* 272 /*
293 var mta = require('mta-wechat-analysis') 273 var mta = require('mta-wechat-analysis')
@@ -15,7 +15,7 @@ @@ -15,7 +15,7 @@
15 layer-style="2" 15 layer-style="2"
16 style="width: 100%; height: 360rpx;"></map> 16 style="width: 100%; height: 360rpx;"></map>
17 <view class="view content" style="height: {{height}}px;"> 17 <view class="view content" style="height: {{height}}px;">
18 - <filter-group height="{{height}}"></filter-group> 18 + <filter-group height="{{height}}" bindevent="filterGroupEvent"></filter-group>
19 <scroll-view class="view scroll-view" scroll-y="true" 19 <scroll-view class="view scroll-view" scroll-y="true"
20 scroll-into-view="seller-{{activeSellerID}}" 20 scroll-into-view="seller-{{activeSellerID}}"
21 scroll-with-animation 21 scroll-with-animation