Index.vue 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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="decryptAES(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 { decryptAES } from '@/services/websocket/package/crypto'
  29. import plus from '@/utils/h5plus'
  30. const { getQueryStringToNumber } = useNavigation()
  31. /// 所属机构
  32. const qs = getQueryStringToNumber('memberUserId')
  33. /// 创建电子签合同
  34. const { getTencentUsereSignRecords, createTemplate, userInfo, signId, dataList } = useRequestCreateFlowByTemplateDirectly(qs)
  35. const iconName = (type: number) => {
  36. switch (type) {
  37. case 2: return 'info-o'
  38. case 4: return 'close'
  39. case 3: return 'passed'
  40. default: return 'circle'
  41. }
  42. }
  43. const openWebview = (url: string) => {
  44. const ua = window.navigator.userAgent.toLowerCase()
  45. if (ua.indexOf('micromessenger') !== -1) {
  46. showToast({
  47. type: 'fail',
  48. message: '请使用浏览器打开此页面'
  49. })
  50. } else {
  51. plus.openWebview({
  52. url,
  53. titleText: '实名认证',
  54. onClose: () => getTencentUsereSignRecords()
  55. })
  56. }
  57. }
  58. const signer = (item: Model.TencentUsereSignRecordsRsq) => {
  59. /// 如果是已签署
  60. if (item.recordstatus === 2) {
  61. item.signurl ? openWebview(item.signurl) : showFailToast('合同地址错误')
  62. } else if (item.recordstatus === 3) {
  63. showFailToast('合同已签署,请前往腾讯电子签小程序查看!')
  64. } else {
  65. fullloading((hideLoading) => {
  66. /// 创建合同
  67. createTemplate(item.recordid).then((res) => {
  68. hideLoading()
  69. openWebview(res.data.signUrl)
  70. }).catch((err) => {
  71. hideLoading(err, 'fail')
  72. })
  73. })
  74. }
  75. }
  76. getTencentUsereSignRecords().then(() => {
  77. if (!dataList.value.length) {
  78. // 创建电子签合同
  79. requestInitTencentESS({
  80. data: {
  81. memberUserId: signId
  82. }
  83. }).then(() => {
  84. getTencentUsereSignRecords()
  85. })
  86. }
  87. })
  88. </script>