|
|
@@ -1,63 +1,109 @@
|
|
|
-// import dayjs from 'dayjs';
|
|
|
-// import { checkSetting } from '../utils/getVariables.js'
|
|
|
+import http from '../plugins/http';
|
|
|
export default {
|
|
|
computed: {
|
|
|
isLogin() {
|
|
|
return !!this.$store.state.userInfo;
|
|
|
+ },
|
|
|
+ authStatus() {
|
|
|
+ let status = this.$store.state.userInfo?.authStatus;
|
|
|
+
|
|
|
+ return this.AuthStatus.has(status) ? this.AuthStatus.get(status) : '未认证';
|
|
|
}
|
|
|
},
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ AuthStatus: new Map([
|
|
|
+ ['NOT_AUTH', '未认证'],
|
|
|
+ ['PENDING', '认证中'],
|
|
|
+ ['SUCCESS', '已认证'],
|
|
|
+ ['FAIL', '认证失败']
|
|
|
+ ])
|
|
|
+ };
|
|
|
+ },
|
|
|
methods: {
|
|
|
- getLabelName(val = '', list = []) {
|
|
|
- let info = list.find(item => {
|
|
|
- return item.value === val;
|
|
|
+ updateUser(info, sucess = true) {
|
|
|
+ if (info) {
|
|
|
+ return this.$http
|
|
|
+ .post(
|
|
|
+ '/user/save',
|
|
|
+ {
|
|
|
+ ...this.$store.state.userInfo,
|
|
|
+ ...info
|
|
|
+ },
|
|
|
+ {
|
|
|
+ body: 'json'
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ return this.$store.dispatch('getUserInfo');
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ if (sucess) {
|
|
|
+ this.$toast.success('更新成功');
|
|
|
+ }
|
|
|
+ return Promise.resolve();
|
|
|
+ })
|
|
|
+ .catch(e => {
|
|
|
+ if (e) {
|
|
|
+ this.$toast(e.error);
|
|
|
+ }
|
|
|
+ return Promise.reject();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updateFile(e) {
|
|
|
+ const formData = new FormData();
|
|
|
+ formData.append('file', e.file, e.file.name);
|
|
|
+ return http.axios.post('/upload/file', formData).then(res => {
|
|
|
+ return Promise.resolve(res.data);
|
|
|
});
|
|
|
-
|
|
|
- return info ? info.label : val;
|
|
|
},
|
|
|
- showList(list = [], tag = ',') {
|
|
|
- if (!list) {
|
|
|
+ getImg(imgs = '', type = '') {
|
|
|
+ if (!imgs) {
|
|
|
+ imgs = '';
|
|
|
+ }
|
|
|
+ if (!(imgs instanceof Array)) {
|
|
|
+ imgs = imgs.split(',');
|
|
|
+ }
|
|
|
+
|
|
|
+ imgs = imgs.filter(item => {
|
|
|
+ return !!item;
|
|
|
+ });
|
|
|
+ if (imgs.length > 0) {
|
|
|
+ let img = type ? imgs[0][type] : imgs[0];
|
|
|
+ return img + (/\.gif$/i.test(img) ? '' : '?x-oss-process=image/resize,h_300,m_lfit');
|
|
|
+ } else {
|
|
|
return '';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkLogin() {
|
|
|
+ if (this.isLogin) {
|
|
|
+ return Promise.resolve();
|
|
|
} else {
|
|
|
- if (!(list instanceof Array)) {
|
|
|
- list = list.split(',');
|
|
|
- }
|
|
|
- return list.join(tag);
|
|
|
+ this.$dialog
|
|
|
+ .confirm({
|
|
|
+ title: '提示',
|
|
|
+ message: '用户未登录,是否立即登录',
|
|
|
+ confirmButtonText: '立即登录'
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.$router.push('/login');
|
|
|
+ });
|
|
|
+ return Promise.reject();
|
|
|
}
|
|
|
},
|
|
|
- sendCode(phone) {
|
|
|
- this.sending = true;
|
|
|
- this.$http
|
|
|
- .get('/sms/sendVerify', {
|
|
|
- phone: phone
|
|
|
- })
|
|
|
- .then(() => {
|
|
|
- this.sending = false;
|
|
|
- this.checkTime();
|
|
|
- })
|
|
|
- .catch(e => {
|
|
|
- this.sending = false;
|
|
|
- this.$message.error(e.error);
|
|
|
- });
|
|
|
+ getLabelName(val = '', list = []) {
|
|
|
+ let info = list.find(item => {
|
|
|
+ return item.value === val;
|
|
|
+ });
|
|
|
+
|
|
|
+ return info ? info.label : '';
|
|
|
},
|
|
|
- checkTime() {
|
|
|
- this.time = 60;
|
|
|
- let i = setInterval(() => {
|
|
|
- this.time--;
|
|
|
- if (this.time === 0) {
|
|
|
- clearInterval(i);
|
|
|
- }
|
|
|
- }, 1000);
|
|
|
+ scrollRefreash() {
|
|
|
+ this.$toast.clear();
|
|
|
},
|
|
|
- pdCode(phone, code) {
|
|
|
- this.$http
|
|
|
- .get('/sms/verify', {
|
|
|
- phone: phone,
|
|
|
- code: code
|
|
|
- })
|
|
|
- .then(() => {})
|
|
|
- .catch(e => {
|
|
|
- this.$message.error(e.error);
|
|
|
- });
|
|
|
+ wait() {
|
|
|
+ this.$toast('敬请期待');
|
|
|
}
|
|
|
}
|
|
|
};
|