Hetong.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <view class="phone-hetong-page">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">合同</text>
  6. <uni-icons class="nav-bar-right-icon bar-ml10" type="list" @click="handleGoLishi" size="30"></uni-icons>
  7. </view>
  8. <template v-if="tId">
  9. <view class="pdf-box">
  10. <image v-for="item in imgList" :mode="item.mode" :src="`data:image/png;base64,${item}`"></image>
  11. </view>
  12. </template>
  13. <template v-else>
  14. <view class="no-hetong-box">暂无合同</view>
  15. </template>
  16. <view class="hetong-tip-box" v-if="tId && info.status == 0">
  17. 请务必仔细阅读上述内容,确认已完全理解所有条款后,点击【我已阅读】按钮完成签字确认。
  18. </view>
  19. <button v-if="tId && info.status == 0" type="default" class="phone-green-btn ht-btn"
  20. @click="handleQianming">我已阅读</button>
  21. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  22. <view class="ht-qm-popup">
  23. <view class="icon-title-navBar-box">
  24. <view @click="goback2" class="nav-bar-icon"></view>
  25. <text class="nav-bar-title">签名</text>
  26. </view>
  27. <writeSign @getBase64="getBase64"></writeSign>
  28. </view>
  29. </uni-popup>
  30. </view>
  31. </template>
  32. <script setup>
  33. import {
  34. ref
  35. } from "vue";
  36. import * as httpApi from "@/api/hetong.js"
  37. import {
  38. onLoad
  39. } from "@dcloudio/uni-app"
  40. import writeSign from "@/components/writeSign/index.vue"
  41. import {throttleAdvanced} from "@/utils/common.js"
  42. const tId = ref(null)
  43. const info = ref({})
  44. const show = ref(false)
  45. const popupRef = ref(null)
  46. const imgList = ref([])
  47. function goUpPage() {
  48. uni.navigateBack()
  49. }
  50. onLoad(({id}) => {
  51. tId.value = id;
  52. init()
  53. })
  54. function init() {
  55. if (!tId.value) {
  56. uni.showToast({
  57. title: '数据异常,请确认路径是否完整'
  58. })
  59. return;
  60. }
  61. httpApi.getHetongInfo({id:tId.value}).then(res => {
  62. info.value = res.data;
  63. imgList.value = res.data.base64List;
  64. setTimeout(() => {
  65. console.log('xianshi')
  66. show.value = true;
  67. }, 3000)
  68. })
  69. }
  70. function handleGoLishi() {
  71. uni.redirectTo({
  72. url: '/pages/admin/Hetong/HetongList'
  73. })
  74. }
  75. function handleQianming() {
  76. popupRef.value.open()
  77. }
  78. const handleQM = throttleAdvanced((img) => {
  79. uni.showToast({
  80. title: "签名提交中...",
  81. mask: true,
  82. })
  83. httpApi.getHetongQianming({
  84. id: info.value.id,
  85. yifangBase64: img.replace(/^data:image\/\w+;base64,/, ''), // 当前接口,只有唯一yifangBase64 + id
  86. }).then(res => {
  87. if (res.data) {
  88. uni.showToast({
  89. title: "签名成功",
  90. duration: 2000,
  91. mask: true,
  92. success() {
  93. setTimeout(() => uni.navigateBack(),2000)
  94. }
  95. })
  96. }
  97. })
  98. })
  99. function getBase64(img) {
  100. if (!img) {
  101. uni.showToast({
  102. title: '签名异常'
  103. })
  104. return;
  105. }
  106. handleQM(img)
  107. }
  108. function goback2() {
  109. popupRef.value.close()
  110. }
  111. </script>
  112. <style>
  113. </style>