saoCode.vue 5.0 KB

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