278 lines
6.8 KiB
JavaScript
Raw Normal View History

2024-02-29 17:16:05 +08:00
let app = getApp();
2024-03-09 15:49:42 +08:00
import Notify from '@vant/weapp/notify/notify';
2024-02-29 17:16:05 +08:00
import {
2024-03-09 18:24:04 +08:00
selfFormatTimeYMDHMS
} from "../../../../utils/util.js"
2024-03-01 15:07:02 +08:00
2024-02-26 09:06:34 +08:00
Page({
2024-03-01 15:07:02 +08:00
/**
* 页面的初始数据
*/
data: {
2024-03-09 15:49:42 +08:00
IMG_NAME: app.IMG_NAME,
2024-03-09 18:24:04 +08:00
userDetail: {},
idcardTypeShow: false,
idcardTypeList: [{
name: '居民身份证',
}, ],
visitTimeShow: false, // 到访时间show
visitTimeDate: new Date().getTime(), // 到访时间-当前
visitTimeMinDate: new Date().getTime(), // 到访时间-最小
leaveTimeShow: false, // 离开时间show
leaveTimeDate: new Date().getTime(), // 离开时间-当前
fileList: [], // 上传文件
2024-03-09 15:49:42 +08:00
detail: {
customerId: null, //企业id
customerName: null, //企业名称
userId: null, // 被访人id
username: null, //被访人姓名
mobile: null, //被访人手机号
intervieweeId: null, // 访客id
name: null, // 访客姓名
phone: null, // 访客手机号
2024-03-09 18:24:04 +08:00
cardType: '居民身份证', // 证件类型
cardNo: null, // 证件号
2024-03-09 15:49:42 +08:00
visitTime: null, // 到访时间
leaveTime: null, // 离开时间
visitContent: null, // 来访事由
photo: null, // 头像
}
2024-03-01 15:07:02 +08:00
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
2024-03-09 14:24:42 +08:00
console.log('onLoad', options)
let _this = this;
2024-03-09 18:24:04 +08:00
let userDetail = wx.getStorageSync('user')
//
let detail = _this.data.detail;
detail.intervieweeId = userDetail.id // 访客id
detail.name = userDetail.username // 访客姓名
detail.phone = userDetail.mobile // 访客手机号
2024-03-09 14:24:42 +08:00
_this.setData({
2024-03-09 18:24:04 +08:00
...options,
userDetail,
detail
2024-03-09 14:24:42 +08:00
})
2024-03-01 15:07:02 +08:00
// 页面初始化 options为页面跳转所带来的参数
wx.setNavigationBarTitle({
2024-03-08 14:11:33 +08:00
title: options.title
2024-03-01 15:07:02 +08:00
})
2024-03-09 14:24:42 +08:00
},
// 跳转-索引栏(单位、人员)
jumpIndexBar(e) {
console.log('jumpIndexBar', e);
2024-03-09 15:49:42 +08:00
let _this = this;
2024-03-09 14:24:42 +08:00
let title = e.currentTarget.dataset.title
2024-03-09 15:49:42 +08:00
// 校验是否选择“被访单位” 后 ,再选择被访人信息
2024-03-09 18:24:04 +08:00
if (title == '人员' && !_this.data.detail.customerId) {
2024-03-09 15:49:42 +08:00
// 危险通知
Notify({
type: 'danger',
message: '请先选择被访单位!'
});
2024-03-09 18:24:04 +08:00
return;
2024-03-09 15:49:42 +08:00
}
// url 参数
let param = '?title=' + title;
if (title == '人员') {
param = param + '&id=' + _this.data.detail.customerId;
}
2024-03-09 14:24:42 +08:00
wx.navigateTo({
2024-03-09 15:49:42 +08:00
url: '/pages/meeting/visitorIinvitation/indexBar/indexBar' + param,
2024-03-01 15:07:02 +08:00
})
},
2024-03-09 18:24:04 +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
})
},
// 图片-上传前校验
beforeRead(event) {
const {
file,
callback
} = event.detail;
callback(file.type === 'image');
},
// 图片-上传后
afterRead(event) {
let _this = this;
const {
file
} = event.detail;
// 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
wx.uploadFile({
url: app.DOMAIN_NAME + '/api/dfs/upload',
filePath: file.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.DOMAIN_NAME + fileData.fileName,
name: fileData.fileName,
deletable: true,
})
_this.setData({
fileList
})
},
});
},
// 删除图片
deleteImg(event) {
console.log('deleteImg', event);
let _this = this;
let fileList = _this.data.fileList;
fileList.splice(event.detail.index, 1);
_this.setData({
fileList
})
},
2024-03-01 15:07:02 +08:00
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面初次渲染完成
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onReady: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面显示
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onShow: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面隐藏
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onHide: function () {
2024-03-01 15:07:02 +08:00
},
/**
2024-03-09 14:24:42 +08:00
* 生命周期函数--监听页面卸载
2024-03-01 15:07:02 +08:00
*/
2024-03-09 14:24:42 +08:00
onUnload: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
2024-03-01 15:07:02 +08:00
},
2024-03-09 14:24:42 +08:00
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
2024-03-01 15:07:02 +08:00
}
2024-02-26 09:06:34 +08:00
})