2024-07-26 17:28:44 +08:00
|
|
|
let app = getApp();
|
|
|
|
|
|
|
|
import Notify from '@vant/weapp/notify/notify';
|
|
|
|
|
|
|
|
import {
|
|
|
|
selfFormatTimeYMDHMS
|
|
|
|
} from "../../../utils/util.js"
|
|
|
|
|
|
|
|
import {
|
|
|
|
visitorPersonRq,
|
|
|
|
selectVisitorRecordByIdRq,
|
|
|
|
updateVisitorPersonStatusRq
|
|
|
|
} from "../../../api/meeting/visitorIinvitation.js"
|
|
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面的初始数据
|
|
|
|
*/
|
|
|
|
data: {
|
|
|
|
IMG_NAME: app.IMG_NAME,
|
|
|
|
id: null,
|
|
|
|
title: null,
|
|
|
|
userDetail: {},
|
2024-08-06 17:32:38 +08:00
|
|
|
recorderManager: null, // 录音对象
|
|
|
|
voiceObj: {}, // 录音文件对象
|
|
|
|
innerAudioContext: null, // 音频对象
|
|
|
|
innerAudioContextIsPlay: false, // 音频对象-是否播放
|
2024-07-26 17:28:44 +08:00
|
|
|
idcardTypeShow: false,
|
|
|
|
idcardTypeList: [{
|
|
|
|
name: '居民身份证',
|
|
|
|
}, ],
|
|
|
|
visitTimeShow: false, // 到访时间show
|
|
|
|
visitTimeDate: new Date().getTime(), // 到访时间-当前
|
|
|
|
visitTimeMinDate: new Date().getTime(), // 到访时间-最小
|
|
|
|
leaveTimeShow: false, // 离开时间show
|
|
|
|
leaveTimeDate: new Date().getTime(), // 离开时间-当前
|
|
|
|
fileList: [], // 上传文件
|
|
|
|
detail: {
|
|
|
|
customerId: null, //企业id
|
|
|
|
customerName: null, //企业名称
|
|
|
|
userId: null, // 被访人id
|
|
|
|
userName: null, //被访人姓名
|
|
|
|
userMobile: null, //被访人手机号
|
|
|
|
intervieweeId: null, // 访客id
|
|
|
|
name: null, // 访客姓名
|
|
|
|
phone: null, // 访客手机号
|
|
|
|
cardType: '居民身份证', // 证件类型
|
|
|
|
cardNo: null, // 证件号
|
|
|
|
visitTime: null, // 到访时间
|
|
|
|
leaveTime: null, // 离开时间
|
|
|
|
visitContent: null, // 来访事由
|
|
|
|
photo: null, // 头像-相对路径
|
|
|
|
url: null, // 人脸设备图片-全路径
|
2024-08-06 17:32:38 +08:00
|
|
|
voiceUrl: null, // 语音
|
2024-07-26 17:28:44 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面加载
|
|
|
|
*/
|
|
|
|
onLoad(options) {
|
|
|
|
console.log('onLoad', options)
|
|
|
|
let _this = this;
|
|
|
|
let userDetail = wx.getStorageSync('user')
|
|
|
|
//
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
_this.setData({
|
|
|
|
...options,
|
|
|
|
userDetail,
|
|
|
|
detail
|
|
|
|
})
|
|
|
|
// 页面初始化 options为页面跳转所带来的参数
|
|
|
|
wx.setNavigationBarTitle({
|
|
|
|
title: options.title
|
|
|
|
})
|
|
|
|
|
2024-08-06 17:32:38 +08:00
|
|
|
// 初始化录音
|
|
|
|
_this.initRecording()
|
2024-07-26 17:28:44 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
// 显示-身份证类型
|
|
|
|
showIdcardType() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
idcardTypeShow: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 选择-身份证类型
|
|
|
|
selectIdcardType(e) {
|
|
|
|
console.log('selectIdcardType', e);
|
|
|
|
let _this = this;
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
detail.cardType = e.detail.name;
|
|
|
|
_this.setData({
|
|
|
|
idcardTypeShow: false,
|
|
|
|
detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 关闭-身份证类型
|
|
|
|
closeIdcardType() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
idcardTypeShow: false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 显示-到访时间
|
|
|
|
showVisitTime() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
visitTimeShow: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 关闭-到访时间
|
|
|
|
closeVisitTime() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
visitTimeShow: false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 确认-到访时间
|
|
|
|
confirmVisitTime(e) {
|
|
|
|
console.log('confirmVisitTime', e);
|
|
|
|
let _this = this;
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
detail.visitTime = selfFormatTimeYMDHMS(e.detail);
|
|
|
|
_this.setData({
|
|
|
|
visitTimeShow: false,
|
|
|
|
visitTimeDate: e.detail,
|
|
|
|
detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 显示-离开时间
|
|
|
|
showLeaveTime() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
leaveTimeShow: true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 关闭-离开时间
|
|
|
|
closeLeaveTime() {
|
|
|
|
let _this = this;
|
|
|
|
_this.setData({
|
|
|
|
leaveTimeShow: false
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 确认-离开时间
|
|
|
|
confirmLeaveTime(e) {
|
|
|
|
console.log('confirmLeaveTime111', e);
|
|
|
|
let _this = this;
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
detail.leaveTime = selfFormatTimeYMDHMS(e.detail);
|
|
|
|
_this.setData({
|
|
|
|
leaveTimeShow: false,
|
|
|
|
leaveTimeDate: e.detail,
|
|
|
|
detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2024-08-06 17:32:38 +08:00
|
|
|
initRecording() {
|
|
|
|
let _this = this
|
|
|
|
let recorderManager = wx.getRecorderManager()
|
|
|
|
recorderManager.onStart(() => {
|
|
|
|
console.log('recorder start')
|
|
|
|
})
|
|
|
|
recorderManager.onStop((res) => {
|
|
|
|
console.log('recorder stop', res)
|
|
|
|
_this.setData({
|
|
|
|
voiceObj: res,
|
|
|
|
innerAudioContext: null, // 音频对象
|
|
|
|
innerAudioContextIsPlay: false, // 音频对象-是否播放
|
|
|
|
})
|
|
|
|
})
|
|
|
|
_this.setData({
|
|
|
|
recorderManager
|
|
|
|
})
|
|
|
|
},
|
|
|
|
// 开始录音
|
|
|
|
startRecording() {
|
|
|
|
this.data.recorderManager.start({
|
|
|
|
duration: 60000,
|
|
|
|
sampleRate: 16000, //采样率,有效值 8000/16000/44100
|
|
|
|
numberOfChannels: 1, //录音通道数,有效值 1/2
|
|
|
|
encodeBitRate: 96000, //编码码率
|
|
|
|
format: 'mp3', //音频格式,有效值 aac/mp3
|
|
|
|
frameSize: 50, //指定帧大小
|
|
|
|
// audioSource: 'auto' //指定录音的音频输入源,可通过 wx.getAvailableAudioSources() 获取
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 停止录音
|
|
|
|
stopRecording() {
|
|
|
|
this.data.recorderManager.stop()
|
|
|
|
},
|
|
|
|
|
|
|
|
// 播放语音
|
|
|
|
startAudio() {
|
|
|
|
console.log('startAudio');
|
|
|
|
let _this = this
|
|
|
|
// 获取innerAudioContext实例
|
|
|
|
let innerAudioContext = _this.data.innerAudioContext
|
|
|
|
let innerAudioContextIsPlay = _this.data.innerAudioContextIsPlay
|
|
|
|
if (!innerAudioContext) {
|
|
|
|
// 全局设置播放声音
|
|
|
|
wx.setInnerAudioOption({ obeyMuteSwitch: false });
|
|
|
|
innerAudioContext = wx.createInnerAudioContext()
|
|
|
|
// 设置音频文件的路径
|
|
|
|
innerAudioContext.src = _this.data.voiceObj.tempFilePath
|
|
|
|
innerAudioContextIsPlay = false
|
|
|
|
innerAudioContext.onEnded(() => {
|
|
|
|
_this.setData({
|
|
|
|
innerAudioContextIsPlay: false
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if (innerAudioContextIsPlay) { // 播放中
|
|
|
|
innerAudioContext.stop()
|
|
|
|
innerAudioContextIsPlay = false
|
|
|
|
} else { // 未播放
|
|
|
|
innerAudioContext.play()
|
|
|
|
innerAudioContextIsPlay = true
|
|
|
|
}
|
|
|
|
//
|
|
|
|
_this.setData({
|
|
|
|
innerAudioContext,
|
|
|
|
innerAudioContextIsPlay
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 停止语音
|
|
|
|
stopAudio() {
|
|
|
|
_this.data.innerAudioContext.stop()
|
|
|
|
},
|
2024-07-26 17:28:44 +08:00
|
|
|
|
|
|
|
// 图片-上传前校验
|
|
|
|
beforeRead(event) {
|
2024-08-06 17:32:38 +08:00
|
|
|
// const {
|
|
|
|
// file,
|
|
|
|
// callback
|
|
|
|
// } = event.detail;
|
|
|
|
// callback(file.type === 'image');
|
2024-07-26 17:28:44 +08:00
|
|
|
},
|
|
|
|
|
2024-08-06 17:32:38 +08:00
|
|
|
// 文件-上传后
|
|
|
|
fileAfterRead(event) {
|
2024-07-26 17:28:44 +08:00
|
|
|
let _this = this;
|
2024-08-06 17:32:38 +08:00
|
|
|
console.log('fileAfterRead' ,event);
|
2024-07-26 17:28:44 +08:00
|
|
|
const {
|
|
|
|
file
|
|
|
|
} = event.detail;
|
|
|
|
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
2024-08-06 17:32:38 +08:00
|
|
|
for (let i = 0; i < file.length; i++) {
|
|
|
|
let url = file[i].url;
|
|
|
|
wx.uploadFile({
|
|
|
|
url: app.DOMAIN_NAME + '/api/dfs/upload',
|
|
|
|
filePath: url,
|
|
|
|
name: 'file',
|
|
|
|
formData: {},
|
|
|
|
success(res) {
|
|
|
|
console.log('upload file ', res);
|
|
|
|
let fileData = JSON.parse(res.data)
|
|
|
|
// 上传完成需要更新 fileList
|
|
|
|
let fileList = _this.data.fileList;
|
|
|
|
fileList.push({
|
|
|
|
relativeUrl: fileData.fileName,
|
|
|
|
url: app.IMG_NAME + fileData.fileName,
|
|
|
|
name: fileData.fileName,
|
|
|
|
deletable: true,
|
|
|
|
})
|
|
|
|
_this.setData({
|
|
|
|
fileList
|
|
|
|
})
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2024-07-26 17:28:44 +08:00
|
|
|
},
|
|
|
|
|
2024-08-06 17:32:38 +08:00
|
|
|
|
2024-07-26 17:28:44 +08:00
|
|
|
// 删除图片
|
|
|
|
deleteImg(event) {
|
|
|
|
console.log('deleteImg', event);
|
|
|
|
let _this = this;
|
|
|
|
let fileList = _this.data.fileList;
|
|
|
|
fileList.splice(event.detail.index, 1);
|
|
|
|
_this.setData({
|
|
|
|
fileList
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// input输入内容监听
|
|
|
|
fieldInput(e) {
|
|
|
|
console.log('fieldInput', e);
|
|
|
|
let _this = this;
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
detail[e.currentTarget.dataset.name] = e.detail
|
|
|
|
_this.setData({
|
|
|
|
detail
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
// 提交数据
|
|
|
|
submitData() {
|
|
|
|
let _this = this;
|
|
|
|
// 上传文件列表
|
|
|
|
let fileList = _this.data.fileList;
|
|
|
|
// 数据
|
|
|
|
let detail = _this.data.detail;
|
|
|
|
//
|
|
|
|
// 校验数据
|
|
|
|
//
|
|
|
|
// 被访单位
|
|
|
|
if (!detail.customerId) {
|
|
|
|
_this.showErrMsg('请选择被访单位!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 被访人姓名
|
|
|
|
if (!detail.userName) {
|
|
|
|
_this.showErrMsg('请输入被访人姓名!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 被访人电话
|
|
|
|
if (!detail.userMobile) {
|
|
|
|
_this.showErrMsg('请输入被访人电话!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 访客姓名
|
|
|
|
if (!detail.name) {
|
|
|
|
_this.showErrMsg('请填写访客姓名!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 访客手机号
|
|
|
|
if (!detail.phone) {
|
|
|
|
_this.showErrMsg('请填写访客手机号!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 证件号
|
|
|
|
if (!detail.cardNo) {
|
|
|
|
_this.showErrMsg('请填写证件号!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 到访时间
|
|
|
|
if (!detail.visitTime) {
|
|
|
|
_this.showErrMsg('请选择到访时间!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 离开时间
|
|
|
|
if (!detail.leaveTime) {
|
|
|
|
_this.showErrMsg('请选择离开时间!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 来访事由
|
|
|
|
if (!detail.visitContent) {
|
|
|
|
_this.showErrMsg('请填写来访事由!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// 图片上传
|
|
|
|
if (fileList && fileList.length > 0) {
|
|
|
|
detail.photo = fileList[0].relativeUrl // 头像-相对路径
|
|
|
|
detail.url = fileList[0].url // 人脸设备图片-全路径
|
|
|
|
} else {
|
|
|
|
_this.showErrMsg('请上传照片!')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// 添加数据
|
|
|
|
visitorPersonRq(detail).then(res => {
|
|
|
|
console.log('visitorPersonRq', res);
|
|
|
|
// 刷新上个页面参数
|
|
|
|
let pages = getCurrentPages(); //获取page
|
|
|
|
let prevPage = pages[pages.length - 2]; //上一个页面(父页面)
|
|
|
|
prevPage.setData({
|
|
|
|
changeData: true
|
|
|
|
})
|
|
|
|
//
|
|
|
|
if (res.code == 0) {
|
|
|
|
wx.navigateBack()
|
|
|
|
} else {
|
|
|
|
_this.showErrMsg(res.msg)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 显示错误消息
|
|
|
|
showErrMsg(msg) {
|
|
|
|
Notify({
|
|
|
|
type: 'danger',
|
|
|
|
message: msg
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
|
*/
|
|
|
|
onReady: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面显示
|
|
|
|
*/
|
|
|
|
onShow: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面隐藏
|
|
|
|
*/
|
|
|
|
onHide: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 生命周期函数--监听页面卸载
|
|
|
|
*/
|
|
|
|
onUnload: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
|
*/
|
|
|
|
onPullDownRefresh: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
|
*/
|
|
|
|
onReachBottom: function () {
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 用户点击右上角分享
|
|
|
|
*/
|
|
|
|
onShareAppMessage: function () {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|