123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- <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) {
- let list = res.result.split("?")[1].split("&");
- let codeData = {};
- list.forEach((item) => {
- codeData[item.split("=")[0]] = item.split("=")[1];
- })
- if(codeData.type == 1 || codeData.type == 5 || codeData.type == 7 ||
- codeData.type == 8 || codeData.type == 9 || codeData.type == 10 ||
- codeData.type == 11 || codeData.type == 12){
- uni.navigateTo({
- url: '/pages/views/saoCode/saoCode?q=' + encodeURIComponent(res.result)
- });
- }else{
- uni.showToast({
- mask: true,
- icon: "none",
- position: "center",
- title: '请扫描正确的小程序二维码',
- duration: 2000
- });
- }
- }
- });
- },
- },
- 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>
|