mine.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. // pages/mine/mine.js
  2. import international from '../../international/appointment_scence/index'
  3. const {
  4. desensitizationPhone,
  5. desensitizationIdNumber,
  6. } = require('../../utils/util')
  7. const app = getApp();
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. //国际化语言包
  14. international: international,
  15. //中英文配置
  16. language: app.data.language,
  17. //胶囊位置
  18. statusBarCont: app.data.statusBarCont,
  19. //1常客 2访客
  20. type: 2,
  21. //用户基础信息
  22. userInfo: null,
  23. //可供使用的账号信息
  24. usedAdminInfo: null,
  25. // 功能列表
  26. component_list: [{
  27. id: 1,
  28. name_ch: '邀请人员',
  29. name_en: 'Invite',
  30. icon: '../../static/mine/my_appointment.png',
  31. url: ''
  32. },
  33. {
  34. id: 2,
  35. name_ch: '申请审核',
  36. name_en: 'Audit',
  37. icon: '../../static/mine/appointment_records.png',
  38. url: ''
  39. },
  40. {
  41. id: 6,
  42. name_ch: '访客记录',
  43. name_en: 'VisitorRecords',
  44. icon: '../../static/mine/visitors.png',
  45. url: ''
  46. },
  47. {
  48. id: 4,
  49. name_ch: '企业信息',
  50. name_en: 'Enterprise',
  51. icon: '../../static/mine/change_msg.png',
  52. url: ''
  53. }
  54. ],
  55. },
  56. // 跳转
  57. goto(e) {
  58. let id = e.currentTarget.dataset.id
  59. let obj = {
  60. 1: {
  61. url: '/pages/regular_invite/regular_invite',
  62. needUserInfo: true,
  63. needAdminInfo: true,
  64. tmplIds: ['261lS0M-ugfPHTOFeTFS6IN8WQshNOCbrPEC51OONy8'],
  65. ch: "要先注册为内部员工才可以使用该功能哦,是否现在去注册?",
  66. en: "Please do certification first,regist now?",
  67. jumpLink: '/pages/regular_register/regular_register',
  68. jumpLinkTmplIds:['v_ue7JEmz5AYeRz690ymJO1ImTOiM96FyeHPYny7ihw', 'sYVZwmwu3gGNF4Ywjo0qgx-Gu7MEj59EDJvmOaQPVA0','sYVZwmwu3gGNF4Ywjo0qgx-Gu7MEj59EDJvmOaQPVA0']
  69. },
  70. 2: {
  71. url: '/pages/regular_visit_records/regular_visit_records',
  72. needUserInfo: true,
  73. needAdminInfo: true,
  74. ch: "要先注册为内部员工才可以使用该功能哦,是否现在去注册?",
  75. en: "Please do certification first,regist now?",
  76. jumpLink: '/pages/regular_register/regular_register',
  77. jumpLinkTmplIds:['v_ue7JEmz5AYeRz690ymJO1ImTOiM96FyeHPYny7ihw', 'sYVZwmwu3gGNF4Ywjo0qgx-Gu7MEj59EDJvmOaQPVA0','sYVZwmwu3gGNF4Ywjo0qgx-Gu7MEj59EDJvmOaQPVA0']
  78. },
  79. 4: {
  80. url: '/pages/regular_company_manage/regular_company_manage',
  81. needvisitorUserInfo: true,
  82. ch: "要先进行认证才可以看到您的记录呢,是否现在去认证?",
  83. en: "Please do certification first,apply now?",
  84. jumpLink: '/pages/visitor_make/visitor_make?justCertification=true',
  85. jumpLinkTmplIds:['fXvvf63kLk-koo2Rnt0igsVnaPNAoO9bMRqaKtFOqJg', 'sYVZwmwu3gGNF4Ywjo0qg2hJMHqpTr2yh_x-qr710T8','sYVZwmwu3gGNF4Ywjo0qg3ED_h5wsEZW2j7AyU1zhWA']
  86. },
  87. 6: {
  88. url: '/pages/visit_records/visit_records',
  89. needvisitorUserInfo: true,
  90. ch: "要先进行认证才可以看到您的记录呢,是否现在去认证?",
  91. en: "Please do certification first,apply now?",
  92. jumpLink: '/pages/visitor_make/visitor_make?justCertification=true',
  93. jumpLinkTmplIds:['fXvvf63kLk-koo2Rnt0igsVnaPNAoO9bMRqaKtFOqJg', 'sYVZwmwu3gGNF4Ywjo0qg2hJMHqpTr2yh_x-qr710T8','sYVZwmwu3gGNF4Ywjo0qg3ED_h5wsEZW2j7AyU1zhWA']
  94. }
  95. }
  96. let config = obj[id];
  97. if((config.needUserInfo && !app.data.userInfo) || (config.needvisitorUserInfo && !app.data.visitorUserInfo) || (config.needAdminInfo && !app.data.adminInfo)) {
  98. wx.showModal({
  99. content: config[this.data.language],
  100. confirmText:this.data.language =="ch"?"是":"YES" ,
  101. cancelText:this.data.language =="ch"?"否":"NO",
  102. complete: (res) => {
  103. if (!res.confirm) {
  104. return;
  105. }
  106. if(config.jumpLinkTmplIds) {
  107. wx.requestSubscribeMessage({
  108. tmplIds: config.jumpLinkTmplIds,
  109. success(res) {}
  110. });
  111. }
  112. wx.navigateTo({
  113. url: config.jumpLink,
  114. })
  115. }
  116. })
  117. return;
  118. }
  119. if(config.tmplIds) {
  120. wx.requestSubscribeMessage({
  121. tmplIds: config.tmplIds,
  122. success(res) {}
  123. });
  124. }
  125. wx.navigateTo({
  126. url: config.url
  127. })
  128. },
  129. // 认证
  130. goCertification(e) {
  131. let type = e.currentTarget.dataset.type
  132. if(type == 1) {
  133. wx.navigateTo({
  134. url: '/pages/visitor_make/visitor_make?justCertification=true'
  135. })
  136. return;
  137. }
  138. if(type == 2) {
  139. wx.navigateTo({
  140. url: '/pages/regular_register/regular_register?justCertification=true'
  141. })
  142. return;
  143. }
  144. },
  145. //图片预览
  146. preview(e) {
  147. let url = e.currentTarget.dataset.src;
  148. wx.previewImage({
  149. current: url, // 当前显示图片的http链接
  150. urls: [url] // 需要预览的图片http链接列表
  151. })
  152. },
  153. getUserInfo() {
  154. let { userInfo } = this.data;
  155. userInfo = app.data.userInfo || app.data.visitorUserInfo
  156. if (userInfo && userInfo.idNumber) {
  157. userInfo.hideIdNumber = desensitizationIdNumber(userInfo.idNumber)
  158. }
  159. if (userInfo && userInfo.phone) {
  160. userInfo.hidePhone = desensitizationPhone(userInfo.phone)
  161. }
  162. this.setData({
  163. userInfo,
  164. type: (app.data.adminInfo && app.data.adminInfo.official)? 1 : 2,
  165. language: app.data.language,
  166. })
  167. },
  168. /**
  169. * 生命周期函数--监听页面加载
  170. */
  171. onLoad: function (options) {
  172. },
  173. /**
  174. * 生命周期函数--监听页面初次渲染完成
  175. */
  176. onReady: function () {
  177. },
  178. /**
  179. * 生命周期函数--监听页面显示
  180. */
  181. onShow: function () {
  182. this.getUserInfo()
  183. },
  184. /**
  185. * 生命周期函数--监听页面隐藏
  186. */
  187. onHide: function () {
  188. },
  189. /**
  190. * 生命周期函数--监听页面卸载
  191. */
  192. onUnload: function () {
  193. },
  194. /**
  195. * 页面相关事件处理函数--监听用户下拉动作
  196. */
  197. onPullDownRefresh: function () {
  198. },
  199. /**
  200. * 页面上拉触底事件的处理函数
  201. */
  202. onReachBottom: function () {
  203. },
  204. /**
  205. * 用户点击右上角分享
  206. */
  207. onShareAppMessage: function () {
  208. }
  209. })