Ship signup sheet, subscribe reminders, cover crop, and theme updates.
Wire real WeChat app config, prefer activity cover over posters, and add admin cover cropping for the home banner. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,12 +12,29 @@ function chooseOne(mediaType) {
|
||||
success: (res) => {
|
||||
const file = res.tempFiles && res.tempFiles[0]
|
||||
if (file && file.tempFilePath) resolve(file.tempFilePath)
|
||||
else reject(new Error('未选择文件'))
|
||||
},
|
||||
fail: reject
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Crop to a wide banner ratio before upload (closest built-in scale is 16:9).
|
||||
function cropCover(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!wx.cropImage) {
|
||||
resolve(filePath)
|
||||
return
|
||||
}
|
||||
wx.cropImage({
|
||||
src: filePath,
|
||||
cropScale: '16:9',
|
||||
success: (res) => resolve(res.tempFilePath || filePath),
|
||||
fail: () => resolve(filePath)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function uploadWithLoading(filePath) {
|
||||
wx.showLoading({ title: '上传中', mask: true })
|
||||
return api.uploadMedia(filePath).then(
|
||||
@@ -71,6 +88,7 @@ Page({
|
||||
|
||||
pickCover() {
|
||||
chooseOne('image')
|
||||
.then(cropCover)
|
||||
.then(uploadWithLoading)
|
||||
.then((data) => this.setData({ cover: data.url, coverPreview: media.absUrl(data.url) }))
|
||||
.catch((error) => {
|
||||
|
||||
Reference in New Issue
Block a user