Commit 9455e2f4 by fengzhaoyu

访客手动输入预约单 完善

parent 6e798bc0
...@@ -17,20 +17,15 @@ const $http = (url, data, type, loadingType) => { ...@@ -17,20 +17,15 @@ const $http = (url, data, type, loadingType) => {
// 时间戳未过期 // 时间戳未过期
if(!!hasToken && ((new Date()).getTime() - hasToken.loginTime)< (hasToken.expires_in-300) * 1000){ if(!!hasToken && ((new Date()).getTime() - hasToken.loginTime)< (hasToken.expires_in-300) * 1000){
data.orgId = dd.corpId; data.orgId = dd.corpId;
let sendData = '';
for(let key in data){
sendData = `${sendData}${key}=${data[key]}&`
}
sendData = sendData.substring(0, sendData.length - 1);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
dd.httpRequest({ dd.httpRequest({
headers: { headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}` "Authorization": `Bearer ${token}`
}, },
url: `${app.globalData.globalUrl}${url}?${sendData}`, url: `${app.globalData.globalUrl}${url}`,
method: type, method: type,
dataType: 'json', dataType: 'json',
data:data,
success: function(res) { success: function(res) {
if( res.data.code == 0 || res.data.resultCode === 0 ) { if( res.data.code == 0 || res.data.resultCode === 0 ) {
return resolve(res.data.data) return resolve(res.data.data)
...@@ -83,7 +78,6 @@ const $http = (url, data, type, loadingType) => { ...@@ -83,7 +78,6 @@ const $http = (url, data, type, loadingType) => {
}) })
}, },
fail: function(err) { fail: function(err) {
debugger
dd.hideLoading() dd.hideLoading()
if(err.status == 426) { if(err.status == 426) {
dd.removeStorageSync({key: 'token'}) dd.removeStorageSync({key: 'token'})
...@@ -92,7 +86,6 @@ const $http = (url, data, type, loadingType) => { ...@@ -92,7 +86,6 @@ const $http = (url, data, type, loadingType) => {
}) })
} }
else { else {
debugger
dd.alert({ dd.alert({
content:'请检查网络并下拉重试', content:'请检查网络并下拉重试',
buttonText: '确定' buttonText: '确定'
......
...@@ -19,8 +19,7 @@ create.Page({ ...@@ -19,8 +19,7 @@ create.Page({
const _that = this const _that = this
dd.chooseExternalUsers({ dd.chooseExternalUsers({
multiple: false, //是否多选 true多选,false单选,默认是单选 multiple: false, //是否多选 true多选,false单选,默认是单选
limitTips: "超出了", limitTips: "请单选",
maxUsers: 1, //默认不限制
success: function(res) { success: function(res) {
if (_that.data.query == 0) { if (_that.data.query == 0) {
_that.store.data.visitorName = res[0].name _that.store.data.visitorName = res[0].name
...@@ -28,7 +27,7 @@ create.Page({ ...@@ -28,7 +27,7 @@ create.Page({
_that.update() _that.update()
} }
else { else {
_that.store.data.visitorPeer[_that.data.query -1].name = res[0].name _that.store.data.visitorPeer[_that.data.query - 1].name = res[0].name
_that.store.data.selectVisitors = false _that.store.data.selectVisitors = false
_that.update() _that.update()
} }
...@@ -38,6 +37,10 @@ create.Page({ ...@@ -38,6 +37,10 @@ create.Page({
}) })
}, },
fail: function(err) { fail: function(err) {
_that.store.data.selectVisitors = false
dd.navigateBack({
delta: 1
})
} }
}); });
......
...@@ -6,9 +6,11 @@ create.Page({ ...@@ -6,9 +6,11 @@ create.Page({
store: exampleStore, store: exampleStore,
useAll: true, useAll: true,
data: { data: {
query:''
}, },
onLoad(query) { onLoad(query) {
console.log(query.visitorId, 'query') console.log(query.index, 'query')
this.setData({ query: query.index })
dd.setNavigationBar({ dd.setNavigationBar({
title: '手机通讯录', title: '手机通讯录',
}); });
...@@ -34,24 +36,13 @@ create.Page({ ...@@ -34,24 +36,13 @@ create.Page({
}) })
}, },
fail: function(err) { fail: function(err) {
_that.store.data.selectVisitors = false
_that.update()
dd.navigateBack({
delta: 1
})
} }
}); });
// dd.chooseExternalUsers({
// multiple: false, //是否多选 true多选,false单选,默认是单选
// limitTips: "超出了",
// maxUsers: 1, //默认不限制
// success: function(res) {
// _that.store.data.visitorName = res[0].name
// _that.store.data.selectVisitors = false
// _that.update()
// dd.navigateBack({
// delta: 1
// })
// },
// fail: function(err) {
// }
// });
}, },
onShow() { onShow() {
......
...@@ -285,13 +285,12 @@ ...@@ -285,13 +285,12 @@
background: rgba(0, 0, 0, 0.2); background: rgba(0, 0, 0, 0.2);
position: fixed; position: fixed;
top: 0; top: 0;
z-index: 10001
} }
.selectVisitor { .selectVisitor {
z-index: 9999;
position: fixed; position: fixed;
left: 32rpx; left: 32rpx;
;
right: 32rpx; right: 32rpx;
bottom: 140rpx; bottom: 140rpx;
overflow: hidden; overflow: hidden;
...@@ -319,11 +318,11 @@ ...@@ -319,11 +318,11 @@
} }
.selectCancel { .selectCancel {
z-index: 9999;
width: 686rpx; width: 686rpx;
position: fixed; position: fixed;
bottom: 20rpx; bottom: 20rpx;
left: 32rpx; left: 32rpx;
;
right: 32rpx; right: 32rpx;
height: 100rpx; height: 100rpx;
text-align: center; text-align: center;
......
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
访客姓名 访客姓名
</view> </view>
<view class="visitorInput"> <view class="visitorInput">
<input placeholder="请输入或选择" value="{{visitorName}}" onInput='changeMainVisitor' data-index='{{0}}' /> <input placeholder="请输入或选择" value="{{visitorName}}" onInput='visitorInput' data-index='{{0}}' data-type='visitorName'/>
</view> </view>
<text class="icontongxunlu iconfont" onTap="selectVisitors" data-index='{{0}}'></text> <text class="icontongxunlu iconfont" onTap="selectVisitors" data-index='{{0}}' ></text>
</view> </view>
<view class="visitorName"> <view class="visitorName">
<view class="visitorNameText"> <view class="visitorNameText">
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
访客手机 访客手机
</view> </view>
<view class=" visitorInput visitorPhoneInput "> <view class=" visitorInput visitorPhoneInput ">
<input placeholder="请输入" /> <input placeholder="请输入" data-type='visitorPhone' onInput='visitorInput'/>
</view> </view>
</view> </view>
<view class="visitorName"> <view class="visitorName">
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
访客单位 访客单位
</view> </view>
<view class="visitorInput visitorPhoneInput"> <view class="visitorInput visitorPhoneInput">
<input placeholder="请输入" /> <input placeholder="请输入" data-type='visitorCompany' onInput='visitorInput' />
</view> </view>
</view> </view>
</view> </view>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
开始 开始
</view> </view>
<view class="startTimeBottop" onTap="selectStartTime"> <view class="startTimeBottop" onTap="selectStartTime">
<view>{{startTime}}</view> <view>{{startTimeYear}}</view>
<view class="minute">{{startTimeHour}}</view> <view class="minute">{{startTimeHour}}</view>
</view> </view>
</view> </view>
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
结束 结束
</view> </view>
<view class="startTimeBottop" onTap="selectEndTime"> <view class="startTimeBottop" onTap="selectEndTime">
<view>{{endTime}}</view> <view>{{endTimeYear}}</view>
<view class="minute">{{endTimeHour}}</view> <view class="minute">{{endTimeHour}}</view>
</view> </view>
</view> </view>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</picker> </picker>
<view class="line"></view> <view class="line"></view>
<view class="inputPurpose" a:if='{{isInput}}'> <view class="inputPurpose" a:if='{{isInput}}'>
<input placeholder="请输入来访目的" /> <input placeholder="请输入来访目的" data-type='visitorPurpose' onInput='visitorInput' />
</view> </view>
<picker value="{{0}}" range="{{arriveAddress}}" onChange='selectAddress'> <picker value="{{0}}" range="{{arriveAddress}}" onChange='selectAddress'>
<view> <view>
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
访客姓名 访客姓名
</view> </view>
<view class="visitorInput"> <view class="visitorInput">
<input placeholder="请输入或选择" value="{{item.name}}" /> <input placeholder="请输入或选择" value="{{item.name}}" data-type='visitorPeerName' data-index='{{index + 1}}' onInput='visitorInput' />
</view> </view>
<text class="icontongxunlu iconfont" data-index='{{index + 1}}' onTap="selectVisitors"></text> <text class="icontongxunlu iconfont" data-index='{{index + 1}}' onTap="selectVisitors"></text>
</view> </view>
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
访客手机 访客手机
</view> </view>
<view class=" visitorInput visitorPhoneInput "> <view class=" visitorInput visitorPhoneInput ">
<input placeholder="请输入" /> <input placeholder="请输入" data-type='visitorPeerPhone' data-index='{{index + 1}}' onInput='visitorInput' value="{{item.phone}}" />
</view> </view>
</view> </view>
</view> </view>
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
<view class="iconfont iconjia moreJia" onTap="copyPerson"> <view class="iconfont iconjia moreJia" onTap="copyPerson">
</view> </view>
</view> </view>
<view class="ccPeople" > <view class="ccPeople">
<view a:for="{{copyPerson}}" a:for-index="index" a:for-item="item"></view> <view a:for="{{copyPerson}}" a:for-index="index" a:for-item="item"></view>
</view> </view>
<view class="visitorName"> <view class="visitorName">
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
备注 备注
</view> </view>
<view class="visitorInput"> <view class="visitorInput">
<input placeholder="请输入" /> <input placeholder="请输入" data-type='visitorNode' onInput='visitorInput'/>
</view> </view>
</view> </view>
<view class="isHidden"> <view class="isHidden">
...@@ -136,7 +136,7 @@ ...@@ -136,7 +136,7 @@
<view class="confirmAppointment"> <view class="confirmAppointment">
<view class="confirmAppointmentButton" onTap="confirmAppointment">确认预约</view> <view class="confirmAppointmentButton" onTap="confirmAppointment">确认预约</view>
</view> </view>
<view class="selectVisitors" a:if='{{selectVisitors}}'> <view class="selectVisitors" a:if='{{selectVisitors}}' catchtouchstart="selectCancel">
<view class="selectVisitor"> <view class="selectVisitor">
<view class="selectVisitorTitle">选择访客</view> <view class="selectVisitorTitle">选择访客</view>
<view class="select" onTap="historyVistiorsSelect">历史访客</view> <view class="select" onTap="historyVistiorsSelect">历史访客</view>
......
...@@ -6,12 +6,12 @@ create.Page({ ...@@ -6,12 +6,12 @@ create.Page({
store: exampleStore, store: exampleStore,
useAll: true, useAll: true,
data: { data: {
startTime: '00年00月00日', startTimeYear: '', // 开始时间的年月日
startTimeHour: '00:00', startTimeHour: '', // 开始时间的时分
endTime: '00年00月00日', endTimeYear: '', // 结束时间的年月日
endTimeHour: '00:00', endTimeHour: '', // 结束时间的时分
startTimes: '', startTime: '', // 完整的开始时间
endTimes: '', endTime: '', // 完整的结束时间
Purpose: '', Purpose: '',
Purposes: [], Purposes: [],
currentPurpose: '', currentPurpose: '',
...@@ -21,19 +21,68 @@ create.Page({ ...@@ -21,19 +21,68 @@ create.Page({
Companions: [], Companions: [],
copyPerson: [], copyPerson: [],
index: '', index: '',
copyPerson: [] copyPerson: [],
visitorPhone: '',// 主访客的手机号
visitorCompany: '',// 访客的单位
visitorPurpose: '', // 访客手动输入的目的
visitorNode: '' // 访客的备注
}, },
onLoad(query) { onLoad(query) {
console.log('onload事件触发')
dd.setNavigationBar({ dd.setNavigationBar({
title: '预约访客', title: '预约访客'
}); });
let startTimeYear = this.timeToStr(new Date()).yearMonthDate
let startTimeHour = this.timeToStr(new Date()).hourMinute
let endTimeYear = this.timeToStr(new Date()).yearMonthDate
let endTimeHour = this.timeToStr(new Date()).hourMinute
this.setData({
startTimeYear: startTimeYear,
startTimeHour: startTimeHour,
endTimeYear: endTimeYear,
endTimeHour: endTimeHour
})
this.Purpose() this.Purpose()
this.arriveAddress() this.arriveAddress()
}, },
changeMainVisitor(event) { //本页面input输入事件
console.log(event.detail.value) visitorInput(event) {
const _that = this
switch (event.currentTarget.dataset.type) {
case "visitorName":
_that.store.data.visitorName = event.detail.value
_that.update()
break;
case "visitorPhone":
_that.setData({ visitorPhone: event.detail.value })
break;
case "visitorCompany":
_that.setData({ visitorCompany: event.detail.value })
break;
case "visitorPurpose":
_that.setData({ visitorPurpose: event.detail.value })
break;
case "visitorPeerName":
console.log(_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1])
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].name = event.detail.value
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].index = event.currentTarget.dataset.index
_that.update
break;
case "visitorPeerPhone":
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].phone = event.detail.value
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].index = event.currentTarget.dataset.index
_that.update
break;
case "visitorNode":
_that.setData({ visitorNode: event.detail.value })
break;
default:
break;
}
}, },
// 点击通讯录选择访客 控制遮照层是否层 // 点击通讯录选择访客 控制遮照层出
selectVisitors(event) { selectVisitors(event) {
this.setData({ index: event.target.dataset.index }) this.setData({ index: event.target.dataset.index })
this.store.data.selectVisitors = true this.store.data.selectVisitors = true
...@@ -55,10 +104,9 @@ create.Page({ ...@@ -55,10 +104,9 @@ create.Page({
// 添加同行人员 // 添加同行人员
addCompanions() { addCompanions() {
if (this.store.data.visitorPeer.length < 4) { if (this.store.data.visitorPeer.length < 4) {
this.store.data.visitorPeer.push({ name: '', index: '' }) this.store.data.visitorPeer.push({ name: '', index: '', phone: '' })
console.log(this.store.data.visitorPeer) console.log(this.store.data.visitorPeer)
this.update() this.update()
} else { } else {
dd.alert({ dd.alert({
content: '最多可添加四名同行人员', content: '最多可添加四名同行人员',
...@@ -98,15 +146,19 @@ create.Page({ ...@@ -98,15 +146,19 @@ create.Page({
}, },
// 提交预约单 // 提交预约单
confirmAppointment() { confirmAppointment() {
debugger
let data = { let data = {
startTime: this.data.startTimes, startTime: this.data.startTimes,
endTime: this.data.endTimes, endTime: this.data.endTimes,
purpose:this.data.currentPurpose, visitorInfo: `${this.store.data.visitorName}:${this.data.visitorPhone}`,
visitorCompany: this.data.visitorCompany,
purpose: JSON.stringify(this.data.currentPurpose),
visitorPurpose: this.data.visitorPurpose,
visitAddress: this.data.defaultAddress, visitAddress: this.data.defaultAddress,
visitorPeer: JSON.stringify(this.store.data.visitorPeer),
visitorNode: this.data.visitorNode
} }
$http.$http('/admin/visitor/addRecord', data, 'post').then(res => { $http.$http('/admin/visitor/addRecord', data, 'post').then(res => {
console.log(res,66666666666) console.log(res, 66666666666)
}) })
}, },
selectStartTime() { selectStartTime() {
...@@ -164,7 +216,7 @@ create.Page({ ...@@ -164,7 +216,7 @@ create.Page({
this.setData({ arriveAddress: arriveAddress }) this.setData({ arriveAddress: arriveAddress })
}) })
}, },
// 来访的目的
Purpose() { Purpose() {
$http.$http('/admin/visit-purpose/list', {}, 'post').then(res => { $http.$http('/admin/visit-purpose/list', {}, 'post').then(res => {
console.log(res, 'Purpose') console.log(res, 'Purpose')
...@@ -180,9 +232,10 @@ create.Page({ ...@@ -180,9 +232,10 @@ create.Page({
}) })
}, },
timeToStr(time) { timeToStr(time) {
if(/-/.test(time)) {
time = time.replace(/\-/g, "/") time = time.replace(/\-/g, "/")
}
let timeData = new Date(time) let timeData = new Date(time)
console.log('timeData', timeData)
let year = timeData.getFullYear() let year = timeData.getFullYear()
let month = timeData.getMonth() + 1 let month = timeData.getMonth() + 1
let date = timeData.getDate() let date = timeData.getDate()
...@@ -193,9 +246,13 @@ create.Page({ ...@@ -193,9 +246,13 @@ create.Page({
month: month.toString().length > 1 ? month : '0' + month, month: month.toString().length > 1 ? month : '0' + month,
date: date.toString().length > 1 ? date : '0' + date, date: date.toString().length > 1 ? date : '0' + date,
hour: hour.toString().length > 1 ? hour : '0' + hour, hour: hour.toString().length > 1 ? hour : '0' + hour,
minute: minute.toString().length > 1 ? minute : '0' + minute minute: minute.toString().length > 1 ? minute : '0' + minute,
yearMonthDate: `${year}${month.toString().length > 1 ? month : '0' + month}${date.toString().length > 1 ? date : '0' + date}日`,
hourMinute: `${hour.toString().length > 1 ? hour : '0' + hour}${minute.toString().length > 1 ? minute : '0' + minute}分`,
allTime: `${year}${month.toString().length > 1 ? month : '0' + month}${date.toString().length > 1 ? date : '0' + date}${hour.toString().length > 1 ? hour : '0' + hour}:${minute.toString().length > 1 ? minute : '0' + minute}分`
} }
}, },
isInput() { isInput() {
if (this.data.currentPurpose != '其他') { if (this.data.currentPurpose != '其他') {
this.setData({ this.setData({
...@@ -208,7 +265,6 @@ create.Page({ ...@@ -208,7 +265,6 @@ create.Page({
}) })
} }
}, },
test() { test() {
...@@ -218,6 +274,9 @@ create.Page({ ...@@ -218,6 +274,9 @@ create.Page({
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
// 关闭遮照层
this.store.data.selectVisitors = false
this.update()
}, },
onHide() { onHide() {
// 页面隐藏 // 页面隐藏
......
...@@ -2,9 +2,10 @@ class Store { ...@@ -2,9 +2,10 @@ class Store {
data = { data = {
title: '测试', title: '测试',
visitorName: '', visitorName: '', // 主访客的姓名
selectVisitors: false, //控制遮照层是否层出 selectVisitors: false, //控制遮照层是否层出
visitorPeer:[] // 同行访客 visitorPeer:[], // 同行访客
backgroundColor:'#fff', //预约访客页面顶部导航栏的背景色
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment