Browse Source

feat: 刷新页面store数据清空

test2
xuesinan 4 years ago
parent
commit
17869db2f2
  1. 1
      CHANGELOG.md
  2. 2
      components/Plugin/Plugin.vue
  3. 27
      components/Render/Render.vue
  4. 3
      hooks/project/useGenerateWebviewParam.js
  5. 24
      pages.json
  6. 15
      pages/project/project.vue
  7. 4
      pages/workbench/workbench.vue
  8. BIN
      static/work.png
  9. 12
      store/index.js

1
CHANGELOG.md

@ -45,6 +45,7 @@
- | 手机号登录 | [565585b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/565585b) - | 手机号登录 | [565585b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/565585b)
- | 刷新token重新运行api | [02fb4bf](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/02fb4bf) - | 刷新token重新运行api | [02fb4bf](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/02fb4bf)
- | 添加 timeline | [72dad2b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/72dad2b) - | 添加 timeline | [72dad2b](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/72dad2b)
- | 添加财务申请详情页 | [e69d233](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/e69d233)
- | 跳转财务详情 | [742720d](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/742720d) - | 跳转财务详情 | [742720d](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/742720d)
- | 未登录调用项目列表接口 | [aab6489](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/aab6489) - | 未登录调用项目列表接口 | [aab6489](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/aab6489)
- | 文件上传添加APP的条件判断 | [5d4c1be](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/5d4c1be) - | 文件上传添加APP的条件判断 | [5d4c1be](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/5d4c1be)

2
components/Plugin/Plugin.vue

@ -28,6 +28,7 @@
<p-domain-source-manage v-else-if="pluginId === '20'" class="p-2" /> <p-domain-source-manage v-else-if="pluginId === '20'" class="p-2" />
<p-project-version-management v-else-if="pluginId === '21'" class="p-2" /> <p-project-version-management v-else-if="pluginId === '21'" class="p-2" />
<!-- #ifdef H5 -->
<Render <Render
v-else v-else
:task="task" :task="task"
@ -37,6 +38,7 @@
:businessPluginId="businessPluginId" :businessPluginId="businessPluginId"
:param="param" :param="param"
/> />
<!-- #endif -->
</view> </view>
</template> </template>

27
components/Render/Render.vue

