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. 37
      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
--|--|--
- | api封装 | 7d4edfc
bind phone | 图形验证码;短信验证码;绑定手机号 | 93ffea2
- | cache indexedDB处理 | 3388967
calendar, tall.js | 上下滑动切换日历的模式,tall.js中domain根据环境变量切换 | 364e25d
- | db store | 6414c4f

8
src/components/Globals/Globals.vue

@ -12,9 +12,9 @@
<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>
<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-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">
<Plugin
:class="[`row-span-${plugin.row}`, `col-span-${plugin.col}`]"
@ -26,9 +26,9 @@
v-for="plugin in pluginArr"
/>
</template>
</block>
</template>
</template>
</template>
</block>
</view>
</scroll-view>
</view>

1
src/components/ImageCode/ImageCode.vue

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

4
src/components/Projects/Projects.vue

@ -7,10 +7,10 @@
{{ index + 1 }}
</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="mr-2">{{ project.name }}</view>
<!-- 状态 TODO:-->
<!-- 状态 TODO: -->
<view class="px-2 text-xs text-green-400 bg-green-100 rounded-full">进行中</view>
</view>

37
src/components/Roles/Roles.vue

@ -7,14 +7,18 @@
default-tab-choice 我的角色 && 当前展示
default-tab-item 我的角色 && 当前不展示
tab-choice 不是我的 && 当前展示
TODO:
-->
<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,
'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">
: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">
{{ item.name }}
</view>
@ -74,18 +78,23 @@ export default {
//
setCurrentRole(index) {
console.log('index: ', index);
const data = document.getElementsByClassName('tab-children');
// tabList
const query = uni.createSelectorQuery().in(this);
query
.selectAll('.tab-children')
.boundingClientRect(data => {
data.forEach(item => {
this.tabList.push({
width: item.clientWidth,
left: item.offsetLeft,
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) {

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

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

5
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) {

2
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);

3
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() {

1
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: ');

6
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;
}
},

Loading…
Cancel
Save