Ver código fonte

首页修改

chengjunhui 1 mês atrás
pai
commit
8d6b8bf681

+ 45 - 30
pages/home/index/index.js

@@ -106,6 +106,11 @@ Page({
   moreHandler() {
     this.experience();
   },
+  selectCity(e) {
+    wx.navigateTo({
+      url: "/pages/home/location/index",
+    });
+  },
   experience(e) {
     // console.log(e, 11111111);
     if (
@@ -113,13 +118,13 @@ Page({
       e.currentTarget.dataset.index == 3
     ) {
       // if (wx.getStorageSync("USER")) {
-        const obj = this.data.goodsClassfiyList.find(v => v.name == '联名福利') || '';
-        // console.log(obj);
-        wx.setStorageSync('classfiyId', obj ? obj.id : '')
-        wx.navigateTo({
-          url: e.currentTarget.dataset.index == 4 ?
-            "/invitationCode/index" : `/pages/quality/index/index`,
-        });
+      const obj = this.data.goodsClassfiyList.find(v => v.name == '联名福利') || '';
+      // console.log(obj);
+      wx.setStorageSync('classfiyId', obj ? obj.id : '')
+      wx.navigateTo({
+        url: e.currentTarget.dataset.index == 4 ?
+          "/invitationCode/index" : `/pages/quality/index/index`,
+      });
       // } else {
       //   wx.navigateTo({
       //     url: "/pages/login",
@@ -186,7 +191,7 @@ Page({
   // 最新兼职
   newJob() {
     let nowCity = wx.getStorageSync("CHOOSECITY");
-    // console.log(nowCity);
+    console.log(nowCity);
     let that = this;
     app._post_form(
       "home/label",
@@ -372,20 +377,45 @@ Page({
     // })
   },
   onLoad: function (options) {
-    this.loadCity();
+    console.log("options", options);
+    if (!options.cityId) {
+      this.loadCity();
+    }
     this.height();
     if (wx.getStorageSync("USER")) {
       this.PushVipInfo();
     }
+
     let _this = this;
     _this.data.option = options;
     setTimeout(function () {
       _this.loadDictionary();
     }, 100);
     _this.addScore();
-    _this.getLocal();
+    if (options.cityId) {
+      let cityData = {
+        cityName: options.cityName,
+        cityId: options.cityId
+      };
+      wx.setStorageSync("CHOOSECITY", cityData);
+      this.setData({
+        currentCity: cityData,
+      }, () => {
+        console.log("currentCity", this.data.currentCity)
+        //设置城市选择数据
+        this.loadList(true)
+        _this.hotActive();
+        _this.newJob();
+        _this.schoolPer();
+        _this.getExpert();
+        _this.getShop();
+        _this.getGoodsClassfiy();
+        _this.getShopList();
+      });
+    } else {
+      _this.getLocal();
+    }
     _this.getAgree()
-
   },
   toPrivacy() {
     wx.openPrivacyContract({
@@ -564,7 +594,7 @@ Page({
   },
   loadCity: function () {
     let _this = this;
-    app._post_form("region/list", "", null, function (res) {
+    app._post_form("serviceCityList", "", null, function (res) {
       if (res.data.length) {
         //设置城市选择的数据
         let cityData = {
@@ -585,29 +615,14 @@ Page({
             let cityName = res.data[i].name;
             if (nowCity.cityName === cityName) {
               cityData.cityName = res.data[i].name;
-              cityData.cityId = res.data[i].id;
+              cityData.cityId = res.data[i].cityId;
               cityListIndex.push(i);
-
-              // for (let m = 0; m < res.data[i].childRegionList.length; m++) {
-              // 	let areaName = res.data[i].childRegionList[m].name;
-              // 	if (nowCity.areaName === areaName) {
-              // 		cityData.areaName = res.data[i].childRegionList[m].name;
-              // 		cityData.areaId = res.data[i].childRegionList[m].id;
-
-              // 		cityListPickerData.push(res.data[i].childRegionList);
-              // 		cityListIndex.push(m);
-              // 		break a;
-              // 	}
-              // }
             }
           }
         }
         else {
           cityData.cityName = res.data[0].name;
-          cityData.cityId = res.data[0].id;
-          cityData.areaName = res.data[0].childRegionList[0].name;
-          cityData.areaId = res.data[0].childRegionList[0].id;
-          cityListPickerData = [res.data, res.data[0].childRegionList];
+          cityData.cityId = res.data[0].cityId;
           cityListIndex = [0, 0];
         }
         //设置城市选择数据
@@ -732,7 +747,7 @@ Page({
         }
         const obj = res.list.find(v => v.name == '联名福利') || '';
         // console.log(obj);
-        if(!obj) return
+        if (!obj) return
         this.getGoodsList1(obj.id);
       }
     });

+ 12 - 5
pages/home/index/index.wxml

@@ -14,15 +14,22 @@
               <form class='temp-box' report-submit='true' bindsubmit=''>
                 <view class='white-spaceone'>
                   <!--<image src="{{appAssetsUrl2}}new/ad.png" lazy-load="true" class='location'></image>-->
-                  <picker mode="selector" bindchange="cityPickerChange" value="{{cityListIndex}}"
-                    range="{{cityListPickerData}}" range-key="name"
-                    style="display: inline-block;height: 30rpx;line-height: 10rpx;color: white;">
+                  <!--
+                  <picker mode="selector" bindchange="cityPickerChange" value="{{cityListIndex}}" range="{{cityListPickerData}}" range-key="name" style="display: inline-block;height: 30rpx;line-height: 10rpx;color: white;">
                     <view class="picker">
-                      <text wx:if="{{cityListPickerData.length>0}}" form-type='submit'
-                        class='side'>{{currentCity.cityName}}</text>
+                      <text wx:if="{{cityListPickerData.length>0}}" form-type='submit' class='side'>
+                        {{currentCity.cityName}}
+                      </text>
                       <text wx:else form-type='submit' class='side' style="color: white;">未知</text>
                     </view>
                   </picker>
+                  -->
+                  <view class="picker" bindtap="selectCity">
+                    <text wx:if="{{currentCity.cityName}}" form-type='submit' class='side'>{{
+                      currentCity.cityName
+                    }}</text>
+                    <text wx:else form-type='submit' class='side' style="color: white;">未知</text>
+                  </view>
                   <image src="{{appAssetsUrl2}}new/xiala.png" mode="widthFix" class="xiala"></image>
                 </view>
               </form>

+ 7 - 5
pages/home/location/index.js

@@ -28,16 +28,16 @@ Page({
   //选择城市
   bindtap(e) {
     let cityName = e.currentTarget.dataset.detail.name ? e.currentTarget.dataset.detail.name : ''
-    let cityId = e.currentTarget.dataset.id
+    let cityId = e.currentTarget.dataset.cityid
     // console.log(e.target.dataset.detail.name)
-    // console.log(e)
+    console.log(e.currentTarget.dataset)
     wx.reLaunch({
       url: `/pages/home/index/index?cityName=${cityName}&cityId=${cityId}`,
       // url: '/pages/home/index/index?id=' + e.currentTarget.dataset.id,
     })
   },
   loadData: function () {
-    app._post_form('two/citylist', '', null,  (res)=> {
+    app._post_form('hotCityList', '', {},  (res)=> {
       // console.log(res)
       if(res && res.msg === 'success') {
         let citys = res.city, hotCitys = res.hot;
@@ -68,7 +68,8 @@ Page({
           let subItem = {};
           subItem.key = '热门'
           subItem.name = item.name
-          subItem.id=item.id
+          subItem.id = item.id
+          subItem.cityId = item.cityId
           subItems.push(subItem)
         })
         arrayItem.item = subItems
@@ -88,7 +89,8 @@ Page({
               let subItem = {};
               subItem.key = item.letter
               subItem.name = ite.name
-              subItem.id=ite.id
+              subItem.id = ite.id
+              subItem.cityId = ite.cityId
               arrayItem.push(subItem)
             })
             _arrayItem.item = arrayItem

+ 1 - 1
pages/home/location/index.wxml

@@ -15,7 +15,7 @@
             <view id="{{'index'+index}}" wx:for="{{list}}" wx:key="key">
                 <view class='list-title'>{{item.title}}</view>
                 <view class='{{index===0&&config.horizontal&&item.type==="hot"?"list-horizontal":""}}'>
-                    <view class='list-name' wx:for="{{item.item}}" data-id="{{city.id}}" wx:for-item="city" wx:for-index="idx" wx:key="city" data-detail="{{city}}" catchtap='bindtap'>
+                    <view class='list-name' wx:for="{{item.item}}" data-cityId="{{city.cityId}}" wx:for-item="city" wx:for-index="idx" wx:key="city" data-detail="{{city}}" catchtap='bindtap'>
                         {{city.name}}
                     </view>
                 </view>