Browse Source

feat: 工具箱页面调整 添加查询工具箱的使用者接口

develop
song 4 years ago
parent
commit
7f5b2901d3
  1. 3
      CHANGELOG.md
  2. 3
      src/App.vue
  3. 4
      src/apis/yanyuan.js
  4. 7
      src/pages/index/index.vue
  5. 71
      src/pagesProject/project/project.vue
  6. 75
      src/pagesYanyuan/hold-all/hold-all.vue
  7. 9
      src/store/yanyuan/mutations.js
  8. 1
      src/store/yanyuan/state.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-12-20)
# 0.1.0 (2021-12-22)
### 🌟 新功能
范围|描述|commitId
@ -192,6 +192,7 @@
- | 时间轴无任务时时间刻度加载修改 | [4921672](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/4921672)
- | 时间轴滚动位置修改 | [551da63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/551da63)
- | 时间轴骨架屏修改 | [ca78d02](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/ca78d02)
- | 测试页面标题修改 | [decbcf1](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/decbcf1)
- | 添加canvas | [9bc13c7](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/9bc13c7)
- | 添加绑定WiFi | [c523022](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c523022)
- | 监听时间基本点 | [033fca0](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/033fca0)

3
src/App.vue

@ -8,6 +8,7 @@ export default {
async onLaunch(options) {
// TODO: this
console.log('options: ', options);
this.setScene(options.scene);
if (options.scene === 1047) {
//
if (options.query && options.query.scene) {
@ -52,7 +53,7 @@ export default {
...mapActions('socket', ['initSocket']),
...mapMutations(['setSystemInfo']),
...mapMutations('user', ['setToken', 'setUser']),
...mapMutations('yanyuan', ['setToolCode', 'setEnterByCode']),
...mapMutations('yanyuan', ['setToolCode', 'setEnterByCode', 'setScene']),
//
async signin() {

4
src/apis/yanyuan.js

@ -24,6 +24,8 @@ const install = (Vue, vm) => {
vm.$u.api.bindTool = param => vm.$u.post(`${yanyuan}/tool/bind`, param);
// 查询工具箱列表
vm.$u.api.queryToolList = param => vm.$u.post(`${yanyuan}/tool/queryToolList`, param);
// 查询工具箱的使用者
vm.$u.api.getUserName = param => vm.$u.post(`${yanyuan}/tool/getUserName`, param);
// 试题查询
vm.$u.api.getQuestion = param => vm.$u.post(`${yanyuan}/question/get`, param);
@ -52,6 +54,8 @@ const install = (Vue, vm) => {
vm.$u.api.queryAuditNum = param => vm.$u.post(`${yanyuan}/family/queryAuditNum`, param);
// 查询家属成员列表
vm.$u.api.queryFamilyList = param => vm.$u.post(`${yanyuan}/family/queryList`, param);
// 查询用户是否是项目成员
vm.$u.api.familyIsMember = param => vm.$u.post(`${yanyuan}/family/isMember`, param);
// 试题答案保存
vm.$u.api.chooseTool = param => vm.$u.post(`${yanyuan}/trainPlan/chooseTool`, param);

7
src/pages/index/index.vue

@ -90,12 +90,19 @@ export default {
},
async onLoad(options) {
console.log('index options: ', options);
this.options = options;
if (options.code === 'true') {
console.log('onLoad options: ', options);
//
await this.homeIdentity();
}
//
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
});
},
methods: {

71
src/pagesProject/project/project.vue

@ -18,10 +18,30 @@
<!-- 引导语 -->
<GuidePage class="w-full h-full" v-if="showGuide" @quitGuide="quitGuide" />
<!-- 选择老人 -->
<!-- :async-close="true" -->
<u-modal v-model="showElder" title="选择老人" @confirm="confirmModel" @cancel="cancelModel" ref="uModal" :show-cancel-button="true">
<ChooseElder></ChooseElder>
</u-modal>
<!-- 设置使用者 -->
<!-- :async-close="true" -->
<u-modal
v-model="showUser"
title="设置使用者"
@confirm="confirmSetUserModel"
@cancel="cancelSetUserModel"
ref="uModal"
:show-cancel-button="true"
>
<ChooseUser></ChooseUser>
</u-modal>
</view>
</template>
<script>
import toolMixin from '@/mixins/tool';
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex';
import { setPlaceholderTasks, computeFillPlaceholderTaskCount } from '@/utils/task';
import Title from './components/Title/Title';
@ -32,6 +52,7 @@ import ConfigInfo from './components/ConfigInfo/ConfigInfo';
// import { flatten } from 'lodash';
export default {
mixins: [toolMixin],
components: { Title, Roles, TimeLine, ConfigInfo, GuidePage },
data() {
return {
@ -50,6 +71,7 @@ export default {
...mapState('role', ['visibleRoles', 'roleId']),
...mapState('task', ['timeNode', 'timeUnit', 'tasks', 'regularTask', 'newProjectInfo', 'showSkeleton', 'showScrollTo']),
...mapState('project', ['project']),
...mapState('yanyuan', ['scene']),
...mapGetters('task', ['timeGranularity']),
...mapGetters('project', ['projectId']),
...mapGetters('user', ['userId']),
@ -57,10 +79,18 @@ export default {
onLoad(options) {
if (options.share && options.share === '1') {
console.log('0001');
this.shareInit(options);
} else {
console.log('0002');
this.init(options);
}
//
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
});
},
watch: {
@ -332,7 +362,7 @@ export default {
* 初始化
* @param {object | null} options
*/
init(options) {
async init(options) {
if (!this.token) {
// tokenuserIdtoken
// token userId
@ -354,6 +384,14 @@ export default {
}
// TODO
// this.getProjectById({ projectId: options.p, num: 0 }); // id
console.log('options: ', options);
// await this.queryFamilyIsMember(options.p);
console.log('this.userId: ', this.userId);
if (this.scene === 1007 || this.scene === 1008) {
console.log('查询用户是否是项目成员', this.userId);
await this.queryFamilyIsMember(options.p);
}
// id
this.getRoles({ projectId: options.p, num: 0, templateCode: this.project.templateCode });
@ -487,6 +525,37 @@ export default {
console.log('error: ', error);
}
},
/**
* 查询用户是否是项目成员
* @param {string} projectId
*/
async queryFamilyIsMember(projectId) {
try {
const params = { projectId };
const data = await this.$u.api.familyIsMember(params);
console.log('data: ', data);
//
if ((data.familyStatus === 1 || data.familyStatus === 2) && data.keyUserId) {
console.log('不是成员 询问是否成为家属');
const arr = [{ keyUserId: data.keyUserId, sex: data.sex, userName: data.userName }];
this.setElderlyInfo(arr);
this.showElder = true;
}
// if (data.familyStatus === 1) {
// console.log(' ');
// this.init(options);
// }
if (data.familyStatus === 0) {
console.log('申请已提交,返回首页');
this.transferContent = '家属申请已提交,请等待审核';
//
this.$t.page.openPage('/pagesYanyuan/transfer-page/transfer-page?type=jiashu');
}
} catch (error) {
console.error('error: ', error);
}
},
},
};
</script>

75
src/pagesYanyuan/hold-all/hold-all.vue

@ -15,23 +15,38 @@
class="mr-2"
:class="
item.equipmentStatus === 0
? 'text-blue-500'
: item.equipmentStatus === 1
? 'text-gray-500'
: item.equipmentStatus === 1
? 'text-green-500'
: item.equipmentStatus === 2
? 'text-red-500'
: 'text-green-500'
? 'text-yellow-500'
: 'text-red-500'
"
>
{{ item.code }}
</view>
<view class="flex items-center text-gray-400">
<u-icon v-if="item.wifiStatus === 2" name="wifi" color="#1890FF" size="36"></u-icon>
<u-icon v-else @click="openBinding" name="wifi" color="#999999" size="36"></u-icon>
<view class="flex items-center text-gray-400" @click="getUserName(item.equipmentId)">
<u-icon
:class="
item.equipmentStatus === 0
? 'text-gray-500'
: item.equipmentStatus === 1
? 'text-green-500'
: item.equipmentStatus === 2
? 'text-yellow-500'
: 'text-red-500'
"
name="error-circle"
size="36"
></u-icon>
</view>
</view>
<view class="flex flex-nowrap items-center">
<view class="battery-box">
<view class="flex items-center text-gray-400">
<u-icon v-if="item.wifiStatus === 1" name="wifi" color="#1890FF" size="36"></u-icon>
<u-icon v-else @click="openBinding" name="wifi" color="#999999" size="36"></u-icon>
</view>
<view class="battery-box ml-3">
<view class="battery-text u-font-10 font-light">{{ item.electricQuantity }}</view>
<view class="battery" :style="{ width: setWidth(item.electricQuantity) }"></view>
</view>
@ -40,6 +55,8 @@
</view>
</view>
<u-empty v-else text="列表为空" mode="list" class="mt-10"></u-empty>
<u-modal v-model="show" :content="content"></u-modal>
</view>
</template>
@ -49,23 +66,25 @@ export default {
return {
lists: [],
tips: [
{
value: '未设置',
bg: 'bg-gray-500',
},
{
value: '开机',
bg: 'bg-blue-500',
bg: 'bg-green-500',
},
{
value: '休眠',
bg: 'bg-gray-500',
bg: 'bg-yellow-500',
},
{
value: '断电',
value: '关机',
bg: 'bg-red-500',
},
{
value: '正常',
bg: 'bg-green-500',
},
],
content: '',
show: false,
};
},
@ -101,6 +120,32 @@ export default {
console.error('error: ', error);
}
},
/**
* 查询工具箱的使用者
* @param string equipmentId 设备id
*/
async getUserName(equipmentId) {
try {
const params = { equipmentId };
const data = await this.$u.api.getUserName(params);
console.log('data: ', data);
if (data.status === -2) {
this.show = true;
this.content = '使用前请先选择长者!';
}
if (data.status === -1) {
this.show = true;
this.content = '尚未填写长者信息!';
}
if (data.status === 0) {
this.show = true;
this.content = `绑定者为 ${data.userName},性别 ${data.sex === 1 ? '男' : '女'}`;
}
} catch (error) {
console.error('error: ', error);
}
},
},
};
</script>

9
src/store/yanyuan/mutations.js

@ -160,6 +160,15 @@ const mutations = {
setTestNumber(state, data) {
state.testNumber = data;
},
/**
* 设置场景值
* @param {object} state
* @param {object} data
*/
setScene(state, data) {
state.scene = data;
},
};
export default mutations;

1
src/store/yanyuan/state.js

@ -18,6 +18,7 @@ const state = {
enterByCode: false, // 是不是通过扫码进入
toolCode: '', // 二维码携带的工具箱code
testNumber: 0, // 已经完成的试题编号
scene: '', // 场景值
};
export default state;

Loading…
Cancel
Save