10.10综合交易所原始源码-管理后台
1
admin
2026-01-07 e1e694369dabf557615669ce2f71e9af70277ff6
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<template>
  <el-dialog
    :title = "googleAuthBind?'解绑谷歌验证器':'绑定谷歌验证器'"
    :visible.sync="visible"
    :append-to-body="true">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="120px">
      <div class="gogTop">
        <div v-if="!getInput" class="gogRefresgh" @click="getGoogleAuthSecret()"><i class="el-icon-refresh"></i></div>
      </div>
      <el-form-item v-if="getInput && !googleAuthBind" label="密钥"  style="position:relative">
        <el-input type="number"  :disabled="true" placeholder="请点击右侧 生成密钥和二维码"></el-input>
        <span class="maTreButton" @click="getGoogleAuthSecret()">生成密钥和二维码</span>
      </el-form-item>
      <el-form-item v-show="!getInput" label="密钥"  style="position:relative">
        <el-input type="text"  :disabled="true" v-model="dataForm.secret"></el-input>
        <el-button class="spaButton" type="button"
          v-clipboard:copy="dataForm.secret"  
          v-clipboard:success="onCopy" 
          v-clipboard:error="onError">
          复制
           </el-button>
      </el-form-item>
      <div v-show="!getInput" class="qrCode">
        <img :src=gleimg alt="">
      </div>
      <el-form-item v-if="!googleAuthBind" label="谷歌验证" prop="code">
        <el-input type="number" placeholder="请输入谷歌验证码" v-model="dataForm.code"></el-input>
      </el-form-item>
      <el-form-item label="超级谷歌验证码" prop="rootGoogleAuthCode">
        <el-input type="number" placeholder="请输入超级谷歌验证码" v-model="dataForm.rootGoogleAuthCode"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
  import { Debounce } from '@/utils/debounce'
  import { encrypt } from '@/utils/crypto'
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          password: '',
          newPassword: '',
          urlencoded:'',
          rootGoogleAuthCode:'',
          code:'',
          secret:'',//谷歌密钥
        },
        googleAuthBind:'',//系统用户是否绑定谷歌验证器
        getInput:true,
        gleimg:'',
        gogleUs:'',//用户列表进入
        dataRule: {
          code: [
            { required: true, message: '谷歌验证码不能为空', trigger: 'blur' },
          ],
          rootGoogleAuthCode: [
            { required: true, message: '超级谷歌验证码不能为空', trigger: 'blur' },
          ],
        },
        data:{}
      }
    },
    computed: {
      userName: {
        get () { return this.$store.state.user.name }
      },
      mainTabs: {
        get () { return this.$store.state.common.mainTabs },
        set (val) { this.$store.commit('common/updateMainTabs', val) }
      }
    },
    created(){
      console.log(this.googleAuthBind)
    },
    methods: {
      // 初始化
      init (googleAuthBind,id,data) {
        this.visible = true
        this.gogleUs = id
        this.googleAuthBind = googleAuthBind
        this.data = {...data};
        this.$nextTick(() => {
          this.getInput = true
          this.$refs['dataForm'].resetFields()
        })
      },
      // 表单提交
      dataFormSubmit: Debounce(function () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            if(this.googleAuthBind){ //解绑
              this.$http({
                url: this.$http.adornUrl('/agent/unbindGoogleAuthCode'),
                method: 'post',
                data: this.$http.adornData({
                  'rootGoogleAuthCode': this.dataForm.rootGoogleAuthCode,
                  'id': this.gogleUs,
                })
              }).then(({data}) => {
                this.$message({
                  message: '解绑成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              })
            }else{
                this.$http({
                url: this.$http.adornUrl('/agent/bindGoogleAuthCode'),
                method: 'post',
                data: this.$http.adornData({
                  'googleAuthCode': this.dataForm.code,
                  'id':this.gogleUs,
                  'rootGoogleCode':this.dataForm.rootGoogleAuthCode,
                  'googleAuthSecret': this.dataForm.secret
                })
              }).then(({data}) => {
                if(data.code==0){
                  this.$message({
                    message: '绑定成功',
                    type: 'success',
                    duration: 1500,
                    onClose: () => {
                      this.visible = false
                      this.$emit('refreshDataList')
                    }
                  })
                }else{
                  this.$message({
                    message: data.msg || "绑定失败",
                    type: 'error',
                    duration: 1500,
                    onClose: () => {
                      this.visible = false
                      this.$emit('refreshDataList')
                    }
                  })
                }
                
              })
            }
 
          }
        })
      }),
      //获取密钥
      getGoogleAuthSecret () {         
            this.$http({
              url: this.$http.adornUrl('/getLoginGoogleAuthSecret'),
              method: 'get',
              params: this.$http.adornParams(Object.assign({
                name:this.data.username || this.data.userName
              }))
            }).then(({data}) => {
              if(data.code == 0){
                this.getInput= false
                this.dataForm.secret = data.data.googleAuthSecret
                this.gleimg = data.data.googleAuthImg
                this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
              })
              }else{
                this.$message({
                message: '生成失败',
                type: 'error',
                duration: 1500,
              })
              }
            })      
      },
      onCopy: function (e) {
        this.$message({
                message: '复制成功',
                type: 'success',
              })
    },
    onError: function (e) {
      this.$message({
                message: '复制失败',
                type: 'error',
              })
    }
    }
  }
</script>
<style scoped>
.gogText{
  float: left;
}
.gogRefresgh{
  float: right;
  cursor: pointer;
}
.el-icon-refresh:hover{
  color: #02A1E9;
}
.gogTop{
  overflow: hidden;
    padding: 0 15px;
    height: 43px;
}
.maTreButton{
  position: absolute;
  width: 123px;
  right: 10px;
  color: #02A1E9;
  cursor: pointer;
}
.maTreButton:hover{
  color: rgb(59, 226, 184);
}
.qrCode{
  width: 219px;
  height: 228px;
  border: 1px solid #e1e4eb;
  margin: 0 auto;
  margin-bottom: 20px;
}
.spaButton{
  position: absolute;
  right: 2px;
  border: none;
  background: #eff2f5;
  color: #02A1E9;
}
</style>