- 新增地址选择插件,支持地图位置选择并返回地址和经纬度 - 新增微信订阅消息发送功能,支持审核结果、提现通知等场景 - 新增订单支付状态查询、提现收款人姓名保存等接口 - 新增服务区域管理,支持按省市区划分并同步到信息发布 - 新增资金流水和营收报表导出功能 - 新增可用优惠券查询、订单退款拆分处理等功能 - 优化后台角标显示、首页数据统计、UI配置下发等 - 修复订单支付并发问题、地区管理逻辑等
406 行
9.6 KiB
Vue
406 行
9.6 KiB
Vue
<template>
|
|
<view class="admin">
|
|
<fc-navbar title="LOGO 与图标设置" theme="gradient" :show-back="true" />
|
|
|
|
<view class="admin__wrap">
|
|
<!-- 站点信息 -->
|
|
<view class="admin__card">
|
|
<view class="admin__card-head">
|
|
<text class="admin__card-title">站点信息</text>
|
|
<text class="admin__card-tip">LOGO 会同步应用到小程序首页、登录页与我的页</text>
|
|
</view>
|
|
<view class="admin__logo-row">
|
|
<view class="admin__logo-box">
|
|
<image class="admin__logo" :src="logoPreview" mode="aspectFit" />
|
|
</view>
|
|
<view class="admin__logo-ops">
|
|
<view class="admin__btn admin__btn--primary" @click="pickLogo">
|
|
<text>上传 / 更换 LOGO</text>
|
|
</view>
|
|
<view class="admin__btn" @click="resetLogo"><text>恢复默认 LOGO</text></view>
|
|
<text class="admin__uploaded">{{ form.logo ? '当前:已自定义 LOGO' : '当前:使用内置默认 LOGO' }}</text>
|
|
</view>
|
|
</view>
|
|
<view class="admin__field">
|
|
<text class="admin__label">小程序名称</text>
|
|
<input v-model="form.siteName" class="admin__input" placeholder="请输入小程序名称"
|
|
placeholder-class="admin__ph" />
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 图标分组 -->
|
|
<view v-for="g in groups" :key="g.group" class="admin__card">
|
|
<view class="admin__card-head">
|
|
<text class="admin__card-title">{{ g.group }}</text>
|
|
<text class="admin__card-tip">{{ g.items.length }} 个图标</text>
|
|
</view>
|
|
<view class="admin__grid">
|
|
<view v-for="it in g.items" :key="it.key" class="admin__icon">
|
|
<view class="admin__icon-preview">
|
|
<image class="admin__icon-img" :src="preview(it)" mode="aspectFit" />
|
|
<text v-if="isCustom(it.key)" class="admin__icon-badge">已改</text>
|
|
</view>
|
|
<text class="admin__icon-name">{{ it.name }}</text>
|
|
<text class="admin__icon-key">{{ it.key }}</text>
|
|
<view class="admin__icon-ops">
|
|
<text class="admin__icon-op" @click="pickIcon(it)">替换</text>
|
|
<text class="admin__icon-op admin__icon-op--reset" @click="resetIcon(it)">默认</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 底部操作栏 -->
|
|
<view class="admin__bar">
|
|
<text class="admin__bar-info">共 {{ total }} 个图标 · 已自定义 {{ customCount }} 个</text>
|
|
<view class="admin__btn admin__btn--ghost" @click="resetAll"><text>全部恢复默认</text></view>
|
|
<view class="admin__btn admin__btn--primary admin__btn--lg" @click="save">
|
|
<text>{{ saving ? '保存中…' : '保存设置' }}</text>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
|
|
import { ICON_GROUPS, ICON_DEFAULTS, ICON_BASE, DEFAULT_LOGO } from '@/common/assets/icons.js'
|
|
import adminApi from '@/common/api/admin.js'
|
|
import { uploadImage } from '@/common/utils/upload.js'
|
|
import { applyUiConfig, loadUiConfig } from '@/common/store/ui.js'
|
|
|
|
export default {
|
|
components: { FcNavbar },
|
|
data() {
|
|
return {
|
|
groups: ICON_GROUPS,
|
|
form: {
|
|
siteName: '',
|
|
logo: '',
|
|
icons: {},
|
|
},
|
|
saving: false,
|
|
}
|
|
},
|
|
computed: {
|
|
total() {
|
|
return this.groups.reduce((sum, g) => sum + g.items.length, 0)
|
|
},
|
|
customCount() {
|
|
return Object.keys(this.form.icons).filter((k) => !!this.form.icons[k]).length
|
|
},
|
|
logoPreview() {
|
|
return this.form.logo || DEFAULT_LOGO
|
|
},
|
|
},
|
|
onLoad() {
|
|
this.load()
|
|
},
|
|
methods: {
|
|
async load() {
|
|
try {
|
|
await loadUiConfig(true)
|
|
const cfg = await adminApi.uiSetting()
|
|
this.form.siteName = cfg.siteName || ''
|
|
this.form.logo = cfg.logo || ''
|
|
this.form.icons = { ...(cfg.icons || {}) }
|
|
} catch (e) {
|
|
uni.showToast({ title: '配置读取失败', icon: 'none' })
|
|
}
|
|
},
|
|
/** 内置默认图标地址 */
|
|
defaultIcon(key) {
|
|
const file = ICON_DEFAULTS[key]
|
|
return file ? ICON_BASE + file : ''
|
|
},
|
|
/** 预览地址:已自定义用自定义,否则用内置 */
|
|
preview(item) {
|
|
return this.form.icons[item.key] || this.defaultIcon(item.key)
|
|
},
|
|
isCustom(key) {
|
|
return !!this.form.icons[key]
|
|
},
|
|
pickLogo() {
|
|
this.chooseImage((path) => {
|
|
this.form.logo = path
|
|
})
|
|
},
|
|
pickIcon(item) {
|
|
this.chooseImage((path) => {
|
|
this.form.icons[item.key] = path
|
|
})
|
|
},
|
|
/** 统一选图 + 上传 */
|
|
chooseImage(cb) {
|
|
uni.chooseImage({
|
|
count: 1,
|
|
success: async (res) => {
|
|
const file = (res.tempFilePaths || [])[0]
|
|
if (!file) return
|
|
try {
|
|
uni.showLoading({ title: '上传中' })
|
|
const up = await uploadImage(file)
|
|
cb(up.url || file)
|
|
uni.hideLoading()
|
|
uni.showToast({ title: '已选择,请记得保存', icon: 'none' })
|
|
} catch (e) {
|
|
uni.hideLoading()
|
|
uni.showToast({ title: e.message || '上传失败', icon: 'none' })
|
|
}
|
|
},
|
|
fail: () => {},
|
|
})
|
|
},
|
|
resetLogo() {
|
|
this.form.logo = ''
|
|
},
|
|
resetIcon(item) {
|
|
delete this.form.icons[item.key]
|
|
},
|
|
resetAll() {
|
|
uni.showModal({
|
|
title: '恢复默认',
|
|
content: '将清空所有自定义 LOGO 与图标,确定继续?',
|
|
confirmColor: '#00e070',
|
|
success: async (r) => {
|
|
if (!r.confirm) return
|
|
try {
|
|
const cfg = await adminApi.resetUiSetting()
|
|
this.form.logo = ''
|
|
this.form.icons = {}
|
|
applyUiConfig(cfg)
|
|
uni.showToast({ title: '已恢复默认', icon: 'none' })
|
|
} catch (e) {
|
|
uni.showToast({ title: e.message, icon: 'none' })
|
|
}
|
|
},
|
|
})
|
|
},
|
|
async save() {
|
|
if (this.saving) return
|
|
if (!this.form.siteName) {
|
|
uni.showToast({ title: '请填写小程序名称', icon: 'none' })
|
|
return
|
|
}
|
|
this.saving = true
|
|
try {
|
|
const cfg = await adminApi.saveUiSetting({
|
|
siteName: this.form.siteName,
|
|
logo: this.form.logo,
|
|
icons: this.form.icons,
|
|
})
|
|
// 立即应用到本地端,无需重启即可看到效果
|
|
applyUiConfig(cfg)
|
|
uni.showToast({ title: '保存成功,用户端立即生效', icon: 'none' })
|
|
} catch (e) {
|
|
uni.showToast({ title: e.message || '保存失败', icon: 'none' })
|
|
} finally {
|
|
this.saving = false
|
|
}
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
.admin {
|
|
min-height: 100vh;
|
|
background: $fc-bg;
|
|
padding-bottom: 180rpx;
|
|
}
|
|
.admin__wrap {
|
|
max-width: 1400rpx;
|
|
margin: 0 auto;
|
|
padding: 0 8rpx;
|
|
}
|
|
.admin__card {
|
|
background: #ffffff;
|
|
border-radius: $fc-radius-lg;
|
|
margin: 24rpx;
|
|
padding: 28rpx;
|
|
box-shadow: $fc-shadow;
|
|
}
|
|
.admin__card-head {
|
|
display: flex;
|
|
align-items: baseline;
|
|
justify-content: space-between;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
.admin__card-title {
|
|
font-size: $fc-font-lg;
|
|
font-weight: 700;
|
|
color: $fc-text;
|
|
}
|
|
.admin__card-tip {
|
|
font-size: $fc-font-xs;
|
|
color: $fc-text-placeholder;
|
|
}
|
|
/* ---- LOGO ---- */
|
|
.admin__logo-row {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
.admin__logo {
|
|
width: 132rpx;
|
|
height: 132rpx;
|
|
border-radius: 29rpx;
|
|
}
|
|
.admin__logo-box {
|
|
width: 160rpx;
|
|
height: 160rpx;
|
|
border-radius: 36rpx;
|
|
background: $fc-gradient-soft;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
box-shadow: $fc-shadow;
|
|
}
|
|
.admin__logo-ops {
|
|
flex: 1;
|
|
margin-left: 32rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
.admin__btn {
|
|
margin-bottom: 16rpx;
|
|
align-self: flex-start;
|
|
padding: 16rpx 36rpx;
|
|
border-radius: $fc-radius-pill;
|
|
border: 2rpx solid $fc-primary-text;
|
|
color: $fc-primary-text;
|
|
font-size: $fc-font-sm;
|
|
background: #ffffff;
|
|
&--primary {
|
|
background: $fc-gradient-primary;
|
|
border-color: transparent;
|
|
color: $fc-primary-ink;
|
|
font-weight: 600;
|
|
box-shadow: 0 8rpx 22rpx rgba(4, 48, 30, 0.28);
|
|
}
|
|
&--ghost {
|
|
align-self: center;
|
|
margin: 0 20rpx 0 0;
|
|
border-color: $fc-border;
|
|
color: $fc-text-secondary;
|
|
}
|
|
&--lg {
|
|
padding: 20rpx 60rpx;
|
|
font-size: $fc-font;
|
|
align-self: center;
|
|
margin: 0;
|
|
}
|
|
}
|
|
.admin__uploaded {
|
|
font-size: $fc-font-xs;
|
|
color: $fc-text-placeholder;
|
|
margin-top: 4rpx;
|
|
}
|
|
.admin__field {
|
|
margin-top: 28rpx;
|
|
display: flex;
|
|
align-items: center;
|
|
border-top: 2rpx solid $fc-border;
|
|
padding-top: 24rpx;
|
|
}
|
|
.admin__label {
|
|
width: 200rpx;
|
|
font-size: $fc-font;
|
|
color: $fc-text-regular;
|
|
}
|
|
.admin__input {
|
|
flex: 1;
|
|
height: 80rpx;
|
|
background: $fc-bg;
|
|
border-radius: $fc-radius;
|
|
padding: 0 24rpx;
|
|
font-size: $fc-font;
|
|
}
|
|
.admin__ph {
|
|
color: $fc-text-placeholder;
|
|
}
|
|
/* ---- 图标网格 ---- */
|
|
.admin__grid {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
}
|
|
.admin__icon {
|
|
width: 20%;
|
|
padding: 16rpx 8rpx;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
}
|
|
.admin__icon-preview {
|
|
position: relative;
|
|
width: 96rpx;
|
|
height: 96rpx;
|
|
border-radius: 24rpx;
|
|
background: $fc-gradient-soft;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.admin__icon-img {
|
|
width: 76rpx;
|
|
height: 76rpx;
|
|
}
|
|
.admin__icon-badge {
|
|
position: absolute;
|
|
top: -10rpx;
|
|
right: -10rpx;
|
|
padding: 2rpx 10rpx;
|
|
border-radius: $fc-radius-pill;
|
|
background: $fc-gradient-warm;
|
|
color: #ffffff;
|
|
font-size: 18rpx;
|
|
}
|
|
.admin__icon-name {
|
|
margin-top: 12rpx;
|
|
font-size: $fc-font-xs;
|
|
color: $fc-text;
|
|
text-align: center;
|
|
}
|
|
.admin__icon-key {
|
|
margin-top: 4rpx;
|
|
font-size: 18rpx;
|
|
color: $fc-text-placeholder;
|
|
}
|
|
.admin__icon-ops {
|
|
display: flex;
|
|
margin-top: 10rpx;
|
|
}
|
|
.admin__icon-op {
|
|
padding: 4rpx 14rpx;
|
|
margin: 0 4rpx;
|
|
border-radius: $fc-radius-pill;
|
|
background: $fc-primary-lighter;
|
|
color: $fc-primary-text;
|
|
font-size: 20rpx;
|
|
&--reset {
|
|
background: $fc-bg;
|
|
color: $fc-text-secondary;
|
|
}
|
|
}
|
|
/* ---- 底部操作栏 ---- */
|
|
.admin__bar {
|
|
position: fixed;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 18rpx 32rpx;
|
|
padding-bottom: calc(18rpx + env(safe-area-inset-bottom));
|
|
background: #ffffff;
|
|
border-top: 2rpx solid $fc-border;
|
|
box-shadow: 0 -6rpx 24rpx rgba(4, 48, 30, 0.08);
|
|
}
|
|
.admin__bar-info {
|
|
flex: 1;
|
|
font-size: $fc-font-sm;
|
|
color: $fc-text-secondary;
|
|
}
|
|
</style>
|
|
|