diff --git a/miniprogram/api/meeting/visitorIinvitation.js b/miniprogram/api/meeting/visitorIinvitation.js index c8bb8b1..de3d295 100644 --- a/miniprogram/api/meeting/visitorIinvitation.js +++ b/miniprogram/api/meeting/visitorIinvitation.js @@ -2,19 +2,19 @@ import { request } from '../selfRequest'; -// 微信登录接口 -export function companyRq(data) { + +// 获取所有的企业 +export function visitorListRq() { return request({ url: '/api/visitor/list', - method: "get" + method: "get", }); } -// 注册用户 -export function registerPhone(data) { +// 获取企业下的所有用户 +export function visitorSelectUserByCustomerRq(id) { return request({ - url: '/social_user_login/login', - method: "post", - data + url: '/api/visitor/selectUserByCustomer/' + id, + method: "get", }); } \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js index b17ffca..ceef38f 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js +++ b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.js @@ -9,112 +9,6 @@ Page({ * 页面的初始数据 */ data: { - IMG_NAME: app.IMG_NAME, - detail: {}, - value: '', - companyShow: false, - usernameShow: false, - cardTypeShow: false, - arriveShow: false, - leaveShow: false, - submitSuccesShow: false, - companyColumns: ['公司1', '公司2', '公司3'], - columns: ['身份证', '护照', '通行证'], - fileList: [], - currentDate: new Date().getTime(), - /** 索引栏*/ - indexList: ["A", "B", "C", "D"], - scrollTop: 0, - /** mock客户数据*/ - customerList: [{ - firstLetter: "A", - list: [{ - code: "AB01", - name: "A1客户" - }, - { - code: "AB02", - name: "A2客户" - }, - { - code: "AB03", - name: "A3客户" - }, - ], - }, - { - firstLetter: "B", - list: [{ - code: "BB01", - name: "B1客户" - }, - { - code: "BB02", - name: "B2客户" - }, - { - code: "BB03", - name: "B3客户" - }, - { - code: "BB04", - name: "B4客户" - }, - ], - }, - { - firstLetter: "C", - list: [{ - code: "CB01", - name: "C1客户" - }, - { - code: "CB02", - name: "C2客户" - }, - { - code: "CB03", - name: "C3客户" - }, - { - code: "CB04", - name: "C4客户" - }, - { - code: "CB05", - name: "C5客户" - }, - ], - }, - { - firstLetter: "D", - list: [{ - code: "DB01", - name: "D1客户" - }, - { - code: "DB02", - name: "D2客户" - }, - { - code: "DB03", - name: "D3客户" - }, - { - code: "DB04", - name: "D4客户" - }, - { - code: "DB05", - name: "D5客户" - }, - { - code: "DB06", - name: "D6客户" - }, - ], - }, - ], }, @@ -122,157 +16,74 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad(options) { + console.log('onLoad', options) + let _this = this; + _this.setData({ + ...options + }) // 页面初始化 options为页面跳转所带来的参数 wx.setNavigationBarTitle({ title: options.title }) - console.log('options.goods_id', options) - companyRq({}).then(res => { - console.log('res', res) - if (res.code == 0) { - // res.row - } + }, + + + // 跳转-索引栏(单位、人员) + jumpIndexBar(e) { + console.log('jumpIndexBar', e); + let title = e.currentTarget.dataset.title + wx.navigateTo({ + url: '/pages/meeting/visitorIinvitation/indexBar/indexBar?title=' + title, }) }, + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () { + + }, + /** * 生命周期函数--监听页面卸载 */ - onUnload() { + onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ - onPullDownRefresh() { + onPullDownRefresh: function () { }, - onChange(event) { - // event.detail 为当前输入的值 - console.log(event.detail); - }, /** * 页面上拉触底事件的处理函数 */ - onReachBottom() { + onReachBottom: function () { }, /** * 用户点击右上角分享 */ - onShareAppMessage() { + onShareAppMessage: function () { - }, - getUsernameHandle() { - // this.setData({ - // usernameShow: true - // }); - wx.navigateTo({ - url: '/pages/meeting/visitorIinvitation/indexBar/indexBar' - }) - - }, - getCompanyHandle() { - this.setData({ - companyShow: true - }); - }, - getCardTypeHandle() { - this.setData({ - cardTypeShow: true - }); - }, - changeHandler(e) { - console.log(e) - - }, - // confirmHandle(){ - - // }, - confirmHandle() { - this.setData({ - companyShow: false, - usernameShow: false, - cardTypeShow: false, - arriveShow: false, - leaveShow: false - }); - }, - cancelHandle() { - this.setData({ - companyShow: false, - usernameShow: false, - cardTypeShow: false, - arriveShow: false, - leaveShow: false - }); - }, - getArriveHandle() { - this.setData({ - arriveShow: true - }); - - }, - getLeaveHandle() { - this.setData({ - leaveShow: true - }); - }, - onClose() { - this.setData({ - usernameShow: true - }); - }, - afterRead(event) { - const { - file - } = event.detail; - // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式 - wx.uploadFile({ - url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址 - filePath: file.url, - name: 'file', - formData: { - user: 'test' - }, - success(res) { - // 上传完成需要更新 fileList - const { - fileList = [] - } = this.data; - fileList.push({ - ...file, - url: res.data - }); - this.setData({ - fileList - }); - }, - }); - }, - onInput(event) { - this.setData({ - currentDate: event.detail, - }); - }, - submitFormFn() { - this.setData({ - submitSuccesShow: true, - }); - - }, - submitDialogFn() { - this.setData({ - submitSuccesShow: false, - }); - setTimeout(() => { - wx.navigateTo({ - url: '/pages/meeting/visitorIinvitation/appointmentRecord/appointmentRecord', - }) - }, 10); } }) \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.wxml b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.wxml index ded4df0..138b0b1 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/detail/detail.wxml +++ b/miniprogram/pages/meeting/visitorIinvitation/detail/detail.wxml @@ -3,17 +3,17 @@ 预约信息 - + 被访单位 - + - + 被访人姓名 - + 被访人电话 - + 访客姓名 @@ -59,32 +59,4 @@ 提交 - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.js b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.js index e61f5d6..bd3880e 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.js +++ b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.js @@ -1,68 +1,178 @@ -Page({ - data: { - type: "", - /** 索引栏*/ - indexList: ["A", "B", "C", "D"], - scrollTop: 0, - /** mock客户数据*/ - customerList: [ - { - firstLetter: "A", - list: [ - { code: "AB01", name: "A1客户" }, - { code: "AB02", name: "A2客户" }, - { code: "AB03", name: "A3客户" }, - ], - }, - { - firstLetter: "B", - list: [ - { code: "BB01", name: "B1客户" }, - { code: "BB02", name: "B2客户" }, - { code: "BB03", name: "B3客户" }, - { code: "BB04", name: "B4客户" }, - ], - }, - { - firstLetter: "C", - list: [ - { code: "CB01", name: "C1客户" }, - { code: "CB02", name: "C2客户" }, - { code: "CB03", name: "C3客户" }, - { code: "CB04", name: "C4客户" }, - { code: "CB05", name: "C5客户" }, - ], - }, - { - firstLetter: "D", - list: [ - { code: "DB01", name: "D1客户" }, - { code: "DB02", name: "D2客户" }, - { code: "DB03", name: "D3客户" }, - { code: "DB04", name: "D4客户" }, - { code: "DB05", name: "D5客户" }, - { code: "DB06", name: "D6客户" }, - ], - }, - ], - }, - - //索引栏发生变化事件 - onPageScroll(event) { - this.setData({ - scrollTop: event.scrollTop, - }); - }, +import { + visitorListRq, + visitorSelectUserByCustomerRq, +} from "../../../../api/meeting/visitorIinvitation.js" + +Page({ + + data: { + title: '', + /** 索引栏*/ + indexList: [], + /** 数据*/ + dataList: [], + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + let _this = this; + _this.setData({ + ...options + }) + wx.setNavigationBarTitle({ + title: '请选择' + options.title, + }) + // + // + if (_this.data.title == '单位') { + // 获取所有的企业 + _this.getVisitorList() + } + if (_this.data.title == '人员') { + // 获取企业下的所有用户 + _this.getVisitorSelectUserByCustomer() + } + + }, + + // 获取所有的企业 + getVisitorList() { + let _this = this; + visitorListRq().then(res => { + console.log('getVisitorList', res); + let filterDataList = res.rows.map(item => { + let otherData = JSON.stringify({ + id: item.id, + name: item.name, + mailAddress: item.mailAddress, + }) + + return { + label: item.name, + value: item.id, + otherData + } + }) + // 赋值并且格式化数据 + _this.setAndFormatData(filterDataList) + }) + }, + + // 获取企业下的所有用户 + getVisitorSelectUserByCustomer() { + visitorSelectUserByCustomerRq().then(res => { + console.log('getVisitorSelectUserByCustomer', res); + }) + }, + + + // 格式化数据 + setAndFormatData(transferList) { + let _this = this; + // 索引列 + let indexList = _this.getFirstCharacterList(transferList) + // 对应每个索引的数据列表 + let dataList = indexList.map(item => { + let title = item; + let collectList = []; + for (let i = 0; i < transferList.length; i++) { + let transferData = transferList[i]; + if (title == transferData.label.substring(0, 1)) { + collectList.push(transferData) + } + } + return { + title, + list: collectList + } + }) + _this.setData({ + indexList, + dataList + }) + }, + + // 获取第一个字符数组,不重复 + getFirstCharacterList(list) { + let firstNameList = list.map(item => { + return { + name: item.label.substring(0, 1), + exist: false + } + }); + for (let i = 0; i < firstNameList.length; i++) { + for (let j = i + 1; j < firstNameList.length; j++) { + // 已重复的数据直接跳过 + if (firstNameList[j].exist) { + continue; + } + // 数据重复 + if (firstNameList[i].name == firstNameList[j].name) { + firstNameList[j].exist = true; + } + } + } + return firstNameList.filter(item => !item.exist).map(item => item.name) + }, + + + + + // 选择 + selectClick(e) { + console.log('selectClick', e); + let label = e.currentTarget.dataset.label + let value = e.currentTarget.dataset.value + }, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady() { + + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow() { + + }, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide() { + + }, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload() { + + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh() { + + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom() { + + }, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage() { - /**选择客户发生事件 */ - getCustomer: function (event) { - console.log(event.currentTarget.dataset.id); - console.log(event.currentTarget.dataset.name); - const value = event.currentTarget.dataset.name - if(value){ - wx.reLaunch({ - url: '/pages/meeting/visitorIinvitation/visitorIinvitation?name='+value, - }) } - }, -}); \ No newline at end of file +}) \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.json b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.json index 4ac8a02..8761843 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.json +++ b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.json @@ -1,8 +1,8 @@ { - "navigationBarTitleText":"选择被访人姓名", - "usingComponents": { - "van-cell": "@vant/weapp/cell/index", - "van-index-bar": "@vant/weapp/index-bar/index", - "van-index-anchor": "@vant/weapp/index-anchor/index" - } + "navigationBarTitleText": "选择", + "usingComponents": { + "van-cell": "@vant/weapp/cell/index", + "van-index-bar": "@vant/weapp/index-bar/index", + "van-index-anchor": "@vant/weapp/index-anchor/index" + } } \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxml b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxml index 517774a..9e62bb8 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxml +++ b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxml @@ -1,6 +1,6 @@ - - - {{item.firstLetter}} - - + + + + + \ No newline at end of file diff --git a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxss b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxss index 47ba0cc..e69de29 100644 --- a/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxss +++ b/miniprogram/pages/meeting/visitorIinvitation/indexBar/indexBar.wxss @@ -1 +0,0 @@ -/* pages/meeting/visitorIinvitation/indexBar/indexBar.wxss */ \ No newline at end of file