123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- // pages/regular_invite/regular_invite.js
- import international from '../../international/appointment_scence/index'
- const {
- userWhiteInviteUserVisitor,
- userWhiteGetSnList,
- } = require('../../utils/api/api')
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- //国际化语言包
- international: international,
- //中英文配置
- language: null,
- // 人员类型列表
- personTypeList: [{
- id: 0,
- name_ch: '访客',
- name_en: 'visit',
- },
- {
- id: 1,
- name_ch: '同事',
- name_en: 'friend',
- },
- {
- id: 2,
- name_ch: '亲属',
- name_en: 'family',
- },
- ],
- //邀请方式
- isRealNameList: [{
- id: 0,
- name_ch: '微信',
- name_en: 'WeChat',
- },
- {
- id: 1,
- name_ch: '短信',
- name_en: 'SMS',
- },
- ],
- // 拜访事由列表
- reasonList: [{
- name: '业务洽谈'
- },
- {
- name: '会议邀请'
- },
- {
- name: '施工安装'
- },
- {
- name: '探亲访友'
- },
- {
- name: '工作检查'
- },
- {
- name: '面试邀请'
- },
- {
- name: '快递外卖'
- },
- {
- name: '家政保洁'
- }],
- // 通道权限列表--设备列表
- machineList: [],
- //是否打开设备列表勾选弹窗
- chooseSN: false,
- //选中的设备数量
- snListLength: null,
- //是否显示新增手机号按钮
- showAddBut: true,
- //是否清除已填写的手机号
- closeNum: false,
- //是否禁用邀请按钮
- isDisabled: true,
- //提交的表单
- form: {},
- },
- // 常客获取楼宇的设备列表(sn和name)
- userWhiteGetSnList() {
- let adminInfo = app.data.adminInfo
- userWhiteGetSnList({
- adminId: adminInfo.buildingAdminId,
- companyId: adminInfo.companyAdminId,
- }).then(res => {
- this.setData({
- machineList: res.data
- })
- })
- },
- // 打开通道权限弹出框
- showSN() {
- this.setData({
- chooseSN: true
- })
- },
- //获取填写的值
- getValue(e) {
- var {
- form
- } = this.data;
- switch (e.currentTarget.dataset.type) {
- case 'snList':
- this.setData({
- 'form.snList': e.detail,
- snListLength: e.detail.length
- })
- break;
- case 'reason':
- this.setData({
- 'form.reason': e.detail.name
- })
- break;
- case 'invitationWay':
- this.setData({
- 'form.invitationWay': e.detail
- })
- this.setData({
- showAddBut: e.detail == 0?false:true,
- 'form.phoneList': [],
- closeNum: true
- })
- break;
- default:
- form[e.currentTarget.dataset.type] = e.detail
- break;
- }
- this.matchComplete();
- },
- // 判断用户是否填写完整
- matchComplete() {
- let form = this.data.form;
- let isDisabled = form.startTime && form.endTime && form.reason && form.phoneList && form.phoneList.length > 0 ? false : true;
- this.setData({
- isDisabled: isDisabled
- })
- },
- // 立即邀请
- gotoInvited() {
- const that = this;
- return new Promise((reslove, reject) => {
- that.data.form.userWhitelistId = app.data.adminInfo.userWhitelistId
- userWhiteInviteUserVisitor(that.data.form).then(res => {
- if (res.code != 200) {
- wx.showModal({
- title: '提示',
- content: res.msg,
- showCancel: false,
- success() {}
- })
- reject();
- return;
- }
- if (!that.data.showAddBut) {
- that.data.flag = 1;
- reslove({
- title: '您收到一个来自' + app.data.userInfo.username + '邀请函',
- path: '/pages/visitor_make/visitor_make?userVisitorDetailId=' + res.data[0].userVisitorListDetailId,
- imageUrl: '../../static/comment/invitation.jpg',
- })
- } else {
- wx.showModal({
- title: '提示',
- content: '您已成功邀请用户,短信将在几分钟内发送至用户手机~',
- showCancel: false,
- success() {
- wx.navigateBack({
- delta: 1,
- })
- }
- })
- }
- })
- })
- },
- //判断是否分享完回来的(无法判断是否真的分享-2018 年腾讯已取消分享取消回调)
- judgeContinueShare() {
- if (this.data.flag == 1) {
- this.data.flag = null;
- wx.showModal({
- content: '分享邀请函成功,是否继续邀请?',
- confirmText: "继续邀请",
- complete: (res) => {
- if (res.cancel) {
- wx.navigateBack({
- delta: 1,
- })
- }
- if (res.confirm) {
- this.setData({
- "form.phoneList": [],
- closeNum: true
- });
- this.matchComplete()
- }
- }
- })
- }
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- 'form.reason': "业务洽谈"
- })
- this.userWhiteGetSnList()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.judgeContinueShare()
- this.setData({
- language: app.data.language,
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- let userInfo = app.data.userInfo
- let promise = this.gotoInvited()
- return {
- title: '您收到一个来自' + userInfo.username + '邀请函',
- path: '/pages/visitor_make/visitor_make?userVisitorDetailId=null',
- imageUrl: '../../static/comment/invitation.jpg',
- promise
- }
- }
- })
|