浏览代码

企业详情页编辑/删除按钮隐藏显示,企业搜索列表功能优化,登录增加userId获取

menc 2 年之前
父节点
当前提交
9384bdaada
共有 7 个文件被更改,包括 74 次插入56 次删除
  1. 1 0
      app.js
  2. 1 1
      base/httputil.js
  3. 2 0
      pages/denglu/denglu.js
  4. 45 40
      pages/details/details.js
  5. 2 6
      pages/details/details.wxml
  6. 4 1
      pages/details/details.wxss
  7. 19 8
      pages/search/search.js

+ 1 - 0
app.js

@@ -5,4 +5,5 @@ App({
     host : "http://sookajs.top:4002"
     host : "http://sookajs.top:4002"
   },
   },
   isLoginSuccess:false,
   isLoginSuccess:false,
+  loginUserId: null,
 })
 })

+ 1 - 1
base/httputil.js

@@ -1,7 +1,7 @@
 // let BASE_Server = "http://127.0.0.1:8329"
 // let BASE_Server = "http://127.0.0.1:8329"
     // let BASE_Server = "https://192.168.1.109:8080"
     // let BASE_Server = "https://192.168.1.109:8080"
 let BASE_Server = "https://sookajs.top:18080"
 let BASE_Server = "https://sookajs.top:18080"
-// let BASE_Server = "http://192.168.2.9:18080"
+// let BASE_Server = "http://192.168.2.9:8080"
 
 
 
 
 
 

+ 2 - 0
pages/denglu/denglu.js

@@ -70,6 +70,8 @@ Page({
     } else {
     } else {
       // that.data.openid = res.openid
       // that.data.openid = res.openid
       app.globalToken = res.data.access_token,
       app.globalToken = res.data.access_token,
+      app.loginUserId=res.data.loginUser.userId,
+    
       wx.setStorageSync('userName', that.data.userName),
       wx.setStorageSync('userName', that.data.userName),
       wx.setStorageSync('password', that.data.password),
       wx.setStorageSync('password', that.data.password),
       app.isLoginSuccess = true
       app.isLoginSuccess = true

+ 45 - 40
pages/details/details.js

@@ -8,8 +8,8 @@ Page({
   onLoad(e) {
   onLoad(e) {
     this.data.busEnterpriseId = e.busEnterpriseId
     this.data.busEnterpriseId = e.busEnterpriseId
   },
   },
-  onShow(){
-   
+  onShow() {
+
     this.getEnterpriseDetails()
     this.getEnterpriseDetails()
   },
   },
   data: {
   data: {
@@ -29,7 +29,8 @@ Page({
       longitude: 125.3504459,
       longitude: 125.3504459,
       width: 35,
       width: 35,
       height: 50
       height: 50
-    }]
+    }],
+    isShowEdit: true,
 
 
   },
   },
 
 
@@ -40,11 +41,15 @@ Page({
     http.post("/system/AppEnterpriseController/getEnterpriseDetails", obj, this.getEnterpriseDetailsSuccess)
     http.post("/system/AppEnterpriseController/getEnterpriseDetails", obj, this.getEnterpriseDetailsSuccess)
   },
   },
   getEnterpriseDetailsSuccess(res) {
   getEnterpriseDetailsSuccess(res) {
- 
+    //  var currentUserId=res.enterpriseDetails.userId;
+    //  var loginUserid=app.loginUserId; 
+    this.isShowEdit = (res.enterpriseDetails.userId === app.loginUserId)
     this.setData({
     this.setData({
       enterpriseDetails: res.enterpriseDetails,
       enterpriseDetails: res.enterpriseDetails,
       latitude: res.enterpriseDetails.latitude,
       latitude: res.enterpriseDetails.latitude,
       longitude: res.enterpriseDetails.longitude,
       longitude: res.enterpriseDetails.longitude,
+      isShowEdit: this.isShowEdit,
+
       markers: [{
       markers: [{
         id: res.enterpriseDetails.busEnterpriseId,
         id: res.enterpriseDetails.busEnterpriseId,
         name: res.enterpriseDetails.businessName,
         name: res.enterpriseDetails.businessName,
@@ -52,7 +57,7 @@ Page({
         latitude: res.enterpriseDetails.latitude,
         latitude: res.enterpriseDetails.latitude,
         longitude: res.enterpriseDetails.longitude,
         longitude: res.enterpriseDetails.longitude,
         width: 35,
         width: 35,
-        height: 50
+        height: 50,
       }]
       }]
     })
     })
   },
   },
@@ -70,20 +75,20 @@ Page({
     })
     })
   },
   },
   //巡更点跳转
   //巡更点跳转
