zouyu
2023-11-17 d8ac6057eaad648687699e25a575f3b7b8c1b102
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<template>
  <div class="login-new-container">
    <div class="login-new-left"></div>
    <div class="login-new-right">
      <div class="login-new-weaper">
        <h1>{{ sysTitle && sysTitle != 'null' ? sysTitle : 'MES' }}</h1>
        <div class="login-new-border"></div>
        <div class="login-new-main">
          <userLogin v-if="activeName === 'user'" />
          <codeLogin v-else-if="activeName === 'code'" />
        </div>
      </div>
    </div>
    <top-color v-show="false" />
  </div>
</template>
<script>
import { getObj } from '@/api/admin/sys-public-param'
import { fetchList } from '@/api/admin/tenant'
import userLogin from './userlogin'
import codeLogin from './codelogin'
import thirdLogin from './thirdlogin'
import { mapGetters } from 'vuex'
import { getStore, setStore } from '@/util/store'
import topColor from '@/page/index/top/top-color'
import { sysParam } from '../../config/sysParam' // 系统参数
import { LoginByMSL } from '@/api/login'
 
export default {
  name: 'Login',
  components: {
    userLogin,
    codeLogin,
    thirdLogin,
    topColor
  },
  data() {
    return {
      sysTitle: 'MES',
      tenantList: [],
      active: '',
      activeName: 'user',
      socialForm: {}
    }
  },
  watch: {
    $route: {
      handler() {
        const params = this.$route.query
        if (this.validatenull(params.state) && this.validatenull(params.code))
          return
 
        this.socialForm.state = params.state
        this.socialForm.code = params.code
 
        const loading = this.$loading({
          lock: true,
          text: '登录中,请稍后。。。',
          spinner: 'el-icon-loading'
        })
        this.$store
          .dispatch('LoginBySocial', this.socialForm)
          .then(() => {
            loading.close()
            this.$router.push({ path: this.tagWel.value })
          })
          .catch(() => {
            loading.close()
          })
      },
      immediate: true
    }
  },
  created() {
    this.getSysTitle()
  },
  mounted() {
    const _that = this
    $.ajax({
      type: 'get',
      url: 'http://127.0.0.1:15211/LocalUnique',
      /* headers: {
                'Content-Type': 'text/xml;charset=utf-8'
              }, */
      // data: requireData,
      success: function(response) {
        const resultData = JSON.parse(
          response
            .replace(/\r/g, '')
            .replace(/\n/g, '')
            .replace(/\s*/g, '')
        )
        const username = resultData[0].ID
        const password = resultData[0].Unique
        _that.$store
          .dispatch('LoginByMSL', { username: username, password: password })
          .then(() => {
            _that.$router.push({ path: _that.tagWel.value })
          })
      },
      error: function(XMLHttpRequest, textStatus, errorThrown) {
        console.log('访问马上聊出错')
      }
    })
  },
  computed: {
    ...mapGetters(['website', 'tagWel'])
  },
  methods: {
    handleCommand(command) {
      setStore({ name: 'tenantId', content: command })
    },
    getTenantList() {
      fetchList().then((response) => {
        this.tenantList = response.data.data
      })
    },
    getSysTitle() {
      getObj(sysParam.SYSTEM_LOGO_TITLE).then((response) => {
        this.sysTitle = response.data.data
        localStorage.setItem('SYSTEM_LOGO_TITLE', this.sysTitle)
      })
    },
    watermark() {
      const text = ''
      const canvas = document.createElement('canvas')
      canvas.width = '500'
      canvas.height = '200'
      const ctx = canvas.getContext('2d')
      ctx.clearRect(0, 0, 200, 200) // 绘制之前画布清除
      ctx.font = '30px 黑体'
      ctx.rotate((-20 * Math.PI) / 180) // 为了实现水印倾斜效果,旋转画布坐标系
      ctx.fillStyle = 'rgba(100,100,100,0.15)' // 画笔颜色
      ctx.fillText(text, -20, 200) // 书写的内容及位置
      ctx.rotate('20*Math.PI/180') // 坐标系还原,如果后续没有其他操作,这一步可以省略
      // 将canvas的内容转换为base64编码
      const data = canvas.toDataURL('image/png', 1) // 1表示质量(无损压缩)
 
      window.onload = () => {
        const background = 'url(' + data + ') repeat'
        var watermark = document.createElement('div')
        watermark.style.width = '100%'
        watermark.style.height = '100%'
        watermark.style.position = 'fixed'
        watermark.style.left = '0'
        watermark.style.top = '0'
        watermark.style.pointerEvents = 'none'
        watermark.style.background = background
        watermark.style.zIndex = '9999'
        document.body.append(watermark)
      }
    }
  }
}
</script>
 
<style lang="scss">
@import '@/styles/login-new.scss';
</style>