Browse Source

feat: 服务、插件缓存、导入选择服务列表、

test2
xuesinan 4 years ago
parent
commit
cc8004b325
  1. 9
      App.vue
  2. 1
      CHANGELOG.md
  3. 6
      apis/tall.js
  4. 6
      apis/wbs.js
  5. 49
      pages/business/business.vue
  6. 57
      store/index.js

9
App.vue

@ -28,6 +28,11 @@ export default {
this.getGuide(1);
//
if (!uni.$storage.getStorageSync('businessPlugin')) {
this.getServices();
this.getPlugins();
}
setInterval(() => {
this.getServices();
this.getPlugins();
@ -68,14 +73,14 @@ export default {
* 查询服务
*/
async getServices() {
console.log('服务')
this.$store.dispatch('getBusinessPlugin');
},
/**
* 查询插件
*/
async getPlugins() {
console.log('插件')
this.$store.dispatch('getAllPlugin');
},
async getToken() {

1
CHANGELOG.md

@ -16,6 +16,7 @@
- | 获取交付物信息 | [5ae68e2](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/5ae68e2)
- | 获取手机唯一码 | [3f60cf8](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/3f60cf8)
- | 将时间轴改成swiper滑动 | [12384f9](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/12384f9)
- | 解决时间轴日常任务不显示问题 | [c532a93](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/c532a93)
- | 日历页首页 | [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)
- | 设置项目域名 | [1a835f1](https://101.201.226.163:50022/TALL/TALL-MUI-4/commits/1a835f1)

6
apis/tall.js

@ -7,7 +7,11 @@ const tall = `${apiUrl}/ptostall`;
export function setupTall(app) {
uni.$u.api = { ...uni.$u.api } || {};
// 查询广告页和引导页
uni.$u.api.getGuide = type => uni.$u.http.get(`${tall}/business/guide`, { type });
uni.$u.api.getGuide = type => uni.$u.http.get(`${tall}/business/guide`, { type });
// 查询服务
uni.$u.api.getBusinessPlugin = params => uni.$u.http.post(`${tall}/business/query/businessPlugin`, params);
// 查询本域所有插件
uni.$u.api.getAllPlugin = params => uni.$u.http.post(`${tall}/business/query/plugin`, params);
// 登录
uni.$u.api.signin = params => uni.$u.http.post(`${tall}/users/signin`, params);
// 注册

6
apis/wbs.js

@ -3,5 +3,7 @@ import Config from "@/common/js/config.js"
export function setupWbs(app) {
uni.$u.api = { ...uni.$u.api } || {};
// 导入wbs
uni.$u.api.import = formData => uni.$upload.chooseAndUpload(`${Config.apiUrl}/wbs`, formData);
}
uni.$u.api.import = formData => uni.$upload.chooseAndUpload(`${Config.apiUrl}/wbs`, formData);
// 导入时查找域内的业务列表
uni.$u.api.getBusinessList = params => uni.$u.http.post(`${Config.apiUrl}/ptostall/business/import/query`, params);
}

49
pages/business/business.vue

@ -1,13 +1,37 @@
<template>
<view class="business-box">
<view class="business-wrap" v-for="(item, index) in 15" :key="index" @click="toUpload">
<view class="name">业务{{item}}</view>
<view class="desc">业务{{item}}</view>
<view class="business-wrap" v-for="(item, index) in list" :key="index" @click="toUpload">
<view class="business-info">
<view class="name">{{item.name}}</view>
<!-- <view class="desc">{{item.url}}</view> -->
</view>
<view class="mwbs-list" v-if="item.mwbsList && item.mwbsList.length > 0">
<view class="mwbs-item" v-for="(val, key) in item.mwbsList" :key="key" @click.stop="toUpload">
<view class="name">{{val.projectName}}</view>
<!-- <view class="desc">{{val}}</view> -->
</view>
</view>
</view>
</view>
</template>
<script setup>
<script setup>
import { ref } from 'vue';
const list = ref([]);
getList();
async function getList() {
try {
const res = await uni.$u.api.getBusinessList();
list.value = res;
} catch (error) {
console.error('error: ', error);
}
}
async function toUpload() {
try {
const res = await uni.$u.api.import();
@ -37,10 +61,13 @@
}
.business-wrap {
padding: 10px 20px;
border-bottom: 1px solid #eeeeee;
width: 100%;
box-sizing: border-box;
box-sizing: border-box;
.business-info, .mwbs-item {
padding: 10px;
border-bottom: 1px solid #eeeeee;
}
.name {
line-height: 36px;
@ -49,6 +76,14 @@
.desc {
font-size: 12px;
color: #999;
}
.mwbs-list {
padding-left: 16px;
.mwbs-item:last-child {
border-bottom: none;
}
}
}
</style>

57
store/index.js

@ -18,6 +18,8 @@ const state = {
domain: `${Config.apiUrl}/defaultwbs`, // 项目跳转域名
guide: '', // 引导页图片json
advs: '', // 广告图片json
businessPlugin: [], // 所有服务
allPlugin: [], // 所有插件
};
const getters = {
@ -75,18 +77,73 @@ const mutations = {
state.domain = data;
},
/**
* 设置引导页图片
* @param {Object} state
* @param {Object} data
*/
setGuide(state, data) {
state.guide = data;
},
/**
* 设置广告页图片
* @param {Object} state
* @param {Object} data
*/
setAdvs(state, data) {
state.advs = data;
},
/**
* 设置服务列表
* @param {Object} state
* @param {Object} data
*/
setBusinessPlugin(state, data) {
state.businessPlugin = data;
},
/**
* 设置插件列表
* @param {Object} state
* @param {Object} data
*/
setAllPlugin(state, data) {
state.allPlugin = data;
}
};
const actions = {
async getBusinessPlugin({ commit }, param) {
try {
const res = await uni.$u.api.getBusinessPlugin();
uni.$storage.setStorageSync('businessPlugin', res);
commit('setBusinessPlugin', res || []);
return res;
} catch (error) {
uni.$ui.showToast(error.msg);
throw error;
}
},
async getAllPlugin({ commit }, param) {
try {
const res = await uni.$u.api.getAllPlugin();
uni.$storage.setStorageSync('allPlugin', res || []);
commit('setAllPlugin', res);
return res;
} catch (error) {
uni.$ui.showToast(error.msg);
throw error;
}
}
};
export default createStore({
state,
getters,
mutations,
actions,
modules: { user, socket, project, role, task, deliver, finance },
});

Loading…
Cancel
Save