Browse Source

feat(mp): 兼容小程序,去除window,document等

tall
wally 4 years ago
parent
commit
91782556af
  1. 3
      CHANGELOG.md
  2. 8
      src/components/Globals/Globals.vue
  3. 1
      src/components/ImageCode/ImageCode.vue
  4. 4
      src/components/Projects/Projects.vue
  5. 47
      src/components/Roles/Roles.vue
  6. 4
      src/components/TimeLine/component/TimeStatus.vue
  7. 5
      src/components/Tips/Tips.vue
  8. 2
      src/main.js
  9. 3
      src/pages/project/project.vue
  10. 1
      src/pages/test/test.vue
  11. 6
      src/utils/cache.js

3
CHANGELOG.md

@ -1,9 +1,10 @@
# 0.1.0 (2021-08-24) # 0.1.0 (2021-08-25)
### 🌟 新功能 ### 🌟 新功能
范围|描述|commitId 范围|描述|commitId
--|--|-- --|--|--
- | api封装 | 7d4edfc - | api封装 | 7d4edfc
bind phone | 图形验证码;短信验证码;绑定手机号 | 93ffea2
- | cache indexedDB处理 | 3388967 - | cache indexedDB处理 | 3388967
calendar, tall.js | 上下滑动切换日历的模式,tall.js中domain根据环境变量切换 | 364e25d calendar, tall.js | 上下滑动切换日历的模式,tall.js中domain根据环境变量切换 | 364e25d
- | db store | 6414c4f - | db store | 6414c4f

8
src/components/Globals/Globals.vue

@ -12,9 +12,9 @@
<scroll-view :scrollY="true" :style="{ 'max-height': isShrink ? '50rpx' : '280rpx' }"> <scroll-view :scrollY="true" :style="{ 'max-height': isShrink ? '50rpx' : '280rpx' }">
<skeleton :banner="false" :loading="!globals.length" :row="4" animate class="u-line-2 skeleton"></skeleton> <skeleton :banner="false" :loading="!globals.length" :row="4" animate class="u-line-2 skeleton"></skeleton>
<view class="grid gap-2"> <view class="grid gap-2">
<template v-for="item in globals"> <block v-for="item in globals" :key="item.id">
<template v-if="item.plugins"> <template v-if="item.plugins">
<template v-for="pluginArr in item.plugins"> <block v-for="(pluginArr, i) in item.plugins" :key="i">
<template class="p-0 u-col-between" v-if="pluginArr.length"> <template class="p-0 u-col-between" v-if="pluginArr.length">
<Plugin <Plugin
:class="[`row-span-${plugin.row}`, `col-span-${plugin.col}`]" :class="[`row-span-${plugin.row}`, `col-span-${plugin.col}`]"
@ -26,9 +26,9 @@
v-for="plugin in pluginArr" v-for="plugin in pluginArr"
/> />
</template> </template>
</template> </block>
</template> </template>
</template> </block>
</view> </view>
</scroll-view> </scroll-view>
</view> </view>

1
src/components/ImageCode/ImageCode.vue

