重构优惠券页面ui
This commit is contained in:
464
.pages-backup/pages.consumer.2026-06-05T00-38-35-097Z.json
Normal file
464
.pages-backup/pages.consumer.2026-06-05T00-38-35-097Z.json
Normal file
@@ -0,0 +1,464 @@
|
||||
{
|
||||
"pages": [
|
||||
{
|
||||
"path": "pages/main/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "首页",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/boot",
|
||||
"style": {
|
||||
"navigationBarTitleText": ""
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/login",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/register",
|
||||
"style": {
|
||||
"navigationBarTitleText": "注册"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/forgot-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "忘记密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/terms",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户协议与隐私政策"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/center",
|
||||
"style": {
|
||||
"navigationBarTitleText": "用户中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "个人资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/change-password",
|
||||
"style": {
|
||||
"navigationBarTitleText": "修改密码"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-phone",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定手机"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/user/bind-email",
|
||||
"style": {
|
||||
"navigationBarTitleText": "绑定邮箱"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/messages",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息",
|
||||
"enablePullDownRefresh": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/cart",
|
||||
"style": {
|
||||
"navigationBarTitleText": "购物车",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/main/category",
|
||||
"style": {
|
||||
"navigationBarTitleText": "分类",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
}
|
||||
],
|
||||
"subPackages": [
|
||||
{
|
||||
"root": "pages/mall/consumer",
|
||||
"pages": [
|
||||
{
|
||||
"path": "settings",
|
||||
"style": {
|
||||
"navigationBarTitleText": "设置"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "edit-profile",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑资料"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "wallet",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的钱包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "withdraw",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额提现"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "search",
|
||||
"style": {
|
||||
"navigationBarTitleText": "搜索",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "channel-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "频道详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "shop-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "店铺详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "coupons",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的优惠券"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "favorites",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的收藏"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "footprint",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的足迹"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address",
|
||||
"style": {
|
||||
"navigationBarTitleText": "地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "收货地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "address-edit",
|
||||
"style": {
|
||||
"navigationBarTitleText": "编辑地址"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "payment-success",
|
||||
"style": {
|
||||
"navigationBarTitleText": "支付成功",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "orders",
|
||||
"style": {
|
||||
"navigationBarTitleText": "",
|
||||
"navigationStyle": "custom",
|
||||
"enablePullDownRefresh": true,
|
||||
"backgroundColor": "#f5f5f5"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订单详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "logistics",
|
||||
"style": {
|
||||
"navigationBarTitleText": "物流详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "评价晒单"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "退款/售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "apply-refund",
|
||||
"style": {
|
||||
"navigationBarTitleText": "申请售后"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "refund-review",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "chat_new",
|
||||
"style": {
|
||||
"navigationBarTitleText": "客服聊天(新版)"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-list",
|
||||
"style": {
|
||||
"navigationBarTitleText": "软件订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/plan-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "订阅详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/subscribe-checkout",
|
||||
"style": {
|
||||
"navigationBarTitleText": "确认订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/my-subscriptions",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的订阅"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "subscription/followed-shops",
|
||||
"style": {
|
||||
"navigationBarTitleText": "关注店铺"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/signin",
|
||||
"style": {
|
||||
"navigationBarTitleText": "签到"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange",
|
||||
"style": {
|
||||
"navigationBarTitleText": "积分兑换"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "points/exchange-records",
|
||||
"style": {
|
||||
"navigationBarTitleText": "兑换记录"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "red-packets/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的红包"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡管理"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/add",
|
||||
"style": {
|
||||
"navigationBarTitleText": "添加银行卡"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "居家上门服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/apply",
|
||||
"style": {
|
||||
"navigationBarTitleText": "提交服务申请",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/service-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "预约服务",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/order-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "服务单详情",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "home-service/feedback",
|
||||
"style": {
|
||||
"navigationBarTitleText": "验收反馈",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "bank-cards/verify",
|
||||
"style": {
|
||||
"navigationBarTitleText": "银行卡验证"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "balance/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "余额"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "my-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "我的评价"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "message-detail",
|
||||
"style": {
|
||||
"navigationBarTitleText": "消息详情"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "member/index",
|
||||
"style": {
|
||||
"navigationBarTitleText": "会员中心"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "product-reviews",
|
||||
"style": {
|
||||
"navigationBarTitleText": "商品评价"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"tabBar": {
|
||||
"color": "#999999",
|
||||
"selectedColor": "#ff5000",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/main/index",
|
||||
"text": "首页",
|
||||
"iconPath": "static/tabbar/home.png",
|
||||
"selectedIconPath": "static/tabbar/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/messages",
|
||||
"text": "消息",
|
||||
"iconPath": "static/tabbar/message.png",
|
||||
"selectedIconPath": "static/tabbar/message.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/cart",
|
||||
"text": "购物车",
|
||||
"iconPath": "static/tabbar/cart.png",
|
||||
"selectedIconPath": "static/tabbar/cart.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/main/profile",
|
||||
"text": "我的",
|
||||
"iconPath": "static/tabbar/user.png",
|
||||
"selectedIconPath": "static/tabbar/user.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "mall",
|
||||
"navigationBarBackgroundColor": "#FFFFFF",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
},
|
||||
"condition": {
|
||||
"current": 0,
|
||||
"list": [
|
||||
{
|
||||
"name": "consumer端",
|
||||
"path": "pages/main/index",
|
||||
"query": "role=consumer"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -387,12 +387,21 @@ export type UserAddress = {
|
||||
|
||||
export type UserCoupon = {
|
||||
id: string
|
||||
template_id: string
|
||||
template_name: string
|
||||
amount: number
|
||||
min_spend: number
|
||||
expire_at: string
|
||||
status: number
|
||||
discount_type?: number
|
||||
discount_type: number
|
||||
coupon_type: number
|
||||
used_at: string
|
||||
received_at: string
|
||||
merchant_id: string
|
||||
shop_name: string
|
||||
shop_logo: string
|
||||
scope_type: string
|
||||
consumer_deleted_at?: string
|
||||
}
|
||||
|
||||
export type ChatRoom = {
|
||||
@@ -7699,7 +7708,7 @@ class SupabaseService {
|
||||
}
|
||||
|
||||
// 获取用户优惠券列表
|
||||
async getUserCoupons(status: number = 1): Promise<UserCoupon[]> {
|
||||
async getUserCoupons(status?: number): Promise<UserCoupon[]> {
|
||||
try {
|
||||
const userId = this.getCurrentUserId()
|
||||
if (userId == null) {
|
||||
@@ -7707,13 +7716,16 @@ class SupabaseService {
|
||||
return empty
|
||||
}
|
||||
|
||||
const response = await supa
|
||||
let query = supa
|
||||
.from('ml_user_coupons')
|
||||
.select('*, template:ml_coupon_templates(name, discount_value, min_order_amount, coupon_type, discount_type)')
|
||||
.select('*, template:ml_coupon_templates(name, discount_value, min_order_amount, coupon_type, discount_type, merchant_id, applicable_products)')
|
||||
.eq('user_id', userId!)
|
||||
.eq('status', status.toString())
|
||||
.order('expire_at', { ascending: true })
|
||||
.execute()
|
||||
|
||||
if (status != null) {
|
||||
query = query.eq('status', status.toString())
|
||||
}
|
||||
|
||||
const response = await query.order('expire_at', { ascending: true }).execute()
|
||||
|
||||
if (response.error != null) {
|
||||
console.error('获取优惠券失败:', response.error)
|
||||
@@ -7745,20 +7757,34 @@ class SupabaseService {
|
||||
}
|
||||
|
||||
const coupons: UserCoupon[] = []
|
||||
const merchantIds: string[] = []
|
||||
|
||||
for (let i = 0; i < rawData.length; i++) {
|
||||
const item = rawData[i]
|
||||
let template: any | null = null
|
||||
let itemId = ''
|
||||
let itemTemplateId = ''
|
||||
let itemStatus = 1
|
||||
let itemUsedAt = ''
|
||||
let itemReceivedAt = ''
|
||||
let itemExpire = ''
|
||||
|
||||
if (item instanceof UTSJSONObject) {
|
||||
template = item.get('template') as any | null
|
||||
itemId = item.getString('id') ?? ''
|
||||
itemTemplateId = item.getString('template_id') ?? ''
|
||||
itemStatus = item.getNumber('status') ?? 1
|
||||
itemUsedAt = item.getString('used_at') ?? ''
|
||||
itemReceivedAt = item.getString('received_at') ?? ''
|
||||
itemExpire = item.getString('expire_at') ?? ''
|
||||
} else {
|
||||
const iObj = JSON.parse(JSON.stringify(item)) as UTSJSONObject
|
||||
template = iObj.get('template') as any | null
|
||||
itemId = iObj.getString('id') ?? ''
|
||||
itemTemplateId = iObj.getString('template_id') ?? ''
|
||||
itemStatus = iObj.getNumber('status') ?? 1
|
||||
itemUsedAt = iObj.getString('used_at') ?? ''
|
||||
itemReceivedAt = iObj.getString('received_at') ?? ''
|
||||
itemExpire = iObj.getString('expire_at') ?? ''
|
||||
}
|
||||
|
||||
@@ -7768,33 +7794,127 @@ class SupabaseService {
|
||||
let tAmount = 0
|
||||
let tMin = 0
|
||||
let tDiscountType = 1
|
||||
let tCouponType = 1
|
||||
let tMerchantId = ''
|
||||
let tScopeType = 'store'
|
||||
|
||||
if (template instanceof UTSJSONObject) {
|
||||
tName = template.getString('name') ?? '优惠券'
|
||||
tAmount = template.getNumber('discount_value') ?? 0
|
||||
tMin = template.getNumber('min_order_amount') ?? 0
|
||||
tDiscountType = template.getNumber('discount_type') ?? 1
|
||||
tCouponType = template.getNumber('coupon_type') ?? 1
|
||||
tMerchantId = template.getString('merchant_id') ?? ''
|
||||
|
||||
const applicableProducts = template.get('applicable_products')
|
||||
if (applicableProducts != null) {
|
||||
let hasProducts = false
|
||||
if (Array.isArray(applicableProducts)) {
|
||||
const arr = applicableProducts as any[]
|
||||
if (arr.length > 0) hasProducts = true
|
||||
} else if (typeof applicableProducts === 'string') {
|
||||
const s = applicableProducts as string
|
||||
if (s != '' && s != '[]') {
|
||||
try {
|
||||
const parsed = JSON.parse(s)
|
||||
if (Array.isArray(parsed) && (parsed as any[]).length > 0) {
|
||||
hasProducts = true
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (hasProducts) {
|
||||
tScopeType = 'product'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const tObj = JSON.parse(JSON.stringify(template)) as UTSJSONObject
|
||||
tName = tObj.getString('name') ?? '优惠券'
|
||||
tAmount = tObj.getNumber('discount_value') ?? 0
|
||||
tMin = tObj.getNumber('min_order_amount') ?? 0
|
||||
tDiscountType = tObj.getNumber('discount_type') ?? 1
|
||||
tCouponType = tObj.getNumber('coupon_type') ?? 1
|
||||
tMerchantId = tObj.getString('merchant_id') ?? ''
|
||||
|
||||
const applicableProducts = tObj.get('applicable_products')
|
||||
if (applicableProducts != null) {
|
||||
let hasProducts = false
|
||||
if (Array.isArray(applicableProducts)) {
|
||||
const arr = applicableProducts as any[]
|
||||
if (arr.length > 0) hasProducts = true
|
||||
} else if (typeof applicableProducts === 'string') {
|
||||
const s = applicableProducts as string
|
||||
if (s != '' && s != '[]') {
|
||||
try {
|
||||
const parsed = JSON.parse(s)
|
||||
if (Array.isArray(parsed) && (parsed as any[]).length > 0) {
|
||||
hasProducts = true
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (hasProducts) {
|
||||
tScopeType = 'product'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tMerchantId != '' && merchantIds.indexOf(tMerchantId) == -1) {
|
||||
merchantIds.push(tMerchantId)
|
||||
}
|
||||
|
||||
const couponItem: UserCoupon = {
|
||||
id: itemId,
|
||||
template_id: itemTemplateId,
|
||||
template_name: tName,
|
||||
amount: tAmount,
|
||||
min_spend: tMin,
|
||||
expire_at: itemExpire,
|
||||
status: status,
|
||||
discount_type: tDiscountType
|
||||
status: itemStatus,
|
||||
discount_type: tDiscountType,
|
||||
coupon_type: tCouponType,
|
||||
used_at: itemUsedAt,
|
||||
received_at: itemReceivedAt,
|
||||
merchant_id: tMerchantId,
|
||||
shop_name: '',
|
||||
shop_logo: '',
|
||||
scope_type: tScopeType
|
||||
}
|
||||
|
||||
coupons.push(couponItem)
|
||||
}
|
||||
|
||||
// 批量查询店铺信息
|
||||
if (merchantIds.length > 0) {
|
||||
try {
|
||||
const shopRes = await supa
|
||||
.from('ml_shops')
|
||||
.select('merchant_id, shop_name, shop_logo')
|
||||
.in('merchant_id', merchantIds as any[])
|
||||
.execute()
|
||||
|
||||
if (shopRes.error == null && shopRes.data != null) {
|
||||
const shopRows = shopRes.data as any[]
|
||||
for (let i = 0; i < shopRows.length; i++) {
|
||||
const shopObj = normalizeUtsObject(shopRows[i])
|
||||
const mid = shopObj.getString('merchant_id') ?? ''
|
||||
const sname = shopObj.getString('shop_name') ?? ''
|
||||
const slogo = shopObj.getString('shop_logo') ?? ''
|
||||
if (mid != '') {
|
||||
for (let j = 0; j < coupons.length; j++) {
|
||||
if (coupons[j].merchant_id == mid) {
|
||||
coupons[j].shop_name = sname
|
||||
coupons[j].shop_logo = slogo
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (shopErr) {
|
||||
console.error('查询店铺信息失败:', shopErr)
|
||||
}
|
||||
}
|
||||
|
||||
return coupons
|
||||
} catch (e) {
|
||||
console.error('获取优惠券异常:', e)
|
||||
@@ -7802,6 +7922,38 @@ class SupabaseService {
|
||||
}
|
||||
}
|
||||
|
||||
// 软删除用户优惠券(消费者端自行管理)
|
||||
async softDeleteUserCoupons(ids: string[]): Promise<boolean> {
|
||||
try {
|
||||
const userId = this.getCurrentUserId()
|
||||
if (userId == null || ids.length == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
const nowIso = new Date().toISOString()
|
||||
|
||||
const response = await supa
|
||||
.from('ml_user_coupons')
|
||||
.update({
|
||||
consumer_deleted_at: nowIso,
|
||||
consumer_deleted_by: userId,
|
||||
consumer_delete_reason: 'user_delete'
|
||||
} as any)
|
||||
.in('id', ids as any[])
|
||||
.eq('user_id', userId!)
|
||||
.execute()
|
||||
|
||||
if (response.error != null) {
|
||||
console.error('软删除优惠券失败:', response.error)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
} catch (e) {
|
||||
console.error('软删除优惠券异常:', e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 获取可用优惠券数量
|
||||
async getUserCouponCount(): Promise<number> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user