|
@@ -0,0 +1,73 @@
|
|
|
+<template>
|
|
|
+ <el-dialog :visible.sync="localShow" width="350px" modal-append-to-body append-to-body>
|
|
|
+ <div class="fx-column fx-cen-cen pt30 pb30 bg-white gap-20">
|
|
|
+ <div class="fx-row ai-cen gap-20">
|
|
|
+ <el-image :src="img" style="height: 48px;" />
|
|
|
+ <i class="el-icon-refresh f24" @click="loadCodeImage(true)" />
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-input v-model="code" placeholder="请输入上图结果" />
|
|
|
+ </div>
|
|
|
+ <el-button type="primary" @click="handleConfirm">确认</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getCodeImg } from '@/api/login'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'CodeInputPopup',
|
|
|
+ props: {
|
|
|
+ show: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ localShow: this.show || false,
|
|
|
+ img: '',
|
|
|
+ uuid: '',
|
|
|
+ code: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ show: function(val) {
|
|
|
+ this.localShow = val
|
|
|
+ if (val) this.loadCodeImage()
|
|
|
+ },
|
|
|
+ localShow: function(val) {
|
|
|
+ this.$emit('update:show', val)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ loadCodeImage: async function(force) {
|
|
|
+ if (!force && this.uuid && this.img) return
|
|
|
+ const res = await getCodeImg()
|
|
|
+ this.uuid = res.uuid
|
|
|
+ this.img = 'data:image/gif;base64,' + res.img
|
|
|
+ },
|
|
|
+ reset: function() {
|
|
|
+ this.uuid = ''
|
|
|
+ this.img = ''
|
|
|
+ this.code = ''
|
|
|
+ },
|
|
|
+ handleConfirm: function() {
|
|
|
+ if (!this.code) {
|
|
|
+ return this.msgError('请输入验证码')
|
|
|
+ }
|
|
|
+ this.localShow = false
|
|
|
+ const { code, uuid } = this
|
|
|
+ this.$emit('complete', { code, uuid })
|
|
|
+ this.$nextTick(() => this.reset())
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.gap-20 {
|
|
|
+ gap: 20px;
|
|
|
+}
|
|
|
+</style>
|