Browse Source

fix: 修改扫码逻辑

develop
song 4 years ago
parent
commit
e1234a681c
  1. 3
      CHANGELOG.md
  2. 38
      src/App.vue
  3. 14
      src/components/ChooseElder/ChooseElder.vue
  4. 14
      src/components/ChooseUser/ChooseUser.vue
  5. 30
      src/components/Upload/Upload.vue
  6. 7
      src/mixins/tool.js
  7. 77
      src/pages/index/index.vue
  8. 6
      src/pagesProject/project/components/Evaluated/EvaluatedNLCP.vue
  9. 6
      src/pagesProject/project/components/Evaluated/EvaluatedXLJH.vue
  10. 39
      src/pagesUser/git-phone-power/git-phone-power.vue
  11. 13
      src/pagesYanyuan/input-code/input-code.vue
  12. 13
      src/pagesYanyuan/scan-code/scan-code.vue
  13. 10
      src/pagesYanyuan/transfer-page/transfer-page.vue

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-12-13) # 0.1.0 (2021-12-14)
### 🌟 新功能 ### 🌟 新功能
范围|描述|commitId 范围|描述|commitId
@ -187,6 +187,7 @@
- | 时间轴滚动位置修改 | [551da63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/551da63) - | 时间轴滚动位置修改 | [551da63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/551da63)
- | 时间轴骨架屏修改 | [ca78d02](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/ca78d02) - | 时间轴骨架屏修改 | [ca78d02](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/ca78d02)
- | 添加canvas | [9bc13c7](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/9bc13c7) - | 添加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) - | 监听时间基本点 | [033fca0](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/033fca0)
- | 答题时记录做到第几题 | [547eb6e](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/547eb6e) - | 答题时记录做到第几题 | [547eb6e](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/547eb6e)
- | 绘制canvas | [3c9d471](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/3c9d471) - | 绘制canvas | [3c9d471](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/3c9d471)

38
src/App.vue

@ -1,9 +1,9 @@
<script> <script>
import toolMixin from '@/mixins/tool'; // import toolMixin from '@/mixins/tool';
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex'; import { mapActions, mapGetters, mapMutations, mapState } from 'vuex';
export default { export default {
mixins: [toolMixin], // mixins: [toolMixin],
async onLaunch(options) { async onLaunch(options) {
// TODO: this // TODO: this
@ -44,16 +44,14 @@ export default {
computed: { computed: {
...mapGetters(['useStorage']), ...mapGetters(['useStorage']),
...mapState('user', ['token']), ...mapState('user', ['token']),
...mapState('yanyuan', ['enterByCode', 'toolCode']),
}, },
methods: { methods: {
...mapActions('user', ['getToken']), ...mapActions('user', ['getToken']),
...mapActions('socket', ['initSocket']), ...mapActions('socket', ['initSocket']),
...mapActions('yanyuan', ['getBindTool']),
...mapMutations(['setSystemInfo']), ...mapMutations(['setSystemInfo']),
...mapMutations('user', ['setToken', 'setUser']), ...mapMutations('user', ['setToken', 'setUser']),
...mapMutations('yanyuan', ['setIdentityInfo', 'setToolCode', 'setEnterByCode']), ...mapMutations('yanyuan', ['setToolCode', 'setEnterByCode']),
// //
async signin() { async signin() {
@ -63,11 +61,6 @@ export default {
this.setUser(data); this.setUser(data);
this.setToken(data.token); this.setToken(data.token);
this.noPhone(data); this.noPhone(data);
//
await this.homeIdentity();
if (this.enterByCode && this.toolCode) {
await this.bindTool();
}
} else { } else {
this.$t.ui.showToast('返回数据异常'); this.$t.ui.showToast('返回数据异常');
} }
@ -98,31 +91,6 @@ export default {
}, },
}); });
}, },
/**
* 首页用户身份判断
*/
async homeIdentity() {
try {
const data = await this.$u.api.homeIdentity();
this.setIdentityInfo(data);
} catch (error) {
console.error('error: ', error);
}
},
/**
* 绑定工具箱
*/
async bindTool() {
try {
const params = { toolCode: this.toolCode };
await this.getBindTool(params);
this.initTool();
} catch (error) {
console.error('error: ', error);
}
},
}, },
}; };
</script> </script>

14
src/components/ChooseElder/ChooseElder.vue

@ -3,14 +3,16 @@
<view <view
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
class="flex flex-nowrap text-center p-2" class="flex flex-nowrap p-2"
:class="item.checked ? 'bg-blue-500 text-white' : 'bg-gray-100'" :class="item.checked ? 'bg-blue-500 text-white' : 'bg-gray-100'"
@click="changeChecked(index)" @click="changeChecked(index)"
> >
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view> <view class="flex-1 flex flex-nowrap">
<view class="flex-1">{{ item.userName }} </view> <view class="flex-1">{{ item.userName }} </view>
<view class="flex-1" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view> <view class="flex-1" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view>
</view> </view>
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view>
</view>
</view> </view>
</template> </template>
@ -26,8 +28,14 @@ export default {
watch: { watch: {
elderlyInfo(val) { elderlyInfo(val) {
if (val && val.length) { if (val && val.length) {
val.forEach(item => { val.forEach((item, index) => {
if (index === 0) {
item.checked = true;
this.ids.push(item.keyUserId);
this.setKeyUserIds(this.ids);
} else {
item.checked = false; item.checked = false;
}
}); });
this.list = val; this.list = val;
} }

14
src/components/ChooseUser/ChooseUser.vue

@ -3,14 +3,16 @@
<view <view
v-for="(item, index) in list" v-for="(item, index) in list"
:key="index" :key="index"
class="flex flex-nowrap text-center p-2" class="flex flex-nowrap justify-between p-2"
:class="item.checked ? 'bg-blue-500 text-white' : 'bg-gray-100'" :class="item.checked ? 'bg-blue-500 text-white' : 'bg-gray-100'"
@click="changeChecked(index)" @click="changeChecked(index)"
> >
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view> <view class="flex-1 flex flex-nowrap">
<view class="flex-1">{{ item.userName }} </view> <view class="flex-1">{{ item.userName }} </view>
<view class="flex-1" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view> <view class="flex-1" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view>
</view> </view>
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view>
</view>
</view> </view>
</template> </template>
@ -26,8 +28,14 @@ export default {
watch: { watch: {
elderlyInfo(val) { elderlyInfo(val) {
if (val && val.length) { if (val && val.length) {
val.forEach(item => { val.forEach((item, index) => {
if (index === 0) {
item.checked = true;
this.ids.push(item.keyUserId);
this.setKeyUserIds(this.ids);
} else {
item.checked = false; item.checked = false;
}
}); });
this.list = val; this.list = val;
} }

30
src/components/Upload/Upload.vue

@ -36,6 +36,28 @@
@click="openPage('/pagesYanyuan/hold-all/hold-all')" @click="openPage('/pagesYanyuan/hold-all/hold-all')"
></u-icon> ></u-icon>
</view> </view>
<!-- 选择老人 -->
<!-- :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>
<!-- 全局提示框 -->
<u-top-tips ref="uTips"></u-top-tips>
</view> </view>
</template> </template>
@ -98,10 +120,11 @@ export default {
uni.scanCode({ uni.scanCode({
onlyFromCamera: true, onlyFromCamera: true,
success(res) { success(res) {
that.$t.ui.showToast('扫码成功');
const arr = res.path.split('='); const arr = res.path.split('=');
const toolCode = arr && arr.length ? arr[arr.length - 1] : ''; const toolCode = arr && arr.length ? arr[arr.length - 1] : '';
if (toolCode) {
that.submit(toolCode); that.submit(toolCode);
}
}, },
fail() { fail() {
that.failMsg('扫码失败'); that.failMsg('扫码失败');
@ -130,9 +153,12 @@ export default {
try { try {
const params = { toolCode }; const params = { toolCode };
await this.getBindTool(params); await this.getBindTool(params);
setTimeout(() => {
this.$t.ui.showToast('工具箱绑定成功');
this.initTool(); this.initTool();
}, 2000);
} catch (error) { } catch (error) {
console.error('error: ', error); console.error('error: ', error.msg || '工具箱绑定失败');
} }
}, },
}, },

7
src/mixins/tool.js

@ -84,14 +84,17 @@ export default {
.showModal('提示', '是否申请成为家属?') .showModal('提示', '是否申请成为家属?')
.then(async () => { .then(async () => {
const params = { bindUserId }; const params = { bindUserId };
console.log('params: ', params);
const res = await this.getCreateTrainee(params); const res = await this.getCreateTrainee(params);
console.log('res: ', res);
if (!res.length) { if (!res.length) {
this.$t.ui.showToast('提醒工具箱拥有者添加使用者信息'); this.$t.ui.showToast('提醒工具箱拥有者添加使用者信息');
setTimeout(() => { setTimeout(() => {
uni.redirectTo({ url: '/pages/index/index' }); uni.redirectTo({ url: '/pages/index/index' });
}, 2000); }, 2000);
} else { } else {
this.setShowChooseElder(true); this.showElder = true;
// this.setShowChooseElder(true);
} }
}) })
.catch(() => { .catch(() => {
@ -117,7 +120,7 @@ export default {
if (!this.keyUserIds.length) { if (!this.keyUserIds.length) {
this.setShowChooseElder(true); this.setShowChooseElder(true);
this.$t.ui.showToast('请先选择老人!'); this.$t.ui.showToast('请先选择老人!');
this.$refs.uModal.clearLoading(); // this.$refs.uModal.clearLoading();
return; return;
} }
this.setShowChooseElder(false); this.setShowChooseElder(false);

77
src/pages/index/index.vue

@ -14,23 +14,49 @@
<!-- 全局提示框 --> <!-- 全局提示框 -->
<u-top-tips ref="uTips"></u-top-tips> <u-top-tips ref="uTips"></u-top-tips>
<!-- 选择老人 -->
<!-- :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> </view>
</template> </template>
<script> <script>
import { mapState, mapMutations } from 'vuex'; import toolMixin from '@/mixins/tool';
import { mapState, mapMutations, mapActions } from 'vuex';
let prevY = 0; let prevY = 0;
export default { export default {
mixins: [toolMixin],
data() { data() {
return { return {
calendar: null, calendar: null,
days: [], days: [],
options: {},
}; };
}, },
computed: mapState('user', ['token', 'user']), computed: {
...mapState('user', ['token', 'user']),
...mapState('yanyuan', ['enterByCode', 'toolCode']),
},
watch: { watch: {
token(value) { token(value) {
@ -38,6 +64,15 @@ export default {
this.getProjects(); this.getProjects();
this.handleFindPoint(); this.handleFindPoint();
}, },
user(value) {
if (value.wxInfo && value.wxInfo.nickname && value.phone) {
if (this.options && this.options.scene && !this.options.code) {
//
this.homeIdentity();
}
}
},
}, },
onShow() { onShow() {
@ -47,12 +82,18 @@ export default {
this.setProject(); this.setProject();
}, },
onReady() { async onLoad(options) {
// this.calendar = this.$refs.calendar; this.options = options;
if (options.code === 'true') {
//
await this.homeIdentity();
}
}, },
methods: { methods: {
...mapMutations('project', ['setProjects', 'setDotList', 'setProject']), ...mapMutations('project', ['setProjects', 'setDotList', 'setProject']),
...mapActions('yanyuan', ['getBindTool']),
...mapMutations('yanyuan', ['setIdentityInfo']),
// //
getProjects(start = this.$moment().startOf('day').valueOf(), end = this.$moment().endOf('day').valueOf()) { getProjects(start = this.$moment().startOf('day').valueOf(), end = this.$moment().endOf('day').valueOf()) {
@ -124,6 +165,34 @@ export default {
duration: '6000', duration: '6000',
}); });
}, },
/**
* 首页用户身份判断
*/
async homeIdentity() {
try {
const data = await this.$u.api.homeIdentity();
this.setIdentityInfo(data);
if (this.enterByCode && this.toolCode) {
await this.bindTool();
}
} catch (error) {
console.error('error: ', error);
}
},
/**
* 绑定工具箱
*/
async bindTool() {
try {
const params = { toolCode: this.toolCode };
await this.getBindTool(params);
this.initTool();
} catch (error) {
console.error('error: ', error);
}
},
}, },
}; };
</script> </script>

6
src/pagesProject/project/components/Evaluated/EvaluatedNLCP.vue

@ -1,6 +1,6 @@
<template> <template>
<view class="charts-box"> <view class="charts-box">
<view class="flex justify-between"> <view class="flex justify-between" @click="changeShowState">
<view> <view>
<text class="mr-2 font-bold">{{ task.name }}</text> <text class="mr-2 font-bold">{{ task.name }}</text>
<u-rate <u-rate
@ -14,8 +14,8 @@
<!-- v-if="!task.data.showDetail" --> <!-- v-if="!task.data.showDetail" -->
</u-rate> </u-rate>
</view> </view>
<u-icon name="arrow-up" color="#909399" v-if="task.data.showDetail" @click="changeShowState"></u-icon> <u-icon name="arrow-up" color="#909399" v-if="task.data.showDetail"></u-icon>
<u-icon name="arrow-down" color="#909399" v-else @click="changeShowState"></u-icon> <u-icon name="arrow-down" color="#909399" v-else></u-icon>
</view> </view>
<view class="bg-white" v-if="obj && obj.id && task.data.showDetail"> <view class="bg-white" v-if="obj && obj.id && task.data.showDetail">
<UCharts <UCharts

6
src/pagesProject/project/components/Evaluated/EvaluatedXLJH.vue

@ -1,6 +1,6 @@
<template> <template>
<view> <view>
<view class="flex flex-nowrap items-center"> <view class="flex flex-nowrap items-center" @click="changeShowState(task.data.showDetail)">
<view class="flex-1 flex flex-nowrap items-center"> <view class="flex-1 flex flex-nowrap items-center">
<u-rate <u-rate
:count="task.data.train.level" :count="task.data.train.level"
@ -31,8 +31,8 @@
}} }}
</view> </view>
</view> </view>
<u-icon name="arrow-up" color="#909399" v-if="task.data.showDetail" @click="changeShowState(task.data.showDetail)"></u-icon> <u-icon name="arrow-up" color="#909399" v-if="task.data.showDetail"></u-icon>
<u-icon name="arrow-down" color="#909399" v-else @click="changeShowState(task.data.showDetail)"></u-icon> <u-icon name="arrow-down" color="#909399" v-else></u-icon>
</view> </view>
<!-- 详情 --> <!-- 详情 -->
<view v-if="task.data.showDetail"> <view v-if="task.data.showDetail">

39
src/pagesUser/git-phone-power/git-phone-power.vue

@ -36,7 +36,7 @@
<script> <script>
import UserAuthMixin from '@/mixins/userAuth'; import UserAuthMixin from '@/mixins/userAuth';
import { mapMutations } from 'vuex'; import { mapState, mapMutations, mapGetters } from 'vuex';
export default { export default {
mixins: [UserAuthMixin], mixins: [UserAuthMixin],
@ -52,6 +52,11 @@ export default {
}; };
}, },
computed: {
...mapGetters('user', ['userId']),
...mapState('yanyuan', ['enterByCode']),
},
mounted() { mounted() {
if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) { if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) {
this.showBindPnone = true; this.showBindPnone = true;
@ -88,7 +93,13 @@ export default {
type: 'success', type: 'success',
duration: '2000', duration: '2000',
}); });
setTimeout(() => uni.redirectTo({ url: '/pages/index/index' }), 2000); let url = '';
if (this.enterByCode) {
url = `/pages/index/index?u=${this.userId}&code=true`;
} else {
url = `/pages/index/index?u=${this.userId}`;
}
setTimeout(() => uni.reLaunch({ url }), 2000);
} else { } else {
this.phone = data.phone; this.phone = data.phone;
} }
@ -125,14 +136,26 @@ export default {
type: 'success', type: 'success',
duration: '3000', duration: '3000',
}); });
setTimeout(() => uni.redirectTo({ url: '/pages/index/index' }), 3000); let url = '';
if (this.enterByCode) {
url = `/pages/index/index?u=${this.userId}&code=true`;
} else {
url = `/pages/index/index?u=${this.userId}`;
}
setTimeout(() => uni.reLaunch({ url }), 3000);
} else { } else {
this.$refs.uTips.show({ this.$refs.uTips.show({
title: '即将跳转上一页', title: '即将跳转上一页',
type: 'success', type: 'success',
duration: '3000', duration: '3000',
}); });
setTimeout(() => uni.redirectTo({ url: '/pages/index/index' }), 3000); let url = '';
if (this.enterByCode) {
url = `/pages/index/index?u=${this.userId}&code=true`;
} else {
url = `/pages/index/index?u=${this.userId}`;
}
setTimeout(() => uni.reLaunch({ url }), 3000);
} }
} catch (error) { } catch (error) {
console.error('error: ', error); console.error('error: ', error);
@ -143,7 +166,13 @@ export default {
// //
back() { back() {
uni.redirectTo({ url: '/pages/index/index' }); let url = '';
if (this.enterByCode) {
url = `/pages/index/index?u=${this.userId}&code=true`;
} else {
url = `/pages/index/index?u=${this.userId}`;
}
uni.reLaunch({ url });
}, },
}, },
}; };

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

@ -11,25 +11,18 @@
</view> </view>
<!-- 选择老人 --> <!-- 选择老人 -->
<u-modal <!-- :async-close="true" -->
v-model="showElder" <u-modal v-model="showElder" title="选择老人" @confirm="confirmModel" @cancel="cancelModel" ref="uModal" :show-cancel-button="true">
title="选择老人"
@confirm="confirmModel"
@cancel="cancelModel"
:async-close="true"
ref="uModal"
:show-cancel-button="true"
>
<ChooseElder></ChooseElder> <ChooseElder></ChooseElder>
</u-modal> </u-modal>
<!-- 设置使用者 --> <!-- 设置使用者 -->
<!-- :async-close="true" -->
<u-modal <u-modal
v-model="showUser" v-model="showUser"
title="设置使用者" title="设置使用者"
@confirm="confirmSetUserModel" @confirm="confirmSetUserModel"
@cancel="cancelSetUserModel" @cancel="cancelSetUserModel"
:async-close="true"
ref="uModal" ref="uModal"
:show-cancel-button="true" :show-cancel-button="true"
> >

13
src/pagesYanyuan/scan-code/scan-code.vue

@ -39,25 +39,18 @@
</view> </view>
<!-- 选择老人 --> <!-- 选择老人 -->
<u-modal <!-- :async-close="true" -->
v-model="showElder" <u-modal v-model="showElder" title="选择老人" @confirm="confirmModel" @cancel="cancelModel" ref="uModal" :show-cancel-button="true">
title="选择老人"
@confirm="confirmModel"
@cancel="cancelModel"
:async-close="true"
ref="uModal"
:show-cancel-button="true"
>
<ChooseElder></ChooseElder> <ChooseElder></ChooseElder>
</u-modal> </u-modal>
<!-- 设置使用者 --> <!-- 设置使用者 -->
<!-- :async-close="true" -->
<u-modal <u-modal
v-model="showUser" v-model="showUser"
title="设置使用者" title="设置使用者"
@confirm="confirmSetUserModel" @confirm="confirmSetUserModel"
@cancel="cancelSetUserModel" @cancel="cancelSetUserModel"
:async-close="true"
ref="uModal" ref="uModal"
:show-cancel-button="true" :show-cancel-button="true"
> >

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

@ -3,7 +3,7 @@
<img class="my-28 w-24 h-24" src="https://www.tall.wiki/staticrec/yanyuan/logo.png" /> <img class="my-28 w-24 h-24" src="https://www.tall.wiki/staticrec/yanyuan/logo.png" />
<view class="text-xl flex flex-col"> <view class="text-xl flex flex-col">
<text class="mb-1">{{ content }}</text> <text class="mb-1">{{ content }}</text>
<text>5秒后跳转到首页...</text> <text>{{ time }}秒后跳转到首页...</text>
</view> </view>
</view> </view>
</template> </template>
@ -13,7 +13,7 @@ import toolMixin from '@/mixins/tool';
export default { export default {
mixins: [toolMixin], mixins: [toolMixin],
data() { data() {
return { content: '' }; return { content: '', time: 5, timer: null };
}, },
onLoad(options) { onLoad(options) {
@ -38,6 +38,12 @@ export default {
async openApplyModal() { async openApplyModal() {
await this.applyFamily(); await this.applyFamily();
this.content = this.transferContent; this.content = this.transferContent;
this.timer = setInterval(() => {
this.time--;
if (this.time === 0) {
clearInterval(this.timer);
}
}, 1000);
}, },
}, },
}; };

Loading…
Cancel
Save