Commit 9455e2f4 by fengzhaoyu

访客手动输入预约单 完善

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