@ -4,7 +4,7 @@
<view <view
class="content" class="content"
style="border-radius: 8px;" style="border-radius: 8px;"
id="project" :id="`project-${task.id}`"
:data-did="task.detailId" :data-did="task.detailId"
:data-param="param" :data-param="param"
:data-pdu="task.planDuration" :data-pdu="task.planDuration"
@ -22,7 +22,7 @@
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<view <view
class="content" class="content"
id="project" :id="`project-${task.id}`"
:data-did="task.detailId" :data-did="task.detailId"
:data-param="param" :data-param="param"
:data-pdu="task.planDuration" :data-pdu="task.planDuration"
@ -60,6 +60,7 @@ const roleId = computed(() => store.state.role.roleId);
const token = computed(() => store.state.user.token); const token = computed(() => store.state.user.token);
const userId = computed(() => store.getters['user/userId']); const userId = computed(() => store.getters['user/userId']);
const projectId = computed(() => store.getters['project/projectId']); const projectId = computed(() => store.getters['project/projectId']);
const allPlugin = uni.$storage.getStorageSync('allPlugin');
</script> </script>
<script module="project" lang="renderjs"> <script module="project" lang="renderjs">
@ -69,6 +70,9 @@ export default {
pluginContent: null, pluginContent: null,
pluginJs: null, pluginJs: null,
show: false, show: false,
pluginlists: [],
flag: false,
pluginInfo: {}
}; };
}, },
@ -81,12 +85,26 @@ export default {
methods: { methods: {
// //
async getPlugin() { async getPlugin() {
this.pluginlists = JSON.parse(this.allPlugin);
this.pluginlists.forEach(item => {
if (this.pluginId === item.id) {
this.flag = true;
this.pluginInfo = item;
this.show = true;
}
});
if (this.flag) {
this.$nextTick(() => {
this.init(this.pluginInfo);
});
} else {
const params = { businessPluginId: this.businessPluginId }; const params = { businessPluginId: this.businessPluginId };
this.$catchReq.getOtherPlugin(params, (err, res) => { this.$catchReq.getOtherPlugin(params, (err, res) => {
if (err) { if (err) {
console.error('err: ', err); console.error('err: ', err);
} else { } else {
if (!res || !res.id) return; if (!res) return;
if (res.html && res.js) { if (res.html && res.js) {
this.show = true; this.show = true;
this.$nextTick(() => { this.$nextTick(() => {
@ -95,10 +113,11 @@ export default {
} }
} }
}); });
}
}, },
init(res) { init(res) {
const content = document.querySelector('.content'); const content = document.getElementById(`project-${this.task.id}`);
content.innerHTML = res.html; content.innerHTML = res.html;
const script = document.createElement('script'); const script = document.createElement('script');

3
hooks/project/useGenerateWebviewParam.js

@ -3,12 +3,11 @@ import { useStore } from 'vuex';
export default function useGenerateWebviewParam() { export default function useGenerateWebviewParam() {
const store = useStore(); const store = useStore();
console.log('store: ', store);
const projectId = computed(() => store.getters['project/projectId']); const projectId = computed(() => store.getters['project/projectId']);
const token = computed(() => store.state.user.token); const token = computed(() => store.state.user.token);
const projectName = computed(() => store.getters['project/projectName']); const projectName = computed(() => store.getters['project/projectName']);
console.log('projectName: ', projectName);
return { return {
projectId: projectId.value, projectId: projectId.value,
token: token.value, token: token.value,

24
pages.json

@ -1,5 +1,5 @@
{ {
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages "pages": [
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
@ -10,15 +10,13 @@
{ {
"path": "pages/workbench/workbench", "path": "pages/workbench/workbench",
"style": { "style": {
"navigationBarText": "TALL", "navigationBarTitleText": "工作台"
"navigationStyle": "custom"
} }
}, },
{ {
"path": "pages/business/business", "path": "pages/business/business",
"style": { "style": {
"navigationBarText": "业务列表", "navigationBarTitleText": "业务列表"
"navigationStyle": "custom"
} }
}, },
{ {
@ -28,36 +26,28 @@
"navigationBarTextStyle": "white" "navigationBarTextStyle": "white"
} }
}, },
//
{ {
"path": "pages/user/accountLogin", "path": "pages/user/accountLogin",
"style": { "style": {
"navigationStyle": "custom", "navigationBarTitleText": "用户名登录"
"navigationBarTextStyle": "white"
} }
}, },
//
{ {
"path": "pages/user/login", "path": "pages/user/login",
"style": { "style": {
"navigationStyle": "custom", "navigationBarTitleText": "登录"
"navigationBarTextStyle": "white"
} }
}, },
//
{ {
"path": "pages/user/rigister", "path": "pages/user/rigister",
"style": { "style": {
"navigationStyle": "custom", "navigationBarTitleText": "注册"
"navigationBarTextStyle": "white"
} }
}, },
//
{ {
"path": "pages/user/agreement", "path": "pages/user/agreement",
"style": { "style": {
"navigationStyle": "custom", "navigationBarTitleText": "注册协议"
"navigationBarTextStyle": "white"
} }
}, },
{ {

15
pages/project/project.vue

@ -41,6 +41,7 @@ const initHook = useInit();
const getTasksHook = useGetTasks(); const getTasksHook = useGetTasks();
const store = useStore(); const store = useStore();
const projectId = computed(() => store.getters['project/projectId']); const projectId = computed(() => store.getters['project/projectId']);
const userInfo = computed(() => store.state.user.user);
const userId = computed(() => store.getters['user/userId']); const userId = computed(() => store.getters['user/userId']);
const roleId = computed(() => store.state.role.roleId); // id const roleId = computed(() => store.state.role.roleId); // id
const roleIndex = computed(() => store.state.role.roleIndex); // const roleIndex = computed(() => store.state.role.roleIndex); //
@ -59,6 +60,13 @@ onMounted(() => {
height.value = `${system.windowHeight}px`; height.value = `${system.windowHeight}px`;
}); });
if (!userInfo.value) {
let res = uni.$storage.getStorageSync('user');
if (res) {
store.commit('user/setUser', JSON.parse(res));
}
}
/** /**
* 当角色发生变化时 * 当角色发生变化时
* 重新查询永久日常任务和普通日常任务 * 重新查询永久日常任务和普通日常任务
@ -189,12 +197,11 @@ function setScrollPosition() {
store.commit('task/setScrollToTaskId', `a${taskId}`); store.commit('task/setScrollToTaskId', `a${taskId}`);
uni.$storage.setStorageSync('taskId', ''); // uni.$storage.setStorageSync('taskId', ''); //
} else { } else {
if (allTasks.value[roleIndex.value]) { if (!allTasks.value[roleIndex.value]) return;
if (!(allTasks.value[roleIndex.value].task && allTasks.value[roleIndex.value].task.length)) {
if (allTasks.value[roleIndex.value] && !allTasks.value[roleIndex.value].task) {
allTasks.value[roleIndex.value].task = []; allTasks.value[roleIndex.value].task = [];
} }
}
const item = allTasks.value[roleIndex.value].task.find(task => task.detailId); const item = allTasks.value[roleIndex.value].task.find(task => task.detailId);
if (item) { if (item) {

4
pages/workbench/workbench.vue

@ -1,5 +1,5 @@
<template> <template>
<image src="../../static/adv.jpg"></image> <image src="../../static/work.png"></image>
</template> </template>
<script> <script>
@ -8,7 +8,7 @@
<style lang="scss" scoped> <style lang="scss" scoped>
image { image {
width: 100%; width: 100%;
height: calc(100vh - var(--status-bar-height)); height: calc(100% - var(--status-bar-height));
object-fit: cover; object-fit: cover;
} }
</style> </style>

BIN
static/work.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

12
store/index.js

@ -18,8 +18,8 @@ const state = {
domain: `${Config.apiUrl}/defaultwbs`, // 项目跳转域名 domain: `${Config.apiUrl}/defaultwbs`, // 项目跳转域名
guide: '', // 引导页图片json guide: '', // 引导页图片json
advs: '', // 广告图片json advs: '', // 广告图片json
businessPlugin: [], // 所有服务 businessPlugin: '', // 所有服务
allPlugin: [], // 所有插件 allPlugin: '', // 所有插件
firstOpenApp: false, // 是否是第一次打开APP或者引导页有更新,false表示从未打开过,true表示打开过 firstOpenApp: false, // 是否是第一次打开APP或者引导页有更新,false表示从未打开过,true表示打开过
isOpenApp: true, // 是否打开APP isOpenApp: true, // 是否打开APP
}; };
@ -128,8 +128,8 @@ const actions = {
async getBusinessPlugin({ commit }, param) { async getBusinessPlugin({ commit }, param) {
try { try {
const res = await uni.$u.api.getBusinessPlugin(); const res = await uni.$u.api.getBusinessPlugin();
uni.$storage.setStorageSync('businessPlugin', res); uni.$storage.setStorageSync('businessPlugin', JSON.stringify(res) || '');
commit('setBusinessPlugin', res || []); commit('setBusinessPlugin', JSON.stringify(res) || '');
return res; return res;
} catch (error) { } catch (error) {
uni.$ui.showToast(error.msg); uni.$ui.showToast(error.msg);
@ -140,8 +140,8 @@ const actions = {
async getAllPlugin({ commit }, param) { async getAllPlugin({ commit }, param) {
try { try {
const res = await uni.$u.api.getAllPlugin(); const res = await uni.$u.api.getAllPlugin();
uni.$storage.setStorageSync('allPlugin', res || []); uni.$storage.setStorageSync('allPlugin', JSON.stringify(res) || '');
commit('setAllPlugin', res); commit('setAllPlugin', JSON.stringify(res) || '');
return res; return res;
} catch (error) { } catch (error) {
uni.$ui.showToast(error.msg); uni.$ui.showToast(error.msg);

Loading…
Cancel
Save