Index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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="customername" />
  9. <Cell title="手机号码" :value="mobile2" />
  10. <Cell title="证件号码" :value="decryptAES(cardnum)" />
  11. <Cell title="签署机构" :value="memberUserId" />
  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 { shallowRef } from 'vue'
  24. import { CellGroup, Cell, showFailToast, showToast } from 'vant'
  25. import { fullloading } from '@/utils/vant';
  26. import { useNavigation } from '@mobile/router/navigation'
  27. import { useRequest } from '@/hooks/request'
  28. import { queryTencentUsereSignRecords, requestInitTencentESS } from '@/services/api/account';
  29. import { useRequestCreateFlowByTemplateDirectly } from '@/business/user/account';
  30. import plus from '@/utils/h5plus'
  31. import { getFileUrl } from '@/filters';
  32. import { getUserId } from '@/services/methods/user'
  33. import { useUserStore } from '@/stores'
  34. import { decryptAES } from '@/services/websocket/package/crypto'
  35. const { getQueryStringToNumber } = useNavigation()
  36. /// 所属机构
  37. const memberUserId = getQueryStringToNumber('memberUserId')
  38. /// userStore
  39. const userStore = useUserStore()
  40. /// 创建电子签合同
  41. const { createTemplate, templateFormData } = useRequestCreateFlowByTemplateDirectly()
  42. /// 电子签合同信息
  43. const dataList = shallowRef<Model.TencentUsereSignRecordsRsq[]>([])
  44. /// 用户信息
  45. const { customername, cardnum, mobile2 } = userStore.userInfo
  46. /// 查询
  47. const { run } = useRequest(queryTencentUsereSignRecords, {
  48. params: {
  49. userId: getUserId(),
  50. memberUserId: memberUserId
  51. },
  52. onSuccess: (res) => {
  53. if (res.data.length != 0) {
  54. dataList.value = res.data
  55. } else {
  56. /// 创建电子签合同
  57. initTencentESS()
  58. }
  59. }
  60. })
  61. /// 创建电子签合同
  62. const { run: initTencentESS } = useRequest(requestInitTencentESS, {
  63. manual: true,
  64. params: {
  65. userId: getUserId(),
  66. memberUserId: memberUserId
  67. },
  68. onSuccess: () => {
  69. /// 重新请求
  70. run()
  71. }
  72. })
  73. const iconName = (type: number) => {
  74. switch (type) {
  75. case 2: return 'info-o'
  76. case 4: return 'close'
  77. case 3: return 'passed'
  78. default: return 'circle'
  79. }
  80. }
  81. const openWebview = (url: string) => {
  82. const ua = window.navigator.userAgent.toLowerCase()
  83. if (ua.indexOf('micromessenger') !== -1) {
  84. showToast({
  85. type: 'fail',
  86. message: '请使用浏览器打开此页面'
  87. })
  88. } else {
  89. plus.openWebview({
  90. url,
  91. titleText: '实名认证',
  92. onClose: () => run()
  93. })
  94. }
  95. }
  96. const signer = (item: Model.TencentUsereSignRecordsRsq) => {
  97. /// 如果是已签署
  98. if (item.recordstatus === 2) {
  99. item.signurl ? openWebview(item.signurl) : showFailToast('合同地址错误')
  100. } else if (item.recordstatus === 3) {
  101. const fileUrl = getFileUrl(item.contractfileaddr)
  102. item.contractfileaddr ? plus.openURL(fileUrl) : showFailToast('合同地址错误')
  103. } else {
  104. fullloading((hideLoading) => {
  105. const userinfotype = useUserStore().userInfo.userinfotype
  106. templateFormData.userESignRecordID = item.recordid
  107. templateFormData.userType = userinfotype
  108. /// 个人信息
  109. if (userinfotype === 1) {
  110. templateFormData.personInfo = {
  111. idCardNumber: decryptAES(cardnum),
  112. mobile: mobile2,
  113. name: customername
  114. }
  115. } else {
  116. templateFormData.organizationInfo = {
  117. name: customername
  118. }
  119. }
  120. /// 创建合同
  121. createTemplate().then((res) => {
  122. hideLoading()
  123. openWebview(res.data.signUrl)
  124. }).catch((err) => {
  125. hideLoading(err, 'fail')
  126. })
  127. })
  128. }
  129. }
  130. </script>