Explorar o código

增加访客历史功能

jiagsf hai 3 semanas
pai
achega
89c0b1b914
Modificáronse 2 ficheiros con 98 adicións e 109 borrados
  1. 16 17
      pages/interviewee/index.axml
  2. 82 92
      pages/interviewee/index.js

+ 16 - 17
pages/interviewee/index.axml

@@ -103,7 +103,6 @@
             </view>
             </view>
           </view>
           </view>
         </view>
         </view>
-        {{ intervieweeForm.name }}
         <block a:if="{{ isHistory }}">
         <block a:if="{{ isHistory }}">
           <view class="interviewee-content-rightHistory">
           <view class="interviewee-content-rightHistory">
             <view class="rightHistory-title">
             <view class="rightHistory-title">
@@ -125,7 +124,7 @@
                 a:for="{{ historyList }}"
                 a:for="{{ historyList }}"
                 a:for-index="index"
                 a:for-index="index"
               >
               >
-                <view class="content_box {{ item.info1.isSel ? 'content_boxSel' : '' }}" onTap="selInfo" id="{{item.id}}">
+                <view class="content_box {{ item.info1.isSel ? 'content_boxSel' : '' }}" onTap="selInfo" data-index={{ index }}>
                   <view class="content_box_left content_box_info">
                   <view class="content_box_left content_box_info">
                     <view class="title">
                     <view class="title">
                       访客信息
                       访客信息
@@ -142,7 +141,7 @@
                           姓名
                           姓名
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.carno }}
+                          : {{ item.info1.visitorName }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -150,7 +149,7 @@
                           手机号
                           手机号
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.certPhone }}
+                          : {{ item.info1.visitorPhone }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -158,7 +157,7 @@
                           单位
                           单位
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.company }}
+                          : {{ item.info1.visitorUnit }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -166,7 +165,7 @@
                           车牌
                           车牌
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.carno }}
+                          : {{ item.info1.carnum }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -174,7 +173,7 @@
                           事由
                           事由
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info1.causeMatterName }}
                         </view>
                         </view>
                       </view>
                       </view>
                     </view>
                     </view>
@@ -184,7 +183,7 @@
                       受访人信息
                       受访人信息
                       <view class="title-info" a:if="{{ item.info1.isSel }}">
                       <view class="title-info" a:if="{{ item.info1.isSel }}">
                         <image catchTouchMove
                         <image catchTouchMove
-                          catchTap="selInfo2" id="{{ item.id }}"
+                          catchTap="selInfo2" data-index="{{ index }}"
                           a:if="{{ item.info2.isSel }}"
                           a:if="{{ item.info2.isSel }}"
                           class="selected-icon"
                           class="selected-icon"
                           mode="scaleToFill" 
                           mode="scaleToFill" 
@@ -199,7 +198,7 @@
                           姓名
                           姓名
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.name }}
                         </view>
                         </view>
                       </view>
                       </view>
 
 
@@ -208,7 +207,7 @@
                           手机号
                           手机号
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.phone }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -216,7 +215,7 @@
                           单位
                           单位
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.company }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -224,7 +223,7 @@
                           部门
                           部门
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.unitName }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -232,7 +231,7 @@
                           楼层
                           楼层
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.floor }}
                         </view>
                         </view>
                       </view>
                       </view>
                       <view class="info_box">
                       <view class="info_box">
@@ -240,7 +239,7 @@
                           房间号
                           房间号
                         </view>
                         </view>
                         <view class="info_box_value">
                         <view class="info_box_value">
-                          : {{ item.info1.reason }}
+                          : {{ item.info2.room }}
                         </view>
                         </view>
                       </view>
                       </view>
                     </view>
                     </view>
@@ -250,11 +249,11 @@
             </view>
             </view>
             <!-- 页数 -->
             <!-- 页数 -->
             <view class="num-page">
             <view class="num-page">
-              <view class="previous magnify" onTap="previousFun">上一页</view>
+              <view class="previous magnify" onTap="historyPreviousFun">上一页</view>
               <view class="total">
               <view class="total">
-                {{pageSize}}/{{pageNum}}
+                {{historyPagNum}}/{{historyPageSize}}
               </view>
               </view>
-              <view class="next magnify" onTap="nextFun">下一页</view>
+              <view class="next magnify" onTap="historyNextFun">下一页</view>
             </view>
             </view>
           </view>
           </view>
         </block>
         </block>

+ 82 - 92
pages/interviewee/index.js

