Browse Source

perf: 解决error

develop
song 4 years ago
parent
commit
1a6e5131d4
  1. 9
      .env.development
  2. 1
      .env.production
  3. 1
      .gitignore
  4. 11
      .hbuilderx/launch.json
  5. 3
      CHANGELOG.md
  6. 23
      src/App.vue
  7. 30
      src/apis/yanyuan.js
  8. 6
      src/common/styles/tailwind.scss
  9. 43
      src/components/ConfigInfo/components/config.js
  10. 13
      src/components/Modal/Modal.vue
  11. 221
      src/components/myp-one/myp-one.vue
  12. 2
      src/main.js
  13. 108
      src/mixins/tool.js
  14. 1
      src/mixins/userAuth.js
  15. 14
      src/pages.json
  16. 2
      src/pages/index/index.vue
  17. 5
      src/pagesUser/phone-bind/phone-bind.vue
  18. 18
      src/pagesYanyuan/be-family/be-family.vue
  19. 54
      src/pagesYanyuan/input-code/input-code.vue
  20. 33
      src/pagesYanyuan/transfer-page/transfer-page.vue
  21. 3
      src/store/index.js
  22. 33
      src/store/yanyuan/actions.js
  23. 3
      src/store/yanyuan/getters.js
  24. 12
      src/store/yanyuan/index.js
  25. 30
      src/store/yanyuan/mutations.js
  26. 8
      src/store/yanyuan/state.js

9
.env.development

@ -1,6 +1,7 @@
VUE_APP_NODE_ENV=development
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_PROJECT_PATH=https://www.tall.wiki/tall-project
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_PROJECT_PATH=https://test.tall.wiki/tall-project
VUE_APP_YY_API_URL=http://192.168.0.99/gateway
VUE_APP_VERSION=v3.2.0

1
.env.production

@ -3,4 +3,5 @@ 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_PROJECT_PATH=https://www.tall.wiki/tall-project
VUE_APP_YY_API_URL=http://192.168.0.99/gateway
VUE_APP_VERSION=v3.2.0

1
.gitignore

@ -14,6 +14,7 @@ yarn-error.log*
yarn.lock
package-lock.json
pages.json
# Editor directories and files
.project

11
.hbuilderx/launch.json

@ -2,10 +2,15 @@
// launchtypelocalremote, localremote
"version": "0.0",
"configurations": [{
"type": "uniCloud",
"default": {
"default" :
{
"launchtype" : "local"
}
},
"mp-weixin" :
{
"launchtype" : "local"
},
"type" : "uniCloud"
}
]
}

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-11-09)
# 0.1.0 (2021-11-10)
### 🌟 新功能
范围|描述|commitId
@ -59,6 +59,7 @@
- | 添加时间轴上下滚动 | [2b81bbc](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/2b81bbc)
- | 添加药物使用记录界面 | [425cb63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/425cb63)
- | 添加设置界面 | [7ca0c59](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/7ca0c59)
- | 添加输入工具码界面 | [8c120bc](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/8c120bc)
- | 添加项目排序 | [a0b491b](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/a0b491b)
- | 添加首页弹出按钮及界面 | [edd56cd](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/edd56cd)
- | 点击日历日期查询项目列表 | [c458385](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c458385)

23
src/App.vue

