Browse Source

feat: 日常任务插件布局

pull/16/head^2
aBin 4 years ago
parent
commit
d62abd0343
  1. 3
      .env.development
  2. 3
      .env.production
  3. 1
      .eslintrc.js
  4. 1
      CHANGELOG.md
  5. 9
      src/apis/project.js
  6. 11
      src/apis/task.js
  7. 43
      src/components/Globals/Globals.vue
  8. 4
      src/components/Plugin/Plugin.vue
  9. 92
      src/components/Roles/component/RoleList.vue
  10. 183
      src/components/Roles/components/RoleList.vue
  11. 84
      src/components/Skeleton/READ_ME.md
  12. 186
      src/components/Skeleton/Skeleton.vue
  13. 45
      src/components/Skeleton/view.vue
  14. 37
      src/components/TimeLine/component/TimeBox.vue
  15. 7
      src/config/app.js
  16. 5
      src/config/plugin.js
  17. 5
      src/config/zIndex.js
  18. 10
      src/main.js
  19. 102
      src/mock/mock.js
  20. 2
      src/pages.json
  21. 12
      src/pages/project/project.vue
  22. 2
      src/pages/test/test.vue
  23. 19
      src/store/user/actions.js
  24. 24
      src/store/user/mutations.js
  25. 6
      src/store/user/state.js
  26. 2
      src/utils/indexedDB.js
  27. 15
      src/utils/request.js
  28. 17
      src/utils/tall.js
  29. 1
      vue.config.js

3
.env.development

@ -1,2 +1,5 @@
VUE_APP_NODE_ENV=development
VUE_APP_BASE_URL=https://test.tall.wiki
VUE_APP_API_URL=https://test.tall.wiki/gateway
VUE_APP_MSG_URL=wss://test.tall.wiki/websocket/message/v4.0/ws
VUE_APP_PUBLIC_PATH=/pt-dev/

3
.env.production

@ -1,2 +1,5 @@
VUE_APP_NODE_ENV=production
VUE_APP_BASE_URL=https://www.tall.wiki
VUE_APP_API_URL=https://www.tall.wiki/gateway
VUE_APP_MSG_URL=wss://www.tall.wiki/websocket/message/v4.0/ws
VUE_APP_PUBLIC_PATH=/pt-dev/

1
.eslintrc.js

@ -36,5 +36,6 @@ module.exports = {
Vuex: true,
axios: true,
_: true,
uni: true,
},
};

1
CHANGELOG.md

@ -5,6 +5,7 @@
--|--|--
- | 标题栏变化 | [c0fcd9d](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/c0fcd9d)
- | 标题栏角色栏全局任务组件新建 | [0500cb4](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/0500cb4)
- | 插件数据获取 | [5b91bdc](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/5b91bdc)
- | 角色栏实现 | [94cd671](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/94cd671)
- | 模拟接口测试 | [69e7931](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/69e7931)
- | 时间基准线,默认插件 | [a33ba1e](https://dd.tall.wiki/gitea/wally/TALL-MUI-3/commits/a33ba1e)

9
src/apis/project.js

@ -0,0 +1,9 @@
const apiUrl = process.env.VUE_APP_API_URL;
const tall = `${apiUrl}/defaultwbs`;
const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
vm.$u.api.findProjectById = params => vm.$u.post(`${tall}/project/findProjectById`, params);
};
export default { install };

11
src/apis/task.js

@ -0,0 +1,11 @@
const apiUrl = process.env.VUE_APP_API_URL;
const tall = `${apiUrl}/defaultwbs/task`;
const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
vm.$u.api.getGlobal = param => vm.$u.post(`${tall}/global`, param);
vm.$u.api.getPermanent = param => vm.$u.post(`${tall}/permanent`, param);
vm.$u.api.getERegular = param => vm.$u.post(`${tall}/regular`, param);
};
export default { install };

43
src/components/Globals/Globals.vue

