Index.vue 3.3 KB

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