合并merchant文件
This commit is contained in:
@@ -135,13 +135,52 @@
|
||||
}
|
||||
})
|
||||
},
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
|
||||
async uploadImageToSupa(localPath: string): Promise<string> {
|
||||
if (localPath.startsWith('http://') || localPath.startsWith('https://')) {
|
||||
return localPath
|
||||
}
|
||||
|
||||
let ext = '.jpg'
|
||||
const dotIndex = localPath.lastIndexOf('.')
|
||||
if (dotIndex > -1) {
|
||||
ext = localPath.substring(dotIndex).toLowerCase()
|
||||
}
|
||||
|
||||
const uuid = Date.now().toString() + '_' + Math.floor(Math.random() * 1000)
|
||||
const remotePath = `shops/${this.merchantId}_${uuid}${ext}`
|
||||
|
||||
try {
|
||||
const uploadResult = await supa.storage.from('zhipao').upload(remotePath, localPath, {})
|
||||
if (uploadResult.status == 200 || uploadResult.status == 201) {
|
||||
const data = uploadResult.data
|
||||
if (data != null) {
|
||||
const dataObj = data as UTSJSONObject
|
||||
const key = dataObj.getString('Key')
|
||||
if (key != null && key != '') {
|
||||
return `${supa.baseUrl}/storage/v1/object/public/${key}`
|
||||
}
|
||||
}
|
||||
}
|
||||
console.error('上传图片失败:', uploadResult.error)
|
||||
return localPath
|
||||
} catch (e) {
|
||||
console.error('上传图片异常:', e)
|
||||
return localPath
|
||||
}
|
||||
},
|
||||
|
||||
>>>>>>> local-backup-root-cyj
|
||||
async saveShop() {
|
||||
if (!this.shop.shop_name) {
|
||||
uni.showToast({ title: '请输入店铺名称', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
uni.showLoading({ title: '保存中...' })
|
||||
|
||||
try {
|
||||
@@ -149,6 +188,27 @@
|
||||
shop_name: this.shop.shop_name,
|
||||
shop_logo: this.shop.shop_logo,
|
||||
shop_banner: this.shop.shop_banner,
|
||||
=======
|
||||
uni.showLoading({ title: '正在上传图片...' })
|
||||
|
||||
try {
|
||||
let finalLogo = this.shop.shop_logo
|
||||
if (finalLogo != '' && !finalLogo.startsWith('http')) {
|
||||
finalLogo = await this.uploadImageToSupa(finalLogo)
|
||||
}
|
||||
|
||||
let finalBanner = this.shop.shop_banner
|
||||
if (finalBanner != '' && !finalBanner.startsWith('http')) {
|
||||
finalBanner = await this.uploadImageToSupa(finalBanner)
|
||||
}
|
||||
|
||||
uni.showLoading({ title: '保存中...' })
|
||||
|
||||
const shopData = {
|
||||
shop_name: this.shop.shop_name,
|
||||
shop_logo: finalLogo,
|
||||
shop_banner: finalBanner,
|
||||
>>>>>>> local-backup-root-cyj
|
||||
description: this.shop.description,
|
||||
contact_name: this.shop.contact_name,
|
||||
contact_phone: this.shop.contact_phone,
|
||||
|
||||
Reference in New Issue
Block a user