Browse Source

feat:修复bug

jinx 4 năm trước cách đây
mục cha
commit
9fec2303aa

+ 7 - 7
component/roomItem/roomItem.js

@@ -22,16 +22,16 @@ Component({
   methods: {
     gotoWV(e) {
       let {
-        id
+        id,
+        index
       } = e.currentTarget.dataset
       console.log(id)
-      this.triggerEvent('gotoWV', id)
+      let data = {
+        id: id,
+        index: index,
+      }
+      this.triggerEvent('gotoWV', data)
 
-
-      // wx.navigateTo({
-      //   url: `/pages/webview/index?id=${id}`,
-      //   // url: `/pages/share/share?id=${id}`,
-      // })
     }
     // toDetail () {
     //   getApp().autoSubcrebe && getApp().autoSubcrebe()

+ 3 - 3
component/roomItem/roomItem.wxml

@@ -1,4 +1,4 @@
-<view class="tj_listItem" data-id="{{room.id}}" bindtap="gotoWV">
+<view class="tj_listItem" data-id="{{room.id}}" data-index="{{index}}" bindtap="gotoWV">
 				<view class="tj_listItemCover">
 					<image mode="aspectFill" class="coverImage"
 						src="{{room.appListPicUrl}}"></image>
@@ -39,8 +39,8 @@
 
 					<view class="tj_listItemPrice">
 							<text class="unitPrice">平均{{room.averagePrice}}元/平</text>
-							<text class="totalPrice" wx:if="{{room.type==2}}">{{room.retailPrice}}元/月</text>
-							<text class="totalPrice" wx:else>{{room.retailPrice}}万</text>
+							<!-- <text class="totalPrice" wx:if="{{room.type==2}}">{{room.retailPrice}}元/月</text> -->
+							<text class="totalPrice">{{room.retailPrice}}万</text>
 
 
 					</view>

+ 23 - 7
component/storeItem/storeItem.js

@@ -5,21 +5,32 @@ Component({
    */
   properties: {
     store: Object,
+    index: Number
   },
 
   /**
    * 组件的初始数据
    */
   data: {
-      storeItem:null
+    storeItem: null
   },
-  attached(){
+  attached() {
+
     this.setData({
-      storeItem:this.data.store
+      storeItem: this.data.store
     })
-    if(this.data.storeItem.pvTotalNum>=10000){
+    if (this.data.storeItem.pvTotalNum >= 10000) {
+      this.setData({
+        'storeItem.pvTotalNum': (this.data.storeItem.pvTotalNum / 10000).toFixed(1) + 'w'
+      })
+    }
+  },
+
+  observers: {
+    'store': function (numberA, numberB) {
+      console.log(numberA)
       this.setData({
-        'storeItem.pvTotalNum':(this.data.storeItem.pvTotalNum/10000).toFixed(1)+'w'
+        storeItem: this.properties.store
       })
     }
   },
@@ -29,10 +40,15 @@ Component({
   methods: {
     gotoWV(e) {
       let {
-        id
+        id,
+        index
       } = e.currentTarget.dataset
       console.log(id)
-      this.triggerEvent('gotoWV', id)
+      let data = {
+        id: id,
+        index: index,
+      }
+      this.triggerEvent('gotoWV', data)
 
     }
   }

+ 1 - 1
component/storeItem/storeItem.wxml

@@ -1,5 +1,5 @@
 <!--component/storeItem/storeItem.wxml-->
-<view class="storeBox" data-id="{{storeItem.id}}" bindtap="gotoWV">
+<view class="storeBox" data-id="{{storeItem.id}}" data-index="{{index}}" bindtap="gotoWV">
   <view class="storeCover">
     <image mode="aspectFill"
       src="{{storeItem.appListPicUrl}}"></image>

+ 5 - 1
config/api.js

@@ -117,5 +117,9 @@ module.exports = {
     SceneReport: API_BASE_URL + '../app/census/getSceneCensus',
     GetAdminBrands: API_BASE_URL + 'user/getAdminBrands',
     AddTalkCount: API_BASE_URL + '../app/census/addGoodsQueryNum',
-    AddGoodsViewCount: API_BASE_URL + 'goods/logDetail'
+    AddGoodsViewCount: API_BASE_URL + 'goods/logDetail',
+ 
+
+    //统计商家访问次数
+    increaseViewCount: API_BASE_URL + 'brand/increaseViewCount'
 };

+ 2 - 1
pages/goods/goods.js

@@ -393,6 +393,7 @@ Router({
       }
 
       //验证库存
+      console.log(checkedProduct.goods_number ,this.data.number)
       if (checkedProduct.goods_number < this.data.number) {
         util.showErrorToast('库存不足');
         //找不到对应的product信息,提示没有库存
@@ -495,7 +496,7 @@ Router({
 
   },
   cutNumber: function () {
-    if (tjos.data.checkGoods.goods_number === 0 ) return;
+    if (this.data.checkGoods.goods_number === 0 ) return;
     this.setData({
       number: (this.data.number - 1 > 1) ? this.data.number - 1 : 1
     });

+ 41 - 11
pages/index/index.js

@@ -60,7 +60,7 @@ Router({
     ],
     middleList: {},
     middleEmptyLength: 0,
-   
+    middleTypeList: [],
     roomTabList: [{
         type: 0,
         title: '新房'
@@ -101,15 +101,29 @@ Router({
     wx.navigateTo({
       url: `/pages/webview/index?id=${id}`,
     })
+    util.request(api.increaseViewCount, {
+      brandId: id
+    }, 'GET').then((res) => {
+      
+    });
   },
   gotoWV: function (event) {
-    let id = event.detail
+    let {id} = event.detail
     wx.navigateTo({
       url: `/pages/webview/index?id=${id}`,
     })
+    util.request(api.increaseViewCount, {
+      brandId: id
+    }, 'GET').then((res) => {
+        // var num =  'roomList['+index+'].pvTotalNum'
+        // this.setData({
+        //   [num]:res.data
+        // })
+    });
+
   },
   onPullDownRefresh() {
-  
+
     this.setData({
       roomList: [],
       'fetcherData.page': 1,
@@ -208,17 +222,29 @@ Router({
     }).then((res) => {
       // console.log(res)
       if (res.errno === 0) {
-        if (res.data.data.length == 0) {
-          let mt = (type-0)+1
+        let mt = (type - 0) + 1
 
+        if (res.data.data.length == 0) {
           this.setData({
             middleEmptyLength: this.data.middleEmptyLength + 1,
-            middleType:mt
+            middleType: mt
           })
+
+        } else {
+          let t = this.data.middleTypeList
+          t.push(type)
+          this.setData({
+            middleTypeList: t,
+          }, () => {
+            this.setData({
+              middleType: this.data.middleTypeList[0]
+            })
+          })
+
         }
         let value = `middleList.${type}`
         this.setData({
-          [value]: res.data.data
+          [value]: res.data.data,
         })
       }
     });
@@ -242,6 +268,9 @@ Router({
     app.checkNetStatu();
     // 页面渲染完成
     this.getRoomList()
+    this.setData({
+      middleTypeList:[]
+    })
     for (let i = 0; i < this.data.middleTabList.length; i++) {
       this.getMiddleList(this.data.middleTabList[i].type)
     }
@@ -261,11 +290,12 @@ Router({
     if (city != this.data.city) {
       this.setData({
         'city': app.globalData.city,
-        'fetcherData.page':1,
+        'fetcherData.page': 1,
         middleEmptyLength: 0,
-        hasData:true,
-        loading:false,
-        roomList:[]
+        hasData: true,
+        loading: false,
+        roomList: [],
+        middleTypeList:[]
       })
       this.getRoomList()
       for (let i = 0; i < this.data.middleTabList.length; i++) {

+ 5 - 3
pages/searchRoom/searchRoom.js

@@ -47,9 +47,7 @@ Page({
         title: '加载中...',
       });
       // console.log(this.data.searchKey)
-      this.setData({
-        isSearch: true
-      })
+     
       this.getRoomList()
     } else {
       wx.showToast({
@@ -78,6 +76,7 @@ Page({
       }
     }
     if (!this.data.loading) {
+     
       this.setData({
         loading: true
       })
@@ -92,12 +91,15 @@ Page({
 
             this.setData({
               storeList: res.data.data,
+              isSearch: true
             })
           } else {
 
             this.setData({
               roomList: res.data.data,
+              isSearch: true
             })
+           
           }
 
 

+ 5 - 0
pages/sence/sence.js

@@ -124,6 +124,11 @@ Page({
     wx.navigateTo({
       url: `/pages/webview/index?id=${id}`,
     })
+    util.request(api.increaseViewCount, {
+      brandId: id
+    }, 'GET').then((res) => {
+      
+    });
   },
   /**
    * 生命周期函数--监听页面加载

+ 19 - 10
pages/store/store.js

@@ -11,7 +11,7 @@ Page({
     type: 21,
     storeList: [],
     hasData: true,
-    loading:false,
+    loading: false,
     fetcherData: {
       type: 21,
       address: '',
@@ -21,10 +21,19 @@ Page({
     }
   },
   gotoWV: function (event) {
-    let id = event.detail
+    let {id,index} = event.detail
     wx.navigateTo({
       url: `/pages/webview/index?id=${id}`,
     })
+    util.request(api.increaseViewCount, {
+      brandId: id
+    }, 'GET').then((res) => {
+        var num =  'storeList['+index+'].pvTotalNum'
+        this.setData({
+          [num]:res.data
+        })
+    });
+
   },
   toSearch(e) {
     var type = e.currentTarget.dataset.type
@@ -35,16 +44,16 @@ Page({
   },
   getStoreList() {
     if (this.data.hasData) {
-      if(!this.data.loading){
+      if (!this.data.loading) {
         this.setData({
-          loading:true
+          loading: true
         })
         wx.showLoading({
           title: '加载中...',
         })
         util.request(api.BrandList, this.data.fetcherData).then((res) => {
           this.setData({
-            loading:false
+            loading: false
           })
           if (res.errno === 0) {
             if (res.data.data.length != 0) {
@@ -52,21 +61,21 @@ Page({
                 storeList: this.data.storeList.concat(res.data.data),
                 'fetcherData.page': this.data.fetcherData.page + 1
               })
-  
+
             } else {
               this.setData({
                 hasData: false
               })
-  
+
             }
           }
-        }).catch(err=>{
+        }).catch(err => {
           this.setData({
-            loading:false
+            loading: false
           })
         });
       }
-     
+
     } else {
       console.log('没有更多数据')
     }

+ 2 - 2
pages/store/store.wxml

@@ -9,8 +9,8 @@
   </view>
   <view style="height: 84rpx;"></view>
   <view class="storeList" wx:if="{{storeList.length>0}}">
-    <view wx:for="{{storeList}}">
-      <storeItem store="{{item}}"  bindgotoWV="gotoWV"></storeItem>
+    <view wx:for="{{storeList}}" wx:for-index="index">
+      <storeItem store="{{item}}" index="{{index}}" bindgotoWV="gotoWV"></storeItem>
     </view>
   </view>
 

+ 13 - 4
pages/user/user.js

@@ -83,9 +83,14 @@ Page({
       }
     })
   },
-
-  async save() {
-    console.log(this.file)
+  changPhone(e){
+    this.setData({
+      'mobile': e.detail.value,
+    });
+  },
+  async save(e) {
+    let type = e.currentTarget.dataset.type
+    console.log(e)
     if (this.file) {
       let avatar = await (new Promise(r => {
         wx.uploadFile({
@@ -107,7 +112,11 @@ Page({
     const body = {...this.data}
     delete body.region
     const {data} = await util.request(api.UpdateUserInfo, body, 'POST', 'application/json')
-    wx.navigateBack()
+    if(type=='1'){
+      wx.navigateBack()
+    }else{
+
+    }
   },
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 2 - 2
pages/user/user.wxml

@@ -17,7 +17,7 @@
     <view class="item">
       <text>手机号</text>
       <view class="ir">
-        <input value="{{mobile}}" class="ipname" disabled wx:if="{{mobile}}"></input>
+        <input bindblur="save" data-type="2" bindinput="changPhone" value="{{mobile}}" class="ipname"  wx:if="{{mobile}}"></input>
         <button wx:if="{{!mobile}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="getPhone">点击获取手机号</button>
       </view>
     </view>
@@ -64,6 +64,6 @@
   </view>
 
   <view class="save">
-    <button bindtap="save">保存</button>
+    <button bindtap="save" data-type="1" >保存</button>
   </view>
 </view>