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
@ -187,6 +187,7 @@
- | 时间轴滚动位置修改 | [551da63](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/551da63)
- | 时间轴骨架屏修改 | [ca78d02](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/ca78d02)
- | 添加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)
- | 答题时记录做到第几题 | [547eb6e](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/547eb6e)
- | 绘制canvas | [3c9d471](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/3c9d471)

38
src/App.vue

@ -1,9 +1,9 @@
<script>
import toolMixin from '@/mixins/tool';
// import toolMixin from '@/mixins/tool';
import { mapActions, mapGetters, mapMutations, mapState } from 'vuex';
export default {
mixins: [toolMixin],
// mixins: [toolMixin],
async onLaunch(options) {
// TODO: this
@ -44,16 +44,14 @@ export default {
computed: {
...mapGetters(['useStorage']),
...mapState('user', ['token']),
...mapState('yanyuan', ['enterByCode', 'toolCode']),
},
methods: {
...mapActions('user', ['getToken']),
...mapActions('socket', ['initSocket']),
...mapActions('yanyuan', ['getBindTool']),
...mapMutations(['setSystemInfo']),
...mapMutations('user', ['setToken', 'setUser']),
...mapMutations('yanyuan', ['setIdentityInfo', 'setToolCode', 'setEnterByCode']),
...mapMutations('yanyuan', ['setToolCode', 'setEnterByCode']),
//
async signin() {
@ -63,11 +61,6 @@ export default {
this.setUser(data);
this.setToken(data.token);
this.noPhone(data);
//
await this.homeIdentity();
if (this.enterByCode && this.toolCode) {
await this.bindTool();
}
} else {
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>

14
src/components/ChooseElder/ChooseElder.vue

@ -3,14 +3,16 @@
<view
v-for="(item, index) in list"
: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'"
@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" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view>
</view>
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view>
</view>
</view>
</template>
@ -26,8 +28,14 @@ export default {
watch: {
elderlyInfo(val) {
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;
}
});
this.list = val;
}

14
src/components/ChooseUser/ChooseUser.vue

@ -3,14 +3,16 @@
<view
v-for="(item, index) in list"
: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'"
@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" v-if="item.sex">{{ item.sex === 1 ? '' : item.sex === 2 ? '' : '' }}</view>
</view>
<view v-if="item.checked"><u-icon name="checkbox-mark"></u-icon></view>
</view>
</view>
</template>
@ -26,8 +28,14 @@ export default {
watch: {
elderlyInfo(val) {
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;
}
});
this.list = val;
}

30
src/components/Upload/Upload.vue

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

7
src/mixins/tool.js

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

77
src/pages/index/index.vue

@ -14,23 +14,49 @@
<!-- 全局提示框 -->
<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>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
import toolMixin from '@/mixins/tool';
import { mapState, mapMutations, mapActions } from 'vuex';
let prevY = 0;
export default {
mixins: [toolMixin],
data() {
return {
calendar: null,
days: [],
options: {},
};
},
computed: mapState('user', ['token', 'user']),
computed: {
...mapState('user', ['token', 'user']),
...mapState('yanyuan', ['enterByCode', 'toolCode']),
},
watch: {
token(value) {
@ -38,6 +64,15 @@ export default {
this.getProjects();
this.handleFindPoint();
},
user(value) {
if (value.wxInfo && value.wxInfo.nickname && value.phone) {
if (this.options && this.options.scene && !this.options.code) {
//
this.homeIdentity();
}
}
},
},
onShow() {
@ -47,12 +82,18 @@ export default {
this.setProject();
},
onReady() {
// this.calendar = this.$refs.calendar;
async onLoad(options) {
this.options = options;
if (options.code === 'true') {
//
await this.homeIdentity();
}
},
methods: {
...mapMutations('project', ['setProjects', 'setDotList', 'setProject']),
...mapActions('yanyuan', ['getBindTool']),
...mapMutations('yanyuan', ['setIdentityInfo']),
//
getProjects(start = this.$moment().startOf('day').valueOf(), end = this.$moment().endOf('day').valueOf()) {
@ -124,6 +165,34 @@ export default {
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>

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

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

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

@ -1,6 +1,6 @@
<template>
<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">
<u-rate
:count="task.data.train.level"
@ -31,8 +31,8 @@
}}
</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-down" color="#909399" v-else @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></u-icon>
</view>
<!-- 详情 -->
<view v-if="task.data.showDetail">

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

@ -36,7 +36,7 @@
<script>
import UserAuthMixin from '@/mixins/userAuth';
import { mapMutations } from 'vuex';
import { mapState, mapMutations, mapGetters } from 'vuex';
export default {
mixins: [UserAuthMixin],
@ -52,6 +52,11 @@ export default {
};
},
computed: {
...mapGetters('user', ['userId']),
...mapState('yanyuan', ['enterByCode']),
},
mounted() {
if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) {
this.showBindPnone = true;
@ -88,7 +93,13 @@ export default {
type: 'success',
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 {
this.phone = data.phone;
}
@ -125,14 +136,26 @@ export default {
type: 'success',
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 {
this.$refs.uTips.show({
title: '即将跳转上一页',
type: 'success',
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) {
console.error('error: ', error);
@ -143,7 +166,13 @@ export default {
//
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>
<!-- 选择老人 -->
<u-modal
v-model="showElder"
title="选择老人"
@confirm="confirmModel"
@cancel="cancelModel"
:async-close="true"
ref="uModal"
:show-cancel-button="true"
>
<!-- :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"
:async-close="true"
ref="uModal"
:show-cancel-button="true"
>

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

@ -39,25 +39,18 @@
</view>
<!-- 选择老人 -->
<u-modal
v-model="showElder"
title="选择老人"
@confirm="confirmModel"
@cancel="cancelModel"
:async-close="true"
ref="uModal"
:show-cancel-button="true"
>
<!-- :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"
:async-close="true"
ref="uModal"
: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" />
<view class="text-xl flex flex-col">
<text class="mb-1">{{ content }}</text>
<text>5秒后跳转到首页...</text>
<text>{{ time }}秒后跳转到首页...</text>
</view>
</view>
</template>
@ -13,7 +13,7 @@ import toolMixin from '@/mixins/tool';
export default {
mixins: [toolMixin],
data() {
return { content: '' };
return { content: '', time: 5, timer: null };
},
onLoad(options) {
@ -38,6 +38,12 @@ export default {
async openApplyModal() {
await this.applyFamily();
this.content = this.transferContent;
this.timer = setInterval(() => {
this.time--;
if (this.time === 0) {
clearInterval(this.timer);
}
}, 1000);
},
},
};

Loading…
Cancel
Save