@ -1,13 +1,14 @@
<script>
import toolMixin from '@/mixins/tool';
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex';
export default {
mixins: [toolMixin],
async onLaunch(options) {
// TODO: this
options.u = '1298194698783170560';
// TODO: this
console.log('options: ', options);
this.checkNetwork(); //
this.getSystemInfo(); //
/* #ifdef MP-WEIXIN */
@ -39,23 +40,9 @@ export default {
methods: {
...mapActions('user', ['getToken']),
...mapActions('socket', ['initSocket']),
...mapMutations(['setNetworkConnected', 'setSystemInfo']),
...mapMutations(['setSystemInfo']),
...mapMutations('user', ['setToken', 'setUser']),
// store
// 2g 3g ;
checkNetwork() {
uni.getNetworkType({
success: ({ networkType }) => {
this.setNetworkConnected(!(networkType === 'none' || networkType === '2g' || networkType === '3g'));
},
});
//
uni.onNetworkStatusChange(({ isConnected, networkType }) => {
this.setNetworkConnected(isConnected && !(networkType === '2g' || networkType === '3g'));
});
},
//
async signin() {
try {

30
src/apis/yanyuan.js

@ -0,0 +1,30 @@
const url = process.env.VUE_APP_YY_API_URL;
const yanyuan = `${url}/yanyuan/v2.0`;
const install = (Vue, vm) => {
vm.$u.api = { ...vm.$u.api } || {};
// 填写用户信息
vm.$u.api.addTrainee = param => vm.$u.post(`${yanyuan}/trainee/add`, param);
// 查询用户创建的老人信息
vm.$u.api.createTrainee = param => vm.$u.post(`${yanyuan}/trainee/create`, param);
// 查询体验账号
vm.$u.api.experienceTrainee = param => vm.$u.post(`${yanyuan}/trainee/experience`, param);
// 绑定手机号后,关联用户原有的使用者
vm.$u.api.relationTrainee = param => vm.$u.post(`${yanyuan}/trainee/relation`, param);
// 体验账号升级
vm.$u.api.upgradeTrainee = param => vm.$u.post(`${yanyuan}/trainee/upgrade`, param);
// 申请成为家属
vm.$u.api.applyFamily = param => vm.$u.post(`${yanyuan}/family/apply`, param);
// 查询个人信息
vm.$u.api.getPersonalInfo = param => vm.$u.post(`${yanyuan}/family/personal`, param);
// 绑定工具箱
vm.$u.api.bindTool = param => vm.$u.post(`${yanyuan}/tool/bind`, param);
// 用户身份判断
vm.$u.api.identityUserPower = param => vm.$u.post(`${yanyuan}/userPower/identity`, param);
};
export default { install };

6
src/common/styles/tailwind.scss

@ -1113,6 +1113,9 @@
.h-12 {
height: 3rem !important;
}
.h-24 {
height: 6rem !important;
}
.h-full {
height: 100%;
}
@ -1134,6 +1137,9 @@
.w-12 {
width: 3rem !important;
}
.w-24 {
width: 6rem !important;
}
.w-full {
width: 100% !important;
}

43
src/components/ConfigInfo/components/config.js

@ -479,3 +479,46 @@ export const familyInfo = [
value: '大专或大学',
},
];
/**
* 是否成为家属
* 展示类型: showType: 1 标题+折叠, 2 直接展示
* 试题类型, type:1 单选,2 日期(年月日),3 数字输入框,4 单列下拉框,5 多选,6 日期(年月日时),7 多列下拉选框, 8 文本输入框 9 多列地区选择 11 吸烟 12 饮酒 13 饮茶
*/
export const beFamily = [
[
{
name: '姓名',
showType: 2,
type: 8,
value: null,
},
{
name: '性别',
showType: 1,
type: 1,
radioList: ['男', '女'],
value: null,
},
{
name: '年龄',
showType: 2,
type: 3,
value: null,
},
{
name: '职业',
showType: 1,
type: 1,
radioList: ['干部', '军人', '技术人员', '农民', '工人', '运动员', '个体商业人员', '其他'],
value: null,
},
{
name: '文化程度',
showType: 1,
type: 1,
radioList: ['文盲', '小学', '初中', '高中或中专', '大学或大专', '大学以上', '其他'],
value: null,
},
],
];

13
src/components/Modal/Modal.vue

@ -0,0 +1,13 @@
<template>
<u-modal v-model="show" content="111111"></u-modal>
</template>
<script>
export default {
data() {
return { show: false };
},
};
</script>
<style></style>

221
src/components/myp-one/myp-one.vue

@ -0,0 +1,221 @@
<template>
<view class="code-box">
<view class="flex-box">
<input :value="inputValue" type="number" :focus="autoFocus" :maxlength="maxlength" class="hide-input" @input="getVal" />
<view class="flex flex-nowrap my-5">
<block v-for="(item, index) in ranges" :key="index" class="flex-1 mx-1">
<view
:class="['item', { active: codeIndex === item, middle: type === 'middle', bottom: type === 'bottom', box: type === 'box' }]"
>
<view class="line" v-if="type !== 'middle'"></view>
<view v-if="type === 'middle' && codeIndex <= item" class="bottom-line"></view>
<block v-if="isPwd && codeArr.length >= item">
<text class="dot">.</text>
</block>
<block v-else> {{ codeArr[index] ? codeArr[index] : '' }}</block>
</view>
</block>
</view>
</view>
</view>
</template>
<script>
// 使 v-model
// 使refs
// 广
// UI mypUI-nvueuni-appmp/h5/app
export default {
name: 'mypOneInput',
props: {
// 使v-model
// value
value: {
type: String,
default: '',
},
// 4/6
maxlength: {
type: Number,
default: 10,
},
autoFocus: {
type: Boolean,
default: false,
},
isPwd: {
type: Boolean,
default: false,
},
// middle-middle line, bottom-bottom line, box-square box
type: {
type: String,
default: 'bottom',
},
},
watch: {
maxlength: {
immediate: true,
handler: function () {
this.ranges = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
// if (newV === 6) {
// this.ranges = [1, 2, 3, 4, 5, 6];
// } else {
// this.ranges = [1, 2, 3, 4];
// }
},
},
value: {
immediate: true,
handler: function (newV) {
if (newV !== this.inputValue) {
this.inputValue = newV;
this.toMakeAndCheck(newV);
}
},
},
},
data() {
return {
inputValue: '',
codeIndex: 1,
codeArr: [],
ranges: [1, 2, 3, 4],
};
},
methods: {
getVal(e) {
const val = e.detail.value;
this.inputValue = val;
this.$emit('input', val);
this.toMakeAndCheck(val);
},
toMakeAndCheck(val) {
const arr = val.split('');
this.codeIndex = arr.length + 1;
this.codeArr = arr;
if (this.codeIndex > Number(this.maxlength)) {
this.$emit('finish', this.codeArr.join(''));
}
},
// refs v-model
// 使refsvalue
//
set(val) {
this.inputValue = val;
this.toMakeAndCheck(val);
},
// 使refs
clear() {
this.inputValue = '';
this.codeArr = [];
this.codeIndex = 1;
},
},
};
</script>
<style scoped>
@keyframes twinkling {
0% {
opacity: 0.2;
}
50% {
opacity: 0.5;
}
100% {
opacity: 0.2;
}
}
.code-box {
text-align: center;
}
.flex-box {
display: flex;
justify-content: center;
flex-wrap: wrap;
position: relative;
}
.flex-box .hide-input {
position: absolute;
top: 0;
left: -100%;
width: 200%;
height: 100%;
text-align: left;
z-index: 9;
opacity: 1;
}
.flex-box .item {
position: relative;
width: 60upx;
height: 70upx;
margin-right: 12upx;
font-size: 46upx;
font-weight: bold;
color: #333333;
line-height: 70upx;
--tw-bg-opacity: 1;
background-color: rgba(249, 250, 251, var(--tw-bg-opacity));
}
.flex-box .item:last-child {
margin-right: 0;
}
.flex-box .middle {
border: none;
}
.flex-box .box {
box-sizing: border-box;
border-radius: 6rpx;
}
.flex-box .bottom {
box-sizing: border-box;
border-bottom: 8rpx solid #212121;
}
.flex-box .active {
border-color: #00c777;
}
.flex-box .active .line {
display: block;
}
.flex-box .line {
display: none;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: 2upx;
height: 40upx;
background: #333333;
animation: twinkling 1s infinite ease;
}
.flex-box .dot {
font-size: 80upx;
line-height: 40upx;
}
.flex-box .bottom-line {
height: 4px;
background: #000000;
width: 80%;
position: absolute;
border-radius: 2px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
</style>

2
src/main.js

@ -12,6 +12,7 @@ import tall from '@/apis/tall.js';
import task from '@/apis/task.js';
import uView from 'uview-ui';
import wbs from '@/apis/wbs.js';
import yanyuan from '@/apis/yanyuan.js';
//#ifdef H5
// import './registerServiceWorker';
@ -45,5 +46,6 @@ Vue.use(task, app);
Vue.use(plugin, app);
Vue.use(role, app);
Vue.use(wbs, app);
Vue.use(yanyuan, app);
app.$mount();

108
src/mixins/tool.js

@ -0,0 +1,108 @@
// 工具箱相关处理
import { mapState, mapActions } from 'vuex';
export default {
computed: mapState('yanyuan', ['toolInfo']),
methods: {
...mapActions('yanyuan', ['getCreateTrainee']),
initTool() {
const { toolInfo } = this;
console.log('toolInfo: ', toolInfo);
// 工具箱是否被绑定
if (!toolInfo || !toolInfo.bindUserId || toolInfo.isBind !== 1) {
console.log('工具箱没有被绑定');
this.$t.page.openPage('/pagesYanyuan/scan-code/scan-code');
// this.$t.page.openPage('/pagesYanyuan/input-code/input-code');
return;
}
// 不是自己 弹出是否申请成为家属
if (toolInfo.isMine !== 1) {
console.log('绑定者不是自己');
this.becomeFamily(toolInfo.bindUserId);
return;
}
// 不是公司用户
if (toolInfo.isCompany !== 1) {
console.log('不是公司用户');
this.isNotCompany();
return;
}
// 是公司用户 填写用户信息
console.log('是公司用户');
this.$t.page.openPage('/pagesYanyuan/add-info/add-info');
// TODO this测试
},
// 不是公司用户
isNotCompany() {
if (this.toolInfo.isMax !== 1) {
console.log('没有满员');
// 没有体验用户
if (this.toolInfo.isUx !== 1) {
console.log('没有体验用户');
// 添加新用户
this.$t.page.openPage('/pagesYanyuan/add-info/add-info');
return;
}
// 有体验用户 判断体验用户数量
console.log('有体验用户');
this.becomeUser(this.toolInfo.uxUserInfo);
}
// 满员 已绑定
console.log('满员');
this.$t.page.openPage('/pagesYanyuan/transfer-page/transfer-page?type=manyuan');
},
// 判断是否成为家属
becomeFamily(bindUserId) {
console.log('判断是否成为家属');
this.$t.ui
.showModal('提示', '是否成为家属?')
.then(async () => {
console.log('是');
const params = { bindUserId };
console.log('params: ', params);
const res = await this.getCreateTrainee(params);
if (!res.length) {
this.$t.ui.showToast('提醒工具箱拥有者添加使用者信息');
setTimeout(() => {
uni.redirectTo({ url: '/pages/index/index' });
}, 2000);
} else {
this.$t.page.openPage('/pagesYanyuan/be-family/be-family');
}
})
.catch(() => {
uni.redirectTo({ url: '/pages/index/index' });
});
},
// 判断是否设置为使用者
becomeUser(uxUserInfo) {
// 1个弹框 询问是否将XXX设置为使用者 多个 弹框选择使用者
if (uxUserInfo && uxUserInfo.length === 1) {
const content = uxUserInfo[0].userName;
console.log('判断是否设置为使用者');
this.$t.ui
.showModal('提示', `是否将${content}设置为使用者?`)
.then(() => {
console.log('是');
})
.catch(() => {
console.log('否');
});
}
if (uxUserInfo && uxUserInfo.length > 1) {
console.log('判断是否设置为使用者');
}
},
},
};

1
src/mixins/userAuth.js

@ -6,6 +6,7 @@ export default {
computed: mapState('user', ['token', 'user']),
methods: {
...mapMutations('user', ['setUser']),
// 获取授权
openAuth() {
if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) return; // 用户信息里有微信信息就不用再获取了

14
src/pages.json

@ -72,6 +72,20 @@
"navigationBarTitleText": "脑力测评",
"navigationStyle": "default"
}
},
{
"path": "transfer-page/transfer-page",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "default"
}
},
{
"path": "be-family/be-family",
"style": {
"navigationBarTitleText": "申请成为家属",
"navigationStyle": "default"
}
}
]
},

2
src/pages/index/index.vue

@ -1,5 +1,5 @@
<template>
<view class="flex flex-col h-full bg-gray-50">
<view class="flex flex-col h-full bg-gray-50" @click="openAuth">
<view class="relative" @touchmove="onMove">
<!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar" @handleFindPoint="handleFindPoint" />

5
src/pagesUser/phone-bind/phone-bind.vue

@ -116,7 +116,10 @@ export default {
type: 'success',
duration: '3000',
});
setTimeout(() => uni.navigateBack(), 2000);
setTimeout(() => {
// uni.navigateBack();
uni.redirectTo({ url: '/pages/index/index' });
}, 2000);
} catch (error) {
/* this.$refs.uTips.show({
title: error.msg || '手机号绑定失败',

18
src/pagesYanyuan/be-family/be-family.vue

@ -0,0 +1,18 @@
<template>
<view> 老人列表 </view>
</template>
<script>
export default {
name: 'BeFamily',
data() {
return {};
},
mounted() {},
methods: {},
};
</script>
<style lang="scss" scoped></style>

54
src/pagesYanyuan/input-code/input-code.vue

@ -4,41 +4,41 @@
<img class="w-full mt-16" style="height: 6rem" src="https://www.tall.wiki/staticrec/yanyuan/input-code.png" />
</view>
<view class="flex flex-nowrap my-5">
<u-input
input-align="center"
type="number"
:value="num.value"
:placeholder="placeholder"
class="flex-1 mx-1 bg-gray-100"
v-for="num in nums"
:key="num.id"
/>
</view>
<myp-one ref="one" type="box" @finish="finished"></myp-one>
<view class="px-2 mt-2 w-full">
<u-button type="primary" class="w-full">确认</u-button>
<u-button type="primary" class="w-full" @click="submit">确认</u-button>
</view>
</view>
</template>
<script>
import toolMixin from '@/mixins/tool';
import { mapActions } from 'vuex';
export default {
mixins: [toolMixin],
data() {
return {
placeholder: ' ',
nums: [
{ value: '', id: 1 },
{ value: '', id: 2 },
{ value: '', id: 3 },
{ value: '', id: 4 },
{ value: '', id: 5 },
{ value: '', id: 6 },
{ value: '', id: 7 },
{ value: '', id: 8 },
{ value: '', id: 9 },
{ value: '', id: 10 },
],
};
return { toolCode: '' };
},
methods: {
...mapActions('yanyuan', ['getBindTool']),
finished(val) {
this.toolCode = val;
},
async submit() {
try {
const params = { toolCode: this.toolCode };
await this.getBindTool(params);
this.initTool();
} catch (error) {
console.log('error: ', error);
}
},
},
};
</script>

33
src/pagesYanyuan/transfer-page/transfer-page.vue

@ -0,0 +1,33 @@
<template>
<view class="flex flex-col items-center">
<img class="my-28 w-24 h-24" src="https://www.tall.wiki/staticrec/yanyuan/logo.png" />
<view class="text-xl flex flex-col">
<text class="mb-1">{{ content }}</text>
<text>5秒后跳转到首页...</text>
</view>
</view>
</template>
<script>
export default {
data() {
return { content: '' };
},
onLoad(options) {
if (options.type === 'manyuan') {
this.content = '工具已绑定';
}
},
mounted() {
this.$nextTick(() => {
setTimeout(() => {
uni.redirectTo({ url: '/pages/index/index' });
}, 5000);
});
},
};
</script>
<style></style>

3
src/store/index.js

@ -6,6 +6,7 @@ import socket from './socket/index';
import project from './project/index';
import role from './role/index';
import task from './task/index';
import yanyuan from './yanyuan/index';
// 不属于具体模块的 应用级的 store内容
const state = {
@ -48,4 +49,4 @@ const mutations = {
};
Vue.use(Vuex);
export default new Vuex.Store({ state, getters, mutations, modules: { user, messages, socket, project, role, task } });
export default new Vuex.Store({ state, getters, mutations, modules: { user, messages, socket, project, role, task, yanyuan } });

33
src/store/yanyuan/actions.js

@ -0,0 +1,33 @@
const actions = {
/**
* 绑定工具箱
* @param {*} commit
* @param {object} params
*/
async getBindTool({ commit }, params) {
try {
const data = await uni.$u.api.bindTool(params);
commit('setToolInfo', data);
return data;
} catch (error) {
uni.$t.ui.showToast(error.msg || '工具箱绑定失败');
}
},
/**
* 查询用户创建的老人信息
* @param {*} commit
* @param {object} params
*/
async getCreateTrainee({ commit }, params) {
try {
const data = await uni.$u.api.createTrainee(params);
commit('setElderlyInfo', data);
return data;
} catch (error) {
uni.$t.ui.showToast(error.msg || '查询失败');
}
},
};
export default actions;

3
src/store/yanyuan/getters.js

@ -0,0 +1,3 @@
const getters = {};
export default getters;

12
src/store/yanyuan/index.js

@ -0,0 +1,12 @@
import state from './state';
import getters from './getters';
import mutations from './mutations';
import actions from './actions';
export default {
namespaced: true,
state,
getters,
mutations,
actions,
};

30
src/store/yanyuan/mutations.js

@ -0,0 +1,30 @@
const mutations = {
/**
* 设置是否绑定工具箱
* @param {object} state
* @param {array} show 项目列表
*/
setIsBinding(state, show) {
state.isBinding = show;
},
/**
* 设置工具箱信息
* @param {object} state
* @param {array} data 项目列表
*/
setToolInfo(state, data) {
state.toolInfo = data;
},
/**
* 设置用户创建的老人信息
* @param {object} state
* @param {array} data 项目列表
*/
setElderlyInfo(state, data) {
state.elderlyInfo = data;
},
};
export default mutations;

8
src/store/yanyuan/state.js

@ -0,0 +1,8 @@
/* eslint-disable */
const state = {
isBinding: false, // 工具箱是否被绑定
toolInfo: {}, // 绑定过的工具箱信息
elderlyInfo: {}, // 用户创建的老人信息
};
export default state;
Loading…
Cancel
Save