|
@@ -7,21 +7,70 @@ import { ref } from 'vue'
|
|
|
|
|
|
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
import { onLoad } from '@dcloudio/uni-app'
|
|
|
|
|
|
|
|
|
|
+import { signAgreementApi } from '@/services/modules/common'
|
|
|
|
|
+import { fileApi } from '@/services/modules/file'
|
|
|
|
|
+
|
|
|
|
|
+import { useUserStore } from '@/stores/modules/user'
|
|
|
|
|
+
|
|
|
import SignaturePad from './components/SignaturePad.vue'
|
|
import SignaturePad from './components/SignaturePad.vue'
|
|
|
|
|
|
|
|
const type = ref('')
|
|
const type = ref('')
|
|
|
onLoad((e) => {
|
|
onLoad((e) => {
|
|
|
- type.value = e.type || ''
|
|
|
|
|
|
|
+ type.value = e?.type || ''
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+const userStore = useUserStore()
|
|
|
const handleSignatureDone = (filePath: string) => {
|
|
const handleSignatureDone = (filePath: string) => {
|
|
|
- console.log('Signature done, file path:', filePath)
|
|
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '保存中',
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- saveSignature(filePath)
|
|
|
|
|
|
|
+ uni.uploadFile({
|
|
|
|
|
+ url: fileApi.fileUpload(),
|
|
|
|
|
+ filePath: filePath,
|
|
|
|
|
+ name: 'file',
|
|
|
|
|
+ header: {
|
|
|
|
|
+ Authorization: `Bearer ${userStore.access_token}`,
|
|
|
|
|
+ },
|
|
|
|
|
+ success(res) {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ if (res.statusCode === 200 && res.data) {
|
|
|
|
|
+ const uploadRes = JSON.parse(res.data)
|
|
|
|
|
+ if (uploadRes.code === 0) {
|
|
|
|
|
+ if (type.value === 'HONEST_AGREEMENT_V2') {
|
|
|
|
|
+ saveSignature(uploadRes.data.url)
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: uploadRes.msg || '上传失败',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 1500,
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail() {
|
|
|
|
|
+ uni.hideLoading()
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: '上传失败',
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ duration: 1500,
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-const saveSignature = (filePath: string) => {
|
|
|
|
|
- console.log('filePath', filePath)
|
|
|
|
|
|
|
+// 签署协议
|
|
|
|
|
+const saveSignature = async (url: string) => {
|
|
|
|
|
+ const res = await signAgreementApi({
|
|
|
|
|
+ agreementType: type.value,
|
|
|
|
|
+ signatureUrl: url,
|
|
|
|
|
+ })
|
|
|
|
|
+ if (res.code === 0 && res.data) {
|
|
|
|
|
+ uni.showTabBar()
|
|
|
|
|
+ uni.navigateBack()
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const handleClear = () => {
|
|
const handleClear = () => {
|