user.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <template>
  2. <view class="container">
  3. <view class="user-section">
  4. <!-- <view class="bg"></view> -->
  5. <view class="user-info-box flex_item" @click="ToMycode">
  6. <view class="portrait" v-if="userInfo.type != 2 && userInfo.type">
  7. <image :src="userInfo.avatar"></image>
  8. </view>
  9. <view class="portrait" v-if="!userInfo.type">
  10. <image src="../../static/error/missing-face.png"></image>
  11. </view>
  12. <view class="portrait" v-if="userInfo.type == 2">
  13. <image :src="userInfo.ext_info.photo"></image>
  14. </view>
  15. <view class="info">
  16. <view class="name-box flex_item">
  17. <view class="name clamp">
  18. {{ (userInfo.ext_info ? (userInfo.ext_info.name ? userInfo.ext_info.name : false) : false) || '游客' }}
  19. </view>
  20. <view class="name-text" v-if="userInfo.type == 1">用户</view>
  21. <view class="name-text" v-if="userInfo.type == 2">医生</view>
  22. <view class="name-text" v-if="userInfo.type == 3">机构</view>
  23. </view>
  24. <view class="name-box flex_item" v-if="userInfo.type">
  25. <view class="name-text left" v-if="userInfo.type != 1 && userInfo.ext_info.status == 0">审核中
  26. </view>
  27. <view class="name-text left" v-if="userInfo.type != 1 && userInfo.ext_info.status == 2">审核不通过
  28. </view>
  29. </view>
  30. <view v-if="userInfo.type == 2">所在医院:{{ userInfo.ext_info.hospital_name }}</view>
  31. </view>
  32. <!-- <view class="icon flex">
  33. <view class="my" @click.stop="navTo('/pages/user/msg')"><image src="/static/img/img012.png"></image></view>
  34. </view> -->
  35. </view>
  36. <!-- <view class="myinfo flex" v-if="userInfo.type == 1" @click="navTo('/pages/userinfo/patient')">我的资料</view> -->
  37. <image class="arc" src="/static/img/arc.png"></image>
  38. </view>
  39. <view class="cover-container">
  40. <view class="info-box" v-if="userInfo.type != 2"
  41. @click="navTo('/pages/shareQrCode/index?spread=' + userInfo.uid)">
  42. <view class="info">
  43. <image src="/static/img/img032.png" mode="aspectFit"></image>
  44. </view>
  45. <view class="text">二维码分享</view>
  46. </view>
  47. <view class="info-box" v-if="userInfo.type == 2"
  48. @click="navTo('/pages/shareQrCode/card?spread=' + userInfo.uid)">
  49. <view class="info">
  50. <image src="/static/img/img032.png" mode="aspectFit"></image>
  51. </view>
  52. <view class="text">二维码分享</view>
  53. </view>
  54. <view class="item-box">
  55. <view class="flex item-list" @click="navTo('/pages/wallet/commission')">
  56. <view class="flex_item list-icon">
  57. <view class="icon">
  58. <image src="/static/img/img033.png"></image>
  59. </view>
  60. <view class="text">我的余额</view>
  61. </view>
  62. <view class="icon"><text class="iconfont iconenter"></text></view>
  63. </view>
  64. <view class="fen"></view>
  65. <view class="flex item-list" @click="navTo('/pages/order/myorder')">
  66. <view class="flex_item list-icon">
  67. <view class="icon">
  68. <image src="/static/img/img034.png"></image>
  69. </view>
  70. <view class="text">我的订单</view>
  71. </view>
  72. <view class="icon"><text class="iconfont iconenter"></text></view>
  73. </view>
  74. <view class="fen"></view>
  75. <view class="flex item-list" @click="navTo('/pages/recommend/index')">
  76. <view class="flex_item list-icon">
  77. <view class="icon">
  78. <image src="/static/img/img036.png"></image>
  79. </view>
  80. <view class="text">我的推荐</view>
  81. </view>
  82. <view class="icon"><text class="iconfont iconenter"></text></view>
  83. </view>
  84. <view class="fen"></view>
  85. <view class="flex item-list" v-if="userInfo.type == 1" @click="navTo('/pages/userinfo/patient')">
  86. <view class="flex_item list-icon">
  87. <view class="icon">
  88. <image src="/static/img/img035.png"></image>
  89. </view>
  90. <view class="text">我的资料</view>
  91. </view>
  92. <view class="icon"><text class="iconfont iconenter"></text></view>
  93. </view>
  94. <view class="flex item-list" v-if="userInfo.type == 2" @click="navTo('/pages/userinfo/doctor')">
  95. <view class="flex_item list-icon">
  96. <view class="icon">
  97. <image src="/static/img/img035.png"></image>
  98. </view>
  99. <view class="text">我的资料</view>
  100. </view>
  101. <view class="icon"><text class="iconfont iconenter"></text></view>
  102. </view>
  103. <view class="flex item-list" v-if="userInfo.type == 3" @click="navTo('/pages/userinfo/mechanism')">
  104. <view class="flex_item list-icon">
  105. <view class="icon">
  106. <image src="/static/img/img035.png"></image>
  107. </view>
  108. <view class="text">我的资料</view>
  109. </view>
  110. <view class="icon"><text class="iconfont iconenter"></text></view>
  111. </view>
  112. </view>
  113. </view>
  114. <!-- 问诊评论 -->
  115. <view class="item-box bottom" v-if="userInfo.type == 2">
  116. <view class="icon-box flex_item">
  117. <view class="left-icon"></view>
  118. <view class="flex left-box">
  119. <view class="left-tit">问诊评论</view>
  120. <view class="more" @click="navTo('/pages/user/reply?id=' + userInfo.uid)">
  121. 查看更多
  122. <text class="iconfont iconenter"></text>
  123. </view>
  124. </view>
  125. </view>
  126. <view class="left-txt" v-if="list == ''">暂无数据</view>
  127. <view class="ask-list flex_item" v-if="list != ''" v-for="(ls, index) in list" :key="index">
  128. <image :src="ls.avatar || '/static/error/missing-face.png'" class="ask-img"></image>
  129. <text class="ask-txt ellipsis">{{ ls.comment }}</text>
  130. </view>
  131. </view>
  132. <view class="list-cell" v-if="userInfo.type" @click="toLogout"><text class="cell-tit">退出登录</text></view>
  133. </view>
  134. </template>
  135. <script>
  136. import {
  137. mapState,
  138. mapMutations
  139. } from 'vuex';
  140. import uniList from '@/components/uni-list/uni-list.vue';
  141. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  142. import {
  143. getUserInfo
  144. } from '@/api/login.js';
  145. import {
  146. allComment
  147. } from '@/api/doctor.js';
  148. import {
  149. saveUrl,
  150. interceptor
  151. } from '@/utils/loginUtils.js';
  152. import {
  153. logout
  154. } from '@/api/set.js';
  155. let startY = 0,
  156. moveY = 0,
  157. pageAtTop = true;
  158. export default {
  159. components: {
  160. uniList,
  161. uniListItem
  162. },
  163. data() {
  164. return {
  165. list: ''
  166. };
  167. },
  168. onShow() {
  169. // 判断是否已经登录
  170. console.log(this.hasLogin, 'user');
  171. this.loadBaseData();
  172. // if (this.hasLogin) {
  173. // } else {
  174. // this.userInfo = {
  175. // ext_info: {
  176. // status: ''
  177. // }
  178. // };
  179. // }
  180. },
  181. watch: {},
  182. computed: {
  183. ...mapState(['hasLogin', 'userInfo'])
  184. },
  185. methods: {
  186. ...mapMutations(['setUserInfo', 'setOrderInfo', 'logout']),
  187. //退出登录
  188. toLogout() {
  189. uni.showModal({
  190. content: '确定要退出登录么',
  191. success: e => {
  192. if (e.confirm) {
  193. this.logout();
  194. }
  195. }
  196. });
  197. },
  198. // 加载初始数据
  199. loadBaseData() {
  200. let obj = this;
  201. getUserInfo({})
  202. .then(({
  203. data
  204. }) => {
  205. obj.setUserInfo(data);
  206. // obj.userInfo = data;
  207. console.log(obj.userInfo);
  208. // let arr = data.map(e => {
  209. // e.createtime = getTime(e.createtime);
  210. // return e;
  211. // });
  212. this.getDoctor();
  213. if (data.ext_info.status == 2) {
  214. uni.showModal({
  215. title: '提示',
  216. content: '您的审核未通过: \n ' + data.ext_info.reason + ' \n 是否重新提交审核!',
  217. success: function(res) {
  218. if (res.confirm) {
  219. console.log('用户点击确定');
  220. if (data.type == 2) {
  221. uni.navigateTo({
  222. url: '/pages/public/DocRegister'
  223. });
  224. }
  225. if (data.type == 3) {
  226. uni.navigateTo({
  227. url: '/pages/public/MecRegister'
  228. });
  229. }
  230. } else if (res.cancel) {
  231. console.log('用户点击取消');
  232. }
  233. }
  234. });
  235. }
  236. // 1是病人 2是医生 3是机构
  237. if (obj.userInfo.type == 2) {
  238. uni.setTabBarItem({
  239. index: 0,
  240. text: '首页',
  241. iconPath: 'static/tabBar/tab-home.png',
  242. selectedIconPath: 'static/tabBar/tab-home-current.png'
  243. });
  244. uni.setTabBarItem({
  245. index: 1,
  246. text: '我的病人',
  247. iconPath: 'static/tabBar/tab-cate.png',
  248. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  249. visible: true
  250. });
  251. uni.setTabBarItem({
  252. index: 2,
  253. text: '科普学习',
  254. iconPath: 'static/tabBar/tab-study.png',
  255. selectedIconPath: 'static/tabBar/tab-study-current.png',
  256. visible: false
  257. });
  258. uni.setTabBarItem({
  259. index: 3,
  260. text: '接单',
  261. iconPath: 'static/tabBar/jd.png',
  262. selectedIconPath: 'static/tabBar/jd-act.png',
  263. pagePath: '/pages/dd/dd',
  264. visible:true
  265. })
  266. uni.setTabBarItem({
  267. index: 4,
  268. text: '我的',
  269. iconPath: 'static/tabBar/tab-my.png',
  270. selectedIconPath: 'static/tabBar/tab-my-current.png'
  271. });
  272. }
  273. if (obj.userInfo.type == 1) {
  274. uni.setTabBarItem({
  275. index: 0,
  276. text: '首页',
  277. iconPath: 'static/tabBar/tab-home.png',
  278. selectedIconPath: 'static/tabBar/tab-home-current.png'
  279. });
  280. uni.setTabBarItem({
  281. index: 1,
  282. text: '咨询记录',
  283. iconPath: 'static/tabBar/tab-cate.png',
  284. selectedIconPath: 'static/tabBar/tab-cate-current.png',
  285. visible: true
  286. });
  287. uni.setTabBarItem({
  288. index: 2,
  289. text: '科普学习',
  290. iconPath: 'static/tabBar/tab-study.png',
  291. selectedIconPath: 'static/tabBar/tab-study-current.png',
  292. visible: false
  293. });
  294. uni.setTabBarItem({
  295. index: 3,
  296. text: '接单',
  297. iconPath: 'static/tabBar/jd.png',
  298. selectedIconPath: 'static/tabBar/jd-act.png',
  299. visible: false
  300. })
  301. uni.setTabBarItem({
  302. index: 4,
  303. text: '我的',
  304. iconPath: 'static/tabBar/tab-my.png',
  305. selectedIconPath: 'static/tabBar/tab-my-current.png'
  306. });
  307. }
  308. if (obj.userInfo.type == 3) {
  309. uni.setTabBarItem({
  310. index: 0,
  311. text: '首页',
  312. iconPath: 'static/tabBar/tab-home.png',
  313. selectedIconPath: 'static/tabBar/tab-home-current.png'
  314. });
  315. uni.setTabBarItem({
  316. index: 1,
  317. text: '咨询记录',
  318. iconPath: 'static/tabBar/tab-cate.png',
  319. selectedIconPath: 'static/tabBar/tab-cate-current.png'
  320. });
  321. uni.setTabBarItem({
  322. index: 2,
  323. text: '科普学习',
  324. iconPath: 'static/tabBar/tab-study.png',
  325. selectedIconPath: 'static/tabBar/tab-study-current.png',
  326. visible: false
  327. });
  328. uni.setTabBarItem({
  329. index: 3,
  330. text: '发布订单',
  331. iconPath: 'static/tabBar/jd.png',
  332. selectedIconPath: 'static/tabBar/jd-act.png',
  333. pagePath: '/pages/dd/dd',
  334. visible: true
  335. })
  336. uni.setTabBarItem({
  337. index: 4,
  338. text: '我的',
  339. iconPath: 'static/tabBar/tab-my.png',
  340. selectedIconPath: 'static/tabBar/tab-my-current.png'
  341. });
  342. }
  343. if (obj.userInfo.type == 2 && obj.userInfo.ext_info.price == '0.00') {
  344. uni.showModal({
  345. title: '提示',
  346. content: '您的用户信息尚未完善,是否前去完善?',
  347. success: function(res) {
  348. if (res.confirm) {
  349. console.log('用户点击确定');
  350. uni.navigateTo({
  351. url: '/pages/userinfo/doctor'
  352. });
  353. } else if (res.cancel) {
  354. console.log('用户点击取消');
  355. }
  356. }
  357. });
  358. }
  359. })
  360. .catch(e => {
  361. if (e.message == '请登录') {
  362. uni.showModal({
  363. title: '提示',
  364. content: '您未登录,是否登录?',
  365. success: function(res) {
  366. if (res.confirm) {
  367. uni.navigateTo({
  368. url: '/pages/public/wxLogin'
  369. });
  370. } else if (res.cancel) {
  371. console.log('用户点击取消');
  372. }
  373. }
  374. });
  375. } else {
  376. console.log(e.message);
  377. }
  378. });
  379. },
  380. //获取医生详情
  381. getDoctor() {
  382. let obj = this;
  383. console.log(obj.userInfo, 55);
  384. allComment({
  385. uid: obj.userInfo.uid,
  386. limit: 5,
  387. page: 1
  388. })
  389. .then(({
  390. data
  391. }) => {
  392. obj.list = data;
  393. })
  394. .catch(e => {
  395. console.log(e.message);
  396. });
  397. },
  398. ToMycode() {
  399. if (this.userInfo.type == 1) {
  400. uni.navigateTo({
  401. url: '/pages/userinfo/patient'
  402. });
  403. }
  404. if (this.userInfo.type == 2) {
  405. uni.navigateTo({
  406. url: '/pages/userinfo/doctor'
  407. });
  408. }
  409. if (this.userInfo.type == 3) {
  410. uni.navigateTo({
  411. url: '/pages/userinfo/mechanism'
  412. });
  413. }
  414. },
  415. /**
  416. * 统一跳转接口,拦截未登录路由
  417. * navigator标签现在默认没有转场动画,所以用view
  418. */
  419. navTo(url) {
  420. if (!this.hasLogin) {
  421. // 保存地址
  422. saveUrl();
  423. uni.showModal({
  424. title: '提示',
  425. content: '您未登录,是否马上登录?',
  426. success: res => {
  427. if (res.confirm) {
  428. interceptor();
  429. }
  430. }
  431. });
  432. // 登录拦截
  433. } else {
  434. uni.navigateTo({
  435. url
  436. });
  437. }
  438. }
  439. }
  440. };
  441. </script>
  442. <style lang="scss">
  443. .list-cell {
  444. margin-top: 60rpx;
  445. .cell-tit {
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. text-align: center;
  450. width: 560rpx;
  451. height: 80rpx;
  452. color: #fff;
  453. background: $base-color;
  454. border-radius: 40rpx;
  455. font-size: $font-base + 2rpx;
  456. margin: 0 auto;
  457. }
  458. }
  459. page {
  460. height: 100%;
  461. // padding-bottom: 188rpx;
  462. }
  463. %flex-center {
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: center;
  467. align-items: center;
  468. }
  469. %section {
  470. display: flex;
  471. justify-content: space-around;
  472. align-content: center;
  473. background: #fff;
  474. border-radius: 10rpx;
  475. }
  476. .container {
  477. background-color: $page-color-base;
  478. height: 1650rpx;
  479. // padding-bottom: 188rpx;
  480. }
  481. .user-section {
  482. // height: 500rpx;
  483. padding: 60rpx 30rpx 0;
  484. padding-bottom: 90rpx;
  485. position: relative;
  486. background: linear-gradient(52deg, #7e99fe, #978ffa);
  487. .arc {
  488. position: absolute;
  489. left: 0;
  490. bottom: 0;
  491. // margin-top: -34rpx;
  492. width: 100%;
  493. height: 36rpx;
  494. }
  495. // .bg {
  496. // position: absolute;
  497. // left: 0;
  498. // top: 0;
  499. // width: 100%;
  500. // height: 100%;
  501. // background: linear-gradient(52deg, rgba(126, 153, 254, 1), rgba(151, 143, 250, 1));
  502. // }
  503. }
  504. .user-info-box {
  505. font-size: 32rpx;
  506. color: #ffffff;
  507. height: 200rpx;
  508. // display: flex;
  509. // align-items: center;
  510. // justify-content: space-between;
  511. // position: relative;
  512. z-index: 3;
  513. .portrait {
  514. width: 135rpx;
  515. height: 135rpx;
  516. image {
  517. width: 100%;
  518. height: 100%;
  519. border-radius: 100%;
  520. }
  521. }
  522. .info {
  523. padding: 0rpx 25rpx;
  524. width: 75%;
  525. .name-box {
  526. width: 100%;
  527. padding-bottom: 15rpx;
  528. .name {
  529. font-size: 32rpx;
  530. max-width: 60%;
  531. }
  532. .name-text {
  533. margin-left: 25rpx;
  534. font-size: 22rpx !important;
  535. border: 2rpx solid #ffffff;
  536. padding: 2rpx 25rpx;
  537. border-radius: 25rpx;
  538. }
  539. .left {
  540. margin-left: 0 !important;
  541. }
  542. }
  543. }
  544. .icon {
  545. image {
  546. width: 48rpx;
  547. height: 49rpx;
  548. }
  549. }
  550. }
  551. .myinfo {
  552. z-index: 999;
  553. position: absolute;
  554. right: 0;
  555. top: 25%;
  556. background-color: #ffffff;
  557. color: #6786fb;
  558. font-size: 24rpx;
  559. padding: 14rpx 29rpx;
  560. border-top-left-radius: 50rpx;
  561. border-bottom-left-radius: 50rpx;
  562. }
  563. .cover-container {
  564. // background: $page-color-base;
  565. margin-top: -100rpx;
  566. position: relative;
  567. // background: #f5f5f5;
  568. padding-bottom: 20rpx;
  569. .info-box {
  570. // position: absolute;
  571. // top: -80rpx;
  572. z-index: 999;
  573. margin: 0 auto;
  574. // margin-top: -80rpx;
  575. width: 91%;
  576. color: #697079;
  577. left: 35rpx;
  578. border-radius: 25rpx;
  579. background-color: #ffffff;
  580. text-align: center;
  581. font-size: 24rpx;
  582. padding: 25rpx 0rpx;
  583. .info {
  584. width: 100%;
  585. height: 100rpx;
  586. text-align: center;
  587. image {
  588. width: 100rpx;
  589. height: 100%;
  590. }
  591. }
  592. .text {
  593. padding-top: 15rpx;
  594. }
  595. }
  596. }
  597. .bottom {
  598. padding-bottom: 100rpx !important;
  599. }
  600. .item-box {
  601. width: 100%;
  602. background-color: #ffffff;
  603. // position: relative;
  604. // top: 150rpx;
  605. padding: 15rpx 25rpx;
  606. padding-bottom: 0;
  607. margin-top: 30rpx;
  608. .item-list {
  609. width: 100%;
  610. padding: 10rpx 0rpx;
  611. .list-icon {
  612. image {
  613. width: 77rpx;
  614. height: 77rpx;
  615. margin-right: 35rpx;
  616. }
  617. .text {
  618. color: #323232;
  619. font-size: 28rpx;
  620. font-weight: bold;
  621. }
  622. }
  623. }
  624. .fen {
  625. width: 100%;
  626. height: 2rpx;
  627. background-color: #ececec;
  628. margin: 10rpx 0rpx;
  629. }
  630. }
  631. .icon-box {
  632. margin-bottom: 32rpx;
  633. }
  634. .left-icon {
  635. width: 12rpx;
  636. height: 42rpx;
  637. background: $base-color;
  638. border-radius: 6rpx;
  639. }
  640. .left-box {
  641. width: 100%;
  642. }
  643. .left-tit {
  644. font-size: 30rpx;
  645. font-weight: bold;
  646. color: rgba(51, 51, 51, 1);
  647. line-height: 42rpx;
  648. margin-left: 14rpx;
  649. }
  650. .more {
  651. font-size: 24rpx;
  652. color: #666666;
  653. }
  654. .left-txt {
  655. font-size: 28rpx;
  656. font-weight: 500;
  657. color: rgba(102, 102, 102, 1);
  658. line-height: 52rpx;
  659. }
  660. .ask-list {
  661. margin-bottom: 25rpx;
  662. .ask-img {
  663. width: 92rpx;
  664. height: 92rpx;
  665. border-radius: 50%;
  666. }
  667. .ask-txt {
  668. font-size: 28rpx;
  669. font-weight: 500;
  670. width: 80%;
  671. padding-left: 15rpx;
  672. color: rgba(102, 102, 102, 1);
  673. line-height: 48rpx;
  674. }
  675. }
  676. /*公用边框样式*/
  677. %icon {
  678. margin-right: 10rpx;
  679. display: inline-block;
  680. padding: 2rpx 10rpx;
  681. border: 1rpx solid $color-yellow;
  682. color: $color-yellow;
  683. line-height: 1;
  684. font-size: $font-base;
  685. border-radius: 10rpx;
  686. }
  687. </style>