saoCode.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <!--扫描二维码页面-->
  2. <template>
  3. <view id="saoCode">
  4. <web-view :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. chemicalAioIdentityScanLogin
  13. } from '@/api/basicsModules/index.js'
  14. export default {
  15. name: "saoCode",
  16. data() {
  17. return {
  18. baseUrl: config.base_url,
  19. code: "",
  20. type: "",
  21. }
  22. },
  23. onLoad(option) {
  24. let self = this;
  25. if (option.q) {
  26. let text = decodeURIComponent(option.q)
  27. let list = text.split("?")[1].split("&");
  28. let codeData = {};
  29. list.forEach((item) => {
  30. codeData[item.split("=")[0]] = item.split("=")[1];
  31. })
  32. if (!uni.getStorageSync('token')) {
  33. uni.setStorageSync('codeData', codeData);
  34. uni.redirectTo({
  35. url: '/pages/login/login',
  36. });
  37. } else {
  38. if (codeData.type == 11) {
  39. //化学品终端-扫码登录
  40. this.chemicalAioIdentityScanLogin(codeData.code, codeData.subId, codeData.macId);
  41. }
  42. }
  43. } else {
  44. let codeData = uni.getStorageSync('codeData');
  45. uni.removeStorageSync('codeData');
  46. if (codeData.type == 11) {
  47. //化学品终端-扫码登录
  48. this.chemicalAioIdentityScanLogin(codeData.code, codeData.subId, codeData.macId);
  49. }
  50. }
  51. },
  52. mounted() {
  53. },
  54. methods: {
  55. //化学品终端-扫码登录
  56. async chemicalAioIdentityScanLogin(code, subId, macId) {
  57. const {
  58. data
  59. } = await chemicalAioIdentityScanLogin({
  60. code: code,
  61. subId: subId,
  62. userId: uni.getStorageSync('userId'),
  63. macId: macId
  64. });
  65. uni.showToast({
  66. mask: true,
  67. icon: "none",
  68. position: "center",
  69. title: data.message,
  70. duration: 2000
  71. });
  72. setTimeout(function() {
  73. uni.redirectTo({
  74. url: '/pages/mine/mine',
  75. });
  76. }, 2000);
  77. },
  78. },
  79. }
  80. </script>
  81. <style lang="stylus" scoped>
  82. #saoCode {
  83. overflow scroll
  84. }
  85. </style>