diff --git a/.env.development b/.env.development index a0baa70..594a0a0 100644 --- a/.env.development +++ b/.env.development @@ -1,9 +1,10 @@ # 页面标题 VUE_APP_TITLE = 填鸭测试环境 # 接口请求地址,会设置到 axios 的 baseURL 参数上 -VUE_APP_API_ROOT = http://localhost:8999/tduck-api +VUE_APP_API_ROOT = /tduck-api # 是否开启 CDN 支持,开启设置 ON,关闭设置 OFF # 详情介绍请阅读 http://eoner.gitee.io/vue-automation/#/cdn VUE_APP_CDN = OFF # 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空 VUE_APP_DEBUG_TOOL = + diff --git a/package.json b/package.json index 48ec428..c870829 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,9 @@ "js-md5": "^0.7.3", "nprogress": "^0.2.0", "vue": "^2.6.12", + "vue-clipboard2": "^0.3.1", "vue-meta": "^2.4.0", + "vue-qr": "^2.3.0", "vue-router": "^3.4.8", "vuedraggable": "^2.24.3", "vuex": "^3.5.1" diff --git a/public/MP_verify_ADM9iUdaNzf3LpYF.txt b/public/MP_verify_ADM9iUdaNzf3LpYF.txt new file mode 100644 index 0000000..1146b37 --- /dev/null +++ b/public/MP_verify_ADM9iUdaNzf3LpYF.txt @@ -0,0 +1 @@ +ADM9iUdaNzf3LpYF \ No newline at end of file diff --git a/src/api/index.js b/src/api/index.js index 82be318..9d5901b 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -15,7 +15,7 @@ const toLogin = () => { } const api = axios.create({ - baseURL: process.env.NODE_ENV !== 'development' && process.env.VUE_APP_API_ROOT, + baseURL: process.env.VUE_APP_API_ROOT, timeout: 10000, responseType: 'json', withCredentials: false, diff --git a/src/assets/logo.png b/src/assets/logo.png deleted file mode 100644 index f23b758..0000000 Binary files a/src/assets/logo.png and /dev/null differ diff --git a/src/main.js b/src/main.js index 4e3b3c8..8f696d7 100644 --- a/src/main.js +++ b/src/main.js @@ -11,7 +11,7 @@ import api from './api' import store from './store/index' // 全局组件自动注册 import '@/components/autoRegister' - +import VueClipboard from 'vue-clipboard2' Vue.prototype.$api = api Vue.prototype.$dayjs = dayjs Vue.prototype.$store = store @@ -29,6 +29,7 @@ Vue.prototype.msgInfo = function(msg) { this.$message.info(msg) } +Vue.use(VueClipboard) Vue.use(meta) Vue.use(Element, {size: 'small', zIndex: 3000}) diff --git a/src/router/index.js b/src/router/index.js index 2c4bc52..ad7e8e7 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -30,6 +30,7 @@ routes.push({ }) const router = new Router({ + mode: 'history', routes: routes.flat() }) diff --git a/src/router/modules/root.js b/src/router/modules/root.js index 9fa3f2d..c0051cd 100644 --- a/src/router/modules/root.js +++ b/src/router/modules/root.js @@ -70,7 +70,7 @@ export default [ path: '/project/view', meta: {requireLogin: false}, component: () => import(/* webpackChunkName: 'root' */ '@/views/form/ProjectForm.vue') -`` }, + }, { path: '/project/write', meta: {requireLogin: false}, diff --git a/src/utils/defaultValue.js b/src/utils/defaultValue.js new file mode 100644 index 0000000..be90aee --- /dev/null +++ b/src/utils/defaultValue.js @@ -0,0 +1,5 @@ +export default { + projectShareTitle: '填鸭表单', + projectShareDesc: '快来填写吧', + projectShareImg: 'https://qiniu.smileyi.top/c4ca4238a0b923820dcc509a6f75849b/4b2c7071f3f543549907b9e3b41df1ed.png' +} diff --git a/src/utils/index.js b/src/utils/index.js index 37ec907..aeeba82 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,5 +1,6 @@ /* eslint-disable no-nested-ternary */ /* eslint-disable no-restricted-syntax */ + /* eslint-disable guard-for-in */ /** * num 小于0,左缩进num*2个空格; 大于0,右缩进num*2个空格。 @@ -9,7 +10,10 @@ */ export function indent(str, num, len = 2) { if (num === 0) return str - const isLeft = num < 0; const result = []; let reg; let + const isLeft = num < 0 + const result = [] + let reg + let spaces = '' if (isLeft) { num *= -1 @@ -126,9 +130,15 @@ export function deepClone(obj) { // RegExp if (_toString.call(obj) === '[object RegExp]') { const flags = [] - if (obj.global) { flags.push('g') } - if (obj.multiline) { flags.push('m') } - if (obj.ignoreCase) { flags.push('i') } + if (obj.global) { + flags.push('g') + } + if (obj.multiline) { + flags.push('m') + } + if (obj.ignoreCase) { + flags.push('i') + } return new RegExp(obj.source, flags.join('')) } @@ -143,15 +153,26 @@ export function deepClone(obj) { } export function uuid() { - let s = []; - let hexDigits = "0123456789abcdef"; + let s = [] + let hexDigits = '0123456789abcdef' for (var i = 0; i < 36; i++) { - s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); + s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1) } - s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 - s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 - s[8] = s[13] = s[18] = s[23] = "-"; + s[14] = '4' // bits 12-15 of the time_hi_and_version field to 0010 + s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1) // bits 6-7 of the clock_seq_hi_and_reserved to 01 + s[8] = s[13] = s[18] = s[23] = '-' + + let uuid = s.join('') + return uuid +} - let uuid = s.join(""); - return uuid; +export function getQueryString(name) { + let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i') + let r = window.location.search.substr(1).match(reg) //获取url中"?"符后的字符串并正则匹配 + let context = '' + if (r != null) + context = r[2] + reg = null + r = null + return context == null || context == '' || context == 'undefined' ? '' : context } diff --git a/src/utils/loadWxSdk.js b/src/utils/loadWxSdk.js new file mode 100644 index 0000000..cc70e04 --- /dev/null +++ b/src/utils/loadWxSdk.js @@ -0,0 +1,26 @@ +import loadScript from './loadScript' +import ELEMENT from 'element-ui' + +let wxObj + +export default function loadWXJs(cb) { + if (wxObj) { + cb(wxObj) + return + } + + const loading = ELEMENT.Loading.service({ + fullscreen: true, + lock: true, + text: 'wxsdk资源加载中...', + spinner: 'el-icon-loading', + background: 'rgba(255, 255, 255, 0.5)' + }) + + loadScript('http://res.wx.qq.com/open/js/jweixin-1.6.0.js', () => { + loading.close() + // eslint-disable-next-line no-undef + wxObj = wx + cb(wxObj) + }) +} diff --git a/src/views/account/login.vue b/src/views/account/login.vue index 97b894f..cd62aa6 100644 --- a/src/views/account/login.vue +++ b/src/views/account/login.vue @@ -11,10 +11,15 @@
- +
- 刷新二维码 + + 刷新二维码 +
@@ -218,19 +223,48 @@ export default { email: '', password: '' }, - wxLoginQrCode: 'http://qiniu.smileyi.top/20191213/9f217b754ad44f0caaa83040ce62fe93.png' + wxLoginQrCode: '', + wxLoginId: '', + refreshWxQrcodeTimer: null, + wxQrcodeResultTimer: null } }, + created() { + this.getLoginWxQrCode() + this.refreshWxQrcodeTimer = setInterval(() => { + this.getLoginWxQrCode() + }, 5 * 60 * 1000) + this.wxQrcodeResultTimer = setInterval(() => { + this.getLoginWxQrCodeResult() + }, 5 * 1000) + }, + destroyed() { + clearInterval(this.refreshWxQrcodeTimer) + clearInterval(this.wxQrcodeResultTimer) + }, methods: { loginTypeHandleClick() { }, registerHandleClick() { }, + getLoginWxQrCode() { + this.$api.get('/login/wx/qrcode').then(res => { + this.wxLoginQrCode = res.data.qrCodeUrl + this.wxLoginId = res.data.loginId + }) + }, + getLoginWxQrCodeResult() { + this.$api.get('/login/wx/qrcode/result', {params: {loginId: this.wxLoginId}}).then(res => { + if (res.data) { + this.loginSuccessHandle(res.data) + } + }) + }, sendEmailCodeHandle() { this.$refs['emailRegForm'].validateField('email', err => { if (!err) { this.validateCodeBtn = true - this.$api.get(`/user/send-email-code?email=${this.accountForm.email}`).then(() => { + this.$api.get(`/register/email/code?email=${this.accountForm.email}`).then(() => { this.msgSuccess('验证码发送成功,5分钟内有效') this.validateCodeBtn = true let count = 60 @@ -249,7 +283,7 @@ export default { emailRegHandle() { this.$refs['emailRegForm'].validate(valid => { if (valid) { - this.$api.post('/user/email-register', this.accountForm).then(() => { + this.$api.post('/register/email', this.accountForm).then(() => { this.msgSuccess('注册成功,快去登录吧') setTimeout(() => { this.formType = 'login' @@ -261,26 +295,29 @@ export default { } }) }, + loginSuccessHandle(data) { + this.msgSuccess('登录成功') + this.$store.dispatch('user/login', data).then(() => { + // 登录成功后路由跳回 + // eslint-disable-next-line no-debugger + if (this.$route.query.redirect) { + this.$router.replace({ + path: this.$route.query.redirect + }) + } else { + if (window.history.length <= 1) { + this.$router.push({path: '/home'}) + } else { + this.$router.push({path: '/home'}) + } + } + }) + }, loginHandle() { this.$refs['accountLoginForm'].validate(valid => { if (valid) { - this.$api.post('/user/account-login', this.accountForm).then(res => { - this.msgSuccess('登录成功') - this.$store.dispatch('user/login', res.data).then(() => { - // 登录成功后路由跳回 - // eslint-disable-next-line no-debugger - if (this.$route.query.redirect) { - this.$router.replace({ - path: this.$route.query.redirect - }) - } else { - if (window.history.length <= 1) { - this.$router.push({path: '/home'}) - } else { - this.$router.push({path: '/home'}) - } - } - }) + this.$api.post('/login/account', this.accountForm).then(res => { + this.loginSuccessHandle(res.data) }) } else { return false @@ -293,7 +330,7 @@ export default { diff --git a/src/views/form/setting.vue b/src/views/form/setting.vue index 0a37649..a035c1c 100644 --- a/src/views/form/setting.vue +++ b/src/views/form/setting.vue @@ -532,8 +532,8 @@ export default { queryUserProjectSetting() { this.userProjectSettingData.projectKey = this.projectKey this.$api.get(`/user/project/setting/query/${this.projectKey}`).then(res => { - this.userProjectSettingData = res.data if (res.data) { + this.userProjectSettingData = res.data let { submitPromptImg, submitPromptText, submitJumpUrl, timedCollectionBeginTime, timedQuantitativeQuantity, newWriteNotifyEmail, newWriteNotifyWx, diff --git a/src/views/form/write.vue b/src/views/form/write.vue index 0d93967..ced5400 100644 --- a/src/views/form/write.vue +++ b/src/views/form/write.vue @@ -1,12 +1,18 @@