regular_invite.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. // pages/regular_invite/regular_invite.js
  4. import international from "../../international/appointment_scence/index";
  5. const {
  6. userWhiteInviteUserVisitor,
  7. userWhiteGetSnList,
  8. getVisitoryByUserVisitorListDetailId
  9. } = require("../../utils/api/api");
  10. const app = getApp();
  11. Page({
  12. /**
  13. * 页面的初始数据
  14. */
  15. data: {
  16. international: international,
  17. //国际化语言包
  18. language: app.data.language,
  19. machineList: [],
  20. // 通道权限列表--设备列表
  21. // 人员类型列表
  22. personTypeList: [{
  23. id: 0,
  24. name_ch: "访客",
  25. name_en: "visitors"
  26. }, {
  27. id: 1,
  28. name_ch: "同事",
  29. name_en: "colleagues"
  30. }, {
  31. id: 2,
  32. name_ch: "亲属",
  33. name_en: "relatives"
  34. }],
  35. isRealNameList: [
  36. // {
  37. // id: 0,
  38. // name_ch: "微信",
  39. // name_en: "WeChat"
  40. // },
  41. {
  42. id: 1,
  43. name_ch: "短信",
  44. name_en: "SMS"
  45. }],
  46. // 拜访事由列表
  47. reasonList: [{
  48. name: "业务洽谈"
  49. }, {
  50. name: "会议邀请"
  51. }, {
  52. name: "施工安装"
  53. }, {
  54. name: "探亲访友"
  55. }, {
  56. name: "工作检查"
  57. }, {
  58. name: "面试邀请"
  59. }, {
  60. name: "快递外卖"
  61. }, {
  62. name: "家政保洁"
  63. }],
  64. form: {},
  65. //提交的表单
  66. chooseSN: false,
  67. snListLength: null,
  68. isDisabled: true,
  69. showAddBut: true,
  70. closeNum: false
  71. },
  72. //获取开始时间
  73. getValue(e) {
  74. const {
  75. form
  76. } = this.data;
  77. switch (e.currentTarget.dataset.type) {
  78. case "snList":
  79. this.setData({
  80. "form.snList": e.detail,
  81. snListLength: e.detail.length,
  82. chooseSN: false
  83. });
  84. break;
  85. case "reason":
  86. this.setData({
  87. "form.reason": e.detail.name
  88. });
  89. break;
  90. case "personnelType":
  91. this.setData({
  92. "form.personnelType": e.detail
  93. });
  94. break;
  95. case "invitationWay":
  96. this.setData({
  97. "form.invitationWay": e.detail
  98. });
  99. if (e.detail == 0) {
  100. this.setData({
  101. showAddBut: false
  102. });
  103. } else {
  104. this.setData({
  105. showAddBut: true
  106. });
  107. }
  108. break;
  109. default:
  110. form[e.currentTarget.dataset.type] = e.detail;
  111. break;
  112. }
  113. this.matchComplete();
  114. },
  115. // 判断用户是否填写完整
  116. matchComplete() {
  117. let form = this.data.form;
  118. let isDisabled = form.startTime && form.endTime && form.snList && form.snList.length > 0 && form.reason && form.phoneList && form.phoneList.length > 0 ? false : true;
  119. this.setData({
  120. isDisabled: isDisabled
  121. });
  122. },
  123. // 立即邀请
  124. gotoInvited() {
  125. const that = this;
  126. return new Promise((reslove, reject) => {
  127. let {
  128. phoneList,
  129. snList
  130. } = that.data.form;
  131. that.data.form.userWhitelistId = app.data.adminInfo.userWhitelistId;
  132. if (phoneList && snList) {
  133. userWhiteInviteUserVisitor(that.data.form).then(res => {
  134. if (res.code == 200) {
  135. if (!that.data.showAddBut) {
  136. reslove({
  137. title: "您收到一个来自" + app.data.userInfo.username + "邀请函",
  138. path: "/pages/visitor_make/visitor_make?userVisitorDetailId=" + res.data[0].userVisitorListDetailId,
  139. imageUrl: "../../static/comment/invitation.jpg"
  140. });
  141. } else {
  142. my.alert({
  143. title: "提示",
  144. content: "您已成功邀请用户,短信将在几分钟内发送至用户手机~",
  145. success() {
  146. my.navigateBack()
  147. }
  148. })
  149. }
  150. } else {
  151. my.alert({
  152. title: "提示",
  153. content: res.msg,
  154. success() {
  155. my.navigateBack()
  156. }
  157. })
  158. reject();
  159. }
  160. });
  161. } else {
  162. wx.showToast({
  163. title: "请将内容输入完整!",
  164. icon: "none"
  165. });
  166. reject();
  167. }
  168. });
  169. },
  170. // 常客获取楼宇的设备列表(sn和name)
  171. userWhiteGetSnList() {
  172. let adminInfo = app.data.adminInfo;
  173. userWhiteGetSnList({
  174. adminId: adminInfo.adminId,
  175. companyId: adminInfo.companyAdminId
  176. }).then(res => {
  177. // res.data.
  178. this.setData({
  179. machineList: res.data
  180. });
  181. });
  182. },
  183. // 打开通道权限弹出框
  184. showSN() {
  185. this.setData({
  186. chooseSN: true
  187. });
  188. },
  189. /**
  190. * 生命周期函数--监听页面加载
  191. */
  192. onLoad: function (options) {
  193. this.userWhiteGetSnList();
  194. },
  195. /**
  196. * 生命周期函数--监听页面初次渲染完成
  197. */
  198. onReady: function () {},
  199. /**
  200. * 生命周期函数--监听页面显示
  201. */
  202. onShow: function () {
  203. this.setData({
  204. language: app.data.language
  205. });
  206. },
  207. /**
  208. * 生命周期函数--监听页面隐藏
  209. */
  210. onHide: function () {},
  211. /**
  212. * 生命周期函数--监听页面卸载
  213. */
  214. onUnload: function () {},
  215. /**
  216. * 页面相关事件处理函数--监听用户下拉动作
  217. */
  218. onPullDownRefresh: function () {},
  219. /**
  220. * 页面上拉触底事件的处理函数
  221. */
  222. onReachBottom: function () {},
  223. /**
  224. * 用户点击右上角分享
  225. */
  226. onShareAppMessage: function () {
  227. let userInfo = app.data.userInfo;
  228. let promise = this.gotoInvited();
  229. return {
  230. title: "您收到一个来自" + userInfo.username + "邀请函",
  231. path: "/pages/visitor_make/visitor_make?userVisitorDetailId=null",
  232. imageUrl: "../../static/comment/invitation.jpg",
  233. promise
  234. };
  235. },
  236. antmoveAction: function () {
  237. //执行时动态赋值,请勿删除
  238. }
  239. });