saoCode.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <!--扫描二维码页面-->
  2. <template>
  3. <view id="saoCode">
  4. <web-view v-if="webViewType" :src="baseUrl+'admin/#/codeHtml?code='+code+'&type='+type"></web-view>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. config
  10. } from '@/api/request/config.js'
  11. import {
  12. chemicalAioVerifyScanLogin,
  13. chemicalAioVerifyAppletLogin,
  14. laboratoryAppletGetSubDetailInfo
  15. } from '@/pages/api/index.js'
  16. export default {
  17. name: "saoCode",
  18. data() {
  19. return {
  20. webViewType: false,
  21. baseUrl: config.base_url,
  22. code: "",
  23. type: "",
  24. }
  25. },
  26. onLoad(option) {
  27. console.log('option',option)
  28. let self = this;
  29. if (option.q) {
  30. let text = decodeURIComponent(option.q)
  31. let list = text.split("?")[1].split("&");
  32. let codeData = {};
  33. list.forEach((item) => {
  34. codeData[item.split("=")[0]] = item.split("=")[1];
  35. })
  36. if (!uni.getStorageSync('token')) {
  37. uni.setStorageSync('codeData', codeData);
  38. uni.redirectTo({
  39. url: '/pages/login/login',
  40. });
  41. } else {
  42. //二维码功能识别
  43. this.codeRecognize(codeData);
  44. }
  45. } else {
  46. let codeData = uni.getStorageSync('codeData');
  47. uni.removeStorageSync('codeData');
  48. //二维码功能识别
  49. this.codeRecognize(codeData);
  50. }
  51. },
  52. mounted() {
  53. },
  54. methods: {
  55. //二维码功能识别
  56. codeRecognize(codeData) {
  57. console.log('codeData',codeData)
  58. if (!codeData.type) {
  59. //非功能二维码提示
  60. uni.showToast({
  61. mask: true,
  62. icon: "none",
  63. position: "center",
  64. title: '请扫描正确的小程序二维码',
  65. duration: 2000
  66. });
  67. setTimeout(function() {
  68. uni.redirectTo({
  69. url: '/pages/views/home/home',
  70. });
  71. }, 2000);
  72. } else {
  73. if (codeData.type == 11) {
  74. //化学品终端-扫码登录
  75. this.chemicalAioVerifyScanLogin(codeData.code, codeData.subId, codeData.macId);
  76. } else if (codeData.type == 12) {
  77. //化学品终端-双人认证
  78. this.chemicalAioVerifyAppletLogin(codeData.doorId, codeData.subId, codeData.macId, codeData.code);
  79. } else if (codeData.type == 7) {
  80. //培训课程
  81. uni.redirectTo({
  82. url: '/pages/views/pages_patrolInspector/courseQRcode?code=' + codeData.code,
  83. });
  84. } else if (codeData.type == 8) {
  85. //化学品柜
  86. uni.redirectTo({
  87. url: '/pages/views/pages_patrolInspector/chemicalCabinetQRcode?code=' + codeData.code,
  88. });
  89. } else if (codeData.type == 9) {
  90. //化学品
  91. uni.redirectTo({
  92. url: '/pages/views/pages_patrolInspector/chemicalDetail?code=' + codeData.code,
  93. });
  94. } else if (codeData.type == 1 || codeData.type == 2 || codeData.type == 3) {
  95. //1.MSDS说明书 2.安全制度 3.危险源详情
  96. this.$set(this, 'code', codeData.code);
  97. this.$set(this, 'type', codeData.type);
  98. this.$set(this, 'webViewType', true);
  99. } else if (codeData.type == 5) {
  100. //实验室详情
  101. this.laboratoryAppletGetSubDetailInfo(codeData.code);
  102. } else if (codeData.type == 10) {
  103. uni.showToast({
  104. mask: true,
  105. icon: "none",
  106. position: "center",
  107. title: '专项检查功能请从安全检查进入',
  108. duration: 2000
  109. });
  110. setTimeout(function() {
  111. uni.redirectTo({
  112. url: '/pages/views/home/home',
  113. });
  114. }, 2000);
  115. } else {
  116. uni.showToast({
  117. mask: true,
  118. icon: "none",
  119. position: "center",
  120. title: '二维码异常,请联系管理员',
  121. duration: 2000
  122. });
  123. setTimeout(function() {
  124. uni.redirectTo({
  125. url: '/pages/views/home/home',
  126. });
  127. }, 2000);
  128. }
  129. }
  130. },
  131. //化学品终端-扫码登录
  132. async chemicalAioVerifyScanLogin(code, subId, macId) {
  133. const {
  134. data
  135. } = await chemicalAioVerifyScanLogin({
  136. code: code,
  137. subId: subId,
  138. userId: uni.getStorageSync('userId'),
  139. macId: macId
  140. });
  141. uni.showToast({
  142. mask: true,
  143. icon: "none",
  144. position: "center",
  145. title: data.message,
  146. duration: 2000
  147. });
  148. setTimeout(function() {
  149. uni.redirectTo({
  150. url: '/pages/views/mine/mine',
  151. });
  152. }, 2000);
  153. },
  154. //化学品终端-双人认证
  155. async chemicalAioVerifyAppletLogin(doorId, subId, macId, code) {
  156. console.log('doorId',doorId)
  157. console.log('subId',subId)
  158. console.log('macId',macId)
  159. console.log('code',code)
  160. const {
  161. data
  162. } = await chemicalAioVerifyAppletLogin({
  163. doorId: doorId,
  164. subId: subId,
  165. macId: macId,
  166. code: code,
  167. userId: uni.getStorageSync('userId'),
  168. });
  169. console.log('data',data)
  170. uni.showToast({
  171. mask: true,
  172. icon: "none",
  173. position: "center",
  174. title: data.message,
  175. duration: 2000
  176. });
  177. setTimeout(function() {
  178. uni.redirectTo({
  179. url: '/pages/views/mine/mine',
  180. });
  181. }, 2000);
  182. },
  183. //实验室详情-跳转
  184. async laboratoryAppletGetSubDetailInfo(infoId) {
  185. const {
  186. data
  187. } = await laboratoryAppletGetSubDetailInfo({
  188. infoId: infoId
  189. });
  190. if (data.code == 200) {
  191. uni.redirectTo({
  192. url: '/pages_manage/views/laboratory/infoPage?infoData=' + encodeURIComponent(JSON.stringify(data.data))+'&saoCode=true'
  193. });
  194. }
  195. },
  196. },
  197. }
  198. </script>
  199. <style lang="stylus" scoped>
  200. #saoCode {
  201. overflow scroll
  202. }
  203. </style>