From 91782556afcf94482db4dd28464f078e508bf986 Mon Sep 17 00:00:00 2001 From: wally <18603454788@163.com> Date: Wed, 25 Aug 2021 09:28:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(mp):=20=E5=85=BC=E5=AE=B9=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=EF=BC=8C=E5=8E=BB=E9=99=A4window=EF=BC=8Cdoc?= =?UTF-8?q?ument=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 3 +- src/components/Globals/Globals.vue | 8 ++-- src/components/ImageCode/ImageCode.vue | 1 + src/components/Projects/Projects.vue | 4 +- src/components/Roles/Roles.vue | 47 +++++++++++-------- .../TimeLine/component/TimeStatus.vue | 4 +- src/components/Tips/Tips.vue | 5 +- src/main.js | 2 - src/pages/project/project.vue | 3 +- src/pages/test/test.vue | 1 - src/utils/cache.js | 6 --- 11 files changed, 44 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37cc466..dcb1fc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,10 @@ -# 0.1.0 (2021-08-24) +# 0.1.0 (2021-08-25) ### 🌟 新功能 范围|描述|commitId --|--|-- - | api封装 | 7d4edfc + bind phone | 图形验证码;短信验证码;绑定手机号 | 93ffea2 - | cache indexedDB处理 | 3388967 calendar, tall.js | 上下滑动切换日历的模式,tall.js中domain根据环境变量切换 | 364e25d - | db store | 6414c4f diff --git a/src/components/Globals/Globals.vue b/src/components/Globals/Globals.vue index e002088..6b25305 100644 --- a/src/components/Globals/Globals.vue +++ b/src/components/Globals/Globals.vue @@ -12,9 +12,9 @@ - + diff --git a/src/components/ImageCode/ImageCode.vue b/src/components/ImageCode/ImageCode.vue index 53567ab..378ff20 100644 --- a/src/components/ImageCode/ImageCode.vue +++ b/src/components/ImageCode/ImageCode.vue @@ -14,6 +14,7 @@ export default { }, methods: { + // 获取图形验证码 async getCode() { try { const data = await this.$u.api.getImageCode(); diff --git a/src/components/Projects/Projects.vue b/src/components/Projects/Projects.vue index 6338842..326ef55 100644 --- a/src/components/Projects/Projects.vue +++ b/src/components/Projects/Projects.vue @@ -7,10 +7,10 @@ {{ index + 1 }} - + {{ project.name }} - + 进行中 diff --git a/src/components/Roles/Roles.vue b/src/components/Roles/Roles.vue index 243bd24..aedbd69 100644 --- a/src/components/Roles/Roles.vue +++ b/src/components/Roles/Roles.vue @@ -7,14 +7,18 @@ default-tab-choice 是 我的角色 && 当前展示 default-tab-item 是 我的角色 && 当前不展示 tab-choice 不是我的 && 当前展示 - TODO: - :class="{ - 'default-tab-choice': +item.mine === 1 && roleId === item.id, - 'default-tab-item': +item.mine === 1 && roleId !== item.id, - 'tab-choice': +item.mine === 0 && roleId === item.id, - }" --> - + {{ item.name }} @@ -74,18 +78,23 @@ export default { // 设置滚动位置 setCurrentRole(index) { - console.log('index: ', index); - const data = document.getElementsByClassName('tab-children'); - // 获取当前所有子元素 并插入到 tabList 列表中 - data.forEach(item => { - this.tabList.push({ - width: item.clientWidth, - left: item.offsetLeft, - }); - }); - //当前滚动的位置 + const query = uni.createSelectorQuery().in(this); + query + .selectAll('.tab-children') + .boundingClientRect(data => { + data.forEach(item => { + this.tabList.push({ + width: item.width, + left: item.left, + }); + }); + }) + .exec(); + + const system = uni.getSystemInfoSync(); // 获取系统信息 + // 当前滚动的位置 let left = 0; - let screenWidth = window.screen.width; + let screenWidth = system.windowWidth; for (let i = 0; i < index; i++) { left += this.tabList[i].width + this.tabList[i].left * 2; } @@ -102,7 +111,7 @@ export default { this.clearPluginScript(); this.$nextTick(() => { this.setRoleId(id); - //改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 + // 改变index 即手动点击切换 我在此时将当前元素赋值给左边距 实现自动滚动 this.setCurrentRole(index); }); } catch (error) { diff --git a/src/components/TimeLine/component/TimeStatus.vue b/src/components/TimeLine/component/TimeStatus.vue index 48e4ca0..d595e16 100644 --- a/src/components/TimeLine/component/TimeStatus.vue +++ b/src/components/TimeLine/component/TimeStatus.vue @@ -22,8 +22,8 @@ - - + + diff --git a/src/components/Tips/Tips.vue b/src/components/Tips/Tips.vue index c5930ce..b485f10 100644 --- a/src/components/Tips/Tips.vue +++ b/src/components/Tips/Tips.vue @@ -48,7 +48,8 @@ export default { }, mounted() { - this.height = window.screen.height; + const system = uni.getSystemInfoSync(); + this.height = system.windowHeight; }, methods: { @@ -65,7 +66,6 @@ export default { async onChangeStatus(type) { try { const param = { id: this.tip.taskId, type }; - // TODO: 发请求 await uni.$u.api.updateTaskType(param); if (type === 0) { this.$t.ui.showToast('项目已重新开始'); @@ -77,6 +77,7 @@ export default { this.$t.ui.showToast('项目结束'); } this.tip.show = false; + // TODO: 更新界面 不要整体刷新 // location.reload(); // this.$router.go(0); } catch (error) { diff --git a/src/main.js b/src/main.js index 03fe0b7..b887267 100644 --- a/src/main.js +++ b/src/main.js @@ -37,8 +37,6 @@ App.mpType = 'app'; const app = new Vue({ ...App, store }); -// window.vm = app; - Vue.use(request, app); Vue.use(tall, app); Vue.use(project, app); diff --git a/src/pages/project/project.vue b/src/pages/project/project.vue index 9fefdc2..fbffcd6 100644 --- a/src/pages/project/project.vue +++ b/src/pages/project/project.vue @@ -69,7 +69,8 @@ export default { }, mounted() { - this.height = window.screen.height + 'px'; + const system = uni.getSystemInfoSync(); + this.height = system.windowHeight + 'px'; }, onUnload() { diff --git a/src/pages/test/test.vue b/src/pages/test/test.vue index 0c2ed13..5ec1fc1 100644 --- a/src/pages/test/test.vue +++ b/src/pages/test/test.vue @@ -46,7 +46,6 @@ export default { console.log('update data: ', data); }, - // TODO: async createIndex() { // const data = await this.$db.createIndex('projects', 'sex', 'woman'); console.log('update data: '); diff --git a/src/utils/cache.js b/src/utils/cache.js index c22e6c5..33bc1c1 100644 --- a/src/utils/cache.js +++ b/src/utils/cache.js @@ -130,7 +130,6 @@ export default { const data = await uni.$t.storage.getStorage('projects'); return filter.projects(JSON.parse(data), startTime, endTime); } catch (error) { - console.error('error: ', error); return []; } }, @@ -177,7 +176,6 @@ export default { const data = await uni.$t.storage.getStorage(`roles_${projectId}`); return filter.roles(JSON.parse(data)); } catch (error) { - console.error('error: ', error); return null; } }, @@ -235,7 +233,6 @@ export default { const data = await uni.$t.storage.getStorage(`plan_task_${params.projectId}_${params.roleId}`); return filter.planTask(JSON.parse(data), params.timeNode, params.queryNum, params.timeUnit, params.queryType); } catch (error) { - console.error('error: ', error); return []; } }, @@ -283,7 +280,6 @@ export default { const data = await uni.$t.storage.getStorage(`fixed_tasks_${params.projectId}_${params.roleId}`); return filter.fixedTasks(JSON.parse(data)); } catch (error) { - console.error('error: ', error); return []; } }, @@ -331,7 +327,6 @@ export default { const data = await uni.$t.storage.getStorage(`variable_tasks_${params.projectId}_${params.roleId}`); return filter.dailyTask(JSON.parse(data), params.timeNode); } catch (error) { - console.error('error: ', error); return []; } }, @@ -378,7 +373,6 @@ export default { const data = await uni.$t.storage.getStorage(`plugin_${pluginId}`); return filter.plugin(JSON.parse(data)); } catch (error) { - console.error('error: ', error); return null; } },