From 99d42e2887f8978fa1e5e6bf3f7e1e43e51669c7 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Tue, 10 Aug 2021 14:40:31 +0800 Subject: [PATCH] =?UTF-8?q?style:=20=E5=88=A0=E9=99=A4mock,console;upload?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0loading?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/components/Plugin/Plugin.vue | 4 - src/components/Roles/Roles.vue | 5 +- src/components/TimeLine/TimeLine.vue | 4 +- .../TimeLine/component/TimeStatus.vue | 1 - src/components/Tips/Tips.vue | 2 +- src/components/Upload/Upload.vue | 14 +- src/mock/mock.js | 401 ------------------ src/pages/project/project.vue | 2 +- src/utils/tall.js | 2 +- src/utils/ui.js | 2 +- src/utils/upload.js | 19 +- 12 files changed, 38 insertions(+), 419 deletions(-) delete mode 100644 src/mock/mock.js diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ffe47..935d1d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ - | 距调整pc端 | 5069aa1 - | 配置默认插件接口 | f0c177d - | 面变化首页变化 | 5e860f1 + - | 项目api url设置 | 6cd5245 - | 项目列表, 项目url | 32e005b - | 首页项目样式改变 | 8514c85 diff --git a/src/components/Plugin/Plugin.vue b/src/components/Plugin/Plugin.vue index a49bf66..88a6b41 100644 --- a/src/components/Plugin/Plugin.vue +++ b/src/components/Plugin/Plugin.vue @@ -87,7 +87,6 @@ export default { }); if (!data || !data.id) return; const reg = /data-root=["|']?(\w+)["|']?/gi; - // console.log(data.html); let uuid = ''; // FIXME: 没有兼容 只有js, 没有html的情况 if (data.html) { @@ -95,8 +94,6 @@ export default { if (reg.test(data.html)) { uuid = RegExp.$1; - // console.log('uuid: ', uuid, `p${this.pluginTaskId}`); - const str = data.html.replace(new RegExp(uuid, 'g'), `p${this.pluginTaskId}`); this.pluginContent = str; } else { @@ -106,7 +103,6 @@ export default { const str = data.js.replace(new RegExp(uuid, 'g'), `p${this.pluginTaskId}`); this.handleDom(str); } - // console.log(this.pluginContent); // if (data.js) { // if (reg.test(data.js)) { diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index d2d1183..aebf966 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -111,13 +111,12 @@ export default { this.clearEndFlag(); }); } catch (error) { - console.log('role.vue changeRole error: ', error); + console.error('role.vue changeRole error: ', error); } }, // 清除插件script clearPluginScript() { - console.log('clearPluginScript: '); try { const scripts = document.querySelectorAll('script[data-type=plugin]'); @@ -125,7 +124,7 @@ export default { document.body.removeChild(scripts[i]); } } catch (error) { - console.log('clearPluginScript error: ', error); + console.error('clearPluginScript error: ', error); } }, diff --git a/src/components/TimeLine/TimeLine.vue b/src/components/TimeLine/TimeLine.vue index ef33b32..9b85f91 100644 --- a/src/components/TimeLine/TimeLine.vue +++ b/src/components/TimeLine/TimeLine.vue @@ -60,7 +60,7 @@ export default { const startTime = this.tasks[0].planStart - 0; if (this.tasks[0].plugins && this.tasks[0].plugins.length === 0 && !this.topEnd) { // 没有数据时 自动加载数据 - console.log('没有数据时: '); + console.warn('没有数据时: '); const addTasks = [ { panel: {}, @@ -81,7 +81,7 @@ export default { this.setUpTasks([...addTasks.concat(this.tasks)]); } else { // 有数据时 - console.log('有数据时: '); + console.warn('有数据时: '); const upQuery = { timeNode: startTime, queryType: 0, diff --git a/src/components/TimeLine/component/TimeStatus.vue b/src/components/TimeLine/component/TimeStatus.vue index 08ca698..ef6fced 100644 --- a/src/components/TimeLine/component/TimeStatus.vue +++ b/src/components/TimeLine/component/TimeStatus.vue @@ -109,7 +109,6 @@ export default { computeCyclePersent() { if (!this.task || !this.task.realStart || !this.task.planDuration) return 100; const { realStart, planDuration } = this.task; - console.log((((Date.now() - +realStart) * 100) / +planDuration).toFixed(2)); return (((Date.now() - +realStart) * 100) / +planDuration).toFixed(2); }, diff --git a/src/components/Tips/Tips.vue b/src/components/Tips/Tips.vue index 3f139b4..036a804 100644 --- a/src/components/Tips/Tips.vue +++ b/src/components/Tips/Tips.vue @@ -80,7 +80,7 @@ export default { location.reload(); // this.$router.go(0); } catch (error) { - console.log(error); + console.error(error); } }, diff --git a/src/components/Upload/Upload.vue b/src/components/Upload/Upload.vue index 7006a76..7d0a100 100644 --- a/src/components/Upload/Upload.vue +++ b/src/components/Upload/Upload.vue @@ -1,22 +1,30 @@ `, - ], - }, - }); - }, - }, - //根据id获取token - { - path: '/tall/v1.0/users/userId', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { - account: 'wally', - id: 123, - phone: '18603454788', - refresh_token: 'string', - token: 'string', - wxInfo: { - city: 'string', - country: 'string', - headImgUrl: 'string', - language: 'string', - nickname: 'string', - province: 'string', - sex: 0, - }, - }, - }); - }, - }, - //根据id获取项目信息 - { - path: '/defaultwbs/project/findProjectById', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { - name: '默认项目', - projectId: 1235555, - }, - }); - }, - }, - //查询角色栏展示的角色 - { - path: '/defaultwbs/role/show', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { - //不展示的角色 - invisibleList: [ - { - id: 123456789, - mine: 1, - name: 'string', - pm: 0, - sequence: 33, - }, - ], //展示的角色 - visibleList: [ - { - id: 1, - name: '项目经理', - mine: 0, - pm: 1, - sequence: 1, - }, - { - id: 2, - name: '运维', - mine: 0, - pm: 0, - sequence: 2, - }, - { - id: 3, - name: '导师一', - mine: 1, - pm: 0, - sequence: 3, - }, - { - id: 4, - name: '导师二', - mine: 1, - pm: 0, - sequence: 4, - }, - { - id: 5, - name: '导师三', - mine: 1, - pm: 0, - sequence: 5, - }, - ], - }, - }); - }, - }, - //配置角色栏展示的角色 - { - path: '/defaultwbs/role/updateShow', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { description: 'data数据' }, - }); - }, - }, - //根据角色查找永久的日常任务 - { - path: '/defaultwbs/task/permanent', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: [ - { - description: 'string', - detailId: 147258, - id: 258147, - name: 'string', - panel: { - backgroundColor: 'string', - border: 'string', - borderRadius: 'string', - col: 132, - height: 'string', - row: 147, - shadow: 'string', - width: 'string', - }, - planDuration: 123, - planStart: 123456789, - plugins: [ - [ - { - col: 1, - colspan: 123, - param: 123, - pluginId: 13, - row: 2, - rowspan: 123, - }, - ], - ], - process: 0, - realDuration: 123456789, - realStart: 123456789, - skip: -1, - skipTaskId: 123456789, - }, - ], - }); - }, - }, - //根据时间和角色查找日常任务 - { - path: '/defaultwbs/task/global', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: [ - { - description: 'string', - detailId: 147258, - id: 258147, - name: 'string', - panel: { - backgroundColor: 'string', - border: 'string', - borderRadius: 'string', - col: 132, - height: 'string', - row: 147, - shadow: 'string', - width: 'string', - }, - planDuration: 123, - planStart: 123456789, - plugins: [ - [ - { - col: 1, - colspan: 123, - param: 123, - pluginId: 13, - row: 1, - rowspan: 123, - }, - ], - ], - process: 0, - realDuration: 123456789, - realStart: 123456789, - skip: -1, - skipTaskId: 123456789, - }, - ], - }); - }, - }, - //根据时间基准点和角色查找定期任务 - { - path: '/defaultwbs/task/regular', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: [ - { - description: 'string', - detailId: 147258, - id: 258147, - name: 'string', - panel: { - backgroundColor: 'string', - border: 'string', - borderRadius: 'string', - col: 132, - height: '100', - row: 147, - shadow: 'string', - width: 'string', - }, - planDuration: 123, - planStart: 123456789, - plugins: [ - [ - { - col: 123, - colspan: 123, - param: 123, - pluginId: 1, - row: 123, - rowspan: 123, - }, - ], - ], - process: 0, - realDuration: 123456789, - realStart: 123456789, - skip: -1, - skipTaskId: 123456789, - }, - { - description: 'string', - detailId: 147258, - id: 254565, - name: 'string', - panel: { - backgroundColor: 'string', - border: 'string', - borderRadius: 'string', - col: 132, - height: '100', - row: 147, - shadow: 'string', - width: 'string', - }, - planDuration: 123, - planStart: 123456789, - plugins: [ - [ - { - col: 123, - colspan: 123, - param: 123, - pluginId: 2, - row: 123, - rowspan: 123, - }, - ], - ], - process: 0, - realDuration: 123456789, - realStart: 123456789, - skip: -1, - skipTaskId: 123456789, - }, - { - description: 'string', - detailId: 147258, - id: 111125, - name: 'string', - panel: { - backgroundColor: 'string', - border: 'string', - borderRadius: 'string', - col: 132, - height: '100', - row: 147, - shadow: 'string', - width: 'string', - }, - planDuration: 123, - planStart: 123456789, - plugins: [ - [ - { - col: 123, - colspan: 123, - param: 123, - pluginId: 3, - row: 123, - rowspan: 123, - }, - ], - ], - process: 0, - realDuration: 123456789, - realStart: 123456789, - skip: -1, - skipTaskId: 123456789, - }, - ], - }); - }, - }, - //修改任务状态 - { - path: '/defaultwbs/task/type', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { description: 'data数据' }, - }); - }, - }, - //根据id查询插件信息 - { - path: '/defaultwbs/plugin', - method: 'post', - handler: (req, res) => { - return res.json({ - code: 200, - msg: 'ok', - success: true, - data: { - html: '
', - id: 13, - intro: 'string', - js: 'string', - name: 'string', - styleType: -1, - version: 'string', - }, - }); - }, - }, -]; diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index 42fe18e..e5c9975 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -161,7 +161,7 @@ export default { await this.getRegulars(params); } catch (error) { - console.log('error: ', error); + console.error('error: ', error); } }, diff --git a/src/utils/tall.js b/src/utils/tall.js index 7bf177b..5088746 100644 --- a/src/utils/tall.js +++ b/src/utils/tall.js @@ -16,7 +16,7 @@ const $t = { timeConfig, // 时间相关配置 ui, // ui界面提示相关 chooseAndUpload: upload.chooseAndUpload, // 选择并上传单个文件相关的封装 - domain: 'https://www.tall.wiki/tall3/v3.0.0/defaultwbs', + domain: 'https://www.tall.wiki/gateway/defaultwbs', }; uni.$t = $t; diff --git a/src/utils/ui.js b/src/utils/ui.js index ab54252..1de1476 100644 --- a/src/utils/ui.js +++ b/src/utils/ui.js @@ -22,7 +22,7 @@ export default { * 显示加载雪花 * @param {string} title */ - showLoading(title) { + showLoading(title = '玩命加载中...') { return uni.showLoading({ title, mask: true, diff --git a/src/utils/upload.js b/src/utils/upload.js index a9b1cf0..1eebe8b 100644 --- a/src/utils/upload.js +++ b/src/utils/upload.js @@ -8,6 +8,9 @@ export default { * @returns */ chooseAndUpload(url, formData = {}, extension = ['.xls', '.xlsx'], name = 'param') { + uni.hideLoading(); + clearTimeout(timer); + let timer = null; return new Promise((resolve, reject) => { const token = uni.$t.storage.getStorageSync(uni.$t.app.tokenKey); if (!token) { @@ -17,6 +20,13 @@ export default { count: 1, //默认100 extension, success: res => { + if (!timer) { + timer = setTimeout(() => { + uni.$t.ui.showLoading('正在上传...'); + timer = null; + }, 800); + } + // 开始上传 uni.uploadFile({ url, filePath: res.tempFilePaths[0], @@ -24,7 +34,10 @@ export default { formData, header: { Authorization: `Bearer ${token}` }, success: ({ data, statusCode }) => { - console.log('data, statusCode: ', data, statusCode); + console.log('s'); + clearTimeout(timer); + uni.hideLoading(); + if (statusCode === 200 && data) { const { code, msg } = JSON.parse(data); if (code !== 200) { @@ -37,11 +50,15 @@ export default { } }, fail: error => { + clearTimeout(timer); + uni.hideLoading(); reject(error); }, }); }, fail: error => { + clearTimeout(timer); + uni.hideLoading(); reject(error); }, });