Browse Source

style: 细节调整

refact
wally 4 years ago
parent
commit
bdd5f87c89
  1. 22
      App.vue
  2. 4
      CHANGELOG.md
  3. 116
      hooks/project/useInit.js
  4. 32
      pages/project/project.vue

22
App.vue

@ -88,9 +88,9 @@ export default {
},
/**
* 没有手机号 跳转绑定手机号的界面
* @param {string} phone
*/
* 没有手机号 跳转绑定手机号的界面
* @param {string} phone
*/
async noPhone(phone) {
if (!phone) {
uni.navigateTo({ title: '/pages/phone-bind/phone-bind' });
@ -101,13 +101,13 @@ export default {
</script>
<style lang="scss">
/*每个页面公共css */
@import "@/uni_modules/vk-uview-ui/index.scss";
@import '@/common/styles/iconfont.scss';
@import '@/common/styles/app.scss';
@import '@/common/styles/tailwind.scss';
/*每个页面公共css */
@import "@/uni_modules/vk-uview-ui/index.scss";
@import '@/common/styles/iconfont.scss';
@import '@/common/styles/app.scss';
@import '@/common/styles/tailwind.scss';
page {
height: 100%;
}
page {
height: 100%;
}
</style>

4
CHANGELOG.md

@ -1,4 +1,4 @@
# 1.0.0 (2022-01-07)
# 1.0.0 (2022-01-10)
### 🌟 新功能
范围|描述|commitId
@ -9,6 +9,7 @@
- | 使用uview完成api请求 | [1b3efd8](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1b3efd8)
- | 日历页添加 | [1b46a91](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1b46a91)
- | 日历页首页 | [561c8e6](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/561c8e6)
- | 时间轴接口 | [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)
- | 更新代码 | [392c8cc](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/392c8cc)
- | 项目列表 | [a52e6d5](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/a52e6d5)
@ -24,6 +25,7 @@
### 🔨 代码重构
范围|描述|commitId
--|--|--
- | project init 重构 | [2457a87](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/2457a87)
- | 重构project init 部分 | [c7bf2df](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/c7bf2df)

116
hooks/project/useInit.js

@ -1,27 +1,10 @@
import { computed, nextTick, onMounted, ref, watch } from 'vue';
import { computed } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import useGetUserIdFromLocal from '@/hooks/user/useGetUserIdFromLocal';
import { useStore } from 'vuex';
// import {
// flatten
// } from 'lodash';
export default function useInit() {
const store = useStore();
const token = computed(() => store.state.user.token);
const userId = useGetUserIdFromLocal();
const roleId = computed(() => store.state.role.roleId);
const timeNode = computed(() => store.state.task.timeNode);
const timeUnit = computed(() => store.state.task.timeUnit);
const tasks = computed(() => store.state.task.tasks);
const newProjectInfo = computed(() => store.state.task.newProjectInfo);
const showScrollTo = computed(() => store.state.task.showScrollTo);
const timeGranularity = computed(() => store.getters['task/timeGranularity']);
const projectId = computed(() => store.getters['project/projectId']);
const height = ref(null);
const timeLine = ref(null);
onLoad(options => {
if (options.share && options.share === '1') {
@ -36,16 +19,19 @@ export default function useInit() {
// height.value = `${system.windowHeight}px`;
// });
// 设置 初始显示角色信息
function setInitialRoleId(visibleList) {
if (!visibleList || !visibleList.length) return;
const index = visibleList.findIndex(item => +item.mine === 1);
const currentRole = index > 0 ? visibleList[index] : visibleList[0];
const storageRoleId = uni.$storage.getStorageSync('roleId');
const currentRoleId = storageRoleId || (currentRole ? currentRole.id : '');
store.commit('role/setRoleId', currentRoleId);
// 清空storage
uni.$storage.setStorageSync('roleId', '');
/**
* 通过项目id获取项目信息
* @param {object} params 提交的参数
*/
async function getProjectById(params) {
try {
const data = await uni.$u.api.findProjectById(params);
store.commit('project/setProject', data);
// 根据项目id获取角色列表
getRoles(params);
} catch (error) {
console.log('error: ', error || '获取项目信息失败');
}
}
/**
@ -65,44 +51,23 @@ export default function useInit() {
});
}
/**
* 通过项目id获取项目信息
* @param {object} params 提交的参数
*/
async function getProjectById(params) {
try {
const data = await uni.$u.api.findProjectById(params);
store.commit('project/setProject', data);
// 根据项目id获取角色列表
getRoles(params);
} catch (error) {
console.log('error: ', error || '获取项目信息失败');
}
// 设置 初始显示角色信息
function setInitialRoleId(visibleList) {
if (!visibleList || !visibleList.length) return;
const index = visibleList.findIndex(item => +item.mine === 1);
const currentRole = index > 0 ? visibleList[index] : visibleList[0];
const storageRoleId = uni.$storage.getStorageSync('roleId');
const currentRoleId = storageRoleId || (currentRole ? currentRole.id : '');
store.commit('role/setRoleId', currentRoleId);
// 清空storage
uni.$storage.setStorageSync('roleId', '');
}
/**
* 初始化
* token userId处理
* 1.1 store里有token 且没过期直接使用store的token
* 1.2 store里的token不可用 查localStorage里的token有且没过期 用localStorage里的token
* 2. store里跟localStorage里的token均不可用 查userId
* 2.1 url里有userId 将userId保存store和localStorage根据userId查token
* 2.2 url里没有userId 查store里的userId有无 有的话 根据store里的userId获取token
* 2.3 url跟store的userId均没有查localStorage里的userId 根据userId获取token
* @param {object | null} options
*/
function init(options) {
console.log('初始化init');
if (!token.value) {
// 不论有没有token都直接从userId获取token
// token有过期时间 从本地获取可能是过期 干脆直接从userId获取
if (!options || !options.u) {
uni.$ui.showToast('缺少用户信息参数'); // 参数里没有u (userId)提示
} else {
store.dispatch('user/getToken', options.u);
}
}
// 参数里有项目名称 就设置标题里的项目名称
options && options.pname && store.commit('project/setProjectName', options.pname);
@ -114,43 +79,26 @@ export default function useInit() {
uni.$storage.setStorageSync('roleId', '');
}
// 根据项目id获取项目信息
const params = {
projectId: options.p,
num: 0,
};
const params = { projectId: options.p, num: 0 };
getProjectById(params);
// 查询医院是否填写了调查问卷
// this.handleQueryNotWrite(options.p);
// 根据项目id获取成员列表
store.dispatch('role/getAllMembers', {
projectId: options.p,
});
store.dispatch('role/getAllMembers', { projectId: options.p });
}
}
// 分享链接来的初始化
async function shareInit(options) {
console.log('分享链接来的初始化init');
const storageUser = uni.$storage.getStorageSync('user');
const user = storageUser ? JSON.parse(storageUser) : null;
if (user && user.id) {
await store.dispatch('user/getToken', user.id);
const res = await clickShare({
code: options.shareId,
});
const res = await clickShare({ code: options.shareId });
if (res && res.projectId) {
let query = {
...uni.$route.query,
};
query = {
u: user.id,
p: res.projectId,
};
uni.$router.push({
path: uni.$route.path,
query,
});
console.log('query', query);
let query = { ...uni.$route.query };
query = { u: user.id, p: res.projectId };
uni.$router.push({ path: uni.$route.path, query });
init(query);
}
} else {
@ -158,7 +106,5 @@ export default function useInit() {
}
}
return {
init,
};
return { init };
}

32
pages/project/project.vue

@ -17,10 +17,7 @@
</template>
<script setup>
import {
computed,
watch,
} from 'vue';
import { computed, watch } from 'vue';
import { useStore } from 'vuex';
import useInit from '@/hooks/project/useInit';
import useGetTasks from '@/hooks/project/useGetTasks';
@ -36,10 +33,10 @@ const userId = computed(() => store.getters['user/userId']);
const newProjectInfo = computed(() => store.state.task.newProjectInfo);
/**
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生 改变
*/
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生 改变
*/
watch(timeNode, newValue => {
if (newValue && roleId.value) {
console.log('当时间基准点发生变化时');
@ -51,11 +48,11 @@ watch(timeNode, newValue => {
});
/**
* 当角色发生变化时
* 重新查询永久日常任务和普通日常任务
* 注意: 切换角色后 重新设置了时间基准点 时间基准点一定会变
* 所以监听时间基准点获取 可变日常任务即可 这里不用获取 避免重复获取
*/
* 当角色发生变化时
* 重新查询永久日常任务和普通日常任务
* 注意: 切换角色后 重新设置了时间基准点 时间基准点一定会变
* 所以监听时间基准点获取 可变日常任务即可 这里不用获取 避免重复获取
*/
watch(roleId, newValue => {
if (newValue) {
console.log('当角色发生变化时', newValue);
@ -70,10 +67,10 @@ watch(roleId, newValue => {
});
/**
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
* 当时间基准点发生变化时
* 重新根据时间和角色查询普通日常任务
* 永久日常任务不发生改变
*/
watch(newProjectInfo, newValue => {
console.log('当时间基准点发生变化时');
if (newValue && newValue.value.projectId && newValue.value.url) {
@ -112,7 +109,6 @@ function clearTasksData() {
//
store.commit('task/clearEndFlag');
}
</script>
<style lang="scss" scoped>

Loading…
Cancel
Save