Commit 6d50c0f3 by fengzhaoyu

修改ios不兼容

parent 1eba81b5
...@@ -54,7 +54,7 @@ Page({ ...@@ -54,7 +54,7 @@ Page({
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
success: function(res) { success: function(res) {
console.log(res,res) console.log(res,'11111111')
if(res.data.resultCode == 0) { if(res.data.resultCode == 0) {
const data = res.data.data const data = res.data.data
dd.setStorageSync({ dd.setStorageSync({
......
...@@ -6,7 +6,7 @@ create.Page({ ...@@ -6,7 +6,7 @@ create.Page({
store: exampleStore, store: exampleStore,
useAll: true, useAll: true,
data: { data: {
query:'' query: ''
}, },
onLoad(query) { onLoad(query) {
console.log(query.index, 'query') console.log(query.index, 'query')
...@@ -17,13 +17,13 @@ create.Page({ ...@@ -17,13 +17,13 @@ create.Page({
}, },
onReady() { onReady() {
const _that = this const _that = this
_that.store.data.selectVisitors = false
_that.update()
dd.choosePhonebook({ dd.choosePhonebook({
multiple: false, //是否多选: true多选 false单选; 默认true multiple: false, //是否多选: true多选 false单选; 默认true
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
_that.store.data.selectVisitors = false
_that.update()
} }
else { else {
_that.store.data.visitorPeer[_that.data.query - 1] = res[0].name _that.store.data.visitorPeer[_that.data.query - 1] = res[0].name
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
访客手机 访客手机
</view> </view>
<view class=" visitorInput visitorPhoneInput "> <view class=" visitorInput visitorPhoneInput ">
<input placeholder="请输入" data-type='visitorPhone' onInput='visitorInput'/> <input placeholder="请输入" pattern="[0-9]*" data-type='visitorPhone' onInput='visitorInput' type="number" value="{{visitorPhone}}"/>
</view> </view>
</view> </view>
<view class="visitorName"> <view class="visitorName">
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
访客手机 访客手机
</view> </view>
<view class=" visitorInput visitorPhoneInput "> <view class=" visitorInput visitorPhoneInput ">
<input placeholder="请输入" data-type='visitorPeerPhone' data-index='{{index + 1}}' onInput='visitorInput' value="{{item.phone}}" /> <input type="number" pattern="[0-9]*" placeholder="请输入" data-type='visitorPeerPhone' data-index='{{index + 1}}' onInput='visitorInput' value="{{item.phone}}" />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -25,7 +25,8 @@ create.Page({ ...@@ -25,7 +25,8 @@ create.Page({
visitorCompany: '',// 访客的单位 visitorCompany: '',// 访客的单位
visitorPurpose: '', // 访客手动输入的目的 visitorPurpose: '', // 访客手动输入的目的
visitorNode: '',// 访客的备注 visitorNode: '',// 访客的备注
isPackUp: false // 是否收起更多消息 isPackUp: false, // 是否收起更多消息
formValidation: false,
}, },
onLoad(query) { onLoad(query) {
this.reSet() this.reSet()
...@@ -75,9 +76,9 @@ create.Page({ ...@@ -75,9 +76,9 @@ create.Page({
startTimeYear: startTimeYear, startTimeYear: startTimeYear,
startTimeHour: startTimeHour, startTimeHour: startTimeHour,
endTimeYear: endTimeYear, endTimeYear: endTimeYear,
endTimeHour: `24:00`, endTimeHour: `23时59分`,
startTime: `${startTime.year}-${startTime.month}-${startTime.date} ${startTime.hour}:${startTime.minute}`, startTime: `${startTime.year}-${startTime.month}-${startTime.date} ${startTime.hour}:${startTime.minute}`,
endTime: `${startTime.year}-${startTime.month}-${startTime.date} 24:00` endTime: `${startTime.year}-${startTime.month}-${startTime.date} 23:59`
}) })
}, },
//本页面input输入事件 //本页面input输入事件
...@@ -101,13 +102,13 @@ create.Page({ ...@@ -101,13 +102,13 @@ create.Page({
console.log(_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1]) 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].name = event.detail.value
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].index = event.currentTarget.dataset.index _that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].index = event.currentTarget.dataset.index
_that.update _that.update
break; break;
case "visitorPeerPhone": case "visitorPeerPhone":
_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1].phone = event.detail.value _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.store.data.visitorPeer[event.currentTarget.dataset.index - 1].index = event.currentTarget.dataset.index
_that.update _that.update
console.log(_that.store.data.visitorPeer[event.currentTarget.dataset.index - 1])
break; break;
case "visitorNode": case "visitorNode":
_that.setData({ visitorNode: event.detail.value }) _that.setData({ visitorNode: event.detail.value })
...@@ -130,11 +131,59 @@ create.Page({ ...@@ -130,11 +131,59 @@ create.Page({
}, },
// 点击外部联系人 // 点击外部联系人
externalContactSelect(event) { externalContactSelect(event) {
dd.navigateTo({ url: `./../externalContact/externalContact?index=${this.data.index}` }); const _that = this
dd.chooseExternalUsers({
title: '外部联人',
multiple: false, //是否多选 true多选,false单选,默认是单选
limitTips: "请单选",
success: function(res) {
if (_that.data.index == 0) {
_that.store.data.visitorName = res[0].name
_that.store.data.selectVisitors = false
_that.update()
}
else {
_that.store.data.visitorPeer[_that.data.index - 1].name = res[0].name
_that.store.data.selectVisitors = false
_that.update()
}
},
fail: function(err) {
_that.store.data.selectVisitors = false
_that.update()
}
});
}, },
// 点击手机通讯录 // 点击手机通讯录
phoneAddressBookSelect() { phoneAddressBookSelect() {
dd.navigateTo({ url: `./../phoneAddressBook/phoneAddressBook?index=${this.data.index}` }); const _that = this
dd.choosePhonebook({
title: '手机通讯录',
multiple: false, //是否多选: true多选 false单选; 默认true
success: function(res) {
console.log(res, 'res')
if (_that.data.index == 0) {
_that.setData({
visitorPhone: res[0].mobile
})
_that.store.data.visitorName = res[0].name
_that.update()
console.log(_that.data.visitorPhone, 'visitorPhone')
console.log(res[0].mobile, 'res[0].mobile')
}
else {
_that.store.data.visitorPeer[_that.data.index - 1] = res[0].name
_that.store.data.selectVisitors = false
_that.update()
}
},
fail: function(err) {
_that.store.data.selectVisitors = false
_that.update()
}
});
}, },
// 添加同行人员 // 添加同行人员
addCompanions() { addCompanions() {
...@@ -212,10 +261,10 @@ create.Page({ ...@@ -212,10 +261,10 @@ create.Page({
// 提交预约单 // 提交预约单
confirmAppointment() { confirmAppointment() {
const _that = this const _that = this
// _that.formValidation() console.log(_that.store.data.visitorPeer, 'number电话号码')
let participator = '' let participator = ''
_that.data.copyPerson.forEach((item, index) => { _that.data.copyPerson.forEach((item, index) => {
participator = participator + item.userId + ',' participator = participator + item.name + ':' + item.userId + ','
}) })
participator = participator.substring(0, participator.length - 1) participator = participator.substring(0, participator.length - 1)
...@@ -232,6 +281,8 @@ create.Page({ ...@@ -232,6 +281,8 @@ create.Page({
else { else {
purpose = this.data.currentPurpose purpose = this.data.currentPurpose
} }
console.log(this.store.data.visitorPeer, 'number111')
this.formValidation()
let data = { let data = {
startTime: this.data.startTime + '' + ':00', startTime: this.data.startTime + '' + ':00',
endTime: this.data.endTime + '' + ':00', endTime: this.data.endTime + '' + ':00',
...@@ -241,26 +292,44 @@ create.Page({ ...@@ -241,26 +292,44 @@ create.Page({
visitorPurpose: this.data.visitorPurpose, visitorPurpose: this.data.visitorPurpose,
visitAddress: this.data.defaultAddress, visitAddress: this.data.defaultAddress,
visitorNode: this.data.visitorNode, visitorNode: this.data.visitorNode,
participator: participator participator: participator,
ddUserId: dd.getStorageSync({ key: 'userId' }).data
} }
if (this.data.formValidation) {
$http.$http('/admin/visitor/addRecord', data, 'post').then(res => { $http.$http('/admin/visitor/addRecord', data, 'post').then(res => {
dd.alert({ dd.alert({
content: '预约成功', content: '预约成功',
buttonText: '确定', buttonText: '确定',
success: () => { success: () => {
dd.redirectTo({ dd.navigateBack({
url: '/pages/visitors/visitors' delta: 1
}) })
}, },
}); });
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
}
}, },
// 表单验证 // 表单验证
formValidation() { formValidation() {
if (this.store.data.visitorName == '' || this.store.data.visitorName.length > 20) { console.log(this.store.data.visitorPeer, 'number1')
dd.alert({ content: '访客姓名不能为空且长度小于20个字符', buttonText: '确定' }) // 手机号码相同
let number = [this.data.visitorPhone]
let name = false
let mobile = false
this.store.data.visitorPeer.forEach((item, index) => {
if (item.name == '' || item.length > 10) {
name = true
}
else if (item.phone == '' || !(/^[1][3,4,5,7,8][0-9]{9}$/).test(this.data.visitorPhone)) {
mobile = true
}
number.push(item.phone)
})
let s = this.isRepeat(number);
if (this.store.data.visitorName == '' || this.store.data.visitorName.length > 10) {
dd.alert({ content: '访客姓名不能为空且长度小于10个字符', buttonText: '确定' })
return return
} }
else if (this.data.visitorPhone == '' || !(/^[1][3,4,5,7,8][0-9]{9}$/).test(this.data.visitorPhone)) { else if (this.data.visitorPhone == '' || !(/^[1][3,4,5,7,8][0-9]{9}$/).test(this.data.visitorPhone)) {
...@@ -271,7 +340,7 @@ create.Page({ ...@@ -271,7 +340,7 @@ create.Page({
dd.alert({ content: '访客单位的长度小于20个字符', buttonText: '确定' }) dd.alert({ content: '访客单位的长度小于20个字符', buttonText: '确定' })
return return
} }
else if (new Date(this.data.startTime).getTime() < new Date(this.data.endTime)) { else if (new Date(this.data.startTime).getTime() > new Date(this.data.endTime).getTime()) {
dd.alert({ content: '开始时间不能晚于结束时间', buttonText: '确定' }) dd.alert({ content: '开始时间不能晚于结束时间', buttonText: '确定' })
return return
} }
...@@ -279,6 +348,30 @@ create.Page({ ...@@ -279,6 +348,30 @@ create.Page({
dd.alert({ content: '来访目的的长度小于20个字符', buttonText: '确定' }) dd.alert({ content: '来访目的的长度小于20个字符', buttonText: '确定' })
return return
} }
else if (number.length > 1 && this.isRepeat(number)) {
dd.alert({ content: '手机号码不能相同', buttonText: '确定' })
return
}
else if (name) {
dd.alert({ content: '访客姓名不能为空且长度小于10个字符', buttonText: '确定' })
return
}
else if (mobile) {
return dd.alert({ content: '访客姓名不能为空且长度小于10个字符', buttonText: '确定' })
}
this.setData({
formValidation: true
})
},
// 手机号码不能重复
isRepeat(ary) {
var number = Array.from(new Set(ary))
if (number.length != ary) {
return false
}
else {
return true
}
}, },
// 选择开始时间 // 选择开始时间
selectStartTime() { selectStartTime() {
...@@ -333,9 +426,9 @@ create.Page({ ...@@ -333,9 +426,9 @@ create.Page({
console.log(res, 'arriveAddress') console.log(res, 'arriveAddress')
let arriveAddress = [] let arriveAddress = []
res.forEach((item, index) => { res.forEach((item, index) => {
arriveAddress.push(item.address) arriveAddress.push(item.address + item.addressDetail)
if (item.isDefault == '0') { if (item.isDefault == '0') {
this.setData({ defaultAddress: item.address }) this.setData({ defaultAddress: item.address + item.addressDetail })
} }
}) })
if (this.data.defaultAddress == '') { if (this.data.defaultAddress == '') {
...@@ -395,16 +488,13 @@ create.Page({ ...@@ -395,16 +488,13 @@ create.Page({
} }
}, },
test() {
},
onReady() { onReady() {
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
// 关闭遮照层 // 关闭遮照层
this.store.data.selectVisitors = false this.store.data.selectVisitors = false;
this.update() this.update()
}, },
onHide() { onHide() {
......
<view class='visitors'> <view class='visitors'>
<view class="tabs"> <view class="tabs">
<view class="{{type === '0' ? 'clickTabs' : ''}}" data-type="0" onTap="changeType">我的访客</view> <view class="{{type == '1' ? 'clickTabs' : ''}}" data-type="1" onTap="changeType">我的访客</view>
<view class="{{type !== '0' ? 'clickTabs' : ''}}" data-type="1" onTap="changeType">公司访客</view> <view class="{{type !== '1' ? 'clickTabs' : ''}}" data-type="0" onTap="changeType">公司访客</view>
</view> </view>
<view class='visitorSituation' a:if="{{dataList.length !== 0}}">今天共 <view class='visitorSituation' a:if="{{dataList.length !== 0}}">今天共
<text>{{todayVisit}}</text>位访客,到访 <text>{{todayVisit}}</text>位访客,到访
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<view class='{{item.processStatus=="cancel"|| item.overdue?"ashStaus":(item.processStatus=="invite" ? "status":"arrive")}}'>{{item.processStatus == 'invite'?'待访问':(item.processStatus == 'cancel'?"已取消":"已到访")}}</view> <view class='{{item.processStatus=="cancel"|| item.overdue?"ashStaus":(item.processStatus=="invite" ? "status":"arrive")}}'>{{item.processStatus == 'invite'?'待访问':(item.processStatus == 'cancel'?"已取消":"已到访")}}</view>
</view> </view>
<view class='visitorListCenter'> <view class='visitorListCenter'>
<view class='{{item.processStatus=="cancel" || item.overdue?"asglongTime":"longTime"}}'a:if='item.longTime'>长期</view> <view class='{{item.processStatus=="cancel" || item.overdue?"asglongTime":"longTime"}}' a:if='{{item.longTime}}'>长期</view>
<view class='people'>被访人:{{item.byVisitorName}}</view> <view class='people'>被访人:{{item.byVisitorName}}</view>
</view> </view>
<view class='visitorListBottom'> <view class='visitorListBottom'>
......
...@@ -2,7 +2,7 @@ const app = getApp() ...@@ -2,7 +2,7 @@ const app = getApp()
import $http from './../../API/http' import $http from './../../API/http'
Page({ Page({
data: { data: {
type: '0', type: '1',
dataList: [], dataList: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
...@@ -46,13 +46,13 @@ Page({ ...@@ -46,13 +46,13 @@ Page({
console.log(dataList.length) console.log(dataList.length)
if (dataList.length > 0) { if (dataList.length > 0) {
dataList.forEach((item, index) => { dataList.forEach((item, index) => {
if (new Date(item.endTime).getTime() < new Date().getTime()) { if (new Date(item.endTime.replace(/\-/g, "/")).getTime() < new Date().getTime()) {
item.overdue = true item.overdue = true
} }
else { else {
item.overdue = false item.overdue = false
} }
if (new Date(item.endTime).getTime() - new Date(item.startTime).getTime() < 24 * 60 * 60 * 3 * 1000) { if (new Date(item.endTime.replace(/\-/g, "/")).getTime() - new Date(item.startTime.replace(/\-/g, "/")).getTime() < 24 * 60 * 60 * 3 * 1000) {
item.longTime = false item.longTime = false
} }
else { else {
...@@ -98,15 +98,31 @@ Page({ ...@@ -98,15 +98,31 @@ Page({
appointment() { appointment() {
dd.navigateTo({ url: './../reservations/reservations' }); dd.navigateTo({ url: './../reservations/reservations' });
}, },
resetData() {
this.setData({
type: '1',
dataList: [],
currentPage: 1,
pageSize: 10,
totalCount: '',
overdue: false,
todayVisit: 0,
arrivedVisit: 0
})
},
onLoad(query) { onLoad(query) {
console.log('进入onLoad')
this.resetData()
dd.setNavigationBar({ title: '智能访客' }); dd.setNavigationBar({ title: '智能访客' });
this.visitorList(0) this.visitorList(1)
this.arriveStaus() this.arriveStaus()
}, },
onReady() { onReady() {
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
console.log('进入onshow')
}, },
onHide() { onHide() {
// 页面隐藏 // 页面隐藏
...@@ -129,7 +145,7 @@ Page({ ...@@ -129,7 +145,7 @@ Page({
}, },
onPullDownRefresh() { onPullDownRefresh() {
this.setData({ this.setData({
type: '0', type: '1',
dataList: [], dataList: [],
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
...@@ -138,6 +154,7 @@ Page({ ...@@ -138,6 +154,7 @@ Page({
}) })
this.visitorList(this.data.type) this.visitorList(this.data.type)
dd.stopPullDownRefresh() dd.stopPullDownRefresh()
this.arriveStaus()
}, },
onShareAppMessage() { onShareAppMessage() {
// 返回自定义分享信息 // 返回自定义分享信息
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="staus" a:if="{{processStatus == 'invite'}}"> <view class="staus" a:if="{{processStatus == 'invite' && self}}">
<view class="noOverdue" a:if='{{!overdue}}'> <view class="noOverdue" a:if='{{!overdue}}'>
<view class="cancel" onTap="cancel">取消访客</view> <view class="cancel" onTap="cancel">取消访客</view>
<view class="reception" onTap="reception">接待访客</view> <view class="reception" onTap="reception">接待访客</view>
......
...@@ -15,7 +15,8 @@ Page({ ...@@ -15,7 +15,8 @@ Page({
phone: '', // 访客的手机号 phone: '', // 访客的手机号
processStatus: '', // 访客的状态 processStatus: '', // 访客的状态
overdue: '', overdue: '',
visitAddress: '' //到访的地址 visitAddress: '', //到访的地址
self:true
}, },
onLoad(event) { onLoad(event) {
console.log(JSON.parse(event.item), 'query') console.log(JSON.parse(event.item), 'query')
...@@ -26,6 +27,7 @@ Page({ ...@@ -26,6 +27,7 @@ Page({
title: "访客详情", title: "访客详情",
}); });
this.setData({ this.setData({
self:query.self,
visitorName: query.visitorName, visitorName: query.visitorName,
company: query.companyName, company: query.companyName,
startTimeYear: `${query.startTime.yearMonthDate}`, startTimeYear: `${query.startTime.yearMonthDate}`,
...@@ -34,8 +36,8 @@ Page({ ...@@ -34,8 +36,8 @@ Page({
endHour: `${query.endTime.hourMinute}`, endHour: `${query.endTime.hourMinute}`,
byVisitorName: `${query.byVisitorName}`, byVisitorName: `${query.byVisitorName}`,
purpose: query.purpose, purpose: query.purpose,
visitAddress:query.visitAddress, visitAddress: query.visitAddress,
participatorUserList:query.participatorUserList, participatorUserList: query.participatorUserList,
participator: '', participator: '',
phone: query.mobile, phone: query.mobile,
processStatus: query.processStatus, processStatus: query.processStatus,
...@@ -53,7 +55,10 @@ Page({ ...@@ -53,7 +55,10 @@ Page({
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
success: (result) => { success: (result) => {
console.log(result,11111111111) if (result.confirm == false) {
}
else {
let data = { let data = {
recordId: this.data.recordId recordId: this.data.recordId
} }
...@@ -61,16 +66,25 @@ Page({ ...@@ -61,16 +66,25 @@ Page({
console.log(res) console.log(res)
this.setData({ processStatus: 'cancel' }) this.setData({ processStatus: 'cancel' })
}) })
}
}, },
}); });
}, },
reception() { reception() {
console.log(3333333)
dd.confirm({ dd.confirm({
title: '确认已接待', title: '确认已接待',
confirmButtonText: '确认', confirmButtonText: '确认',
cancelButtonText: '取消', cancelButtonText: '取消',
success: (result) => { success: (result) => {
console.log(result)
console.log(4444)
if (result.confirm == 'false') {
console.log(11111111111111)
}
else {
console.log(222222)
let data = { let data = {
recordId: this.data.recordId recordId: this.data.recordId
} }
...@@ -78,7 +92,12 @@ Page({ ...@@ -78,7 +92,12 @@ Page({
console.log(res) console.log(res)
this.setData({ processStatus: 'arrive' }) this.setData({ processStatus: 'arrive' })
}) })
}
}, },
fail: (err) => {
console.log(66666)
}
}); });
...@@ -93,7 +112,6 @@ Page({ ...@@ -93,7 +112,6 @@ Page({
fail: function(err) { fail: function(err) {
} }
}); });
}, },
onShow() { onShow() {
// 页面显示 // 页面显示
......
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