修改上传图片路径参数

This commit is contained in:
wangxiaowei
2025-12-20 09:20:39 +08:00
parent 1a8e0ae847
commit 7e3b9c83d2
13 changed files with 49 additions and 59 deletions

View File

@ -206,7 +206,7 @@
try {
const response = JSON.parse(e.file.response)
if (response.code) {
const avatarUrl = response.data.uri
const avatarUrl = response.data.url
await updateUserInfo({ avatar: avatarUrl })
user.value.avatar = avatarUrl
toast.info('头像上传成功')

View File

@ -473,7 +473,7 @@
status: res.status, // 状态 0下架1上架
}
fileList.value = res.img.split(',').map((item: string) => ({
fileList.value = res.img_list.map((item: string) => ({
name: item,
url: item
}))
@ -510,7 +510,7 @@
const res = files.map(item => {
if (item.response) {
response = JSON.parse(item.response)
url = response.data.uri
url = response.data.url
name = response.data.name
}
return {
@ -651,8 +651,14 @@
toast.info('请输入退改说明')
return
}
formData.img = Add.fileList.map(item => item.url).join(',')
// 将图片URL中的 https://cz.stnav.com/ 替换为空
formData.img = Add.fileList.map(item => {
if (typeof item.url === 'string') {
return item.url.replace(import.meta.env.VITE_UPLOAD_IMAGE_URL, '')
}
return item.url
}).join(',')
if (roomId.value.includes(0)) {
formData.room_id = '0'
@ -678,6 +684,7 @@
await editTeaSpecialistOrderPackage(formData)
}
uni.$emit('refreshOrderList')
uni.hideLoading()
toast.info(type.value == 'add' ? '发布成功' : '编辑成功')
router.navigateBack(1, 500)

View File

@ -25,7 +25,7 @@
<view class="rounded-4rpx w-60rpx text-center text-[#FF5951] border-2rpx border-solid border-[#FF5951] text-22rpx pb-4rpx mx-14rpx">{{ detail.discount }}</view>
<price-format color="#BFC2CC" :first-size="22" :second-size="22" :subscript-size="22" :price="detail.price" lineThrough></price-format>
</view>
<view class="text-[#6A6363] flex-1 text-22rpx leading-32rpx text-right">已售 10+</view>
<view class="text-[#6A6363] flex-1 text-22rpx leading-32rpx text-right">已售 {{ detail.sold > 10 ? '10+' : detail.sold }}</view>
</view>
<view class="font-bold text-36rpx text-[#303133] leading-50rpx mt-26rpx">{{ detail.title }}</view>
<view class="font-500 text-26rpx leading-48rpx text-[#303133] mt-24rpx">{{ detail.description }}</view>
@ -170,38 +170,11 @@
id.value = Number(args.id)
teaRoomPrice.value = Number(args.price) || 0
// if (args.type == ReserveServiceCategory.GroupBuying) {
// isGroupBuying.value = true
// pay.value = 3
Detail.handleInitGroupBuying()
// }
// Detail.handleInitReserveRoom()
Detail.handleInitGroupBuying()
// 获取用户需求详
// getUserInfo().then(res => {
// user.value = res
// })
})
const Detail = {
/**
* 初始包间详情
*/
handleInitReserveRoom: async () => {
// 包间详情
const userStore = useUserStore()
userInfo.value = userStore.userInfo
const res = await getTeaRoomDetail({
id: storeId.value,
latitude: uni.getStorageSync('latitude'),
longitude: uni.getStorageSync('longitude'),
user_id: userInfo.value.id || 0
})
teaRoom.value = res.details
swiperList.value = teaRoom.value.img_arr
},
/*
* 初始化套餐详情
*/

View File

@ -51,6 +51,9 @@
import useMescroll from "@/uni_modules/mescroll-uni/hooks/useMescroll.js"
import { getTeaSpecialistOrderPackageList } from '@/api/order'
import { router } from '@/utils/tools'
import { useStoreStore } from '@/store'
const useStore = useStoreStore()
// mescroll
const { mescrollInit, downCallback, getMescroll } = useMescroll(onPageScroll, onReachBottom) // 调用mescroll的hook
@ -63,7 +66,7 @@
}
const list = ref<Array<any>>([]) // 茶室列表
const keywords = ref<string>('') // 搜索关键词
// tab
const tab = ref<number>(1)
const tabList = ref<Array<{title: string, num: number, name: number}>>([
@ -95,6 +98,7 @@
size: mescroll.size,
status: tab.value,
search: keywords.value,
store_id: useStore.defaultStore.id,
}
getTeaSpecialistOrderPackageList(filter).then((res) => {

View File

@ -244,7 +244,7 @@
const res = files.map(item => {
if (item.response) {
response = JSON.parse(item.response)
url = response.data.uri
url = response.data.url
name = response.data.name
}
return {
@ -290,8 +290,14 @@
return
}
form.value.image_arr = EditStore.fileList.map(item => item.url)
form.value.image = EditStore.fileList[0].url
form.value.image_arr = EditStore.fileList.map(item => {
if (typeof item.url === 'string') {
return item.url.replace(import.meta.env.VITE_UPLOAD_IMAGE_URL, '')
}
return item.url
})
form.value.image = form.value.image_arr[0]
form.value.id = useStore.defaultStore.id
uni.showLoading({

View File

@ -29,8 +29,8 @@
<template v-for="(label, labelIndex) in teaRoom.label" :key="labelIndex">
<view class="mr-20rpx flex items-start">
<wd-tag
:color="Detail.handleRandomColor(labelIndex)"
:bg-color="Detail.handleRandomColor(labelIndex)"
:color="randomLabelColor(labelIndex)"
:bg-color="randomLabelColor(labelIndex)"
plain
custom-class="!rounded-4rpx"
>{{ label.label_name }}</wd-tag>
@ -55,6 +55,7 @@
<script lang="ts" setup>
import { getStoreOrderDetails } from '@/api/store'
import PriceFormat from '@/components/PriceFormat.vue'
import { randomLabelColor } from '@/utils/tools'
const swiperList = ref<string[]>([])
const html: string = '<p>这里是富文本内容,需要后台传递</p>'
@ -63,9 +64,6 @@
const roomId = ref<number>(0) // 门店ID
const teaRoom = ref<any>({})
// 随机颜色列表
const tagColors = ['#40AE36', '#F55726']
onLoad((args) => {
roomId.value = Number(args.id)
Detail.handleInitReserveRoom()
@ -80,16 +78,6 @@
console.log("🚀 ~ res:", res)
teaRoom.value = res.details
swiperList.value = teaRoom.value.img_arr
},
/**
* 根据索引返回伪随机颜色
* @param index 索引
* @returns 颜色值
*/
handleRandomColor: (index: number) => {
// 可根据index做伪随机保证每次渲染一致
return tagColors[index % tagColors.length]
}
}
</script>

View File

@ -100,7 +100,7 @@ const alovaInstance = createAlova({
if (config.meta?.toast !== false) {
toast.info(msg)
router.switchTab(import.meta.env.VITE_LOGIN_URL, 1000)
router.navigateTo(import.meta.env.VITE_LOGIN_URL, 1000)
}
throw new Error(`登录超时[${code}]${msg}`)
}

View File

@ -1,5 +1,5 @@
<!-- 使用 type="home" 属性设置首页其他页面不需要设置默认为page -->
<route lang="jsonc" type="home">{
<route lang="jsonc" type="page">{
"needLogin": true,
"layout": "tabbar",
"style": {

View File

@ -1,4 +1,4 @@
<route lang="jsonc" type="page">{
<route lang="jsonc" type="home">{
"layout": "default",
"style": {
"navigationStyle": "custom"

View File

@ -521,7 +521,7 @@
try {
const response = JSON.parse(e.file.response)
if (response.code) {
const avatarUrl = response.data.uri
const avatarUrl = response.data.url
await updateUserInfo({ avatar: avatarUrl })
form.image = avatarUrl
toast.info('头像上传成功')

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

View File

@ -135,4 +135,15 @@ export function copy(data: any) {
toast.info('已复制到剪贴板')
}
})
}
}
/**
* 随机标签颜色
* @param index 索引
* @returns
*/
export function randomLabelColor (index: number) {
const tagColors = ['#40AE36', '#F55726']
return tagColors[index % tagColors.length]
}