@ -12,19 +12,15 @@
<view slot="body">
<scroll-view :scrollY="true" :style="{ height: isShrink ? '40rpx' : '240rpx' }">
<view class="p-0 u-col-between">
<!-- <view class="u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆</view>
<view class="mt-2 u-line-2"> 瓶身描绘的牡丹一如你初妆222</view> -->
<Plugin :pluginId="pluginId" :styleType="styleType" />
<view class="grid grid-cols-3 gap-2 h-36" v-if="plugins.length">
<Plugin
:pluginId="pluginId"
:styleType="styleType"
v-for="(plugin, pluginIndex) in plugins"
:key="pluginIndex"
:class="getClass(plugin.col, plugin.row)"
/>
</view>
</view>
</scroll-view>
</view>
@ -41,13 +37,32 @@ export default {
loading: true,
pluginId: 0,
styleType: 0,
task: null,
plugins: [],
};
},
async created() {
const permanent = await this.$u.api.getPermanent({ roleId: 0 });
const res = await this.$u.api.getGlobal({
roleId: 0,
timeNode: new Date().getTime(),
timeUnit: 7,
});
for (let item of res.plugins) {
this.plugins.push(...item);
}
this.task = res;
console.log('permanent', permanent);
},
mounted() {
setTimeout(() => (this.loading = false), 5000);
},
computed: mapState('home', ['isShrink']),
methods: {
getClass(col, row) {
return [`row-span-${row}`, `col-span-${col}`];
},
},
};
</script>

4
src/components/Plugin/Plugin.vue

@ -1,7 +1,7 @@
<template>
<view v-if="pluginContent && pluginContent.html">
<view v-if="pluginContent && pluginContent.html" style="height: 100%">
<!-- <view> {{ pluginContent.html }} </view> -->
<view v-html="pluginContent.html"> </view>
<view v-html="pluginContent.html" style="height: 100%"> </view>
<!-- <u-parse :html="pluginContent.html" ref="ht-box"></u-parse> -->
</view>
</template>

92
src/components/Roles/component/RoleList.vue

