|
@@ -53,131 +53,77 @@
|
|
|
</div>
|
|
</div>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <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-input
|
|
|
|
|
- label="SN码"
|
|
|
|
|
- label-width="100px"
|
|
|
|
|
- prop="ordersproductsn"
|
|
|
|
|
- clearable
|
|
|
|
|
- v-model="model.ordersproductsn"
|
|
|
|
|
- placeholder="请输入SN码"
|
|
|
|
|
- :rules="[{ required: true, message: '请填写SN码' }]"
|
|
|
|
|
- />
|
|
|
|
|
- </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.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">
|
|
|
<view class="flex items-center mb-4">
|
|
<view class="flex items-center mb-4">
|
|
|
<view class="text-lg font-bold text-gray-800">可用优惠券</view>
|
|
<view class="text-lg font-bold text-gray-800">可用优惠券</view>
|
|
|
<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="coupon-box">
|
|
<view class="coupon-box">
|
|
|
<!-- 这里添加优惠券列表组件 -->
|
|
<!-- 这里添加优惠券列表组件 -->
|
|
|
<view v-if="!coupons?.length" class="text-center py-8 text-gray-400">暂无可用优惠券</view>
|
|
<view v-if="!coupons?.length" class="text-center py-8 text-gray-400">暂无可用优惠券</view>
|
|
|
<view v-else>
|
|
<view v-else>
|
|
|
<view class="coupon-list">
|
|
<view class="coupon-list">
|
|
|
- <wd-radio-group v-model="couponChoose" shape="dot" @change="couponRadioChange">
|
|
|
|
|
- <wd-radio
|
|
|
|
|
- :value="coupon.couponid"
|
|
|
|
|
- v-for="coupon in couponsShow"
|
|
|
|
|
- :key="coupon.couponid"
|
|
|
|
|
- :disabled="coupon.canReceive"
|
|
|
|
|
- >
|
|
|
|
|
|
|
+ <wd-radio-group v-model="couponChoose" shape="dot">
|
|
|
|
|
+ <wd-radio :value="coupon.couponid" v-for="coupon in coupons" :key="coupon.couponid">
|
|
|
<view class="flex items-center justify-between">
|
|
<view class="flex items-center justify-between">
|
|
|
<view class="text-gray-800">{{ coupon.couponmc }}</view>
|
|
<view class="text-gray-800">{{ coupon.couponmc }}</view>
|
|
|
- <view class="flex items-center justify-end" @click.stop>
|
|
|
|
|
- <wd-button
|
|
|
|
|
- size="small"
|
|
|
|
|
- type="success"
|
|
|
|
|
- @click="handleReceive(coupon)"
|
|
|
|
|
- plain
|
|
|
|
|
- hairline
|
|
|
|
|
- :disabled="!coupon.canReceive"
|
|
|
|
|
- >
|
|
|
|
|
- {{ !coupon.canReceive ? '已领取' : '领取并使用' }}
|
|
|
|
|
- </wd-button>
|
|
|
|
|
- </view>
|
|
|
|
|
</view>
|
|
</view>
|
|
|
</wd-radio>
|
|
</wd-radio>
|
|
|
</wd-radio-group>
|
|
</wd-radio-group>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+ <!-- 领取优惠劵 -->
|
|
|
|
|
+ <view class="mt-4 px-2">
|
|
|
|
|
+ <wd-button type="primary" plain block @tap="showPhoneDialog">领取优惠劵</wd-button>
|
|
|
|
|
+ </view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
- <!-- 提交按钮 -->
|
|
|
|
|
- <view class="mt-2 pb-4 px-2">
|
|
|
|
|
- <wd-button type="success" block @tap="handleSubmit" :loading="submitLoading">
|
|
|
|
|
- 提交订单
|
|
|
|
|
- </wd-button>
|
|
|
|
|
|
|
+ <!-- 下单 -->
|
|
|
|
|
+ <!-- 立即下单按钮 -->
|
|
|
|
|
+ <view class="fixed-bottom bg-white p-4 border-t border-gray-100">
|
|
|
|
|
+ <wd-button type="primary" block size="large" @tap="handleOrder">立即下单</wd-button>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
|
|
|
+ <!-- 手机号输入弹窗 -->
|
|
|
|
|
+ <wd-popup
|
|
|
|
|
+ v-model="phoneDialogVisible"
|
|
|
|
|
+ round
|
|
|
|
|
+ :closable="true"
|
|
|
|
|
+ title="请输入手机号"
|
|
|
|
|
+ custom-class="w-[80%]"
|
|
|
|
|
+ >
|
|
|
|
|
+ <view class="phone-dialog p-6">
|
|
|
|
|
+ <view class="text-center mb-5">
|
|
|
|
|
+ <view class="text-lg font-semibold text-gray-800 mb-2">请输入您的手机号码</view>
|
|
|
|
|
+ <view class="text-sm text-gray-500">领取优惠券需要验证您的手机号</view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ <wd-input
|
|
|
|
|
+ v-model="phone"
|
|
|
|
|
+ placeholder="请输入您的手机号码"
|
|
|
|
|
+ clearable
|
|
|
|
|
+ :error="phoneError"
|
|
|
|
|
+ :error-message="phoneErrorMsg"
|
|
|
|
|
+ @blur="validatePhone"
|
|
|
|
|
+ required
|
|
|
|
|
+ class="mb-4"
|
|
|
|
|
+ />
|
|
|
|
|
+ <view class="mt-6">
|
|
|
|
|
+ <wd-button
|
|
|
|
|
+ type="success"
|
|
|
|
|
+ block
|
|
|
|
|
+ @click="handleSubmit"
|
|
|
|
|
+ :loading="submitLoading"
|
|
|
|
|
+ :disabled="submitLoading"
|
|
|
|
|
+ >
|
|
|
|
|
+ 确认领取
|
|
|
|
|
+ </wd-button>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </view>
|
|
|
|
|
+ </wd-popup>
|
|
|
|
|
+
|
|
|
<!-- loading -->
|
|
<!-- loading -->
|
|
|
<wd-overlay :show="overlayShow">
|
|
<wd-overlay :show="overlayShow">
|
|
|
<view class="wrapper w-full h-full flex items-center justify-center">
|
|
<view class="wrapper w-full h-full flex items-center justify-center">
|
|
@@ -190,195 +136,112 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
import { useProductStore } from '@/store/product'
|
|
import { useProductStore } from '@/store/product'
|
|
|
import { useCouponStore } from '@/store/coupon'
|
|
import { useCouponStore } from '@/store/coupon'
|
|
|
-import { useOrderStore } from '@/store/order'
|
|
|
|
|
-import { useAppStore } from '@/store/app'
|
|
|
|
|
-import { useUserStore } from '@/store/user'
|
|
|
|
|
import { useMessage } from 'wot-design-uni'
|
|
import { useMessage } from 'wot-design-uni'
|
|
|
-import { uploadFile } from '@/hooks/useUpload'
|
|
|
|
|
|
|
+import { useAppStore } from '@/store/app'
|
|
|
|
|
|
|
|
-const appStore = useAppStore()
|
|
|
|
|
-const userStore = useUserStore()
|
|
|
|
|
const couponStore = useCouponStore()
|
|
const couponStore = useCouponStore()
|
|
|
const productStore = useProductStore()
|
|
const productStore = useProductStore()
|
|
|
-const orderStore = useOrderStore()
|
|
|
|
|
|
|
+const appStore = useAppStore()
|
|
|
const message = useMessage()
|
|
const message = useMessage()
|
|
|
const usersid = ref('') // 销售网点用户id(渠道id)
|
|
const usersid = ref('') // 销售网点用户id(渠道id)
|
|
|
const productsid = ref('') // 产品id
|
|
const productsid = ref('') // 产品id
|
|
|
const productInfo = ref<any>(null) // 产品详情
|
|
const productInfo = ref<any>(null) // 产品详情
|
|
|
const overlayShow = ref(false) // 加载状态
|
|
const overlayShow = ref(false) // 加载状态
|
|
|
const coupons = ref<any[]>([]) // 可用优惠券列表
|
|
const coupons = ref<any[]>([]) // 可用优惠券列表
|
|
|
-const currentCoupon2id = ref('') // 当前选中的优惠劵
|
|
|
|
|
-const coupon2idList = ref<any[]>([]) // 已领取的优惠券ID列表
|
|
|
|
|
-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<{
|
|
|
|
|
- ordersproductsn: string // SN码
|
|
|
|
|
- ordersinvoiceImgIds: any[] // 购机发票ids
|
|
|
|
|
- ordersinvoiceImgList: any[] // 购机发票列表
|
|
|
|
|
- ordersidentityImgIds: any[] // 证件信息ids
|
|
|
|
|
- ordersidentityImgList: any[] // 证件信息列表
|
|
|
|
|
-}>({
|
|
|
|
|
- ordersproductsn: '',
|
|
|
|
|
- ordersinvoiceImgIds: [],
|
|
|
|
|
- ordersinvoiceImgList: [],
|
|
|
|
|
- ordersidentityImgIds: [],
|
|
|
|
|
- ordersidentityImgList: [],
|
|
|
|
|
-})
|
|
|
|
|
-const form = ref()
|
|
|
|
|
-const userstype = ref('') // 用户类型
|
|
|
|
|
-const tipsText = computed(() => {
|
|
|
|
|
- if (userstype.value === '个人') {
|
|
|
|
|
- return '请上传身份证正面和反面'
|
|
|
|
|
- }
|
|
|
|
|
- return '请上传营业执照'
|
|
|
|
|
-})
|
|
|
|
|
-
|
|
|
|
|
-function beforeUpload({ files, resolve }) {
|
|
|
|
|
- // 判断是否完善了个人信息
|
|
|
|
|
- if (!userStore.isAuthComplete) {
|
|
|
|
|
- handleAuthComplete()
|
|
|
|
|
|
|
+const phoneDialogVisible = ref(false) // 手机号输入弹窗显示状态
|
|
|
|
|
+
|
|
|
|
|
+// 手机号相关
|
|
|
|
|
+const phone = ref('')
|
|
|
|
|
+const phoneError = ref(false)
|
|
|
|
|
+const phoneErrorMsg = ref('')
|
|
|
|
|
+
|
|
|
|
|
+// 显示手机号输入弹窗
|
|
|
|
|
+function showPhoneDialog() {
|
|
|
|
|
+ // 检查是否选择了优惠券
|
|
|
|
|
+ if (!couponChoose.value && coupons.value && coupons.value.length > 0) {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '请选择优惠券',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
return
|
|
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)
|
|
|
|
|
|
|
+ phoneDialogVisible.value = true
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- const loading = ref(false)
|
|
|
|
|
- const error = ref(false)
|
|
|
|
|
- const data = ref<any>()
|
|
|
|
|
|
|
+// 验证手机号
|
|
|
|
|
+function validatePhone() {
|
|
|
|
|
+ if (!phone.value) {
|
|
|
|
|
+ phoneError.value = true
|
|
|
|
|
+ phoneErrorMsg.value = '请输入手机号码'
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- await uploadFile({
|
|
|
|
|
- tempFilePath: file.url,
|
|
|
|
|
- formData: requestFromData,
|
|
|
|
|
- data,
|
|
|
|
|
- error,
|
|
|
|
|
- loading,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ const phoneReg = /^1[3-9]\d{9}$/
|
|
|
|
|
+ if (!phoneReg.test(phone.value)) {
|
|
|
|
|
+ phoneError.value = true
|
|
|
|
|
+ phoneErrorMsg.value = '请输入正确的手机号码'
|
|
|
|
|
+ return false
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- 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,
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ phoneError.value = false
|
|
|
|
|
+ phoneErrorMsg.value = ''
|
|
|
|
|
+ return true
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
- // console.log('model[modelStats]:', model)
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// 提交表单
|
|
|
|
|
+async function handleSubmit() {
|
|
|
|
|
+ // 验证手机号
|
|
|
|
|
+ if (!validatePhone()) {
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-// 删除文件时,删除ids数组数据
|
|
|
|
|
-function handleRemoveInvoice({ file }) {
|
|
|
|
|
- model.ordersinvoiceImgIds = model.ordersinvoiceImgIds.filter((item) => item.url !== file.url)
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ submitLoading.value = true
|
|
|
|
|
|
|
|
-// 删除文件时,删除ids数组数据
|
|
|
|
|
-function handleRemoveIdentity({ file }) {
|
|
|
|
|
- model.ordersidentityImgIds = model.ordersidentityImgIds.filter((item) => item.url !== file.url)
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ // 获取选中的优惠券
|
|
|
|
|
+ const selectedCoupon = coupons.value.find((coupon) => coupon.couponid === couponChoose.value)
|
|
|
|
|
|
|
|
-// 完善资料提示
|
|
|
|
|
-function handleAuthComplete() {
|
|
|
|
|
- message
|
|
|
|
|
- .confirm({
|
|
|
|
|
- msg: '您还未完善个人信息, 请先完善信息',
|
|
|
|
|
|
|
+ if (!selectedCoupon) {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '请选择优惠券',
|
|
|
title: '提示',
|
|
title: '提示',
|
|
|
- confirmButtonText: '去完善',
|
|
|
|
|
- cancelButtonText: '继续浏览',
|
|
|
|
|
- })
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pages-sub/user/index',
|
|
|
|
|
- })
|
|
|
|
|
})
|
|
})
|
|
|
- .catch(() => {
|
|
|
|
|
- // ...
|
|
|
|
|
- })
|
|
|
|
|
-}
|
|
|
|
|
|
|
+ submitLoading.value = false
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
-// 提交表单
|
|
|
|
|
-function handleSubmit() {
|
|
|
|
|
- // 判断是否完善了个人信息
|
|
|
|
|
- if (!userStore.isAuthComplete) handleAuthComplete()
|
|
|
|
|
-
|
|
|
|
|
- form.value.validate().then(async (res) => {
|
|
|
|
|
- if (res.valid) {
|
|
|
|
|
- // 判断是否选择了优惠券
|
|
|
|
|
- if (couponsShow.value.length && !currentCoupon2id.value) {
|
|
|
|
|
- message.alert({
|
|
|
|
|
- msg: '当前有可用优惠券,请选择优惠券',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 是否上传了购机发票
|
|
|
|
|
- if (!model.ordersinvoiceImgIds.length) {
|
|
|
|
|
- message.alert({
|
|
|
|
|
- msg: '请上传购机发票',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- // 是否上传了证件信息
|
|
|
|
|
- if (!model.ordersidentityImgIds.length) {
|
|
|
|
|
- message.alert({
|
|
|
|
|
- msg: '请上传证件信息',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- submitLoading.value = true
|
|
|
|
|
- const invoiceFileIds = model.ordersinvoiceImgIds.map((item) => item.id)
|
|
|
|
|
- const identityFileIds = model.ordersidentityImgIds.map((item) => item.id)
|
|
|
|
|
-
|
|
|
|
|
- const res = await orderStore.submitOrder({
|
|
|
|
|
- ordersproductid: productsid.value,
|
|
|
|
|
- orderscouponid: currentCoupon2id.value,
|
|
|
|
|
- ordersproductsn: model.ordersproductsn,
|
|
|
|
|
- ordersuserid1: usersid.value, // 渠道id 魏哥:微信下单增加参数ordersuserid1对应渠道id,后端渠道看自己的订单数据相比管理员只需要另外新增菜单权限配置,额外固定配置参数ordersuserid1.value=session:workeruserid,界面都可以先套用,然后给渠道归类一个角色。
|
|
|
|
|
- filesid: [...invoiceFileIds, ...identityFileIds].join(','),
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 调用领取优惠券API
|
|
|
|
|
+ const result = await couponStore.receiveCoupon({
|
|
|
|
|
+ couponid: selectedCoupon.couponid,
|
|
|
|
|
+ coupon2phone: phone.value,
|
|
|
|
|
+ coupon2productids: productsid.value,
|
|
|
|
|
+ })
|
|
|
|
|
|
|
|
- message
|
|
|
|
|
- .alert({
|
|
|
|
|
- msg: '提交成功',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
- .then(() => {
|
|
|
|
|
- uni.navigateTo({ url: '/pages/order/index' })
|
|
|
|
|
- })
|
|
|
|
|
- .finally(() => {
|
|
|
|
|
- submitLoading.value = false
|
|
|
|
|
- })
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- message.alert({
|
|
|
|
|
- msg: '提交失败',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
- } finally {
|
|
|
|
|
- submitLoading.value = false
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (result && result.Success) {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '优惠券领取成功,请注意查收短信',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
|
|
+ phoneDialogVisible.value = false // 关闭弹窗
|
|
|
|
|
+ } else {
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: result?.Message || '领取失败,请稍后再试',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
- })
|
|
|
|
|
|
|
+
|
|
|
|
|
+ submitLoading.value = false
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('领取优惠券出错:', error)
|
|
|
|
|
+ message.alert({
|
|
|
|
|
+ msg: '操作失败',
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ })
|
|
|
|
|
+ submitLoading.value = false
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 获取产品详情
|
|
// 获取产品详情
|
|
@@ -392,73 +255,55 @@ async function getProductDetail() {
|
|
|
overlayShow.value = false
|
|
overlayShow.value = false
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 获取可用优惠券列表
|
|
|
|
|
|
|
+// 获取优惠券列表
|
|
|
async function getCouponList() {
|
|
async function getCouponList() {
|
|
|
if (!productsid.value) return
|
|
if (!productsid.value) return
|
|
|
coupons.value = await couponStore.getCouponList(productsid.value)
|
|
coupons.value = await couponStore.getCouponList(productsid.value)
|
|
|
|
|
+ // 如果有可用优惠券,默认选中第一个
|
|
|
|
|
+ if (coupons.value && coupons.value.length > 0) {
|
|
|
|
|
+ couponChoose.value = coupons.value[0].couponid
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 领取优惠券
|
|
|
|
|
-async function handleReceive(coupon: any) {
|
|
|
|
|
- overlayShow.value = true
|
|
|
|
|
- await couponStore.receiveCoupon(coupon.couponid)
|
|
|
|
|
- overlayShow.value = false
|
|
|
|
|
-
|
|
|
|
|
- message.alert({
|
|
|
|
|
- msg: '领取成功',
|
|
|
|
|
- title: '提示',
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- // 重新获取优惠券列表状态
|
|
|
|
|
- await getCouponsShow()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 获取该用户下,已领取的优惠劵id,用于判断是否可以领取
|
|
|
|
|
-async function getCoupon2id() {
|
|
|
|
|
- const { Data } = await couponStore.getCoupon2id({
|
|
|
|
|
- coupon2userid: appStore.appInfo.userid,
|
|
|
|
|
- coupon2isused: 0,
|
|
|
|
|
- coupon2productids: productsid.value,
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- coupon2idList.value = Data
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 优惠券选择
|
|
|
|
|
-async function couponRadioChange(e: any) {
|
|
|
|
|
- currentCoupon2id.value = couponsShow.value.find((item) => item.couponid === e.value)?.coupon2code
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-// 获取可展示的优惠券列表
|
|
|
|
|
-function getCouponsShow() {
|
|
|
|
|
- Promise.all([
|
|
|
|
|
- getCouponList(), // 获取可用优惠券列表
|
|
|
|
|
- getCoupon2id(), // 获取该用户下,已领取的优惠劵id,用于判断是否可以领取
|
|
|
|
|
- ]).then(() => {
|
|
|
|
|
- couponsShow.value = coupons.value.map((coupon) => {
|
|
|
|
|
- // 找到匹配的已领取优惠券记录
|
|
|
|
|
- const receivedCoupon = coupon2idList.value.find(
|
|
|
|
|
- (item) => item.coupon2coupon1id === coupon.couponid,
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
- return {
|
|
|
|
|
- ...coupon,
|
|
|
|
|
- canReceive: !receivedCoupon, // 是否可以领取
|
|
|
|
|
- coupon2sid: receivedCoupon?.coupon2sid, // 优惠券id
|
|
|
|
|
- coupon2code: receivedCoupon?.coupon2code, // 优惠券码
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// 立即下单
|
|
|
|
|
+function handleOrder() {
|
|
|
|
|
+ // 检查登录状态
|
|
|
|
|
+ if (!appStore.isLoginState) {
|
|
|
|
|
+ // 未登录状态,显示确认框
|
|
|
|
|
+ message
|
|
|
|
|
+ .confirm({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ msg: '请先登录后再进行下单操作',
|
|
|
|
|
+ confirmButtonText: '去登录',
|
|
|
|
|
+ cancelButtonText: '取消',
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(() => {
|
|
|
|
|
+ // 用户点击确认,跳转到登录页面
|
|
|
|
|
+ // 保存当前页面路径用于登录后回跳
|
|
|
|
|
+ const currentPage = getCurrentPages()[getCurrentPages().length - 1].route
|
|
|
|
|
+ const queryParams = `?usersid=${usersid.value}&productsid=${productsid.value}`
|
|
|
|
|
+ const redirectPath = `/${currentPage}${queryParams}`
|
|
|
|
|
+
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages-sub/auth/index?redirect=${encodeURIComponent(redirectPath)}`,
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ .catch(() => {
|
|
|
|
|
+ // 取消操作,不做任何处理
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 已登录状态,跳转到订单确认页面
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: `/pages/form/formStep4?usersid=${usersid.value}&productsid=${productsid.value}`,
|
|
|
})
|
|
})
|
|
|
- })
|
|
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onLoad(async (query) => {
|
|
onLoad(async (query) => {
|
|
|
usersid.value = query.usersid
|
|
usersid.value = query.usersid
|
|
|
productsid.value = query.productsid
|
|
productsid.value = query.productsid
|
|
|
getProductDetail() // 获取产品详情
|
|
getProductDetail() // 获取产品详情
|
|
|
- getCouponsShow() // 获取可展示的优惠券列表
|
|
|
|
|
-
|
|
|
|
|
- // 获取用户类型
|
|
|
|
|
- userstype.value = await userStore.getUserType() // 个人/企业
|
|
|
|
|
|
|
+ getCouponList() // 获取优惠券列表
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
@@ -468,7 +313,7 @@ onLoad(async (query) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
.detail-box {
|
|
.detail-box {
|
|
|
- :deep(.wd-cell) {
|
|
|
|
|
|
|
+ :deep(.wd-cell__wrapper) {
|
|
|
// @apply py-2;
|
|
// @apply py-2;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -477,7 +322,7 @@ onLoad(async (query) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
:deep(.wd-cell__value) {
|
|
:deep(.wd-cell__value) {
|
|
|
- @apply text-gray-800 text-sm;
|
|
|
|
|
|
|
+ @apply text-gray-800 text-sm whitespace-nowrap;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|