12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <template>
- <view id="home">
- <teacherHome class="flex-box-page" v-if="userType==1"></teacherHome>
- <pupilHome class="flex-box-page" v-if="userType==2"></pupilHome>
- <img class="scan_btn" @click.stop="saoCode" src="@/pages_safetyExamine/images/icon_xyxc_sm.png" />
- </view>
- </template>
- <script>
- import {
- teacherHome
- } from '@/pages/views/teacherPage/teacherHome'
- import {
- pupilHome
- } from '@/pages/views/pupilPage/pupilHome'
- export default {
- name: "home",
- components: {
- teacherHome,
- pupilHome,
- },
- data() {
- return {
- userType: 0,
- }
- },
- onLoad() {
-
- },
- onShow() {
- if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
- this.userType = uni.getStorageSync('userType')
- } else {
- uni.removeStorageSync('token');
- uni.removeStorageSync('userId');
- uni.removeStorageSync('userType');
- uni.redirectTo({
- url: '/pages/login/login',
- });
- }
- },
- methods: {
- /* 扫一扫*/
- saoCode() {
- let self = this;
- uni.scanCode({
- onlyFromCamera: true,
- success: function(res) {
- console.log('res',res)
- console.log('res.result',res.result)
- // uni.navigateTo({
- // url: '/pages/views/saoCode/saoCode?q=' + res.result
- // });
- uni.navigateTo({
- url: '/pages/views/saoCode/saoCode?q=' + encodeURIComponent(res.result)
- });
- }
- });
- },
- },
- onHide() {
- this.userType = 0;
- },
- onUnload() {
- this.userType = 0;
- }
- }
- </script>
- <style lang="stylus" scoped>
- #home {
- height: 100%;
- display: flex;
- flex-direction: column;
- .flex-box-page{
- flex:1;
- display: flex;
- flex-direction: column;
- }
- .scan_btn {
- z-index:10;
- position: fixed;
- bottom: 210rpx;
- right: 0rpx;
- width: 130rpx;
- height: 130rpx;
- }
- }
- </style>
|