regular_visit_details.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. const _my = require("../../__antmove/api/index.js")(my);
  2. const wx = _my;
  3. // pages/regular_visit_details/regular_visit_details.js
  4. const {
  5. userWhiteHandleVisitList,
  6. userWhiteGetSnList,
  7. visitoryDownFaceAgain
  8. } = require("../../utils/api/api");
  9. const app = getApp();
  10. import international from "../../international/appointment_scence/index";
  11. const {
  12. throttle
  13. } = require("../../utils/throttle/throttle");
  14. import QRCode from "../../utils/util/weapp-qrcode";
  15. import { userCreate } from '/utils/api/zfb_ioTVsp'
  16. Page({
  17. /**
  18. * 页面的初始数据
  19. */
  20. data: {
  21. international: international,
  22. language: app.data.language,
  23. regularList: null,
  24. //相关信息
  25. machineList: [],
  26. // 通道权限列表--设备列表
  27. chooseSN: false,
  28. snListLength: null,
  29. snList: null,
  30. isRegular: false,
  31. // 人员类型列表
  32. personTypeList: [{
  33. id: 0,
  34. name_ch: "访客",
  35. name_en: "visitors"
  36. }, {
  37. id: 1,
  38. name_ch: "同事",
  39. name_en: "colleagues"
  40. }, {
  41. id: 2,
  42. name_ch: "亲属",
  43. name_en: "relatives"
  44. }],
  45. personnelType: 0,
  46. remark: "",
  47. uniqueId: null,
  48. //备注
  49. reviewStatus: 2 //2同意1拒绝
  50. },
  51. // 常客获取楼宇的设备列表(sn和name)
  52. userWhiteGetSnList() {
  53. let adminInfo = app.data.adminInfo;
  54. if (adminInfo) {
  55. userWhiteGetSnList({
  56. adminId: adminInfo.adminId,
  57. companyId: adminInfo.companyAdminId
  58. }).then(res => {
  59. // res.data.
  60. this.setData({
  61. machineList: res.data
  62. });
  63. });
  64. }
  65. },
  66. //获取开始时间
  67. getValue(e) {
  68. var {
  69. form
  70. } = this.data;
  71. switch (e.currentTarget.dataset.type) {
  72. case "snList":
  73. // form.snList = e.detail
  74. this.setData({
  75. snList: e.detail,
  76. snListLength: e.detail.length,
  77. chooseSN: false
  78. });
  79. break;
  80. case "personnelType":
  81. this.setData({
  82. personnelType: e.detail
  83. });
  84. break;
  85. default:
  86. form[e.currentTarget.dataset.type] = e.detail;
  87. break;
  88. }
  89. },
  90. // 打开通道权限弹出框
  91. showSN() {
  92. this.setData({
  93. chooseSN: true
  94. });
  95. },
  96. // 选择通过/拒绝
  97. chooseFun(e) {
  98. this.setData({
  99. reviewStatus: e.currentTarget.dataset.type,
  100. remark: ""
  101. });
  102. },
  103. // 备注
  104. onInput(e) {
  105. this.setData({
  106. remark: e.detail
  107. });
  108. },
  109. handle(e) {
  110. let {
  111. snList,
  112. regularList,
  113. remark,
  114. reviewStatus,
  115. personnelType
  116. } = this.data;
  117. wx.requestSubscribeMessage({
  118. entityIds: ["9d4ddcd78f66444482ad66c5a262ffed"],
  119. success(res) {
  120. if(res.behavior === 'cancel') {
  121. return
  122. }
  123. if (snList || reviewStatus == 1) {
  124. let data = {
  125. snList: snList || [],
  126. reviewStatus,
  127. userVisitorListDetailId: regularList.userVisitorListDetailId,
  128. personnelType,
  129. remark
  130. };
  131. userWhiteHandleVisitList(data).then(res => {
  132. if (res.code == 200) {
  133. my.alert({
  134. title: "提醒",
  135. content: "操作成功!",
  136. success(res) {
  137. wx.navigateBack({
  138. delta: 1
  139. })
  140. }
  141. })
  142. } else {
  143. wx.showToast({
  144. title: res.msg,
  145. icon: "none"
  146. });
  147. }
  148. });
  149. } else {
  150. wx.showToast({
  151. title: "请选择通道权限!",
  152. icon: "none"
  153. });
  154. }
  155. }
  156. });
  157. },
  158. // 访客重新下发
  159. visitoryDownFaceAgain: throttle(function () {
  160. visitoryDownFaceAgain({
  161. userVisitorListDetailId: this.data.regularList.userVisitorListDetailId
  162. }).then(res => {
  163. if (res.code === 200) {
  164. wx.showToast({
  165. title: "下发成功!",
  166. icon: "none"
  167. });
  168. } else {
  169. wx.showToast({
  170. title: res.msg,
  171. icon: "none"
  172. });
  173. }
  174. });
  175. }, 5000),
  176. // 生成二维码
  177. creatQrCode(id) {
  178. // wx.showLoading({
  179. // title: '加载中...',
  180. // })
  181. let that = this;
  182. new QRCode("myQrcode", {
  183. text: `HHFKJ?userId=$123&timestamp=${this.data.dateTime}`,
  184. width: 176,
  185. //canvas 画布的宽
  186. height: 176,
  187. //canvas 画布的高
  188. padding: 0,
  189. // 生成二维码四周自动留边宽度,不传入默认为0
  190. correctLevel: QRCode.CorrectLevel.L,
  191. // 二维码可辨识度
  192. callback: res => {
  193. //工具回调数据
  194. // 接下来就可以直接调用微信小程序的api保存到本地或者将这张二维码直接画在海报上面去,看各自需求
  195. // wx.hideLoading()
  196. //将图片路劲放入data中,显示在wxml的image标签上
  197. console.log(res);
  198. that.setData({
  199. qrCode: res.path
  200. });
  201. }
  202. });
  203. },
  204. // 获取人脸入库的流水号
  205. getUniqueId() {
  206. userCreate({
  207. certType: 'IDENTITY_CARD',
  208. certNo: app.data.userInfo.idNumber,
  209. certName: app.data.userInfo.username,
  210. phone: app.data.userInfo.phone,
  211. avatar: app.data.userInfo.avatar
  212. }).then((res) => {
  213. if(res.data && !res.data.uniqueId) {
  214. // uniqueId为空,表示已入库
  215. this.setData({
  216. uniqueId: null
  217. })
  218. } else {
  219. this.setData({
  220. uniqueId: res.data.uniqueId
  221. })
  222. }
  223. })
  224. },
  225. /**
  226. * 生命周期函数--监听页面加载
  227. */
  228. onLoad: function (options) {
  229. this.creatQrCode()
  230. if (options && options.isRegular) {
  231. this.setData({
  232. isRegular: true
  233. })
  234. } else {
  235. this.getUniqueId()
  236. }
  237. this.data.regularList = JSON.parse(options.list)
  238. this.userWhiteGetSnList();
  239. },
  240. /**
  241. * 生命周期函数--监听页面初次渲染完成
  242. */
  243. onReady: function () {
  244. let {
  245. regularList
  246. } = this.data;
  247. this.setData({
  248. regularList
  249. });
  250. },
  251. /**
  252. * 生命周期函数--监听页面显示
  253. */
  254. onShow: function () {
  255. this.setData({
  256. language: app.data.language
  257. });
  258. },
  259. /**
  260. * 生命周期函数--监听页面隐藏
  261. */
  262. onHide: function () {},
  263. /**
  264. * 生命周期函数--监听页面卸载
  265. */
  266. onUnload: function () {},
  267. /**
  268. * 页面相关事件处理函数--监听用户下拉动作
  269. */
  270. onPullDownRefresh: function () {},
  271. /**
  272. * 页面上拉触底事件的处理函数
  273. */
  274. onReachBottom: function () {},
  275. /**
  276. * 用户点击右上角分享
  277. */
  278. onShareAppMessage: function () {},
  279. antmoveAction: function () {
  280. //执行时动态赋值,请勿删除
  281. }
  282. });