功能:同步小程序流程

This commit is contained in:
xiaowang
2026-05-23 18:45:41 +08:00
parent 844516988b
commit 30ae763e18
117 changed files with 8823 additions and 76 deletions
@@ -1,23 +1,71 @@
/**
* Purpose: productApi supports index.js by holding or executing the product api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const productApi = require('../../api/product')
/**
* Purpose: tagApi supports index.js by holding or executing the tag api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const tagApi = require('../../api/tag')
/**
* Purpose: userApi supports index.js by holding or executing the user api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const userApi = require('../../api/user')
/**
* Purpose: couponApi supports index.js by holding or executing the coupon api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const couponApi = require('../../api/coupon')
/**
* Purpose: shopApi supports index.js by holding or executing the shop api page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const shopApi = require('../../api/shop')
/**
* Purpose: navigation supports index.js by holding or executing the navigation page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const navigation = require('../../utils/navigation')
/**
* Purpose: format supports index.js by holding or executing the format page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const format = require('../../utils/format')
/**
* Purpose: cache supports index.js by holding or executing the cache page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const cache = require('../../utils/cache')
/**
* Purpose: upload supports index.js by holding or executing the upload page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const upload = require('../../utils/upload')
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
const { getDraftValue, clearDraft, scheduleDraftSave, clearDraftTimer } = require('../../utils/form-draft')
const { markDirty } = require('../../utils/page-state')
const { CACHE_TTL } = require('../../utils/config')
/**
* Purpose: DRAFT_KEY supports index.js by holding or executing the draft key page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const DRAFT_KEY = 'admin-product-form'
/**
* Purpose: normalizeId supports index.js by holding or executing the normalize id page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function normalizeId(value) {
return value === undefined || value === null ? '' : String(value)
}
/**
* Purpose: buildCheckableList supports index.js by holding or executing the build checkable list page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function buildCheckableList(list, selectedIds, labelKey) {
return (Array.isArray(list) ? list : []).map(item => ({
...item,
@@ -27,41 +75,133 @@ function buildCheckableList(list, selectedIds, labelKey) {
}))
}
/**
* Purpose: syncSelectedIds supports index.js by holding or executing the sync selected ids page or API role.
* Usage: import, call, read, or update this function from the owning page/module while preserving the surrounding loading and permission flow.
*/
function syncSelectedIds(selectedIds, list) {
const availableIds = new Set((Array.isArray(list) ? list : []).map(item => normalizeId(item.id)))
return (Array.isArray(selectedIds) ? selectedIds : []).filter(id => availableIds.has(normalizeId(id)))
}
Page({
/**
* Purpose: data supports index.js by holding or executing the data page or API role.
* Usage: import, call, read, or update this page-data from the owning page/module while preserving the surrounding loading and permission flow.
*/
data: {
/**
* Purpose: mode supports index.js by holding or executing the mode page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
mode: 'create',
/**
* Purpose: productId supports index.js by holding or executing the product id page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
productId: '',
/**
* Purpose: shops supports index.js by holding or executing the shops page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shops: [],
/**
* Purpose: shopIndex supports index.js by holding or executing the shop index page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopIndex: 0,
/**
* Purpose: shopLabel supports index.js by holding or executing the shop label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopLabel: '',
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: [],
/**
* Purpose: artists supports index.js by holding or executing the artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
artists: [],
/**
* Purpose: coupons supports index.js by holding or executing the coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
coupons: [],
/**
* Purpose: uploading supports index.js by holding or executing the uploading page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploading: false,
/**
* Purpose: uploadProgress supports index.js by holding or executing the upload progress page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploadProgress: 0,
/**
* Purpose: form supports index.js by holding or executing the form page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
form: {
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '',
/**
* Purpose: description supports index.js by holding or executing the description page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
description: '',
/**
* Purpose: price supports index.js by holding or executing the price page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
price: '',
/**
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
approximateDuration: '',
/**
* Purpose: likeCount supports index.js by holding or executing the like count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
likeCount: '',
/**
* Purpose: collectCount supports index.js by holding or executing the collect count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
collectCount: '',
/**
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
imageFileIds: [],
/**
* Purpose: shopId supports index.js by holding or executing the shop id page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopId: ''
}
},
/**
* Purpose: onLoad supports index.js by holding or executing the on load page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
onLoad(options) {
const mode = options && options.mode ? options.mode : 'create'
const currentProduct = getTempRecord('currentProduct', null)
const draft = getDraftValue(DRAFT_KEY, null)
this.setData({
mode,
/**
* Purpose: productId supports index.js by holding or executing the product id page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
productId: options && options.id ? options.id : ''
})
@@ -75,14 +215,50 @@ Page({
this._selectedCouponIds = format.splitCsv(currentProduct.availableCoupons)
this._initialShopId = currentProduct.shopId
this.setData({
/**
* Purpose: form supports index.js by holding or executing the form page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
form: {
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: currentProduct.title || '',
/**
* Purpose: description supports index.js by holding or executing the description page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
description: currentProduct.description || '',
/**
* Purpose: price supports index.js by holding or executing the price page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
price: currentProduct.price || '',
/**
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
approximateDuration: currentProduct.approximateDuration || '',
/**
* Purpose: likeCount supports index.js by holding or executing the like count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
likeCount: currentProduct.likeCount || '',
/**
* Purpose: collectCount supports index.js by holding or executing the collect count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
collectCount: currentProduct.collectCount || '',
/**
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
imageFileIds: format.splitCsv(currentProduct.imageFileIds),
/**
* Purpose: shopId supports index.js by holding or executing the shop id page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopId: currentProduct.shopId || ''
}
})
@@ -94,6 +270,10 @@ Page({
this._selectedCouponIds = Array.isArray(draft.selectedCouponIds) ? draft.selectedCouponIds : this._selectedCouponIds
this._initialShopId = draft.form && draft.form.shopId ? draft.form.shopId : this._initialShopId
this.setData({
/**
* Purpose: form supports index.js by holding or executing the form page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
form: {
...this.data.form,
...(draft.form || {})
@@ -104,20 +284,52 @@ Page({
this.loadDependencies()
},
/**
* Purpose: onUnload supports index.js by holding or executing the on unload page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
onUnload() {
clearTempRecord('currentProduct')
clearDraftTimer(this)
},
/**
* Purpose: scheduleProductDraft supports index.js by holding or executing the schedule product draft page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
scheduleProductDraft() {
scheduleDraftSave(this, DRAFT_KEY, () => ({
/**
* Purpose: mode supports index.js by holding or executing the mode page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
mode: this.data.mode,
/**
* Purpose: form supports index.js by holding or executing the form page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
form: {
...this.data.form,
/**
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
imageFileIds: this.data.form.imageFileIds.slice()
},
/**
* Purpose: selectedTagIds supports index.js by holding or executing the selected tag ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
selectedTagIds: this._selectedTagIds.slice(),
/**
* Purpose: selectedArtistIds supports index.js by holding or executing the selected artist ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
selectedArtistIds: this._selectedArtistIds.slice(),
/**
* Purpose: selectedCouponIds supports index.js by holding or executing the selected coupon ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
selectedCouponIds: this._selectedCouponIds.slice()
}))
},
@@ -147,6 +359,10 @@ Page({
this.setData({
shops,
shopIndex,
/**
* Purpose: shopLabel supports index.js by holding or executing the shop label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopLabel: selectedShop ? selectedShop.shopName : '',
'form.shopId': selectedShop ? selectedShop.id : ''
})
@@ -154,7 +370,15 @@ Page({
await this.loadShopScopedOptions(selectedShop ? selectedShop.id : '')
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '初始化作品表单失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
}
@@ -166,8 +390,20 @@ Page({
this._selectedArtistIds = []
this._selectedCouponIds = []
this.setData({
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: [],
/**
* Purpose: artists supports index.js by holding or executing the artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
artists: [],
/**
* Purpose: coupons supports index.js by holding or executing the coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
coupons: []
})
return
@@ -185,24 +421,60 @@ Page({
this._selectedCouponIds = syncSelectedIds(this._selectedCouponIds, couponList)
this.setData({
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: buildCheckableList(tagList, this._selectedTagIds, 'tagName'),
/**
* Purpose: artists supports index.js by holding or executing the artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
artists: buildCheckableList(artistList, this._selectedArtistIds, 'nickname'),
/**
* Purpose: coupons supports index.js by holding or executing the coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
coupons: buildCheckableList(couponList, this._selectedCouponIds, 'couponName')
})
this.scheduleProductDraft()
} catch (error) {
this.setData({
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: [],
/**
* Purpose: artists supports index.js by holding or executing the artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
artists: [],
/**
* Purpose: coupons supports index.js by holding or executing the coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
coupons: []
})
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '店铺关联数据加载失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
}
},
/**
* Purpose: handleInputChange supports index.js by holding or executing the handle input change page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleInputChange(event) {
const field = event.currentTarget.dataset.field
this.setData({
@@ -211,11 +483,19 @@ Page({
this.scheduleProductDraft()
},
/**
* Purpose: handleShopChange supports index.js by holding or executing the handle shop change page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleShopChange(event) {
const shopIndex = Number(event.detail.value)
const selectedShop = this.data.shops[shopIndex]
this.setData({
shopIndex,
/**
* Purpose: shopLabel supports index.js by holding or executing the shop label page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopLabel: selectedShop ? selectedShop.shopName : '',
'form.shopId': selectedShop ? selectedShop.id : ''
})
@@ -223,33 +503,69 @@ Page({
this.scheduleProductDraft()
},
/**
* Purpose: handleTagChange supports index.js by holding or executing the handle tag change page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleTagChange(event) {
this._selectedTagIds = event.detail.value || []
this.setData({
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: this.data.tags.map(item => ({
...item,
/**
* Purpose: checked supports index.js by holding or executing the checked page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
checked: this._selectedTagIds.includes(item.valueId)
}))
})
this.scheduleProductDraft()
},
/**
* Purpose: handleArtistChange supports index.js by holding or executing the handle artist change page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleArtistChange(event) {
this._selectedArtistIds = event.detail.value || []
this.setData({
/**
* Purpose: artists supports index.js by holding or executing the artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
artists: this.data.artists.map(item => ({
...item,
/**
* Purpose: checked supports index.js by holding or executing the checked page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
checked: this._selectedArtistIds.includes(item.valueId)
}))
})
this.scheduleProductDraft()
},
/**
* Purpose: handleCouponChange supports index.js by holding or executing the handle coupon change page or API role.
* Usage: import, call, read, or update this method from the owning page/module while preserving the surrounding loading and permission flow.
*/
handleCouponChange(event) {
this._selectedCouponIds = event.detail.value || []
this.setData({
/**
* Purpose: coupons supports index.js by holding or executing the coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
coupons: this.data.coupons.map(item => ({
...item,
/**
* Purpose: checked supports index.js by holding or executing the checked page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
checked: this._selectedCouponIds.includes(item.valueId)
}))
})
@@ -260,14 +576,34 @@ Page({
try {
const files = await upload.chooseImageFiles({ count: 9 })
this.setData({
/**
* Purpose: uploading supports index.js by holding or executing the uploading page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploading: true,
/**
* Purpose: uploadProgress supports index.js by holding or executing the upload progress page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploadProgress: 0
})
const result = await upload.uploadImageFiles({
files,
/**
* Purpose: scene supports index.js by holding or executing the scene page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
scene: 'admin-product-image',
/**
* Purpose: onProgress supports index.js by holding or executing the on progress page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
onProgress: progress => {
this.setData({
/**
* Purpose: uploadProgress supports index.js by holding or executing the upload progress page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploadProgress: Math.round(progress)
})
}
@@ -279,11 +615,23 @@ Page({
this.scheduleProductDraft()
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '图片上传失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
} finally {
this.setData({
/**
* Purpose: uploading supports index.js by holding or executing the uploading page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
uploading: false
})
}
@@ -292,37 +640,105 @@ Page({
async handleSubmit() {
if (!this.data.form.title) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '请输入作品标题',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
return
}
if (!this.data.form.shopId) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '请选择所属店铺',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
return
}
if (!this.data.form.price) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: '请输入作品价格',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
return
}
const payload = {
/**
* Purpose: shopId supports index.js by holding or executing the shop id page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
shopId: this.data.form.shopId || undefined,
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: this.data.form.title,
/**
* Purpose: description supports index.js by holding or executing the description page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
description: this.data.form.description || undefined,
/**
* Purpose: imageFileIds supports index.js by holding or executing the image file ids page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
imageFileIds: this.data.form.imageFileIds.join(',') || undefined,
/**
* Purpose: price supports index.js by holding or executing the price page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
price: Number(this.data.form.price),
/**
* Purpose: tags supports index.js by holding or executing the tags page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
tags: this._selectedTagIds.join(',') || undefined,
/**
* Purpose: likeCount supports index.js by holding or executing the like count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
likeCount: this.data.form.likeCount ? Number(this.data.form.likeCount) : undefined,
/**
* Purpose: collectCount supports index.js by holding or executing the collect count page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
collectCount: this.data.form.collectCount ? Number(this.data.form.collectCount) : undefined,
/**
* Purpose: approximateDuration supports index.js by holding or executing the approximate duration page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
approximateDuration: this.data.form.approximateDuration || undefined,
/**
* Purpose: bookableArtists supports index.js by holding or executing the bookable artists page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
bookableArtists: this._selectedArtistIds.join(',') || undefined,
/**
* Purpose: availableCoupons supports index.js by holding or executing the available coupons page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
availableCoupons: this._selectedCouponIds.join(',') || undefined
}
@@ -335,13 +751,29 @@ Page({
clearDraft(DRAFT_KEY)
markDirty('admin-products')
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: this.data.mode === 'edit' ? '作品已更新' : '作品已创建',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
navigation.goBack('/pages/products/index')
} catch (error) {
wx.showToast({
/**
* Purpose: title supports index.js by holding or executing the title page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
title: error.message || '保存失败',
/**
* Purpose: icon supports index.js by holding or executing the icon page or API role.
* Usage: import, call, read, or update this page-data-field from the owning page/module while preserving the surrounding loading and permission flow.
*/
icon: 'none'
})
}