This commit is contained in:
jr719 2021-04-13 00:40:20 +08:00
parent 5c65f0e0fc
commit 3be98d89b3
3 changed files with 252 additions and 254 deletions

View File

@ -73,22 +73,22 @@ const actions = {
// user logout // user logout
logout({ commit, state, dispatch }) { logout({ commit, state, dispatch }) {
// return new Promise((resolve, reject) => { // return new Promise((resolve, reject) => {
// logout(state.token) // logout(state.token)
// .then(() => { // .then(() => {
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
commit('SET_ROLES', []) commit('SET_ROLES', [])
removeToken() removeToken()
resetRouter() resetRouter()
// reset visited views and cached views // reset visited views and cached views
// to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485 // to fixed https://github.com/PanJiaChen/vue-element-admin/issues/2485
dispatch('tagsView/delAllViews', null, { root: true }) dispatch('tagsView/delAllViews', null, { root: true })
// resolve() // resolve()
// }) // })
// .catch(error => { // .catch(error => {
// reject(error) // reject(error)
// }) // })
// }) // })
}, },

View File

@ -5,8 +5,7 @@
type="primary" type="primary"
style="position:absolute;right:50px;top:120px" style="position:absolute;right:50px;top:120px"
@click="$router.push('/convenience/add')" @click="$router.push('/convenience/add')"
><i class="el-icon-plus" /> 直接建立工单</el-button ><i class="el-icon-plus" /> 直接建立工单</el-button>
>
<div class="title">工单列表</div> <div class="title">工单列表</div>
<div style="margin-bottom:15px;margin-top:15px" /> <div style="margin-bottom:15px;margin-top:15px" />
<el-radio-group v-model="listQuery.phase"> <el-radio-group v-model="listQuery.phase">
@ -16,20 +15,20 @@
<el-radio-button label="PROCESSING">办理中</el-radio-button> <el-radio-button label="PROCESSING">办理中</el-radio-button>
<el-radio-button label="FINISH">已办结</el-radio-button> <el-radio-button label="FINISH">已办结</el-radio-button>
</el-radio-group> </el-radio-group>
<br /> <br>
<br /> <br>
<el-radio-group v-model="listQuery.status"> <el-radio-group v-model="listQuery.status">
<el-radio-button :label="undefined">全部状态</el-radio-button> <el-radio-button :label="undefined">全部状态</el-radio-button>
<el-radio-button label="MINE">我处理</el-radio-button> <el-radio-button label="MINE">我处理</el-radio-button>
<el-radio-button label="FORWARDED">已转交</el-radio-button> <el-radio-button label="FORWARDED">已转交</el-radio-button>
<el-radio-button label="FORWARDED_APPLY" <el-radio-button
>转交超限审批中</el-radio-button label="FORWARDED_APPLY"
> >转交超限审批中</el-radio-button>
<el-radio-button label="SUBMIT_APPLY">已提交审批</el-radio-button> <el-radio-button label="SUBMIT_APPLY">已提交审批</el-radio-button>
<el-radio-button label="WAIT_APPLY">待我审批</el-radio-button> <el-radio-button label="WAIT_APPLY">待我审批</el-radio-button>
</el-radio-group> </el-radio-group>
<br /> <br>
<br /> <br>
</div> </div>
<div class="convenienceList"> <div class="convenienceList">
@ -57,13 +56,13 @@
<p>流水号{{ item.serialNumber }}</p> <p>流水号{{ item.serialNumber }}</p>
<p> <p>
阶段{{ item.phase | phaseFilter }} 阶段{{ item.phase | phaseFilter }}
<i class="icon_timeout" v-if="timers&&timers[index].status !== null"></i> <i v-if="timers&&timers[index].status !== null" class="icon_timeout" />
<span style="color:#ff3000">{{ <span style="color:#ff3000">{{
timers && timers[index].status === null timers && timers[index].status === null
? "" ? ""
: timers&&timers[index].status : timers&&timers[index].status
? "已超时" ? "已超时"
: "即将超时" : "即将超时"
}}</span> }}</span>
</p> </p>
</div> </div>
@ -92,8 +91,7 @@
type="primary" type="primary"
size="mini" size="mini"
@click="handleUpdate(item, 5)" @click="handleUpdate(item, 5)"
>接单</el-button >接单</el-button>
>
</p> </p>
</div> </div>
</div> </div>
@ -187,10 +185,10 @@
<script> <script>
// import Pagination from "@/components/Pagination"; // import Pagination from "@/components/Pagination";
import { list, typeList, update } from "@/api/convenience"; import { list, typeList, update } from '@/api/convenience'
import { parseTime } from "@/utils"; import { parseTime } from '@/utils'
import { staffList } from "@/api/staff"; import { staffList } from '@/api/staff'
import AliOss from "@/components/AliOSS/index.vue"; import AliOss from '@/components/AliOSS/index.vue'
export default { export default {
components: { components: {
@ -200,48 +198,48 @@ export default {
filters: { filters: {
sponsorFilter(status) { sponsorFilter(status) {
const statusMap = { const statusMap = {
SELF: "居民", SELF: '居民',
STAFF: "工作人员" STAFF: '工作人员'
}; }
return statusMap[status]; return statusMap[status]
}, },
phaseFilter(status) { phaseFilter(status) {
const statusMap = { const statusMap = {
PENDING_ORDER: "待接单", PENDING_ORDER: '待接单',
PREREQUISITES: "要件准备中", PREREQUISITES: '要件准备中',
PROCESSING: "办理中", PROCESSING: '办理中',
FINISH: "办结" FINISH: '办结'
}; }
return statusMap[status]; return statusMap[status]
}, },
statusFilter(status) { statusFilter(status) {
const statusMap = { const statusMap = {
MINE: "待我处理", MINE: '待我处理',
FORWARDED: "已转交", FORWARDED: '已转交',
FORWARDED_APPLY: "转交超限审批中", FORWARDED_APPLY: '转交超限审批中',
SUBMIT_APPLY: "提交申请", SUBMIT_APPLY: '提交申请',
WAIT_APPLY: "待审核" WAIT_APPLY: '待审核'
}; }
return statusMap[status]; return statusMap[status]
}, },
typeFilter(status) { typeFilter(status) {
const statusMap = { const statusMap = {
1: "建立工单", 1: '建立工单',
2: "撤销工单", 2: '撤销工单',
3: "沟通", 3: '沟通',
4: "调整工单类别", 4: '调整工单类别',
5: "接单", 5: '接单',
6: "要件齐备", 6: '要件齐备',
7: "办结", 7: '办结',
8: "转交超限审批提交", 8: '转交超限审批提交',
9: "转交超限审批撤销", 9: '转交超限审批撤销',
10: "转交超限审批", 10: '转交超限审批',
11: "发起审批", 11: '发起审批',
12: "撤销审批", 12: '撤销审批',
13: "审批操作", 13: '审批操作',
14: "转交" 14: '转交'
}; }
return statusMap[status]; return statusMap[status]
} }
}, },
data() { data() {
@ -272,140 +270,140 @@ export default {
}, },
msec: 0, msec: 0,
rules: { rules: {
ids: [{ required: true, message: "请选择操作对象", trigger: "change" }] ids: [{ required: true, message: '请选择操作对象', trigger: 'change' }]
}, },
timers: undefined, timers: undefined,
timersInterval: undefined timersInterval: undefined
}; }
}, },
watch: { watch: {
"listQuery.phase": { 'listQuery.phase': {
// //
handler(val) { handler(val) {
this.listQuery.phase = val; this.listQuery.phase = val
this.getList(); this.getList()
}, },
deep: true // true deep: true // true
}, },
"listQuery.status": { 'listQuery.status': {
// //
handler(val) { handler(val) {
this.listQuery.status = val; this.listQuery.status = val
this.getList(); this.getList()
}, },
deep: true // true deep: true // true
} }
}, },
created() { created() {
this.getList(); this.getList()
this.getStaffList(); this.getStaffList()
}, },
methods: { methods: {
getList() { getList() {
this.listLoading = true; this.listLoading = true
list(this.listQuery).then(res => { list(this.listQuery).then(res => {
this.list = res.d.records; this.list = res.d.records
this.listLoading = false; this.listLoading = false
clearInterval(this.timersInterval); clearInterval(this.timersInterval)
const tempData = res.d.records; const tempData = res.d.records
const now = Date.parse(new Date()).toString() / 1000; const now = Date.parse(new Date()).toString() / 1000
const arr = []; const arr = []
tempData.map((item, index) => { tempData.map((item, index) => {
let msec = []; let msec = []
let obj = {}; let obj = {}
switch (item.phase) { switch (item.phase) {
case "PENDING_ORDER": case 'PENDING_ORDER':
// //
msec = now - item.createDate; msec = now - item.createDate
obj = { obj = {
time: msec, time: msec,
phase: item.phase, phase: item.phase,
status: null status: null
}; }
arr.push(obj); arr.push(obj)
break; break
case "PREREQUISITES": case 'PREREQUISITES':
// //
msec = now - item.createDate - item.acceptanceTime; msec = now - item.createDate - item.acceptanceTime
obj = { obj = {
time: msec, time: msec,
phase: item.phase, phase: item.phase,
status: null status: null
}; }
arr.push(obj); arr.push(obj)
break; break
case "PROCESSING": case 'PROCESSING':
// //
msec = msec =
now - now -
item.createDate - item.createDate -
item.acceptanceTime - item.acceptanceTime -
item.prerequisitesTime; item.prerequisitesTime
obj = { obj = {
time: msec, time: msec,
phase: item.phase, phase: item.phase,
status: null status: null
}; }
arr.push(obj); arr.push(obj)
break; break
case "FINISH": case 'FINISH':
msec = msec =
item.acceptanceTime + item.prerequisitesTime + item.finishTime; item.acceptanceTime + item.prerequisitesTime + item.finishTime
obj = { obj = {
time: msec, time: msec,
phase: item.phase, phase: item.phase,
status: null status: null
}; }
arr.push(obj); arr.push(obj)
// //
break; break
default: default:
break; break
} }
}); })
this.timersInterval = setInterval(() => { this.timersInterval = setInterval(() => {
if (arr.length > 0) { if (arr.length > 0) {
arr.map((item, index) => { arr.map((item, index) => {
if (item.phase !== "FINISH") { if (item.phase !== 'FINISH') {
item.time++; item.time++
if (this.list[index].phase === "PENDING_ORDER") { if (this.list[index].phase === 'PENDING_ORDER') {
if (item.status == null) { if (item.status == null) {
if (item.time > 57600) { if (item.time > 57600) {
item.status = false; item.status = false
if (item.time >= 86400) { if (item.time >= 86400) {
item.status = true; item.status = true
} }
} }
} }
} }
if (this.list[index].phase === "PROCESSING") { if (this.list[index].phase === 'PROCESSING') {
if (item.status == null) { if (item.status == null) {
// &&item.time<this.list[index].eventType.commitmentTimeLimit // &&item.time<this.list[index].eventType.commitmentTimeLimit
if ( if (
item.time > item.time >
this.list[index].eventType.timeoutReminder * 3600 this.list[index].eventType.timeoutReminder * 3600
) { ) {
item.status = false; item.status = false
if ( if (
item.time >= item.time >=
this.list[index].eventType.commitmentTimeLimit * 3600 this.list[index].eventType.commitmentTimeLimit * 3600
) { ) {
item.status = true; item.status = true
} }
} }
} }
} }
} }
}); })
} }
this.timers = arr; this.timers = arr
}, 1000); }, 1000)
}); })
}, },
getTypeList() { getTypeList() {
typeList().then(res => { typeList().then(res => {
// console.log(res); // console.log(res);
}); })
}, },
getStaffList() { getStaffList() {
staffList().then(res => { staffList().then(res => {
@ -413,10 +411,10 @@ export default {
const obj = { const obj = {
label: item.name, label: item.name,
value: item.id value: item.id
}; }
this.staffOptions.push(obj); this.staffOptions.push(obj)
}); })
}); })
}, },
handleTypeChange() {}, handleTypeChange() {},
resetPayload() { resetPayload() {
@ -428,79 +426,79 @@ export default {
attachmentList: undefined, attachmentList: undefined,
approve: undefined, approve: undefined,
evaluation: undefined evaluation: undefined
}; }
}, },
handleUpdate(row, type) { handleUpdate(row, type) {
this.resetPayload(); this.resetPayload()
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.applyForm.clearValidate(); this.$refs.applyForm.clearValidate()
}); })
this.updateType = type; this.updateType = type
this.payload.id = row.id; this.payload.id = row.id
this.payload.version = row.version; this.payload.version = row.version
this.payload.type = type; this.payload.type = type
switch (type) { switch (type) {
case 5: case 5:
this.applyDialog = true; this.applyDialog = true
break; break
case 6: case 6:
this.applyDialog = true; this.applyDialog = true
break; break
case 11: case 11:
this.applyDialog = true; this.applyDialog = true
break; break
case 13: case 13:
this.applyDialog = true; this.applyDialog = true
break; break
case 14: case 14:
this.applyDialog = true; this.applyDialog = true
break; break
default: default:
this.updateData(); this.updateData()
break; break
} }
}, },
updateData() { updateData() {
update(this.payload).then(res => { update(this.payload).then(res => {
if (res.c === 200) { if (res.c === 200) {
this.$notify.success("操作成功"); this.$notify.success('操作成功')
this.getList(); this.getList()
} }
}); })
}, },
apply() { apply() {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.applyForm.validate(valid => { this.$refs.applyForm.validate(valid => {
if (valid) { if (valid) {
this.updateData(); this.updateData()
this.applyDialog = false; this.applyDialog = false
} }
}); })
}, 100); }, 100)
}, },
handleFilterPhase(phase, event) { handleFilterPhase(phase, event) {
// console.log(event.target.tagName==='SPAN'); // console.log(event.target.tagName==='SPAN');
if (event.target.tagName === "SPAN") { if (event.target.tagName === 'SPAN') {
event.target.parentElement.setAttribute( event.target.parentElement.setAttribute(
"class", 'class',
"el-button el-button--" + 'el-button el-button--' +
(phase === undefined ? "primary" : "default") + (phase === undefined ? 'primary' : 'default') +
" el-button--medium is-round" ' el-button--medium is-round'
); )
} else { } else {
event.target.setAttribute( event.target.setAttribute(
"class", 'class',
"el-button el-button--" + 'el-button el-button--' +
(phase === undefined ? "primary" : "default") + (phase === undefined ? 'primary' : 'default') +
" el-button--medium is-round" ' el-button--medium is-round'
); )
} }
this.listQuery.phase = phase; this.listQuery.phase = phase
this.getList(); this.getList()
}, },
handleFilterStatus(status) { handleFilterStatus(status) {
this.listQuery.status = status; this.listQuery.status = status
this.getList(); this.getList()
}, },
handlePreview() {}, handlePreview() {},
handleRemove() {}, handleRemove() {},
@ -509,18 +507,18 @@ export default {
timeFormat(timeStamp) { timeFormat(timeStamp) {
const timeStr = `${ const timeStr = `${
Math.floor(timeStamp / 3600) < 9 Math.floor(timeStamp / 3600) < 9
? "0" + Math.floor(timeStamp / 3600) ? '0' + Math.floor(timeStamp / 3600)
: Math.floor(timeStamp / 3600) : Math.floor(timeStamp / 3600)
}:${ }:${
Math.floor(((timeStamp % 86400) % 3600) / 60) < 9 Math.floor(((timeStamp % 86400) % 3600) / 60) < 9
? "0" + Math.floor(((timeStamp % 86400) % 3600) / 60) ? '0' + Math.floor(((timeStamp % 86400) % 3600) / 60)
: Math.floor(((timeStamp % 86400) % 3600) / 60) : Math.floor(((timeStamp % 86400) % 3600) / 60)
}:${ }:${
Math.floor(((timeStamp % 86400) % 3600) % 60) < 9 Math.floor(((timeStamp % 86400) % 3600) % 60) < 9
? "0" + Math.floor(((timeStamp % 86400) % 3600) % 60) ? '0' + Math.floor(((timeStamp % 86400) % 3600) % 60)
: Math.floor(((timeStamp % 86400) % 3600) % 60) : Math.floor(((timeStamp % 86400) % 3600) % 60)
}`; }`
return timeStr; return timeStr
}, },
countdown(index, status) { countdown(index, status) {
// //
@ -538,7 +536,7 @@ export default {
// return statusEl; // return statusEl;
// } // }
} }
}; }
</script> </script>
<style scope> <style scope>

