作者 lihongjuan

3233

@@ -63,5 +63,10 @@ @@ -63,5 +63,10 @@
63 } 63 }
64 ] 64 ]
65 }, 65 },
  66 + "permission": {
  67 + "scope.userLocation": {
  68 + "desc": "你的位置信息将用于小程序位置接口的效果展示"
  69 + }
  70 + },
66 "sitemapLocation": "sitemap.json" 71 "sitemapLocation": "sitemap.json"
67 } 72 }
@@ -135,8 +135,10 @@ Page({ @@ -135,8 +135,10 @@ Page({
135 record: '', 135 record: '',
136 showcountry: false, 136 showcountry: false,
137 showcity: false, 137 showcity: false,
  138 + showregin:false,
138 countrylist: [], 139 countrylist: [],
139 citylist: [], 140 citylist: [],
  141 + reginlist:[],
140 sort_id: '', 142 sort_id: '',
141 country: '', 143 country: '',
142 city: "", 144 city: "",
@@ -163,6 +165,8 @@ Page({ @@ -163,6 +165,8 @@ Page({
163 sle: false 165 sle: false
164 166
165 }], 167 }],
  168 + currentCity:''
  169 +
166 170
167 171
168 }, 172 },
@@ -176,8 +180,68 @@ Page({ @@ -176,8 +180,68 @@ Page({
176 }) 180 })
177 console.log(this.data.url) 181 console.log(this.data.url)
178 this.getshailist(); 182 this.getshailist();
179 - this.gethomeindex() 183 + this.gethomeindex();
  184 + this.getcity()
  185 + },
  186 +
  187 +
  188 + //获取用户当前位置
  189 + getcity() {
  190 + let that = this;
  191 + wx.getLocation({
  192 + type: 'gcj02',
  193 + success: function (res) {
  194 + // 经纬度
  195 + var latitude = res.latitude
  196 + var longitude = res.longitude
  197 +
  198 + // that.setData({
  199 + // wd: latitude,
  200 + // jd: longitude
  201 + // })
  202 +
  203 + // that.gethostipallist()
  204 + var aK = that.data.aK
  205 + wx.request({
  206 + url: 'https://api.map.baidu.com/geocoder/v2/?ak=y8jPDTMIuAnaVscUztce1RKfNx8v5sok&location=' + latitude + ',' + longitude + '&output=json',
  207 + data: {},
  208 + header: {
  209 + 'content-type': 'application/json'
  210 + },
  211 + success: function (res) {
  212 + console.log('1234567890', res)
  213 + var province = res.data.result.addressComponent.province;
  214 + let district = res.data.result.addressComponent.district
  215 + that.setData({
  216 + currentCity: province
  217 + })
  218 + wx.request({
  219 + // url: 'xxx' + city,
  220 + // data: {},
  221 + // header: {
  222 + // 'content-type': 'application/json'
  223 + // },
  224 + // success: function (res) {
  225 + // that.setData({
  226 + // county: res.data,
  227 + // })
  228 + // },
  229 + })
  230 + }
  231 + })
  232 +
  233 + },
  234 + fail: function () {
  235 + wx.showToast({
  236 + title: '授权失败,请打开GPS重新进入页面授权',
  237 + icon: 'none',
  238 + duration: 2000
  239 + })
  240 + }
  241 + })
180 }, 242 },
  243 +
  244 +
