|
@@ -15,7 +15,7 @@
|
|
|
<view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
<view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
|
</view>
|
|
</view>
|
|
|
<view class="rules-text text-sm text-gray-600 space-y-1">
|
|
<view class="rules-text text-sm text-gray-600 space-y-1">
|
|
|
- <view>1. 优惠券发放后,有效期为1个月,过期作废;</view>
|
|
|
|
|
|
|
+ <view>1. 优惠券审核后,有效期为30天,过期作废;</view>
|
|
|
<view>2. 个人购买者:享受消费优惠券同类型农机不超过2台;</view>
|
|
<view>2. 个人购买者:享受消费优惠券同类型农机不超过2台;</view>
|
|
|
<view>3. 组织购买者:享受消费优惠券同类型农机不超过10台。</view>
|
|
<view>3. 组织购买者:享受消费优惠券同类型农机不超过10台。</view>
|
|
|
</view>
|
|
</view>
|
|
@@ -129,37 +129,6 @@
|
|
|
]"
|
|
]"
|
|
|
@blur="validatePhone"
|
|
@blur="validatePhone"
|
|
|
/>
|
|
/>
|
|
|
-
|
|
|
|
|
- <!-- 验证码 -->
|
|
|
|
|
- <wd-cell
|
|
|
|
|
- title="验证码"
|
|
|
|
|
- title-width="100px"
|
|
|
|
|
- prop="smsCode"
|
|
|
|
|
- required
|
|
|
|
|
- custom-class="custom-cell"
|
|
|
|
|
- vertical-align="center"
|
|
|
|
|
- >
|
|
|
|
|
- <view class="flex items-center flex-1">
|
|
|
|
|
- <wd-input
|
|
|
|
|
- v-model="formData.smsCode"
|
|
|
|
|
- placeholder="请输入验证码"
|
|
|
|
|
- clearable
|
|
|
|
|
- no-border
|
|
|
|
|
- custom-style="flex:1;"
|
|
|
|
|
- :rules="[{ required: true, message: '请输入验证码' }]"
|
|
|
|
|
- />
|
|
|
|
|
- <wd-button
|
|
|
|
|
- size="small"
|
|
|
|
|
- type="primary"
|
|
|
|
|
- plain
|
|
|
|
|
- @click="getSmsCode"
|
|
|
|
|
- :disabled="smsCodeDisabled || !isPhoneValid"
|
|
|
|
|
- custom-style="margin-left: 10px;"
|
|
|
|
|
- >
|
|
|
|
|
- {{ smsCodeButtonText }}
|
|
|
|
|
- </wd-button>
|
|
|
|
|
- </view>
|
|
|
|
|
- </wd-cell>
|
|
|
|
|
</wd-cell-group>
|
|
</wd-cell-group>
|
|
|
</wd-form>
|
|
</wd-form>
|
|
|
</view>
|
|
</view>
|
|
@@ -190,8 +159,9 @@ import UploadComponent from '@/components/UploadComponent.vue'
|
|
|
const couponStore = useCouponStore()
|
|
const couponStore = useCouponStore()
|
|
|
const message = useMessage()
|
|
const message = useMessage()
|
|
|
|
|
|
|
|
-const productsid = ref('')
|
|
|
|
|
-const couponid = ref('')
|
|
|
|
|
|
|
+const productsid = ref('') // 产品id
|
|
|
|
|
+const couponid = ref('') // 优惠券(主劵)id
|
|
|
|
|
+const usersid = ref('') // 用户id(销售点userid)
|
|
|
|
|
|
|
|
const formRef = ref<any>()
|
|
const formRef = ref<any>()
|
|
|
const formData = reactive({
|
|
const formData = reactive({
|
|
@@ -199,9 +169,6 @@ const formData = reactive({
|
|
|
usersname: '', // 姓名或企业名称
|
|
usersname: '', // 姓名或企业名称
|
|
|
idNumber: '', // 证件号
|
|
idNumber: '', // 证件号
|
|
|
|
|
|
|
|
- // 移除旧的idPhoto字段,替换为文件上传相关字段
|
|
|
|
|
- // idPhoto: '', // 证件照片
|
|
|
|
|
-
|
|
|
|
|
// 身份证照片(个人用户)
|
|
// 身份证照片(个人用户)
|
|
|
idCardFiles: [], // 身份证照片文件列表
|
|
idCardFiles: [], // 身份证照片文件列表
|
|
|
idCardIds: [], // 身份证照片ID列表
|
|
idCardIds: [], // 身份证照片ID列表
|
|
@@ -211,7 +178,6 @@ const formData = reactive({
|
|
|
businessLicenseIds: [], // 营业执照照片ID列表
|
|
businessLicenseIds: [], // 营业执照照片ID列表
|
|
|
|
|
|
|
|
phone: '', // 手机号
|
|
phone: '', // 手机号
|
|
|
- smsCode: '', // 短信验证码
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const usersnameLabel = computed(() => (formData.userstype === '个人' ? '姓名' : '企业名称'))
|
|
const usersnameLabel = computed(() => (formData.userstype === '个人' ? '姓名' : '企业名称'))
|
|
@@ -238,35 +204,6 @@ function validatePhone() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 短信验证码相关
|
|
|
|
|
-const smsCodeButtonText = ref('获取验证码')
|
|
|
|
|
-const smsCodeDisabled = ref(false)
|
|
|
|
|
-let countdownTimer: number | null = null
|
|
|
|
|
-
|
|
|
|
|
-async function getSmsCode() {
|
|
|
|
|
- validatePhone()
|
|
|
|
|
- if (!isPhoneValid.value) {
|
|
|
|
|
- uni.showToast({ title: '请输入正确的手机号码', icon: 'none' })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- uni.showToast({ title: '验证码已发送', icon: 'none' })
|
|
|
|
|
- smsCodeDisabled.value = true
|
|
|
|
|
- let countdown = 60
|
|
|
|
|
- smsCodeButtonText.value = `${countdown}s后重试`
|
|
|
|
|
-
|
|
|
|
|
- countdownTimer = setInterval(() => {
|
|
|
|
|
- countdown--
|
|
|
|
|
- if (countdown <= 0) {
|
|
|
|
|
- if (countdownTimer) clearInterval(countdownTimer)
|
|
|
|
|
- smsCodeButtonText.value = '获取验证码'
|
|
|
|
|
- smsCodeDisabled.value = false
|
|
|
|
|
- } else {
|
|
|
|
|
- smsCodeButtonText.value = `${countdown}s后重试`
|
|
|
|
|
- }
|
|
|
|
|
- }, 1000)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// 用户类型切换
|
|
// 用户类型切换
|
|
|
function handleUserTypeChange() {
|
|
function handleUserTypeChange() {
|
|
|
// 清空相关字段以便用户重新输入和校验
|
|
// 清空相关字段以便用户重新输入和校验
|
|
@@ -324,39 +261,44 @@ async function handleSubmit() {
|
|
|
? formData.idCardIds.map((item) => item.id).join(',')
|
|
? formData.idCardIds.map((item) => item.id).join(',')
|
|
|
: formData.businessLicenseIds.map((item) => item.id).join(',')
|
|
: formData.businessLicenseIds.map((item) => item.id).join(',')
|
|
|
|
|
|
|
|
- // 模拟API调用
|
|
|
|
|
- await new Promise((resolve) => setTimeout(resolve, 1500))
|
|
|
|
|
-
|
|
|
|
|
- // 调用领取优惠券API - 注意:这里的API参数需要根据您的实际接口调整
|
|
|
|
|
- // await couponStore.receiveCoupon({
|
|
|
|
|
- // couponid: couponid.value,
|
|
|
|
|
- // coupon2phone: formData.phone,
|
|
|
|
|
- // coupon2productids: productsid.value,
|
|
|
|
|
- // userstype: formData.userstype,
|
|
|
|
|
- // usersname: formData.usersname,
|
|
|
|
|
- // idNumber: formData.idNumber,
|
|
|
|
|
- // fileIds: fileIds, // 上传的文件ID字符串
|
|
|
|
|
- // smsCode: formData.smsCode,
|
|
|
|
|
- // // ... 其他可能需要的参数
|
|
|
|
|
- // })
|
|
|
|
|
|
|
+ // 调用领取优惠券API
|
|
|
|
|
+ const res = await couponStore.receiveCouponNew({
|
|
|
|
|
+ couponid: couponid.value,
|
|
|
|
|
+ userstype: formData.userstype,
|
|
|
|
|
+ usersshtyxydm: formData.userstype === '企业' ? formData.idNumber : '',
|
|
|
|
|
+ usersidcardnumber: formData.userstype === '个人' ? formData.idNumber : '',
|
|
|
|
|
+ usersname: formData.usersname,
|
|
|
|
|
+ coupon2productids: productsid.value,
|
|
|
|
|
+ coupon2phone: formData.phone,
|
|
|
|
|
+ filesid: fileIds, // 上传的文件ID字符串
|
|
|
|
|
+ coupon2merchantid: usersid.value,
|
|
|
|
|
+ // smsCode: formData.smsCode,
|
|
|
|
|
+ // ... 其他可能需要的参数
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // console.log('领取优惠券API成功', res) 领取优惠券API成功 2025052017584880465552
|
|
|
|
|
|
|
|
message
|
|
message
|
|
|
- .alert({
|
|
|
|
|
|
|
+ .confirm({
|
|
|
msg: '优惠券领取成功!',
|
|
msg: '优惠券领取成功!',
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- confirmButtonText: '确定',
|
|
|
|
|
|
|
+ confirmButtonText: '使用优惠劵下单',
|
|
|
|
|
+ cancelButtonText: '返回到产品页',
|
|
|
})
|
|
})
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
// 跳转回formStep3页面
|
|
// 跳转回formStep3页面
|
|
|
// 注意:需要确保formStep3页面能够正确处理返回逻辑,比如刷新优惠券列表
|
|
// 注意:需要确保formStep3页面能够正确处理返回逻辑,比如刷新优惠券列表
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ // url: `/pages/form/formStep4?usersid=${usersid.value}&productsid=${productsid.value}&couponcode=${res}`, // 跳转到formStep4 下单页面
|
|
|
|
|
+ url: `/pages/coupon/index`, // 跳转到优惠劵列表
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ // 取消操作,不做任何处理
|
|
|
uni.navigateBack()
|
|
uni.navigateBack()
|
|
|
})
|
|
})
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('领取优惠券出错:', error)
|
|
console.error('领取优惠券出错:', error)
|
|
|
- message.alert({
|
|
|
|
|
- msg: '操作失败,请稍后重试',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
} finally {
|
|
} finally {
|
|
|
submitLoading.value = false
|
|
submitLoading.value = false
|
|
|
overlayShow.value = false
|
|
overlayShow.value = false
|
|
@@ -366,46 +308,13 @@ async function handleSubmit() {
|
|
|
onLoad(async (query: any) => {
|
|
onLoad(async (query: any) => {
|
|
|
productsid.value = query.productsid || ''
|
|
productsid.value = query.productsid || ''
|
|
|
couponid.value = query.couponid || ''
|
|
couponid.value = query.couponid || ''
|
|
|
|
|
+ usersid.value = query.usersid || ''
|
|
|
// 可以根据 query 中的参数做一些初始化操作
|
|
// 可以根据 query 中的参数做一些初始化操作
|
|
|
})
|
|
})
|
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
|
- if (countdownTimer) {
|
|
|
|
|
- clearInterval(countdownTimer)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 如果需要清理任何资源,可以在这里添加清理逻辑
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 表单校验规则
|
|
|
|
|
-const rules = {
|
|
|
|
|
- userstype: [{ required: true, message: '请选择用户类型' }],
|
|
|
|
|
- usersname: [{ required: true, message: '请输入名称/企业名称' }],
|
|
|
|
|
- idNumber: [{ required: true, message: '请输入证件号' }],
|
|
|
|
|
-
|
|
|
|
|
- // 移除旧的idPhoto验证规则
|
|
|
|
|
- // idPhoto: [{ required: true, message: '请上传证件照片' }],
|
|
|
|
|
-
|
|
|
|
|
- // 根据用户类型添加自定义验证规则
|
|
|
|
|
- idCardIds: [
|
|
|
|
|
- {
|
|
|
|
|
- required: true,
|
|
|
|
|
- validator: (val) => formData.userstype !== '个人' || (val && val.length > 0),
|
|
|
|
|
- message: '请上传身份证照片',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
- businessLicenseIds: [
|
|
|
|
|
- {
|
|
|
|
|
- required: true,
|
|
|
|
|
- validator: (val) => formData.userstype !== '企业' || (val && val.length > 0),
|
|
|
|
|
- message: '请上传营业执照照片',
|
|
|
|
|
- },
|
|
|
|
|
- ],
|
|
|
|
|
-
|
|
|
|
|
- phone: [
|
|
|
|
|
- { required: true, message: '请输入手机号码' },
|
|
|
|
|
- { required: false, pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' },
|
|
|
|
|
- ],
|
|
|
|
|
- smsCode: [{ required: true, message: '请输入验证码' }],
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
// 将校验规则绑定到form
|
|
// 将校验规则绑定到form
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
// 初始化其他必要的操作
|
|
// 初始化其他必要的操作
|