优化
This commit is contained in:
parent
fbb9c67e24
commit
a711c6e594
|
|
@ -28,6 +28,15 @@
|
|||
<text class="record-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<!-- 切换身份 -->
|
||||
<view class="record-entry" style="margin-top:20rpx" @click="goRoleSelect">
|
||||
<view style="display:flex;align-items:center">
|
||||
<image src="/static/ic_switch.png" class="logout-icon" />
|
||||
<text class="record-label">切换身份</text>
|
||||
</view>
|
||||
<text class="record-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<!-- 退出登录 -->
|
||||
<view class="record-entry logout-entry" @click="handleLogout">
|
||||
<view style="display:flex;align-items:center">
|
||||
|
|
@ -237,6 +246,11 @@
|
|||
uni.navigateTo({ url: '/pages/merchant/records' })
|
||||
},
|
||||
|
||||
/** 切换身份 */
|
||||
goRoleSelect() {
|
||||
uni.navigateTo({ url: '/pages/login/role-select' })
|
||||
},
|
||||
|
||||
/** 退出登录 */
|
||||
handleLogout() {
|
||||
uni.showModal({
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
<text class="arrow-right">›</text>
|
||||
</view>
|
||||
<view v-if="isLogin && userInfo.isMerchant" class="menu-item" @click="goRoleSelect">
|
||||
<image class="menu-icon" src="/static/ic_pitch.png" mode="aspectFit" />
|
||||
<image class="menu-icon" src="/static/ic_switch.png" mode="aspectFit" />
|
||||
<text class="menu-text">切换身份</text>
|
||||
<text class="arrow-right">›</text>
|
||||
</view>
|
||||
|
|
@ -158,9 +158,7 @@
|
|||
// 即使接口失败也清除本地状态
|
||||
}
|
||||
clearAuth()
|
||||
this.isLogin = false
|
||||
this.userInfo = {}
|
||||
uni.showToast({ title: '已退出登录', icon: 'none' })
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
<!-- 右侧信息 -->
|
||||
<view class="coupon-right">
|
||||
<text class="coupon-name">{{ item.name }}</text>
|
||||
<text class="coupon-info">适用门店:{{ item.stores.map(s => s.name).join('、') }}</text>
|
||||
<text
|
||||
class="coupon-info">有效期:{{ isPermanent(item) ? '永久有效' : formatDate(item.validStart) + '至' + formatDate(item.validEnd) }}</text>
|
||||
<text class="coupon-info">剩余数量:{{ item.remainingCount }} 张</text>
|
||||
|
|
@ -92,6 +93,7 @@
|
|||
import {
|
||||
getPopup
|
||||
} from '@/api/config'
|
||||
import { isLoggedIn, checkLogin } from '@/utils/auth'
|
||||
import RichContentPopup from '@/components/RichContentPopup.vue'
|
||||
import ConfirmDialog from '@/components/ConfirmDialog.vue'
|
||||
import NavBar from '@/components/NavBar.vue'
|
||||
|
|
@ -150,21 +152,25 @@
|
|||
async loadData() {
|
||||
this.loading = true
|
||||
try {
|
||||
const [balanceRes, availableRes, storesRes] = await Promise.all([
|
||||
getBalance(), getAvailable(), getStores()
|
||||
])
|
||||
this.balance = balanceRes.balance ?? balanceRes.data?.balance ?? 0
|
||||
this.availableList = availableRes.data || availableRes || []
|
||||
const stores = storesRes.data || storesRes || []
|
||||
this.storeOptions = [{
|
||||
label: '全部',
|
||||
value: ''
|
||||
},
|
||||
...stores.map(s => ({
|
||||
label: s.name,
|
||||
value: s.id
|
||||
}))
|
||||
]
|
||||
// 未登录时跳过积分余额请求
|
||||
const requests = [getAvailable(), getStores()]
|
||||
if (isLoggedIn()) {
|
||||
requests.unshift(getBalance())
|
||||
}
|
||||
const results = await Promise.all(requests)
|
||||
|
||||
if (isLoggedIn()) {
|
||||
const balanceRes = results[0]
|
||||
this.balance = balanceRes.balance ?? balanceRes.data?.balance ?? 0
|
||||
this.availableList = results[1].data || results[1] || []
|
||||
const stores = results[2].data || results[2] || []
|
||||
this.storeOptions = [{ label: '全部', value: '' }, ...stores.map(s => ({ label: s.name, value: s.id }))]
|
||||
} else {
|
||||
this.balance = 0
|
||||
this.availableList = results[0].data || results[0] || []
|
||||
const stores = results[1].data || results[1] || []
|
||||
this.storeOptions = [{ label: '全部', value: '' }, ...stores.map(s => ({ label: s.name, value: s.id }))]
|
||||
}
|
||||
// 加载积分页背景图配置
|
||||
try {
|
||||
const bgRes = await getPopup('points-bg')
|
||||
|
|
@ -199,6 +205,7 @@
|
|||
})
|
||||
},
|
||||
onExchange(item) {
|
||||
if (!checkLogin()) return
|
||||
if (item.remainingCount <= 0) return
|
||||
if (item.pointsCost > 0 && this.balance < item.pointsCost) {
|
||||
uni.showToast({
|
||||
|
|
|
|||
BIN
miniapp/static/ic_switch.png
Normal file
BIN
miniapp/static/ic_switch.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
|
|
@ -26,6 +26,7 @@ public class CouponController : ControllerBase
|
|||
/// GET /api/coupons/available
|
||||
/// </summary>
|
||||
[HttpGet("available")]
|
||||
[AllowAnonymous]
|
||||
public async Task<ActionResult<ApiResponse<List<AvailableCouponResponse>>>> GetAvailable()
|
||||
{
|
||||
var templates = await _couponService.GetAvailableTemplatesAsync();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user