index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { connect } from 'herculex';
  2. import { getIn } from 'herculex/dist/utils/manipulate';
  3. import { createSubscribe } from 'applet-page-component';
  4. import { myCard } from '../utils/service';
  5. import { history, replaceStar } from '../utils/index';
  6. Component(connect({
  7. mapStateToProps: {
  8. isLogin: state => state.$global.userInfo.isLogin,
  9. bookingInfo: state => getIn(state, ['$global', 'bookingInfo'], {})
  10. }
  11. })(createSubscribe({
  12. onShow() {
  13. this.getMyCard();
  14. }
  15. })({
  16. data: {
  17. hasCard: false,
  18. // 是否有就诊卡绑定,如果绑定则展示就诊卡,如果没有绑定则展示,新增或者绑定就诊卡按钮
  19. myCardInfo: {}
  20. },
  21. props: {
  22. componentData: {}
  23. },
  24. didMount() {
  25. // 我的证件
  26. this.getMyCard();
  27. },
  28. methods: {
  29. async getMyCard() {
  30. const [, res] = await myCard();
  31. if (res) {
  32. res.viewCardNum = replaceStar(res.cardNum, 3, 4);
  33. this.setData({
  34. myCardInfo: res,
  35. hasCard: true
  36. });
  37. } else {
  38. this.setData({
  39. hasCard: false
  40. });
  41. }
  42. },
  43. toDetail() {
  44. const [item] = this.props.componentData.serviceList;
  45. const [, pageUuid] = item.url.split(':');
  46. const {
  47. myCardInfo
  48. } = this.data;
  49. history.openPage({
  50. pageType: 'card-detail',
  51. data: {
  52. cardNum: myCardInfo.cardNum,
  53. type: 0,
  54. pageUuid
  55. }
  56. });
  57. }
  58. }
  59. })));