| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 |
- <template>
- </template>
- <script>
- import { choseType } from '@/api/index.js';
- import {
- login,
- getUserInfo
- } from '@/api/login.js';
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- saveUrl,
- interceptor
- } from '@/utils/loginUtils.js';
- export default {
- data() {
- return {
- type: '',
- typeName: ''
- }
- },
- onLoad(opt) {
- let obj = this
- obj.type = opt.type
- if (obj.type == 1) {
- obj.typeName = '病人'
- } else if (obj.type == 2) {
- obj.typeName = '医生'
- } else if (obj.type == 3) {
- obj.typeName = '机构'
- }
- // 保存用户
- obj.setChooseType(obj.type)
- if (obj.hasLogin) {
- // 判断用户类型是否和入口类型一致
- getUserInfo({}).then(e => {
- obj.setUserInfo(e.data);
- if(obj.userInfo.ext_info == null) {
- choseType({
- type: obj.type*1
- })
- .then(function(re) {
- if (re.msg == '修改成功') {
- if (obj.type == 1) {
- uni.navigateTo({
- url: `/pages/public/PatRegister`
- });
- }
- if (obj.type == 2) {
- uni.navigateTo({
- url: `/pages/public/DocRegister`
- });
- }
- if (obj.type == 3) {
- uni.navigateTo({
- url: `/pages/public/MecRegister`
- });
- }
- }
- })
- .catch(eer => {
-
- });
- }else {
- if (obj.userInfo.type != obj.type) {
- uni.showModal({
- title: '提示',
- content: '您当前的用户类型和入口类型不一致,请选择相应的入口进入!',
- success: function(res) {
-
- setTimeout(function() {
- //安卓手机
- document.addEventListener(
- "WeixinJSBridgeReady",
- function() {
- WeixinJSBridge.call("closeWindow");
- },
- false
- );
- //ios手机
- WeixinJSBridge.call("closeWindow");
- }, 100);
-
- }
- })
- } else {
-
- if (obj.userInfo.type == 2) {
- uni.setTabBarItem({
- index: 0,
- text: '首页',
- iconPath: 'static/tabBar/tab-home.png',
- selectedIconPath: 'static/tabBar/tab-home-current.png'
- });
- uni.setTabBarItem({
- index: 1,
- text: '我的病人',
- iconPath: 'static/tabBar/tab-cate.png',
- selectedIconPath: 'static/tabBar/tab-cate-current.png',
- visible: true
- });
- uni.setTabBarItem({
- index: 2,
- text: '科普学习',
- iconPath: 'static/tabBar/tab-study.png',
- selectedIconPath: 'static/tabBar/tab-study-current.png',
- visible: false
- });
- uni.setTabBarItem({
- index: 3,
- text: '接单',
- iconPath: 'static/tabBar/jd.png',
- selectedIconPath: 'static/tabBar/jd-act.png',
- visible: true
- })
- uni.setTabBarItem({
- index: 4,
- text: '我的',
- iconPath: 'static/tabBar/tab-my.png',
- selectedIconPath: 'static/tabBar/tab-my-current.png'
- });
- }
- if (obj.userInfo.type == 3) {
- uni.setTabBarItem({
- index: 0,
- text: '首页',
- iconPath: 'static/tabBar/tab-home.png',
- selectedIconPath: 'static/tabBar/tab-home-current.png'
- });
- uni.setTabBarItem({
- index: 1,
- text: '咨询记录',
- iconPath: 'static/tabBar/tab-cate.png',
- selectedIconPath: 'static/tabBar/tab-cate-current.png',
- visible: true
- });
- uni.setTabBarItem({
- index: 2,
- text: '科普学习',
- iconPath: 'static/tabBar/tab-study.png',
- selectedIconPath: 'static/tabBar/tab-study-current.png',
- visible: false
- });
- uni.setTabBarItem({
- index: 3,
- text: '发布订单',
- iconPath: 'static/tabBar/jd.png',
- selectedIconPath: 'static/tabBar/jd-act.png',
- pagePath: '/pages/dd/dd',
- visible: true
- })
-
- uni.setTabBarItem({
- index: 4,
- text: '我的',
- iconPath: 'static/tabBar/tab-my.png',
- selectedIconPath: 'static/tabBar/tab-my-current.png'
- });
- }
- if (obj.userInfo.type == 1) {
- uni.setTabBarItem({
- index: 0,
- text: '首页',
- iconPath: 'static/tabBar/tab-home.png',
- selectedIconPath: 'static/tabBar/tab-home-current.png'
- });
- uni.setTabBarItem({
- index: 1,
- text: '咨询记录',
- iconPath: 'static/tabBar/tab-cate.png',
- selectedIconPath: 'static/tabBar/tab-cate-current.png',
- visible: true
- });
- uni.setTabBarItem({
- index: 2,
- text: '科普学习',
- iconPath: 'static/tabBar/tab-study.png',
- selectedIconPath: 'static/tabBar/tab-study-current.png',
- visible: true
- });
- uni.setTabBarItem({
- index: 3,
- text: '接单',
- iconPath: 'static/tabBar/jd.png',
- selectedIconPath: 'static/tabBar/jd-act.png',
- visible: false
- })
- uni.setTabBarItem({
- index: 4,
- text: '我的',
- iconPath: 'static/tabBar/tab-my.png',
- selectedIconPath: 'static/tabBar/tab-my-current.png.png'
- });
- }
- uni.switchTab({
- url: '/pages/index/home'
- })
- }
- }
-
- })
-
-
- } else {
- let bool = uni.getStorageSync('weichatBrowser')
- if(bool) {
- uni.navigateTo({
- url: '/pages/public/wxLogin'
- })
- }else {
- uni.navigateTo({
- url:'/pages/public/login'
- })
- }
-
- }
- },
- computed: {
- ...mapState(['hasLogin', 'userInfo'])
- },
- methods: {
- ...mapMutations(['setChooseType','setUserInfo'])
- }
- }
- </script>
- <style>
- </style>
|