sign-stream/src/views/upload-id-card/index.vue

206 lines
5.2 KiB
Vue
Raw Normal View History

2024-01-31 08:18:27 +00:00
<script setup>
2024-02-05 05:10:46 +00:00
import steps from '@/components/steps/index.vue'
2024-02-05 08:27:29 +00:00
import one from './content/one.vue'
import { useRoute, useRouter } from 'vue-router'
import two from './content/two.vue'
import three from './content/three.vue'
2024-02-05 11:54:48 +00:00
import complete from './content/complete.vue'
2024-09-10 06:52:30 +00:00
import { computed, ref, watch } from "vue";
import { storeToRefs } from "pinia";
import { useUserStore } from "@/stores/userStore.js";
import { showToast } from "vant";
import { check_id_card, save_register_info } from "@/apis/index.js";
2024-02-19 09:00:40 +00:00
const userStore = useUserStore()
2024-09-10 06:52:30 +00:00
const { idCardInfo, iDCardImage, recentPhoto, artworkFile, telNum, selectAddress, detailAddress, submitReturnData } = storeToRefs(userStore);
2024-02-05 08:27:29 +00:00
const route = useRoute()
const router = useRouter()
const active = ref(Number(route.params.active))
2024-09-10 06:52:30 +00:00
const buttons = ref([{ label: "下一步", type: "next" }])
2024-02-05 08:27:29 +00:00
const contentComputed = computed(() => {
switch (active.value) {
case 0:
return one
case 1:
return two
case 2:
2024-09-10 06:52:30 +00:00
return three
2024-02-05 11:54:48 +00:00
case 3:
2024-09-10 06:52:30 +00:00
return complete
2024-02-05 08:27:29 +00:00
}
})
2024-09-10 06:52:30 +00:00
const submitClick = async () => {
const data = {
artistName: idCardInfo.value.realName,
gender: idCardInfo.value.sex === '男' ? 1 : 2,
phoneNum: telNum.value,
idCard: idCardInfo.value.iDNum,
2024-09-10 10:59:35 +00:00
address: JSON.stringify(selectAddress.value.selectedOptions.map(item => {
return {
text: item.text,
value: item.value
}
})),
2024-09-10 06:52:30 +00:00
address1: detailAddress.value,
idCardPhoto: iDCardImage.value.front,
idCardBackPhoto: iDCardImage.value.back,
artistPhoto: recentPhoto.value,
artworkFile: artworkFile.value
2024-02-20 09:00:39 +00:00
}
2024-09-10 06:52:30 +00:00
const res = await save_register_info(data)
if (res.status === 0) {
submitReturnData.value = res.data.data
2024-02-20 09:00:39 +00:00
}
}
2024-09-10 06:52:30 +00:00
watch(active, () => {
switch (active.value) {
2024-02-20 09:00:39 +00:00
case 0:
2024-09-10 06:52:30 +00:00
buttons.value = [{ label: "下一步", type: "next" }]
break
2024-02-20 09:00:39 +00:00
case 1:
2024-09-10 06:52:30 +00:00
buttons.value = [{ label: "上一步", type: "back" }, { label: "下一步", type: "next" }];
2024-02-20 09:00:39 +00:00
break
case 2:
2024-09-10 06:52:30 +00:00
buttons.value = [{ label: "上一步", type: "back" }, { label: "提交", type: "submit" }]
2024-02-20 09:00:39 +00:00
break
2024-02-21 03:30:59 +00:00
case 3:
2024-09-10 06:52:30 +00:00
buttons.value = [{ label: "完成", type: "finish" }]
2024-02-21 03:30:59 +00:00
break
2024-02-20 09:00:39 +00:00
}
2024-09-10 06:52:30 +00:00
}, {
immediate: true
2024-02-20 09:00:39 +00:00
})
2024-09-10 06:52:30 +00:00
const stepsClick = async (item) => {
2024-02-05 08:27:29 +00:00
switch (active.value) {
case 0:
2024-09-10 06:52:30 +00:00
if (!iDCardImage.value.front || !iDCardImage.value.back) {
2024-02-19 09:00:40 +00:00
showToast({
2024-09-10 06:52:30 +00:00
message: '请上传完整的身份证图片',
className: 'particulars-detail-popup'
2024-02-19 09:00:40 +00:00
});
2024-02-23 07:40:28 +00:00
return
}
2024-09-10 06:52:30 +00:00
const res = await check_id_card({
idCard: idCardInfo.value.iDNum
2024-02-23 07:40:28 +00:00
})
2024-09-10 06:52:30 +00:00
if (res.status === 0) {
} else {
2024-02-19 09:00:40 +00:00
return
}
2024-09-10 06:52:30 +00:00
active.value = 1
2024-02-05 08:27:29 +00:00
router.replace(`/title-forward/upload-id-card/${1}`)
break
case 1:
if (item.type === 'next') {
2024-09-10 06:52:30 +00:00
if (!recentPhoto.value) {
2024-02-20 09:00:39 +00:00
showToast({
2024-09-10 06:52:30 +00:00
message: '请上传近照',
className: 'particulars-detail-popup'
2024-02-20 09:00:39 +00:00
});
return;
}
2024-09-10 06:52:30 +00:00
if (selectAddress.value?.selectedOptions?.length < 3 || !selectAddress.value?.selectedOptions) {
showToast({
message: '请选择通讯地址',
className: 'particulars-detail-popup'
});
return
}
if (!detailAddress.value) {
showToast({
message: '请输入详细地址',
className: 'particulars-detail-popup'
});
return
}
active.value = 2
2024-02-05 08:27:29 +00:00
router.replace(`/title-forward/upload-id-card/${2}`)
} else if (item.type === 'back') {
2024-09-10 06:52:30 +00:00
active.value = 0
2024-02-05 08:27:29 +00:00
router.replace(`/title-forward/upload-id-card/${0}`)
}
break
case 2:
2024-02-21 03:30:59 +00:00
2024-09-10 06:52:30 +00:00
if (item.type === 'submit') {
if (!artworkFile.value) {
2024-02-21 03:30:59 +00:00
showToast({
2024-09-10 06:52:30 +00:00
message: '请上传作品',
className: 'particulars-detail-popup'
2024-02-21 03:30:59 +00:00
});
2024-09-10 06:52:30 +00:00
return;
2024-02-21 03:30:59 +00:00
}
2024-02-20 09:00:39 +00:00
submitClick()
2024-09-10 06:52:30 +00:00
active.value = 3
2024-02-05 11:54:48 +00:00
router.replace(`/title-forward/upload-id-card/${3}`)
2024-09-10 06:52:30 +00:00
} else if (item.type === 'back') {
active.value = 1
router.replace(`/title-forward/upload-id-card/${1}`)
2024-02-21 03:30:59 +00:00
}
break
case 3:
if (item.type === 'finish') {
router.push('/title-forward/reg-details')
2024-02-05 08:27:29 +00:00
}
break
}
}
2024-01-31 08:18:27 +00:00
</script>
<template>
2024-02-05 05:10:46 +00:00
<div class="container">
2024-09-10 06:52:30 +00:00
<steps v-model:active="active" />
2024-02-05 08:27:29 +00:00
<div class="content">
2024-09-10 06:52:30 +00:00
<component :is="contentComputed" />
2024-02-05 08:27:29 +00:00
</div>
2024-02-05 05:10:46 +00:00
<div class="bottom-btn">
2024-09-10 06:52:30 +00:00
<div class="item"
@click="stepsClick(item)"
v-for="item in buttons"
2024-02-05 08:27:29 +00:00
:class="[item.type==='back'?'back':'']">
2024-02-05 05:10:46 +00:00
{{ item.label }}
</div>
</div>
</div>
2024-01-31 08:18:27 +00:00
</template>
<style scoped lang="scss">
2024-02-05 05:10:46 +00:00
.container {
box-sizing: border-box;
padding-top: 14px;
padding-right: 21px;
padding-left: 21px;
2024-02-05 08:27:29 +00:00
.content {
margin-top: 20px;
}
.bottom-btn {
2024-02-19 09:00:40 +00:00
margin-top: 18px;
margin-bottom: 38px;
2024-02-05 08:27:29 +00:00
width: 100%;
2024-02-05 05:10:46 +00:00
display: flex;
justify-content: center;
2024-01-31 08:18:27 +00:00
2024-02-05 08:27:29 +00:00
.item {
display: flex;
justify-content: center;
align-items: center;
color: #fff;
font-size: 16px;
border-radius: 20px;
width: 142px;
height: 32px;
2024-09-10 06:52:30 +00:00
background-color: #2159c4;
2024-02-05 08:27:29 +00:00
&.back {
2024-09-10 06:52:30 +00:00
background-color: #24437e;
2024-02-05 08:27:29 +00:00
margin-right: 30px;
}
}
}
2024-02-05 05:10:46 +00:00
}
2024-01-31 08:18:27 +00:00
</style>