Przeglądaj źródła

feature 代码提交

xiahan 4 miesięcy temu
rodzic
commit
a4a5562813

+ 4 - 2
app.js

@@ -28,7 +28,7 @@ App({
               dsKey: options.query.deskey
             },
             success(res) {
-              debugger
+      
               wx.hideLoading()
               if (!res.data.code || res.data.code!= "200") {
                 utils.simleInfoWithBack('登录失败,请稍后再试')
@@ -47,7 +47,8 @@ App({
                   currentDsKey:""
                 }
                 if(resData.swUserManagementVos.length!=0){
-                  _this.globalData.currentAccountInfo=(resData.swUserManagementVos||[])[0]
+                  _this.globalData.currentAccountInfo=(resData.swUserManagementVos||[])[0];
+                  _this.globalData.userWxInfo.currentDsKey=(resData.swUserManagementVos||[])[0].dsKey;
                 };
                 _this.globalData.waterCompanys=resData.waterCompany;
                 if (resData.swUserManagementVos.length == 0) {
@@ -99,6 +100,7 @@ App({
       homePageInfo: baseIp+ '/wechat/account/info/', // 首页获取用水量等信息
       billList: baseIp+ '/wechat/bill/list', // 首页获取用水量等信息
       accountList: baseIp+ '/wechat/account/list', // 首页获取用水量等信息
+      accountUnbind: baseIp+ '/wechat/account/unbind', // 户号解绑方法
     },
     imgPreviewUrl: "http://192.168.0.215:9000/common/sys/sysfile/preview?fileId=",
     // 统一管理图片路径

+ 1 - 3
pages/homepage/homepage.js

@@ -66,7 +66,6 @@ Page({
   },
 
   onLoad() {
-    debugger;
     let refresh= app.globalData.refresh;
     if(refresh==1){
       wx.showLoading({
@@ -77,7 +76,6 @@ Page({
         return;
       }
       const _this = this;
-      debugger;
       wx.request({
         url: app.globalData.interfaceUrls.homePageInfo+app.globalData.currentAccountInfo.usernumber,
         method: 'GET',
@@ -117,7 +115,7 @@ Page({
   // 切换水表
   handleSwitchMeter() {
     wx.navigateTo({
-      // url: '/pages/meterList/meterList'
+       url: '/pages/huhaoguanli/huhaoguanli'
     })
   },
 

+ 72 - 38
pages/huhaoguanli/huhaoguanli.js

@@ -6,7 +6,7 @@ Page({
   data: {
     huHaoList: [],
     showUnbindModal: false,
-    currentHuHao: null
+    unbindId: null
   },
 
   onLoad: function (options) {
@@ -34,21 +34,12 @@ Page({
         let apiReturnData = res.data;
         debugger;
         _this.setData({
-          huHaoList: apiReturnData.data.map(data => {
-            return {
-              id: data.id,
-              name: data.username,
-              tag: data.groupName,
-              phone: data.usernumber,
-              address: data.address,
-              deleted: 0
-            };
-          }),
+          huHaoList: apiReturnData.data,
         })
       },
       fail(error) {
         wx.hideLoading()
-        utils.simleInfo('登录失败,请稍后再试')
+        utils.simleInfo('获取数据失败,请稍后再试')
       }
     });
   },
@@ -56,11 +47,10 @@ Page({
   // 点击解除绑定按钮
   unbindHuHao: function (e) {
     const id = e.currentTarget.dataset.id;
-    const huHao = this.data.huHaoList.find(item => item.id === id);
 
     this.setData({
       showUnbindModal: true,
-      currentHuHao: huHao
+      unbindId: id
     });
   },
 
@@ -68,39 +58,83 @@ Page({
   cancelUnbind: function () {
     this.setData({
       showUnbindModal: false,
-      currentHuHao: null
+      unbindId: null
     });
   },
 
   // 确认解绑
   confirmUnbind: function () {
-    const id = this.data.currentHuHao.id;
-
-    // 这里应该调用后端接口,将deleted设为1
-    // 模拟接口调用成功后的处理
-    const updatedList = this.data.huHaoList.map(item => {
-      if (item.id === id) {
-        return { ...item, deleted: 1 };
-      }
-      return item;
+    const id = this.data.unbindId;
+    this.accountUnbind(id);
+  },
+  // 解绑方法
+  accountUnbind:function (id) {
+    debugger;
+    const unbindInfo = this.data.huHaoList.filter(item => {
+      return item.id === id;
+    })[0];
+    const otherInfo=this.data.huHaoList.filter(item => {
+      return item.id!= id;
     });
-
-    this.setData({
-      huHaoList: updatedList,
-      showUnbindModal: false,
-      currentHuHao: null
+    const _this = this;
+    wx.showLoading({
+      title: '获取中...',
+      mask: true,
     });
-
-    // 刷新页面数据
-    this.filterHuHaoList();
-
-    wx.showToast({
-      title: '解绑成功',
-      icon: 'success',
-      duration: 2000
+    wx.request({
+      url: app.globalData.interfaceUrls.accountUnbind,
+      method: 'POST',
+      data: {
+        account: unbindInfo.usernumber,
+        deKey: unbindInfo.dsKey,
+        refresh: false,
+        //为true 时otherDsKeys最好必填节约后端请求时间
+        otherDsKeys: []
+      },
+      header: {
+        'content-type': 'application/json', // 默认值
+        'token': app.globalData.userWxInfo.token,
+        // '!SAAS_LOGIN_TOKEN_!': app.globalData.currentAccountInfo.dsKey
+      },
+      success(res) {
+        wx.hideLoading();
+        let apiReturnData = res.data;
+        if(apiReturnData.code=='200'){
+          wx.showToast({
+            title: '解绑成功',
+            icon: 'success',
+            duration: 2000
+          });
+          _this.setData({
+            huHaoList: otherInfo,
+            showUnbindModal: false,
+            currentHuHao: null
+          });
+          if(otherInfo.length==0){
+            app.globalData.currentAccountInfo=[];
+            app.globalData.userWxInfo.currentDsKey="";
+            wx.redirectTo({
+              url: '/pages/FirstBangDing/FirstBangDing',
+            })
+          }else{
+            app.globalData.currentAccountInfo=otherInfo[0];
+            app.globalData.userWxInfo.currentDsKey=otherInfo[0].deKey;
+          }
+        }else{
+          wx.showToast({
+            title: apiReturnData.msg,
+            icon: 'error',
+            duration: 2000
+          })
+          wx.hideLoading();
+        }
+      },
+      fail(error) {
+        wx.hideLoading();
+        utils.simleInfo('户号解绑失败,请稍后再试');
+      }
     });
   },
-
   // 跳转到绑定新户号页面
   goToBindNewHuHao: function () {
     wx.navigateTo({

+ 3 - 3
pages/huhaoguanli/huhaoguanli.wxml

@@ -17,12 +17,12 @@
           <image class="card-background" src="/static_file/card.png" mode="aspectFill" />
           <view class="card-header">
             <view class="name-tag">
-              <text class="name">{{item.name}}</text>
-              <text class="tag" wx:if="{{item.tag}}">{{item.tag}}</text>
+              <text class="name">{{item.username}}</text>
+              <text class="tag" wx:if="{{item.groupName}}">{{item.groupName}}</text>
             </view>
           </view>
           <view class="card-body">
-            <text class="phone">{{item.phone}}</text>
+            <text class="phone">{{item.usernumber}}</text>
             <text class="address">{{item.address}}</text>
           </view>
           <view class="card-footer">

+ 11 - 68
pages/tongzhiList/tongzhiList.js

@@ -1,81 +1,24 @@
 // 通知列表页面的JS文件
+const app = getApp();
+const utils = require('../../utils/util.js')
 Page({
   /**
    * 页面的初始数据
    */
   data: {
     noticeList: [
-      {
-        id: '1',
-        title: '缴费通知',
-        content: '由于您没有缴费,为保证正常用水,请您看到通知后到小程序主页进行充值缴费...',
-        date: '2025-03-10',
-        type: 'payment',
-        source: '智慧水务'
-      },
-      {
-        id: '2',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      },
-      {
-        id: '3',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      },
-      {
-        id: '4',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      },
-      {
-        id: '5',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      },
-      {
-        id: '6',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        icon: '/static_file/water_drop_icon.png',
-        source: '智慧水务'
-      },
-      {
-        id: '7',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      },
-      {
-        id: '8',
-        title: '停水通知',
-        content: '因管道维修,您所在区域将于2025年3月15日8:00-18:00停水,请提前做好准备...',
-        date: '2025-03-08',
-        type: 'notice',
-        source: '智慧水务'
-      }
     ]
   },
 
-  // onLoad: function (options) {
-  //   this.getNoticeList();
-  // },
+  onLoad: function (options) {
+    debugger
+    app.globalData.waterCompanys[0].notifications.forEach(data=>{
+      data.publishtime=utils.formatDate(new Date(data.publishtime))
+    });
+    this.setData({
+      noticeList: app.globalData.waterCompanys[0].notifications
+    });
+  },
 
 
   // getNoticeList: function() {

+ 9 - 5
pages/tongzhiList/tongzhiList.wxml

@@ -1,10 +1,12 @@
+<wxs module="tools">
+
+</wxs>
 <view class="container">
-  <!-- 返回按钮 -->
+  <!-- 返回按钮 --> 
   <view class="custom-nav">
     <view class="fixed-back" bindtap="goBack">←</view>
     <view class="nav-title">通知公告</view>
   </view>
-
   <scroll-view scroll-y="true" class="notice-list">
     <block wx:for="{{noticeList}}" wx:key="id">
       <view class="notice-item" bindtap="goToDetail" data-id="{{item.id}}">
@@ -12,10 +14,12 @@
           <image class="notice-icon" src="{{item.type === 'payment' ? '/static_file/horn_icon.png' : '/static_file/water_drop_icon.png'}}" mode="aspectFit"></image>
         </view>
         <view class="notice-content">
-          <view class="notice-title">{{item.title}}</view>
-          <view class="notice-desc">{{item.content}}</view>
+          <view class="notice-title">{{item.noticetitle}}</view>
+          <view class="notice-desc">
+            <rich-text nodes="{{item.noticecontent}}"></rich-text>
+          </view>
         </view>
-        <view class="notice-date">{{item.date}}</view>
+        <view class="notice-date">{{item.publishtime}}</view>
       </view>
     </block>
     

+ 1 - 7
pages/tzxq/tzxq.js

@@ -21,13 +21,7 @@ Page({
         // 直接设置通知详情数据
         this.setData({
           noticeId: noticeData.id,
-          noticeDetail: {
-            id: noticeData.id,
-            title: noticeData.title,
-            content: noticeData.content,
-            date: noticeData.date,
-            source: noticeData.source || '智慧水务'
-          }
+          noticeDetail:noticeData
         });
       } catch (error) {
         console.error('解析通知数据失败', error);

+ 7 - 5
pages/tzxq/tzxq.wxml

@@ -12,19 +12,21 @@
 
   <view class="notice-detail-wrapper">
     <view class="notice-detail">
-      <view class="notice-title">{{noticeDetail.title}}</view>
+      <view class="notice-title">{{noticeDetail.noticetitle}}</view>
       <!-- 标题下方的分隔线 -->
       <view class="title-divider"></view>
       <!-- 通知内容 -->
       <view class="notice-content">
-        <rich-text nodes="{{noticeDetail.content}}"></rich-text>
+        <rich-text nodes="{{noticeDetail.noticecontent}}"></rich-text>
       </view>
       
       <!-- 落款和日期放在右下角 -->
       <view class="notice-footer">
-        <view class="notice-signature">{{noticeDetail.source}}</view>
-        <view class="notice-footer-date">{{noticeDetail.date}}</view>
-      </view>
+        <!-- 
+          <view class="notice-signature">{{noticeDetail.source}}</view> 
+          <view class="notice-footer-date">{{noticeDetail.date}}</view>
+        -->
+      </view> 
     </view>
   </view>
 </view> 

+ 0 - 3
pages/zhangdanlist/zhangdanlist.js

@@ -21,7 +21,6 @@ Page({
   },
 
   onLoad: function(options) {
-    debugger;
     // 确保图片资源正确加载
     this.setData({
       images: {
@@ -40,7 +39,6 @@ Page({
       title: '获取中...',
       mask: true,
     });
-      debugger;
       wx.request({
         url: app.globalData.interfaceUrls.billList,
         method: 'POST',
@@ -57,7 +55,6 @@ Page({
         success (res) {
           wx.hideLoading();
           let apiReturnData=res.data;
-          debugger;
           _this.setData({
             billList:apiReturnData.data,
           })

+ 8 - 0
utils/util.js

@@ -8,6 +8,13 @@ const formatTime = date => {
 
   return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
 }
+const formatDate = date => {
+  const year = date.getFullYear()
+  const month = date.getMonth() + 1
+  const day = date.getDate()
+
+  return `${[year, month, day].map(formatNumber).join('-')} `
+}
 
 const formatNumber = n => {
   n = n.toString()
@@ -37,4 +44,5 @@ module.exports = {
   simleInfoWithBack: simleInfoWithBack,
   formatNumber: formatNumber,
   formatTime: formatTime,
+  formatDate: formatDate,
 }