View File

@ -11,12 +11,13 @@
margin: 0 auto;" margin: 0 auto;"
> >
<el-row> <el-row>
<el-col :span="12" <el-col
><img :span="12"
src="./img/loginImg.png" ><img
style="padding: 70px 0px 70px 72px;width:100%" src="./img/loginImg.png"
alt="" style="padding: 70px 0px 70px 72px;width:100%"
/></el-col> alt=""
></el-col>
<el-col :span="12"> <el-col :span="12">
<el-form <el-form
@ -75,8 +76,7 @@
type="primary" type="primary"
style="width:100%;margin-bottom:30px;border-radius:10px;height:54px" style="width:100%;margin-bottom:30px;border-radius:10px;height:54px"
@click.native.prevent="handleLogin" @click.native.prevent="handleLogin"
>登录</el-button >登录</el-button>
>
</el-form> </el-form>
</el-col> </el-col>
</el-row> </el-row>
@ -85,12 +85,12 @@
</template> </template>
<script> <script>
import { validUsername } from "@/utils/validate"; import { validUsername } from '@/utils/validate'
import { getGuestToken, getSms } from "@/api/user"; import { getGuestToken, getSms } from '@/api/user'
import Axios from "axios"; import Axios from 'axios'
export default { export default {
name: "Login", name: 'Login',
// components: { SocialSign }, // components: { SocialSign },
data() { data() {
const validateUsername = (rule, value, callback) => { const validateUsername = (rule, value, callback) => {
@ -100,57 +100,57 @@ export default {
// callback() // callback()
// } // }
if (value.length < 4) { if (value.length < 4) {
callback(new Error("账号格式错误不能为空或小于11位")); callback(new Error('账号格式错误不能为空或小于11位'))
} else { } else {
callback(); callback()
} }
}; }
const validateCaptcha = (rule, value, callback) => { const validateCaptcha = (rule, value, callback) => {
if (value.length < 6) { if (value.length < 6) {
callback(new Error("验证码格式错误不能为空或小于6位")); callback(new Error('验证码格式错误不能为空或小于6位'))
} else { } else {
callback(); callback()
} }
}; }
return { return {
// loginForm: { // loginForm: {
// username: 'admin', // username: 'admin',
// password: '111111' // password: '111111'
// }, // },
loginForm: { loginForm: {
username: "18882564006", username: '18882564006',
captcha: "111111", captcha: '111111',
appVersion: "1.0.0", appVersion: '1.0.0',
system: "IOS", system: 'IOS',
device: navigator.userAgent, device: navigator.userAgent,
extra: "" extra: ''
}, },
loginRules: { loginRules: {
username: [ username: [
{ required: true, trigger: "blur", validator: validateUsername } { required: true, trigger: 'blur', validator: validateUsername }
], ],
captcha: [ captcha: [
{ required: true, trigger: "blur", validator: validateCaptcha } { required: true, trigger: 'blur', validator: validateCaptcha }
] ]
}, },
passwordType: "password", passwordType: 'password',
capsTooltip: false, capsTooltip: false,
loading: false, loading: false,
showDialog: false, showDialog: false,
redirect: undefined, redirect: undefined,
otherQuery: {}, otherQuery: {},
codeText: "获取验证码", codeText: '获取验证码',
time: 5, time: 5,
getCodeDisabled: false getCodeDisabled: false
}; }
}, },
watch: { watch: {
$route: { $route: {
handler: function(route) { handler: function(route) {
const query = route.query; const query = route.query
if (query) { if (query) {
this.redirect = query.redirect; this.redirect = query.redirect
this.otherQuery = this.getOtherQuery(query); this.otherQuery = this.getOtherQuery(query)
} }
}, },
immediate: true immediate: true
@ -158,30 +158,30 @@ export default {
}, },
created() { created() {
// window.addEventListener('storage', this.afterQRScan) // window.addEventListener('storage', this.afterQRScan)
const { appVersion, system, device, extra } = this.loginForm; const { appVersion, system, device, extra } = this.loginForm
const payload = { const payload = {
appVersion, appVersion,
system, system,
device, device,
extra extra
}; }
Axios({ Axios({
method: "POST", method: 'POST',
url: `${process.env.VUE_APP_BASE_API}api/auth/guest`, url: `${process.env.VUE_APP_BASE_API}api/auth/guest`,
data: payload, data: payload,
headers: { headers: {
Authorization: "basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA==" Authorization: 'basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA=='
} }
}).then(res => { }).then(res => {
// console.log(res); // console.log(res);
sessionStorage.setItem("token", res.data.d.access_token); sessionStorage.setItem('token', res.data.d.access_token)
}); })
}, },
mounted() { mounted() {
if (this.loginForm.username === "") { if (this.loginForm.username === '') {
this.$refs.username.focus(); this.$refs.username.focus()
} else if (this.loginForm.captcha === "") { } else if (this.loginForm.captcha === '') {
this.$refs.password.focus(); this.$refs.password.focus()
} }
}, },
destroyed() { destroyed() {
@ -189,8 +189,8 @@ export default {
}, },
methods: { methods: {
checkCapslock(e) { checkCapslock(e) {
const { key } = e; const { key } = e
this.capsTooltip = key && key.length === 1 && key >= "A" && key <= "Z"; this.capsTooltip = key && key.length === 1 && key >= 'A' && key <= 'Z'
}, },
// showPwd() { // showPwd() {
// if (this.passwordType === 'password') { // if (this.passwordType === 'password') {
@ -206,37 +206,37 @@ export default {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
Axios({ Axios({
method: "POST", method: 'POST',
url: `${process.env.VUE_APP_BASE_API}api/auth/sms`, url: `${process.env.VUE_APP_BASE_API}api/auth/sms`,
data: this.loginForm, data: this.loginForm,
headers: { headers: {
Authorization: Authorization:
"basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA==" 'basic YW5kcm9pZC1jbGllbnQ6YW5kcm9pZC1zZWNyZXQtMjAyMA=='
} }
}).then(res => { }).then(res => {
console.log(res); console.log(res)
if (res.data.c === 200) { if (res.data.c === 200) {
this.$store.dispatch("user/setToken", res.data.d.access_token); this.$store.dispatch('user/setToken', res.data.d.access_token)
this.$router.push({ this.$router.push({
path: this.redirect || "/", path: this.redirect || '/',
query: this.otherQuery query: this.otherQuery
}); })
this.$notify({ this.$notify({
title: "成功", title: '成功',
message: "登录成功", message: '登录成功',
type: "success", type: 'success',
duration: 2000 duration: 2000
}); })
} else { } else {
this.$notify.error(res.data.m); this.$notify.error(res.data.m)
} }
}); })
} else { } else {
console.log("error submit!!"); console.log('error submit!!')
return false; return false
} }
}); })
// this.$refs.loginForm.validate(valid => { // this.$refs.loginForm.validate(valid => {
// if (valid) { // if (valid) {
// this.loading = true // this.loading = true
@ -256,53 +256,53 @@ export default {
}, },
getOtherQuery(query) { getOtherQuery(query) {
return Object.keys(query).reduce((acc, cur) => { return Object.keys(query).reduce((acc, cur) => {
if (cur !== "redirect") { if (cur !== 'redirect') {
acc[cur] = query[cur]; acc[cur] = query[cur]
} }
return acc; return acc
}, {}); }, {})
}, },
handleSms() { handleSms() {
this.getCodeDisabled = false; this.getCodeDisabled = false
const payload = { const payload = {
phone: this.loginForm.username, phone: this.loginForm.username,
category: "SIGNIN" category: 'SIGNIN'
}; }
Axios({ Axios({
method: "GET", method: 'GET',
url: `${process.env.VUE_APP_BASE_API}api/common/sms/send`, url: `${process.env.VUE_APP_BASE_API}api/common/sms/send`,
params: payload, params: payload,
headers: { headers: {
Authorization: "Bearer " + sessionStorage.getItem("token") Authorization: 'Bearer ' + sessionStorage.getItem('token')
} }
}).then(res => { }).then(res => {
if (res.data.c === 200) { if (res.data.c === 200) {
this.getCodeDisabled = true; this.getCodeDisabled = true
this.timer(); this.timer()
this.$notify({ this.$notify({
title: "成功", title: '成功',
message: "获取验证码成功", message: '获取验证码成功',
type: "success", type: 'success',
duration: 2000 duration: 2000
}); })
} }
}); })
}, },
timer() { timer() {
this.codeText = `${this.time}s 后重新获取`; this.codeText = `${this.time}s 后重新获取`
var interval = setInterval(() => { var interval = setInterval(() => {
this.time--; this.time--
this.codeText = `${this.time}s 后重新获取`; this.codeText = `${this.time}s 后重新获取`
if (this.time === 0) { if (this.time === 0) {
this.time = 5; this.time = 5
this.codeText = "获取验证码"; this.codeText = '获取验证码'
this.getCodeDisabled = false; this.getCodeDisabled = false
clearInterval(interval); clearInterval(interval)
} }
}, 1000); }, 1000)
} }
} }
}; }
</script> </script>
<style lang="scss"> <style lang="scss">