diff --git a/.env.development b/.env.development index cf42d45..ff634ef 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,6 @@ VITE_APP_PREVIEW=true -# VITE_APP_API_BASE_URL=http://172.16.0.51:8166/web/ +# VITE_APP_API_BASE_URL=http://172.16.0.47:8166/web/ +# VITE_APP_API_BASE_URL=https://wechat-test.api.puabadge.com/web/ VITE_APP_API_BASE_URL=https://wechat.api.puabadge.com/web/ # VITE_APP_API_WX_URL=https://wechat.api.puabadge.com/web/ # http://web.suwa3d.dev:28499/ diff --git a/components.d.ts b/components.d.ts index afda2f6..cb74f3e 100644 --- a/components.d.ts +++ b/components.d.ts @@ -21,7 +21,6 @@ declare module '@vue/runtime-core' { Tabbar: typeof import('./src/components/tabbar/index.vue')['default'] Tensorflow: typeof import('./src/components/arFrame/tensorflow.vue')['default'] VanActionSheet: typeof import('vant/es')['ActionSheet'] - VanConfigProvider: typeof import('vant/es')['ConfigProvider'] VanDivider: typeof import('vant/es')['Divider'] VanField: typeof import('vant/es')['Field'] VanIcon: typeof import('vant/es')['Icon'] diff --git a/src/api/badge.ts b/src/api/badge.ts index 3ad3466..9bc76a5 100644 --- a/src/api/badge.ts +++ b/src/api/badge.ts @@ -65,7 +65,7 @@ export const getOrderDetail = (params: any) => { } // 推送生成效果图 -export const putMOdeling = (data: any) => { +export const putModeling = (data: any) => { return request('images/putModeling', { method: 'POST', data, @@ -110,4 +110,4 @@ export const trialPhone = (data: any) => { method: 'POST', data, }) -} \ No newline at end of file +} diff --git a/src/views/badge/index.vue b/src/views/badge/index.vue index 34ac9fc..a3c93ef 100644 --- a/src/views/badge/index.vue +++ b/src/views/badge/index.vue @@ -41,7 +41,6 @@ const openApp = () => { const imgurl = ref('') const imgBgUrl = ref('') -const isBgShow = ref(true) const remaining = ref(0) function goToRecord() { router.push('/badge/record') @@ -58,9 +57,12 @@ const getSizeList = () => { } const orderStat = ref({}) +const prodId = ref(7) const getOrderStat = () => { badgeApi.getOrderStat({}).then((res: any) => { orderStat.value = res + prodId.value = res.prod_id + getSundryList() }) } @@ -75,18 +77,10 @@ function goToPreview() { showToast('请先上传照片') return } - if (isBgShow.value == false && !imgBgUrl.value) { - showToast('请先上传背景照片') - return - } if (orderStat.value.remain_count <= 0) { showToast('剩余次数不足') return } - if (checkId.value == 0) { - showToast('请选择风格样式') - return - } isLoading.value = true if (trialCode.value) { trialPhone() @@ -117,8 +111,9 @@ const trialPhone = async () => { message: err.message, duration: 2000, }) + isLoading.value = false }).finally(() => { - + isLoading.value = false }) } const picture = ref(null) @@ -154,7 +149,6 @@ const getRandomNumber = () => { // 获取Pid const pid = ref('') -const kindId = ref(0) const getPid = async () => { showLoadingToast({ message: '上传中...', @@ -163,46 +157,28 @@ const getPid = async () => { duration: 0, }) const params = { - extend_value: isBgShow.value ? -1 : 0, - kind_id: checkId.value, + prod_id: prodId.value } try { const res = await badgeApi.getPid(params) console.log('getPid', res) isLoading.value = false pid.value = res.pid - if (isBgShow.value) { - try { - const uploadTasks = [ - sendToOss(imgurl.value, res.url), - sendToOss(imgurl.value, res.oss_url) - ] - await Promise.all(uploadTasks) - } catch (err) { - closeToast() - console.error('上传失败:', err) - showFailToast({ - message: '上传失败', - duration: 2000, - }) - } - } else { - try { - const uploadTasks = [ - sendToOss(imgurl.value, res.url), - sendToOss(imgurl.value, res.oss_url), - sendToOss(imgBgUrl.value, res.extend_url), - sendToOss(imgBgUrl.value, res.extend_bg_url) - ] - await Promise.all(uploadTasks) - } catch (err) { - closeToast() - console.error('上传失败:', err) - showFailToast({ - message: '上传失败', - duration: 2000, - }) - } + try { + const uploadTasks = [ + sendToOss(imgurl.value, res.url), + sendToOss(imgurl.value, res.oss_url) + ] + await Promise.all(uploadTasks) + } catch (err) { + closeToast() + console.error('上传失败:', err) + showFailToast({ + message: '上传失败', + duration: 2000, + }) + isLoading.value = false + return } } catch (err) { isLoading.value = false @@ -240,11 +216,10 @@ const sendToOss = async (src: string, url: string) => { isAnotherAPICalled.value = true const params = { pid: pid.value, - kind_id: checkId.value, - extend_value: isBgShow.value ? -1 : 0, group: 1, + prod_id: prodId.value } - badgeApi.putMOdeling(params).then((res: any) => { + badgeApi.putModeling(params).then((res: any) => { console.log('putModeling', res) createLog() }).catch((err) => { @@ -268,7 +243,7 @@ const createLog = () => { const params = { pid: pid.value, group: 1, - kind_id: checkId.value, + prod_id: prodId.value } badgeApi.createLog(params).then((res: any) => { console.log('createLog', res) @@ -283,6 +258,7 @@ const createLog = () => { query: { pid: pid.value, group: 1, + prod_id: prodId.value }, }) }, 1000); @@ -297,32 +273,12 @@ const createLog = () => { }) } - -const kindList = ref([]) -const checkId = ref(0) -const getKindList = () => { - badgeApi.getKindList({ - page: 1, - size: 20, - scale: 20, - }).then((res: any) => { - const data = res || [] - kindList.value = data.list - }).catch((err) => { - showToast({ - message: err.message, - duration: 2000, - }) - }).finally(() => { - - }) -} const sundryList = ref([]) const getSundryList = () => { badgeApi.getSundryList({ page: 1, size: 6, - group: 'gp', + group: prodId.value == 7 ? 'gp' : 'pet', }).then((res: any) => { const data = res || [] sundryList.value = data.list @@ -335,25 +291,7 @@ const getSundryList = () => { }) } -const caseList = ref([]) -const getList = () => { - badgeApi.getSundryList({ - page: 1, - size: 5, - group: 'case', - ids: '6,7,8,9,19' - }).then((res: any) => { - const data = res || [] - caseList.value = data.list - }).catch((err) => { - showToast({ - message: err.message, - duration: 2000, - }) - }).finally(() => { - - }) -} + const trialCode = ref(false) const trialCodeValue = ref('') const getTrialCode = () => { @@ -380,6 +318,10 @@ const onBlur = async () => { return; } } +const styleChange = (id: number) => { + prodId.value = id + getSundryList() +} const key = CryptoJS.enc.Utf8.parse("123abcdefpua2025"); const iv = CryptoJS.enc.Utf8.parse('DYgjCEIMVrj2W9xN'); function Encrypt(word: string): string { @@ -387,7 +329,6 @@ function Encrypt(word: string): string { let encrypted = CryptoJS.AES.encrypt(srcs, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7 }); return encrypted.ciphertext.toString(); - } function handleBeforeUnload(_event: BeforeUnloadEvent) { localStorage.remove('code') @@ -395,9 +336,7 @@ function handleBeforeUnload(_event: BeforeUnloadEvent) { localStorage.remove('userId') } onMounted(() => { - getKindList() getSundryList() - getList() openApp() getTrialCode() window.addEventListener('beforeunload', handleBeforeUnload); @@ -407,6 +346,24 @@ onMounted(() => {