Index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <app-view class="g-form">
  3. <template #header>
  4. <app-navbar title="合同签署" />
  5. </template>
  6. <div class="g-form__container">
  7. <CellGroup inset>
  8. <Cell title="姓名" :value="userInfo.customername" />
  9. <Cell title="手机号码" :value="userInfo.mobile2" />
  10. <Cell title="证件号码" :value="userInfo.cardnum" />
  11. <Cell title="签署机构" :value="signId" />
  12. </CellGroup>
  13. <CellGroup inset>
  14. <template v-for="(item, index) in dataList" :key="index">
  15. <Cell :title="item.templatename" :icon="iconName(item.recordstatus)" @click="signer(item)"
  16. is-link />
  17. </template>
  18. </CellGroup>
  19. </div>
  20. </app-view>
  21. </template>
  22. <script lang="ts" setup>
  23. import { CellGroup, Cell, showFailToast, showToast } from 'vant'
  24. import { fullloading } from '@/utils/vant'
  25. import { useNavigation } from '@mobile/router/navigation'
  26. import { requestInitTencentESS } from '@/services/api/account'
  27. import { useRequestCreateFlowByTemplateDirectly } from '@/business/user/account'
  28. import plus from '@/utils/h5plus'
  29. const { getQueryStringToNumber } = useNavigation()
  30. /// 所属机构
  31. const qs = getQueryStringToNumber('memberUserId')
  32. /// 创建电子签合同
  33. const { getTencentUsereSignRecords, createTemplate, userInfo, signId, dataList } = useRequestCreateFlowByTemplateDirectly(qs)
  34. const iconName = (type: number) => {
  35. switch (type) {
  36. case 2: return 'info-o'
  37. case 4: return 'close'
  38. case 3: return 'passed'
  39. default: return 'circle'
  40. }
  41. }
  42. const openWebview = (url: string) => {
  43. const ua = window.navigator.userAgent.toLowerCase()
  44. if (ua.indexOf('micromessenger') !== -1) {
  45. showToast({
  46. type: 'fail',
  47. message: '请使用浏览器打开此页面'
  48. })
  49. } else {
  50. plus.openWebview({
  51. url,
  52. titleText: '实名认证',
  53. onClose: () => getTencentUsereSignRecords()
  54. })
  55. }
  56. }
  57. const signer = (item: Model.TencentUsereSignRecordsRsq) => {
  58. /// 如果是已签署
  59. if (item.recordstatus === 2) {
  60. item.signurl ? openWebview(item.signurl) : showFailToast('合同地址错误')
  61. } else if (item.recordstatus === 3) {
  62. showFailToast('合同已签署,请前往腾讯电子签小程序查看!')
  63. } else {
  64. fullloading((hideLoading) => {
  65. /// 创建合同
  66. createTemplate(item.recordid).then((res) => {
  67. hideLoading()
  68. openWebview(res.data.signUrl)
  69. }).catch((err) => {
  70. hideLoading(err, 'fail')
  71. })
  72. })
  73. }
  74. }
  75. getTencentUsereSignRecords().then(() => {
  76. if (!dataList.value.length) {
  77. // 创建电子签合同
  78. requestInitTencentESS({
  79. data: {
  80. memberUserId: signId
  81. }
  82. }).then(() => {
  83. getTencentUsereSignRecords()
  84. })
  85. }
  86. })
  87. </script>