@@ -14,6 +14,7 @@ import {
 import {
 import {
   encryptAndSign
   encryptAndSign
 } from '../../utils/index/getSM4'
 } from '../../utils/index/getSM4'
+import { match } from 'assert'
 const app = getApp()
 const app = getApp()
 Page({
 Page({
   data: {
   data: {
@@ -168,45 +169,10 @@ Page({
     screenIntervalId: null, //定时器
     screenIntervalId: null, //定时器
     // 默认历史
     // 默认历史
 
 
-    historyPagNum: 0, //总页数
-    historyPageSize: 0, //当前页数
-    historyPagNum: 1,
+    historyPagNum: 1, //当前页数
+    historyPageSize: 0, //总页数
     isHistory: true,
     isHistory: true,
-    historyList: [{
-      id:1,
-      info1:{
-        visitorName: '访客1',
-        visitorUnit: '单位1',
-        isSel:false,
-      },
-      info2:{
-        name: '受访人1',
-        phone: '1111111111111',
-        idNumber: '11111111111',
-        company: '11111111111',
-        unitName: '111111111',
-        floor: '111111111111',
-        room: '1111111111111',
-        showTitle: '111111111',
-      }
-    },{
-      id:2,
-      info1:{
-        visitorName: '访客1',
-        visitorUnit: '单位2',
-        isSel:false,
-      },
-      info2:{
-        name: '受访人2',
-        phone: '22222222222',
-        idNumber: '2222222222',
-        company: '222222222222',
-        unitName: '2222222222222',
-        floor: '222222222222222',
-        room: '2222222222222',
-        showTitle: '222222222222',
-      }
-    }]
+    historyList: []
   },
   },
   onLoad() {
   onLoad() {
     my.hideBackHome();
     my.hideBackHome();
@@ -261,48 +227,78 @@ Page({
       }
       }
     })
     })
   },
   },
-  async getHistory(){
+  async getHistory(historyPagNum){
     try {
     try {
-      let data = {
+      let params = {
         data : {
         data : {
-          "certNo": this.data.remainingInfo.visitorIdCard,
-          sn: app.globalData.sn,
+          certNo: "362330199801077198",
+          sn: "118D002000500012",
+
+          // "certNo": this.data.remainingInfo.visitorIdCard,
+          // sn: app.globalData.sn,
         },
         },
-        pageNum:this.data.historyPagNum,
+        pageNum: historyPagNum ? historyPagNum : 1,
         pageSize: 2
         pageSize: 2
       }
       }
-      let res = await app.data.publicInterface('fkjHistoryRecordUrl','/history',data,'post','历史访问记录请求失败')
-      let array = res.data.forEach((item,index)=>{
-        item.info1 = {
-          'carno': item.carno,
-          'certName': item.certName,
-          'certPhone': item.certPhone,
-          'company': item.company,
-          'reason': item.reason,
-          'isSel': false
-        }
-        item.info2 = {
-          "visiteeBm": item.visiteeBm,
-				  "visiteeCompany": item.visiteeCompany,
-				  "visiteeFloor": item.visiteeFloor,
-				  "visiteePhone": item.visiteePhone,
-				  "visiteeRoom": item.visiteeRoom,
-				  "visiteeXm": item.visiteeXm,
-          'isSel': false
-        }
-      })
-      console.log()
-      this.setData({
-        isHistory: array
-        // 'pagination.current': newCurrent,
-        // 'pagination.pageNum': resData.pages,
-        // 'pagination.total': resData.total,
-        // tableList: resData.list,
-      })
-
+      let res = await app.data.publicInterface('fkjHistoryRecordUrl','/history',params,'post','历史访问记录请求失败')
+      if(res.data.total > 0 ){
+        let array = res.data.list.map((item,index)=>{
+          return{
+            info1:{
+              'carnum': item.carno,
+              'visitorName': item.certName,
+              'visitorPhone': item.certPhone,
+              'visitorUnit': item.company,
+              'causeMatterName': item.reason,
+              'isSel': false
+            },
+            info2:{
+              "unitName": item.visiteeBm,
+              "company": item.visiteeCompany,
+              "floor": item.visiteeFloor,
+              "phone": item.visiteePhone,
+              "room": item.visiteeRoom,
+              "name": item.visiteeXm,
+              'isSel': false
+            }
+          }
+        })
+        this.setData({
+          historyPagNum: historyPagNum ? historyPagNum : 1,
+          historyPageSize: res.data.pages,
+          historyList: array,
+        })
+      }else{
+        this.setData({
+          isHistory: false
+        })
+      }
     } catch (error) {
     } catch (error) {
       console.log(error);
       console.log(error);
     }
     }
+  },
+   // 上一页
+   historyPreviousFun() {
+    console.log(this.data)
+    const pageNum = this.data.historyPagNum - 1
+    if (pageNum <= 0) {
+      return
+    }
+    this.setData({
+      intervieweeForm:{}
+    })
+    this.getHistory(pageNum)
+  },
+  // 下一页
+  historyNextFun() {
+    const pageNum = this.data.historyPagNum + 1
+    if (pageNum > this.data.historyPageSize) {
+      return
+    }
+    this.setData({
+      intervieweeForm:{}
+    })
+    this.getHistory(pageNum)
   },
   },
   async getTable(e) {
   async getTable(e) {
     try {
     try {
@@ -332,11 +328,11 @@ Page({
   },
   },
   // 选中受访人信息数据
   // 选中受访人信息数据
   selInfo: function (e) {
   selInfo: function (e) {
-    const id = e.currentTarget.id; // 获取被点击项的id
-    const items = this.data.historyList.map(item => {
+    const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
+    const items = this.data.historyList.map((item,index) => {
       item.info1.isSel = false
       item.info1.isSel = false
       item.info2.isSel = false
       item.info2.isSel = false
-      if (item.id == id) {
+      if (index == idx) {
         this.setData({
         this.setData({
           remainingInfo: {
           remainingInfo: {
             ...this.data.remainingInfo,
             ...this.data.remainingInfo,
@@ -366,9 +362,9 @@ Page({
   },
   },
   // 选择受访人 单独控制
   // 选择受访人 单独控制
   selInfo2: function (e){
   selInfo2: function (e){
-    const id = e.currentTarget.id; // 获取被点击项的id
-    const items = this.data.historyList.map(item => {
-      if (item.id == id) {
+    const idx = e.currentTarget.dataset.index; // 获取被点击项的下标
+    const items = this.data.historyList.map((item,index) => {
+      if (index == idx) {
         if(!item.info2.isSel){
         if(!item.info2.isSel){
           this.setData({
           this.setData({
             intervieweeForm:{
             intervieweeForm:{
@@ -388,6 +384,7 @@ Page({
           }
           }
          }; 
          }; 
       }
       }
+      // console.log(item)
       return item; // 其他项保持不变
       return item; // 其他项保持不变
     });
     });
     this.setData({ 
     this.setData({ 
@@ -527,7 +524,6 @@ Page({
       'remainingInfo.causeMatterName': item,
       'remainingInfo.causeMatterName': item,
       isShowCauseMatter: false
       isShowCauseMatter: false
     })
     })
-
   },
   },
 
 
   // 是否显示搜索项
   // 是否显示搜索项
@@ -691,24 +687,18 @@ Page({
   // 确定
   // 确定
   async sure() {
   async sure() {
     if(this.data.isHistory){
     if(this.data.isHistory){
-      if(!this.data.intervieweeForm.name) this.backEnter()
-      return
+      if(!this.data.intervieweeForm.name) {
+        this.backEnter()
+        return
+      }
     }
     }
-
-    return
     let {
     let {
       remainingInfo,
       remainingInfo,
       intervieweeForm,
       intervieweeForm,
       carnum
       carnum
     } = this.data
     } = this.data
-    console.log(
-      'remainingInfo',
-      remainingInfo)
-    console.log(
-      'intervieweeForm',
-      intervieweeForm)
     let form = Object.assign({}, remainingInfo, intervieweeForm);
     let form = Object.assign({}, remainingInfo, intervieweeForm);
-    console.log(form)
+    console.log('form --->', form) 
     form.carnum = carnum
     form.carnum = carnum
     form.visitingTime = getDate()
     form.visitingTime = getDate()
     app.data.visitoMsgData = form
     app.data.visitoMsgData = form
@@ -743,7 +733,7 @@ Page({
         time: form.visitingTime,
         time: form.visitingTime,
       }
       }
       console.log('data', data)*/
       console.log('data', data)*/
-      console.log(JSON.stringify(areaRes))
+      console.log('areaRes ----> ', JSON.stringify(areaRes))
       let newPushData = {
       let newPushData = {
         "appType": "HHVisit",
         "appType": "HHVisit",
         "recordid": 0, // 没有
         "recordid": 0, // 没有
@@ -785,7 +775,7 @@ Page({
         "endTime": null, // 有效期结束时间
         "endTime": null, // 有效期结束时间
         "event": 1 // 事件类型: 1 登记 2 签离
         "event": 1 // 事件类型: 1 登记 2 签离
       }
       }
-      console.log(JSON.stringify(newPushData))
+      console.log('newPushData ----> ',JSON.stringify(newPushData))
       let url = app.globalData.snDisposition.transitPushUrl
       let url = app.globalData.snDisposition.transitPushUrl
       try {
       try {
         // 进出记录推送
         // 进出记录推送