统一甲屿云命名体系

This commit is contained in:
2026-06-29 23:26:43 +08:00
parent 48c47fe3ff
commit bc8a7d8d4c
1268 changed files with 3477 additions and 3511 deletions
@@ -0,0 +1,87 @@
const couponApi = require('../../api/coupon')
const userApi = require('../../api/user')
const navigation = require('../../utils/navigation')
const { getTempRecord, clearTempRecord } = require('../../utils/storage')
Page({
data: {
coupon: null,
users: [],
quantity: 1
},
onLoad() {
const coupon = getTempRecord('currentCoupon', null)
this.setData({
coupon
})
this.loadUsers()
},
onUnload() {
clearTempRecord('currentCoupon')
},
async loadUsers() {
try {
const users = await userApi.listAllUsers()
this.setData({
users: (Array.isArray(users) ? users : []).map(item => ({
...item,
valueId: String(item.id),
checked: false
}))
})
} catch (error) {
wx.showToast({
title: error.message || '可发放用户加载失败',
icon: 'none'
})
}
},
handleUserCheck(event) {
const selected = event.detail.value || []
this.setData({
users: this.data.users.map(item => ({
...item,
checked: selected.includes(item.valueId)
}))
})
},
handleQuantityInput(event) {
this.setData({
quantity: event.detail.value
})
},
async handleSubmit() {
const selectedUserIds = this.data.users.filter(item => item.checked).map(item => Number(item.id))
if (!selectedUserIds.length) {
wx.showToast({
title: '请至少选择一个用户',
icon: 'none'
})
return
}
try {
await couponApi.distributeCoupon({
couponId: this.data.coupon.id,
userIds: selectedUserIds,
quantity: Number(this.data.quantity || 1)
})
wx.showToast({
title: '优惠券已发放',
icon: 'none'
})
navigation.goBack('/pages/coupons/index')
} catch (error) {
wx.showToast({
title: error.message || '发放失败',
icon: 'none'
})
}
}
})
@@ -0,0 +1,5 @@
{
"usingComponents": {
"navigation-bar": "/admin/components/navigation-bar/navigation-bar"
}
}
@@ -0,0 +1,28 @@
<navigation-bar title="发放优惠券" back="{{true}}" color="#f6efe7" background="#081518"></navigation-bar>
<view class="page-shell">
<view class="page-stack">
<view class="surface-card" wx:if="{{coupon}}">
<text class="section-title">{{coupon.couponName}}</text>
<text class="section-desc">选择用户后批量发放,数量默认 1。移动端只保留高频发放能力,不把 Web 的宽表格搬过来。</text>
<view class="field-group">
<text class="field-label">发放数量</text>
<input class="field-input" type="number" value="{{quantity}}" bindinput="handleQuantityInput"></input>
</view>
<view class="field-group">
<text class="field-label">选择用户</text>
<checkbox-group bindchange="handleUserCheck">
<block wx:for="{{users}}" wx:key="id">
<label class="checkbox-chip {{item.checked ? 'active' : ''}}">
<checkbox value="{{item.valueId}}" checked="{{item.checked}}" />
{{item.nickname || item.account}}
</label>
</block>
</checkbox-group>
</view>
<view class="action-row">
<button class="primary-btn" bindtap="handleSubmit">确认发放</button>
</view>
</view>
</view>
</view>
@@ -0,0 +1,5 @@
@import "../../app.wxss";
checkbox {
transform: scale(0.75);
margin-right: 8rpx;
}