@ -9,8 +9,6 @@
</view>
</scroll-view>
</view>
<!-- 骨架屏 -->
<u-skeleton :animation="true" :loading="loading" bg-color="#fff"></u-skeleton>
</view>
</template>
@ -24,16 +22,76 @@ export default {
tabList: [], //tab dom
scrollLeft: 0, //scrollview
roles: [
{ id: 1, name: '项目经理', mine: 0, pm: 1, sequence: 1 },
{ id: 2, name: '运维', mine: 0, pm: 0, sequence: 2 },
{ id: 3, name: '导师一', mine: 1, pm: 0, sequence: 3 },
{ id: 4, name: '导师二', mine: 1, pm: 0, sequence: 4 },
{ id: 5, name: '导师三', mine: 1, pm: 0, sequence: 5 },
{ id: 6, name: '导师四', mine: 1, pm: 0, sequence: 6 },
{ id: 7, name: '导师五', mine: 1, pm: 0, sequence: 7 },
{ id: 8, name: '导师六', mine: 1, pm: 0, sequence: 8 },
{ id: 9, name: '导师七', mine: 1, pm: 0, sequence: 9 },
{ id: 10, name: '导师八', mine: 1, pm: 0, sequence: 10 },
{
id: 1,
name: '项目经理',
mine: 0,
pm: 1,
sequence: 1,
},
{
id: 2,
name: '运维',
mine: 0,
pm: 0,
sequence: 2,
},
{
id: 3,
name: '导师一',
mine: 1,
pm: 0,
sequence: 3,
},
{
id: 4,
name: '导师二',
mine: 1,
pm: 0,
sequence: 4,
},
{
id: 5,
name: '导师三',
mine: 1,
pm: 0,
sequence: 5,
},
{
id: 6,
name: '导师四',
mine: 1,
pm: 0,
sequence: 6,
},
{
id: 7,
name: '导师五',
mine: 1,
pm: 0,
sequence: 7,
},
{
id: 8,
name: '导师六',
mine: 1,
pm: 0,
sequence: 8,
},
{
id: 9,
name: '导师七',
mine: 1,
pm: 0,
sequence: 9,
},
{
id: 10,
name: '导师八',
mine: 1,
pm: 0,
sequence: 10,
},
],
loading: true, //
};
@ -51,7 +109,10 @@ export default {
const data = document.getElementsByClassName('tab-children');
// TODO tabList
data.forEach(item => {
this.tabList.push({ width: item.clientWidth, left: item.offsetLeft });
this.tabList.push({
width: item.clientWidth,
left: item.offsetLeft,
});
});
},
@ -120,6 +181,7 @@ export default {
color: $roleChoiceColor;
font-weight: 600;
}
.default-tab-choice:before {
content: '';
position: absolute;
@ -171,4 +233,8 @@ scroll-view ::v-deep ::-webkit-scrollbar {
}
/* #endif */
.skeleton {
height: 44rpx;
}
</style>

183
src/components/Roles/components/RoleList.vue

@ -1,183 +0,0 @@
<template>
<view class="wrap">
<view class="homeBox">
<scroll-view :enable-flex="true" :scroll-left="scrollLeft" :throttle="false" scroll-with-animation scroll-x>
<view class="tabBox u-skeleton">
<view :key="index" @click="changeIndex(index)" class="tab-item" v-for="(item, index) in roles">
<view :class="setColor(item.isMine, tabIndex, index)" class="tab-children u-skeleton-rect">{{ item.value }}</view>
</view>
</view>
<u-skeleton :animation="true" :loading="loading" bgcolor="#fff"></u-skeleton>
</scroll-view>
</view>
</view>
</template>
<script>
export default {
name: 'RoleList',
data() {
return {
tabIndex: 0, //访 index 0
tabList: [], //tab dom
scrollLeft: 0, //scrollview
roles: [
{ id: 1, value: '项目经理', isMine: 0 },
{ id: 2, value: '运维', isMine: 0 },
{ id: 3, value: '导师一', isMine: 1 },
{ id: 4, value: '导师二', isMine: 1 },
{ id: 5, value: '导师三', isMine: 1 },
{ id: 6, value: '导师四', isMine: 1 },
{ id: 7, value: '导师五', isMine: 1 },
{ id: 8, value: '导师六', isMine: 1 },
{ id: 9, value: '导师七', isMine: 1 },
{ id: 10, value: '导师八', isMine: 1 },
],
loading: true, //
};
},
mounted() {
this.init();
setTimeout(() => {
this.loading = false;
console.log('this.loading: ', this.loading);
}, 5000);
},
methods: {
init() {
const data = document.getElementsByClassName('tab-children');
// TODO tabList
data.forEach(item => {
this.tabList.push({ width: item.clientWidth, left: item.offsetLeft });
});
},
changeIndex(index) {
//index
this.tabIndex = index;
//
let left = 0;
let screenWidth = window.screen.width;
for (let i = 0; i < index; i++) {
left += this.tabList[i].width + this.tabList[i].left * 2;
}
left += this.tabList[index].width;
this.scrollLeft = left - screenWidth / 2;
},
//
setColor(isMine, tabIndex, index) {
if (isMine === 1 && tabIndex === index) {
return 'default-tab-choice';
}
if (isMine === 1 && tabIndex !== index) {
return 'default-tab-item';
}
if (isMine === 0 && tabIndex === index) {
return 'tab-choice';
}
},
},
};
</script>
<style lang="scss" scoped>
$tabChoiceColor: #f40; //线
$max: 100%;
//
.wrap {
position: relative;
background: #f7f7f7;
}
.homeBox {
// sticky
position: sticky;
top: 0;
background: #fff; //
/* #ifdef H5 */
// h5 44px
top: 88rpx;
/* #endif */
.tabBox {
position: relative;
white-space: nowrap;
// height: 88rpx;
/* #ifdef MP-TOUTIAO */
/* #endif */
.tab-item {
padding: 15rpx 24rpx;
position: relative;
display: inline-block;
text-align: center;
font-size: 30rpx;
transition-property: background-color, width;
}
.default-tab-item {
color: $tabChoiceColor;
}
.default-tab-choice {
//
position: relative;
color: $tabChoiceColor;
font-weight: 600;
}
.default-tab-choice:before {
content: '';
position: absolute;
left: 0;
bottom: -14rpx;
width: 100%;
height: 6rpx;
border-radius: 2rpx;
background: $tabChoiceColor;
}
.tab-choice {
//
position: relative;
color: $uni-color-primary;
font-weight: 600;
}
.tab-choice:before {
content: '';
position: absolute;
left: 0;
bottom: -14rpx;
width: 100%;
height: 6rpx;
border-radius: 2rpx;
background: $uni-color-primary;
}
}
}
// //
/* #ifndef APP-NVUE */
::-webkit-scrollbar,
::-webkit-scrollbar,
::-webkit-scrollbar {
display: none;
width: 0 !important;
height: 0 !important;
-webkit-appearance: none;
background: transparent;
}
/* #endif */
/* #ifdef H5 */
// 穿H5scroll-view
scroll-view ::v-deep ::-webkit-scrollbar {
display: none;
}
/* #endif */
</style>

84
src/components/Skeleton/READ_ME.md

@ -0,0 +1,84 @@
# skeleton组件
### 1.描述
> 此组件用于加载数据时占位图显示,跟vant-ui骨架屏用法相似,但比vant-ui更灵活
### 2.用法
- 基本用法
代码:
```vue
//基本用法
<skeleton :row="3" animate :loading="loading" >
<view>
content
</view>
</skeleton>
```
- **显示 title ——通过 **title 属性显示title占位图
代码:
```vue
//显示 title——通过 title 属性显示title占位图
<skeleton :row="3" title animate :loading="loading">
<view>
content
</view>
</skeleton>
```
- 显示头像(上面)——通过avatar=‘top’让头像的占位图上面显示
代码:
```vue
<skeleton :avatar="top" avatarAlign="left" :row="3" animate :loading="loading" style="margin-top:24rpx;">
<view>
content
</view>
</skeleton>
```
- 显示头像(左边)——通过avatar=‘left’让头像的占位图左边显示
代码:
```vue
<skeleton title :avatar="left" :row="3" animate :loading="loading" style="margin-top:24rpx;">
<view>
content
</view>
</skeleton>
```
- 显示banner**——通过 **banner属性显示banner占位图(只显示banner,不显示内容占位图时设置row="0")
代码:
```vue
<skeleton banner :row="0" animate :loading="loading" style="margin-top:24rpx;">
<view>
content
</view>
</skeleton>
```
###
### 3. API
### Props
| **属性名** | **说明** | **类型** | **默认值** | 可取值 |
| --- | --- | --- | --- | --- |
| loading | 是否显示骨架屏 | Boolean | true | true/false |
| row | 段落行数 | Number | String | 3 | 0表示不展现 |
| rowWidth | 段落行宽度 | Boolean &#124; Number | '100%' | |
| title | 是否显示标题 | Boolean &#124; String | false | |
| banner | 是否显示banner | Boolean &#124; String | false | |
| animate | 是否开启动画 | Boolean &#124; String | false | |
| avatar | 头像位置 | Boolean &#124; String | ''空 | left/top |
| avatarSize | 头像大小 | String | - | |
| avatarShape | 头像形状 | String | circle | circle/round |

186
src/components/Skeleton/Skeleton.vue

@ -0,0 +1,186 @@
<template>
<view>
<view :class="[avatarClass, animationClass]" class="lx-skeleton" v-show="loading">
<view :class="[avatarShapeClass, bannerClass]" :style="{ width: avatarSize, height: avatarSize }" class="avatar-class"></view>
<view :style="{ width: rowWidth }" class="row">
<view class="row-class lx-skeleton_title" v-if="title"></view>
<view :key="index" class="row-class" v-for="(item, index) in row"></view>
</view>
</view>
<slot v-if="!loading"></slot>
</view>
</template>
<script>
/**
* skeleton 骨架屏
* @description 用于加载数据时占位图显示跟Vant-UI用法相似但比Vant-UI更灵活
* @property {Boolean} loading 是否显示骨架屏默认为true
* @property {Number | String} row 段落行数默认为3
* @property {Boolean | Number} rowWidth 段落行宽度默认为100%
* @property {Boolean | String} title 是否显示标题默认为false
* @property {Boolean | String} banner 是否显示banner默认为false
* @property {Boolean | String} animate 是否开启动画默认为false
* @property {Boolean | String} avatar 头像位置
* @property {String} avatarSize 头像大小
* @property {String} avatarShape 头像形状默认为circle
*
* */
export default {
props: {
loading: {
type: Boolean,
default: true,
},
row: {
type: Number,
default: 3,
},
title: {
type: String,
default: '',
},
avatar: {
type: String,
default: '',
},
animate: {
type: Boolean,
default: false,
},
avatarSize: { type: String },
rowWidth: {
type: String,
default: '100%',
},
avatarShape: {
type: String,
default: 'circle',
},
banner: {
type: Boolean,
default: false,
},
// avator-size:{
// type: String,
// defualt: '32px'
// }
},
computed: {
avatarClass() {
if (this.avatar == 'top') {
return ['lx-skeleton_avator__top'];
} else if (this.avatar == 'left') {
return ['lx-skeleton_avator__left'];
} else {
return '';
}
},
animationClass() {
return [this.animate ? 'lx-skeleton_animation' : ''];
},
slotClass() {
return [!this.loading ? 'show' : 'hide'];
},
avatarShapeClass() {
return [this.avatarShape == 'round' ? 'lx-skeleton_avator__round' : ''];
},
bannerClass() {
return [this.banner ? 'lx-skeleton_banner' : ''];
},
},
data() {
return {};
},
};
</script>
<style lang="scss" scoped>
.lx-skeleton {
background-color: #fff;
padding: 12px;
}
.lx-skeleton_avator__left {
display: flex;
width: 100%;
}
.lx-skeleton_avator__left .avatar-class,
.lx-skeleton_avator__top .avatar-class {
background-color: #f2f3f5;
border-radius: 50%;
width: 32px;
height: 32px;
}
.lx-skeleton_avator__left .avatar-class.lx-skeleton_avator__round,
.lx-skeleton_avator__top .avatar-class.lx-skeleton_avator__round {
border-radius: 0;
width: 32px;
height: 32px;
}
.lx-skeleton_avator__left .avatar-class {
margin-right: 16px;
}
.lx-skeleton_avator__top .avatar-class {
margin: 0 auto 12px auto;
}
.row-class {
width: 100%;
height: 16px;
background-color: #f2f3f5;
}
.row-class:not(:first-child) {
margin-top: 12px;
}
.row {
flex: 1;
}
.lx-skeleton_avator__left .row {
width: calc(100% - 48px);
}
.row-class:nth-last-child(1) {
width: 60%;
}
.lx-skeleton_animation .row-class {
animation-duration: 1.5s;
animation-name: blink;
animation-timing-function: ease-in-out;
animation-iteration-count: infinite;
}
@keyframes blink {
50% {
opacity: 0.6;
}
}
.lx-skeleton_title {
width: 40%;
}
.show {
display: block;
}
.hide {
display: none;
}
.lx-skeleton .lx-skeleton_banner {
width: 92%;
margin: 10px auto;
height: 64px;
border-radius: 0;
background-color: #f2f3f5;
}
</style>

45
src/components/Skeleton/view.vue

@ -0,0 +1,45 @@
<template>
<view>
<nav-bar title="骨架屏"></nav-bar>
<view class="content">
基础用法
<skeleton :row="3" animate :loading="loading">
<view> content1 </view>
</skeleton>
显示 title
<skeleton :row="3" title animate :loading="loading">
<view> content2 </view>
</skeleton>
显示头像上面)
<skeleton :avatar="avatarTop" :row="3" animate :loading="loading" style="margin-top: 24rpx">
<view> content3 </view>
</skeleton>
显示头像左面
<skeleton title :avatar="avatarLeft" :row="3" animate :loading="loading" style="margin-top: 24rpx">
<view> content4 </view>
</skeleton>
显示banner
<skeleton banner :row="0" animate :loading="loading" style="margin-top: 24rpx">
<view> content5 </view>
</skeleton>
</view>
</view>
</template>
<script>
export default {
data() {
return {
loading: true, //
avatarTop: 'top',
avatarLeft: 'left',
};
},
onLoad() {
//
setTimeout(() => {
this.loading = false;
}, 3000);
},
};
</script>

