This commit is contained in:
18631081161 2026-03-11 22:20:56 +08:00
parent fbb9c67e24
commit a711c6e594
5 changed files with 39 additions and 19 deletions

View File

@ -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({

View File

@ -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' })
}
}
}

View File

@ -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()
])
//
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 = availableRes.data || availableRes || []
const stores = storesRes.data || storesRes || []
this.storeOptions = [{
label: '全部',
value: ''
},
...stores.map(s => ({
label: s.name,
value: s.id
}))
]
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({

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -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();