Browse Source

feat: 刷新页面store数据清空

test2
xuesinan 4 years ago
parent
commit
17869db2f2
  1. 1
      CHANGELOG.md
  2. 2
      components/Plugin/Plugin.vue
  3. 49
      components/Render/Render.vue
  4. 3
      hooks/project/useGenerateWebviewParam.js
  5. 24
      pages.json
  6. 17
      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)
- | 刷新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)
- | 添加财务申请详情页 | [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)
- | 未登录调用项目列表接口 | [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)

2
components/Plugin/Plugin.vue

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

49
components/Render/Render.vue

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

3
hooks/project/useGenerateWebviewParam.js

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

24
pages.json

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

17
pages/project/project.vue

@ -41,6 +41,7 @@ const initHook = useInit();
const getTasksHook = useGetTasks();
const store = useStore();
const projectId = computed(() => store.getters['project/projectId']);
const userInfo = computed(() => store.state.user.user);
const userId = computed(() => store.getters['user/userId']);
const roleId = computed(() => store.state.role.roleId); // id
const roleIndex = computed(() => store.state.role.roleIndex); //
@ -59,6 +60,13 @@ onMounted(() => {
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}`);
uni.$storage.setStorageSync('taskId', ''); //
} else {
if (allTasks.value[roleIndex.value]) {
if (!(allTasks.value[roleIndex.value].task && allTasks.value[roleIndex.value].task.length)) {
allTasks.value[roleIndex.value].task = [];
}
}
if (!allTasks.value[roleIndex.value]) return;
if (allTasks.value[roleIndex.value] && !allTasks.value[roleIndex.value].task) {
allTasks.value[roleIndex.value].task = [];
}
const item = allTasks.value[roleIndex.value].task.find(task => task.detailId);
if (item) {

4
pages/workbench/workbench.vue

@ -1,5 +1,5 @@
<template>
<image src="../../static/adv.jpg"></image>
<image src="../../static/work.png"></image>
</template>
<script>
@ -8,7 +8,7 @@
<style lang="scss" scoped>
image {
width: 100%;
height: calc(100vh - var(--status-bar-height));
height: calc(100% - var(--status-bar-height));
object-fit: cover;
}
</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`, // 项目跳转域名
guide: '', // 引导页图片json
advs: '', // 广告图片json
businessPlugin: [], // 所有服务
allPlugin: [], // 所有插件
businessPlugin: '', // 所有服务
allPlugin: '', // 所有插件
firstOpenApp: false, // 是否是第一次打开APP或者引导页有更新,false表示从未打开过,true表示打开过
isOpenApp: true, // 是否打开APP
};
@ -128,8 +128,8 @@ const actions = {
async getBusinessPlugin({ commit }, param) {
try {
const res = await uni.$u.api.getBusinessPlugin();
uni.$storage.setStorageSync('businessPlugin', res);
commit('setBusinessPlugin', res || []);
uni.$storage.setStorageSync('businessPlugin', JSON.stringify(res) || '');
commit('setBusinessPlugin', JSON.stringify(res) || '');
return res;
} catch (error) {
uni.$ui.showToast(error.msg);
@ -140,8 +140,8 @@ const actions = {
async getAllPlugin({ commit }, param) {
try {
const res = await uni.$u.api.getAllPlugin();
uni.$storage.setStorageSync('allPlugin', res || []);
commit('setAllPlugin', res);
uni.$storage.setStorageSync('allPlugin', JSON.stringify(res) || '');
commit('setAllPlugin', JSON.stringify(res) || '');
return res;
} catch (error) {
uni.$ui.showToast(error.msg);

Loading…
Cancel
Save