37
src/components/TimeLine/component/TimeBox.vue

@ -83,46 +83,33 @@ export default {
TaskPanel: { height: '100' },
},
],
};
},
methods: {
addTopList() {
const item = [
addList: [
{
state: 0,
plugins: [[{ pluginId: '111' }], [{ pluginId: '222' }]],
TaskPanel: { height: '100' },
},
{
state: 0,
plugins: [[{ pluginId: '111' }], [{ pluginId: '222' }]],
TaskPanel: { height: '100' },
},
{
state: 0,
plugins: [[{ pluginId: '111' }], [{ pluginId: '333' }]],
TaskPanel: { height: '100' },
},
];
this.list = item.concat(this.list);
console.log('this.list: ', this.list);
],
};
},
methods: {
addTopList() {
this.list = this.addList.concat(this.list);
},
addBottomList() {
const item = [
{
state: 0,
plugins: [[{ pluginId: '111' }], [{ pluginId: '333' }]],
},
{
state: 0,
plugins: [[{ pluginId: '111' }], [{ pluginId: '333' }]],
},
{
state: 0,
plugins: [[{ pluginId: '111' }]],
},
];
this.list = this.list.concat(item);
console.log('this.list: ', this.list);
this.list = this.list.concat(this.addList);
},
},
};