-  xungengList(){
+  xungengList() {
     wx.navigateTo({
     wx.navigateTo({
-      url: '../patrol_list/patrol_list?enterpriseId='+this.data.busEnterpriseId,
+      url: '../patrol_list/patrol_list?enterpriseId=' + this.data.busEnterpriseId,
     })
     })
   },
   },
   //导航
   //导航
   navRoad(event) {
   navRoad(event) {
-   
+
     wx.getLocation({ //获取当前经纬度
     wx.getLocation({ //获取当前经纬度
       type: 'wgs84', //返回可以用于wx.openLocation的经纬度,
       type: 'wgs84', //返回可以用于wx.openLocation的经纬度,
       success: function (res) {
       success: function (res) {
         wx.openLocation({ //​使用微信内置地图查看位置。
         wx.openLocation({ //​使用微信内置地图查看位置。
           latitude: Number(event.currentTarget.dataset.marker.latitude), //要去的纬度-地址
           latitude: Number(event.currentTarget.dataset.marker.latitude), //要去的纬度-地址
-          longitude:Number( event.currentTarget.dataset.marker.longitude), //要去的经度-地址
+          longitude: Number(event.currentTarget.dataset.marker.longitude), //要去的经度-地址
           name: event.currentTarget.dataset.marker.name,
           name: event.currentTarget.dataset.marker.name,
           address: event.currentTarget.dataset.marker.address
           address: event.currentTarget.dataset.marker.address
         })
         })
@@ -97,48 +102,48 @@ Page({
   //巡检跳转
   //巡检跳转
   bindViewXunJian() {
   bindViewXunJian() {
     wx.navigateTo({
     wx.navigateTo({
-      url: '../xunjian/xunjian?busEnterpriseId='+this.data.busEnterpriseId
-      +"&isBeforeBack=true",
+      url: '../xunjian/xunjian?busEnterpriseId=' + this.data.busEnterpriseId
+        + "&isBeforeBack=true",
     })
     })
   },
   },
   //巡检跳转
   //巡检跳转
   bindViewXunChaJiLu() {
   bindViewXunChaJiLu() {
     wx.navigateTo({
     wx.navigateTo({
       url: '../xunchajilu/xunchajilu?busEnterpriseId='
       url: '../xunchajilu/xunchajilu?busEnterpriseId='
-      +this.data.enterpriseDetails.busEnterpriseId
-      +"&businessName="+this.data.enterpriseDetails.businessName,
+        + this.data.enterpriseDetails.busEnterpriseId
+        + "&businessName=" + this.data.enterpriseDetails.businessName,
     })
     })
   },
   },
   //企业详情
   //企业详情
   bindViewQiYeXiangQingTable() {
   bindViewQiYeXiangQingTable() {
     wx.navigateTo({
     wx.navigateTo({
-      url: '../qiyexqtable/qiyexqtable?busEnterpriseId='+this.data.busEnterpriseId,
+      url: '../qiyexqtable/qiyexqtable?busEnterpriseId=' + this.data.busEnterpriseId,
     })
     })
-    },
-    bindViewQiYeDelete(){
-        wx.showModal({
-          title: '提示',
-          content: '确认废弃该企业?',
-          complete: (res) => {
-            if (res.cancel) {
-              
-            }else {
-              this.deleteEnterprise()
-            }
-          }
-        })
-    },
-    deleteEnterprise() {
-      let obj = new Object();
-      obj.busEnterpriseId = this.data.busEnterpriseId
-      http.post("/system/AppEnterpriseController/deleteEnterprise", obj, this.deleteEnterpriseSuccess)
-    },
-    deleteEnterpriseSuccess(res) {
-      wx.showToast({
-        title: res.msg,
-      })
-      if(res.code == 200){
-        wx.navigateBack()
+  },
+  bindViewQiYeDelete() {
+    wx.showModal({
+      title: '提示',
+      content: '确认废弃该企业?',
+      complete: (res) => {
+        if (res.cancel) {
+
+        } else {
+          this.deleteEnterprise()
+        }
       }
       }
-    },
+    })
+  },
+  deleteEnterprise() {
+    let obj = new Object();
+    obj.busEnterpriseId = this.data.busEnterpriseId
+    http.post("/system/AppEnterpriseController/deleteEnterprise", obj, this.deleteEnterpriseSuccess)
+  },
+  deleteEnterpriseSuccess(res) {
+    wx.showToast({
+      title: res.msg,
+    })
+    if (res.code == 200) {
+      wx.navigateBack()
+    }
+  },
 })
 })

+ 2 - 6
pages/details/details.wxml

@@ -5,16 +5,12 @@
 
 
     <view class="map_btn">
     <view class="map_btn">
     <text class="iconfont icon-wenjianguanli" bindtap="bindViewXunChaJiLu"></text>
     <text class="iconfont icon-wenjianguanli" bindtap="bindViewXunChaJiLu"></text>
-    <text class="iconfont icon-icon-test" bindtap="bindViewQiYeXiangQingTable"></text>
-    <text class="iconfont icon-pinleishanchu" bindtap="bindViewQiYeDelete"></text>
+    <text class="iconfont icon-icon-test" bindtap="bindViewQiYeXiangQingTable" wx:if="{{isShowEdit}}"></text>
+    <text class="iconfont icon-pinleishanchu" bindtap="bindViewQiYeDelete" wx:if="{{isShowEdit}}"></text>
     </view>
     </view>
 
 
-
-
     <view class="map_view">
     <view class="map_view">
 
 
-
-
       <view>
       <view>
         <span>经度:</span>
         <span>经度:</span>
         <i>{{enterpriseDetails.longitude}}</i>
         <i>{{enterpriseDetails.longitude}}</i>

+ 4 - 1
pages/details/details.wxss

@@ -36,7 +36,10 @@ word-wrap:break-word
   background: rgba(0, 0, 0, 0.479);
   background: rgba(0, 0, 0, 0.479);
   display: flex;
   display: flex;
   flex-direction: row;
   flex-direction: row;
-  width: 220rpx;
+  /* width: 220rpx; */
+  width: auto;
+  padding-left: 20rpx;
+  padding-right: 20rpx;
   height: 70rpx;
   height: 70rpx;
   position: absolute;
   position: absolute;
   right:20rpx;
   right:20rpx;

+ 19 - 8
pages/search/search.js

@@ -22,7 +22,7 @@ Page({
     total: 0,
     total: 0,
     pageNum: 1 // 页码
     pageNum: 1 // 页码
   },
   },
-  onLoad() {},
+  onLoad() { },
 
 
   //加载数据
   //加载数据
   loadData: function () {
   loadData: function () {
@@ -33,8 +33,6 @@ Page({
     // obj.businessName = e.detail.value
     // obj.businessName = e.detail.value
     obj.searchValue = this.data.keyword,
     obj.searchValue = this.data.keyword,
       this.list(obj)
       this.list(obj)
-
-
   },
   },
   onShow() {
   onShow() {
     this.loadData();
     this.loadData();
@@ -49,7 +47,20 @@ Page({
   },
   },
 
 
   searchEnterprise(e) {
   searchEnterprise(e) {
+    wx.showNavigationBarLoading();
+
+    var loadingData = this.data.loadingData
+    if (loadingData) {
+      return;
+    }
+    this.setData({
+      pageNum: 1,
+      isRefresh: true
+    })
     var obj = new Object()
     var obj = new Object()
+    obj.pageNum = this.data.pageNum
+    obj.pageSize = 10
+    obj.reasonable = false
     this.data.keyword = e.detail.value,
     this.data.keyword = e.detail.value,
       obj.searchValue = e.detail.value,
       obj.searchValue = e.detail.value,
       this.list(obj)
       this.list(obj)
@@ -106,7 +117,8 @@ Page({
 
 
       var that = this
       var that = this
 
 
-      if (res.data.rows.length == 0) {
+
+      if (res.rows.length == 0) {
         wx.showToast({
         wx.showToast({
           title: '暂无更多数据',
           title: '暂无更多数据',
           icon: "none"
           icon: "none"
@@ -119,8 +131,8 @@ Page({
       }
       }
       if (this.data.isRefresh) {
       if (this.data.isRefresh) {
         this.setData({
         this.setData({
-          enterpriseList: res.data.rows,
-          total: res.data.total
+          enterpriseList: res.rows,
+          total: res.total
         })
         })
 
 
 
 
@@ -139,7 +151,7 @@ Page({
 
 
       } else {
       } else {
         this.setData({
         this.setData({
-          enterpriseList: this.data.enterpriseList.concat(res.data.rows)
+          enterpriseList: this.data.enterpriseList.concat(res.rows)
         })
         })
         // 隐藏加载框
         // 隐藏加载框
 
 
@@ -148,7 +160,6 @@ Page({
             hidden: true,
             hidden: true,
             loadingData: false
             loadingData: false
           });
           });
-
           wx.hideLoading();
           wx.hideLoading();
         }, 1000)
         }, 1000)