|
@@ -53,14 +53,14 @@
|
|
|
</div>
|
|
</div>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- SN码 -->
|
|
|
|
|
- <view class="bg-white px-4 py-4 mb-3 shadow-sm">
|
|
|
|
|
- <view class="flex items-center mb-4">
|
|
|
|
|
- <view class="text-lg font-bold text-gray-800">农机SN码</view>
|
|
|
|
|
- <view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
|
|
|
- </view>
|
|
|
|
|
- <div class="detail-box rounded-lg">
|
|
|
|
|
- <wd-form ref="form" :model="model">
|
|
|
|
|
|
|
+ <wd-form ref="form" :model="model">
|
|
|
|
|
+ <!-- SN码 -->
|
|
|
|
|
+ <view class="bg-white px-4 py-4 mb-3 shadow-sm">
|
|
|
|
|
+ <view class="flex items-center mb-4">
|
|
|
|
|
+ <view class="text-lg font-bold text-gray-800">农机SN码</view>
|
|
|
|
|
+ <view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <div class="detail-box rounded-lg">
|
|
|
<wd-cell-group border>
|
|
<wd-cell-group border>
|
|
|
<wd-input
|
|
<wd-input
|
|
|
label="SN码"
|
|
label="SN码"
|
|
@@ -72,9 +72,64 @@
|
|
|
:rules="[{ required: true, message: '请填写SN码' }]"
|
|
:rules="[{ required: true, message: '请填写SN码' }]"
|
|
|
/>
|
|
/>
|
|
|
</wd-cell-group>
|
|
</wd-cell-group>
|
|
|
- </wd-form>
|
|
|
|
|
- </div>
|
|
|
|
|
- </view>
|
|
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <!-- 购机发票 -->
|
|
|
|
|
+ <view class="bg-white px-4 py-4 mb-3 shadow-sm">
|
|
|
|
|
+ <view class="flex items-center mb-4">
|
|
|
|
|
+ <view class="text-lg font-bold text-gray-800">购机发票</view>
|
|
|
|
|
+ <view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <div class="detail-box rounded-lg">
|
|
|
|
|
+ <wd-cell-group border>
|
|
|
|
|
+ <wd-upload
|
|
|
|
|
+ v-model:file-list="model.ordersinvoiceImgList"
|
|
|
|
|
+ image-mode="aspectFill"
|
|
|
|
|
+ :upload-method="
|
|
|
|
|
+ createCustomUpload({
|
|
|
|
|
+ attmodel: 'orders_invoice',
|
|
|
|
|
+ attpath: '/orders_invoice/',
|
|
|
|
|
+ modelStats: 'ordersinvoiceImgIds',
|
|
|
|
|
+ })
|
|
|
|
|
+ "
|
|
|
|
|
+ :rules="[{ required: true, message: '请上传购机发票' }]"
|
|
|
|
|
+ :limit="1"
|
|
|
|
|
+ :before-upload="beforeUpload"
|
|
|
|
|
+ @remove="handleRemoveInvoice"
|
|
|
|
|
+ ></wd-upload>
|
|
|
|
|
+ </wd-cell-group>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <!-- 证件信息 -->
|
|
|
|
|
+ <view class="bg-white px-4 py-4 mb-3 shadow-sm">
|
|
|
|
|
+ <view class="flex items-center mb-4">
|
|
|
|
|
+ <view class="text-lg font-bold text-gray-800">证件信息</view>
|
|
|
|
|
+ <view class="ml-2 flex-1 h-px bg-gray-100"></view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <div class="detail-box rounded-lg">
|
|
|
|
|
+ <wd-cell-group border>
|
|
|
|
|
+ <wd-upload
|
|
|
|
|
+ v-model:file-list="model.ordersidentityImgList"
|
|
|
|
|
+ image-mode="aspectFill"
|
|
|
|
|
+ :upload-method="
|
|
|
|
|
+ createCustomUpload({
|
|
|
|
|
+ attmodel: 'orders_identity',
|
|
|
|
|
+ attpath: '/orders_identity/',
|
|
|
|
|
+ modelStats: 'ordersidentityImgIds',
|
|
|
|
|
+ })
|
|
|
|
|
+ "
|
|
|
|
|
+ :rules="[{ required: true, message: '请上传证件信息' }]"
|
|
|
|
|
+ :limit="2"
|
|
|
|
|
+ :before-upload="beforeUpload"
|
|
|
|
|
+ @remove="handleRemoveIdentity"
|
|
|
|
|
+ ></wd-upload>
|
|
|
|
|
+ </wd-cell-group>
|
|
|
|
|
+ <div class="tips mt-2">
|
|
|
|
|
+ <wd-text type="warning" :text="tipsText" v-if="userStore.isAuthComplete"></wd-text>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </wd-form>
|
|
|
|
|
|
|
|
<!-- 优惠券卡片 -->
|
|
<!-- 优惠券卡片 -->
|
|
|
<view class="bg-white px-4 py-4 shadow-sm">
|
|
<view class="bg-white px-4 py-4 shadow-sm">
|
|
@@ -139,6 +194,7 @@ import { useOrderStore } from '@/store/order'
|
|
|
import { useAppStore } from '@/store/app'
|
|
import { useAppStore } from '@/store/app'
|
|
|
import { useUserStore } from '@/store/user'
|
|
import { useUserStore } from '@/store/user'
|
|
|
import { useMessage } from 'wot-design-uni'
|
|
import { useMessage } from 'wot-design-uni'
|
|
|
|
|
+import { uploadFile } from '@/hooks/useUpload'
|
|
|
|
|
|
|
|
const appStore = useAppStore()
|
|
const appStore = useAppStore()
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
@@ -157,32 +213,108 @@ const couponsShow = ref<any[]>([]) // 展示的优惠券列表
|
|
|
const couponChoose = ref('') // 选择的优惠券ID
|
|
const couponChoose = ref('') // 选择的优惠券ID
|
|
|
const submitLoading = ref(false) // 提交订单loading
|
|
const submitLoading = ref(false) // 提交订单loading
|
|
|
const model = reactive<{
|
|
const model = reactive<{
|
|
|
- ordersproductsn: string
|
|
|
|
|
|
|
+ ordersproductsn: string // SN码
|
|
|
|
|
+ ordersinvoiceImgIds: any[] // 购机发票ids
|
|
|
|
|
+ ordersinvoiceImgList: any[] // 购机发票列表
|
|
|
|
|
+ ordersidentityImgIds: any[] // 证件信息ids
|
|
|
|
|
+ ordersidentityImgList: any[] // 证件信息列表
|
|
|
}>({
|
|
}>({
|
|
|
ordersproductsn: '',
|
|
ordersproductsn: '',
|
|
|
|
|
+ ordersinvoiceImgIds: [],
|
|
|
|
|
+ ordersinvoiceImgList: [],
|
|
|
|
|
+ ordersidentityImgIds: [],
|
|
|
|
|
+ ordersidentityImgList: [],
|
|
|
})
|
|
})
|
|
|
const form = ref()
|
|
const form = ref()
|
|
|
|
|
+const userstype = ref('') // 用户类型
|
|
|
|
|
+const tipsText = computed(() => {
|
|
|
|
|
+ if (userstype.value === '个人') {
|
|
|
|
|
+ return '请上传身份证正面和反面'
|
|
|
|
|
+ }
|
|
|
|
|
+ return '请上传营业执照'
|
|
|
|
|
+})
|
|
|
|
|
|
|
|
-// 提交表单
|
|
|
|
|
-function handleSubmit() {
|
|
|
|
|
|
|
+function beforeUpload({ files, resolve }) {
|
|
|
// 判断是否完善了个人信息
|
|
// 判断是否完善了个人信息
|
|
|
if (!userStore.isAuthComplete) {
|
|
if (!userStore.isAuthComplete) {
|
|
|
- message
|
|
|
|
|
- .confirm({
|
|
|
|
|
- msg: '您还未完善个人信息, 请先完善信息',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- confirmButtonText: '去完善',
|
|
|
|
|
- cancelButtonText: '继续浏览',
|
|
|
|
|
- })
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages-sub/user/index',
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- .catch(() => {
|
|
|
|
|
- // ...
|
|
|
|
|
|
|
+ handleAuthComplete()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ // console.log('files:', files)
|
|
|
|
|
+ resolve(true)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 创建自定义上传方法
|
|
|
|
|
+function createCustomUpload({ attmodel, attpath, modelStats }) {
|
|
|
|
|
+ return async function (file, formData, options) {
|
|
|
|
|
+ const requestFromData = {
|
|
|
|
|
+ attmodel,
|
|
|
|
|
+ attpath,
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // console.log('file:', file)
|
|
|
|
|
+ // console.log('formData:', formData)
|
|
|
|
|
+ // console.log('options:', options)
|
|
|
|
|
+
|
|
|
|
|
+ const loading = ref(false)
|
|
|
|
|
+ const error = ref(false)
|
|
|
|
|
+ const data = ref<any>()
|
|
|
|
|
+
|
|
|
|
|
+ await uploadFile({
|
|
|
|
|
+ tempFilePath: file.url,
|
|
|
|
|
+ formData: requestFromData,
|
|
|
|
|
+ data,
|
|
|
|
|
+ error,
|
|
|
|
|
+ loading,
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ if (!error.value) {
|
|
|
|
|
+ options.onSuccess('', file, formData)
|
|
|
|
|
+ // {"Status":0,"Data":"2025041016044040627399","Message":"执行成功","OtherData":"https://dzapi.kdboss.cn/upfile/orders_invoice/20250410/2025041016044040731543.png"}
|
|
|
|
|
+ const dataObject = JSON.parse(data.value)
|
|
|
|
|
+ model[modelStats].push({
|
|
|
|
|
+ url: file.url,
|
|
|
|
|
+ id: dataObject.Data,
|
|
|
})
|
|
})
|
|
|
|
|
+
|
|
|
|
|
+ // console.log('model[modelStats]:', model)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 删除文件时,删除ids数组数据
|
|
|
|
|
+function handleRemoveInvoice({ file }) {
|
|
|
|
|
+ model.ordersinvoiceImgIds = model.ordersinvoiceImgIds.filter((item) => item.url !== file.url)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 删除文件时,删除ids数组数据
|
|
|
|
|
+function handleRemoveIdentity({ file }) {
|
|
|
|
|
+ model.ordersidentityImgIds = model.ordersidentityImgIds.filter((item) => item.url !== file.url)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 完善资料提示
|
|
|
|
|
+function handleAuthComplete() {
|
|
|
|
|
+ message
|
|
|
|
|
+ .confirm({
|
|
|
|
|
+ msg: '您还未完善个人信息, 请先完善信息',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ confirmButtonText: '去完善',
|
|
|
|
|
+ cancelButtonText: '继续浏览',
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pages-sub/user/index',
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ // ...
|
|
|
|
|
+ })
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 提交表单
|
|
|
|
|
+function handleSubmit() {
|
|
|
|
|
+ // 判断是否完善了个人信息
|
|
|
|
|
+ if (!userStore.isAuthComplete) handleAuthComplete()
|
|
|
|
|
|
|
|
form.value.validate().then(async (res) => {
|
|
form.value.validate().then(async (res) => {
|
|
|
if (res.valid) {
|
|
if (res.valid) {
|
|
@@ -195,15 +327,36 @@ function handleSubmit() {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 是否上传了购机发票
|
|
|
|
|
+ if (!model.ordersinvoiceImgIds.length) {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '请上传购机发票',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 是否上传了证件信息
|
|
|
|
|
+ if (!model.ordersidentityImgIds.length) {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '请上传证件信息',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
try {
|
|
try {
|
|
|
submitLoading.value = true
|
|
submitLoading.value = true
|
|
|
|
|
+ const invoiceFileIds = model.ordersinvoiceImgIds.map((item) => item.id)
|
|
|
|
|
+ const identityFileIds = model.ordersidentityImgIds.map((item) => item.id)
|
|
|
|
|
+
|
|
|
const res = await orderStore.submitOrder({
|
|
const res = await orderStore.submitOrder({
|
|
|
ordersproductid: productsid.value,
|
|
ordersproductid: productsid.value,
|
|
|
orderscouponid: currentCoupon2id.value,
|
|
orderscouponid: currentCoupon2id.value,
|
|
|
ordersproductsn: model.ordersproductsn,
|
|
ordersproductsn: model.ordersproductsn,
|
|
|
ordersuserid1: usersid.value, // 渠道id 魏哥:微信下单增加参数ordersuserid1对应渠道id,后端渠道看自己的订单数据相比管理员只需要另外新增菜单权限配置,额外固定配置参数ordersuserid1.value=session:workeruserid,界面都可以先套用,然后给渠道归类一个角色。
|
|
ordersuserid1: usersid.value, // 渠道id 魏哥:微信下单增加参数ordersuserid1对应渠道id,后端渠道看自己的订单数据相比管理员只需要另外新增菜单权限配置,额外固定配置参数ordersuserid1.value=session:workeruserid,界面都可以先套用,然后给渠道归类一个角色。
|
|
|
|
|
+ filesid: [...invoiceFileIds, ...identityFileIds].join(','),
|
|
|
})
|
|
})
|
|
|
- console.log('submitOrder res:', res)
|
|
|
|
|
|
|
|
|
|
message
|
|
message
|
|
|
.alert({
|
|
.alert({
|
|
@@ -303,6 +456,9 @@ onLoad(async (query) => {
|
|
|
productsid.value = query.productsid
|
|
productsid.value = query.productsid
|
|
|
getProductDetail() // 获取产品详情
|
|
getProductDetail() // 获取产品详情
|
|
|
getCouponsShow() // 获取可展示的优惠券列表
|
|
getCouponsShow() // 获取可展示的优惠券列表
|
|
|
|
|
+
|
|
|
|
|
+ // 获取用户类型
|
|
|
|
|
+ userstype.value = await userStore.getUserType() // 个人/企业
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|