功能:同步小程序流程
This commit is contained in:
@@ -1,16 +1,52 @@
|
||||
/**
|
||||
* Purpose: artistApi supports index.js by holding or executing the artist 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 artistApi = require('../../api/nail-artist')
|
||||
/**
|
||||
* 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: 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: 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: 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')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@@ -20,11 +56,19 @@ 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)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: filterProductsByShop supports index.js by holding or executing the filter products by shop 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 filterProductsByShop(products, shopId) {
|
||||
const targetShopId = normalizeId(shopId)
|
||||
if (!targetShopId) {
|
||||
@@ -35,36 +79,128 @@ function filterProductsByShop(products, shopId) {
|
||||
}
|
||||
|
||||
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: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* 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: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: ['营业中', '休息中'],
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: 0,
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: artistForm supports index.js by holding or executing the artist 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.
|
||||
*/
|
||||
artistForm: {
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: '',
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: '',
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: '',
|
||||
/**
|
||||
* Purpose: portfolioText supports index.js by holding or executing the portfolio text 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.
|
||||
*/
|
||||
portfolioText: ''
|
||||
},
|
||||
/**
|
||||
* 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: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: []
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 currentArtist = getTempRecord('currentArtist', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: options && options.userId ? options.userId : ''
|
||||
})
|
||||
|
||||
@@ -77,19 +213,67 @@ Page({
|
||||
this._selectedProductIds = format.splitCsv(currentArtist.portfolio)
|
||||
this._initialShopId = currentArtist.shopId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: artistForm supports index.js by holding or executing the artist 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.
|
||||
*/
|
||||
artistForm: {
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: currentArtist.identity || '',
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: currentArtist.experience || '',
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: currentArtist.rating || '',
|
||||
/**
|
||||
* Purpose: portfolioText supports index.js by holding or executing the portfolio text 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.
|
||||
*/
|
||||
portfolioText: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: currentArtist.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: currentArtist.signature || ''
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: Number(currentArtist.status) === 0 ? 1 : 0
|
||||
})
|
||||
}
|
||||
@@ -97,6 +281,10 @@ 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('currentArtist')
|
||||
},
|
||||
@@ -132,11 +320,35 @@ Page({
|
||||
const userRecord = (Array.isArray(users) ? users : []).find(item => normalizeId(item.id) === normalizeId(this.data.userId))
|
||||
if (userRecord) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: userForm supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userForm: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: userRecord.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: userRecord.account || '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: userRecord.phone || '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: userRecord.signature || ''
|
||||
}
|
||||
})
|
||||
@@ -144,15 +356,31 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* 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: availableShops,
|
||||
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 : ''
|
||||
})
|
||||
|
||||
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'
|
||||
})
|
||||
}
|
||||
@@ -163,7 +391,15 @@ Page({
|
||||
this._selectedTagIds = []
|
||||
this._selectedProductIds = []
|
||||
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: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: []
|
||||
})
|
||||
return
|
||||
@@ -175,21 +411,49 @@ Page({
|
||||
this._selectedTagIds = syncSelectedIds(this._selectedTagIds, tagList)
|
||||
this._selectedProductIds = syncSelectedIds(this._selectedProductIds, productList)
|
||||
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: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: buildCheckableList(productList, this._selectedProductIds, 'title')
|
||||
})
|
||||
} 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: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
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: 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: handleUserInput supports index.js by holding or executing the handle user input 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.
|
||||
*/
|
||||
handleUserInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
let value = event.detail.value
|
||||
@@ -206,6 +470,10 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleArtistInput supports index.js by holding or executing the handle artist input 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.
|
||||
*/
|
||||
handleArtistInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -213,42 +481,86 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 : ''
|
||||
})
|
||||
this.loadShopScopedOptions(selectedShop ? selectedShop.id : '')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleProductChange supports index.js by holding or executing the handle product 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.
|
||||
*/
|
||||
handleProductChange(event) {
|
||||
this._selectedProductIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: products supports index.js by holding or executing the products 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.
|
||||
*/
|
||||
products: this.data.products.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._selectedProductIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
if (!this.data.userForm.nickname) {
|
||||
return '请输入美甲师昵称'
|
||||
@@ -272,7 +584,15 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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
|
||||
@@ -280,11 +600,35 @@ Page({
|
||||
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
const userPayload = {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.userForm.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.userForm.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.userForm.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.userForm.signature || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: 3,
|
||||
/**
|
||||
* Purpose: shopIds supports index.js by holding or executing the shop 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.
|
||||
*/
|
||||
shopIds: selectedShop ? [Number(selectedShop.id)] : []
|
||||
}
|
||||
|
||||
@@ -301,26 +645,82 @@ Page({
|
||||
}
|
||||
|
||||
await artistApi.saveNailArtistInfo({
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: Number(targetUserId),
|
||||
/**
|
||||
* Purpose: identity supports index.js by holding or executing the identity 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.
|
||||
*/
|
||||
identity: this.data.artistForm.identity || undefined,
|
||||
/**
|
||||
* Purpose: experience supports index.js by holding or executing the experience 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.
|
||||
*/
|
||||
experience: this.data.artistForm.experience ? Number(this.data.artistForm.experience) : 0,
|
||||
/**
|
||||
* Purpose: skills supports index.js by holding or executing the skills 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.
|
||||
*/
|
||||
skills: this._selectedTagIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: rating supports index.js by holding or executing the rating 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.
|
||||
*/
|
||||
rating: this.data.artistForm.rating ? Number(this.data.artistForm.rating) : 0,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.statusIndex === 1 ? 0 : 1,
|
||||
/**
|
||||
* Purpose: portfolio supports index.js by holding or executing the portfolio 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.
|
||||
*/
|
||||
portfolio: this._selectedProductIds.join(',') || undefined,
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.userForm.nickname,
|
||||
/**
|
||||
* 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: selectedShop ? Number(selectedShop.id) : undefined,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.userForm.signature || undefined
|
||||
})
|
||||
|
||||
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/artists/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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,37 @@
|
||||
/**
|
||||
* Purpose: artistApi supports index.js by holding or executing the artist 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 artistApi = require('../../api/nail-artist')
|
||||
/**
|
||||
* 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入美甲师管理')) {
|
||||
return
|
||||
@@ -15,6 +39,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('user:create') || permissionCodes.includes('nail_artist:edit')
|
||||
})
|
||||
this.loadArtists()
|
||||
@@ -24,31 +52,67 @@ Page({
|
||||
try {
|
||||
const list = await artistApi.listNailArtists()
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status text 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.
|
||||
*/
|
||||
displayStatusText: Number(item.status) === 0 ? '休息中' : '营业中'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentArtist')
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const artist = event.currentTarget.dataset.artist
|
||||
setTempRecord('currentArtist', artist)
|
||||
navigation.navigate('/pages/artist-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: artist.userId
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,36 @@
|
||||
/**
|
||||
* Purpose: commentApi supports index.js by holding or executing the comment 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 commentApi = require('../../api/comment')
|
||||
|
||||
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: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments 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.
|
||||
*/
|
||||
comments: []
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
this.loadComments()
|
||||
},
|
||||
@@ -16,8 +40,16 @@ Page({
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
@@ -26,14 +58,30 @@ Page({
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const comments = await commentApi.listComments({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: comments supports index.js by holding or executing the comments 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.
|
||||
*/
|
||||
comments: Array.isArray(comments) ? comments : []
|
||||
})
|
||||
} 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 {
|
||||
@@ -41,19 +89,43 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadComments()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle delete 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '确认删除这条评论?',
|
||||
/**
|
||||
* Purpose: confirmText supports index.js by holding or executing the confirm text 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.
|
||||
*/
|
||||
confirmText: '删除',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async res => {
|
||||
if (!res.confirm) {
|
||||
return
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
/**
|
||||
* 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: 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: 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')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* 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,
|
||||
@@ -18,47 +46,167 @@ 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: couponId supports index.js by holding or executing the coupon 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.
|
||||
*/
|
||||
couponId: '',
|
||||
/**
|
||||
* 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: couponTypeOptions supports index.js by holding or executing the coupon type options 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.
|
||||
*/
|
||||
couponTypeOptions: ['折扣券', '满减券'],
|
||||
/**
|
||||
* Purpose: couponTypeIndex supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponTypeIndex: 0,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponTypeLabel: '折扣券',
|
||||
/**
|
||||
* Purpose: vipLevelOptions supports index.js by holding or executing the vip level options 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.
|
||||
*/
|
||||
vipLevelOptions: ['普通', '青铜', '白银', '黄金'],
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelIndex: 0,
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelLabel: '普通',
|
||||
/**
|
||||
* Purpose: startDate supports index.js by holding or executing the start date 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.
|
||||
*/
|
||||
startDate: '',
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: '',
|
||||
/**
|
||||
* Purpose: endDate supports index.js by holding or executing the end date 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.
|
||||
*/
|
||||
endDate: '',
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: '',
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTags: [],
|
||||
/**
|
||||
* 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: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: '',
|
||||
/**
|
||||
* Purpose: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: '',
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: '',
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: '',
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: '',
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: '',
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon 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.
|
||||
*/
|
||||
couponScene: '',
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: false
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 currentCoupon = getTempRecord('currentCoupon', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: couponId supports index.js by holding or executing the coupon 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.
|
||||
*/
|
||||
couponId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
@@ -72,23 +220,91 @@ Page({
|
||||
this._selectedUnavailableTagIds = Array.isArray(currentCoupon.unavailableTags) ? currentCoupon.unavailableTags.map(item => String(item.id)) : []
|
||||
this._initialShopId = currentCoupon.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: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: currentCoupon.couponName || '',
|
||||
/**
|
||||
* Purpose: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: currentCoupon.couponCode || '',
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: currentCoupon.discountValue || '',
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: currentCoupon.minAmount || '',
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: currentCoupon.reduceAmount || '',
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: currentCoupon.totalCount || '',
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon 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.
|
||||
*/
|
||||
couponScene: currentCoupon.couponScene || '',
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: Number(currentCoupon.autoMatch) === 1
|
||||
},
|
||||
/**
|
||||
* Purpose: couponTypeIndex supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponTypeIndex: Number(currentCoupon.couponType) === 2 ? 1 : 0,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponTypeLabel: Number(currentCoupon.couponType) === 2 ? '满减券' : '折扣券',
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelIndex: this.data.vipLevelOptions.findIndex(item => item === (currentCoupon.requiredVipLevel || '普通')),
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelLabel: currentCoupon.requiredVipLevel || '普通',
|
||||
/**
|
||||
* Purpose: startDate supports index.js by holding or executing the start date 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.
|
||||
*/
|
||||
startDate: start.date,
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: start.time,
|
||||
/**
|
||||
* Purpose: endDate supports index.js by holding or executing the end date 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.
|
||||
*/
|
||||
endDate: end.date,
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: end.time
|
||||
})
|
||||
}
|
||||
@@ -96,6 +312,10 @@ 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('currentCoupon')
|
||||
},
|
||||
@@ -125,13 +345,25 @@ 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 : ''
|
||||
})
|
||||
|
||||
await this.loadTagOptions(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'
|
||||
})
|
||||
}
|
||||
@@ -142,7 +374,15 @@ Page({
|
||||
this._selectedAvailableTagIds = []
|
||||
this._selectedUnavailableTagIds = []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTags: []
|
||||
})
|
||||
return
|
||||
@@ -153,21 +393,49 @@ Page({
|
||||
this._selectedAvailableTagIds = syncSelectedIds(this._selectedAvailableTagIds, tagList)
|
||||
this._selectedUnavailableTagIds = syncSelectedIds(this._selectedUnavailableTagIds, tagList)
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTags: buildCheckableList(tagList, this._selectedAvailableTagIds, 'tagName'),
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTags: buildCheckableList(tagList, this._selectedUnavailableTagIds, 'tagName')
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTags: [],
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTags: []
|
||||
})
|
||||
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
|
||||
const value = event.detail.value
|
||||
@@ -176,32 +444,60 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 : ''
|
||||
})
|
||||
this.loadTagOptions(selectedShop ? selectedShop.id : '')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCouponTypeChange supports index.js by holding or executing the handle coupon type 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.
|
||||
*/
|
||||
handleCouponTypeChange(event) {
|
||||
const couponTypeIndex = Number(event.detail.value)
|
||||
this.setData({
|
||||
couponTypeIndex,
|
||||
/**
|
||||
* Purpose: couponTypeLabel supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponTypeLabel: this.data.couponTypeOptions[couponTypeIndex]
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipLevelChange supports index.js by holding or executing the handle vip level 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.
|
||||
*/
|
||||
handleVipLevelChange(event) {
|
||||
const vipLevelIndex = Number(event.detail.value)
|
||||
this.setData({
|
||||
vipLevelIndex,
|
||||
/**
|
||||
* Purpose: vipLevelLabel supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelLabel: this.data.vipLevelOptions[vipLevelIndex]
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDateTimeChange supports index.js by holding or executing the handle date time 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.
|
||||
*/
|
||||
handleDateTimeChange(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -209,27 +505,55 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAutoMatchChange supports index.js by holding or executing the handle auto match 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.
|
||||
*/
|
||||
handleAutoMatchChange(event) {
|
||||
this.setData({
|
||||
'form.autoMatch': event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAvailableTagChange supports index.js by holding or executing the handle available 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.
|
||||
*/
|
||||
handleAvailableTagChange(event) {
|
||||
this._selectedAvailableTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: availableTags supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTags: this.data.availableTags.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._selectedAvailableTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleUnavailableTagChange supports index.js by holding or executing the handle unavailable 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.
|
||||
*/
|
||||
handleUnavailableTagChange(event) {
|
||||
this._selectedUnavailableTagIds = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: unavailableTags supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTags: this.data.unavailableTags.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._selectedUnavailableTagIds.includes(item.valueId)
|
||||
}))
|
||||
})
|
||||
@@ -239,34 +563,110 @@ Page({
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
if (!this.data.form.couponName) {
|
||||
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 (!selectedShop) {
|
||||
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: couponCode supports index.js by holding or executing the coupon code 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.
|
||||
*/
|
||||
couponCode: this.data.form.couponCode || undefined,
|
||||
/**
|
||||
* Purpose: couponName supports index.js by holding or executing the coupon name 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.
|
||||
*/
|
||||
couponName: this.data.form.couponName,
|
||||
/**
|
||||
* Purpose: couponType supports index.js by holding or executing the coupon type 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.
|
||||
*/
|
||||
couponType: this.data.couponTypeIndex === 1 ? 2 : 1,
|
||||
/**
|
||||
* Purpose: discountValue supports index.js by holding or executing the discount value 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.
|
||||
*/
|
||||
discountValue: this.data.couponTypeIndex === 0 ? Number(this.data.form.discountValue || 0) : undefined,
|
||||
/**
|
||||
* Purpose: minAmount supports index.js by holding or executing the min amount 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.
|
||||
*/
|
||||
minAmount: this.data.couponTypeIndex === 1 ? Number(this.data.form.minAmount || 0) : undefined,
|
||||
/**
|
||||
* Purpose: reduceAmount supports index.js by holding or executing the reduce amount 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.
|
||||
*/
|
||||
reduceAmount: this.data.couponTypeIndex === 1 ? Number(this.data.form.reduceAmount || 0) : undefined,
|
||||
/**
|
||||
* Purpose: totalCount supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
totalCount: this.data.form.totalCount ? Number(this.data.form.totalCount) : undefined,
|
||||
/**
|
||||
* Purpose: startTime supports index.js by holding or executing the start time 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.
|
||||
*/
|
||||
startTime: format.buildDateTime(this.data.startDate, this.data.startTime),
|
||||
/**
|
||||
* Purpose: endTime supports index.js by holding or executing the end time 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.
|
||||
*/
|
||||
endTime: format.buildDateTime(this.data.endDate, this.data.endTime),
|
||||
/**
|
||||
* 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: selectedShop.id,
|
||||
/**
|
||||
* Purpose: couponScene supports index.js by holding or executing the coupon 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.
|
||||
*/
|
||||
couponScene: this.data.form.couponScene || undefined,
|
||||
/**
|
||||
* Purpose: requiredVipLevel supports index.js by holding or executing the required vip level 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.
|
||||
*/
|
||||
requiredVipLevel: this.data.vipLevelLabel || undefined,
|
||||
/**
|
||||
* Purpose: autoMatch supports index.js by holding or executing the auto match 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.
|
||||
*/
|
||||
autoMatch: this.data.form.autoMatch ? 1 : 0,
|
||||
/**
|
||||
* Purpose: availableTagIds supports index.js by holding or executing the available 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.
|
||||
*/
|
||||
availableTagIds: this._selectedAvailableTagIds.map(item => Number(item)),
|
||||
/**
|
||||
* Purpose: unavailableTagIds supports index.js by holding or executing the unavailable 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.
|
||||
*/
|
||||
unavailableTagIds: this._selectedUnavailableTagIds.map(item => Number(item))
|
||||
}
|
||||
|
||||
@@ -277,13 +677,29 @@ Page({
|
||||
await couponApi.createCoupon(payload)
|
||||
}
|
||||
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/coupons/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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,14 +1,42 @@
|
||||
/**
|
||||
* 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: 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: 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入优惠券管理')) {
|
||||
return
|
||||
@@ -16,6 +44,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('coupon:create')
|
||||
})
|
||||
this.loadCoupons()
|
||||
@@ -24,54 +56,130 @@ Page({
|
||||
async loadCoupons() {
|
||||
try {
|
||||
const result = await couponApi.listCoupons({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type text 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.
|
||||
*/
|
||||
displayTypeText: format.getCouponTypeText(item.couponType),
|
||||
/**
|
||||
* Purpose: displayValueText supports index.js by holding or executing the display value text 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.
|
||||
*/
|
||||
displayValueText: format.getCouponValueText(item),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentCoupon')
|
||||
navigation.navigate('/pages/coupon-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
setTempRecord('currentCoupon', coupon)
|
||||
navigation.navigate('/pages/coupon-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: coupon.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDistribute supports index.js by holding or executing the handle distribute 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.
|
||||
*/
|
||||
handleDistribute(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
setTempRecord('currentCoupon', coupon)
|
||||
navigation.navigate('/pages/coupon-distribute/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: coupon.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle delete 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const coupon = event.currentTarget.dataset.coupon
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除优惠券“${coupon.couponName}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -79,13 +187,29 @@ Page({
|
||||
try {
|
||||
await couponApi.deleteCoupon(coupon.id)
|
||||
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'
|
||||
})
|
||||
this.loadCoupons()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,31 +1,111 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth 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 authApi = require('../../api/auth')
|
||||
/**
|
||||
* Purpose: auth supports index.js by holding or executing the auth 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 auth = require('../../utils/auth')
|
||||
/**
|
||||
* 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')
|
||||
const { runWithLoading } = require('../../utils/loading')
|
||||
|
||||
/**
|
||||
* Purpose: ACCOUNT_REGEX supports index.js by holding or executing the account regex 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 ACCOUNT_REGEX = /[^A-Za-z0-9]/g
|
||||
|
||||
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: redirect supports index.js by holding or executing the redirect 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.
|
||||
*/
|
||||
redirect: '',
|
||||
/**
|
||||
* 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: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* 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: loginShops supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop message 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status text 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.
|
||||
*/
|
||||
accountStatusText: '',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: '',
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
this._lookupTicket = 0
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: redirect supports index.js by holding or executing the redirect 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.
|
||||
*/
|
||||
redirect: options && options.redirect ? options.redirect : ''
|
||||
})
|
||||
|
||||
@@ -34,12 +114,20 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
let value = event.detail.value
|
||||
@@ -57,17 +145,33 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 index = Number(event.detail.value)
|
||||
const shop = this.data.loginShops[index]
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShopIndex: index,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: shop ? shop.shopName || '' : '',
|
||||
'form.shopId': shop ? shop.id : ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: resetAccountState supports index.js by holding or executing the reset account state 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.
|
||||
*/
|
||||
resetAccountState() {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
@@ -76,17 +180,49 @@ Page({
|
||||
this._lookupTicket += 1
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status text 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.
|
||||
*/
|
||||
accountStatusText: '',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: '',
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop message 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
'form.shopId': ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleAccountLookup supports index.js by holding or executing the schedule account lookup 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.
|
||||
*/
|
||||
scheduleAccountLookup(account) {
|
||||
if (this._accountTimer) {
|
||||
clearTimeout(this._accountTimer)
|
||||
@@ -99,6 +235,10 @@ Page({
|
||||
}, 420)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: applyLoginShopSelection supports index.js by holding or executing the apply login shop selection 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.
|
||||
*/
|
||||
applyLoginShopSelection(selection) {
|
||||
const shops = Array.isArray(selection && selection.shops) ? selection.shops : []
|
||||
const allowShoplessLogin = Boolean(selection && selection.allowShoplessLogin)
|
||||
@@ -113,13 +253,29 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShops: shops,
|
||||
allowShoplessLogin,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop message 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.
|
||||
*/
|
||||
loginShopMessage: (selection && selection.message) || '',
|
||||
loginShopIndex,
|
||||
loginShopDisplayName,
|
||||
'form.shopId': shopId,
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status text 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.
|
||||
*/
|
||||
accountStatusText: shops.length || allowShoplessLogin ? '该账号可用于后台登录' : '当前账号暂时不可用于后台登录',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: shops.length || allowShoplessLogin ? 'success' : 'warning'
|
||||
})
|
||||
},
|
||||
@@ -141,18 +297,50 @@ Page({
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loginShops supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShops: [],
|
||||
/**
|
||||
* Purpose: loginShopIndex supports index.js by holding or executing the login 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.
|
||||
*/
|
||||
loginShopIndex: -1,
|
||||
/**
|
||||
* Purpose: loginShopDisplayName supports index.js by holding or executing the login shop display name 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.
|
||||
*/
|
||||
loginShopDisplayName: '',
|
||||
/**
|
||||
* Purpose: allowShoplessLogin supports index.js by holding or executing the allow shopless login 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.
|
||||
*/
|
||||
allowShoplessLogin: false,
|
||||
/**
|
||||
* Purpose: loginShopMessage supports index.js by holding or executing the login shop message 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.
|
||||
*/
|
||||
loginShopMessage: '',
|
||||
'form.shopId': '',
|
||||
/**
|
||||
* Purpose: accountStatusText supports index.js by holding or executing the account status text 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.
|
||||
*/
|
||||
accountStatusText: error.message || '该后台账号不存在或不可登录',
|
||||
/**
|
||||
* Purpose: accountStatusType supports index.js by holding or executing the account status type 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.
|
||||
*/
|
||||
accountStatusType: 'error'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
const form = this.data.form
|
||||
if (!form.account) {
|
||||
@@ -171,38 +359,82 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
const payload = await runWithLoading(() => authApi.login({
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: this.data.form.password,
|
||||
/**
|
||||
* 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
|
||||
}))
|
||||
|
||||
await getApp().setAdminSession(payload)
|
||||
|
||||
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'
|
||||
})
|
||||
|
||||
await navigation.redirectAfterLogin(this.data.redirect)
|
||||
} 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: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,41 @@
|
||||
/**
|
||||
* 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
|
||||
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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: currentShop supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShop: null,
|
||||
/**
|
||||
* Purpose: modules supports index.js by holding or executing the modules 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.
|
||||
*/
|
||||
modules: []
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入经营模块')) {
|
||||
return
|
||||
@@ -21,10 +49,18 @@ Page({
|
||||
this.setData({
|
||||
userInfo,
|
||||
currentShop,
|
||||
/**
|
||||
* Purpose: modules supports index.js by holding or executing the modules 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.
|
||||
*/
|
||||
modules: permission.getManageModules(userInfo, permissionCodes, currentShop)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module 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.
|
||||
*/
|
||||
handleOpenModule(event) {
|
||||
const module = event.currentTarget.dataset.module
|
||||
if (!module) {
|
||||
@@ -33,7 +69,15 @@ Page({
|
||||
|
||||
if (!module.allowed) {
|
||||
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: module.disabledReason || '当前账号没有进入该模块的权限',
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -1,27 +1,125 @@
|
||||
/**
|
||||
* Purpose: orderApi loads full backend order detail so direct entry and message navigation can render complete data.
|
||||
* Usage: call getOrderDetail with the current route id before displaying the order detail page.
|
||||
*/
|
||||
const orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: loading marks whether the detail endpoint is currently fetching order data.
|
||||
* Usage: bind it to loading and retry states while preserving any cached order shown on screen.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: orderId keeps the backend order id used by reload and direct-entry flows.
|
||||
* Usage: set it from route options or cached list data before calling loadOrderDetail.
|
||||
*/
|
||||
orderId: '',
|
||||
/**
|
||||
* Purpose: order supports index.js by holding or executing the order 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.
|
||||
*/
|
||||
order: null
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
const order = getTempRecord('currentOrder', null)
|
||||
/**
|
||||
* 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 cachedOrder = getTempRecord('currentOrder', null)
|
||||
const orderId = (options && options.id) || (cachedOrder && cachedOrder.id) || ''
|
||||
this.setData({
|
||||
order: order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayCreateTime: format.formatDateTime(order.createTime)
|
||||
} : null
|
||||
orderId,
|
||||
order: cachedOrder ? this.formatOrder(cachedOrder) : null
|
||||
})
|
||||
|
||||
if (orderId) {
|
||||
this.loadOrderDetail(orderId)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadOrderDetail replaces list-row summary data with the authoritative admin order-detail response.
|
||||
* Usage: call it from onLoad and retry buttons with the backend order id; failures leave cached data visible.
|
||||
*/
|
||||
async loadOrderDetail(orderId) {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const detail = await orderApi.getOrderDetail(orderId)
|
||||
this.setData({
|
||||
order: this.formatOrder(detail)
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '订单详情加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatOrder prepares order and item fields for WXML, including review and change-request summaries.
|
||||
* Usage: run every cached or fetched order object through this method before assigning it to data.order.
|
||||
*/
|
||||
formatOrder(order) {
|
||||
const items = Array.isArray(order && order.items) ? order.items : []
|
||||
return order ? {
|
||||
...order,
|
||||
displayStatusText: format.getOrderStatusText(order),
|
||||
displayCreateTime: format.formatDateTime(order.createTime),
|
||||
displayPayAmount: format.formatPrice(order.payAmount),
|
||||
items: items.map(item => ({
|
||||
...item,
|
||||
displayAppointmentTime: item.appointmentTime ? format.formatDateTime(item.appointmentTime) : '',
|
||||
reviewStatusText: item.reviewStatusText || (item.reviewSummary ? '已评价' : '待评价'),
|
||||
changeStatusText: item.pendingArtistChangeRequest ? item.pendingArtistChangeRequest.displayText : ''
|
||||
}))
|
||||
} : null
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleRetry reloads backend detail when direct entry failed or no cached data exists.
|
||||
* Usage: bind it to the empty state action so operators can recover without returning to the list.
|
||||
*/
|
||||
handleRetry() {
|
||||
if (!this.data.orderId) {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
return
|
||||
}
|
||||
this.loadOrderDetail(this.data.orderId)
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentOrder')
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack supports index.js by holding or executing the handle back 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.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/orders/index')
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">应付金额</text>
|
||||
<text class="meta-value">¥{{order.payAmount || '--'}}</text>
|
||||
<text class="meta-value">¥{{order.displayPayAmount || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">备注</text>
|
||||
@@ -33,9 +33,30 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:else class="empty-state">
|
||||
<view wx:if="{{order && order.items && order.items.length}}" class="surface-card">
|
||||
<text class="section-title">服务项目</text>
|
||||
<block wx:for="{{order.items}}" wx:key="id">
|
||||
<view class="detail-item">
|
||||
<view class="detail-item-head">
|
||||
<text class="detail-item-title">{{item.productTitle || '订单项目'}}</text>
|
||||
<text class="badge">{{item.reviewStatusText}}</text>
|
||||
</view>
|
||||
<text class="detail-item-line">美甲师:{{item.artistName || '--'}}</text>
|
||||
<text wx:if="{{item.displayAppointmentTime}}" class="detail-item-line">预约时间:{{item.displayAppointmentTime}}</text>
|
||||
<text wx:if="{{item.reviewSummary && item.reviewSummary.contentText}}" class="detail-item-line">评价内容:{{item.reviewSummary.contentText}}</text>
|
||||
<view wx:if="{{item.pendingArtistChangeRequest}}" class="change-box">
|
||||
<text class="change-title">改派申请</text>
|
||||
<text class="change-line">{{item.pendingArtistChangeRequest.displayText}}</text>
|
||||
<text wx:if="{{item.pendingArtistChangeRequest.reasonText}}" class="change-line">原因:{{item.pendingArtistChangeRequest.reasonText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{!order}}" class="empty-state">
|
||||
<text class="empty-title">订单详情暂不可用</text>
|
||||
<text class="empty-desc">当前详情页优先复用列表页已拉取的数据。如果你是直接打开该页面,请先回到订单列表重新进入。</text>
|
||||
<text class="empty-desc">当前详情页可通过列表、消息或订单 id 打开;加载失败时可重试。</text>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleRetry">重新加载</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,3 +1,55 @@
|
||||
.page-shell {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.detail-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
padding: 20rpx 0;
|
||||
border-top: 1rpx solid rgba(255, 255, 255, 0.08);
|
||||
}
|
||||
|
||||
.detail-item:first-of-type {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.detail-item-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.detail-item-title {
|
||||
color: #f6efe7;
|
||||
font-size: 30rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.detail-item-line {
|
||||
color: #9fb3ad;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.change-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8rpx;
|
||||
padding: 16rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(240, 126, 87, 0.1);
|
||||
}
|
||||
|
||||
.change-title {
|
||||
color: #f6efe7;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.change-line {
|
||||
color: #f4c7b8;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
/**
|
||||
* Purpose: orderApi supports index.js by holding or executing the order 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 orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
/**
|
||||
* 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')
|
||||
const { setTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty, markDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: STATUS_OPTIONS supports index.js by holding or executing the status options 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 STATUS_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '待服务', value: 1 },
|
||||
@@ -12,24 +32,44 @@ const STATUS_OPTIONS = [
|
||||
{ label: '已取消', value: 0 }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: toId supports index.js by holding or executing the to 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 toId(value) {
|
||||
return value === undefined || value === null ? '' : String(value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: sameId supports index.js by holding or executing the same 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 sameId(left, right) {
|
||||
const leftId = toId(left)
|
||||
const rightId = toId(right)
|
||||
return leftId !== '' && leftId === rightId
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: safeList supports index.js by holding or executing the safe 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 safeList(value) {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: trimText supports index.js by holding or executing the trim text 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 trimText(value) {
|
||||
return String(value || '').trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatRating supports index.js by holding or executing the format rating 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 formatRating(value) {
|
||||
const rating = Number(value)
|
||||
if (!isFinite(rating) || rating <= 0) {
|
||||
@@ -38,6 +78,10 @@ function formatRating(value) {
|
||||
return rating % 1 === 0 ? String(rating) : rating.toFixed(1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: isSubmittedReview supports index.js by holding or executing the is submitted review 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 isSubmittedReview(review) {
|
||||
if (!review) {
|
||||
return false
|
||||
@@ -48,6 +92,10 @@ function isSubmittedReview(review) {
|
||||
return Boolean(review.rating)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: resolveRelatedRecord supports index.js by holding or executing the resolve related record 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 resolveRelatedRecord(source, orderItemId) {
|
||||
if (Array.isArray(source)) {
|
||||
return source.find(item => sameId(item && item.orderItemId, orderItemId)) || null
|
||||
@@ -60,6 +108,10 @@ function resolveRelatedRecord(source, orderItemId) {
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildReviewSummary supports index.js by holding or executing the build review summary 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 buildReviewSummary(review) {
|
||||
if (!review || !isSubmittedReview(review)) {
|
||||
return null
|
||||
@@ -73,6 +125,10 @@ function buildReviewSummary(review) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: buildArtistChangeSummary supports index.js by holding or executing the build artist change summary 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 buildArtistChangeSummary(request) {
|
||||
if (!request) {
|
||||
return null
|
||||
@@ -86,6 +142,10 @@ function buildArtistChangeSummary(request) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: indexByOrderItemId supports index.js by holding or executing the index by order item 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 indexByOrderItemId(list) {
|
||||
return safeList(list).reduce((result, item) => {
|
||||
if (item && item.orderItemId) {
|
||||
@@ -95,6 +155,10 @@ function indexByOrderItemId(list) {
|
||||
}, {})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: safeCall supports index.js by holding or executing the safe call 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.
|
||||
*/
|
||||
async function safeCall(factory, fallbackValue) {
|
||||
try {
|
||||
const result = await factory()
|
||||
@@ -104,6 +168,10 @@ async function safeCall(factory, fallbackValue) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: loadAssistData supports index.js by holding or executing the load assist data 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.
|
||||
*/
|
||||
async function loadAssistData(orders) {
|
||||
const pendingChangesPromise = safeCall(() => orderApi.listMyPendingArtistChangeRequests(), [])
|
||||
const orderReviewListsPromise = Promise.all(orders.map(order => (
|
||||
@@ -129,6 +197,10 @@ async function loadAssistData(orders) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: hasProductionFlag supports index.js by holding or executing the has production flag 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 hasProductionFlag(userInfo) {
|
||||
const sources = [
|
||||
userInfo && userInfo.participateProduction,
|
||||
@@ -140,6 +212,10 @@ function hasProductionFlag(userInfo) {
|
||||
return sources.some(value => value === true || Number(value) === 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: canRequestArtistChangeForItem supports index.js by holding or executing the can request artist change for item 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 canRequestArtistChangeForItem(userInfo, order, item, pendingChange) {
|
||||
if (!userInfo || !order || !item || pendingChange || Number(order.status) !== 1) {
|
||||
return false
|
||||
@@ -156,6 +232,10 @@ function canRequestArtistChangeForItem(userInfo, order, item, pendingChange) {
|
||||
return permission.isShopManager(userInfo) && hasProductionFlag(userInfo)
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatOrderItem supports index.js by holding or executing the format order item 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 formatOrderItem(order, item, userInfo, assistData) {
|
||||
const itemId = toId(item.id)
|
||||
const inlineReviewSummary = resolveRelatedRecord(item.reviewSummary || order.reviewSummary, item.id)
|
||||
@@ -174,6 +254,10 @@ function formatOrderItem(order, item, userInfo, assistData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: formatOrder supports index.js by holding or executing the format order 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 formatOrder(order, userInfo, assistData) {
|
||||
const items = safeList(order.items).map(item => formatOrderItem(order, item, userInfo, assistData))
|
||||
const orderReviewSummary = buildReviewSummary(order.reviewSummary)
|
||||
@@ -188,6 +272,10 @@ function formatOrder(order, userInfo, assistData) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: selectArtist supports index.js by holding or executing the select artist 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 selectArtist(artists) {
|
||||
return new Promise(resolve => {
|
||||
wx.showActionSheet({
|
||||
@@ -198,6 +286,10 @@ function selectArtist(artists) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Purpose: promptChangeReason supports index.js by holding or executing the prompt change reason 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 promptChangeReason() {
|
||||
return new Promise(resolve => {
|
||||
wx.showModal({
|
||||
@@ -219,17 +311,57 @@ function promptChangeReason() {
|
||||
}
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: '',
|
||||
/**
|
||||
* Purpose: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: STATUS_OPTIONS,
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: total supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
total: 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入订单管理')) {
|
||||
return
|
||||
@@ -245,18 +377,34 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh supports index.js by holding or executing the on pull down refresh 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.
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
this.loadOrders().finally(() => {
|
||||
wx.stopPullDownRefresh()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
const status = event.currentTarget.dataset.status
|
||||
this.setData({
|
||||
@@ -269,14 +417,34 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await orderApi.listOrders({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.status === '' ? undefined : this.data.status
|
||||
})
|
||||
|
||||
@@ -288,8 +456,20 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: rawList.map(item => formatOrder(item, this.data.userInfo, assistData)),
|
||||
/**
|
||||
* Purpose: total supports index.js by holding or executing the total 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.
|
||||
*/
|
||||
total: Number(result && result.total) || 0,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -297,22 +477,42 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadOrders()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenOrder supports index.js by holding or executing the handle open order 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.
|
||||
*/
|
||||
handleOpenOrder(event) {
|
||||
const order = event.currentTarget.dataset.order
|
||||
if (!order) {
|
||||
@@ -321,6 +521,10 @@ Page({
|
||||
|
||||
setTempRecord('currentOrder', order)
|
||||
navigation.navigate('/pages/order-detail/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: order.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
@@ -337,7 +541,15 @@ Page({
|
||||
const artists = safeList(options && options.artists)
|
||||
if (!artists.length) {
|
||||
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
|
||||
@@ -356,18 +568,38 @@ Page({
|
||||
await orderApi.requestArtistChange({
|
||||
orderId,
|
||||
orderItemId,
|
||||
/**
|
||||
* Purpose: requestedArtistId supports index.js by holding or executing the requested artist 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.
|
||||
*/
|
||||
requestedArtistId: targetArtist.artistId,
|
||||
reason
|
||||
})
|
||||
markDirty('admin-workbench')
|
||||
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'
|
||||
})
|
||||
this.loadOrders()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -389,7 +621,15 @@ Page({
|
||||
]
|
||||
|
||||
wx.showActionSheet({
|
||||
/**
|
||||
* Purpose: itemList supports index.js by holding or executing the item list 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.
|
||||
*/
|
||||
itemList: options.map(item => item.label),
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
const target = options[result.tapIndex]
|
||||
if (!target) {
|
||||
@@ -400,13 +640,29 @@ Page({
|
||||
await orderApi.updateOrderStatus(order.id, target.status)
|
||||
markDirty('admin-workbench')
|
||||
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'
|
||||
})
|
||||
this.loadOrders()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/**
|
||||
* Purpose: permissionApi supports index.js by holding or executing the permission 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 permissionApi = require('../../api/permission')
|
||||
/**
|
||||
* 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: permissionUtils supports index.js by holding or executing the permission utils 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 permissionUtils = require('../../utils/permission')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: buildPermissionGroups supports index.js by holding or executing the build permission groups 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 buildPermissionGroups(list, checkedIds, assignableIds) {
|
||||
const groups = permissionUtils.groupPermissionsByGroup(list)
|
||||
return Object.keys(groups).map(group => ({
|
||||
@@ -17,25 +33,81 @@ function buildPermissionGroups(list, checkedIds, assignableIds) {
|
||||
}
|
||||
|
||||
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: 'definition-create',
|
||||
/**
|
||||
* 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: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* Purpose: currentUser supports index.js by holding or executing the current user 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.
|
||||
*/
|
||||
currentUser: null,
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: [],
|
||||
/**
|
||||
* 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: permissionCode supports index.js by holding or executing the permission code 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.
|
||||
*/
|
||||
permissionCode: '',
|
||||
/**
|
||||
* Purpose: permissionName supports index.js by holding or executing the permission name 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.
|
||||
*/
|
||||
permissionName: '',
|
||||
/**
|
||||
* Purpose: permissionGroup supports index.js by holding or executing the permission group 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.
|
||||
*/
|
||||
permissionGroup: '',
|
||||
/**
|
||||
* 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: 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 : 'definition-create'
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: options && options.userId ? options.userId : '',
|
||||
/**
|
||||
* 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: mode === 'assign' ? '分配权限' : (mode === 'definition-edit' ? '编辑权限' : '新增权限')
|
||||
})
|
||||
|
||||
@@ -47,16 +119,40 @@ Page({
|
||||
const currentPermission = getTempRecord('currentPermission', null)
|
||||
if (mode === 'definition-edit' && currentPermission) {
|
||||
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: permissionCode supports index.js by holding or executing the permission code 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.
|
||||
*/
|
||||
permissionCode: currentPermission.permissionCode || '',
|
||||
/**
|
||||
* Purpose: permissionName supports index.js by holding or executing the permission name 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.
|
||||
*/
|
||||
permissionName: currentPermission.permissionName || '',
|
||||
/**
|
||||
* Purpose: permissionGroup supports index.js by holding or executing the permission group 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.
|
||||
*/
|
||||
permissionGroup: currentPermission.permissionGroup || '',
|
||||
/**
|
||||
* 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: currentPermission.description || ''
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentPermission')
|
||||
},
|
||||
@@ -78,16 +174,32 @@ Page({
|
||||
const normalizedAssignableIds = (Array.isArray(assignableIds) ? assignableIds : []).map(item => String(item))
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: buildPermissionGroups(allPermissions, checkedIds, normalizedAssignableIds)
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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({
|
||||
@@ -95,13 +207,29 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePermissionCheck supports index.js by holding or executing the handle permission check 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.
|
||||
*/
|
||||
handlePermissionCheck(event) {
|
||||
const selected = event.detail.value || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: this.data.permissionGroups.map(group => ({
|
||||
...group,
|
||||
/**
|
||||
* Purpose: items supports index.js by holding or executing the items 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.
|
||||
*/
|
||||
items: group.items.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: item.disabled ? item.checked : selected.includes(item.valueId)
|
||||
}))
|
||||
}))
|
||||
@@ -122,13 +250,29 @@ Page({
|
||||
try {
|
||||
await permissionApi.assignUserPermissions(this.data.userId, permissionIds)
|
||||
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'
|
||||
})
|
||||
navigation.goBack('/pages/permissions/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'
|
||||
})
|
||||
}
|
||||
@@ -137,7 +281,15 @@ Page({
|
||||
|
||||
if (!this.data.form.permissionCode || !this.data.form.permissionName) {
|
||||
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
|
||||
@@ -151,13 +303,29 @@ Page({
|
||||
await permissionApi.createPermission(this.data.form)
|
||||
}
|
||||
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'
|
||||
})
|
||||
navigation.goBack('/pages/permissions/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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,8 +1,24 @@
|
||||
/**
|
||||
* Purpose: permissionApi supports index.js by holding or executing the permission 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 permissionApi = require('../../api/permission')
|
||||
/**
|
||||
* 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: 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: groupPermissions supports index.js by holding or executing the group permissions 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 groupPermissions(list) {
|
||||
const map = {}
|
||||
;(Array.isArray(list) ? list : []).forEach(item => {
|
||||
@@ -20,13 +36,37 @@ function groupPermissions(list) {
|
||||
}
|
||||
|
||||
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: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: [],
|
||||
/**
|
||||
* Purpose: users supports index.js by holding or executing the users 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.
|
||||
*/
|
||||
users: [],
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: canAssign supports index.js by holding or executing the can assign 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.
|
||||
*/
|
||||
canAssign: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入权限管理')) {
|
||||
return
|
||||
@@ -34,7 +74,15 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('permission:create'),
|
||||
/**
|
||||
* Purpose: canAssign supports index.js by holding or executing the can assign 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.
|
||||
*/
|
||||
canAssign: permissionCodes.includes('permission:assign')
|
||||
})
|
||||
this.loadPageData()
|
||||
@@ -47,38 +95,86 @@ Page({
|
||||
userApi.listAllUsers().catch(() => [])
|
||||
])
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: permissionGroups supports index.js by holding or executing the permission groups 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.
|
||||
*/
|
||||
permissionGroups: groupPermissions(permissions),
|
||||
/**
|
||||
* Purpose: users supports index.js by holding or executing the users 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.
|
||||
*/
|
||||
users: Array.isArray(users) ? users : []
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreatePermission supports index.js by holding or executing the handle create permission 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.
|
||||
*/
|
||||
handleCreatePermission() {
|
||||
clearTempRecord('currentPermission')
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* 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: 'definition-create'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEditPermission supports index.js by holding or executing the handle edit permission 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.
|
||||
*/
|
||||
handleEditPermission(event) {
|
||||
const permission = event.currentTarget.dataset.permission
|
||||
setTempRecord('currentPermission', permission)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* 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: 'definition-edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: permission.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAssignUser supports index.js by holding or executing the handle assign user 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.
|
||||
*/
|
||||
handleAssignUser(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* 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: 'assign',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: user.id
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,20 +1,64 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: PAGE_KEY supports index.js by holding or executing the page 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 PAGE_KEY = 'admin-products'
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入作品管理')) {
|
||||
return
|
||||
@@ -22,6 +66,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('product:create')
|
||||
})
|
||||
|
||||
@@ -30,12 +78,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadProducts()
|
||||
},
|
||||
@@ -44,13 +104,29 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await productApi.listProducts({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
if (requestId !== this._loadRequestId) {
|
||||
@@ -58,13 +134,37 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayPrice supports index.js by holding or executing the display 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.
|
||||
*/
|
||||
displayPrice: format.formatPrice(item.price),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺',
|
||||
/**
|
||||
* Purpose: displayDuration supports index.js by holding or executing the display 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.
|
||||
*/
|
||||
displayDuration: item.approximateDuration || '未设置时长',
|
||||
/**
|
||||
* Purpose: displayTagText supports index.js by holding or executing the display tag text 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.
|
||||
*/
|
||||
displayTagText: Array.isArray(item.tagList) ? item.tagList.join(' / ') : (item.tags || '未设置标签')
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -72,39 +172,87 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentProduct')
|
||||
navigation.navigate('/pages/product-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const product = event.currentTarget.dataset.product
|
||||
setTempRecord('currentProduct', product)
|
||||
navigation.navigate('/pages/product-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: product.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle delete 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const product = event.currentTarget.dataset.product
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除作品“${product.title}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -112,13 +260,29 @@ Page({
|
||||
try {
|
||||
await productApi.deleteProduct(product.id)
|
||||
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'
|
||||
})
|
||||
this.loadProducts()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,17 +1,61 @@
|
||||
/**
|
||||
* Purpose: authApi supports index.js by holding or executing the auth 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 authApi = require('../../api/auth')
|
||||
/**
|
||||
* 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
|
||||
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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: currentShop supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShop: null,
|
||||
/**
|
||||
* Purpose: permissionCodes supports index.js by holding or executing the permission codes 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.
|
||||
*/
|
||||
permissionCodes: [],
|
||||
/**
|
||||
* Purpose: roleLabel supports index.js by holding or executing the role 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.
|
||||
*/
|
||||
roleLabel: '',
|
||||
/**
|
||||
* Purpose: shopScopeText supports index.js by holding or executing the shop scope text 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.
|
||||
*/
|
||||
shopScopeText: '',
|
||||
/**
|
||||
* Purpose: currentShopText supports index.js by holding or executing the current shop text 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.
|
||||
*/
|
||||
currentShopText: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入个人中心')) {
|
||||
return
|
||||
@@ -29,17 +73,37 @@ Page({
|
||||
this.setData({
|
||||
userInfo,
|
||||
currentShop,
|
||||
/**
|
||||
* Purpose: permissionCodes supports index.js by holding or executing the permission codes 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.
|
||||
*/
|
||||
permissionCodes: app.globalData.permissionCodes || [],
|
||||
/**
|
||||
* Purpose: roleLabel supports index.js by holding or executing the role 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.
|
||||
*/
|
||||
roleLabel: userInfo ? permission.getRoleLabel(userInfo.type) : '--',
|
||||
shopScopeText,
|
||||
/**
|
||||
* Purpose: currentShopText supports index.js by holding or executing the current shop text 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.
|
||||
*/
|
||||
currentShopText: currentShop ? `当前店铺:${currentShop.shopName}` : '当前为平台总览模式'
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenOrders supports index.js by holding or executing the handle open orders 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.
|
||||
*/
|
||||
handleOpenOrders() {
|
||||
navigation.switchTab('/pages/orders/index').catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenManage supports index.js by holding or executing the handle open manage 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.
|
||||
*/
|
||||
handleOpenManage() {
|
||||
navigation.switchTab('/pages/manage/index').catch(() => undefined)
|
||||
},
|
||||
@@ -56,26 +120,58 @@ Page({
|
||||
const allowShoplessLogin = Boolean(result && result.allowShoplessLogin)
|
||||
if (allowShoplessLogin && permission.isPlatformAdmin(userInfo)) {
|
||||
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 items = shops.map(shop => ({
|
||||
/**
|
||||
* Purpose: label supports index.js by holding or executing the 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.
|
||||
*/
|
||||
label: shop.shopName,
|
||||
/**
|
||||
* Purpose: value supports index.js by holding or executing the value 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.
|
||||
*/
|
||||
value: shop.id
|
||||
}))
|
||||
|
||||
if (!items.length) {
|
||||
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
|
||||
}
|
||||
|
||||
wx.showActionSheet({
|
||||
/**
|
||||
* Purpose: itemList supports index.js by holding or executing the item list 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.
|
||||
*/
|
||||
itemList: items.map(item => item.label),
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async action => {
|
||||
const target = items[action.tapIndex]
|
||||
if (!target) {
|
||||
@@ -85,13 +181,29 @@ Page({
|
||||
try {
|
||||
await getApp().switchAdminShop(target.value || undefined)
|
||||
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'
|
||||
})
|
||||
this.onShow()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -99,7 +211,15 @@ Page({
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -111,6 +231,10 @@ Page({
|
||||
} finally {
|
||||
getApp().clearAdminSession()
|
||||
wx.reLaunch({
|
||||
/**
|
||||
* Purpose: url supports index.js by holding or executing the url 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.
|
||||
*/
|
||||
url: '/pages/login/index'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/**
|
||||
* Purpose: auditApi reads immutable high-risk operation audit logs for admin review.
|
||||
* Usage: call listLogs with filter and pagination params from this page.
|
||||
*/
|
||||
const auditApi = require('../../api/security-audit')
|
||||
/**
|
||||
* Purpose: navigation centralizes page transitions and fallback back behavior.
|
||||
* Usage: call goBack when the custom navigation bar back event fires.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: format prepares backend timestamps for compact mini-program display.
|
||||
* Usage: call formatDateTime before assigning audit rows to page data.
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
|
||||
/**
|
||||
* Purpose: RESULT_OPTIONS drives the audit result segmented filter.
|
||||
* Usage: keep values aligned with backend result strings accepted by /admin/security-audit/logs.
|
||||
*/
|
||||
const RESULT_OPTIONS = [
|
||||
{ label: '全部', value: '' },
|
||||
{ label: '成功', value: 'SUCCESS' },
|
||||
{ label: '失败', value: 'FAIL' }
|
||||
]
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data stores filter, pagination, and rendered audit rows for the read-only audit page.
|
||||
* Usage: WXML binds these fields and page methods update them through setData.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading indicates whether an audit-log query is currently in flight.
|
||||
* Usage: bind it to the search button and bottom loader to prevent duplicate requests.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: list holds formatted audit log rows returned by the backend.
|
||||
* Usage: append or replace it after listLogs responses.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: page tracks the current backend page number.
|
||||
* Usage: increment it only after a successful load-more response.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size controls how many audit rows each request asks for.
|
||||
* Usage: pass it unchanged to listLogs so paging remains stable.
|
||||
*/
|
||||
size: 10,
|
||||
/**
|
||||
* Purpose: hasMore tells the page whether another backend page is available.
|
||||
* Usage: set it from response totals and guard onReachBottom.
|
||||
*/
|
||||
hasMore: true,
|
||||
/**
|
||||
* Purpose: account filters audit logs by operator account.
|
||||
* Usage: bind it to the search input and pass non-empty values to the API.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: action filters audit logs by action code or action keyword.
|
||||
* Usage: bind it to the search input and pass non-empty values to the API.
|
||||
*/
|
||||
action: '',
|
||||
/**
|
||||
* Purpose: result filters audit logs by success or failure status.
|
||||
* Usage: update it from result chips and pass it to the backend query.
|
||||
*/
|
||||
result: '',
|
||||
/**
|
||||
* Purpose: resultOptions renders available result filter chips.
|
||||
* Usage: iterate it in WXML and compare each option value with data.result.
|
||||
*/
|
||||
resultOptions: RESULT_OPTIONS
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad performs the initial audit-log query for authorized users.
|
||||
* Usage: mini-program runtime calls it once when the page is opened from Manage.
|
||||
*/
|
||||
onLoad() {
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh reloads the first audit-log page after manual refresh.
|
||||
* Usage: mini-program runtime calls it and the method stops the refresh animation after completion.
|
||||
*/
|
||||
async onPullDownRefresh() {
|
||||
await this.loadLogs(true)
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onReachBottom loads the next page when the operator scrolls to the bottom.
|
||||
* Usage: mini-program runtime calls it and the method respects loading and hasMore guards.
|
||||
*/
|
||||
onReachBottom() {
|
||||
if (!this.data.loading && this.data.hasMore) {
|
||||
this.loadLogs(false)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildQuery creates a clean backend query object from page filters and pagination.
|
||||
* Usage: call it before listLogs so empty filters are not sent.
|
||||
*/
|
||||
buildQuery(page) {
|
||||
const query = {
|
||||
page,
|
||||
size: this.data.size
|
||||
}
|
||||
;['account', 'action', 'result'].forEach(key => {
|
||||
const value = String(this.data[key] || '').trim()
|
||||
if (value) {
|
||||
query[key] = value
|
||||
}
|
||||
})
|
||||
return query
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadLogs queries audit logs and updates list pagination state.
|
||||
* Usage: pass true for a fresh search and false for infinite-scroll loading.
|
||||
*/
|
||||
async loadLogs(reset) {
|
||||
if (this.data.loading) {
|
||||
return
|
||||
}
|
||||
const nextPage = reset ? 1 : this.data.page + 1
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const response = await auditApi.listLogs(this.buildQuery(nextPage))
|
||||
const records = Array.isArray(response && response.records)
|
||||
? response.records
|
||||
: (Array.isArray(response && response.list) ? response.list : [])
|
||||
const total = Number(response && response.total) || 0
|
||||
const currentList = reset ? [] : this.data.list
|
||||
const list = currentList.concat(records.map(item => this.formatLog(item)))
|
||||
this.setData({
|
||||
list,
|
||||
page: nextPage,
|
||||
hasMore: total ? list.length < total : records.length >= this.data.size
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '审计日志加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatLog normalizes one backend audit row for compact display.
|
||||
* Usage: call it on every record returned from listLogs before rendering.
|
||||
*/
|
||||
formatLog(item) {
|
||||
return {
|
||||
...item,
|
||||
displayTime: format.formatDateTime(item.operateTime || item.createTime),
|
||||
resultText: item.result === 'SUCCESS' ? '成功' : '失败',
|
||||
resultClass: item.result === 'SUCCESS' ? 'success' : 'fail',
|
||||
operatorText: item.account || item.operatorAccount || '--',
|
||||
reasonText: item.reason || item.failureReason || item.errorMessage || item.remark || ''
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleAccountInput updates the operator-account filter as the input changes.
|
||||
* Usage: bind it to the account input field.
|
||||
*/
|
||||
handleAccountInput(event) {
|
||||
this.setData({ account: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleActionInput updates the action-code filter as the input changes.
|
||||
* Usage: bind it to the action input field.
|
||||
*/
|
||||
handleActionInput(event) {
|
||||
this.setData({ action: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleResultChange switches between all, success, and fail filters.
|
||||
* Usage: bind it to result chips with data-result.
|
||||
*/
|
||||
handleResultChange(event) {
|
||||
this.setData({ result: event.currentTarget.dataset.result || '' })
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch reloads logs using the current text filters.
|
||||
* Usage: bind it to keyboard confirm and the search button.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleReset clears filters and reloads the first audit-log page.
|
||||
* Usage: bind it to the reset button in the filter card.
|
||||
*/
|
||||
handleReset() {
|
||||
this.setData({
|
||||
account: '',
|
||||
action: '',
|
||||
result: ''
|
||||
})
|
||||
this.loadLogs(true)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack returns to Manage when this page is opened as a standalone stack page.
|
||||
* Usage: bind it to the custom navigation bar back event.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
<navigation-bar title="审计日志" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Security Audit</text>
|
||||
<text class="hero-title">高危操作留痕</text>
|
||||
<text class="hero-desc">按账号、动作和结果查看后台关键操作记录,失败原因会保留在详情行中。</text>
|
||||
</view>
|
||||
|
||||
<view class="surface-card">
|
||||
<text class="section-title">筛选</text>
|
||||
<input class="field-input" placeholder="操作者账号" placeholder-class="placeholder" value="{{account}}" bindinput="handleAccountInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||
<input class="field-input" placeholder="动作编码" placeholder-class="placeholder" value="{{action}}" bindinput="handleActionInput" confirm-type="search" bindconfirm="handleSearch"></input>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{resultOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{result === item.value ? 'active' : ''}}" data-result="{{item.value}}" bindtap="handleResultChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<view class="actions-row">
|
||||
<button class="secondary-btn" bindtap="handleReset">重置</button>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="handleSearch">查询</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.action || '--'}}</text>
|
||||
<text class="list-subtitle">{{item.operatorText}} · {{item.displayTime}}</text>
|
||||
</view>
|
||||
<text class="audit-badge {{item.resultClass}}">{{item.resultText}}</text>
|
||||
</view>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务类型</text>
|
||||
<text class="meta-value">{{item.businessType || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务 ID</text>
|
||||
<text class="meta-value">{{item.businessId || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">IP</text>
|
||||
<text class="meta-value">{{item.ipAddress || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">原因</text>
|
||||
<text class="meta-value">{{item.reasonText || '无'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无审计日志</text>
|
||||
<text class="empty-desc">当前筛选条件下没有高危操作记录。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="loading-line">加载中...</view>
|
||||
<view wx:if="{{list.length && !hasMore}}" class="loading-line">已加载全部</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,35 @@
|
||||
.field-input {
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 20rpx;
|
||||
}
|
||||
|
||||
.audit-badge {
|
||||
flex-shrink: 0;
|
||||
padding: 8rpx 14rpx;
|
||||
border-radius: 8rpx;
|
||||
font-size: 22rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.audit-badge.success {
|
||||
color: #73d99f;
|
||||
background: rgba(115, 217, 159, 0.12);
|
||||
}
|
||||
|
||||
.audit-badge.fail {
|
||||
color: #ff9b8b;
|
||||
background: rgba(255, 155, 139, 0.14);
|
||||
}
|
||||
|
||||
.loading-line {
|
||||
color: #7e8f8c;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
@@ -1,30 +1,106 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
|
||||
/**
|
||||
* 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-shop-form'
|
||||
|
||||
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: 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: 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: statusOptions supports index.js by holding or executing the status options 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.
|
||||
*/
|
||||
statusOptions: ['启用', '停用'],
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: 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: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: '',
|
||||
/**
|
||||
* 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: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: '',
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: '',
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file 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.
|
||||
*/
|
||||
coverImageFileId: '',
|
||||
/**
|
||||
* 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: 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 currentShop = getTempRecord('currentShopRecord', null)
|
||||
@@ -32,50 +108,122 @@ Page({
|
||||
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* 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: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
if (mode === 'edit' && currentShop) {
|
||||
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: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: currentShop.shopName || '',
|
||||
/**
|
||||
* 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: currentShop.description || '',
|
||||
/**
|
||||
* Purpose: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: currentShop.address || '',
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: currentShop.businessHours || '',
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file 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.
|
||||
*/
|
||||
coverImageFileId: currentShop.coverImageFileId || '',
|
||||
/**
|
||||
* 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: currentShop.imageFileIds ? String(currentShop.imageFileIds).split(',').filter(Boolean) : []
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: Number(currentShop.status) === 0 ? 1 : 0
|
||||
})
|
||||
}
|
||||
|
||||
if (draft && draft.mode === mode) {
|
||||
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
|
||||
},
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: draft.statusIndex === 1 ? 1 : this.data.statusIndex
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentShopRecord')
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleShopDraft supports index.js by holding or executing the schedule shop 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.
|
||||
*/
|
||||
scheduleShopDraft() {
|
||||
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: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: this.data.statusIndex,
|
||||
/**
|
||||
* 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: 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({
|
||||
@@ -84,8 +232,16 @@ Page({
|
||||
this.scheduleShopDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatusChange supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatusChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: statusIndex supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
statusIndex: Number(event.detail.value)
|
||||
})
|
||||
this.scheduleShopDraft()
|
||||
@@ -102,17 +258,37 @@ Page({
|
||||
async handleUpload(scene, isBanner) {
|
||||
try {
|
||||
const files = await upload.chooseImageFiles({
|
||||
/**
|
||||
* Purpose: count supports index.js by holding or executing the 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.
|
||||
*/
|
||||
count: isBanner ? 1 : 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 results = await upload.uploadImageFiles({
|
||||
files,
|
||||
scene,
|
||||
/**
|
||||
* 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)
|
||||
})
|
||||
}
|
||||
@@ -130,11 +306,23 @@ Page({
|
||||
this.scheduleShopDraft()
|
||||
} 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
|
||||
})
|
||||
}
|
||||
@@ -143,19 +331,55 @@ Page({
|
||||
async handleSubmit() {
|
||||
if (!this.data.form.shopName) {
|
||||
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: shopName supports index.js by holding or executing the shop name 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.
|
||||
*/
|
||||
shopName: this.data.form.shopName,
|
||||
/**
|
||||
* 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: address supports index.js by holding or executing the address 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.
|
||||
*/
|
||||
address: this.data.form.address || undefined,
|
||||
/**
|
||||
* Purpose: businessHours supports index.js by holding or executing the business hours 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.
|
||||
*/
|
||||
businessHours: this.data.form.businessHours || undefined,
|
||||
/**
|
||||
* Purpose: coverImageFileId supports index.js by holding or executing the cover image file 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.
|
||||
*/
|
||||
coverImageFileId: this.data.form.coverImageFileId || 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: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: this.data.statusIndex === 1 ? 0 : 1
|
||||
}
|
||||
|
||||
@@ -169,13 +393,29 @@ Page({
|
||||
markDirty('admin-shops')
|
||||
markDirty('admin-workbench')
|
||||
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/shops/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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,17 +1,53 @@
|
||||
/**
|
||||
* 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入店铺管理')) {
|
||||
return
|
||||
@@ -19,6 +55,10 @@ Page({
|
||||
|
||||
const permissionCodes = getApp().globalData.permissionCodes || []
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: canCreate supports index.js by holding or executing the can create 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.
|
||||
*/
|
||||
canCreate: permissionCodes.includes('shop:create')
|
||||
})
|
||||
|
||||
@@ -27,12 +67,24 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadShops()
|
||||
},
|
||||
@@ -41,13 +93,29 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await shopApi.listShops({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined
|
||||
})
|
||||
if (requestId !== this._loadRequestId) {
|
||||
@@ -55,10 +123,22 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status text 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.
|
||||
*/
|
||||
displayStatusText: Number(item.status) === 0 ? '已停用' : '启用中'
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -66,48 +146,100 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentShopRecord')
|
||||
navigation.navigate('/pages/shop-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const shop = event.currentTarget.dataset.shop
|
||||
setTempRecord('currentShopRecord', shop)
|
||||
navigation.navigate('/pages/shop-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: shop.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleStatus supports index.js by holding or executing the handle status 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.
|
||||
*/
|
||||
handleStatus(event) {
|
||||
const shop = event.currentTarget.dataset.shop
|
||||
const nextStatus = Number(shop.status) === 0 ? 1 : 0
|
||||
shopApi.updateShopStatus(shop.id, nextStatus)
|
||||
.then(() => {
|
||||
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'
|
||||
})
|
||||
this.loadShops()
|
||||
})
|
||||
.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'
|
||||
})
|
||||
})
|
||||
|
||||
@@ -0,0 +1,422 @@
|
||||
/**
|
||||
* Purpose: messageApi wraps admin system-message endpoints for list, publish, revoke, and target options.
|
||||
* Usage: call these methods from page event handlers instead of assembling backend URLs in the view layer.
|
||||
*/
|
||||
const messageApi = require('../../api/system-message')
|
||||
/**
|
||||
* Purpose: navigation handles custom navigation-bar back behavior.
|
||||
* Usage: call goBack when returning to the management menu.
|
||||
*/
|
||||
const navigation = require('../../utils/navigation')
|
||||
/**
|
||||
* Purpose: permission checks button-level rights for create and revoke actions.
|
||||
* Usage: pass stored permission codes into hasPermission before rendering or running guarded actions.
|
||||
*/
|
||||
const permission = require('../../utils/permission')
|
||||
/**
|
||||
* Purpose: auth exposes the current admin permission list stored after login.
|
||||
* Usage: read user info and permissions when deciding which mobile controls are available.
|
||||
*/
|
||||
const auth = require('../../utils/auth')
|
||||
/**
|
||||
* Purpose: format converts backend times into mini-program friendly text.
|
||||
* Usage: call formatDateTime before assigning message rows to data.list.
|
||||
*/
|
||||
const format = require('../../utils/format')
|
||||
/**
|
||||
* Purpose: actionGuard prevents duplicate publish and revoke submissions from rapid taps.
|
||||
* Usage: wrap create and revoke requests with actionGuard.run.
|
||||
*/
|
||||
const actionGuard = require('../../utils/action-guard')
|
||||
|
||||
/**
|
||||
* Purpose: TARGET_TYPE_OPTIONS defines publish target scopes supported by the backend contract.
|
||||
* Usage: render it as chips and submit the selected value as targetType.
|
||||
*/
|
||||
const TARGET_TYPE_OPTIONS = [
|
||||
{ label: '全平台', value: 'PLATFORM_ALL' },
|
||||
{ label: '指定店铺', value: 'SELECTED_SHOPS' },
|
||||
{ label: '指定用户', value: 'SELECTED_USERS' }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: BUSINESS_TYPE_OPTIONS lists common business navigation types used by order review and artist-change messages.
|
||||
* Usage: render it as chips and store the selected value in the publish form.
|
||||
*/
|
||||
const BUSINESS_TYPE_OPTIONS = [
|
||||
{ label: '无', value: '' },
|
||||
{ label: '订单', value: 'ORDER' },
|
||||
{ label: '评价提醒', value: 'ORDER_ARTIST_REVIEW' },
|
||||
{ label: '改派申请', value: 'ORDER_ARTIST_CHANGE' }
|
||||
]
|
||||
|
||||
/**
|
||||
* Purpose: initialForm returns a clean publish form with popup enabled by default.
|
||||
* Usage: call it when opening the form and after successful publish.
|
||||
*/
|
||||
function initialForm() {
|
||||
return {
|
||||
title: '',
|
||||
content: '',
|
||||
targetType: 'PLATFORM_ALL',
|
||||
targetId: '',
|
||||
popupEnabled: true,
|
||||
businessType: '',
|
||||
businessId: '',
|
||||
actionPath: ''
|
||||
}
|
||||
}
|
||||
|
||||
Page({
|
||||
/**
|
||||
* Purpose: data stores system-message list, publish form state, permissions, and picker options.
|
||||
* Usage: WXML binds these fields and event handlers update them through setData.
|
||||
*/
|
||||
data: {
|
||||
/**
|
||||
* Purpose: loading shows whether the message list is being refreshed.
|
||||
* Usage: bind it to page loading lines and refresh controls.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: submitting shows whether publish or revoke is currently running.
|
||||
* Usage: disable action buttons while true.
|
||||
*/
|
||||
submitting: false,
|
||||
/**
|
||||
* Purpose: list contains formatted system messages visible to the current admin scope.
|
||||
* Usage: render it in WXML list cards.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: targetOptions stores backend-provided shops and users for scoped publishing.
|
||||
* Usage: resolve targetId names and validate selected target choices.
|
||||
*/
|
||||
targetOptions: { shops: [], users: [] },
|
||||
/**
|
||||
* Purpose: formVisible controls whether the mobile publish panel is shown.
|
||||
* Usage: toggle it from header and cancel buttons.
|
||||
*/
|
||||
formVisible: false,
|
||||
/**
|
||||
* Purpose: form holds publish fields sent to createMessage after validation.
|
||||
* Usage: update individual properties from inputs and chips.
|
||||
*/
|
||||
form: initialForm(),
|
||||
/**
|
||||
* Purpose: targetTypeOptions renders publish target scope choices.
|
||||
* Usage: iterate it in WXML chips.
|
||||
*/
|
||||
targetTypeOptions: TARGET_TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: businessTypeOptions renders common business navigation choices.
|
||||
* Usage: iterate it in WXML chips.
|
||||
*/
|
||||
businessTypeOptions: BUSINESS_TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: canCreate controls whether the publish action is visible for the current permission set.
|
||||
* Usage: derive it from message:create permission during onLoad.
|
||||
*/
|
||||
canCreate: false,
|
||||
/**
|
||||
* Purpose: canRevoke controls whether revoke buttons are visible for the current permission set.
|
||||
* Usage: derive it from message:delete permission during onLoad.
|
||||
*/
|
||||
canRevoke: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onLoad initializes permission flags and fetches message list data.
|
||||
* Usage: mini-program runtime calls it when the operator opens the system-message page.
|
||||
*/
|
||||
onLoad() {
|
||||
const userInfo = auth.getStoredUserInfo() || {}
|
||||
const codes = userInfo.permissions || []
|
||||
this.setData({
|
||||
canCreate: permission.hasPermission(codes, 'message:create'),
|
||||
canRevoke: permission.hasPermission(codes, 'message:delete')
|
||||
})
|
||||
this.loadMessages()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onPullDownRefresh reloads system messages and target options.
|
||||
* Usage: mini-program runtime calls it after a manual refresh gesture.
|
||||
*/
|
||||
async onPullDownRefresh() {
|
||||
await this.loadMessages()
|
||||
wx.stopPullDownRefresh()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: loadMessages refreshes list data and target options for the publish form.
|
||||
* Usage: call it on page entry, pull refresh, publish success, and revoke success.
|
||||
*/
|
||||
async loadMessages() {
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const [messages, targetOptions] = await Promise.all([
|
||||
messageApi.listMessages(),
|
||||
this.data.canCreate ? messageApi.getTargetOptions() : Promise.resolve(this.data.targetOptions)
|
||||
])
|
||||
this.setData({
|
||||
list: (Array.isArray(messages) ? messages : []).map(item => this.formatMessage(item)),
|
||||
targetOptions: targetOptions || { shops: [], users: [] }
|
||||
})
|
||||
} catch (error) {
|
||||
wx.showToast({
|
||||
title: error.message || '系统消息加载失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: formatMessage normalizes backend message metadata for compact card display.
|
||||
* Usage: call it on every list item before assigning to data.list.
|
||||
*/
|
||||
formatMessage(item) {
|
||||
return {
|
||||
...item,
|
||||
displayTime: format.formatDateTime(item.publishTime || item.createTime),
|
||||
statusText: Number(item.status) === 1 ? '已发布' : '已撤回',
|
||||
popupText: Number(item.popupEnabled) === 1 ? '弹窗' : '不弹窗',
|
||||
businessText: item.businessType || '无业务跳转',
|
||||
actionText: item.actionPath || (item.businessId ? `业务 ID:${item.businessId}` : '无')
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShowForm opens a clean publish panel for authorized operators.
|
||||
* Usage: bind it to the publish button.
|
||||
*/
|
||||
handleShowForm() {
|
||||
this.setData({
|
||||
formVisible: true,
|
||||
form: initialForm()
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleHideForm closes the publish panel without submitting.
|
||||
* Usage: bind it to cancel controls.
|
||||
*/
|
||||
handleHideForm() {
|
||||
this.setData({ formVisible: false })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: patchForm updates one field in the publish form.
|
||||
* Usage: call it from input and chip handlers with a partial form object.
|
||||
*/
|
||||
patchForm(patch) {
|
||||
this.setData({
|
||||
form: {
|
||||
...this.data.form,
|
||||
...patch
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTitleInput stores the publish title input value.
|
||||
* Usage: bind it to the title input.
|
||||
*/
|
||||
handleTitleInput(event) {
|
||||
this.patchForm({ title: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleContentInput stores the publish content textarea value.
|
||||
* Usage: bind it to the content textarea.
|
||||
*/
|
||||
handleContentInput(event) {
|
||||
this.patchForm({ content: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTargetIdInput stores selected shop or user id values.
|
||||
* Usage: bind it to the target id input when targetType is SHOP or USER.
|
||||
*/
|
||||
handleTargetIdInput(event) {
|
||||
this.patchForm({ targetId: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBusinessIdInput stores the optional business id used for message navigation.
|
||||
* Usage: bind it to the business id input.
|
||||
*/
|
||||
handleBusinessIdInput(event) {
|
||||
this.patchForm({ businessId: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleActionPathInput stores the optional frontend action path used by popup and list taps.
|
||||
* Usage: bind it to the action path input.
|
||||
*/
|
||||
handleActionPathInput(event) {
|
||||
this.patchForm({ actionPath: event.detail.value })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTargetTypeChange changes publish target scope and clears stale target ids.
|
||||
* Usage: bind it to target type chips with data-value.
|
||||
*/
|
||||
handleTargetTypeChange(event) {
|
||||
this.patchForm({
|
||||
targetType: event.currentTarget.dataset.value,
|
||||
targetId: ''
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBusinessTypeChange changes the optional business navigation type.
|
||||
* Usage: bind it to business type chips with data-value.
|
||||
*/
|
||||
handleBusinessTypeChange(event) {
|
||||
this.patchForm({ businessType: event.currentTarget.dataset.value || '' })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePopupToggle flips whether recipients should see a one-time popup.
|
||||
* Usage: bind it to the popup switch control.
|
||||
*/
|
||||
handlePopupToggle(event) {
|
||||
this.patchForm({ popupEnabled: Boolean(event.detail.value) })
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: buildPublishPayload validates the form and converts it to backend DTO shape.
|
||||
* Usage: call it inside handlePublish before createMessage; it returns null after showing validation errors.
|
||||
*/
|
||||
buildPublishPayload() {
|
||||
const form = this.data.form
|
||||
const title = String(form.title || '').trim()
|
||||
const content = String(form.content || '').trim()
|
||||
if (!title || !content) {
|
||||
wx.showToast({
|
||||
title: '请填写标题和内容',
|
||||
icon: 'none'
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
const payload = {
|
||||
title,
|
||||
content,
|
||||
targetType: form.targetType,
|
||||
popupEnabled: form.popupEnabled ? 1 : 0,
|
||||
businessType: form.businessType || undefined,
|
||||
businessId: form.businessId ? Number(form.businessId) : undefined,
|
||||
actionPath: String(form.actionPath || '').trim() || undefined
|
||||
}
|
||||
|
||||
if (form.targetType === 'SELECTED_SHOPS') {
|
||||
if (!form.targetId) {
|
||||
wx.showToast({ title: '请输入店铺 ID', icon: 'none' })
|
||||
return null
|
||||
}
|
||||
payload.shopIds = [Number(form.targetId)]
|
||||
}
|
||||
|
||||
if (form.targetType === 'SELECTED_USERS') {
|
||||
if (!form.targetId) {
|
||||
wx.showToast({ title: '请输入用户 ID', icon: 'none' })
|
||||
return null
|
||||
}
|
||||
payload.userIds = [Number(form.targetId)]
|
||||
}
|
||||
|
||||
return payload
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePublish submits the publish form with duplicate-tap protection.
|
||||
* Usage: bind it to the primary publish button.
|
||||
*/
|
||||
async handlePublish() {
|
||||
const payload = this.buildPublishPayload()
|
||||
if (!payload) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await actionGuard.run(this, 'system-message:publish', async () => {
|
||||
this.setData({ submitting: true })
|
||||
await messageApi.createMessage(payload)
|
||||
wx.showToast({
|
||||
title: '消息已发布',
|
||||
icon: 'none'
|
||||
})
|
||||
this.setData({
|
||||
formVisible: false,
|
||||
form: initialForm()
|
||||
})
|
||||
await this.loadMessages()
|
||||
}, {
|
||||
message: '消息发布中,请勿重复提交'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '消息发布失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.setData({ submitting: false })
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleRevoke revokes one message after operator confirmation.
|
||||
* Usage: bind it to list-row revoke buttons with data-id.
|
||||
*/
|
||||
async handleRevoke(event) {
|
||||
const id = event.currentTarget.dataset.id
|
||||
if (!id) {
|
||||
return
|
||||
}
|
||||
const confirmed = await new Promise(resolve => {
|
||||
wx.showModal({
|
||||
title: '撤回消息',
|
||||
content: '确认撤回这条系统消息吗?',
|
||||
confirmText: '撤回',
|
||||
success: res => resolve(Boolean(res.confirm))
|
||||
})
|
||||
})
|
||||
if (!confirmed) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
await actionGuard.run(this, `system-message:revoke:${id}`, async () => {
|
||||
await messageApi.revokeMessage(id)
|
||||
wx.showToast({
|
||||
title: '已撤回',
|
||||
icon: 'none'
|
||||
})
|
||||
await this.loadMessages()
|
||||
}, {
|
||||
message: '消息撤回中,请勿重复操作'
|
||||
})
|
||||
} catch (error) {
|
||||
if (actionGuard.isGuardError(error)) {
|
||||
return
|
||||
}
|
||||
wx.showToast({
|
||||
title: error.message || '撤回失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBack returns to the management menu.
|
||||
* Usage: bind it to the custom navigation bar back event.
|
||||
*/
|
||||
handleBack() {
|
||||
navigation.goBack('/pages/manage/index')
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"navigation-bar": "/components/navigation-bar/navigation-bar"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<navigation-bar title="系统消息" back="{{true}}" bindback="handleBack" color="#f6efe7" background="#081518"></navigation-bar>
|
||||
|
||||
<view class="page-shell">
|
||||
<view class="page-stack">
|
||||
<view class="hero-panel">
|
||||
<text class="hero-kicker">Message Center</text>
|
||||
<text class="hero-title">消息发布与弹窗配置</text>
|
||||
<text class="hero-desc">查看消息列表、弹窗开关、业务跳转和发布状态。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{canCreate && !formVisible}}" class="primary-btn" bindtap="handleShowForm">发布消息</view>
|
||||
|
||||
<view wx:if="{{formVisible}}" class="surface-card form-card">
|
||||
<text class="section-title">发布系统消息</text>
|
||||
<input class="field-input" placeholder="标题" placeholder-class="placeholder" value="{{form.title}}" bindinput="handleTitleInput"></input>
|
||||
<textarea class="field-textarea" placeholder="消息内容" placeholder-class="placeholder" value="{{form.content}}" maxlength="2000" bindinput="handleContentInput"></textarea>
|
||||
|
||||
<text class="field-label">接收范围</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{targetTypeOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{form.targetType === item.value ? 'active' : ''}}" data-value="{{item.value}}" bindtap="handleTargetTypeChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<input wx:if="{{form.targetType !== 'PLATFORM_ALL'}}" class="field-input" placeholder="{{form.targetType === 'SELECTED_SHOPS' ? '店铺 ID' : '用户 ID'}}" placeholder-class="placeholder" value="{{form.targetId}}" bindinput="handleTargetIdInput"></input>
|
||||
<view wx:if="{{form.targetType === 'SELECTED_SHOPS' && targetOptions.shops.length}}" class="option-hint">可选店铺:{{targetOptions.shops.length}} 个,输入对应 ID 发布</view>
|
||||
<view wx:if="{{form.targetType === 'SELECTED_USERS' && targetOptions.users.length}}" class="option-hint">可选用户:{{targetOptions.users.length}} 个,输入对应 ID 发布</view>
|
||||
|
||||
<view class="switch-row">
|
||||
<text class="field-label">弹窗显示一次</text>
|
||||
<switch checked="{{form.popupEnabled}}" color="#f07e57" bindchange="handlePopupToggle"></switch>
|
||||
</view>
|
||||
|
||||
<text class="field-label">业务跳转</text>
|
||||
<view class="chip-row">
|
||||
<block wx:for="{{businessTypeOptions}}" wx:key="value">
|
||||
<view class="chip-btn {{form.businessType === item.value ? 'active' : ''}}" data-value="{{item.value}}" bindtap="handleBusinessTypeChange">{{item.label}}</view>
|
||||
</block>
|
||||
</view>
|
||||
<input class="field-input" placeholder="业务 ID,可选" placeholder-class="placeholder" value="{{form.businessId}}" bindinput="handleBusinessIdInput"></input>
|
||||
<input class="field-input" placeholder="跳转路径,如 /orders?orderId=123" placeholder-class="placeholder" value="{{form.actionPath}}" bindinput="handleActionPathInput"></input>
|
||||
|
||||
<view class="actions-row">
|
||||
<button class="secondary-btn" bindtap="handleHideForm">取消</button>
|
||||
<button class="primary-btn" loading="{{submitting}}" bindtap="handlePublish">发布</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<block wx:for="{{list}}" wx:key="id">
|
||||
<view class="list-card">
|
||||
<view class="list-head">
|
||||
<view>
|
||||
<text class="list-title">{{item.title}}</text>
|
||||
<text class="list-subtitle">{{item.publisherName || '系统'}} · {{item.displayTime}}</text>
|
||||
</view>
|
||||
<text class="badge">{{item.popupText}}</text>
|
||||
</view>
|
||||
<text wx:if="{{item.content}}" class="message-content">{{item.content}}</text>
|
||||
<view class="meta-grid">
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">状态</text>
|
||||
<text class="meta-value">{{item.statusText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">目标</text>
|
||||
<text class="meta-value">{{item.targetTypeName || item.targetType || '--'}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">业务类型</text>
|
||||
<text class="meta-value">{{item.businessText}}</text>
|
||||
</view>
|
||||
<view class="meta-item">
|
||||
<text class="meta-label">跳转</text>
|
||||
<text class="meta-value">{{item.actionText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{canRevoke && item.status === 1}}" class="card-actions">
|
||||
<view class="mini-btn" data-id="{{item.id}}" bindtap="handleRevoke">撤回</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<view wx:if="{{!list.length && !loading}}" class="empty-state">
|
||||
<text class="empty-title">暂无系统消息</text>
|
||||
<text class="empty-desc">发布后的消息会显示弹窗配置和业务跳转信息。</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loading}}" class="loading-line">加载中...</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -0,0 +1,65 @@
|
||||
.form-card {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
color: #f6efe7;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.field-textarea {
|
||||
width: 100%;
|
||||
min-height: 180rpx;
|
||||
box-sizing: border-box;
|
||||
padding: 18rpx 20rpx;
|
||||
border-radius: 8rpx;
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
border: 1rpx solid rgba(255, 255, 255, 0.12);
|
||||
color: #f6efe7;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.switch-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.option-hint {
|
||||
color: #9fb3ad;
|
||||
font-size: 22rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.actions-row {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 16rpx;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
display: block;
|
||||
margin-top: 14rpx;
|
||||
color: #9fb3ad;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.card-actions {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.loading-line {
|
||||
color: #7e8f8c;
|
||||
font-size: 24rpx;
|
||||
text-align: center;
|
||||
padding: 24rpx 0;
|
||||
}
|
||||
@@ -1,37 +1,121 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: tagId supports index.js by holding or executing the tag 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.
|
||||
*/
|
||||
tagId: '',
|
||||
/**
|
||||
* 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: -1,
|
||||
/**
|
||||
* 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: 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: tagName supports index.js by holding or executing the tag name 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.
|
||||
*/
|
||||
tagName: '',
|
||||
/**
|
||||
* Purpose: textColor supports index.js by holding or executing the text color 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.
|
||||
*/
|
||||
textColor: '#2b2b2b',
|
||||
/**
|
||||
* Purpose: bgColor supports index.js by holding or executing the bg color 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.
|
||||
*/
|
||||
bgColor: '#f6e5df',
|
||||
/**
|
||||
* Purpose: borderColor supports index.js by holding or executing the border color 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.
|
||||
*/
|
||||
borderColor: '#ef9a79'
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 currentTag = getTempRecord('currentTag', null)
|
||||
this.setData({
|
||||
mode,
|
||||
/**
|
||||
* Purpose: tagId supports index.js by holding or executing the tag 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.
|
||||
*/
|
||||
tagId: options && options.id ? options.id : ''
|
||||
})
|
||||
|
||||
if (mode === 'edit' && currentTag) {
|
||||
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: tagName supports index.js by holding or executing the tag name 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.
|
||||
*/
|
||||
tagName: currentTag.tagName || '',
|
||||
/**
|
||||
* Purpose: textColor supports index.js by holding or executing the text color 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.
|
||||
*/
|
||||
textColor: currentTag.textColor || '#2b2b2b',
|
||||
/**
|
||||
* Purpose: bgColor supports index.js by holding or executing the bg color 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.
|
||||
*/
|
||||
bgColor: currentTag.bgColor || '#f6e5df',
|
||||
/**
|
||||
* Purpose: borderColor supports index.js by holding or executing the border color 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.
|
||||
*/
|
||||
borderColor: currentTag.borderColor || '#ef9a79'
|
||||
}
|
||||
})
|
||||
@@ -41,6 +125,10 @@ Page({
|
||||
this.loadShops()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentTag')
|
||||
},
|
||||
@@ -70,16 +158,32 @@ 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 : ''
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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({
|
||||
@@ -87,11 +191,19 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 : ''
|
||||
})
|
||||
},
|
||||
@@ -100,14 +212,30 @@ Page({
|
||||
const selectedShop = this.data.shops[this.data.shopIndex]
|
||||
if (!this.data.form.tagName) {
|
||||
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 (!selectedShop) {
|
||||
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
|
||||
@@ -115,6 +243,10 @@ Page({
|
||||
|
||||
const payload = {
|
||||
...this.data.form,
|
||||
/**
|
||||
* 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: selectedShop.id
|
||||
}
|
||||
|
||||
@@ -125,13 +257,29 @@ Page({
|
||||
await tagApi.createTag(payload)
|
||||
}
|
||||
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/tags/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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,12 +1,32 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
|
||||
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: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: []
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入标签管理')) {
|
||||
return
|
||||
@@ -18,40 +38,92 @@ Page({
|
||||
try {
|
||||
const list = await tagApi.listAllTags()
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(list) ? list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: item.shopName || '当前店铺'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentTag')
|
||||
navigation.navigate('/pages/tag-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const tag = event.currentTarget.dataset.tag
|
||||
setTempRecord('currentTag', tag)
|
||||
navigation.navigate('/pages/tag-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: tag.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleDelete supports index.js by holding or executing the handle delete 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.
|
||||
*/
|
||||
handleDelete(event) {
|
||||
const tag = event.currentTarget.dataset.tag
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: `确认删除标签“${tag.tagName}”吗?`,
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -59,13 +131,29 @@ Page({
|
||||
try {
|
||||
await tagApi.deleteTag(tag.id)
|
||||
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'
|
||||
})
|
||||
this.loadTags()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,26 +1,94 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { getTempRecord, clearTempRecord, setTempRecord } = require('../../utils/storage')
|
||||
|
||||
/**
|
||||
* Purpose: CHANGE_SCENE_OPTIONS supports index.js by holding or executing the change scene options 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 CHANGE_SCENE_OPTIONS = ['MANUAL_RECHARGE', 'MANUAL_INCREASE', 'MANUAL_DEDUCT']
|
||||
/**
|
||||
* Purpose: VIP_LEVEL_OPTIONS supports index.js by holding or executing the vip level options 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 VIP_LEVEL_OPTIONS = ['普通', '青铜', '白银', '黄金']
|
||||
|
||||
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: user supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
user: null,
|
||||
/**
|
||||
* Purpose: asset supports index.js by holding or executing the asset 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.
|
||||
*/
|
||||
asset: null,
|
||||
/**
|
||||
* Purpose: balanceHistory supports index.js by holding or executing the balance history 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.
|
||||
*/
|
||||
balanceHistory: [],
|
||||
/**
|
||||
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene 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.
|
||||
*/
|
||||
changeSceneIndex: 0,
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelIndex: 0,
|
||||
/**
|
||||
* Purpose: balanceForm supports index.js by holding or executing the balance 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.
|
||||
*/
|
||||
balanceForm: {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: '',
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: '',
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: vipRemark supports index.js by holding or executing the vip remark 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.
|
||||
*/
|
||||
vipRemark: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 cached = getTempRecord('currentUser', null)
|
||||
if (cached && (!options || !options.id || String(cached.id) === String(options.id))) {
|
||||
@@ -28,6 +96,10 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入用户详情')) {
|
||||
return
|
||||
@@ -35,6 +107,10 @@ Page({
|
||||
this.loadAssetData()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentUser')
|
||||
},
|
||||
@@ -52,36 +128,84 @@ Page({
|
||||
|
||||
this.setData({
|
||||
asset,
|
||||
/**
|
||||
* Purpose: balanceHistory supports index.js by holding or executing the balance history 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.
|
||||
*/
|
||||
balanceHistory: (Array.isArray(balanceHistory) ? balanceHistory : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayChangeTime supports index.js by holding or executing the display change time 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.
|
||||
*/
|
||||
displayChangeTime: format.formatDateTime(item.changeTime),
|
||||
/**
|
||||
* Purpose: amountBadgeClass supports index.js by holding or executing the amount badge class 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.
|
||||
*/
|
||||
amountBadgeClass: Number(item.amount) >= 0 ? 'success-badge' : 'danger-badge'
|
||||
}))
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit() {
|
||||
setTempRecord('currentUser', this.data.user)
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: this.data.user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handlePermissionAssign supports index.js by holding or executing the handle permission assign 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.
|
||||
*/
|
||||
handlePermissionAssign() {
|
||||
setTempRecord('currentUser', this.data.user)
|
||||
navigation.navigate('/pages/permission-form/index', {
|
||||
/**
|
||||
* 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: 'assign',
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: this.data.user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleBalanceInput supports index.js by holding or executing the handle balance input 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.
|
||||
*/
|
||||
handleBalanceInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
this.setData({
|
||||
@@ -89,20 +213,44 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipRemarkInput supports index.js by holding or executing the handle vip remark input 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.
|
||||
*/
|
||||
handleVipRemarkInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: vipRemark supports index.js by holding or executing the vip remark 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.
|
||||
*/
|
||||
vipRemark: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSceneChange supports index.js by holding or executing the handle scene 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.
|
||||
*/
|
||||
handleSceneChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: changeSceneIndex supports index.js by holding or executing the change scene 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.
|
||||
*/
|
||||
changeSceneIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleVipLevelChange supports index.js by holding or executing the handle vip level 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.
|
||||
*/
|
||||
handleVipLevelChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: vipLevelIndex supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevelIndex: Number(event.detail.value)
|
||||
})
|
||||
},
|
||||
@@ -110,26 +258,74 @@ Page({
|
||||
async handleBalanceChange() {
|
||||
try {
|
||||
await userApi.changeUserBalance(this.data.user.id, {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: Number(this.data.balanceForm.amount),
|
||||
/**
|
||||
* Purpose: changeScene supports index.js by holding or executing the change 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.
|
||||
*/
|
||||
changeScene: CHANGE_SCENE_OPTIONS[this.data.changeSceneIndex],
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: this.data.balanceForm.externalOrderNo || undefined,
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: this.data.balanceForm.remark || undefined
|
||||
})
|
||||
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'
|
||||
})
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: balanceForm supports index.js by holding or executing the balance 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.
|
||||
*/
|
||||
balanceForm: {
|
||||
/**
|
||||
* Purpose: amount supports index.js by holding or executing the amount 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.
|
||||
*/
|
||||
amount: '',
|
||||
/**
|
||||
* Purpose: externalOrderNo supports index.js by holding or executing the external order no 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.
|
||||
*/
|
||||
externalOrderNo: '',
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: ''
|
||||
}
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -138,17 +334,41 @@ Page({
|
||||
async handleVipOverride() {
|
||||
try {
|
||||
await userApi.overrideUserVip(this.data.user.id, {
|
||||
/**
|
||||
* Purpose: vipLevel supports index.js by holding or executing the vip level 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.
|
||||
*/
|
||||
vipLevel: VIP_LEVEL_OPTIONS[this.data.vipLevelIndex],
|
||||
/**
|
||||
* Purpose: remark supports index.js by holding or executing the remark 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.
|
||||
*/
|
||||
remark: this.data.vipRemark || undefined
|
||||
})
|
||||
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: 'VIP 等级已更新',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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 || 'VIP 更新失败',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
}
|
||||
@@ -158,13 +378,29 @@ Page({
|
||||
try {
|
||||
await userApi.recalculateUserVip(this.data.user.id)
|
||||
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'
|
||||
})
|
||||
this.loadAssetData()
|
||||
} 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 || 'VIP 重算失败',
|
||||
/**
|
||||
* 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'
|
||||
})
|
||||
}
|
||||
@@ -174,17 +410,37 @@ Page({
|
||||
try {
|
||||
await userApi.resetPassword(this.data.user.id)
|
||||
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'
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleUserAction supports index.js by holding or executing the handle user action 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.
|
||||
*/
|
||||
handleUserAction(event) {
|
||||
const action = event.currentTarget.dataset.action
|
||||
if (action === 'disable') {
|
||||
@@ -204,7 +460,15 @@ Page({
|
||||
try {
|
||||
await userApi.updateUserStatus(this.data.user.id, status)
|
||||
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'
|
||||
})
|
||||
const user = {
|
||||
@@ -215,16 +479,40 @@ Page({
|
||||
setTempRecord('currentUser', user)
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: confirmDelete supports index.js by holding or executing the confirm delete 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.
|
||||
*/
|
||||
confirmDelete() {
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '删除后该账号将不再出现在前端可见列表中,确认继续吗?',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -232,13 +520,29 @@ Page({
|
||||
try {
|
||||
await userApi.deleteUser(this.data.user.id)
|
||||
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'
|
||||
})
|
||||
navigation.goBack('/pages/users/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'
|
||||
})
|
||||
}
|
||||
@@ -246,10 +550,26 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: confirmUnbind supports index.js by holding or executing the confirm unbind 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.
|
||||
*/
|
||||
confirmUnbind() {
|
||||
wx.showModal({
|
||||
/**
|
||||
* 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: content supports index.js by holding or executing the content 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.
|
||||
*/
|
||||
content: '解绑后,该用户将无法登录当前店铺,确认继续吗?',
|
||||
/**
|
||||
* Purpose: success supports index.js by holding or executing the success 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.
|
||||
*/
|
||||
success: async result => {
|
||||
if (!result.confirm) {
|
||||
return
|
||||
@@ -257,12 +577,28 @@ Page({
|
||||
try {
|
||||
await userApi.unbindUser(this.data.user.id)
|
||||
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'
|
||||
})
|
||||
} 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'
|
||||
})
|
||||
}
|
||||
@@ -270,13 +606,37 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: setUser supports index.js by holding or executing the set user 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.
|
||||
*/
|
||||
setUser(user) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: user supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
user: user ? {
|
||||
...user,
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type text 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.
|
||||
*/
|
||||
displayTypeText: format.getUserTypeText(user.type),
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: format.buildShopName(user),
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status text 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.
|
||||
*/
|
||||
displayStatusText: format.getUserStatusText(user.status),
|
||||
/**
|
||||
* Purpose: displayCreateTime supports index.js by holding or executing the display create time 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.
|
||||
*/
|
||||
displayCreateTime: format.formatDateTime(user.createTime)
|
||||
} : null
|
||||
})
|
||||
|
||||
@@ -1,15 +1,47 @@
|
||||
/**
|
||||
* 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: 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: 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')
|
||||
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: ACCOUNT_REGEX supports index.js by holding or executing the account regex 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 ACCOUNT_REGEX = /[^A-Za-z0-9]/g
|
||||
/**
|
||||
* Purpose: PHONE_REGEX supports index.js by holding or executing the phone regex 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 PHONE_REGEX = /[^\d]/g
|
||||
/**
|
||||
* 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-user-form'
|
||||
/**
|
||||
* Purpose: TYPE_OPTIONS supports index.js by holding or executing the type options 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 TYPE_OPTIONS = [
|
||||
{ label: '普通用户', value: 0 },
|
||||
{ label: '店长', value: 2 },
|
||||
@@ -17,28 +49,92 @@ const TYPE_OPTIONS = [
|
||||
{ label: '平台管理员', value: 4 }
|
||||
]
|
||||
|
||||
/**
|
||||
* 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)
|
||||
}
|
||||
|
||||
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: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type 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.
|
||||
*/
|
||||
currentTypeLabel: TYPE_OPTIONS[0].label,
|
||||
/**
|
||||
* 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: selectedShopIds supports index.js by holding or executing the selected shop 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.
|
||||
*/
|
||||
selectedShopIds: [],
|
||||
/**
|
||||
* 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: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: 0
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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 currentUser = getTempRecord('currentUser', null)
|
||||
@@ -53,18 +149,54 @@ Page({
|
||||
|
||||
const baseState = {
|
||||
mode,
|
||||
/**
|
||||
* Purpose: userId supports index.js by holding or executing the user 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.
|
||||
*/
|
||||
userId: options && options.id ? options.id : '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: availableTypes,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type 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.
|
||||
*/
|
||||
currentTypeLabel: availableTypes[0] ? availableTypes[0].label : ''
|
||||
}
|
||||
|
||||
if (mode === 'edit' && currentUser) {
|
||||
baseState.form = {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: currentUser.nickname || '',
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: currentUser.account || '',
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: currentUser.phone || '',
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: '',
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: currentUser.signature || '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(currentUser.type || 0)
|
||||
}
|
||||
baseState.selectedShopIds = Array.isArray(currentUser.shopIds) ? currentUser.shopIds.map(item => String(item)) : []
|
||||
@@ -74,11 +206,23 @@ Page({
|
||||
|
||||
if (draft && draft.mode === mode) {
|
||||
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,
|
||||
/**
|
||||
* Purpose: password supports index.js by holding or executing the password 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.
|
||||
*/
|
||||
password: ''
|
||||
},
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop 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.
|
||||
*/
|
||||
selectedShopIds: Array.isArray(draft.selectedShopIds) ? draft.selectedShopIds : this.data.selectedShopIds
|
||||
})
|
||||
}
|
||||
@@ -87,21 +231,61 @@ Page({
|
||||
this.loadShops()
|
||||
},
|
||||
|
||||
/**
|
||||
* 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('currentUser')
|
||||
clearDraftTimer(this)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: scheduleUserDraft supports index.js by holding or executing the schedule user 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.
|
||||
*/
|
||||
scheduleUserDraft() {
|
||||
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: {
|
||||
/**
|
||||
* Purpose: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.form.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.form.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.form.signature,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(this.data.form.type)
|
||||
},
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop 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.
|
||||
*/
|
||||
selectedShopIds: this.data.selectedShopIds.slice()
|
||||
}))
|
||||
},
|
||||
@@ -115,11 +299,27 @@ Page({
|
||||
|
||||
if (Number(operator.type) !== 4 && currentShop) {
|
||||
this.setData({
|
||||
/**
|
||||
* 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: (Array.isArray(shops) ? shops : []).filter(item => normalizeId(item.id) === normalizeId(currentShop.id)).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: valueId supports index.js by holding or executing the value 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.
|
||||
*/
|
||||
valueId: normalizeId(item.id),
|
||||
/**
|
||||
* 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: true
|
||||
})),
|
||||
/**
|
||||
* Purpose: selectedShopIds supports index.js by holding or executing the selected shop 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.
|
||||
*/
|
||||
selectedShopIds: [normalizeId(currentShop.id)]
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
@@ -127,20 +327,44 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* 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: (Array.isArray(shops) ? shops : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: valueId supports index.js by holding or executing the value 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.
|
||||
*/
|
||||
valueId: normalizeId(item.id),
|
||||
/**
|
||||
* 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.data.selectedShopIds.includes(normalizeId(item.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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 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
|
||||
let value = event.detail.value
|
||||
@@ -161,28 +385,52 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTypeChange supports index.js by holding or executing the handle type 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.
|
||||
*/
|
||||
handleTypeChange(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const item = this.data.typeOptions[index]
|
||||
this.setData({
|
||||
'form.type': item ? item.value : 0,
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type 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.
|
||||
*/
|
||||
currentTypeLabel: item ? item.label : ''
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleShopCheck supports index.js by holding or executing the handle shop check 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.
|
||||
*/
|
||||
handleShopCheck(event) {
|
||||
const selectedShopIds = event.detail.value || []
|
||||
this.setData({
|
||||
selectedShopIds,
|
||||
/**
|
||||
* 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: this.data.shops.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: selectedShopIds.includes(String(item.id))
|
||||
}))
|
||||
})
|
||||
this.scheduleUserDraft()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: validateForm supports index.js by holding or executing the validate form 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.
|
||||
*/
|
||||
validateForm() {
|
||||
const form = this.data.form
|
||||
if (!form.nickname) {
|
||||
@@ -207,18 +455,50 @@ Page({
|
||||
const errorMessage = this.validateForm()
|
||||
if (errorMessage) {
|
||||
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: errorMessage,
|
||||
/**
|
||||
* 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: nickname supports index.js by holding or executing the nickname 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.
|
||||
*/
|
||||
nickname: this.data.form.nickname,
|
||||
/**
|
||||
* Purpose: account supports index.js by holding or executing the account 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.
|
||||
*/
|
||||
account: this.data.form.account,
|
||||
/**
|
||||
* Purpose: phone supports index.js by holding or executing the phone 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.
|
||||
*/
|
||||
phone: this.data.form.phone,
|
||||
/**
|
||||
* Purpose: signature supports index.js by holding or executing the signature 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.
|
||||
*/
|
||||
signature: this.data.form.signature || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: Number(this.data.form.type),
|
||||
/**
|
||||
* Purpose: shopIds supports index.js by holding or executing the shop 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.
|
||||
*/
|
||||
shopIds: this.data.selectedShopIds.map(item => Number(item))
|
||||
}
|
||||
|
||||
@@ -235,21 +515,45 @@ Page({
|
||||
clearDraft(DRAFT_KEY)
|
||||
markDirty('admin-users')
|
||||
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/users/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'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: syncTypeLabel supports index.js by holding or executing the sync type label 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.
|
||||
*/
|
||||
syncTypeLabel(type) {
|
||||
const target = this.data.typeOptions.find(item => Number(item.value) === Number(type))
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: currentTypeLabel supports index.js by holding or executing the current type 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.
|
||||
*/
|
||||
currentTypeLabel: target ? target.label : ''
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,9 +1,25 @@
|
||||
/**
|
||||
* 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: 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')
|
||||
const { setTempRecord, clearTempRecord } = require('../../utils/storage')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
/**
|
||||
* Purpose: TYPE_OPTIONS supports index.js by holding or executing the type options 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 TYPE_OPTIONS = [
|
||||
{ label: '全部角色', value: '' },
|
||||
{ label: '普通用户', value: 0 },
|
||||
@@ -13,15 +29,47 @@ const TYPE_OPTIONS = [
|
||||
]
|
||||
|
||||
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: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: '',
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: '',
|
||||
/**
|
||||
* Purpose: typeOptions supports index.js by holding or executing the type options 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.
|
||||
*/
|
||||
typeOptions: TYPE_OPTIONS,
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: [],
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入用户管理')) {
|
||||
return
|
||||
@@ -31,18 +79,38 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleKeywordInput supports index.js by holding or executing the handle keyword input 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.
|
||||
*/
|
||||
handleKeywordInput(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleSearch supports index.js by holding or executing the handle search 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.
|
||||
*/
|
||||
handleSearch() {
|
||||
this.loadUsers()
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleTypeChange supports index.js by holding or executing the handle type 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.
|
||||
*/
|
||||
handleTypeChange(event) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: event.currentTarget.dataset.type
|
||||
})
|
||||
this.loadUsers()
|
||||
@@ -52,14 +120,34 @@ Page({
|
||||
const requestId = (this._loadRequestId || 0) + 1
|
||||
this._loadRequestId = requestId
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
try {
|
||||
const result = await userApi.listUsers({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: keyword supports index.js by holding or executing the keyword 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.
|
||||
*/
|
||||
keyword: this.data.keyword || undefined,
|
||||
/**
|
||||
* Purpose: type supports index.js by holding or executing the type 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.
|
||||
*/
|
||||
type: this.data.type === '' ? undefined : this.data.type
|
||||
})
|
||||
|
||||
@@ -68,12 +156,32 @@ Page({
|
||||
}
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: list supports index.js by holding or executing the list 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.
|
||||
*/
|
||||
list: (Array.isArray(result && result.list) ? result.list : []).map(item => ({
|
||||
...item,
|
||||
/**
|
||||
* Purpose: displayShopName supports index.js by holding or executing the display shop name 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.
|
||||
*/
|
||||
displayShopName: format.buildShopName(item),
|
||||
/**
|
||||
* Purpose: displayTypeText supports index.js by holding or executing the display type text 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.
|
||||
*/
|
||||
displayTypeText: format.getUserTypeText(item.type),
|
||||
/**
|
||||
* Purpose: displayStatusText supports index.js by holding or executing the display status text 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.
|
||||
*/
|
||||
displayStatusText: format.getUserStatusText(item.status)
|
||||
})),
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -81,38 +189,78 @@ Page({
|
||||
return
|
||||
}
|
||||
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 {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenDetail supports index.js by holding or executing the handle open detail 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.
|
||||
*/
|
||||
handleOpenDetail(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/user-detail/index', {
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleEdit supports index.js by holding or executing the handle edit 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.
|
||||
*/
|
||||
handleEdit(event) {
|
||||
const user = event.currentTarget.dataset.user
|
||||
setTempRecord('currentUser', user)
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* 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: 'edit',
|
||||
/**
|
||||
* Purpose: id supports index.js by holding or executing the 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.
|
||||
*/
|
||||
id: user.id
|
||||
}).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleCreate supports index.js by holding or executing the handle create 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.
|
||||
*/
|
||||
handleCreate() {
|
||||
clearTempRecord('currentUser')
|
||||
navigation.navigate('/pages/user-form/index', {
|
||||
/**
|
||||
* 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'
|
||||
}).catch(() => undefined)
|
||||
}
|
||||
|
||||
@@ -1,24 +1,88 @@
|
||||
/**
|
||||
* Purpose: dashboardApi supports index.js by holding or executing the dashboard 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 dashboardApi = require('../../api/dashboard')
|
||||
/**
|
||||
* Purpose: orderApi supports index.js by holding or executing the order 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 orderApi = require('../../api/order')
|
||||
/**
|
||||
* 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: permission supports index.js by holding or executing the permission 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 permission = require('../../utils/permission')
|
||||
/**
|
||||
* 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')
|
||||
const { CACHE_TTL } = require('../../utils/config')
|
||||
const { consumeDirty } = require('../../utils/page-state')
|
||||
|
||||
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: userInfo supports index.js by holding or executing the user info 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.
|
||||
*/
|
||||
userInfo: null,
|
||||
/**
|
||||
* Purpose: currentShop supports index.js by holding or executing the current shop 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.
|
||||
*/
|
||||
currentShop: null,
|
||||
/**
|
||||
* Purpose: permissionCount supports index.js by holding or executing the permission 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.
|
||||
*/
|
||||
permissionCount: 0,
|
||||
/**
|
||||
* Purpose: shortcutModules supports index.js by holding or executing the shortcut modules 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.
|
||||
*/
|
||||
shortcutModules: [],
|
||||
/**
|
||||
* Purpose: stats supports index.js by holding or executing the stats 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.
|
||||
*/
|
||||
stats: null,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: 0,
|
||||
/**
|
||||
* Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin 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.
|
||||
*/
|
||||
shoplessAdmin: false,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: onShow supports index.js by holding or executing the on show 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.
|
||||
*/
|
||||
onShow() {
|
||||
if (!navigation.ensureLogin('进入工作台')) {
|
||||
return
|
||||
@@ -28,11 +92,19 @@ Page({
|
||||
const dirty = consumeDirty('admin-workbench')
|
||||
if (!this.data.initialized || dirty) {
|
||||
this.loadDashboard({
|
||||
/**
|
||||
* Purpose: force supports index.js by holding or executing the force 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.
|
||||
*/
|
||||
force: dirty
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: syncGlobalState supports index.js by holding or executing the sync global state 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.
|
||||
*/
|
||||
syncGlobalState() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo
|
||||
@@ -43,8 +115,20 @@ Page({
|
||||
this.setData({
|
||||
userInfo,
|
||||
currentShop,
|
||||
/**
|
||||
* Purpose: permissionCount supports index.js by holding or executing the permission 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.
|
||||
*/
|
||||
permissionCount: permissionCodes.length,
|
||||
/**
|
||||
* Purpose: shortcutModules supports index.js by holding or executing the shortcut modules 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.
|
||||
*/
|
||||
shortcutModules: modules.filter(item => item.allowed).slice(0, 4),
|
||||
/**
|
||||
* Purpose: shoplessAdmin supports index.js by holding or executing the shopless admin 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.
|
||||
*/
|
||||
shoplessAdmin: permission.isPlatformAdmin(userInfo) && !currentShop
|
||||
})
|
||||
},
|
||||
@@ -60,15 +144,35 @@ Page({
|
||||
const pendingCacheKey = `workbench:pending:${currentShopId}`
|
||||
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: true
|
||||
})
|
||||
|
||||
if (this.data.shoplessAdmin) {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: stats supports index.js by holding or executing the stats 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.
|
||||
*/
|
||||
stats: null,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
}
|
||||
@@ -88,8 +192,20 @@ Page({
|
||||
}
|
||||
this.setData({
|
||||
stats,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: Number(stats && stats.todayOrders) || 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
return
|
||||
@@ -103,30 +219,86 @@ Page({
|
||||
}
|
||||
const result = force
|
||||
? await orderApi.listOrders({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: 1
|
||||
})
|
||||
: await cache.remember(pendingCacheKey, CACHE_TTL.workbench, () => orderApi.listOrders({
|
||||
/**
|
||||
* Purpose: page supports index.js by holding or executing the page 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.
|
||||
*/
|
||||
page: 1,
|
||||
/**
|
||||
* Purpose: size supports index.js by holding or executing the size 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.
|
||||
*/
|
||||
size: 20,
|
||||
/**
|
||||
* Purpose: status supports index.js by holding or executing the status 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.
|
||||
*/
|
||||
status: 1
|
||||
}))
|
||||
if (requestId !== this._loadRequestId) {
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: stats supports index.js by holding or executing the stats 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.
|
||||
*/
|
||||
stats: null,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: Number(result && result.total) || 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
} catch (error) {
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: stats supports index.js by holding or executing the stats 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.
|
||||
*/
|
||||
stats: null,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
}
|
||||
@@ -136,14 +308,34 @@ Page({
|
||||
|
||||
if (requestId === this._loadRequestId) {
|
||||
this.setData({
|
||||
/**
|
||||
* Purpose: stats supports index.js by holding or executing the stats 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.
|
||||
*/
|
||||
stats: null,
|
||||
/**
|
||||
* Purpose: pendingOrders supports index.js by holding or executing the pending orders 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.
|
||||
*/
|
||||
pendingOrders: 0,
|
||||
/**
|
||||
* Purpose: loading supports index.js by holding or executing the loading 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.
|
||||
*/
|
||||
loading: false,
|
||||
/**
|
||||
* Purpose: initialized supports index.js by holding or executing the initialized 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.
|
||||
*/
|
||||
initialized: true
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenModule supports index.js by holding or executing the handle open module 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.
|
||||
*/
|
||||
handleOpenModule(event) {
|
||||
const path = event.currentTarget.dataset.path
|
||||
if (!path) {
|
||||
@@ -158,10 +350,18 @@ Page({
|
||||
navigation.navigate(path).catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenShops supports index.js by holding or executing the handle open shops 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.
|
||||
*/
|
||||
handleOpenShops() {
|
||||
navigation.navigate('/pages/shops/index').catch(() => undefined)
|
||||
},
|
||||
|
||||
/**
|
||||
* Purpose: handleOpenOrders supports index.js by holding or executing the handle open orders 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.
|
||||
*/
|
||||
handleOpenOrders() {
|
||||
navigation.switchTab('/pages/orders/index').catch(() => undefined)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user