Browse Source

feat: 主体颜色

test2
xuesinan 4 years ago
parent
commit
bb5c0e36ed
  1. 12
      App.vue
  2. 1
      CHANGELOG.md
  3. 8
      apis/tall.js
  4. 4
      pages/index/index.vue
  5. 380
      pages/project/project.vue

12
App.vue

@ -18,10 +18,10 @@ export default {
this.checkNetwork(); //
this.getSystemInfo(); //
const token = this.$store.state.user.token || this.$storage.getStorageSync('anyringToken') || '';
if (token) {
this.$store.commit('user/setToken', token);
}
// const token = this.$store.state.user.token || this.$storage.getStorageSync('anyringToken') || '';
// if (token) {
// this.$store.commit('user/setToken', token);
// }
// if (!token) {
// this.$ui.showToast(', ');
@ -29,8 +29,8 @@ export default {
// return;
// }
// await this.syncLocalDataToStore(options.query.u); // localStoragestore
// token = await this.getToken();
await this.syncLocalDataToStore('1217647686598135808'); // localStoragestore
const token = await this.getToken();
// this.noPhone(this.$store.state.user.phone);
this.$store.dispatch('socket/initSocket');

1
CHANGELOG.md

@ -13,6 +13,7 @@
- | 将时间轴改成swiper滑动 | [12384f9](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/12384f9)
- | 日历页首页 | [561c8e6](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/561c8e6)
- | 日历页添加 | [1b46a91](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1b46a91)
- | 设置状态栏 | [9871356](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/9871356)
- | 时间轴接口 | [a95d005](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a95d005)
- | 时间轴页面 | [e926b75](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e926b75)
- | 时间轴展示 | [8b1b380](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/8b1b380)

8
apis/tall.js

@ -1,9 +1,9 @@
import Config from '@/common/js/config.js'
// const apiUrl = Config.apiUrl;
const apiUrl = Config.apiUrlNew;
// const tall = `${apiUrl}/tall3/v3.0`;
const tall = `${apiUrl}/ptostall`;
const apiUrl = Config.apiUrl;
// const apiUrl = Config.apiUrlNew;
const tall = `${apiUrl}/tall3/v3.0`;
// const tall = `${apiUrl}/ptostall`;
export function setupTall(app) {
uni.$u.api = { ...uni.$u.api } || {};

4
pages/index/index.vue

@ -5,7 +5,7 @@
</view>
<!-- <view class="flex flex-col h-full bg-gray-50" @click="openAuth"> -->
<view class="flex flex-col h-full bg-gray-50">
<theme class="flex flex-col h-full bg-gray-50">
<view class="relative">
<!-- <view class="relative" @touchmove="onMove"> -->
<!-- 日历 -->
@ -26,7 +26,7 @@
<!-- 全局提示框 -->
<u-top-tips ref="uTips"></u-top-tips>
</view>
</theme>
</template>
<script setup>

380
pages/project/project.vue

@ -1,189 +1,195 @@
<template>
<theme :style="{ height: height }" class="flex flex-col overflow-hidden u-font-14">
<!-- 标题栏 -->
<Title />
<view class="container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100">
<!-- 角色栏 -->
<Roles />
<swiper :current="roleIndex" class="swiper container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100" :indicator-dots="false" :autoplay="false" :circular="false" @change="tabsChange">
<swiper-item v-for="(task,index) in allTasks" :key="index">
<!-- 日常任务面板 -->
<Globals :globals="task.global" />
<!-- 定期任务面板 -->
<TimeLine :tasks="task.task" @getTasks="getTasks" class="flex-1 overflow-hidden" />
</swiper-item>
</swiper>
<!-- TODO: DEBUG: -->
<u-button @click="$store.commit('setTheme', 'theme-test')">测试切换主题</u-button>
</view>
</theme>
</template>
<script setup>
import { ref, computed, watch, onMounted } from 'vue';
import { useStore } from 'vuex';
import useInit from '@/hooks/project/useInit';
import useGetTasks from '@/hooks/project/useGetTasks';
import dayjs from 'dayjs';
const initHook = useInit();
const getTasksHook = useGetTasks();
const store = useStore();
const roleId = computed(() => store.state.role.roleId);
const timeNode = computed(() => store.state.task.timeNode);
const timeUnit = computed(() => store.state.task.timeUnit);
const projectId = computed(() => store.getters['project/projectId']);
const userId = computed(() => store.getters['user/userId']);
const newProjectInfo = computed(() => store.state.task.newProjectInfo);
const showScrollTo = computed(() => store.state.task.showScrollTo);
const visibleRoles = computed(() => store.state.role.visibleRoles);
const allTasks = computed(() => store.state.task.allTasks);
const roleIndex = computed(() => store.state.role.roleIndex);
const globals = computed(() => store.getters['task/globals']);
const timeGranularity = computed(() => store.getters['task/timeGranularity']);
const height = ref(null);
onMounted(() => {
const system = uni.getSystemInfoSync();
height.value = `${system.windowHeight}px`;
});
//
function getGlobalData() {
if(!allTasks.value[roleIndex]) {
const param = {
roleId: roleId.value,
timeNode: timeNode.value,
timeUnit: timeUnit.value,
projectId: projectId.value,
};
store.dispatch('task/getGlobal', param);
}
// allTasks
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
arr[index].global = [...globals.value];
store.commit('task/setAllTasks', arr);
}
//
function clearTasksData() {
//
store.commit('task/setPermanents', []);
store.commit('task/setDailyTasks', []);
//
store.commit('task/clearTasks');
//
//
store.commit('task/clearEndFlag');
}
/**
* 当角色发生变化时
* 重新查询永久日常任务和普通日常任务
* 注意: 切换角色后 重新设置了时间基准点 时间基准点一定会变
* 所以监听时间基准点获取 可变日常任务即可 这里不用获取 避免重复获取
*/
watch(roleId, newValue => {
if (newValue) {
// allTasks
if (allTasks.value.length && allTasks.value[roleIndex.value].global && allTasks.value[roleIndex.value].task) return;
console.log('当角色发生变化时', newValue);
store.commit('task/setTimeNode', Date.now());
//
const params = {
roleId: newValue,
projectId: projectId.value,
};
store.dispatch('task/getPermanent', params);
}
});
/**
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生 改变
*/
watch(timeNode, newValue => {
if (newValue && roleId.value) {
console.log('当时间基准点发生变化时');
clearTasksData();
//
getGlobalData(); //
getTasksHook.initPlanTasks(); //
//
let timer = null;
timer = setInterval(() => {
if (showScrollTo.value) {
clearInterval(timer);
setScrollPosition();
}
}, 300);
}
});
/**
* 当收到打开新项目消息状态时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
watch(newProjectInfo, newValue => {
console.log('当收到打开新项目消息状态时');
if (newValue && newValue.value.projectId && newValue.value.url) {
uni.$u.route('/', {
u: userId.value,
p: newValue.value.projectId,
url: newValue.value.url,
});
clearTasksData();
store.commit('role/setRoleId', '');
const options = uni.$route.query;
initHook.init(options);
}
});
function getTasks(params) {
getTasksHook.initPlanTasks(params); //
}
// tabsswiper
function tabsChange(e) {
const { id } = visibleRoles.value[e.detail.current];
store.commit('role/setRoleIndex', e.detail.current);
store.commit('role/setRoleId', id);
}
//
function setScrollPosition() {
// storagetaskId id
const taskId = uni.$storage.getStorageSync('taskId');
if (taskId) {
store.commit('task/setScrollToTaskId', `a${taskId}`);
uni.$storage.setStorageSync('taskId', ''); //
} else {
const item = allTasks.value[roleIndex.value].task.find(task => task.detailId);
if (item) {
store.commit('task/setScrollToTaskId', `a${item.id}`);
} else {
// taskId
// 线id 线
const task = allTasks.value[roleIndex.value].task.find(item => dayjs(+item.planStart).isSame(timeNode.value, timeGranularity.value));
task && store.commit('task/setScrollToTaskId', `a${task.id}`); // task id
<template>
<theme :style="{ height: height }" class="flex flex-col overflow-hidden u-font-14">
<!-- 标题栏 -->
<Title />
<view class="container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100">
<!-- 角色栏 -->
<Roles />
<swiper :current="roleIndex" class="swiper container flex flex-col flex-1 mx-auto overflow-hidden bg-gray-100" :indicator-dots="false" :autoplay="false" :circular="false" @change="tabsChange">
<swiper-item v-for="(task,index) in allTasks" :key="index">
<!-- 日常任务面板 -->
<Globals :globals="task.global" />
<!-- 定期任务面板 -->
<TimeLine :tasks="task.task" @getTasks="getTasks" class="flex-1 overflow-hidden" />
</swiper-item>
</swiper>
<!-- TODO: DEBUG: -->
<u-button @click="$store.commit('setTheme', 'theme-test')">测试切换主题</u-button>
</view>
</theme>
</template>
<script setup>
import { ref, computed, watch, onMounted } from 'vue';
import { useStore } from 'vuex';
import useInit from '@/hooks/project/useInit';
import useGetTasks from '@/hooks/project/useGetTasks';
import dayjs from 'dayjs';
const initHook = useInit();
const getTasksHook = useGetTasks();
const store = useStore();
const projectId = computed(() => store.getters['project/projectId']);
const userId = computed(() => store.getters['user/userId']);
const roleId = computed(() => store.state.role.roleId); // id
const roleIndex = computed(() => store.state.role.roleIndex); //
const visibleRoles = computed(() => store.state.role.visibleRoles); //
const timeNode = computed(() => store.state.task.timeNode); //
const timeUnit = computed(() => store.state.task.timeUnit); //
const newProjectInfo = computed(() => store.state.task.newProjectInfo);
const showScrollTo = computed(() => store.state.task.showScrollTo); //
const allTasks = computed(() => store.state.task.allTasks); //
const globals = computed(() => store.getters['task/globals']); // +
const timeGranularity = computed(() => store.getters['task/timeGranularity']); // dayjs add
const height = ref(null); //
onMounted(() => {
const system = uni.getSystemInfoSync();
height.value = `${system.windowHeight}px`;
});
/**
* 当角色发生变化时
* 重新查询永久日常任务和普通日常任务
* 注意: 切换角色后 重新设置了时间基准点 时间基准点一定会变
* 所以监听时间基准点获取 可变日常任务即可 这里不用获取 避免重复获取
*/
watch(roleId, newValue => {
if (newValue) {
// allTasks
if (allTasks.value.length && allTasks.value[roleIndex.value].global && allTasks.value[roleIndex.value].task)
return;
console.log('当角色发生变化时', newValue);
store.commit('task/setTimeNode', Date.now());
//
const params = {
roleId: newValue,
projectId: projectId.value,
};
store.dispatch('task/getPermanent', params);
}
}
}
</script>
<style lang="scss" scoped>
.border-b {
border-bottom: 1px solid #e4e7ed;
}
});
/**
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生 改变
*/
watch(timeNode, newValue => {
if (newValue && roleId.value) {
console.log('当时间基准点发生变化时');
clearTasksData();
//
getGlobalData(); //
getTasksHook.initPlanTasks(); //
//
let timer = null;
timer = setInterval(() => {
if (showScrollTo.value) {
clearInterval(timer);
setScrollPosition();
}
}, 300);
}
});
/**
* 当收到打开新项目消息状态时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
watch(newProjectInfo, newValue => {
console.log('当收到打开新项目消息状态时');
if (newValue && newValue.value.projectId && newValue.value.url) {
uni.$u.route('/', {
u: userId.value,
p: newValue.value.projectId,
url: newValue.value.url,
});
clearTasksData();
store.commit('role/setRoleId', '');
const options = uni.$route.query;
initHook.init(options);
}
});
//
function getGlobalData() {
if (!allTasks.value[roleIndex]) {
const param = {
roleId: roleId.value,
timeNode: timeNode.value,
timeUnit: timeUnit.value,
projectId: projectId.value,
};
store.dispatch('task/getGlobal', param);
}
// allTasks
const index = visibleRoles.value.findIndex(role => role.id === roleId.value);
const arr = [...allTasks.value];
arr[index].global = [...globals.value];
store.commit('task/setAllTasks', arr);
}
//
function clearTasksData() {
//
store.commit('task/setPermanents', []);
store.commit('task/setDailyTasks', []);
//
store.commit('task/clearTasks');
//
//
store.commit('task/clearEndFlag');
}
function getTasks(params) {
getTasksHook.initPlanTasks(params); //
}
// tabsswiper
function tabsChange(e) {
const {
id
} = visibleRoles.value[e.detail.current];
store.commit('role/setRoleIndex', e.detail.current);
store.commit('role/setRoleId', id);
}
//
function setScrollPosition() {
// storagetaskId id
const taskId = uni.$storage.getStorageSync('taskId');
if (taskId) {
store.commit('task/setScrollToTaskId', `a${taskId}`);
uni.$storage.setStorageSync('taskId', ''); //
} else {
const item = allTasks.value[roleIndex.value].task.find(task => task.detailId);
if (item) {
store.commit('task/setScrollToTaskId', `a${item.id}`);
} else {
// taskId
// 线id 线
const task = allTasks.value[roleIndex.value].task.find(item => dayjs(+item.planStart).isSame(timeNode.value,
timeGranularity.value));
task && store.commit('task/setScrollToTaskId', `a${task.id}`); // task id
}
}
}
</script>
<style lang="scss" scoped>
.border-b {
border-bottom: 1px solid #e4e7ed;
}
</style>

Loading…
Cancel
Save