index.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import { connect } from 'herculex';
  2. import { setPagesQuery } from "../../../../core/utils";
  3. import getQueryString from '../../utils/getQueryParams';
  4. import { queryCertDetail, queryServiceByCode } from '../../services';
  5. const app = getApp();
  6. Component(connect({
  7. mapStateToProps: {
  8. linkQuery: ({
  9. $global,
  10. activeIndex
  11. }) => {
  12. const tabBar = $global.tabbar || [];
  13. const {
  14. linkQuery
  15. } = tabBar[activeIndex] || {};
  16. return linkQuery;
  17. }
  18. }
  19. })({
  20. data: {
  21. rows: [],
  22. cardIcon: '',
  23. certPhotoUrl: '',
  24. serviceInfo: {},
  25. details: {},
  26. loading: true,
  27. imgSrcPrefix: app.globalData.imgSrcPrefix
  28. },
  29. props: {
  30. componentData: {}
  31. },
  32. async didMount() {
  33. const {
  34. linkQuery
  35. } = this.data;
  36. /*
  37. * 获取服务里面的参数
  38. * */
  39. const _certType = getQueryString(linkQuery, 'certType');
  40. const _serviceCode = getQueryString(linkQuery, 'serviceCode');
  41. /*
  42. * url地址里面的参数
  43. * */
  44. const {
  45. certType = _certType,
  46. serviceCode = _serviceCode
  47. } = this.$page.options;
  48. setPagesQuery({
  49. certType,
  50. serviceCode
  51. });
  52. await this.fetchServiceInfo(serviceCode);
  53. await this.fetchCertDetail(certType);
  54. await this.updateData({
  55. loading: false
  56. });
  57. },
  58. methods: {
  59. updateData(data) {
  60. return new Promise(resolve => this.setData(data, resolve));
  61. },
  62. getValue(value) {
  63. return value || '--';
  64. },
  65. /*
  66. * 获取服务详情
  67. * */
  68. async fetchServiceInfo(serviceCode) {
  69. const [err, serviceInfo] = await queryServiceByCode(serviceCode);
  70. if (!err) await this.updateData({
  71. serviceInfo
  72. });
  73. },
  74. /*
  75. * 获取证件详情
  76. * */
  77. async fetchCertDetail(certType) {
  78. const [err, details] = await queryCertDetail(certType);
  79. if (err) return;
  80. const {
  81. grantOrg,
  82. userNameDe,
  83. userCertNoDe,
  84. identityType
  85. } = details;
  86. const rows = [{
  87. name: '姓名:',
  88. value: this.getValue(userNameDe)
  89. }, {
  90. name: '证件号:',
  91. value: this.getValue(userCertNoDe)
  92. }, {
  93. name: '类型:',
  94. value: this.getValue(identityType)
  95. }, {
  96. name: '颁发单位:',
  97. value: this.getValue(grantOrg)
  98. }];
  99. await this.updateData({
  100. rows,
  101. details
  102. });
  103. }
  104. }
  105. }));