7
src/config/app.js

@ -0,0 +1,7 @@
const version = '3.0.0';
export default {
V: version,
version,
theme: [],
};

5
src/config/plugin.js

@ -0,0 +1,5 @@
// 定义插件相关信息
/* eslint-disable */
export default {
defaults: [], // 默认插件id列表
};

5
src/config/zIndex.js

@ -0,0 +1,5 @@
// 定义项目中定位的元素的层级
/* eslint-disable */
export default {
roleBar: 999, // 角色栏成绩
};

10
src/main.js

@ -1,6 +1,7 @@
import Vue from 'vue';
import App from './App';
import uView from 'uview-ui';
import Tall from '@/utils/tall';
import App from './App';
import './common/styles/index.css';
import store from './store';
@ -16,6 +17,7 @@ Vue.use(indexedDB);
Vue.config.productionTip = false;
Vue.use(uView);
Vue.use(Tall);
App.mpType = 'app';
@ -23,10 +25,16 @@ const app = new Vue({ ...App, store });
import request from '@/utils/request.js';
import user from '@/apis/user.js';
import project from '@/apis/project.js';
import task from '@/apis/task.js';
import plugin from '@/apis/plugin.js';
window.vm = app;
Vue.use(request, app);
Vue.use(user, app);
Vue.use(project, app);
Vue.use(task, app);
Vue.use(plugin, app);
app.$mount();