@ -14,6 +14,7 @@ export default {
}, },
methods: { methods: {
//
async getCode() { async getCode() {
try { try {
const data = await this.$u.api.getImageCode(); const data = await this.$u.api.getImageCode();

4
src/components/Projects/Projects.vue

@ -7,10 +7,10 @@
{{ index + 1 }} {{ index + 1 }}
</view> </view>
<view class="flex-1 px-3"> <view class="flex-1 px-3" @click="openProject(project)">
<view class="flex items-center mb-1"> <view class="flex items-center mb-1">
<view class="mr-2">{{ project.name }}</view> <view class="mr-2">{{ project.name }}</view>
<!-- 状态 TODO:--> <!-- 状态 TODO: -->
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full">进行中</view> <view class="px-2 text-xs text-green-400 bg-green-100 rounded-full">进行中</view>
</view> </view>

47
src/components/Roles/Roles.vue

@ -7,14 +7,18 @@
default-tab-choice 我的角色 && 当前展示 default-tab-choice 我的角色 && 当前展示
default-tab-item 我的角色 && 当前不展示 default-tab-item 我的角色 && 当前不展示
tab-choice 不是我的 && 当前展示 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,
}"
--> -->
<view :key="index" @click="changeRole(item.id, index)" class="tab-item" v-for="(item, index) in roles"> <view
: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,
}"
:key="index"
@click="changeRole(item.id, index)"
class="tab-item"
v-for="(item, index) in roles"
>
<view class="tab-children u-skeleton-fillet u-font-14"> <view class="tab-children u-skeleton-fillet u-font-14">
{{ item.name }} {{ item.name }}
</view> </view>
@ -74,18 +78,23 @@ export default {
// //
setCurrentRole(index) { setCurrentRole(index) {
console.log('index: ', index); const query = uni.createSelectorQuery().in(this);
const data = document.getElementsByClassName('tab-children'); query
// tabList .selectAll('.tab-children')
data.forEach(item => { .boundingClientRect(data => {
this.tabList.push({ data.forEach(item => {
width: item.clientWidth, this.tabList.push({
left: item.offsetLeft, width: item.width,
}); left: item.left,
}); });
// });
})
.exec();
const system = uni.getSystemInfoSync(); //
//
let left = 0; let left = 0;
let screenWidth = window.screen.width; let screenWidth = system.windowWidth;
for (let i = 0; i < index; i++) { for (let i = 0; i < index; i++) {
left += this.tabList[i].width + this.tabList[i].left * 2; left += this.tabList[i].width + this.tabList[i].left * 2;
} }
@ -102,7 +111,7 @@ export default {
this.clearPluginScript(); this.clearPluginScript();
this.$nextTick(() => { this.$nextTick(() => {
this.setRoleId(id); this.setRoleId(id);
//index // index
this.setCurrentRole(index); this.setCurrentRole(index);
}); });
} catch (error) { } catch (error) {

4
src/components/TimeLine/component/TimeStatus.vue

@ -22,8 +22,8 @@
</view> </view>
</view> </view>
</u-circle-progress> </u-circle-progress>
<!-- 0未开始 4添加任务TODO: :class="task.process === 4 ? 'progress-box-4' : ''"--> <!-- 0未开始 4添加任务 -->
<view class="flex items-center justify-center rounded-full progress-box" v-else> <view class="flex items-center justify-center rounded-full progress-box" v-else :class="task.process === 4 ? 'progress-box-4' : ''">
<view class="u-progress-content"> <view class="u-progress-content">
<view class="u-progress-dot"></view> <view class="u-progress-dot"></view>
<view class="u-progress-info"> <view class="u-progress-info">

5
src/components/Tips/Tips.vue

@ -48,7 +48,8 @@ export default {
}, },
mounted() { mounted() {
this.height = window.screen.height; const system = uni.getSystemInfoSync();
this.height = system.windowHeight;
}, },
methods: { methods: {
@ -65,7 +66,6 @@ export default {
async onChangeStatus(type) { async onChangeStatus(type) {
try { try {
const param = { id: this.tip.taskId, type }; const param = { id: this.tip.taskId, type };
// TODO:
await uni.$u.api.updateTaskType(param); await uni.$u.api.updateTaskType(param);
if (type === 0) { if (type === 0) {
this.$t.ui.showToast('项目已重新开始'); this.$t.ui.showToast('项目已重新开始');
@ -77,6 +77,7 @@ export default {
this.$t.ui.showToast('项目结束'); this.$t.ui.showToast('项目结束');
} }
this.tip.show = false; this.tip.show = false;
// TODO:
// location.reload(); // location.reload();
// this.$router.go(0); // this.$router.go(0);
} catch (error) { } catch (error) {

2
src/main.js

@ -37,8 +37,6 @@ App.mpType = 'app';
const app = new Vue({ ...App, store }); const app = new Vue({ ...App, store });
// window.vm = app;
Vue.use(request, app); Vue.use(request, app);
Vue.use(tall, app); Vue.use(tall, app);
Vue.use(project, app); Vue.use(project, app);

3
src/pages/project/project.vue

@ -69,7 +69,8 @@ export default {
}, },
mounted() { mounted() {
this.height = window.screen.height + 'px'; const system = uni.getSystemInfoSync();
this.height = system.windowHeight + 'px';
}, },
onUnload() { onUnload() {

1
src/pages/test/test.vue

@ -46,7 +46,6 @@ export default {
console.log('update data: ', data); console.log('update data: ', data);
}, },
// TODO:
async createIndex() { async createIndex() {
// const data = await this.$db.createIndex('projects', 'sex', 'woman'); // const data = await this.$db.createIndex('projects', 'sex', 'woman');
console.log('update data: '); console.log('update data: ');

6
src/utils/cache.js

@ -130,7 +130,6 @@ export default {
const data = await uni.$t.storage.getStorage('projects'); const data = await uni.$t.storage.getStorage('projects');
return filter.projects(JSON.parse(data), startTime, endTime); return filter.projects(JSON.parse(data), startTime, endTime);
} catch (error) { } catch (error) {
console.error('error: ', error);
return []; return [];
} }
}, },
@ -177,7 +176,6 @@ export default {
const data = await uni.$t.storage.getStorage(`roles_${projectId}`); const data = await uni.$t.storage.getStorage(`roles_${projectId}`);
return filter.roles(JSON.parse(data)); return filter.roles(JSON.parse(data));
} catch (error) { } catch (error) {
console.error('error: ', error);
return null; return null;
} }
}, },
@ -235,7 +233,6 @@ export default {
const data = await uni.$t.storage.getStorage(`plan_task_${params.projectId}_${params.roleId}`); 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); return filter.planTask(JSON.parse(data), params.timeNode, params.queryNum, params.timeUnit, params.queryType);
} catch (error) { } catch (error) {
console.error('error: ', error);
return []; return [];
} }
}, },
@ -283,7 +280,6 @@ export default {
const data = await uni.$t.storage.getStorage(`fixed_tasks_${params.projectId}_${params.roleId}`); const data = await uni.$t.storage.getStorage(`fixed_tasks_${params.projectId}_${params.roleId}`);
return filter.fixedTasks(JSON.parse(data)); return filter.fixedTasks(JSON.parse(data));
} catch (error) { } catch (error) {
console.error('error: ', error);
return []; return [];
} }
}, },
@ -331,7 +327,6 @@ export default {
const data = await uni.$t.storage.getStorage(`variable_tasks_${params.projectId}_${params.roleId}`); const data = await uni.$t.storage.getStorage(`variable_tasks_${params.projectId}_${params.roleId}`);
return filter.dailyTask(JSON.parse(data), params.timeNode); return filter.dailyTask(JSON.parse(data), params.timeNode);
} catch (error) { } catch (error) {
console.error('error: ', error);
return []; return [];
} }
}, },
@ -378,7 +373,6 @@ export default {
const data = await uni.$t.storage.getStorage(`plugin_${pluginId}`); const data = await uni.$t.storage.getStorage(`plugin_${pluginId}`);
return filter.plugin(JSON.parse(data)); return filter.plugin(JSON.parse(data));
} catch (error) { } catch (error) {
console.error('error: ', error);
return null; return null;
} }
}, },

Loading…
Cancel
Save