chooseType.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. </template>
  3. <script>
  4. import { choseType } from '@/api/index.js';
  5. import {
  6. login,
  7. getUserInfo
  8. } from '@/api/login.js';
  9. import {
  10. mapState,
  11. mapMutations
  12. } from 'vuex';
  13. import {
  14. saveUrl,
  15. interceptor
  16. } from '@/utils/loginUtils.js';
  17. export default {
  18. data() {
  19. return {
  20. type: '',
  21. typeName: ''
  22. }
  23. },
  24. onLoad(opt) {
  25. let obj = this
  26. obj.type = opt.type
  27. if (obj.type == 1) {
  28. obj.typeName = '病人'
  29. } else if (obj.type == 2) {
  30. obj.typeName = '医生'
  31. } else if (obj.type == 3) {
  32. obj.typeName = '机构'
  33. }
  34. // 保存用户
  35. obj.setChooseType(obj.type)
  36. if (obj.hasLogin) {
  37. // 判断用户类型是否和入口类型一致
  38. getUserInfo({}).then(e => {
  39. obj.setUserInfo(e.data);
  40. if(obj.userInfo.ext_info == null) {
  41. choseType({
  42. type: obj.type*1
  43. })
  44. .then(function(re) {
  45. if (re.msg == '修改成功') {
  46. if (obj.type == 1) {
  47. uni.navigateTo({
  48. url: `/pages/public/PatRegister`
  49. });
  50. }
  51. if (obj.type == 2) {
  52. uni.navigateTo({
  53. url: `/pages/public/DocRegister`
  54. });
  55. }
  56. if (obj.type == 3) {
  57. uni.navigateTo({
  58. url: `/pages/public/MecRegister`
  59. });
  60. }
  61. }
  62. })
  63. .catch(eer => {
  64. });
  65. }else {
  66. if (obj.userInfo.type != obj.type) {
  67. uni.showModal({
  68. title: '提示',
  69. content: '您当前的用户类型和入口类型不一致,请选择相应的入口进入!',
  70. success: function(res) {
  71. setTimeout(function() {
  72. //安卓手机
  73. document.addEventListener(
  74. "WeixinJSBridgeReady",
  75. function() {
  76. WeixinJSBridge.call("closeWindow");
  77. },
  78. false
  79. );
  80. //ios手机
  81. WeixinJSBridge.call("closeWindow");
  82. }, 100);
  83. }
  84. })
  85. } else {
  86. if (obj.userInfo.type == 2) {
  87. uni.setTabBarItem({
  88. index: 0,
  89. text: '首页',
  90. iconPath: 'static/tabBar/tab-home.png',
  91. selectedIconPath: 'static/tabBar/tab-home-current.png'
  92. });
  93. uni.setTabBarItem({
  94. index: 1,
  95. text: '我的病人',
  96. iconPath: 'static/tabBar/tab-cate.png',
  97. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  98. visible: true
  99. });
  100. uni.setTabBarItem({
  101. index: 2,
  102. text: '科普学习',
  103. iconPath: 'static/tabBar/tab-study.png',
  104. selectedIconPath: 'static/tabBar/tab-study-current.png',
  105. visible: false
  106. });
  107. uni.setTabBarItem({
  108. index: 3,
  109. text: '接单',
  110. iconPath: 'static/tabBar/jd.png',
  111. selectedIconPath: 'static/tabBar/jd-act.png',
  112. visible: true
  113. })
  114. uni.setTabBarItem({
  115. index: 4,
  116. text: '我的',
  117. iconPath: 'static/tabBar/tab-my.png',
  118. selectedIconPath: 'static/tabBar/tab-my-current.png'
  119. });
  120. }
  121. if (obj.userInfo.type == 3) {
  122. uni.setTabBarItem({
  123. index: 0,
  124. text: '首页',
  125. iconPath: 'static/tabBar/tab-home.png',
  126. selectedIconPath: 'static/tabBar/tab-home-current.png'
  127. });
  128. uni.setTabBarItem({
  129. index: 1,
  130. text: '咨询记录',
  131. iconPath: 'static/tabBar/tab-cate.png',
  132. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  133. visible: true
  134. });
  135. uni.setTabBarItem({
  136. index: 2,
  137. text: '科普学习',
  138. iconPath: 'static/tabBar/tab-study.png',
  139. selectedIconPath: 'static/tabBar/tab-study-current.png',
  140. visible: false
  141. });
  142. uni.setTabBarItem({
  143. index: 3,
  144. text: '发布订单',
  145. iconPath: 'static/tabBar/jd.png',
  146. selectedIconPath: 'static/tabBar/jd-act.png',
  147. pagePath: '/pages/dd/dd',
  148. visible: true
  149. })
  150. uni.setTabBarItem({
  151. index: 4,
  152. text: '我的',
  153. iconPath: 'static/tabBar/tab-my.png',
  154. selectedIconPath: 'static/tabBar/tab-my-current.png'
  155. });
  156. }
  157. if (obj.userInfo.type == 1) {
  158. uni.setTabBarItem({
  159. index: 0,
  160. text: '首页',
  161. iconPath: 'static/tabBar/tab-home.png',
  162. selectedIconPath: 'static/tabBar/tab-home-current.png'
  163. });
  164. uni.setTabBarItem({
  165. index: 1,
  166. text: '咨询记录',
  167. iconPath: 'static/tabBar/tab-cate.png',
  168. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  169. visible: true
  170. });
  171. uni.setTabBarItem({
  172. index: 2,
  173. text: '科普学习',
  174. iconPath: 'static/tabBar/tab-study.png',
  175. selectedIconPath: 'static/tabBar/tab-study-current.png',
  176. visible: true
  177. });
  178. uni.setTabBarItem({
  179. index: 3,
  180. text: '接单',
  181. iconPath: 'static/tabBar/jd.png',
  182. selectedIconPath: 'static/tabBar/jd-act.png',
  183. visible: false
  184. })
  185. uni.setTabBarItem({
  186. index: 4,
  187. text: '我的',
  188. iconPath: 'static/tabBar/tab-my.png',
  189. selectedIconPath: 'static/tabBar/tab-my-current.png.png'
  190. });
  191. }
  192. uni.switchTab({
  193. url: '/pages/index/home'
  194. })
  195. }
  196. }
  197. })
  198. } else {
  199. let bool = uni.getStorageSync('weichatBrowser')
  200. if(bool) {
  201. uni.navigateTo({
  202. url: '/pages/public/wxLogin'
  203. })
  204. }else {
  205. uni.navigateTo({
  206. url:'/pages/public/login'
  207. })
  208. }
  209. }
  210. },
  211. computed: {
  212. ...mapState(['hasLogin', 'userInfo'])
  213. },
  214. methods: {
  215. ...mapMutations(['setChooseType','setUserInfo'])
  216. }
  217. }
  218. </script>
  219. <style>
  220. </style>