102
src/mock/mock.js

@ -148,11 +148,29 @@ export default [
plugins: [
[
{
col: 123,
col: 1,
colspan: 123,
param: 123,
pluginId: 123456789,
row: 123,
row: 2,
rowspan: 123,
},
{
col: 2,
colspan: 123,
param: 123,
pluginId: 123456789,
row: 1,
rowspan: 123,
},
],
[
{
col: 1,
colspan: 123,
param: 123,
pluginId: 123456789,
row: 2,
rowspan: 123,
},
],
@ -195,12 +213,82 @@ export default [
plugins: [
[
{
col: 123,
colspan: 123,
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 123,
rowspan: 123,
row: 2,
rowspan: 1,
},
{
col: 2,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 1,
rowspan: 1,
},
],
[
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 2,
rowspan: 1,
},
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 2,
rowspan: 1,
},
],
[
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 1,
rowspan: 1,
},
],
[
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 1,
rowspan: 1,
},
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 2,
rowspan: 1,
},
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 2,
rowspan: 1,
},
{
col: 1,
colspan: 0,
param: 123,
pluginId: 123456789,
row: 1,
rowspan: 1,
},
],
],
@ -283,7 +371,7 @@ export default [
msg: 'ok',
success: true,
data: {
html: `<button onclick="openModal()">js打开物流页面</button>`,
html: `<div style="height:100%;background:rgba(252, 211, 77,0.6)" ></div>`,
id: 13,
intro: 'string',
js: `function openModal() {

2
src/pages.json

@ -1,7 +1,7 @@
{
"pages": [
{
"path": "pages/index/index",
"path": "pages/project/project",
"style": {
"navigationStyle": "custom" ,
"navigationBarTextStyle": "white"

12
src/pages/index/index.vue → src/pages/project/project.vue

@ -10,16 +10,19 @@
</template>
<script>
import { mapState, mapMutations, mapActions } from 'vuex';
export default {
data() {
return { title: 'Hello', height: '', scrollHeight: null };
},
computed: { ...mapState('user', ['user', 'token']) },
onLoad() {
console.log(this.$u.config.v);
// this.openPage();
// DEBUG:
this.$u.api.getToken('1217651354919636992');
this.getUserId('1217651354919636992');
const params = { param: { projectId: '1235555' } };
this.$u.api.findProjectById(params);
},
mounted() {
@ -27,6 +30,9 @@ export default {
},
methods: {
...mapMutations('user', ['setToken', 'setUser']),
...mapActions('user', ['getUserId']),
openPage() {
console.log('open');
this.$u.route('/pages/pinch/pinch');

2
src/pages/test/test.vue

@ -13,5 +13,3 @@ export default {
},
};
</script>
<style></style>

19
src/store/user/actions.js

@ -1,3 +1,20 @@
const actions = {};
const actions = {
/**
* 通过userId获取token
* @param {any} commit
* @param {string} userId 用户id
*/
async getUserId({ commit }, userId) {
try {
uni.$u.api.getToken(userId).then(res => {
commit('setToken', res.token);
commit('setUser', res);
return res;
});
} catch (error) {
throw error || '获取个人信息失败';
}
},
};
export default actions;

24
src/store/user/mutations.js

@ -1,3 +1,25 @@
const mutations = {};
const mutations = {
/**
* 设置存储token
* @param {object} state
* @param {string} token
*/
setToken(state, token) {
if (!token) return;
state.token = token;
uni.setStorageSync('anyringToken', token);
},
/**
* 设置user数据
* @param {object} state
* @param {object} user
*/
setUser(state, user) {
if (!user) return;
state.user = { ...user };
uni.setStorageSync('user', JSON.stringify(user));
},
};
export default mutations;

6
src/store/user/state.js

@ -1,3 +1,5 @@
const state = {};
const state = {
token: '',
user: null,
};
export default state;

2
src/utils/indexedDB.js

@ -178,7 +178,7 @@ const install = Vue => {
};
// create
console.log(curriedCreate(Vue.prototype.$db.db));
// console.log(curriedCreate(Vue.prototype.$db.db));
Vue.prototype.$db.create = curriedCreate(Vue.prototype.$db.db);
};

15
src/utils/request.js

@ -13,9 +13,9 @@ const install = (Vue, vm) => {
Vue.prototype.$u.http.interceptor.request = config => {
// TODO: 如果在白名单里 则不需要加token
// if (vm.$store.state.user.token) {
// config.header.Authorization = `Bearer ${vm.$store.state.user.token}`;
// }
if (vm.$store.state.user.token) {
config.header.Authorization = `Bearer ${vm.$store.state.user.token}`;
}
return config;
};
@ -41,6 +41,15 @@ const install = (Vue, vm) => {
return false;
}
};
Vue.prototype.$u.post = (url, param = {}, header = {}) => {
return Vue.prototype.$u.http.request({
url,
method: 'POST',
header,
data: { param },
});
};
};
export default { install };

17
src/utils/tall.js

@ -0,0 +1,17 @@
import app from '@/config/app.js';
import zIndex from '@/config/zIndex.js';
import plugin from '@/config/plugin.js';
const $t = {
zIndex, // 定位元素层级
app, // app级别的相关配置
plugin, // 插件相关配置信息
};
uni.$t = $t;
const install = Vue => {
Vue.prototype.$t = $t;
};
export default { install };

1
vue.config.js

@ -6,6 +6,7 @@ module.exports = {
productionSourceMap: false,
devServer: {
// open: true,
host: '127.0.0.1',
overlay: { warnings: false, errors: true },
// proxy: {}
},

Loading…
Cancel
Save