Hetong.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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="info.id">
  9. <view class="pdf-box"> pdf展示 </view>
  10. <!-- -->
  11. <!-- <web-view class="dljt-pdf-view" :src="pdfUrl1" v-if="show"
  12. webview-styles="height: 50vh;margin-top: 75px"></web-view> -->
  13. </template>
  14. <template v-else>
  15. <view class="no-hetong-box">暂无合同</view>
  16. </template>
  17. <button v-if="info.id && info.status == 0" type="default" class="phone-green-btn ht-btn"
  18. @click="handleQianming">我已阅读</button>
  19. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  20. <view class="ht-qm-popup">
  21. <view class="icon-title-navBar-box">
  22. <view @click="goback2" class="nav-bar-icon"></view>
  23. <text class="nav-bar-title">签名</text>
  24. </view>
  25. <writeSign @getBase64="getBase64"></writeSign>
  26. </view>
  27. </uni-popup>
  28. </view>
  29. </template>
  30. <script setup>
  31. import {
  32. ref
  33. } from "vue";
  34. import * as httpApi from "@/api/hetong.js"
  35. import {
  36. onLoad
  37. } from "@dcloudio/uni-app"
  38. import writeSign from "@/components/writeSign/index.vue"
  39. import {throttleAdvanced} from "@/utils/common.js"
  40. const pdfUrl1 = ref('');
  41. const info = ref({})
  42. const show = ref(false)
  43. const popupRef = ref(null)
  44. function goUpPage() {
  45. uni.navigateBack()
  46. }
  47. onLoad(() => {
  48. init()
  49. })
  50. function init() {
  51. httpApi.getHetongLast().then(res => {
  52. info.value = res.data;
  53. pdfUrl1.value = `/hybrid/html/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`;
  54. // let pdfUrl2 = `https://mozilla.github.io/pdf.js/web/viewer.html?file=${encodeURIComponent(res.data.pdfUrl)}`
  55. console.log('info', info.value)
  56. setTimeout(() => {
  57. console.log('xianshi')
  58. show.value = true;
  59. }, 3000)
  60. })
  61. }
  62. function handleGoLishi() {
  63. uni.redirectTo({
  64. url: '/pages/admin/Hetong/HetongList'
  65. })
  66. }
  67. function handleQianming() {
  68. popupRef.value.open()
  69. }
  70. const handleQM = throttleAdvanced((img) => {
  71. uni.showToast({
  72. title: "签名提交中...",
  73. mask: true,
  74. })
  75. httpApi.getHetongQianming({
  76. id: info.value.id,
  77. fuzeren: img.replace(/^data:image\/\w+;base64,/, '')
  78. }).then(res => {
  79. if (res.data) {
  80. uni.showToast({
  81. title: "签名成功",
  82. duration: 2000,
  83. mask: true,
  84. success() {
  85. setTimeout(() => uni.navigateBack(),2000)
  86. }
  87. })
  88. }
  89. })
  90. })
  91. function getBase64(img) {
  92. if (!img) {
  93. uni.showToast({
  94. title: '签名异常'
  95. })
  96. return;
  97. }
  98. handleQM(img)
  99. }
  100. function goback2() {
  101. popupRef.value.close()
  102. }
  103. </script>
  104. <style>
  105. </style>