181 letterTap(e) { 245 letterTap(e) {
182 console.log(e) 246 console.log(e)
183 const Item = e.currentTarget.dataset.item; 247 const Item = e.currentTarget.dataset.item;
@@ -198,14 +262,15 @@ Page({ @@ -198,14 +262,15 @@ Page({
198 app.post(url, params).then((res) => { 262 app.post(url, params).then((res) => {
199 263
200 that.setData({ 264 that.setData({
201 - record: res.wine_count.dataset,  
202 - citylist: res.region 265 + record: res.wine_count,
  266 +
203 }) 267 })
204 268
205 269
206 if (that.data.type == 1) { 270 if (that.data.type == 1) {
207 that.setData({ 271 that.setData({
208 - shaikind: res.sort 272 + shaikind: res.sort,
  273 +
209 }) 274 })
210 } else if (that.data.type == 2) { 275 } else if (that.data.type == 2) {
211 that.setData({ 276 that.setData({
@@ -216,11 +281,31 @@ Page({ @@ -216,11 +281,31 @@ Page({
216 for (var obj of newcountrylist) { 281 for (var obj of newcountrylist) {
217 obj.sel = false 282 obj.sel = false
218 } 283 }
  284 +
  285 + that.setData({
  286 + countrylist:newcountrylist
  287 + })
219 } else if (that.data.type == 3) { 288 } else if (that.data.type == 3) {
  289 + if(that.data.kindlist[1].name=='中国'){
  290 + that.setData({
  291 + citylist: res.region
  292 + })
  293 + }else{
  294 + that.setData({
  295 + citylist: []
  296 + })
  297 + }
  298 +
  299 +
  300 + let newcitylist = that.data.citylist;
  301 + for (var obj of newcitylist) {
  302 + obj.sel = false
  303 + }
220 304
221 that.setData({ 305 that.setData({
222 - shaikind: res.region 306 + citylist:newcitylist
223 }) 307 })
  308 +
224 } else if (that.data.type == 4) { 309 } else if (that.data.type == 4) {
225 that.setData({ 310 that.setData({
226 shaikind: res.odor 311 shaikind: res.odor
@@ -280,6 +365,19 @@ Page({ @@ -280,6 +365,19 @@ Page({
280 showcountry: true 365 showcountry: true
281 366
282 }) 367 })
  368 + }else if(type==3){
  369 + that.setData({
  370 + shai: false,
  371 + showcity: true
  372 +
  373 + })
  374 + }else{
  375 + that.setData({
  376 + shai: true,
  377 + showcity: false,
  378 + showcountry: false
  379 +
  380 + })
283 } 381 }
284 382
285 let newkindlist = that.data.kindlist; 383 let newkindlist = that.data.kindlist;
@@ -326,7 +424,14 @@ Page({ @@ -326,7 +424,14 @@ Page({
326 if (this.data.type == 1) { 424 if (this.data.type == 1) {
327 if (obj.sel == true) { 425 if (obj.sel == true) {
328 this.setData({ 426 this.setData({
329 - sort_id: obj.id 427 + sort_id: obj.id,
  428 +
  429 + })
  430 +
  431 + let newkindlist=this.data.kindlist;
  432 + newkindlist[0].name = obj.sort_name;
  433 + this.setData({
  434 + kindlist:newkindlist
330 }) 435 })
331 } 436 }
332 } else if (this.data.type == 4) { 437 } else if (this.data.type == 4) {
@@ -334,6 +439,12 @@ Page({ @@ -334,6 +439,12 @@ Page({
334 this.setData({ 439 this.setData({
335 odor_id: obj.id 440 odor_id: obj.id
336 }) 441 })
  442 +
  443 + let newkindlist = this.data.kindlist;
  444 + newkindlist[3].name = obj.odor_name;
  445 + this.setData({
  446 + kindlist: newkindlist
  447 + })
337 } 448 }
338 } 449 }
339 450
@@ -362,6 +473,8 @@ Page({ @@ -362,6 +473,8 @@ Page({
362 this.setData({ 473 this.setData({
363 kindlist: newkindlist 474 kindlist: newkindlist
364 }) 475 })
  476 +
  477 + this.gethomeindex()
365 }, 478 },
366 479
367 //筛选首页内容 480 //筛选首页内容
@@ -389,7 +502,7 @@ Page({ @@ -389,7 +502,7 @@ Page({
389 502
390 }) 503 })
391 }, 504 },
392 - // 选择城市 505 + // 选择国家
393 selectcountry(e) { 506 selectcountry(e) {
394 let countryid = e.currentTarget.dataset.id; 507 let countryid = e.currentTarget.dataset.id;
395 508
@@ -403,9 +516,9 @@ Page({ @@ -403,9 +516,9 @@ Page({
403 516
404 newkindlist[1].name = obj.country_name 517 newkindlist[1].name = obj.country_name
405 this.setData({ 518 this.setData({
406 - kindlist: newkindlist 519 + kindlist: newkindlist,
  520 + country: obj.country_name
407 }) 521 })
408 -  
409 } else { 522 } else {
410 obj.sel = false 523 obj.sel = false
411 } 524 }
@@ -419,12 +532,107 @@ Page({ @@ -419,12 +532,107 @@ Page({
419 }) 532 })
420 533
421 }, 534 },
  535 + //选择城市
  536 + selectcity(e){
  537 + let cityindex = e.currentTarget.dataset.index;
  538 + console.log(cityindex)
  539 +
  540 +
  541 + let newcitylist = this.data.citylist;
  542 +
  543 +
  544 + for (var i=0;i<newcitylist.length;i++) {
  545 +
  546 +
  547 + if (i == cityindex) {
  548 +
  549 + this.setData({
  550 + reginlist: newcitylist[i].region_list,
  551 + showregin:true,
  552 + showcity:false,
  553 + city: newcitylist[i].city
  554 + })
  555 +
  556 + }
  557 + }
  558 + let newreginlist=this.data.reginlist;
  559 + for (var obj of newreginlist){
  560 + obj.sel=false
  561 + }
  562 + this.setData({
  563 + reginlist:newreginlist
  564 + })
  565 + },
  566 +
  567 + //选择区
  568 + selectregin(e){
  569 + let reginindex=e.currentTarget.dataset.index;
  570 + let newreginlist=this.data.reginlist;
  571 + for(var i=0;i<newreginlist.length;i++){
  572 + // newreginlist[i].sel = !newreginlist[i].sel
  573 + if(i==reginindex){
  574 + console.log(243782347)
  575 + newreginlist[i].sel=true;
  576 + let newkindlist = this.data.kindlist;
  577 + newkindlist[2].name = newreginlist[i].name;
  578 + this.setData({
  579 + kindlist: newkindlist,
  580 + region: newreginlist[i].name
  581 + })
  582 +
  583 + console.log(this.data.kindlist)
  584 +
  585 + }else{
  586 + newreginlist[i].sel=false
  587 + }
  588 + }
  589 +
  590 + this.setData({
  591 + reginlist:newreginlist
  592 + })
  593 +
  594 + console.log(this.data.reginlist)
  595 +
  596 + },
  597 +
422 598
  599 +//确定选择国家
423 countrysure() { 600 countrysure() {
424 this.setData({ 601 this.setData({
425 showcountry: false, 602 showcountry: false,
426 shai:false 603 shai:false
427 }) 604 })
  605 +
  606 + this.gethomeindex()
  607 + },
  608 + //确定选择省
  609 + citysure(){
  610 + this.setData({
  611 + showregin: false,
  612 + shai: false,
  613 + showcity: false
  614 +
  615 +
  616 + })
  617 +
  618 + this.gethomeindex()
  619 + },
  620 +
  621 + //选择区
  622 +
  623 + sureregin(){
  624 + this.setData({
  625 + showregin:false,
  626 + shai:false,
  627 + showcity:false
  628 + })
  629 +
  630 + this.gethomeindex()
  631 + },
  632 +
  633 + //筛选
  634 + shai(){
  635 + this.gethomeindex()
428 }, 636 },
429 637
430 638
@@ -20,11 +20,11 @@ @@ -20,11 +20,11 @@
20 </view> 20 </view>
21 21
22 <view class="countryitem" wx:for="{{countrylist}}" wx:key="" data-name="{{item.country_name}}" bindtap="selectcountry" data-id="{{item.id}}"> 22 <view class="countryitem" wx:for="{{countrylist}}" wx:key="" data-name="{{item.country_name}}" bindtap="selectcountry" data-id="{{item.id}}">
23 - <view class="selcounitem" >{{item.country_name}}</view> 23 + <view class="selcounitem">{{item.country_name}}</view>
24 24
25 <view class="gouimg" wx:if="{{item.sel==true}}"> 25 <view class="gouimg" wx:if="{{item.sel==true}}">
26 - <image src="{{url}}/aicon_18x.png"></image>  
27 - </view> 26 + <image src="{{url}}/aicon_18x.png"></image>
  27 + </view>
28 </view> 28 </view>
29 29
30 30
@@ -37,15 +37,47 @@ @@ -37,15 +37,47 @@
37 <view class="quehead"> 37 <view class="quehead">
38 <view class="backrow"></view> 38 <view class="backrow"></view>
39 <view class="selcoun">选择城市</view> 39 <view class="selcoun">选择城市</view>
40 - <view class="cqueding">确定</view> 40 + <view class="cqueding" bindtap="citysure">确定</view>
41 </view> 41 </view>
42 42
43 - <view class="selcounitem" wx:for="{{citylist}}" wx:key="" data-name="{{item.country_name}}" bindtap="selectcountry">{{item.city}}</view> 43 + <view class="nodata" wx:if="{{citylist.length==0}}">暂无数据</view>
  44 +
  45 +
  46 +<block wx:else>
  47 + <view class="countryitem" wx:for="{{citylist}}" wx:key="" data-name="{{item.country_name}}" bindtap="selectcity" data-index="{{index}}" >
  48 + <view class="selcounitem" >{{item.city}}</view>
  49 +
  50 + <!-- <view class="gouimg" wx:if="{{item.sel==true}}">
  51 + <image src="{{url}}/aicon_18x.png"></image>
  52 + </view> -->
  53 + </view>
  54 +</block>
44 55
45 56
46 57
47 </view> 58 </view>
  59 +<!-- 区域选择 -->
  60 +<view class="cregister" wx:if="{{showregin}}">
  61 + <view class="quehead">
  62 + <view class="backrow"></view>
  63 + <view class="selcoun">选择区</view>
  64 + <view class="cqueding" bindtap="sureregin">确定</view>
  65 + </view>
  66 +
  67 +
48 68
  69 + <view class="countryitem" wx:for="{{reginlist}}" wx:key="" data-name="{{item.name}}" bindtap="selectregin" data-index="{{index}}">
  70 + <view class="selcounitem" >{{item.name}}</view>
  71 +
  72 + <view class="gouimg" wx:if="{{item.sel==true}}">
  73 + <image src="{{url}}/aicon_18x.png"></image>
  74 + </view>
  75 + </view>
  76 +
  77 +
  78 +
  79 +
  80 +</view>
49 <view class="heatop"> 81 <view class="heatop">
50 <view class="head"> 82 <view class="head">
51 <view class="address"> 83 <view class="address">
@@ -53,7 +85,7 @@ @@ -53,7 +85,7 @@
53 <image src='{{url}}bicon_01x.png'></image> 85 <image src='{{url}}bicon_01x.png'></image>
54 </view> 86 </view>
55 87
56 - <view class="addressname">天津</view> 88 + <view class="addressname">{{currentCity}}</view>
57 </view> 89 </view>
58 90
59 <view class="headmiddle"> 91 <view class="headmiddle">
@@ -70,7 +102,7 @@ @@ -70,7 +102,7 @@
70 </view> 102 </view>
71 </view> 103 </view>
72 104
73 - <view class="address"> 105 + <view class="address" bindtap="shai">
74 <view class="shaixuan"> 106 <view class="shaixuan">
75 <image src='{{url}}bicon_02@2x.png'></image> 107 <image src='{{url}}bicon_02@2x.png'></image>
76 </view> 108 </view>
@@ -332,4 +332,11 @@ page{ @@ -332,4 +332,11 @@ page{
332 width:50rpx; 332 width:50rpx;
333 height:40rpx; 333 height:40rpx;
334 font-size: 0 334 font-size: 0
  335 +}
  336 +
  337 +.nodata{
  338 + color:#999;
  339 + font-size:30rpx;
  340 + text-align: center;
  341 + margin-top:30rpx;
335 } 342 }