| | |
| | | <template> |
| | | <div class="s-licence"> |
| | | <div class="licence" @click="dialogVisible = true"> |
| | | <span>{{tip}}</span> |
| | | <span>{{ tip }}</span> |
| | | </div> |
| | | <el-dialog |
| | | title="授权管理" |
| | |
| | | <el-form-item label="手机号码" prop="phone"> |
| | | <el-input v-model="registe.phone" size="small" style="max-width:420px"></el-input> |
| | | </el-form-item> |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | @click="getRegsiterCode()" |
| | | style="float:right" |
| | | >提交</el-button> |
| | | <el-button type="primary" size="small" @click="getRegsiterCode()" style="float:right">提交</el-button> |
| | | </el-form> |
| | | </el-tab-pane> |
| | | <el-tab-pane label="认证" name="second" style="text-align:left" :disabled="!regCode.length"> |
| | | <div v-show="!showQrcode" class="auth-box"> |
| | | <span style="line-height: 30px;">注册码</span> |
| | | <a href="#" @click="showQrcode=true" style="font-size: 10px;"> 查看二维码</a> |
| | | <a href="#" @click="showQrcode = true" style="font-size: 10px;"> 查看二维码</a> |
| | | <el-input type="textarea" :readonly="true" :rows="4" placeholder v-model="regCode"></el-input> |
| | | <span style="line-height: 30px;">授权码</span> |
| | | <el-input type="textarea" :rows="5" placeholder="请输入授权码" v-model="license"></el-input> |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | @click="submitLicence()" |
| | | style="margin-top: 15px;float: right;" |
| | | >提交</el-button> |
| | | <el-button type="primary" size="small" @click="submitLicence()" style="margin-top: 15px;float: right;" |
| | | >提交</el-button |
| | | > |
| | | </div> |
| | | <div v-show="showQrcode" style="text-align:right"> |
| | | <vue-qrcode :text="regCode" style="margin-left: 115px;"></vue-qrcode> |
| | | <a href="#" @click="showQrcode=false">返回</a> |
| | | <a href="#" @click="showQrcode = false">返回</a> |
| | | </div> |
| | | </el-tab-pane> |
| | | </el-tabs> |
| | |
| | | <p>用户名称:{{ registe.company }}</p> |
| | | <p>电子邮箱:{{ registe.email }}</p> |
| | | <p> |
| | | 授权期限:{{ '永久有效' }} |
| | | 授权期限:{{ registe.expireTime | TimeFormat }} |
| | | <span v-show="expired" style="color:red">已过期</span> |
| | | </p> |
| | | <el-divider></el-divider> |
| | |
| | | <b>授权码</b> |
| | | </p> |
| | | <el-input type="textarea" :readonly="true" :rows="4" placeholder v-model="licenseCode"></el-input> |
| | | <el-button |
| | | type="primary" |
| | | size="small" |
| | | @click="rereg()" |
| | | style="margin-top: 15px;float: right;" |
| | | >重新注册</el-button> |
| | | <el-button type="primary" size="small" @click="rereg()" style="margin-top: 15px;float: right;" |
| | | >重新注册</el-button |
| | | > |
| | | </div> |
| | | </div> |
| | | </el-dialog> |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { showLicence, getRegCode, updateLicence } from './api.ts' |
| | | import { isPhone, validEmail } from '../../scripts/validate.ts' |
| | | import VueQrcode from 'vue-qrcode-component' |
| | | import { showLicence, getRegCode, updateLicence } from "./api.ts" |
| | | import { isPhone, validEmail } from "../../scripts/validate.ts" |
| | | import VueQrcode from "vue-qrcode-component" |
| | | |
| | | export default { |
| | | name: 'LicenceManage', |
| | | name: "LicenceManage", |
| | | components: { |
| | | VueQrcode |
| | | }, |
| | | data() { |
| | | return { |
| | | registe: { |
| | | company: '', |
| | | email: '', |
| | | phone: '' |
| | | company: "", |
| | | email: "", |
| | | phone: "", |
| | | expireTime: 0 |
| | | }, |
| | | dialogVisible: false, |
| | | authStatus: '', |
| | | active: 'first', |
| | | regCode: '', |
| | | license: '', |
| | | licenseCode: '', |
| | | expireTime: '', |
| | | authStatus: "", |
| | | active: "first", |
| | | regCode: "", |
| | | license: "", |
| | | licenseCode: "", |
| | | expired: false, |
| | | showQrcode: false, |
| | | tip: '', |
| | | tip: "", |
| | | rules: { |
| | | email: [ |
| | | { |
| | | required: true, |
| | | message: '请输入正确的邮箱地址', |
| | | trigger: 'change' |
| | | message: "请输入正确的邮箱地址", |
| | | trigger: "change" |
| | | }, |
| | | { validator: validEmail, trigger: 'blur' } |
| | | { validator: validEmail, trigger: "blur" } |
| | | ], |
| | | phone: [ |
| | | { |
| | | required: true, |
| | | message: '请输入正确的手机号码', |
| | | trigger: 'change' |
| | | message: "请输入正确的手机号码", |
| | | trigger: "change" |
| | | }, |
| | | { validator: isPhone, trigger: 'blur' } |
| | | { validator: isPhone, trigger: "blur" } |
| | | ], |
| | | company: [ |
| | | { |
| | | required: true, |
| | | message: '公司名称不能为空', |
| | | trigger: 'change' |
| | | message: "公司名称不能为空", |
| | | trigger: "change" |
| | | } |
| | | ] |
| | | } |
| | | } |
| | | }, |
| | | filters: { |
| | | timeFormat(timestamp) { |
| | | TimeFormat(timestamp) { |
| | | var now = new Date() |
| | | var currentYear = now.getFullYear() |
| | | |
| | | var date = new Date(timestamp * 1000) //时间戳为10位需*1000,时间戳为13位的话不需乘1000 |
| | | var Y = date.getFullYear() + '-' |
| | | var M = |
| | | (date.getMonth() + 1 < 10 |
| | | ? '0' + (date.getMonth() + 1) |
| | | : date.getMonth() + 1) + '-' |
| | | var D = |
| | | date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ' |
| | | var h = |
| | | date.getHours() < 10 |
| | | ? '0' + date.getHours() + ':' |
| | | : date.getHours() + ':' |
| | | var m = |
| | | date.getMinutes() < 10 |
| | | ? '0' + date.getMinutes() + ':' |
| | | : date.getMinutes() + ':' |
| | | var s = |
| | | date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds() |
| | | return Y + M + D + h + m + s |
| | | var Y = date.getFullYear() |
| | | var M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1 |
| | | var D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate() |
| | | |
| | | if (Y - currentYear > 5) { |
| | | return "永久有效" |
| | | } |
| | | |
| | | return Y + "-" + M + "-" + D |
| | | } |
| | | }, |
| | | mounted() { |
| | |
| | | let rsp = await showLicence() |
| | | if (rsp && rsp.success) { |
| | | if (rsp.data.License.Expires === 0) { |
| | | this.authStatus = 'unregistered' |
| | | this.tip = '未授权, 点击注册' |
| | | this.authStatus = "unregistered" |
| | | this.tip = "未授权, 点击注册" |
| | | } else { |
| | | this.authStatus = 'registered' |
| | | this.authStatus = "registered" |
| | | this.registe.company = rsp.data.License.RegCode.Company |
| | | this.registe.email = rsp.data.License.RegCode.Email |
| | | this.registe.phone = rsp.data.License.RegCode.Phone |
| | | this.registe.expireTime = rsp.data.License.Expires |
| | | console.log(this.registe.expireTime) |
| | | |
| | | this.licenseCode = rsp.data.License.LicenseCode |
| | | this.expireTime = rsp.data.License.Expires |
| | | this.expired = rsp.data.Expired |
| | | if (this.expired) { |
| | | this.tip = '授权已过期' |
| | | this.tip = "授权已过期" |
| | | } else { |
| | | this.tip = '已授权' |
| | | this.tip = "已授权" |
| | | } |
| | | } |
| | | } |
| | | this.showBtn = true |
| | | }, |
| | | getRegsiterCode() { |
| | | this.$refs['reginfo'].validate(valid => { |
| | | this.$refs["reginfo"].validate((valid) => { |
| | | if (valid) { |
| | | getRegCode(this.registe).then(rsp => { |
| | | getRegCode(this.registe).then((rsp) => { |
| | | if (rsp && rsp.success) { |
| | | this.regCode = rsp.data |
| | | this.active = 'second' |
| | | this.active = "second" |
| | | } |
| | | }) |
| | | } |
| | |
| | | }, |
| | | submitLicence() { |
| | | updateLicence({ license: this.license }) |
| | | .then(rsp => { |
| | | .then((rsp) => { |
| | | if (rsp && rsp.success) { |
| | | this.$notify({ |
| | | type: 'success', |
| | | message: '更新授权成功' |
| | | type: "success", |
| | | message: "更新授权成功" |
| | | }) |
| | | |
| | | this.authStatus = 'registered' |
| | | this.authStatus = "registered" |
| | | this.getLicence() |
| | | } |
| | | }) |
| | | .catch(err => { |
| | | .catch((err) => { |
| | | this.$notify({ |
| | | type: 'error', |
| | | message: '授权更新失败' |
| | | type: "error", |
| | | message: "授权更新失败" |
| | | }) |
| | | }) |
| | | }, |
| | | rereg() { |
| | | this.active = 'first' |
| | | this.authStatus = 'unregistered' |
| | | this.active = "first" |
| | | this.authStatus = "unregistered" |
| | | } |
| | | } |
| | | } |