refactor(after-sales): 删除独立售后页面并整合至订单列表

- 删除 afterSales.vue 独立页面,将售后入口统一至 myOrder 页面
- 修改售后相关页面跳转路径为 /pages/order/myOrder?status=5
- 重构 applySuccess 页面,增加微信订阅消息授权与视觉优化
- 重构预存款明细页面,增加收支筛选与日志解析功能
- 新增 store 端 API 基础地址配置
This commit is contained in:
pikachu1995@126.com
2026-11-02 16:57:29 +08:00
parent 1411f15679
commit e1a48d6d11
34 changed files with 7082 additions and 1361 deletions

View File

@@ -169,11 +169,16 @@ lilishop-uniapp
| ✅ 购物卡 | ✅ 腾讯云-云直播 |
| ✅ 卡密商品 | ✅ 二级分销 |
| ✅ 定时任务管理 | ✅ 预约服务商品 |
| ✅ 主题色管理 | ✅ 商家发货改造(整单/拆单/无需配送) |
| ✅ 主题色管理 | ✅ 新增无需配送发货方式 |
| ✅ 多维统计(营业/商品/会员/积分/储值/营销/分销) | ✅ 经营报表(店铺业绩/商品同比环比/订单明细/销售汇总) |
| ✅ 分类页多模板设置 | ✅ 移动端楼层装修组件库 |
| ✅ PC端楼层装修重构 | ✅ 全站统一顶栏 |
| ✅ PC端店铺独立列表 | ✅ 敏感词场景化过滤 |
### 🔜 近期规划中
- 🔜 店铺结算汇总 & 结算台账
- 🔜 支付方式汇总 & 钱包流水 & 财务汇总
- 🔜 微信小店对接
- 🔜 抖店对接
- 🔜 微信小程序原生重构与体验对齐
- 🔜 OpenAPI 开放平台与开发者中心

View File

@@ -110,3 +110,15 @@ export function getLogisticsMessages(params) {
data
});
}
/**
* 获取微信公众号通知配置及绑定状态
*/
export function getWechatOfficialAccountSetting() {
return http.request({
url: '/message/wechatOfficialAccount',
method: Method.GET,
needToken: true,
});
}

View File

@@ -101,12 +101,18 @@ const props = withDefaults(defineProps<{
left?: string
top?: string
business?: string
apiType?: string
}>(), {
height: '80rpx',
width: '350rpx',
left: '180rpx',
top: '30rpx',
business: 'LOGIN'
business: 'LOGIN',
apiType: 'buyer'
})
const sliderBaseUrl = computed(() => {
return props.apiType === 'store' ? api.store : api.buyer
})
const store = useStore()
@@ -182,7 +188,7 @@ function getCode() {
storage.setUuid(uuid.v1())
}
uni.request({
url: api.buyer + '/common/slider/' + props.business,
url: sliderBaseUrl.value + '/common/slider/' + props.business,
header: {
uuid: storage.getUuid()
},
@@ -217,7 +223,7 @@ function end() {
uni.request({
method: 'POST',
url:
api.buyer +
sliderBaseUrl.value +
'/common/slider/' +
props.business +
'?xPos=' +

View File

@@ -1,35 +1,41 @@
/**
* buyer : 买家 API(baseURL 为 buyer + /buyer)
*/
// 开发环境
const dev = {
buyer: "https://buyer-api.pickmall.cn",
im: "https://im-api.pickmall.cn",
mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
};
// 生产环境
const prod = {
buyer: "https://buyer-api.pickmall.cn",
im: "https://im-api.pickmall.cn",
mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
};
let api = dev;
if (process.env.NODE_ENV == "development") {
api = dev;
} else {
api = prod;
}
// 微信小程序、App 打包使用生产环境配置
// #ifdef MP-WEIXIN || APP-PLUS
api = prod;
// #endif
const buyerHost = api.buyer;
api.buyer = buyerHost + "/buyer";
api.im = api.im + "/im";
export default {
...api,
buyerHost,
};
/**
* buyer : 买家 API(baseURL 为 buyer + /buyer)
* store : 商家 API(baseURL 为 store + /store)
*/
// 开发环境
const dev = {
buyer: "https://buyer-api.pickmall.cn",
store: "https://admin-api.pickmall.cn",
im: "https://im-api.pickmall.cn",
mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
};
// 生产环境
const prod = {
buyer: "https://buyer-api.pickmall.cn",
store: "https://admin-api.pickmall.cn",
im: "https://im-api.pickmall.cn",
mqtt: "wss://lilishop-mqtt-pull.dllll.xyz/mqtt",
};
let api = dev;
if (process.env.NODE_ENV == "development") {
api = dev;
} else {
api = prod;
}
// 微信小程序、App 打包使用生产环境配置
// #ifdef MP-WEIXIN || APP-PLUS
api = prod;
// #endif
const buyerHost = api.buyer;
const storeHost = api.store;
api.buyer = buyerHost + "/buyer";
api.store = storeHost + "/store";
api.im = api.im + "/im";
export default {
...api,
buyerHost,
storeHost,
};

View File

@@ -2,18 +2,105 @@
* 微信小程序支付
* 此处针对于微信小程序开发的支付插件
* 第一次支付成功后会跳出订阅的消息 如果用户拒绝或同意都会跳转到支付成功页面
* 如果点击订阅 会将状态写进缓存 之后不再提醒。
*
* @param {sn,price}
*
* @param {sn,price,orderPromotionType}
*/
import { getWeChatMpMessage } from "@/api/message.js";
import { initiatePay } from "@/api/trade";
const SCENE_NAME_MAP = {
ORDER_DELIVER: ["订单发货提醒", "订单发货通知"],
ORDER_COMPLETE: ["订单已完成提醒", "订单完成通知"],
PINTUAN_SUCCESS: ["拼团成功通知"],
AFTER_SALE_AUDIT: ["售后申请审核通知", "售后审核通知"],
POINT_CHANGE: ["积分变更提醒", "积分变更通知"],
WALLET_CHANGE: ["账户余额变动通知", "余额账户变更通知"],
WALLET_WITHDRAWAL_AUDIT_ERROR: ["提现结果通知", "提现申请审核通知"],
};
let cachedMpMessageList = null;
export function prefetchMpMessageTemplates() {
return getWeChatMpMessage()
.then((res) => {
if (res && res.data && Array.isArray(res.data.result)) {
cachedMpMessageList = res.data.result;
}
return cachedMpMessageList || [];
})
.catch(() => cachedMpMessageList || []);
}
function extractTmplIdsByScenes(list, targetScenes) {
const tmplIds = [];
(targetScenes || []).forEach((scene) => {
const aliasNames = SCENE_NAME_MAP[scene] || [];
const matched = (list || []).find(
(item) =>
item &&
item.enable !== false &&
item.code &&
(item.sceneCode === scene || aliasNames.includes(item.name))
);
if (matched && matched.code && !tmplIds.includes(matched.code)) {
tmplIds.push(matched.code);
}
});
return tmplIds.slice(0, 3);
}
export function subscribeMpMessageByScenes(sceneCodes, onComplete) {
const done = typeof onComplete === "function" ? onComplete : () => {};
const targetScenes = Array.isArray(sceneCodes) ? sceneCodes : [];
if (!targetScenes.length) {
done();
return;
}
if (Array.isArray(cachedMpMessageList) && cachedMpMessageList.length) {
const finalTmplIds = extractTmplIdsByScenes(cachedMpMessageList, targetScenes);
if (!finalTmplIds.length) {
done();
return;
}
console.log("[微信订阅消息] 请求订阅 tmplIds:", finalTmplIds);
uni.requestSubscribeMessage({
tmplIds: finalTmplIds,
complete: (res) => {
console.log("[微信订阅消息] 授权返回结果:", res);
done();
},
});
return;
}
prefetchMpMessageTemplates()
.then((list) => {
const finalTmplIds = extractTmplIdsByScenes(list, targetScenes);
if (!finalTmplIds.length) {
done();
return;
}
uni.requestSubscribeMessage({
tmplIds: finalTmplIds,
complete: () => done(),
});
})
.catch(() => done());
}
export function subscribePayMessageThen(onComplete, options = {}) {
const isPintuan =
options &&
String(options.orderPromotionType || "").toUpperCase() === "PINTUAN";
const scenes = isPintuan
? ["ORDER_DELIVER", "ORDER_COMPLETE", "PINTUAN_SUCCESS"]
: ["ORDER_DELIVER", "ORDER_COMPLETE"];
subscribeMpMessageByScenes(scenes, onComplete);
}
class LiLiWXPay {
constructor(...payList) {
this.data = payList[0];
console.log(payList);
// 调用支付
this.pay = () => {
uni.showLoading({
title: "加载中",
@@ -26,7 +113,6 @@ class LiLiWXPay {
};
const paymentMethod = "WECHAT";
const paymentClient = "MP";
// 调用支付
initiatePay(paymentMethod, paymentClient, submitData).then((res) => {
let response = res.data.result;
uni.hideLoading();
@@ -38,16 +124,25 @@ class LiLiWXPay {
package: response.package,
signType: response.signType,
paySign: response.paySign,
success: (e) => {
success: () => {
uni.showToast({
icon: "none",
title: "支付成功!",
});
sendMessage(payList[0].price);
subscribePayMessageThen(
() => {
uni.redirectTo({
url:
"/pages/cart/payment/success?paymentMethod=WECHAT" +
"&payPrice=" +
payList[0].price,
});
},
{ orderPromotionType: this.data.orderPromotionType }
);
},
fail: (e) => {
this.exception = e;
// 支付异常或支付失败之后跳转到订单页面
uni.showModal({
content: "支付失败,如果您已支付,请勿反复支付",
showCancel: false,
@@ -64,41 +159,4 @@ class LiLiWXPay {
}
}
function sendMessage(price) {
//订阅消息
getWeChatMpMessage().then((res) => {
var message = res.data.result;
var templateid = message.map((item) => item.code);
uni.requestSubscribeMessage({
tmplIds: templateid,
success: (res) => {
},
fail: (res) => {
console.log('fail', res)
uni.showToast({
icon: "none",
title: "订阅消息失败",
})
},
complete: (res) => {
console.log('complete', res)
/**
* 已经支付成功
*/
uni.redirectTo({
url:
"/pages/cart/payment/success?paymentMethod=WECHAT" +
"&payPrice=" +
price,
});
},
});
});
}
export default LiLiWXPay;

View File

@@ -0,0 +1,26 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 分页获取客户评价列表
* @param {Object} params { grade, goodsName, replyStatus, pageNumber, pageSize }
*/
export function getStoreEvaluationList(params) {
return storeHttp.request({
url: "/member/evaluation",
method: "GET",
params,
});
}
/**
* 回复客户评价
* @param {String} id 评价ID
* @param {String} reply 回复文字
* @param {String} replyImage 可选回复图片
*/
export function replyStoreEvaluation(id, reply, replyImage = "") {
return storeHttp.request({
url: `/member/evaluation/reply/${id}?reply=${encodeURIComponent(reply)}&replyImage=${encodeURIComponent(replyImage)}`,
method: "PUT",
});
}

View File

@@ -0,0 +1,70 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 获取商家商品列表
* @param {Object} params { goodsName, marketEnable, authFlag, pageNumber, pageSize }
*/
export function getStoreGoodsList(params) {
return storeHttp.request({
url: "/goods/goods/list",
method: "GET",
params,
});
}
/**
* 获取商家商品详情
* @param {String} id 商品ID
*/
export function getStoreGoodsDetail(id) {
return storeHttp.request({
url: `/goods/goods/get/${id}`,
method: "GET",
});
}
/**
* 获取商品关联的 SKU 列表
* @param {String} goodsId 商品ID
*/
export function getStoreGoodsSkuList(goodsId) {
return storeHttp.request({
url: `/goods/goods/sku/${goodsId}/list`,
method: "GET",
});
}
/**
* 上架商品
* @param {String|Array} goodsId
*/
export function upGoods(goodsId) {
const ids = Array.isArray(goodsId) ? goodsId.join(",") : goodsId;
return storeHttp.request({
url: `/goods/goods/up?goodsId=${ids}`,
method: "PUT",
});
}
/**
* 下架商品
* @param {String|Array} goodsId
*/
export function downGoods(goodsId) {
const ids = Array.isArray(goodsId) ? goodsId.join(",") : goodsId;
return storeHttp.request({
url: `/goods/goods/under?goodsId=${ids}`,
method: "PUT",
});
}
/**
* 获取商品统计数量(出售中、已下架等)
*/
export function getStoreGoodsNumber(params) {
return storeHttp.request({
url: "/goods/goods/goodsNumber",
method: "GET",
params,
});
}

View File

@@ -0,0 +1,104 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 商家订单列表
* @param {Object} params { orderStatus, orderType, keywords, pageNumber, pageSize }
*/
export function getStoreOrderList(params) {
return storeHttp.request({
url: "/order/order",
method: "GET",
params,
});
}
/**
* 商家订单详情
* @param {String} sn
*/
export function getStoreOrderDetail(sn) {
return storeHttp.request({
url: `/order/order/${sn}`,
method: "GET",
});
}
/**
* 自提 / 虚拟商品单码核销
* @param {String} sn
* @param {String} verificationCode
*/
export function storeOrderTake(sn, verificationCode) {
return storeHttp.request({
url: `/order/order/take/${sn}/${verificationCode}`,
method: "PUT",
});
}
/**
* 通用核销预检(按核销码查询)
* @param {String} code
*/
export function previewStoreVerification(code) {
return storeHttp.request({
url: "/order/order/verification/preview",
method: "GET",
params: { code },
});
}
/**
* 通用确认核销
* @param {String} code
*/
export function confirmStoreVerification(code) {
return storeHttp.request({
url: "/order/order/verification/confirm",
method: "POST",
data: { code },
});
}
/**
* 预约服务 — 根据核销码查询预约订单详情
* @param {String} code
*/
export function getAppointmentOrderByCode(code) {
return storeHttp.request({
url: `/appointment/verification/order/${code}`,
method: "GET",
});
}
/**
* 预约服务 — 执行核销
* @param {Object} params { orderSn, code, serviceStaffId }
*/
export function verifyAppointmentCode(params) {
return storeHttp.request({
url: "/appointment/verification/verify",
method: "POST",
data: params,
});
}
/**
* 预约服务 — 获取已启用的服务人员列表(供核销时指派/确认)
*/
export function getEnabledServiceStaff() {
return storeHttp.request({
url: "/appointment/service-staff/enabled",
method: "GET",
});
}
/**
* 预约服务 — 根据订单号获取预约单核销状态
* @param {String} orderSn
*/
export function getAppointmentVerificationByOrderSn(orderSn) {
return storeHttp.request({
url: `/appointment/verification/order-by-sn/${orderSn}`,
method: "GET",
});
}

View File

@@ -0,0 +1,94 @@
import { storeHttp } from "../utils/storeRequest.js";
/**
* 账号密码登录(支持店主与店员账号)
* @param {Object} params { username, password }
*/
export function userLogin(params) {
return storeHttp.request({
url: "/passport/login/userLogin",
method: "POST",
params,
header: {
"content-type": "application/x-www-form-urlencoded",
},
});
}
/**
* 短信验证码登录(支持店主与店员手机号)
* @param {Object} params { mobile, code }
*/
export function smsLogin(params) {
return storeHttp.request({
url: "/passport/login/smsLogin",
method: "POST",
params,
header: {
"content-type": "application/x-www-form-urlencoded",
},
});
}
/**
* 发送登录短信
* @param {String} mobile
* @param {String} verificationEnums (LOGIN)
*/
export function sendStoreSms(mobile, verificationEnums = "LOGIN") {
return storeHttp.request({
url: `/common/sms/${verificationEnums}/${mobile}`,
method: "GET",
});
}
/**
* 获取滑块验证码
* @param {String} verificationEnums (LOGIN)
*/
export function getStoreSlider(verificationEnums = "LOGIN") {
return storeHttp.request({
url: `/common/slider/${verificationEnums}`,
method: "GET",
});
}
/**
* 登出
*/
export function storeLogout() {
return storeHttp.request({
url: "/passport/login/logout",
method: "POST",
});
}
/**
* 获取店铺基本配置与信息
*/
export function getStoreSettings() {
return storeHttp.request({
url: "/settings/storeSettings",
method: "GET",
});
}
/**
* 获取当前登录人员(店主 / 店员)个人信息
*/
export function getStoreUserInfo() {
return storeHttp.request({
url: "/member/user/info",
method: "GET",
});
}
/**
* 获取当前登录所属店铺详情
*/
export function getStoreDetail() {
return storeHttp.request({
url: "/member/user",
method: "GET",
});
}

View File

@@ -0,0 +1,650 @@
<template>
<view class="merchant-evaluation-page">
<!-- 顶部 Tab 过滤 -->
<view class="sticky-header">
<view class="tab-scroll-wrap">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</view>
<!-- 评价列表主体 -->
<view class="eval-list-body">
<view
class="eval-card"
v-for="item in evalList"
:key="item.id"
>
<!-- 头部:买家信息与星级 -->
<view class="eval-header">
<view class="user-box">
<image
class="user-avatar"
:src="item.memberProfile || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<view class="user-meta">
<text class="user-name">{{ maskName(item.memberName) }}</text>
<text class="eval-time">{{ item.createTime || '--' }}</text>
</view>
</view>
<!-- 评分 -->
<view class="rating-stars">
<u-icon
v-for="star in 5"
:key="star"
name="star-fill"
size="14"
:color="star <= (item.descriptionScore || 5) ? '#f59e0b' : '#e5e7eb'"
></u-icon>
</view>
</view>
<!-- 评价文字内容 -->
<view class="eval-content">
<text class="content-text">{{ item.content || '用户未填写文字评价' }}</text>
</view>
<!-- 买家晒图 -->
<view class="eval-images" v-if="getImages(item.images).length > 0">
<image
class="eval-pic"
v-for="(img, idx) in getImages(item.images)"
:key="idx"
:src="img"
mode="aspectFill"
@click="previewImages(getImages(item.images), idx)"
></image>
</view>
<!-- 关联商品简要信息 -->
<view class="goods-snippet" v-if="item.goodsName">
<image
class="goods-snippet-img"
:src="item.goodsImage || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<text class="goods-snippet-title">{{ item.goodsName }}</text>
</view>
<!-- 商家已回复内容 -->
<view class="seller-reply-box" v-if="item.reply">
<view class="reply-title-row">
<text class="reply-tag">掌柜回复:</text>
<text class="reply-time" v-if="item.replyTime">{{ item.replyTime }}</text>
</view>
<text class="reply-text">{{ item.reply }}</text>
</view>
<!-- 回复动作条 -->
<view class="eval-footer">
<view
class="reply-trigger-btn"
@click="openReplyModal(item)"
>
<u-icon name="chat" size="14" :color="item.reply ? '#6b7280' : '#ffffff'"></u-icon>
<text :class="{ 'is-replied': item.reply }">
{{ item.reply ? '修改回复' : '立即回复' }}
</text>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && evalList.length === 0">
<u-icon name="chat" size="56" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关评价数据</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载评价数据...</text>
</view>
<view class="no-more" v-else-if="finished && evalList.length > 0">
<text>没有更多了</text>
</view>
</view>
<!-- 回复弹窗 -->
<view class="reply-modal-mask" v-if="showReplyModal" @click.self="closeReplyModal">
<view class="reply-modal-card">
<view class="modal-header">
<text class="modal-title">回复买家评价</text>
<view class="close-btn" @click="closeReplyModal">
<u-icon name="close" size="18" color="#9ca3af"></u-icon>
</view>
</view>
<view class="modal-body">
<textarea
class="reply-textarea"
v-model="replyText"
placeholder="请输入真诚的掌柜回复内容,让买家感受到热情与专业..."
placeholder-class="placeholder"
maxlength="300"
></textarea>
<view class="char-count">
<text>{{ replyText.length }}/300</text>
</view>
</view>
<view class="modal-footer">
<view class="modal-btn cancel" @click="closeReplyModal">取消</view>
<view
class="modal-btn confirm"
:class="{ loading: submittingReply }"
@click="submitReply"
>
{{ submittingReply ? '提交中...' : '提交回复' }}
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreEvaluationList, replyStoreEvaluation } from '../../api/evaluation.js'
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const evalList = ref([])
const showReplyModal = ref(false)
const currentEval = ref(null)
const replyText = ref('')
const submittingReply = ref(false)
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'GOOD', label: '好评' },
{ key: 'POOR', label: '中差评' },
{ key: 'UNREPLIED', label: '待回复' },
]
onLoad(() => {
fetchEvaluations(true)
})
onPullDownRefresh(async () => {
await fetchEvaluations(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchEvaluations(false)
}
})
const fetchEvaluations = async (reset = false) => {
if (reset) {
pageNumber.value = 1
evalList.value = []
finished.value = false
}
loading.value = true
const params = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
}
if (currentTab.value === 'GOOD') {
params.grade = 'GOOD'
} else if (currentTab.value === 'POOR') {
params.grade = 'POOR'
} else if (currentTab.value === 'UNREPLIED') {
params.replyStatus = false
}
try {
const res = await getStoreEvaluationList(params)
loading.value = false
if (res.data && res.data.success && res.data.result) {
const records = res.data.result.records || []
if (reset) {
evalList.value = records
} else {
evalList.value = [...evalList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
finished.value = true
}
} catch (e) {
loading.value = false
finished.value = true
}
}
const switchTab = (tabKey) => {
if (currentTab.value === tabKey) return
currentTab.value = tabKey
fetchEvaluations(true)
}
const maskName = (name) => {
if (!name) return '匿名买家'
if (name.length <= 2) return name[0] + '*'
return name[0] + '***' + name[name.length - 1]
}
const getImages = (imgs) => {
if (!imgs) return []
if (Array.isArray(imgs)) return imgs
if (typeof imgs === 'string') {
try {
const parsed = JSON.parse(imgs)
if (Array.isArray(parsed)) return parsed
} catch (e) {
return imgs.split(',').filter(Boolean)
}
}
return []
}
const previewImages = (urls, current) => {
uni.previewImage({
urls,
current,
})
}
// 打开回复弹窗
const openReplyModal = (item) => {
currentEval.value = item
replyText.value = item.reply || ''
showReplyModal.value = true
}
const closeReplyModal = () => {
showReplyModal.value = false
currentEval.value = null
replyText.value = ''
}
// 提交回复
const submitReply = async () => {
if (!replyText.value.trim()) {
uni.showToast({ title: '请输入回复内容', icon: 'none' })
return
}
if (submittingReply.value) return
submittingReply.value = true
uni.showLoading({ title: '提交中...' })
try {
const res = await replyStoreEvaluation(currentEval.value.id, replyText.value.trim())
uni.hideLoading()
submittingReply.value = false
if (res.data && res.data.success) {
uni.showToast({ title: '回复成功', icon: 'success' })
closeReplyModal()
fetchEvaluations(true)
} else {
uni.showToast({
title: res.data?.message || '回复失败',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
submittingReply.value = false
uni.showToast({ title: '网络异常,请重试', icon: 'none' })
}
}
</script>
<style lang="scss" scoped>
.merchant-evaluation-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 40rpx;
}
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
.tab-scroll-wrap {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
padding: 0 16rpx;
.tab-item {
flex: 1;
text-align: center;
padding: 24rpx 0;
position: relative;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
}
.indicator {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
.eval-list-body {
padding: 24rpx 28rpx;
.eval-card {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.eval-header {
display: flex;
justify-content: space-between;
align-items: center;
.user-box {
display: flex;
align-items: center;
.user-avatar {
width: 72rpx;
height: 72rpx;
border-radius: 36rpx;
background: #f3f4f6;
}
.user-meta {
margin-left: 16rpx;
.user-name {
font-size: 26rpx;
font-weight: 600;
color: #111827;
display: block;
}
.eval-time {
font-size: 20rpx;
color: #9ca3af;
margin-top: 4rpx;
display: block;
}
}
}
.rating-stars {
display: flex;
gap: 4rpx;
}
}
.eval-content {
margin-top: 20rpx;
.content-text {
font-size: 28rpx;
color: #1f2937;
line-height: 1.5;
word-break: break-all;
}
}
.eval-images {
display: flex;
flex-wrap: wrap;
gap: 16rpx;
margin-top: 16rpx;
.eval-pic {
width: 150rpx;
height: 150rpx;
border-radius: 12rpx;
background: #f3f4f6;
}
}
.goods-snippet {
display: flex;
align-items: center;
background: #f9fafb;
border-radius: 12rpx;
padding: 14rpx;
margin-top: 20rpx;
.goods-snippet-img {
width: 64rpx;
height: 64rpx;
border-radius: 8rpx;
background: #e5e7eb;
flex-shrink: 0;
}
.goods-snippet-title {
font-size: 22rpx;
color: #4b5563;
margin-left: 14rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
.seller-reply-box {
margin-top: 20rpx;
background: #f3f4f6;
border-left: 6rpx solid #111827;
border-radius: 8rpx;
padding: 16rpx 20rpx;
.reply-title-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 8rpx;
.reply-tag {
font-size: 24rpx;
font-weight: 700;
color: #111827;
}
.reply-time {
font-size: 20rpx;
color: #9ca3af;
}
}
.reply-text {
font-size: 26rpx;
color: #4b5563;
line-height: 1.4;
}
}
.eval-footer {
display: flex;
justify-content: flex-end;
margin-top: 24rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.reply-trigger-btn {
display: flex;
align-items: center;
gap: 8rpx;
padding: 10rpx 28rpx;
border-radius: 12rpx;
background: #111827;
color: #ffffff;
font-size: 24rpx;
font-weight: 600;
.is-replied {
color: #4b5563;
}
&:has(.is-replied) {
background: #f3f4f6;
border: 1rpx solid #e5e7eb;
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 0;
.empty-text {
font-size: 26rpx;
color: #9ca3af;
margin-top: 20rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 24rpx 0;
font-size: 22rpx;
color: #9ca3af;
}
}
/* 回复弹窗 */
.reply-modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
.reply-modal-card {
background: #ffffff;
width: 100%;
max-width: 640rpx;
border-radius: 28rpx;
padding: 36rpx;
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
.modal-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
}
.modal-body {
position: relative;
.reply-textarea {
width: 100%;
height: 240rpx;
background: #f9fafb;
border: 1rpx solid #e5e7eb;
border-radius: 16rpx;
padding: 20rpx;
font-size: 28rpx;
color: #111827;
box-sizing: border-box;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
.char-count {
position: absolute;
right: 16rpx;
bottom: 16rpx;
font-size: 20rpx;
color: #9ca3af;
}
}
.modal-footer {
display: flex;
gap: 20rpx;
margin-top: 28rpx;
.modal-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
&.cancel {
background: #f3f4f6;
color: #4b5563;
}
&.confirm {
background: #111827;
color: #ffffff;
&.loading {
opacity: 0.7;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,737 @@
<template>
<view class="merchant-goods-detail" v-if="goodsDetail">
<!-- 顶部主图轮播 -->
<view class="gallery-wrapper">
<swiper
class="gallery-swiper"
:indicator-dots="false"
:autoplay="false"
@change="onSwiperChange"
>
<swiper-item
v-for="(img, idx) in galleryImages"
:key="idx"
@click="previewGallery(idx)"
>
<image class="swiper-img" :src="img" mode="aspectFill"></image>
</swiper-item>
</swiper>
<view class="swiper-indicator" v-if="galleryImages.length > 1">
<text>{{ currentSwiperIndex + 1 }} / {{ galleryImages.length }}</text>
</view>
</view>
<!-- 核心信息卡片 -->
<view class="info-card core-card">
<view class="price-row">
<view class="main-price">
<text class="symbol">¥</text>
<text class="num">{{ goodsDetail.price || '0.00' }}</text>
</view>
<view class="sub-price" v-if="goodsDetail.cost">
<text>成本价 ¥{{ goodsDetail.cost }}</text>
</view>
<view class="status-tags">
<view
class="badge market"
:class="goodsDetail.marketEnable === 'UPPER' ? 'on-sale' : 'off-sale'"
>
{{ goodsDetail.marketEnable === 'UPPER' ? '出售中' : '已下架' }}
</view>
<view
class="badge auth"
:class="goodsDetail.authFlag === 'PASS' ? 'auth-pass' : 'auth-pending'"
>
{{ getAuthText(goodsDetail.authFlag) }}
</view>
</view>
</view>
<view class="title-row">
<text class="goods-title">{{ goodsDetail.goodsName }}</text>
</view>
<view class="meta-stats-grid">
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.quantity ?? 0 }}</text>
<text class="stat-label">总库存</text>
</view>
<view class="stat-sep"></view>
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.buyCount ?? 0 }}</text>
<text class="stat-label">累计销量</text>
</view>
<view class="stat-sep"></view>
<view class="stat-col">
<text class="stat-num">{{ goodsDetail.sn || '--' }}</text>
<text class="stat-label">商品货号</text>
</view>
</view>
</view>
<!-- 规格与多 SKU 列表 -->
<view class="info-card" v-if="skuList && skuList.length > 0">
<view class="card-head">
<view class="head-left">
<text class="card-title">规格与 SKU 明细</text>
<text class="sku-count-pill">共 {{ skuList.length }} 种规格</text>
</view>
</view>
<view class="sku-list">
<view
class="sku-item"
v-for="(sku, index) in skuList"
:key="sku.id || sku.sn || index"
>
<image
class="sku-thumb"
:src="getSkuThumb(sku)"
mode="aspectFill"
></image>
<view class="sku-info">
<text class="sku-spec">{{ formatSpecs(sku, index) }}</text>
<text class="sku-sn" v-if="sku.sn">SKU编码:{{ sku.sn }}</text>
<view class="sku-nums">
<text class="sku-price">售价:<text class="val">¥{{ sku.price || '0.00' }}</text></text>
<text class="sku-stock">库存:<text class="val">{{ sku.quantity ?? sku.stock ?? sku.enableQuantity ?? 0 }}</text></text>
</view>
</view>
</view>
</view>
</view>
<!-- 基本属性卡片(优化分类展示) -->
<view class="info-card">
<view class="card-head">
<text class="card-title">基本属性</text>
</view>
<view class="prop-row" v-if="goodsDetail.categoryName">
<text class="prop-label">所属分类</text>
<text class="prop-val cat-val">{{ formatCategoryName(goodsDetail.categoryName) }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.brandName">
<text class="prop-label">商品品牌</text>
<text class="prop-val">{{ goodsDetail.brandName }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.goodsUnit">
<text class="prop-label">计量单位</text>
<text class="prop-val">{{ goodsDetail.goodsUnit }}</text>
</view>
<view class="prop-row" v-if="goodsDetail.releaseTime">
<text class="prop-label">发布时间</text>
<text class="prop-val">{{ goodsDetail.releaseTime }}</text>
</view>
</view>
<!-- 图文详情 -->
<view class="info-card intro-card" v-if="goodsDetail.intro || goodsDetail.mobileIntro">
<view class="card-head">
<text class="card-title">商品图文详情</text>
</view>
<view class="intro-html">
<rich-text :nodes="formatRichText(goodsDetail.mobileIntro || goodsDetail.intro)"></rich-text>
</view>
</view>
<!-- 底部固定悬浮操作栏(带安全底间距,防止遮挡内容) -->
<view class="bottom-action-bar">
<view class="preview-btn" @click="previewInMall">
<u-icon name="eye" size="20" color="#4b5563"></u-icon>
<text>买家预览</text>
</view>
<view
class="market-action-btn off"
v-if="goodsDetail.marketEnable === 'UPPER'"
@click="handleToggleMarket('DOWN')"
>
<text>下架商品</text>
</view>
<view
class="market-action-btn on"
v-else
@click="handleToggleMarket('UPPER')"
>
<text>立即上架</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getStoreGoodsDetail, getStoreGoodsSkuList, upGoods, downGoods } from '../../api/goods.js'
import { parseGoodsImageUrl } from '@/utils/filters.js'
const getSkuThumb = (sku: any) => {
const img = sku.thumbnail || sku.original
if (img) {
const parsed = parseGoodsImageUrl(img)
if (parsed) return parsed
}
const rawSpec = sku.simpleSpecs || sku.specs
if (rawSpec && typeof rawSpec === 'string') {
const match = rawSpec.match(/https?:\/\/[^\s"'\\}]+\.(jpeg|jpg|png|webp|gif)/i)
if (match) return match[0]
}
return galleryImages.value[0] || '/static/tabbar/home.png'
}
const goodsId = ref('')
const goodsDetail = ref<any>(null)
const skuList = ref<any[]>([])
const currentSwiperIndex = ref(0)
onLoad((options: any) => {
if (options?.id) {
goodsId.value = options.id
fetchGoodsDetail()
}
})
const galleryImages = computed(() => {
if (!goodsDetail.value) return []
if (Array.isArray(goodsDetail.value.goodsGalleryList) && goodsDetail.value.goodsGalleryList.length > 0) {
return goodsDetail.value.goodsGalleryList
}
const defaultImg = goodsDetail.value.original || goodsDetail.value.thumbnail
return defaultImg ? [defaultImg] : ['/static/tabbar/home.png']
})
const fetchGoodsDetail = async () => {
uni.showLoading({ title: '加载中...' })
try {
const res: any = await getStoreGoodsDetail(goodsId.value)
uni.hideLoading()
if (res?.data && res.data.success && res.data.result) {
goodsDetail.value = res.data.result
skuList.value = res.data.result.skuList || []
if (skuList.value.length === 0) {
fetchSkuList()
}
} else {
uni.showToast({ title: '获取商品详情失败', icon: 'none' })
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
const fetchSkuList = async () => {
try {
const skuRes: any = await getStoreGoodsSkuList(goodsId.value)
if (skuRes?.data && skuRes.data.success && Array.isArray(skuRes.data.result)) {
skuList.value = skuRes.data.result
}
} catch (e) {}
}
const onSwiperChange = (e: any) => {
currentSwiperIndex.value = e.detail.current
}
const previewGallery = (current: number) => {
uni.previewImage({
urls: galleryImages.value,
current,
})
}
// 智能清洗并优雅格式化规格文本(过滤 images 等系统 JSON 冗余)
const formatSpecs = (sku: any, index: number) => {
// 1. 优先使用规范的 specList 数组
if (sku.specList && Array.isArray(sku.specList) && sku.specList.length > 0) {
const listStr = sku.specList
.map((s: any) => {
if (s.specName && s.specValue) return `${s.specName}: ${s.specValue}`
return s.specValue || s.specName
})
.filter(Boolean)
.join(' / ')
if (listStr) return listStr
}
// 2. 深度清洗 simpleSpecs 或 specs 中的复杂复合 JSON
const rawSpec = sku.simpleSpecs || sku.specs
if (rawSpec && typeof rawSpec === 'string') {
const trimmed = rawSpec.trim()
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
try {
const obj = JSON.parse(trimmed)
const ignoreKeys = ['images', 'code', 'message', 'result', 'success', 'showProgress', 'url', 'status', 'specImage', 'specType']
const pairs: string[] = []
for (const [k, v] of Object.entries(obj)) {
if (!ignoreKeys.includes(k) && typeof v === 'string' && !v.startsWith('http') && v.length < 50) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} catch (e) {}
// JSON 解析失败时正则提取真实的规格键值对
const matches = [...trimmed.matchAll(/"([^"]{1,20})"\s*:\s*"([^"]{1,30})"/g)]
const ignoreKeys = ['code', 'message', 'success', 'url', 'result', 'showProgress', 'status', 'name']
const pairs: string[] = []
for (const m of matches) {
const k = m[1]
const v = m[2]
if (!ignoreKeys.includes(k) && !v.startsWith('http')) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} else {
// 纯文本规格
return trimmed
}
}
// 3. 提取不同于 SPU 主标题的商品名称差异
if (sku.goodsName && sku.goodsName !== goodsDetail.value?.goodsName) {
return sku.goodsName
}
// 4. 最终兜底
return skuList.value.length > 1 ? `规格 ${index + 1}` : '统一规格'
}
// 格式化分类展示:将原始 JSON 数组 [ "数码办公", "手机通讯", "手机" ] 转为层级面包屑 "数码办公 > 手机通讯 > 手机"
const formatCategoryName = (cat: any) => {
if (!cat) return '--'
if (Array.isArray(cat)) {
return cat.filter(Boolean).join(' > ')
}
if (typeof cat === 'string') {
try {
const parsed = JSON.parse(cat)
if (Array.isArray(parsed)) {
return parsed.filter(Boolean).join(' > ')
}
} catch (e) {}
// 处理带引号或逗号的非标准字符串
return cat.replace(/[\[\]"']/g, '').split(',').map((s: string) => s.trim()).filter(Boolean).join(' > ')
}
return String(cat)
}
const getAuthText = (flag: string) => {
const map: Record<string, string> = {
PASS: '审核通过',
AUDIT: '待审核',
REFUSE: '审核驳回',
}
return map[flag] || flag || '已通过'
}
const formatRichText = (html: string) => {
if (!html) return ''
return html
.replace(/<img[^>]*>/gi, (match) => {
return match
.replace(/style="[^"]*"/gi, '')
.replace(/width="[^"]*"/gi, '')
.replace(/height="[^"]*"/gi, '')
})
.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;border-radius:12rpx;margin:16rpx 0;"')
}
// 上下架切换
const handleToggleMarket = (targetStatus: string) => {
const isUp = targetStatus === 'UPPER'
const actionText = isUp ? '上架' : '下架'
uni.showModal({
title: `${actionText}商品`,
content: `确定要${actionText}当前商品?`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: `正在${actionText}...` })
try {
const apiCall = isUp ? upGoods(goodsId.value) : downGoods(goodsId.value)
const resp: any = await apiCall
uni.hideLoading()
if (resp?.data && resp.data.success) {
uni.showToast({ title: `${actionText}成功`, icon: 'success' })
fetchGoodsDetail()
} else {
uni.showToast({
title: resp?.data?.message || `${actionText}失败`,
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络异常,请稍后重试', icon: 'none' })
}
}
},
})
}
// 前往买家端预览
const previewInMall = () => {
uni.navigateTo({
url: `/pages/product/goods?id=${goodsId.value}`,
})
}
</script>
<style lang="scss" scoped>
.merchant-goods-detail {
min-height: 100vh;
background-color: #f4f5f7;
/* 预留出底部固定操作栏的高以及全面屏安全区,彻底解决内容被底部遮挡 */
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
.gallery-wrapper {
position: relative;
width: 100%;
height: 680rpx;
background: #ffffff;
.gallery-swiper {
width: 100%;
height: 100%;
.swiper-img {
width: 100%;
height: 100%;
}
}
.swiper-indicator {
position: absolute;
right: 28rpx;
bottom: 44rpx;
background: rgba(0, 0, 0, 0.55);
color: #ffffff;
font-size: 22rpx;
font-weight: 500;
padding: 6rpx 20rpx;
border-radius: 20rpx;
backdrop-filter: blur(4px);
}
}
.info-card {
margin: 20rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-head {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f9fafb;
.head-left {
display: flex;
align-items: center;
gap: 16rpx;
}
.card-title {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
.sku-count-pill {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 14rpx;
border-radius: 12rpx;
}
}
&.core-card {
margin-top: -30rpx;
position: relative;
z-index: 10;
.price-row {
display: flex;
align-items: baseline;
justify-content: space-between;
.main-price {
color: #ef4444;
display: flex;
align-items: baseline;
.symbol {
font-size: 28rpx;
font-weight: 700;
}
.num {
font-size: 48rpx;
font-weight: 700;
margin-left: 4rpx;
}
}
.sub-price {
font-size: 24rpx;
color: #9ca3af;
margin-left: 16rpx;
flex: 1;
}
.status-tags {
display: flex;
gap: 12rpx;
.badge {
font-size: 22rpx;
padding: 6rpx 16rpx;
border-radius: 10rpx;
font-weight: 600;
&.on-sale {
background: #ecfdf5;
color: #059669;
}
&.off-sale {
background: #f3f4f6;
color: #9ca3af;
}
&.auth-pass {
background: #eff6ff;
color: #2563eb;
}
&.auth-pending {
background: #fffbeb;
color: #d97706;
}
}
}
}
.title-row {
margin-top: 20rpx;
.goods-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
line-height: 1.45;
}
}
.meta-stats-grid {
display: flex;
align-items: center;
background: #f9fafb;
border-radius: 16rpx;
padding: 22rpx 0;
margin-top: 26rpx;
.stat-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.stat-num {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.stat-label {
font-size: 22rpx;
color: #9ca3af;
margin-top: 4rpx;
}
}
.stat-sep {
width: 1rpx;
height: 38rpx;
background: #e5e7eb;
}
}
}
.sku-list {
.sku-item {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f3f4f6;
&:last-child {
border-bottom: none;
}
.sku-thumb {
width: 104rpx;
height: 104rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.sku-info {
flex: 1;
margin-left: 22rpx;
display: flex;
flex-direction: column;
.sku-spec {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.35;
}
.sku-sn {
font-size: 22rpx;
color: #9ca3af;
margin-top: 6rpx;
}
.sku-nums {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.sku-price {
font-size: 24rpx;
color: #6b7280;
.val {
font-size: 28rpx;
font-weight: 700;
color: #ef4444;
}
}
.sku-stock {
font-size: 24rpx;
color: #6b7280;
.val {
font-weight: 600;
color: #111827;
}
}
}
}
}
}
.prop-row {
display: flex;
align-items: flex-start;
justify-content: space-between;
padding: 18rpx 0;
border-bottom: 1rpx solid #f9fafb;
&:last-child {
border-bottom: none;
}
.prop-label {
font-size: 26rpx;
color: #6b7280;
width: 160rpx;
flex-shrink: 0;
}
.prop-val {
flex: 1;
text-align: right;
font-size: 26rpx;
color: #111827;
font-weight: 500;
line-height: 1.45;
&.cat-val {
color: #2563eb;
background: #eff6ff;
display: inline-block;
padding: 6rpx 16rpx;
border-radius: 8rpx;
font-size: 24rpx;
font-weight: 500;
}
}
}
&.intro-card {
.intro-html {
margin-top: 16rpx;
font-size: 28rpx;
color: #374151;
line-height: 1.6;
word-break: break-all;
}
}
}
.bottom-action-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: #ffffff;
display: flex;
align-items: center;
padding: 16rpx 28rpx calc(16rpx + env(safe-area-inset-bottom)) 28rpx;
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
z-index: 100;
gap: 20rpx;
.preview-btn {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 0 20rpx;
text {
font-size: 20rpx;
color: #4b5563;
margin-top: 4rpx;
}
}
.market-action-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
font-weight: 600;
&.off {
background: #fef2f2;
color: #dc2626;
border: 1rpx solid #fecaca;
}
&.on {
background: #111827;
color: #ffffff;
}
}
}
</style>

View File

@@ -0,0 +1,472 @@
<template>
<view class="merchant-goods-page">
<!-- 顶部吸顶搜索栏与 Tab -->
<view class="sticky-header">
<view class="search-bar">
<u-icon name="search" size="18" color="#9ca3af"></u-icon>
<input
class="search-input"
type="text"
v-model="keywords"
placeholder="搜索商品名称"
placeholder-class="placeholder"
@confirm="onSearch"
/>
<view class="clear-btn" v-if="keywords" @click="clearSearch">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view class="tab-scroll-wrap">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</view>
<!-- 商品列表主体 -->
<view class="goods-list-body">
<view
class="goods-card"
v-for="goods in goodsList"
:key="goods.id"
@click="goToDetail(goods.id)"
>
<view class="card-main">
<image
class="goods-img"
:src="goods.thumbnail || goods.original || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
<view class="goods-meta">
<view class="title-row">
<text class="goods-title">{{ goods.goodsName }}</text>
</view>
<view class="stock-sales-row">
<text class="meta-tag">库存: {{ goods.quantity ?? 0 }}</text>
<text class="meta-tag">销量: {{ goods.buyCount ?? 0 }}</text>
</view>
<view class="price-status-row">
<view class="price-box">
<text class="symbol">¥</text>
<text class="price-num">{{ goods.price || goods.sellingPrice || '0.00' }}</text>
</view>
<view class="status-badge" :class="goods.marketEnable === 'UPPER' ? 'on-sale' : 'off-sale'">
{{ goods.marketEnable === 'UPPER' ? '出售中' : '已下架' }}
</view>
</view>
</view>
</view>
<!-- 底部快捷操作条 -->
<view class="card-footer">
<text class="goods-sn" v-if="goods.sn">商品货号:{{ goods.sn }}</text>
<view class="actions-group">
<view
class="action-btn off"
v-if="goods.marketEnable === 'UPPER'"
@click.stop="toggleMarket(goods, 'DOWN')"
>
<text>下架商品</text>
</view>
<view
class="action-btn on"
v-else
@click.stop="toggleMarket(goods, 'UPPER')"
>
<text>立即上架</text>
</view>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && goodsList.length === 0">
<u-icon name="bag" size="56" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关商品</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载商品列表...</text>
</view>
<view class="no-more" v-else-if="finished && goodsList.length > 0">
<text>没有更多了</text>
</view>
</view>
</view>
</template>
<script setup>
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreGoodsList, upGoods, downGoods } from '../../api/goods.js'
const keywords = ref('')
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const goodsList = ref([])
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'UPPER', label: '出售中' },
{ key: 'DOWN', label: '已下架' },
]
onLoad((options) => {
if (options?.tab) {
currentTab.value = options.tab
}
fetchGoods(true)
})
onPullDownRefresh(async () => {
await fetchGoods(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchGoods(false)
}
})
const fetchGoods = async (reset = false) => {
if (reset) {
pageNumber.value = 1
goodsList.value = []
finished.value = false
}
loading.value = true
const params = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
}
if (keywords.value.trim()) {
params.goodsName = keywords.value.trim()
}
if (currentTab.value !== 'ALL') {
params.marketEnable = currentTab.value
}
try {
const res = await getStoreGoodsList(params)
loading.value = false
if (res.data && res.data.success && res.data.result) {
const records = res.data.result.records || []
if (reset) {
goodsList.value = records
} else {
goodsList.value = [...goodsList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
finished.value = true
}
} catch (e) {
loading.value = false
finished.value = true
}
}
const switchTab = (tabKey) => {
if (currentTab.value === tabKey) return
currentTab.value = tabKey
fetchGoods(true)
}
const onSearch = () => {
fetchGoods(true)
}
const clearSearch = () => {
keywords.value = ''
fetchGoods(true)
}
const goToDetail = (id) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/goods/detail?id=${id}`,
})
}
// 快捷上下架切换
const toggleMarket = (goods, targetStatus) => {
const isUp = targetStatus === 'UPPER'
const actionText = isUp ? '上架' : '下架'
uni.showModal({
title: `${actionText}提示`,
content: `确定要${actionText}商品「${goods.goodsName}」吗?`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: `正在${actionText}...` })
try {
const apiCall = isUp ? upGoods(goods.id) : downGoods(goods.id)
const resp = await apiCall
uni.hideLoading()
if (resp.data && resp.data.success) {
uni.showToast({ title: `${actionText}成功`, icon: 'success' })
fetchGoods(true)
} else {
uni.showToast({
title: resp.data?.message || `${actionText}失败`,
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
},
})
}
</script>
<style lang="scss" scoped>
.merchant-goods-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 40rpx;
}
.sticky-header {
position: sticky;
top: 0;
z-index: 100;
background: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.04);
.search-bar {
display: flex;
align-items: center;
background: #f3f4f6;
margin: 20rpx 28rpx;
padding: 16rpx 24rpx;
border-radius: 16rpx;
.search-input {
flex: 1;
margin-left: 16rpx;
font-size: 26rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
}
.tab-scroll-wrap {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
padding: 0 16rpx;
.tab-item {
flex: 1;
text-align: center;
padding: 20rpx 0;
position: relative;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
}
.indicator {
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 40rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
.goods-list-body {
padding: 24rpx 28rpx;
.goods-card {
background: #ffffff;
border-radius: 20rpx;
padding: 24rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-main {
display: flex;
.goods-img {
width: 170rpx;
height: 170rpx;
border-radius: 16rpx;
background: #f3f4f6;
}
.goods-meta {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.title-row {
.goods-title {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
}
.stock-sales-row {
display: flex;
gap: 16rpx;
margin-top: 8rpx;
.meta-tag {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 8rpx;
}
}
.price-status-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 12rpx;
.price-box {
display: flex;
align-items: baseline;
color: #ff3c2a;
.symbol {
font-size: 22rpx;
font-weight: 700;
}
.price-num {
font-size: 34rpx;
font-weight: 700;
margin-left: 4rpx;
}
}
.status-badge {
font-size: 22rpx;
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-weight: 500;
&.on-sale {
background: #ecfdf5;
color: #059669;
}
&.off-sale {
background: #f3f4f6;
color: #9ca3af;
}
}
}
}
}
.card-footer {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.goods-sn {
font-size: 22rpx;
color: #9ca3af;
}
.actions-group {
display: flex;
gap: 16rpx;
.action-btn {
padding: 10rpx 28rpx;
border-radius: 12rpx;
font-size: 24rpx;
font-weight: 600;
&.off {
background: #fef2f2;
color: #dc2626;
border: 1rpx solid #fecaca;
}
&.on {
background: #111827;
color: #ffffff;
}
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
padding: 120rpx 0;
.empty-text {
font-size: 26rpx;
color: #9ca3af;
margin-top: 20rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 24rpx 0;
font-size: 22rpx;
color: #9ca3af;
}
}
</style>

View File

@@ -0,0 +1,812 @@
<template>
<view class="workbench-page">
<!-- 顶部商家信息栏 -->
<view class="store-hero">
<view class="store-info-row">
<view class="store-avatar">
<image
class="avatar-img"
:src="storeInfo.settings?.storeLogo || '/static/tabbar/home.png'"
mode="aspectFill"
></image>
</view>
<view class="store-meta">
<view class="name-row">
<text class="store-name">{{ storeInfo.settings?.storeName || storeInfo.store?.storeName || '商家移动工作台' }}</text>
<view class="badge" :class="isClerk ? 'clerk-badge' : 'owner-badge'">
{{ isClerk ? '店员' : '店主' }}
</view>
</view>
<text class="clerk-name">当前操作员:{{ operatorName }}</text>
</view>
<view class="logout-btn" @click="handleLogout">
<text>退出</text>
</view>
</view>
</view>
<!-- 核心操作区(快速核销) -->
<view class="core-actions-card">
<view class="card-header">
<text class="card-title">快速核销</text>
<text class="card-subtitle">支持预约单、自提单与虚拟卡密</text>
</view>
<!-- 扫码主按钮 -->
<view class="scan-hero-btn" @click="handleScanCode">
<view class="scan-icon-circle">
<u-icon name="scan" size="38" color="#ffffff"></u-icon>
</view>
<view class="scan-text-box">
<text class="main-text">扫码快速核销</text>
<text class="sub-text">扫描顾客出示的核销码/订单码</text>
</view>
<u-icon name="arrow-right" size="18" color="rgba(255,255,255,0.6)"></u-icon>
</view>
<!-- 手动输码 -->
<view class="manual-input-box">
<view class="input-wrap">
<u-icon name="edit-pen" size="20" color="#9ca3af"></u-icon>
<input
class="code-input"
type="number"
maxlength="12"
v-model="manualCode"
placeholder="输入8位数字核销码"
placeholder-class="placeholder"
@confirm="handleManualVerify"
/>
<view class="clear-icon" v-if="manualCode" @click="clearManualCode">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view
class="verify-btn"
:class="{ active: manualCode.trim().length >= 6 }"
@click="handleManualVerify"
>
<text>核销</text>
</view>
</view>
</view>
<!-- 核心业务四大板块 -->
<view class="business-grid-card">
<view class="grid-card-header">
<text class="grid-card-title">经营管理</text>
</view>
<view class="business-grid">
<!-- 订单管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/order/list?tab=ALL')">
<view class="biz-icon-box bg-blue">
<u-icon name="order" size="26" color="#2563eb"></u-icon>
</view>
<text class="biz-title">订单管理</text>
</view>
<!-- 商品管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/goods/list')">
<view class="biz-icon-box bg-emerald">
<u-icon name="bag" size="26" color="#059669"></u-icon>
</view>
<text class="biz-title">商品管理</text>
</view>
<!-- 评价管理 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/evaluation/list')">
<view class="biz-icon-box bg-amber">
<u-icon name="chat" size="26" color="#d97706"></u-icon>
</view>
<text class="biz-title">评价管理</text>
</view>
<!-- 待核销专区 -->
<view class="biz-item" @click="navigateTo('/pages-sub/merchant/pages/order/list?tab=TAKE')">
<view class="biz-icon-box bg-orange">
<u-icon name="checkmark-circle" size="26" color="#ea580c"></u-icon>
</view>
<text class="biz-title">待核销单</text>
</view>
</view>
</view>
<!-- 核销确认弹窗 -->
<view class="modal-mask" v-if="showModal" @click.self="closeModal">
<view class="modal-card">
<view class="modal-header">
<text class="modal-title">核销信息确认</text>
<view class="close-btn" @click="closeModal">
<u-icon name="close" size="18" color="#9ca3af"></u-icon>
</view>
</view>
<!-- 订单概览 -->
<view class="order-summary" v-if="verifyingOrder">
<view class="summary-row">
<text class="label">核销码:</text>
<text class="value highlight-code">{{ currentCode }}</text>
</view>
<view class="summary-row">
<text class="label">订单编号:</text>
<text class="value">{{ verifyingOrder.sn || verifyingOrder.orderSn || '--' }}</text>
</view>
<view class="summary-row" v-if="verifyingOrder.consigneeMobile || verifyingOrder.memberPhone">
<text class="label">顾客电话:</text>
<text class="value">{{ maskPhone(verifyingOrder.consigneeMobile || verifyingOrder.memberPhone) }}</text>
</view>
<view class="summary-row" v-if="verifyingOrder.goodsName || verifyingOrder.orderItems?.[0]?.goodsName">
<text class="label">商品名称:</text>
<text class="value goods-text">
{{ verifyingOrder.goodsName || verifyingOrder.orderItems?.[0]?.goodsName }}
</text>
</view>
<view class="summary-row" v-if="verifyingOrder.num">
<text class="label">购买数量:</text>
<text class="value">{{ verifyingOrder.num }} 件</text>
</view>
<!-- 预约服务专属选项:选择服务人员 -->
<view class="staff-picker-box" v-if="isAppointmentOrder">
<text class="staff-label">指派/核销服务人员:</text>
<picker
class="picker-ctrl"
mode="selector"
:range="staffList"
range-key="name"
:value="selectedStaffIndex"
@change="onStaffChange"
>
<view class="picker-display">
<text>{{ currentStaffName }}</text>
<u-icon name="arrow-down" size="14" color="#6b7280"></u-icon>
</view>
</picker>
</view>
</view>
<!-- 弹窗操作 -->
<view class="modal-footer">
<view class="modal-btn cancel" @click="closeModal">取消</view>
<view
class="modal-btn confirm"
:class="{ loading: confirming }"
@click="submitConfirmVerification"
>
{{ confirming ? '核销中...' : '确认核销' }}
</view>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { ref, computed, onMounted } from 'vue'
import storage from '@/utils/storage.js'
import {
previewStoreVerification,
storeOrderTake,
confirmStoreVerification,
getAppointmentOrderByCode,
verifyAppointmentCode,
getEnabledServiceStaff,
} from '../../api/order.js'
import { storeLogout } from '../../api/passport.js'
const storeInfo = ref({})
const operatorName = computed(() => {
const u = storeInfo.value?.user
return u?.nickName || u?.username || '当前操作员'
})
const isClerk = computed(() => {
const u = storeInfo.value?.user
if (u && (u.isSuper === false || u.shopkeeper === false)) return true
return false
})
const manualCode = ref('')
const showModal = ref(false)
const confirming = ref(false)
const currentCode = ref('')
const verifyingOrder = ref(null)
const isAppointmentOrder = ref(false)
const staffList = ref([])
const selectedStaffIndex = ref(0)
const currentStaffName = computed(() => {
if (staffList.value.length > 0 && staffList.value[selectedStaffIndex.value]) {
return staffList.value[selectedStaffIndex.value].name
}
return '未指派 / 默认'
})
onMounted(() => {
const token = storage.getStoreAccessToken()
if (!token) {
uni.redirectTo({ url: '/pages-sub/merchant/pages/login/index' })
return
}
storeInfo.value = storage.getStoreInfo() || {}
loadStaffList()
})
const loadStaffList = async () => {
try {
const res = await getEnabledServiceStaff()
if (res.data && res.data.success && Array.isArray(res.data.result)) {
staffList.value = res.data.result
}
} catch (e) {
// 忽略加载异常
}
}
const maskPhone = (phone) => {
if (!phone || phone.length < 7) return phone || ''
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
// 扫码快速核销
const handleScanCode = () => {
uni.scanCode({
onlyFromCamera: true,
scanType: ['qrCode', 'barCode'],
success: (res) => {
let code = res.result || ''
if (code.includes('code=')) {
const match = code.match(/code=([a-zA-Z0-9]+)/)
if (match && match[1]) {
code = match[1]
}
}
if (code) {
queryAndShowVerify(code.trim())
} else {
uni.showToast({ title: '未能识别核销码', icon: 'none' })
}
},
fail: () => {},
})
}
// 手动输码核销
const clearManualCode = () => {
manualCode.value = ''
}
const handleManualVerify = () => {
const code = manualCode.value.trim()
if (!code || code.length < 6) {
uni.showToast({ title: '请输入有效的核销码', icon: 'none' })
return
}
queryAndShowVerify(code)
}
// 预检核销码并展示弹窗
const queryAndShowVerify = async (code) => {
currentCode.value = code
uni.showLoading({ title: '正在查询订单...' })
try {
let isAppoint = false
let orderData = null
try {
const appointRes = await getAppointmentOrderByCode(code)
if (appointRes.data && appointRes.data.success && appointRes.data.result) {
isAppoint = true
orderData = appointRes.data.result
}
} catch (e) {}
if (!orderData) {
const previewRes = await previewStoreVerification(code)
if (previewRes.data && previewRes.data.success && previewRes.data.result) {
orderData = previewRes.data.result
}
}
uni.hideLoading()
if (orderData) {
verifyingOrder.value = orderData
isAppointmentOrder.value = isAppoint
showModal.value = true
} else {
verifyingOrder.value = { sn: '以提交核销为准' }
isAppointmentOrder.value = false
showModal.value = true
}
} catch (err) {
uni.hideLoading()
verifyingOrder.value = { sn: '以提交核销为准' }
isAppointmentOrder.value = false
showModal.value = true
}
}
const onStaffChange = (e) => {
selectedStaffIndex.value = e.detail.value
}
const closeModal = () => {
showModal.value = false
verifyingOrder.value = null
manualCode.value = ''
}
// 确认核销提交
const submitConfirmVerification = async () => {
if (confirming.value) return
confirming.value = true
uni.showLoading({ title: '核销中...' })
try {
let success = false
let message = ''
if (isAppointmentOrder.value) {
const staff = staffList.value[selectedStaffIndex.value]
const params = {
orderSn: verifyingOrder.value?.orderSn || verifyingOrder.value?.sn,
code: currentCode.value,
serviceStaffId: staff ? staff.id : undefined,
}
const res = await verifyAppointmentCode(params)
success = res.data && res.data.success
message = res.data?.message
} else {
const sn = verifyingOrder.value?.orderSn || verifyingOrder.value?.sn
if (sn && sn !== '以提交核销为准') {
const res = await storeOrderTake(sn, currentCode.value)
success = res.data && res.data.success
message = res.data?.message
} else {
const res = await confirmStoreVerification(currentCode.value)
success = res.data && res.data.success
message = res.data?.message
}
}
uni.hideLoading()
confirming.value = false
if (success) {
try {
uni.vibrateShort()
} catch (e) {}
uni.showToast({ title: '核销成功!', icon: 'success' })
closeModal()
} else {
uni.showToast({
title: message || '核销失败,请核对核销码',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
confirming.value = false
uni.showToast({ title: '请求失败,请稍后重试', icon: 'none' })
}
}
// 退出登录
const handleLogout = () => {
uni.showModal({
title: '退出商家工作台',
content: '退出后将清除本店登录凭证,确认退出?',
success: async (res) => {
if (res.confirm) {
try {
await storeLogout()
} catch (e) {}
storage.clearStoreAuth()
uni.redirectTo({
url: '/pages-sub/merchant/pages/login/index',
})
}
},
})
}
const navigateTo = (url) => {
uni.navigateTo({ url })
}
</script>
<style lang="scss" scoped>
.workbench-page {
min-height: 100vh;
background-color: #f3f4f6;
padding-bottom: 60rpx;
}
.store-hero {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
padding: 60rpx 36rpx 100rpx 36rpx;
color: #ffffff;
.store-info-row {
display: flex;
align-items: center;
.store-avatar {
width: 96rpx;
height: 96rpx;
border-radius: 20rpx;
overflow: hidden;
background: #ffffff;
border: 2rpx solid rgba(255, 255, 255, 0.2);
.avatar-img {
width: 100%;
height: 100%;
}
}
.store-meta {
flex: 1;
margin-left: 24rpx;
.name-row {
display: flex;
align-items: center;
gap: 12rpx;
.store-name {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
}
.badge {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 8rpx;
font-weight: 500;
&.owner-badge {
background: rgba(255, 255, 255, 0.2);
color: #ffffff;
}
&.clerk-badge {
background: #ecfdf5;
color: #059669;
}
}
}
.clerk-name {
display: block;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.65);
margin-top: 8rpx;
}
}
.logout-btn {
padding: 10rpx 24rpx;
background: rgba(255, 255, 255, 0.12);
border-radius: 12rpx;
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
}
}
.core-actions-card {
margin: -60rpx 32rpx 28rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 36rpx;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
.card-header {
margin-bottom: 28rpx;
.card-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
display: block;
}
.card-subtitle {
font-size: 22rpx;
color: #9ca3af;
margin-top: 6rpx;
display: block;
}
}
.scan-hero-btn {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
border-radius: 22rpx;
padding: 32rpx 28rpx;
display: flex;
align-items: center;
box-shadow: 0 10rpx 24rpx rgba(16, 185, 129, 0.3);
.scan-icon-circle {
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
}
.scan-text-box {
flex: 1;
margin-left: 24rpx;
.main-text {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
display: block;
}
.sub-text {
font-size: 22rpx;
color: rgba(255, 255, 255, 0.8);
margin-top: 6rpx;
display: block;
}
}
}
.manual-input-box {
display: flex;
align-items: center;
margin-top: 28rpx;
gap: 16rpx;
.input-wrap {
flex: 1;
display: flex;
align-items: center;
background: #f9fafb;
border: 1rpx solid #e5e7eb;
border-radius: 16rpx;
padding: 18rpx 24rpx;
.code-input {
flex: 1;
margin-left: 16rpx;
font-size: 28rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
}
.verify-btn {
padding: 20rpx 36rpx;
background: #e5e7eb;
color: #9ca3af;
border-radius: 16rpx;
font-size: 28rpx;
font-weight: 600;
&.active {
background: #111827;
color: #ffffff;
}
}
}
}
.business-grid-card {
margin: 0 32rpx 24rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 32rpx 24rpx;
box-shadow: 0 6rpx 20rpx rgba(0, 0, 0, 0.04);
.grid-card-header {
margin-bottom: 24rpx;
padding-left: 8rpx;
.grid-card-title {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
}
.business-grid {
display: flex;
flex-wrap: wrap;
.biz-item {
width: 50%;
box-sizing: border-box;
padding: 20rpx;
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.biz-icon-box {
width: 96rpx;
height: 96rpx;
border-radius: 24rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 16rpx;
&.bg-blue {
background: #eff6ff;
}
&.bg-emerald {
background: #ecfdf5;
}
&.bg-amber {
background: #fffbeb;
}
&.bg-orange {
background: #fff7ed;
}
}
.biz-title {
font-size: 28rpx;
font-weight: 700;
color: #1f2937;
}
.biz-sub {
font-size: 22rpx;
color: #9ca3af;
margin-top: 4rpx;
}
}
}
}
/* 弹窗遮罩 */
.modal-mask {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.6);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
.modal-card {
background: #ffffff;
width: 100%;
max-width: 620rpx;
border-radius: 28rpx;
padding: 36rpx;
.modal-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 28rpx;
.modal-title {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
}
.order-summary {
background: #f9fafb;
border-radius: 16rpx;
padding: 24rpx;
margin-bottom: 32rpx;
.summary-row {
display: flex;
font-size: 26rpx;
margin-bottom: 14rpx;
&:last-child {
margin-bottom: 0;
}
.label {
color: #6b7280;
width: 150rpx;
}
.value {
color: #111827;
flex: 1;
&.highlight-code {
font-size: 32rpx;
font-weight: 700;
color: #10b981;
}
&.goods-text {
word-break: break-all;
}
}
}
.staff-picker-box {
margin-top: 20rpx;
padding-top: 20rpx;
border-top: 1rpx dashed #e5e7eb;
.staff-label {
font-size: 24rpx;
color: #6b7280;
display: block;
margin-bottom: 12rpx;
}
.picker-display {
display: flex;
align-items: center;
justify-content: space-between;
background: #ffffff;
border: 1rpx solid #d1d5db;
border-radius: 12rpx;
padding: 16rpx 20rpx;
font-size: 26rpx;
color: #111827;
}
}
}
.modal-footer {
display: flex;
gap: 20rpx;
.modal-btn {
flex: 1;
height: 84rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 30rpx;
font-weight: 600;
&.cancel {
background: #f3f4f6;
color: #4b5563;
}
&.confirm {
background: #111827;
color: #ffffff;
&.loading {
opacity: 0.7;
}
}
}
}
}
}
</style>

View File

@@ -0,0 +1,550 @@
<template>
<view class="merchant-login-page">
<!-- 顶部状态栏沉浸背景 -->
<view class="header-bg">
<view class="brand-box">
<view class="badge-icon">
<u-icon name="bag" size="32" color="#ffffff"></u-icon>
</view>
<text class="brand-title">商家管理工作台</text>
<text class="brand-desc">随时随地 · 快捷扫码核销与订单管理</text>
</view>
</view>
<!-- 登录卡片 -->
<view class="login-card">
<!-- 模式切换 Tab -->
<view class="tab-header">
<view
class="tab-item"
:class="{ active: loginType === 'account' }"
@click="switchTab('account')"
>
<text>账号密码登录</text>
<view class="active-indicator" v-if="loginType === 'account'"></view>
</view>
<view
class="tab-item"
:class="{ active: loginType === 'sms' }"
@click="switchTab('sms')"
>
<text>短信验证码登录</text>
<view class="active-indicator" v-if="loginType === 'sms'"></view>
</view>
</view>
<!-- 账号密码表单 -->
<view class="form-container" v-if="loginType === 'account'">
<view class="input-item">
<u-input
v-model="accountForm.username"
placeholder="请输入商家账号/手机号"
border="surround"
prefixIcon="account"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
<view class="input-item">
<u-input
v-model="accountForm.password"
placeholder="请输入登录密码"
type="password"
border="surround"
prefixIcon="lock"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
</view>
<!-- 短信验证码表单 -->
<view class="form-container" v-else>
<view class="input-item">
<u-input
v-model="smsForm.mobile"
placeholder="请输入店主手机号"
type="number"
maxlength="11"
border="surround"
prefixIcon="phone"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
/>
</view>
<view class="input-item">
<u-input
v-model="smsForm.code"
placeholder="请输入 6 位短信验证码"
type="number"
maxlength="6"
border="surround"
prefixIcon="email"
:prefixIconStyle="{ color: '#8c8c8c', fontSize: '36rpx', marginRight: '16rpx' }"
:customStyle="customInputStyle"
clearable
>
<template #suffix>
<view
class="send-btn"
:class="{ disabled: smsCount > 0 || !smsForm.mobile }"
@click="handleSendSms"
>
<text>{{ smsCount > 0 ? `${smsCount}s后重试` : '获取验证码' }}</text>
</view>
</template>
</u-input>
</view>
</view>
<!-- 登录提交按钮 -->
<view class="action-btn" :class="{ loading: submitting }" @click="handleLogin">
<text class="btn-text">{{ submitting ? '正在登录...' : '立即进入工作台' }}</text>
</view>
<view class="notice-tip">
<u-icon name="info-circle" size="14" color="#8c8c8c"></u-icon>
<text class="notice-text">仅限已入驻商城的店主/店员账号登录</text>
</view>
</view>
<!-- 安全滑块拼图验证码弹窗 -->
<myVerification
v-if="codeFlag"
ref="verificationRef"
apiType="store"
business="LOGIN"
@send="handleVerificationSuccess"
/>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, onBeforeUnmount, nextTick } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import storage from '@/utils/storage.js'
import myVerification from '@/components/verification/verification.vue'
import {
userLogin,
smsLogin,
sendStoreSms,
getStoreSettings,
getStoreUserInfo,
getStoreDetail,
} from '../../api/passport.js'
const loginType = ref<'account' | 'sms'>('account')
const submitting = ref(false)
const smsCount = ref(0)
let timer: any = null
// 滑块验证码相关控制
const codeFlag = ref(false)
const verificationRef = ref<any>(null)
const verifyAction = ref<'login' | 'sms'>('login')
const customInputStyle = {
backgroundColor: '#f9fafb',
borderRadius: '16rpx',
height: '84rpx',
paddingLeft: '16rpx',
fontSize: '28rpx',
}
const accountForm = reactive({
username: '',
password: '',
})
const smsForm = reactive({
mobile: '',
code: '',
})
onLoad(() => {
// 如果已存在商家 token,直接进入工作台
if (storage.getStoreAccessToken()) {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}
})
onBeforeUnmount(() => {
if (timer) {
clearInterval(timer)
timer = null
}
})
function switchTab(type: 'account' | 'sms') {
loginType.value = type
}
// 弹出滑块拼图验证码
function openVerification(action: 'login' | 'sms') {
verifyAction.value = action
codeFlag.value = true
nextTick(() => {
verificationRef.value?.show()
verificationRef.value?.getCode()
})
}
// 点击获取短信验证码
const handleSendSms = () => {
if (smsCount.value > 0) return
if (!/^1[3-9]\d{9}$/.test(smsForm.mobile)) {
uni.showToast({ title: '请输入正确的11位手机号', icon: 'none' })
return
}
// 发送短信验证码前先通过滑块拼图验证
openVerification('sms')
}
// 点击“立即进入工作台”按钮
const handleLogin = () => {
if (submitting.value) return
if (loginType.value === 'account') {
if (!accountForm.username.trim()) {
uni.showToast({ title: '请输入商家账号', icon: 'none' })
return
}
if (!accountForm.password) {
uni.showToast({ title: '请输入登录密码', icon: 'none' })
return
}
// 账号密码登录:必须先通过安全滑块拼图验证
openVerification('login')
} else {
// 短信验证码登录
if (!/^1[3-9]\d{9}$/.test(smsForm.mobile)) {
uni.showToast({ title: '请输入有效的手机号', icon: 'none' })
return
}
if (!smsForm.code.trim()) {
uni.showToast({ title: '请输入验证码', icon: 'none' })
return
}
// 短信验证码登录直接提交
doSmsLogin()
}
}
// 滑块验证码成功回调
const handleVerificationSuccess = () => {
if (verifyAction.value === 'login') {
doAccountLogin()
} else if (verifyAction.value === 'sms') {
doSendSms()
}
}
// 执行账号密码登录
const doAccountLogin = async () => {
submitting.value = true
uni.showLoading({ title: '正在登录...' })
try {
const res: any = await userLogin({
username: accountForm.username.trim(),
password: accountForm.password,
})
uni.hideLoading()
submitting.value = false
if (res?.data && res.data.success && res.data.result) {
codeFlag.value = false
const { accessToken, refreshToken } = res.data.result
storage.setStoreAccessToken(accessToken)
if (refreshToken) {
storage.setStoreRefreshToken(refreshToken)
}
// 获取店铺与店员信息
try {
const [settingsRes, userRes, storeRes] = (await Promise.all([
getStoreSettings().catch(() => null),
getStoreUserInfo().catch(() => null),
getStoreDetail().catch(() => null),
])) || []
const storeInfo = {
settings: settingsRes?.data?.result || {},
user: userRes?.data?.result || {},
store: storeRes?.data?.result || {},
}
storage.setStoreInfo(storeInfo)
} catch (e) {
console.warn('获取店铺额外信息失败', e)
}
uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}, 500)
} else {
uni.showToast({
title: res?.data?.message || '登录失败,请检查账号密码',
icon: 'none',
})
verificationRef.value?.getCode()
}
} catch (err: any) {
uni.hideLoading()
submitting.value = false
verificationRef.value?.getCode()
uni.showToast({
title: err?.data?.message || '网络连接异常或账号密码错误',
icon: 'none',
})
}
}
// 执行发送短信验证码
const doSendSms = async () => {
try {
uni.showLoading({ title: '发送中...' })
const res = await sendStoreSms(smsForm.mobile, 'LOGIN')
uni.hideLoading()
if (res?.data && res.data.success) {
codeFlag.value = false
uni.showToast({ title: '验证码已发送', icon: 'success' })
smsCount.value = 60
timer = setInterval(() => {
smsCount.value--
if (smsCount.value <= 0) {
clearInterval(timer)
timer = null
}
}, 1000)
} else {
verificationRef.value?.getCode()
uni.showToast({
title: res?.data?.message || '发送失败,请稍后重试',
icon: 'none',
})
}
} catch (e: any) {
uni.hideLoading()
verificationRef.value?.getCode()
uni.showToast({ title: e?.data?.message || '网络异常,发送失败', icon: 'none' })
}
}
// 执行短信登录
const doSmsLogin = async () => {
submitting.value = true
uni.showLoading({ title: '正在登录...' })
try {
const res: any = await smsLogin({
mobile: smsForm.mobile.trim(),
code: smsForm.code.trim(),
})
uni.hideLoading()
submitting.value = false
if (res?.data && res.data.success && res.data.result) {
const { accessToken, refreshToken } = res.data.result
storage.setStoreAccessToken(accessToken)
if (refreshToken) {
storage.setStoreRefreshToken(refreshToken)
}
try {
const [settingsRes, userRes, storeRes] = (await Promise.all([
getStoreSettings().catch(() => null),
getStoreUserInfo().catch(() => null),
getStoreDetail().catch(() => null),
])) || []
const storeInfo = {
settings: settingsRes?.data?.result || {},
user: userRes?.data?.result || {},
store: storeRes?.data?.result || {},
}
storage.setStoreInfo(storeInfo)
} catch (e) {
console.warn('获取店铺额外信息失败', e)
}
uni.showToast({ title: '登录成功', icon: 'success' })
setTimeout(() => {
uni.redirectTo({
url: '/pages-sub/merchant/pages/index/index',
})
}, 500)
} else {
uni.showToast({
title: res?.data?.message || '登录失败,请检查验证码',
icon: 'none',
})
}
} catch (err: any) {
uni.hideLoading()
submitting.value = false
uni.showToast({ title: err?.data?.message || '网络连接异常', icon: 'none' })
}
}
</script>
<style lang="scss" scoped>
.merchant-login-page {
min-height: 100vh;
background-color: #f7f8fa;
display: flex;
flex-direction: column;
}
.header-bg {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
padding: 100rpx 40rpx 140rpx 40rpx;
color: #ffffff;
display: flex;
justify-content: center;
align-items: center;
.brand-box {
display: flex;
flex-direction: column;
align-items: center;
text-align: center;
.badge-icon {
width: 100rpx;
height: 100rpx;
border-radius: 24rpx;
background: rgba(255, 255, 255, 0.12);
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 24rpx;
}
.brand-title {
font-size: 38rpx;
font-weight: 700;
letter-spacing: 2rpx;
margin-bottom: 12rpx;
}
.brand-desc {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.65);
}
}
}
.login-card {
margin: -80rpx 32rpx 40rpx 32rpx;
background: #ffffff;
border-radius: 28rpx;
padding: 40rpx 36rpx;
box-shadow: 0 12rpx 36rpx rgba(0, 0, 0, 0.06);
.tab-header {
display: flex;
border-bottom: 1rpx solid #f0f0f0;
margin-bottom: 36rpx;
.tab-item {
flex: 1;
text-align: center;
padding-bottom: 24rpx;
font-size: 30rpx;
color: #8c8c8c;
font-weight: 500;
position: relative;
&.active {
color: #111827;
font-weight: 700;
}
.active-indicator {
position: absolute;
bottom: -1rpx;
left: 50%;
transform: translateX(-50%);
width: 48rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
.form-container {
.input-item {
margin-bottom: 28rpx;
.send-btn {
padding: 10rpx 20rpx;
background: #111827;
color: #ffffff;
border-radius: 10rpx;
font-size: 24rpx;
white-space: nowrap;
&.disabled {
background: #d1d5db;
color: #9ca3af;
}
}
}
}
.action-btn {
background: #111827;
border-radius: 18rpx;
height: 92rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 32rpx;
box-shadow: 0 8rpx 20rpx rgba(17, 24, 39, 0.2);
.btn-text {
color: #ffffff;
font-size: 32rpx;
font-weight: 600;
}
&.loading {
opacity: 0.7;
}
}
.notice-tip {
display: flex;
align-items: center;
justify-content: center;
margin-top: 28rpx;
gap: 8rpx;
.notice-text {
font-size: 22rpx;
color: #9ca3af;
}
}
}
</style>

View File

@@ -0,0 +1,586 @@
<template>
<view class="merchant-order-detail">
<!-- 状态头部 -->
<view class="status-banner" :class="getStatusClass(orderDetail?.order?.orderStatus)">
<view class="status-icon">
<u-icon :name="getStatusIcon(orderDetail?.order?.orderStatus)" size="28" color="#ffffff"></u-icon>
</view>
<view class="status-text-box">
<text class="status-title">{{ getStatusText(orderDetail?.order?.orderStatus) }}</text>
<view class="sn-row" @click="copySn(orderSn)">
<text class="status-sub">订单编号:{{ orderSn }}</text>
<u-icon name="file-text" size="13" color="rgba(255,255,255,0.8)"></u-icon>
</view>
</view>
</view>
<!-- 核销码专属卡片 -->
<view class="verify-code-card" v-if="orderDetail?.order?.verificationCode || isAppointment">
<view class="card-title-row">
<text class="card-title">核销凭证</text>
<view class="code-badge">
{{ isAppointment ? '预约核销' : '自提核销' }}
</view>
</view>
<view class="code-box">
<text class="code-number">{{ orderDetail?.order?.verificationCode || '--' }}</text>
<view
class="verify-now-btn"
v-if="orderDetail?.order?.orderStatus === 'TAKE'"
@click="handleDirectVerify"
>
立即核销
</view>
</view>
</view>
<!-- 买家 / 收货信息 -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">买家信息</text>
</view>
<view class="info-row">
<text class="info-label">收货人/自提人:</text>
<text class="info-value">{{ orderDetail?.order?.consigneeName || '匿名买家' }}</text>
</view>
<view class="info-row">
<text class="info-label">联系电话:</text>
<text class="info-value">{{ maskPhone(orderDetail?.order?.consigneeMobile) }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.consigneeAddressPath">
<text class="info-label">地址:</text>
<text class="info-value">{{ orderDetail?.order?.consigneeAddressPath }} {{ orderDetail?.order?.consigneeDetail || '' }}</text>
</view>
</view>
<!-- 商品清单(干净规范,拒绝裸露 JSON) -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">商品清单</text>
</view>
<view
class="goods-row"
v-for="(item, idx) in (orderDetail?.orderItems || [])"
:key="item.id || item.goodsId || idx"
>
<image class="goods-img" :src="getGoodsImage(item)" mode="aspectFill"></image>
<view class="goods-detail">
<text class="goods-title">{{ getGoodsTitle(item) }}</text>
<view class="sku-tag" v-if="getCleanSpecs(item)">
<text>{{ getCleanSpecs(item) }}</text>
</view>
<view class="goods-bottom">
<text class="price">¥{{ item.unitPrice || item.goodsPrice || '0.00' }}</text>
<text class="qty">x{{ item.num || 1 }}</text>
</view>
</view>
</view>
</view>
<!-- 订单财务明细 -->
<view class="info-card">
<view class="card-title-row">
<text class="card-title">费用明细</text>
</view>
<view class="fee-row">
<text class="fee-label">商品总价</text>
<text class="fee-val">¥{{ orderDetail?.order?.goodsPrice || '0.00' }}</text>
</view>
<view class="fee-row" v-if="orderDetail?.order?.discountPrice">
<text class="fee-label">优惠金额</text>
<text class="fee-val discount">-¥{{ orderDetail?.order?.discountPrice }}</text>
</view>
<view class="fee-row" v-if="orderDetail?.order?.freightPrice">
<text class="fee-label">运费</text>
<text class="fee-val">+¥{{ orderDetail?.order?.freightPrice }}</text>
</view>
<view class="fee-divider"></view>
<view class="fee-row total">
<text class="fee-label">实收金额</text>
<text class="fee-val total-price">¥{{ orderDetail?.order?.flowPrice || '0.00' }}</text>
</view>
</view>
<!-- 订单参数(支付方式中文人性化映射) -->
<view class="info-card">
<view class="info-row">
<text class="info-label">下单时间:</text>
<text class="info-value">{{ orderDetail?.order?.createTime || '--' }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.paymentTime">
<text class="info-label">支付时间:</text>
<text class="info-value">{{ orderDetail?.order?.paymentTime }}</text>
</view>
<view class="info-row" v-if="orderDetail?.order?.paymentMethod">
<text class="info-label">支付方式:</text>
<text class="info-value pay-method-val">{{ formatPaymentMethod(orderDetail?.order?.paymentMethod) }}</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getStoreOrderDetail, storeOrderTake } from '../../api/order.js'
import { parseGoodsImageUrl } from '@/utils/filters.js'
const orderSn = ref('')
const orderDetail = ref<any>(null)
const isAppointment = computed(() => {
return orderDetail.value?.order?.orderType === 'APPOINTMENT_GOODS'
})
onLoad((options: any) => {
if (options?.sn) {
orderSn.value = options.sn
fetchDetail()
}
})
const fetchDetail = async () => {
uni.showLoading({ title: '加载中...' })
try {
const res: any = await getStoreOrderDetail(orderSn.value)
uni.hideLoading()
if (res?.data && res.data.success && res.data.result) {
orderDetail.value = res.data.result
} else {
uni.showToast({ title: '获取订单详情失败', icon: 'none' })
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
// 复制单号
const copySn = (sn: string) => {
if (!sn) return
uni.setClipboardData({
data: sn,
success: () => {
uni.showToast({ title: '单号已复制', icon: 'none' })
},
})
}
// 提取商品标题
const getGoodsTitle = (item: any) => {
if (item.goodsName && item.goodsName.trim()) return item.goodsName
if (item.name && item.name.trim()) return item.name
if (orderDetail.value?.order?.orderName) return orderDetail.value.order.orderName
return '精选商品'
}
// 智能提取商品图片,过滤并兼顾富文本/JSON 结构
const getGoodsImage = (item: any) => {
if (item.image) {
const parsed = parseGoodsImageUrl(item.image)
if (parsed) return parsed
}
// 若 image 为空,尝试从 specs JSON 里抓取合法的图片 url
if (item.specs && typeof item.specs === 'string') {
const match = item.specs.match(/https?:\/\/[^\s"'\\}]+\.(jpeg|jpg|png|webp|gif)/i)
if (match) return match[0]
}
return '/static/tabbar/home.png'
}
// 智能提炼清洁规格,绝不裸露冗长的原始 JSON
const getCleanSpecs = (item: any) => {
const specs = item.specs
if (!specs || !String(specs).trim()) return ''
const trimmed = String(specs).trim()
// 若为 JSON 格式
if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
try {
const obj = JSON.parse(trimmed)
const ignoreKeys = ['images', 'code', 'message', 'result', 'success', 'showProgress', 'url', 'status']
const pairs: string[] = []
for (const [k, v] of Object.entries(obj)) {
if (!ignoreKeys.includes(k) && typeof v === 'string' && !v.startsWith('http') && v.length < 50) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
} catch (e) {}
// 解析失败正则提取业务键值对
const matches = [...trimmed.matchAll(/"([^"]{1,20})"\s*:\s*"([^"]{1,30})"/g)]
const ignoreKeys = ['code', 'message', 'success', 'url', 'result', 'showProgress', 'status', 'name']
const pairs: string[] = []
for (const m of matches) {
const k = m[1]
const v = m[2]
if (!ignoreKeys.includes(k) && !v.startsWith('http')) {
pairs.push(`${k}: ${v}`)
}
}
if (pairs.length > 0) return pairs.join(' / ')
return ''
}
// 纯文本规格
return trimmed
}
// 支付方式中文映射
const formatPaymentMethod = (method: string) => {
if (!method) return '--'
const map: Record<string, string> = {
WALLET: '余额支付',
ALIPAY: '支付宝支付',
ALIPAY_PC: '支付宝支付',
ALIPAY_WAP: '支付宝支付',
ALIPAY_APP: '支付宝支付',
WECHAT: '微信支付',
WEIXIN: '微信支付',
WECHAT_MP: '微信支付',
WEIXIN_MP: '微信支付',
WX_JSAPI: '微信支付',
WX_APP: '微信支付',
WX_NATIVE: '微信支付',
WX_H5: '微信支付',
BANK_TRANSFER: '银行转账',
POINT: '积分兑换',
CASH: '现金支付',
OFFLINE: '线下支付',
FREE: '免费免付',
}
const key = String(method).toUpperCase().trim()
return map[key] || method
}
const maskPhone = (phone: string) => {
if (!phone || phone.length < 7) return phone || ''
return phone.replace(/(\d{3})\d{4}(\d{4})/, '$1****$2')
}
const getStatusText = (status: string) => {
const map: Record<string, string> = {
UNPAID: '待付款',
PAID: '已付款',
UNDELIVERED: '待发货',
DELIVERED: '待收货',
COMPLETED: '已完成',
CANCELLED: '已取消',
TAKE: '待核销',
}
return map[status] || status || '处理中'
}
const getStatusClass = (status: string) => {
if (status === 'TAKE') return 'bg-take'
if (status === 'COMPLETED') return 'bg-done'
if (status === 'CANCELLED') return 'bg-cancel'
return 'bg-normal'
}
const getStatusIcon = (status: string) => {
if (status === 'TAKE') return 'checkmark-circle-fill'
if (status === 'COMPLETED') return 'checkmark'
if (status === 'CANCELLED') return 'close'
return 'clock'
}
// 直接在详情页核销
const handleDirectVerify = async () => {
const code = orderDetail.value?.order?.verificationCode
if (!code) {
uni.showToast({ title: '该订单暂无可核销码', icon: 'none' })
return
}
uni.showModal({
title: '确认核销',
content: `确认核销此单?核销码:${code}`,
success: async (res) => {
if (res.confirm) {
uni.showLoading({ title: '正在核销...' })
try {
const takeRes: any = await storeOrderTake(orderSn.value, code)
uni.hideLoading()
if (takeRes?.data && takeRes.data.success) {
uni.showToast({ title: '核销成功', icon: 'success' })
fetchDetail()
} else {
uni.showToast({
title: takeRes?.data?.message || '核销失败',
icon: 'none',
})
}
} catch (e) {
uni.hideLoading()
uni.showToast({ title: '核销异常,请稍后重试', icon: 'none' })
}
}
},
})
}
</script>
<style lang="scss" scoped>
.merchant-order-detail {
min-height: 100vh;
background-color: #f4f5f7;
padding-bottom: calc(50rpx + env(safe-area-inset-bottom));
}
.status-banner {
padding: 44rpx 36rpx;
color: #ffffff;
display: flex;
align-items: center;
&.bg-take {
background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
&.bg-normal {
background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
}
&.bg-done {
background: #6b7280;
}
&.bg-cancel {
background: #9ca3af;
}
.status-icon {
width: 68rpx;
height: 68rpx;
border-radius: 34rpx;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
margin-right: 20rpx;
}
.status-text-box {
display: flex;
flex-direction: column;
.status-title {
font-size: 36rpx;
font-weight: 700;
}
.sn-row {
display: flex;
align-items: center;
gap: 8rpx;
margin-top: 8rpx;
.status-sub {
font-size: 24rpx;
color: rgba(255, 255, 255, 0.85);
}
}
}
}
.verify-code-card {
margin: -24rpx 28rpx 24rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.05);
.card-title-row {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 20rpx;
.card-title {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.code-badge {
font-size: 22rpx;
font-weight: 500;
color: #059669;
background: #ecfdf5;
padding: 4rpx 14rpx;
border-radius: 8rpx;
}
}
.code-box {
display: flex;
justify-content: space-between;
align-items: center;
background: #f9fafb;
border-radius: 16rpx;
padding: 20rpx 28rpx;
.code-number {
font-size: 44rpx;
font-weight: 700;
color: #10b981;
letter-spacing: 4rpx;
}
.verify-now-btn {
background: #111827;
color: #ffffff;
padding: 14rpx 32rpx;
border-radius: 14rpx;
font-size: 26rpx;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(17, 24, 39, 0.2);
}
}
}
.info-card {
margin: 0 28rpx 24rpx 28rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.02);
.card-title-row {
margin-bottom: 20rpx;
padding-bottom: 14rpx;
border-bottom: 1rpx solid #f9fafb;
.card-title {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
}
.info-row {
display: flex;
align-items: flex-start;
font-size: 26rpx;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.info-label {
color: #6b7280;
width: 180rpx;
flex-shrink: 0;
}
.info-value {
color: #111827;
flex: 1;
font-weight: 500;
line-height: 1.4;
&.pay-method-val {
color: #2563eb;
font-weight: 600;
}
}
}
.goods-row {
display: flex;
padding: 18rpx 0;
border-bottom: 1rpx solid #f9fafb;
&:last-child {
border-bottom: none;
}
.goods-img {
width: 140rpx;
height: 140rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.goods-detail {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-title {
font-size: 28rpx;
color: #111827;
font-weight: 600;
line-height: 1.4;
}
.sku-tag {
margin-top: 6rpx;
text {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.goods-bottom {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.price {
font-size: 30rpx;
font-weight: 700;
color: #111827;
}
.qty {
font-size: 22rpx;
color: #9ca3af;
}
}
}
}
.fee-row {
display: flex;
justify-content: space-between;
font-size: 26rpx;
margin-bottom: 14rpx;
color: #6b7280;
.discount {
color: #10b981;
}
&.total {
margin-top: 16rpx;
margin-bottom: 0;
font-size: 28rpx;
font-weight: 700;
color: #111827;
.total-price {
font-size: 36rpx;
font-weight: 700;
color: #ef4444;
}
}
}
.fee-divider {
height: 1rpx;
background: #f3f4f6;
margin: 16rpx 0;
}
}
</style>

View File

@@ -0,0 +1,653 @@
<template>
<view class="merchant-order-page">
<!-- 顶部吸顶搜索栏与 Tab -->
<view class="sticky-header">
<!-- 搜索栏 -->
<view class="search-box">
<view class="search-input-wrap">
<u-icon name="search" size="18" color="#9ca3af"></u-icon>
<input
class="search-input"
type="text"
v-model="keywords"
placeholder="搜索订单号 / 买家手机号"
placeholder-class="placeholder"
confirm-type="search"
@confirm="onSearch"
/>
<view class="clear-btn" v-if="keywords" @click="clearSearch">
<u-icon name="close-circle-fill" size="16" color="#d1d5db"></u-icon>
</view>
</view>
<view class="search-action-btn" v-if="keywords" @click="onSearch">
<text>搜索</text>
</view>
</view>
<!-- 状态横向滑动 Tab 栏(绝不折行) -->
<scroll-view class="tab-scroll" scroll-x :show-scrollbar="false" :scroll-with-animation="true">
<view class="tab-inner">
<view
class="tab-item"
v-for="item in tabList"
:key="item.key"
:class="{ active: currentTab === item.key }"
@click="switchTab(item.key)"
>
<text class="tab-label">{{ item.label }}</text>
<view class="indicator" v-if="currentTab === item.key"></view>
</view>
</view>
</scroll-view>
</view>
<!-- 订单列表主体 -->
<view class="order-list-body">
<!-- 列表数据 -->
<view
class="order-card"
v-for="order in orderList"
:key="order.sn"
@click="goToDetail(order.sn)"
>
<!-- 头部:单号与状态 -->
<view class="card-head">
<view class="sn-box" @click.stop="copySn(order.sn)">
<text class="order-sn">单号:{{ order.sn }}</text>
<u-icon name="file-text" size="14" color="#9ca3af"></u-icon>
</view>
<view class="status-badge" :class="getStatusClass(order.orderStatus)">
{{ getStatusText(order.orderStatus) }}
</view>
</view>
<!-- 商品信息 -->
<view class="goods-container">
<view
class="goods-item"
v-for="goods in (order.orderItems || [])"
:key="goods.id || goods.goodsId"
>
<image class="goods-thumb" :src="goods.image || '/static/tabbar/home.png'" mode="aspectFill"></image>
<view class="goods-info">
<text class="goods-name">{{ getGoodsName(goods, order) }}</text>
<view class="spec-pill" v-if="getSpecText(goods)">
<text>{{ getSpecText(goods) }}</text>
</view>
<view class="price-qty-row">
<text class="goods-price">¥{{ goods.unitPrice || goods.goodsPrice || '0.00' }}</text>
<text class="goods-qty">x{{ goods.num || 1 }}</text>
</view>
</view>
</view>
</view>
<!-- 订单金额与买家信息 -->
<view class="card-foot">
<view class="buyer-info" v-if="order.consigneeMobile || order.memberPhone">
<u-icon name="account" size="14" color="#9ca3af"></u-icon>
<text class="buyer-tel">{{ maskPhone(order.consigneeMobile || order.memberPhone) }}</text>
</view>
<view class="buyer-info" v-else>
<text class="order-type-tag" v-if="order.orderType === 'APPOINTMENT_GOODS'">预约商品单</text>
<text class="order-type-tag" v-else-if="order.verificationCode">自提单</text>
</view>
<view class="total-bar">
<text class="total-label">实付:</text>
<text class="total-symbol">¥</text>
<text class="total-price">{{ order.flowPrice || '0.00' }}</text>
</view>
</view>
<!-- 核销专属快捷动作 -->
<view class="card-actions" v-if="order.verificationCode || order.orderType === 'APPOINTMENT_GOODS' || order.orderStatus === 'TAKE'">
<view class="action-btn verify" @click.stop="quickVerify(order)">
<u-icon name="scan" size="15" color="#ffffff"></u-icon>
<text class="btn-lbl">扫码/输码核销</text>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="!loading && orderList.length === 0">
<u-icon name="order" size="64" color="#d1d5db"></u-icon>
<text class="empty-text">暂无相关订单记录</text>
</view>
<!-- 加载提示 -->
<view class="loading-more" v-if="loading">
<text>正在加载订单数据...</text>
</view>
<view class="no-more" v-else-if="finished && orderList.length > 0">
<text>— 没有更多了 —</text>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
import { getStoreOrderList } from '../../api/order.js'
const keywords = ref('')
const currentTab = ref('ALL')
const loading = ref(false)
const finished = ref(false)
const pageNumber = ref(1)
const pageSize = ref(10)
const orderList = ref<any[]>([])
// 优化 Tab 标题,保持精练统一、绝不换行
const tabList = [
{ key: 'ALL', label: '全部' },
{ key: 'TAKE', label: '待核销' },
{ key: 'UNDELIVERED', label: '待发货' },
{ key: 'DELIVERED', label: '待收货' },
{ key: 'COMPLETED', label: '已完成' },
]
onLoad((options: any) => {
if (options?.tab) {
currentTab.value = options.tab
}
fetchOrders(true)
})
onPullDownRefresh(async () => {
await fetchOrders(true)
uni.stopPullDownRefresh()
})
onReachBottom(() => {
if (!finished.value && !loading.value) {
pageNumber.value++
fetchOrders(false)
}
})
const fetchOrders = async (reset = false) => {
if (reset) {
pageNumber.value = 1
orderList.value = []
finished.value = false
}
loading.value = true
const params: any = {
pageNumber: pageNumber.value,
pageSize: pageSize.value,
keywords: keywords.value.trim() || undefined,
}
if (currentTab.value !== 'ALL') {
params.orderStatus = currentTab.value
}
try {
const res: any = await getStoreOrderList(params)
loading.value = false
if (res?.data && res.data.success) {
const records = res.data.result?.records || []
if (reset) {
orderList.value = records
} else {
orderList.value = [...orderList.value, ...records]
}
if (records.length < pageSize.value) {
finished.value = true
}
} else {
uni.showToast({
title: res?.data?.message || '获取订单列表失败',
icon: 'none',
})
}
} catch (e) {
loading.value = false
uni.showToast({ title: '网络连接异常', icon: 'none' })
}
}
const switchTab = (key: string) => {
if (currentTab.value === key) return
currentTab.value = key
fetchOrders(true)
}
const onSearch = () => {
fetchOrders(true)
}
const clearSearch = () => {
keywords.value = ''
fetchOrders(true)
}
const goToDetail = (sn: string) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/order/detail?sn=${sn}`,
})
}
// 快捷核销
const quickVerify = (order: any) => {
uni.navigateTo({
url: `/pages-sub/merchant/pages/order/detail?sn=${order.sn}&autoVerify=1`,
})
}
// 复制单号
const copySn = (sn: string) => {
if (!sn) return
uni.setClipboardData({
data: sn,
success: () => {
uni.showToast({ title: '单号已复制', icon: 'none' })
},
})
}
// 提取商品名(容错兜底)
const getGoodsName = (goods: any, order: any) => {
if (goods.goodsName && goods.goodsName.trim()) return goods.goodsName
if (goods.name && goods.name.trim()) return goods.name
if (order.orderName && order.orderName.trim()) return order.orderName
if (goods.specs && goods.specs.trim()) return goods.specs
return '精选商品'
}
// 提取规格文本(智能剔除多余字段)
const getSpecText = (goods: any) => {
const specs = goods.specs
if (!specs || !String(specs).trim()) return ''
if (specs === goods.goodsName) return ''
// 处理 JSON 字符串形式
if (typeof specs === 'string' && (specs.startsWith('{') || specs.startsWith('['))) {
try {
const obj = JSON.parse(specs)
if (typeof obj === 'object') {
const values = Object.values(obj).filter(Boolean)
if (values.length) return values.join(' / ')
}
} catch (e) {}
}
return String(specs)
}
// 手机号脱敏
const maskPhone = (phone: string) => {
if (!phone) return ''
const str = String(phone).trim()
if (str.length === 11) {
return str.substring(0, 3) + '****' + str.substring(7)
}
return str
}
// 状态文字映射
const getStatusText = (status: string) => {
const map: Record<string, string> = {
UNPAID: '待付款',
PAID: '已付款',
UNDELIVERED: '待发货',
DELIVERED: '待收货',
COMPLETED: '已完成',
CANCELLED: '已取消',
TAKE: '待核销',
}
return map[status] || status || '处理中'
}
// 状态样式类
const getStatusClass = (status: string) => {
switch (status) {
case 'TAKE':
return 'status-take'
case 'COMPLETED':
return 'status-done'
case 'CANCELLED':
return 'status-cancel'
default:
return 'status-normal'
}
}
</script>
<style lang="scss" scoped>
.merchant-order-page {
min-height: 100vh;
background-color: #f4f5f7;
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
}
.sticky-header {
position: sticky;
top: 0;
z-index: 50;
background: #ffffff;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.04);
.search-box {
padding: 16rpx 28rpx 10rpx 28rpx;
display: flex;
align-items: center;
gap: 16rpx;
.search-input-wrap {
flex: 1;
height: 72rpx;
background: #f3f4f6;
border-radius: 36rpx;
display: flex;
align-items: center;
padding: 0 24rpx;
.search-input {
flex: 1;
margin-left: 12rpx;
font-size: 26rpx;
color: #111827;
}
.placeholder {
color: #9ca3af;
font-size: 26rpx;
}
.clear-btn {
padding: 6rpx;
}
}
.search-action-btn {
font-size: 28rpx;
color: #2563eb;
font-weight: 600;
padding: 0 8rpx;
}
}
.tab-scroll {
width: 100%;
white-space: nowrap;
.tab-inner {
display: flex;
align-items: center;
padding: 0 16rpx;
min-width: 100%;
box-sizing: border-box;
.tab-item {
flex: 1;
min-width: 130rpx;
text-align: center;
padding: 22rpx 12rpx;
position: relative;
white-space: nowrap;
.tab-label {
font-size: 28rpx;
color: #6b7280;
font-weight: 500;
transition: all 0.2s ease;
}
&.active {
.tab-label {
color: #111827;
font-weight: 700;
font-size: 30rpx;
}
.indicator {
position: absolute;
bottom: 4rpx;
left: 50%;
transform: translateX(-50%);
width: 44rpx;
height: 6rpx;
background: #111827;
border-radius: 3rpx;
}
}
}
}
}
}
.order-list-body {
padding: 24rpx 28rpx;
.order-card {
background: #ffffff;
border-radius: 24rpx;
padding: 28rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
.card-head {
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 20rpx;
border-bottom: 1rpx solid #f3f4f6;
.sn-box {
display: flex;
align-items: center;
gap: 8rpx;
.order-sn {
font-size: 24rpx;
color: #6b7280;
font-weight: 500;
}
}
.status-badge {
font-size: 22rpx;
font-weight: 600;
padding: 6rpx 16rpx;
border-radius: 10rpx;
&.status-take {
background: #ecfdf5;
color: #059669;
}
&.status-done {
background: #f3f4f6;
color: #6b7280;
}
&.status-cancel {
background: #f9fafb;
color: #9ca3af;
}
&.status-normal {
background: #fff7ed;
color: #ea580c;
}
}
}
.goods-container {
padding: 10rpx 0;
.goods-item {
display: flex;
padding: 16rpx 0;
border-bottom: 1rpx solid #fafafa;
&:last-child {
border-bottom: none;
}
.goods-thumb {
width: 140rpx;
height: 140rpx;
border-radius: 14rpx;
background: #f9fafb;
border: 1rpx solid #f3f4f6;
flex-shrink: 0;
}
.goods-info {
flex: 1;
margin-left: 20rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
.goods-name {
font-size: 28rpx;
font-weight: 600;
color: #111827;
line-height: 1.4;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.spec-pill {
margin-top: 6rpx;
text {
font-size: 22rpx;
color: #6b7280;
background: #f3f4f6;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.price-qty-row {
display: flex;
justify-content: space-between;
align-items: baseline;
margin-top: 10rpx;
.goods-price {
font-size: 28rpx;
font-weight: 700;
color: #111827;
}
.goods-qty {
font-size: 22rpx;
color: #9ca3af;
}
}
}
}
}
.card-foot {
display: flex;
justify-content: space-between;
align-items: center;
padding-top: 20rpx;
border-top: 1rpx solid #f9fafb;
.buyer-info {
display: flex;
align-items: center;
gap: 8rpx;
.buyer-tel {
font-size: 24rpx;
color: #6b7280;
font-weight: 500;
}
.order-type-tag {
font-size: 20rpx;
color: #2563eb;
background: #eff6ff;
padding: 4rpx 12rpx;
border-radius: 6rpx;
}
}
.total-bar {
display: flex;
align-items: baseline;
.total-label {
font-size: 24rpx;
color: #6b7280;
}
.total-symbol {
font-size: 24rpx;
font-weight: 700;
color: #ef4444;
}
.total-price {
font-size: 34rpx;
font-weight: 700;
color: #ef4444;
margin-left: 2rpx;
}
}
}
.card-actions {
display: flex;
justify-content: flex-end;
padding-top: 20rpx;
margin-top: 16rpx;
border-top: 1rpx dashed #e5e7eb;
.action-btn {
display: flex;
align-items: center;
gap: 8rpx;
padding: 14rpx 28rpx;
border-radius: 36rpx;
font-size: 26rpx;
font-weight: 600;
&.verify {
background: #111827;
color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(17, 24, 39, 0.15);
.btn-lbl {
font-size: 24rpx;
}
}
}
}
}
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 0;
.empty-text {
font-size: 28rpx;
color: #9ca3af;
margin-top: 24rpx;
}
}
.loading-more,
.no-more {
text-align: center;
padding: 30rpx 0;
font-size: 24rpx;
color: #9ca3af;
}
}
</style>

View File

@@ -0,0 +1,155 @@
import api from "@/config/api.js";
import Request from "@/lib/request/index.js";
import Foundation from "@/utils/Foundation.js";
import { md5 } from "@/utils/md5.js";
import storage from "@/utils/storage.js";
import uuid from "@/utils/uuid.modified.js";
let isStoreNavigateTo = false;
function cleanStoreAuth() {
uni.showToast({
title: "商家登录状态已过期,请重新登录",
icon: "none",
duration: 1800,
});
storage.clearStoreAuth();
if (!isStoreNavigateTo) {
isStoreNavigateTo = true;
setTimeout(() => {
isStoreNavigateTo = false;
uni.reLaunch({
url: "/pages-sub/merchant/pages/login/index",
});
}, 1200);
}
}
const storeHttp = new Request();
const ensureUuid = () => {
if (!storage.getUuid()) {
storage.setUuid(uuid.v1());
}
};
storeHttp.setConfig((config) => {
ensureUuid();
config.baseURL = api.store;
config.header = {
...config.header,
};
config.validateStatus = () => true;
return config;
});
storeHttp.interceptors.request.use(
(config) => {
ensureUuid();
const token = storage.getStoreAccessToken();
if (token) {
const nonce = Foundation.randomString(6);
const timestamp = parseInt(new Date().getTime() / 1000);
const sign = md5(nonce + timestamp + token);
const _params = { nonce, timestamp, sign };
config.params = { ...(config.params || {}), ..._params };
config.header.accessToken = token;
}
config.header = {
...config.header,
uuid: storage.getUuid(),
};
return config;
},
(config) => Promise.reject(config)
);
let isStoreRefreshing = false;
let storeRequests = [];
function refreshTokenApi(refreshToken) {
return uni.request({
url: `${api.store}/passport/login/refresh/${refreshToken}`,
method: "GET",
header: {
uuid: storage.getUuid(),
},
});
}
storeHttp.interceptors.response.use(
async (response) => {
isStoreNavigateTo = false;
try {
uni.hideLoading();
} catch (e) {}
const token = storage.getStoreAccessToken();
const refreshToken = storage.getStoreRefreshToken();
// 403 / 401 并且有 refreshToken,尝试刷新
if (
token &&
refreshToken &&
(response.statusCode === 403 || response.statusCode === 401 || response.data?.code === 403)
) {
if (!isStoreRefreshing) {
isStoreRefreshing = true;
storage.removeStoreAccessToken();
try {
const [err, res] = await refreshTokenApi(refreshToken);
const data = res?.data || err?.data;
if (data && data.success && data.result) {
const { accessToken: newAccessToken, refreshToken: newRefreshToken } = data.result;
storage.setStoreAccessToken(newAccessToken);
if (newRefreshToken) {
storage.setStoreRefreshToken(newRefreshToken);
}
response.header = response.header || {};
response.header.accessToken = `${newAccessToken}`;
storeRequests.forEach((cb) => cb(newAccessToken));
storeRequests = [];
return storeHttp.request(response.config);
} else {
cleanStoreAuth();
return Promise.reject(data);
}
} catch (e) {
cleanStoreAuth();
return Promise.reject(e);
} finally {
isStoreRefreshing = false;
}
} else {
return new Promise((resolve) => {
storeRequests.push((newToken) => {
response.header = response.header || {};
response.header.accessToken = `${newToken}`;
resolve(storeHttp.request(response.config));
});
});
}
} else if (
(!token && (response.statusCode === 403 || response.statusCode === 401)) ||
response.data?.code === 403 ||
response.data?.code === 401
) {
cleanStoreAuth();
} else if ((response.statusCode === 200 && response.data && !response.data.success) || response.statusCode === 400) {
if (response.data?.message) {
uni.showToast({
title: response.data.message,
icon: "none",
duration: 2000,
});
}
}
return response;
},
(error) => error
);
export { storeHttp };
export default storeHttp;

View File

@@ -106,6 +106,70 @@
],
"subPackages": [
{
"root": "pages-sub/merchant",
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationBarTitleText": "商家工作台",
"navigationBarBackgroundColor": "#111827",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/login/index",
"style": {
"navigationBarTitleText": "商家登录",
"navigationBarBackgroundColor": "#111827",
"navigationBarTextStyle": "white"
}
},
{
"path": "pages/order/list",
"style": {
"navigationBarTitleText": "订单核销管理",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/order/detail",
"style": {
"navigationBarTitleText": "订单详情",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/goods/list",
"style": {
"navigationBarTitleText": "商品管理",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/goods/detail",
"style": {
"navigationBarTitleText": "商品详情",
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
},
{
"path": "pages/evaluation/list",
"style": {
"navigationBarTitleText": "评价管理",
"enablePullDownRefresh": true,
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black"
}
}
]
},
{
"root": "pages/mine",
"pages": [
@@ -447,6 +511,13 @@
"navigationBarTitleText": "设置"
}
},
{
"path": "set/messageNotice",
"style": {
"navigationBarTitleText": "消息通知",
"navigationStyle": "custom"
}
},
{
"path": "set/personMsg",
"style": {
@@ -471,7 +542,8 @@
}, {
"path": "point/myPoint",
"style": {
"navigationBarTitleText": "我的积分"
"navigationBarTitleText": "我的积分",
"navigationStyle": "custom"
}
},
{
@@ -926,6 +998,7 @@
{
"path": "afterSales/applySuccess",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": "提交成功",
"app-plus": {
"bounce": "none",
@@ -957,13 +1030,6 @@
"navigationBarTitleText": "申请售后"
}
},
{
"path": "afterSales/afterSales",
"style": {
"navigationBarTitleText": "售后管理",
"enablePullDownRefresh": true
}
},
{
"path": "fillorder",
"style": {

View File

@@ -72,10 +72,10 @@ import { onLoad, onBackPress } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import * as API_Trade from '@/api/trade'
import { payCallback } from '@/api/members'
import { unitPrice } from '@/utils/filters.js'
import { unitPrice } from '@/utils/filters.js'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const { proxy } = getCurrentInstance()!
@@ -126,15 +126,20 @@ function hideLoadingIfNeeded() {
}
function callback(paymentMethod: string) {
uni.redirectTo({
url:
'/pages/cart/payment/success?paymentMethod=' +
paymentMethod +
'&payPrice=' +
cashierParams.value.price +
'&orderType=' +
orderType.value,
})
const goSuccess = () => {
uni.redirectTo({
url:
'/pages/cart/payment/success?paymentMethod=' +
paymentMethod +
'&payPrice=' +
cashierParams.value.price +
'&orderType=' +
orderType.value +
'&orderPromotionType=' +
(cashierParams.value.orderPromotionType || ''),
})
}
goSuccess()
}
function cashierData() {

View File

@@ -1,154 +1,188 @@
<template>
<div :style="themeStyle" class="wrapper">
<div class="pay-wrapper">
<div class="pay-money">
¥{{unitPrice(Number(payPrice)) }}
</div>
<div class="pay-btns">
<div v-show="!from" @click="checkOrder">查看{{ orderType == "RECHARGE" ? '余额' : '订单' }}</div>
<div @click="navigateTo('/pages/tabbar/home/index', 'switch')">回到首页</div>
</div>
</div>
<div class="pay-box">
<div class="pay-tag-box">
<h2>订单支付成功!</h2>
<div class="pay-item">
<div>
支付方式:
</div>
<div>{{ paymentTypeFilter(paymentMethod) }}</div>
</div>
</div>
</div>
<goodsRecommend />
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import goodsRecommend from '@/components/m-goods-recommend'
<template>
<div :style="themeStyle" class="wrapper">
<div class="pay-wrapper">
<div class="pay-money">
¥{{ unitPrice(Number(payPrice)) }}
</div>
<div class="pay-btns">
<div v-show="!from" @click="checkOrder">查看{{ orderType == "RECHARGE" ? '余额' : '订单' }}</div>
<div @click="navigateTo('/pages/tabbar/home/index', 'switch')">回到首页</div>
</div>
</div>
<div class="pay-box">
<div class="pay-tag-box">
<h2>订单支付成功!</h2>
<div class="pay-item">
<div>
支付方式:
</div>
<div>{{ paymentTypeFilter(paymentMethod) }}</div>
</div>
</div>
</div>
<goodsRecommend />
</div>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import goodsRecommend from '@/components/m-goods-recommend'
import { unitPrice } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
import {
prefetchMpMessageTemplates,
subscribePayMessageThen,
} from '@/js_sdk/lili-pay/wx-pay.js'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const paymentMethod = ref('')
const from = ref('')
const payPrice = ref<number | string>(0)
const orderType = ref('')
onLoad((options) => {
paymentMethod.value = options.paymentMethod || ''
from.value = options.from || ''
payPrice.value = options.payPrice || 0
orderType.value = options.orderType || ''
})
function paymentTypeFilter(val: string) {
switch (val) {
case 'WECHAT':
return '微信'
case 'ALIPAY':
return '支付宝'
case 'WALLET':
return '余额支付'
default:
return ''
}
}
function checkOrder() {
if (orderType.value == 'RECHARGE') {
uni.reLaunch({
url: '/pages/mine/deposit/operation',
})
return
}
uni.reLaunch({
url: '/pages/order/myOrder?status=0',
})
}
function navigateTo(url: string, type?: string) {
if (type === 'switch') {
uni.switchTab({ url })
} else {
uni.redirectTo({ url })
}
}
</script><style scoped lang="scss">
.subscribe {
justify-content: space-between;
align-items: center;
margin: 0 auto 40rpx auto;
padding: 0 20rpx 20rpx;
width: 80%;
}
.pay-btns {
display: flex;
width: 50%;
justify-content: space-between;
margin: 0 auto;
color: #fff;
>div {
padding: 6px 12px;
border: 1px solid #fff;
border-radius: 100px;
}
}
.pay-money {
line-height: 1;
font-size: 50rpx;
color: #fff;
margin-bottom: 100rpx;
}
.pay-item {
font-weight: bold;
margin: 32rpx 0;
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: var(--theme-primary-70, rgba(255, 60, 42, 0.7));
}
.pay-box {
overflow: hidden;
}
.pay-tag-box {
width: 80%;
margin: 80rpx auto 40rpx auto;
padding: 20rpx;
border-radius: 20rpx;
background: var(--theme-primary-20, rgba(255, 60, 42, 0.2));
>h2 {
margin-top: 20rpx;
font-size: 40rpx;
color: $main-color;
}
}
.pay-wrapper {
background-image: linear-gradient(90deg, $main-color, $light-color, $aider-light-color);
height: 480rpx;
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.pay-box {
transform: translateY(-100rpx);
width: 100%;
background: #fff;
border-top-right-radius: 100rpx;
}
</style>
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const paymentMethod = ref('')
const from = ref('')
const payPrice = ref<number | string>(0)
const orderType = ref('')
const orderPromotionType = ref('')
onLoad((options) => {
paymentMethod.value = options.paymentMethod || ''
from.value = options.from || ''
payPrice.value = options.payPrice || 0
orderType.value = options.orderType || ''
orderPromotionType.value = options.orderPromotionType || ''
// #ifdef MP-WEIXIN
prefetchMpMessageTemplates()
// #endif
})
function paymentTypeFilter(val: string) {
switch (val) {
case 'WECHAT':
return '微信'
case 'ALIPAY':
return '支付宝'
case 'WALLET':
return '余额支付'
default:
return ''
}
}
function checkOrder() {
if (orderType.value == 'RECHARGE') {
uni.reLaunch({
url: '/pages/mine/deposit/operation',
})
return
}
const doGoOrder = () => {
uni.reLaunch({
url: '/pages/order/myOrder?status=0',
})
}
// #ifdef MP-WEIXIN
subscribePayMessageThen(doGoOrder, {
orderPromotionType: orderPromotionType.value,
})
// #endif
// #ifndef MP-WEIXIN
doGoOrder()
// #endif
}
function navigateTo(url: string, type?: string) {
const doNavigate = () => {
if (type === 'switch') {
uni.switchTab({ url })
} else {
uni.redirectTo({ url })
}
}
if (orderType.value == 'RECHARGE') {
doNavigate()
return
}
// #ifdef MP-WEIXIN
subscribePayMessageThen(doNavigate, {
orderPromotionType: orderPromotionType.value,
})
// #endif
// #ifndef MP-WEIXIN
doNavigate()
// #endif
}
</script>
<style scoped lang="scss">
.subscribe {
justify-content: space-between;
align-items: center;
margin: 0 auto 40rpx auto;
padding: 0 20rpx 20rpx;
width: 80%;
}
.pay-btns {
display: flex;
width: 50%;
justify-content: space-between;
margin: 0 auto;
color: #fff;
>div {
padding: 6px 12px;
border: 1px solid #fff;
border-radius: 100px;
}
}
.pay-money {
line-height: 1;
font-size: 50rpx;
color: #fff;
margin-bottom: 100rpx;
}
.pay-item {
font-weight: bold;
margin: 32rpx 0;
display: flex;
justify-content: space-between;
font-size: 24rpx;
color: var(--theme-primary-70, rgba(255, 60, 42, 0.7));
}
.pay-box {
overflow: hidden;
}
.pay-tag-box {
width: 80%;
margin: 80rpx auto 40rpx auto;
padding: 20rpx;
border-radius: 20rpx;
background: var(--theme-primary-20, rgba(255, 60, 42, 0.2));
>h2 {
margin-top: 20rpx;
font-size: 40rpx;
color: $main-color;
}
}
.pay-wrapper {
background-image: linear-gradient(90deg, $main-color, $light-color, $aider-light-color);
height: 480rpx;
position: relative;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.pay-box {
transform: translateY(-100rpx);
width: 100%;
background: #fff;
border-top-right-radius: 100rpx;
}
</style>

View File

@@ -1,239 +1,484 @@
<template>
<view :style="themeStyle" class="wap">
<u-navbar
title="预存款列表"
:fixed="true"
:placeholder="true"
:border="false"
:auto-back="true"
></u-navbar>
<view class="wrapper-show-money">
<view class="money-view">
<text class="money-label">预存款金额</text>
<text class="money">¥{{ unitPrice(walletNum) }}</text>
</view>
</view>
<view class="wrapper-tabs">
<swiper class="swiper-box" :current="swiperCurrent">
<swiper-item class="swiper-item" v-for="index in list.length" :key="index">
<scroll-view
class="scroll-v view-wrapper"
enable-back-to-top
scroll-with-animation
scroll-y
@scrolltolower="loadMore"
>
<view v-if="depositData.length != 0" class="list-card">
<view
class="view-item"
v-for="(logItem, logIndex) in depositData"
:key="logIndex"
>
<view class="view-item-detail">
<text class="item-title">{{ logItem.detail }}</text>
</view>
<view class="view-item-change">
<text
class="item-money"
:class="getMoneyClass(logItem.serviceType)"
>{{ formatLogMoney(logItem) }}</text>
<text class="item-time">{{ logItem.createTime }}</text>
</view>
</view>
</view>
<u-empty v-if="depositData.length == 0" mode="history" text="暂无记录" />
</scroll-view>
</swiper-item>
</swiper>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { getWalletLog, getUserWallet } from '@/api/members'
<template>
<view :style="themeStyle" class="deposit-log-page">
<u-navbar
title="预存款明细"
:fixed="true"
:placeholder="true"
:border="false"
:auto-back="true"
></u-navbar>
<!-- 顶部余额概览卡片 -->
<view class="header-wrap">
<view class="balance-hero">
<view class="hero-glow hero-glow-1"></view>
<view class="hero-glow hero-glow-2"></view>
<view class="hero-top">
<text class="money-label">当前预存款余额 (元)</text>
</view>
<view class="money-row">
<text class="money-symbol">¥</text>
<text class="money-value">{{ unitPrice(walletNum) }}</text>
</view>
</view>
<!-- 收支筛选栏 -->
<view class="filter-bar">
<view
v-for="(tab, idx) in filterTabs"
:key="tab.key"
class="filter-pill"
:class="{ active: activeFilter === idx }"
@click="activeFilter = idx"
>
{{ tab.name }}
</view>
</view>
</view>
<!-- 明细列表区 -->
<view class="list-container">
<view v-if="filteredData.length > 0" class="list-card">
<view
class="log-item"
v-for="(item, logIndex) in filteredData"
:key="logIndex"
>
<!-- 第一行:类型标签 + 标题 | 变动金额 -->
<view class="log-row-main">
<view class="log-title-wrap">
<text class="type-tag" :class="item.parsed.tagClass">{{ item.parsed.tagText }}</text>
<text class="log-title">{{ item.parsed.title }}</text>
</view>
<text class="log-amount" :class="item.parsed.moneyClass">
{{ item.parsed.formattedMoney }}
</text>
</view>
<!-- 第二行:提取出的单号或备注说明 -->
<view v-if="item.parsed.metaList.length > 0" class="log-meta-box">
<view
class="log-meta-line"
v-for="(meta, mIdx) in item.parsed.metaList"
:key="mIdx"
>
<text class="meta-label">{{ meta.label }}:</text>
<text class="meta-val">{{ meta.value }}</text>
</view>
</view>
<!-- 第三行:变动时间 -->
<view class="log-row-foot">
<text class="log-time">{{ item.createTime }}</text>
</view>
</view>
</view>
<view v-else-if="loaded" class="empty-box">
<u-empty mode="history" text="暂无预存款变动记录" />
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, computed } from 'vue'
import { onReachBottom } from '@dcloudio/uni-app'
import { getWalletLog, getUserWallet } from '@/api/members'
import { unitPrice } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const walletNum = ref(0)
const swiperCurrent = ref(0)
const params = ref({
pageNumber: 1,
pageSize: 10,
order: 'desc',
})
const depositData = ref<any[]>([])
const list = [{ name: '预存款变动明细' }]
onMounted(async () => {
getWallet()
const result = await getUserWallet()
walletNum.value = result.data.result.memberWallet
})
function isOutgoing(serviceType: string) {
return serviceType === 'WALLET_PAY' || serviceType === 'WALLET_WITHDRAWAL'
}
function isIncoming(serviceType: string) {
return (
serviceType === 'WALLET_REFUND' ||
serviceType === 'WALLET_RECHARGE' ||
serviceType === 'WALLET_COMMISSION'
)
}
function getMoneyClass(serviceType: string) {
if (isOutgoing(serviceType)) return 'out'
if (isIncoming(serviceType)) return 'in'
return ''
}
function formatLogMoney(logItem: any) {
const amount = unitPrice(logItem.money)
if (isOutgoing(logItem.serviceType)) return `-${amount}`
if (isIncoming(logItem.serviceType)) return `+${amount}`
return amount
}
function getWallet() {
getWalletLog(params.value).then((res) => {
if (res.data.success && res.data.result.records.length) {
depositData.value.push(...res.data.result.records)
}
})
}
function loadMore() {
params.value.pageNumber++
getWallet()
}
</script>
<style lang="scss" scoped>
.wap {
min-height: 100vh;
display: flex;
flex-direction: column;
background: #f5f5f5;
}
.wrapper-show-money {
flex-shrink: 0;
height: 200rpx;
}
.money-view {
height: 100%;
padding: 32rpx 40rpx;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
color: #fff;
background-image: linear-gradient(
25deg,
$main-color,
$light-color,
$aider-light-color
);
}
.money-label {
font-size: 28rpx;
opacity: 0.95;
}
.money {
margin-top: 12rpx;
max-width: 100%;
font-size: 56rpx;
font-weight: 600;
line-height: 1.2;
word-break: break-all;
}
.wrapper-tabs {
flex: 1;
min-height: 0;
padding: 24rpx;
box-sizing: border-box;
}
.swiper-box,
.swiper-item,
.scroll-v {
height: 100%;
}
.list-card {
background: #fff;
border-radius: 16rpx;
overflow: hidden;
}
.view-item {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: space-between;
padding: 28rpx 32rpx;
border-bottom: 1px solid #f5f5f5;
&:last-child {
border-bottom: none;
}
}
.view-item-detail {
flex: 1;
min-width: 0;
padding-right: 24rpx;
}
.item-title {
font-size: 28rpx;
color: #333;
line-height: 1.5;
word-break: break-all;
}
.view-item-change {
flex-shrink: 0;
display: flex;
flex-direction: column;
align-items: flex-end;
align-self: center;
text-align: right;
}
.item-money {
font-size: 34rpx;
font-weight: 600;
line-height: 1.3;
white-space: nowrap;
&.in {
color: $aider-color-green;
}
&.out {
color: #ff5a5f;
}
}
.item-time {
margin-top: 8rpx;
font-size: 22rpx;
color: #999;
line-height: 1.3;
white-space: nowrap;
}
</style>
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const walletNum = ref(0)
const loaded = ref(false)
const hasMore = ref(true)
const activeFilter = ref(0)
const filterTabs = [
{ key: 'ALL', name: '全部明细' },
{ key: 'IN', name: '收入 / 退款' },
{ key: 'OUT', name: '支出 / 提现' },
]
const params = ref({
pageNumber: 1,
pageSize: 10,
order: 'desc',
})
const depositData = ref<any[]>([])
onMounted(async () => {
getWallet()
const result = await getUserWallet()
walletNum.value = result.data?.result?.memberWallet ?? 0
})
onReachBottom(() => {
if (!hasMore.value) return
loadMore()
})
function isOutgoing(logItem: any) {
const money = Number(logItem?.money) || 0
if (money < 0) return true
const serviceType = logItem?.serviceType
return serviceType === 'WALLET_PAY' || serviceType === 'WALLET_WITHDRAWAL'
}
function isIncoming(logItem: any) {
const money = Number(logItem?.money) || 0
if (money > 0) return true
const serviceType = logItem?.serviceType
return (
serviceType === 'WALLET_REFUND' ||
serviceType === 'WALLET_RECHARGE' ||
serviceType === 'WALLET_COMMISSION'
)
}
function parseLogDetail(logItem: any) {
const raw = String(logItem?.detail || '').trim()
const serviceType = logItem?.serviceType || ''
const out = isOutgoing(logItem)
const inc = isIncoming(logItem)
const absAmount = unitPrice(Math.abs(Number(logItem?.money) || 0))
const formattedMoney = out ? `-${absAmount}` : inc ? `+${absAmount}` : absAmount
const moneyClass = out ? 'out' : inc ? 'in' : ''
let title = '余额变动'
let tagText = '变动'
let tagClass = 'tag-default'
const orderMatch = raw.match(/订单\[([^\]]+)\]/)
const afterSaleMatch = raw.match(/售后单\[([^\]]+)\]/)
const rechargeMatch = raw.match(/充值单号为[::]\s*([A-Za-z0-9_-]+)/)
if (afterSaleMatch && afterSaleMatch[1] === 'ORDER_CANCEL') {
title = '订单取消退回'
tagText = '退款'
tagClass = 'tag-in'
} else if (serviceType === 'WALLET_REFUND' || raw.includes('退还') || raw.includes('返还')) {
title = '售后退款入账'
tagText = '退款'
tagClass = 'tag-in'
} else if (serviceType === 'WALLET_PAY' || raw.includes('支付金额')) {
title = '订单余额支付'
tagText = '消费'
tagClass = 'tag-out'
} else if (serviceType === 'WALLET_RECHARGE') {
title = raw.includes('后台') ? '平台余额充值' : '预存款充值'
tagText = '充值'
tagClass = 'tag-in'
} else if (serviceType === 'WALLET_WITHDRAWAL') {
title = out ? '余额提现申请' : '提现退回解冻'
tagText = '提现'
tagClass = out ? 'tag-out' : 'tag-in'
} else if (serviceType === 'WALLET_COMMISSION') {
title = '分销佣金入账'
tagText = '佣金'
tagClass = 'tag-in'
}
const metaList: Array<{ label: string; value: string }> = []
if (orderMatch && orderMatch[1]) {
metaList.push({ label: '订单编号', value: orderMatch[1] })
}
if (afterSaleMatch && afterSaleMatch[1] && afterSaleMatch[1] !== 'ORDER_CANCEL') {
metaList.push({ label: '售后单号', value: afterSaleMatch[1] })
}
if (rechargeMatch && rechargeMatch[1]) {
metaList.push({ label: '充值单号', value: rechargeMatch[1] })
}
if (metaList.length === 0 && raw && !raw.includes('???')) {
const cleaned = raw
.replace(/[,,]?\s*(支付金额|退还金额|余额返还)\[[^\]]+\]/g, '')
.replace(/:\s*\d+(\.\d+)?$/, '')
.trim()
if (cleaned && cleaned !== title) {
metaList.push({ label: '变动说明', value: cleaned })
}
}
return {
title,
tagText,
tagClass,
formattedMoney,
moneyClass,
isOut: out,
isIn: inc,
metaList,
}
}
const decoratedList = computed(() =>
depositData.value.map((item) => ({
...item,
parsed: parseLogDetail(item),
}))
)
const filteredData = computed(() => {
if (activeFilter.value === 1) {
return decoratedList.value.filter((item) => item.parsed.isIn)
}
if (activeFilter.value === 2) {
return decoratedList.value.filter((item) => item.parsed.isOut)
}
return decoratedList.value
})
function getWallet() {
getWalletLog(params.value).then((res) => {
loaded.value = true
const records = (res.data?.success && res.data?.result?.records) || []
if (records.length) {
depositData.value.push(...records)
}
if (records.length < params.value.pageSize) {
hasMore.value = false
}
})
}
function loadMore() {
params.value.pageNumber++
getWallet()
}
</script>
<style lang="scss" scoped>
.deposit-log-page {
min-height: 100vh;
background: #f5f6fa;
padding-bottom: 48rpx;
box-sizing: border-box;
}
.header-wrap {
padding: 24rpx 24rpx 8rpx;
}
.balance-hero {
position: relative;
overflow: hidden;
border-radius: 24rpx;
padding: 36rpx 36rpx 34rpx;
color: #ffffff;
background: linear-gradient(135deg, $main-color 0%, $light-color 60%, $aider-light-color 100%);
box-shadow: 0 12rpx 28rpx rgba(229, 50, 56, 0.18);
}
.hero-glow {
position: absolute;
border-radius: 50%;
background: rgba(255, 255, 255, 0.12);
pointer-events: none;
}
.hero-glow-1 {
width: 220rpx;
height: 220rpx;
right: -60rpx;
top: -70rpx;
}
.hero-glow-2 {
width: 140rpx;
height: 140rpx;
right: 90rpx;
bottom: -60rpx;
background: rgba(255, 255, 255, 0.08);
}
.hero-top {
display: flex;
align-items: center;
justify-content: space-between;
}
.money-label {
font-size: 25rpx;
color: rgba(255, 255, 255, 0.88);
letter-spacing: 0.5rpx;
}
.money-row {
margin-top: 14rpx;
display: flex;
align-items: baseline;
}
.money-symbol {
font-size: 34rpx;
font-weight: 600;
margin-right: 8rpx;
}
.money-value {
font-size: 58rpx;
font-weight: 700;
line-height: 1.15;
letter-spacing: 1rpx;
font-variant-numeric: tabular-nums;
}
.filter-bar {
display: flex;
align-items: center;
gap: 16rpx;
margin-top: 24rpx;
}
.filter-pill {
padding: 12rpx 28rpx;
border-radius: 999rpx;
font-size: 25rpx;
color: #666666;
background: #ffffff;
font-weight: 500;
transition: all 0.2s;
&.active {
background: $main-color;
color: #ffffff;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(229, 50, 56, 0.2);
}
}
.list-container {
padding: 16rpx 24rpx 0;
}
.list-card {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.log-item {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx 30rpx;
box-shadow: 0 2rpx 12rpx rgba(17, 30, 79, 0.03);
}
.log-row-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.log-title-wrap {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
}
.type-tag {
flex-shrink: 0;
font-size: 20rpx;
font-weight: 600;
padding: 4rpx 12rpx;
border-radius: 8rpx;
line-height: 1.3;
&.tag-in {
color: #00a870;
background: rgba(0, 168, 112, 0.1);
}
&.tag-out {
color: #ff4d4f;
background: rgba(255, 77, 79, 0.1);
}
&.tag-default {
color: #666666;
background: #f0f2f5;
}
}
.log-title {
font-size: 30rpx;
font-weight: 600;
color: #1d2129;
line-height: 1.35;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.log-amount {
flex-shrink: 0;
font-size: 34rpx;
font-weight: 700;
line-height: 1.2;
font-variant-numeric: tabular-nums;
color: #1d2129;
&.in {
color: #00a870;
}
&.out {
color: #ff4d4f;
}
}
.log-meta-box {
margin-top: 16rpx;
padding: 14rpx 18rpx;
background: #f8f9fb;
border-radius: 12rpx;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.log-meta-line {
display: flex;
align-items: center;
font-size: 23rpx;
line-height: 1.45;
color: #4e5969;
}
.meta-label {
flex-shrink: 0;
color: #86909c;
}
.meta-val {
flex: 1;
min-width: 0;
color: #4e5969;
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
word-break: break-all;
}
.log-row-foot {
margin-top: 16rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.log-time {
font-size: 22rpx;
color: #999999;
line-height: 1.2;
}
.empty-box {
padding-top: 120rpx;
}
</style>

View File

@@ -45,6 +45,11 @@ import { getUserWallet } from '@/api/members'
import { isLogin, navigateToLogin, unitPrice } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
import {
prefetchMpMessageTemplates,
subscribeMpMessageByScenes,
} from '@/js_sdk/lili-pay/wx-pay.js'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
@@ -52,6 +57,9 @@ const walletNum = ref(0)
onShow(async () => {
if (isLogin('auth')) {
// #ifdef MP-WEIXIN
prefetchMpMessageTemplates()
// #endif
const result = await getUserWallet()
walletNum.value = result.data.result.memberWallet
} else {
@@ -60,7 +68,15 @@ onShow(async () => {
})
function back() {
uni.switchTab({ url: '/pages/tabbar/user/my' })
const doBack = () => {
uni.switchTab({ url: '/pages/tabbar/user/my' })
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['WALLET_CHANGE'], doBack)
// #endif
// #ifndef MP-WEIXIN
doBack()
// #endif
}
function navigateTo(url: string) {

View File

@@ -1,41 +1,114 @@
<template>
<view :style="themeStyle" class="wap">
<view :style="themeStyle" class="withdraw-log-page">
<u-navbar
title="提现记录"
:fixed="true"
:placeholder="true"
:border="false"
:auto-back="true"
:auto-back="false"
@leftClick="back"
></u-navbar>
<scroll-view class="scroll-v view-wrapper" enableBackToTop="true" scroll-with-animation scroll-y @scrolltolower="loadMore">
<view v-if="records.length != 0" class="view-item" v-for="(item, index) in records" :key="index">
<view class="view-item-detail">
<view class="-title">{{ withdrawStatusText(item.applyStatus) }}</view>
<view class="-number" v-if="item.inspectRemark || item.errorMessage">{{ item.inspectRemark || item.errorMessage }}</view>
</view>
<view class="view-item-change">
<view class="-money">-{{unitPrice(item.applyMoney) }}</view>
<view class="-time">{{ item.createTime || item.inspectTime || "" }}</view>
<view v-if="item.applyStatus === 'WAIT_USER_CONFIRM'" class="confirm-btn" @click.stop="confirmWechatReceive(item)">确认收款</view>
<!-- 状态筛选胶囊栏 -->
<view class="filter-bar">
<view
v-for="(tab, idx) in filterTabs"
:key="tab.key"
class="filter-pill"
:class="{ active: activeFilter === idx }"
@click="activeFilter = idx"
>
{{ tab.name }}
</view>
</view>
<!-- 提现记录列表 -->
<view class="list-container">
<view v-if="filteredRecords.length > 0" class="list-card">
<view
class="record-card"
v-for="(item, index) in filteredRecords"
:key="item.id || index"
>
<!-- 第一行:状态标签 + 标题 | 提现金额 -->
<view class="card-row-main">
<view class="title-wrap">
<text class="status-tag" :class="item.parsed.statusClass">
{{ item.parsed.statusText }}
</text>
<text class="card-title">余额提现</text>
</view>
<view class="amount-wrap">
<text class="amount-symbol">¥</text>
<text class="amount-val">{{ unitPrice(item.applyMoney) }}</text>
</view>
</view>
<!-- 第二行:单号、审核备注或失败原因 -->
<view
v-if="item.sn || item.inspectRemark || item.errorMessage || item.inspectTime"
class="meta-box"
>
<view v-if="item.sn" class="meta-line">
<text class="meta-label">提现单号:</text>
<text class="meta-val mono">{{ item.sn }}</text>
</view>
<view v-if="item.inspectTime" class="meta-line">
<text class="meta-label">审核时间:</text>
<text class="meta-val">{{ item.inspectTime }}</text>
</view>
<view v-if="item.inspectRemark || item.errorMessage" class="meta-line">
<text class="meta-label">备注说明:</text>
<text class="meta-val remark-text">{{ item.inspectRemark || item.errorMessage }}</text>
</view>
</view>
<!-- 第三行:申请时间 + 确认收款按钮 -->
<view class="card-row-foot">
<text class="apply-time">申请时间:{{ item.createTime || item.inspectTime || '-' }}</text>
<view
v-if="item.applyStatus === 'WAIT_USER_CONFIRM'"
class="confirm-btn"
@click.stop="confirmWechatReceive(item)"
>
确认收款
</view>
</view>
</view>
</view>
<u-empty v-if="loaded && records.length == 0" mode="history" text="暂无记录" />
</scroll-view>
<view v-else-if="loaded" class="empty-box">
<u-empty mode="history" text="暂无提现记录" />
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { onShow, onReachBottom } from '@dcloudio/uni-app'
import { getWithdrawApplyPage, getWithdrawApplyWechatTransferInfo } from '@/api/members'
import { unitPrice } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
import {
prefetchMpMessageTemplates,
subscribeMpMessageByScenes,
} from '@/js_sdk/lili-pay/wx-pay.js'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const loaded = ref(false)
const hasMore = ref(true)
const activeFilter = ref(0)
const filterTabs = [
{ key: 'ALL', name: '全部' },
{ key: 'PENDING', name: '处理中' },
{ key: 'SUCCESS', name: '已到账' },
{ key: 'FAIL', name: '未通过/失败' },
]
const params = ref({
pageNumber: 1,
pageSize: 10,
@@ -44,40 +117,88 @@ const params = ref({
const records = ref<any[]>([])
onShow(() => {
// #ifdef MP-WEIXIN
// 预拉取订阅模板,保证点击左上角返回时可同步拉起微信订阅弹窗
prefetchMpMessageTemplates()
// #endif
reloadData()
})
// 左上角返回:提示订阅「提现结果通知」后再返回
function back() {
const doBack = () => {
if (getCurrentPages().length > 1) {
uni.navigateBack({ delta: 1 })
} else {
uni.redirectTo({ url: '/pages/mine/deposit/operation' })
}
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['WALLET_WITHDRAWAL_AUDIT_ERROR'], doBack)
// #endif
// #ifndef MP-WEIXIN
doBack()
// #endif
}
onReachBottom(() => {
if (!hasMore.value) return
loadMore()
})
function reloadData() {
params.value.pageNumber = 1
hasMore.value = true
records.value = []
loaded.value = false
getData()
})
}
function withdrawStatusText(applyStatus: string) {
function parseWithdrawStatus(applyStatus: string) {
switch (applyStatus) {
case 'APPLY':
return '申请中'
return { statusText: '申请中', statusClass: 'tag-pending', group: 'PENDING' }
case 'VIA_AUDITING':
return '审核通过'
return { statusText: '审核通过', statusClass: 'tag-pending', group: 'PENDING' }
case 'D_VIA_AUDITING':
return '分销提现审核通过'
case 'FAIL_AUDITING':
return '审核未通过'
case 'D_FAIL_AUDITING':
return '分销提现审核未通过'
return { statusText: '分销审核通过', statusClass: 'tag-pending', group: 'PENDING' }
case 'WAIT_USER_CONFIRM':
return '等待用户确认'
return { statusText: '待确认收款', statusClass: 'tag-action', group: 'PENDING' }
case 'SUCCESS':
return '提现成功'
return { statusText: '提现成功', statusClass: 'tag-success', group: 'SUCCESS' }
case 'FAIL_AUDITING':
return { statusText: '审核未通过', statusClass: 'tag-fail', group: 'FAIL' }
case 'D_FAIL_AUDITING':
return { statusText: '分销审核未通过', statusClass: 'tag-fail', group: 'FAIL' }
case 'ERROR':
return '提现失败'
return { statusText: '提现失败', statusClass: 'tag-fail', group: 'FAIL' }
default:
return applyStatus || ''
return { statusText: applyStatus || '处理中', statusClass: 'tag-pending', group: 'PENDING' }
}
}
const decoratedRecords = computed(() =>
records.value.map((item) => ({
...item,
parsed: parseWithdrawStatus(item.applyStatus),
}))
)
const filteredRecords = computed(() => {
const targetKey = filterTabs[activeFilter.value]?.key || 'ALL'
if (targetKey === 'ALL') return decoratedRecords.value
return decoratedRecords.value.filter((item) => item.parsed.group === targetKey)
})
function getData() {
getWithdrawApplyPage(params.value).then((res) => {
loaded.value = true
if (res.data.success && res.data.result.records.length != 0) {
records.value.push(...res.data.result.records)
const list = (res.data?.success && res.data?.result?.records) || []
if (list.length > 0) {
records.value.push(...list)
}
if (list.length < params.value.pageSize) {
hasMore.value = false
}
})
}
@@ -119,7 +240,8 @@ function confirmWechatReceive(item: any) {
const openResultToast = (errMsg?: string) => {
if (errMsg === 'requestMerchantTransfer:ok') {
uni.showToast({ title: '已唤起确认页面', duration: 2000, icon: 'none' })
uni.showToast({ title: '已确认收款', duration: 2000, icon: 'none' })
setTimeout(() => reloadData(), 800)
return
}
if (errMsg === 'requestMerchantTransfer:cancel') {
@@ -175,55 +297,191 @@ function confirmWechatReceive(item: any) {
</script>
<style lang="scss" scoped>
.view-item {
padding: 32rpx;
.withdraw-log-page {
min-height: 100vh;
background: #f5f6fa;
padding-bottom: 48rpx;
box-sizing: border-box;
}
.filter-bar {
display: flex;
justify-content: space-between;
align-items: center;
gap: 16rpx;
padding: 24rpx 24rpx 8rpx;
overflow-x: auto;
}
.view-item-change {
text-align: right;
> .-money {
font-size: 36rpx;
color: $main-color;
font-weight: bold;
}
> .-time {
font-size: 22rpx;
color: #999;
}
> .confirm-btn {
display: inline-block;
margin-top: 12rpx;
padding: 12rpx 20rpx;
font-size: 24rpx;
border-radius: 8rpx;
.filter-pill {
flex-shrink: 0;
padding: 12rpx 28rpx;
border-radius: 999rpx;
font-size: 25rpx;
color: #666666;
background: #ffffff;
font-weight: 500;
transition: all 0.2s;
&.active {
background: $main-color;
color: #fff;
color: #ffffff;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(229, 50, 56, 0.2);
}
}
.view-item-detail {
line-height: 1.75;
.list-container {
padding: 16rpx 24rpx 0;
}
.list-card {
display: flex;
flex-direction: column;
gap: 18rpx;
}
.record-card {
background: #ffffff;
border-radius: 20rpx;
padding: 28rpx 30rpx;
box-shadow: 0 2rpx 12rpx rgba(17, 30, 79, 0.03);
}
.card-row-main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.title-wrap {
display: flex;
align-items: center;
gap: 12rpx;
min-width: 0;
flex: 1;
overflow: hidden;
> .-title {
font-size: 28rpx;
}
.status-tag {
flex-shrink: 0;
font-size: 21rpx;
font-weight: 600;
padding: 4rpx 14rpx;
border-radius: 8rpx;
line-height: 1.35;
&.tag-pending {
color: #ff7d00;
background: rgba(255, 125, 0, 0.1);
}
> .-number {
font-size: 22rpx;
color: #999;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
&.tag-action {
color: $main-color;
background: rgba(229, 50, 56, 0.1);
}
&.tag-success {
color: #00a870;
background: rgba(0, 168, 112, 0.1);
}
&.tag-fail {
color: #f53f3f;
background: rgba(245, 63, 63, 0.1);
}
}
.wap {
width: 100%;
height: calc(100vh - 44px);
.card-title {
font-size: 30rpx;
font-weight: 600;
color: #1d2129;
line-height: 1.35;
}
.scroll-v {
height: calc(100vh - 88rpx);
.amount-wrap {
flex-shrink: 0;
display: flex;
align-items: baseline;
color: #1d2129;
}
.amount-symbol {
font-size: 24rpx;
font-weight: 600;
margin-right: 4rpx;
}
.amount-val {
font-size: 36rpx;
font-weight: 700;
line-height: 1.2;
font-variant-numeric: tabular-nums;
}
.meta-box {
margin-top: 16rpx;
padding: 14rpx 18rpx;
background: #f8f9fb;
border-radius: 12rpx;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.meta-line {
display: flex;
align-items: flex-start;
font-size: 23rpx;
line-height: 1.45;
color: #4e5969;
}
.meta-label {
flex-shrink: 0;
color: #86909c;
}
.meta-val {
flex: 1;
min-width: 0;
color: #4e5969;
word-break: break-all;
&.mono {
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
&.remark-text {
color: #f53f3f;
}
}
.card-row-foot {
margin-top: 18rpx;
display: flex;
align-items: center;
justify-content: space-between;
gap: 16rpx;
}
.apply-time {
font-size: 22rpx;
color: #999999;
line-height: 1.2;
}
.confirm-btn {
flex-shrink: 0;
padding: 10rpx 28rpx;
font-size: 24rpx;
font-weight: 600;
border-radius: 999rpx;
background: linear-gradient(135deg, $main-color 0%, $light-color 100%);
color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(229, 50, 56, 0.22);
}
.empty-box {
padding-top: 140rpx;
}
</style>

View File

@@ -118,12 +118,23 @@ onMounted(async () => {
withdrawRule.value = res.data.result.withdrawRule || ''
})
let submitting = false
function cashd() {
if (submitting) return
const amount = Number(price.value)
if (!proxy.$u.test.amount(parseInt(String(amount)))) {
if (!(amount > 0) || !proxy.$u.test.amount(parseInt(String(amount)))) {
uni.showToast({ title: '请输入正确金额', duration: 2000, icon: 'none' })
return
}
if (minPrice.value && amount < Number(minPrice.value)) {
uni.showToast({ title: `最低提现金额为 ${minPrice.value} 元`, duration: 2000, icon: 'none' })
return
}
if (amount > Number(walletNum.value || 0)) {
uni.showToast({ title: '提现金额不能大于可提现金额', duration: 2000, icon: 'none' })
return
}
const params: Record<string, any> = { price: amount }
if (type.value === 'ALI') {
@@ -139,14 +150,23 @@ function cashd() {
params.realName = realName.value
}
withdrawalApply(params).then((res) => {
if (res.data.success) {
uni.showToast({ title: '提现成功!', duration: 2000, icon: 'none' })
setTimeout(() => {
uni.navigateBack({ delta: 1 })
}, 1000)
}
})
const doSubmit = () => {
submitting = true
withdrawalApply(params)
.then((res) => {
if (res.data.success) {
uni.showToast({ title: '提现申请已提交', duration: 2000, icon: 'none' })
setTimeout(() => {
uni.navigateBack({ delta: 1 })
}, 1000)
}
})
.finally(() => {
submitting = false
})
}
doSubmit()
}
function handleAll() {

View File

@@ -1,5 +1,13 @@
<template>
<view :style="themeStyle" class="content">
<u-navbar
title="我的积分"
:fixed="true"
:placeholder="true"
:border="false"
:auto-back="false"
@leftClick="handleBack"
></u-navbar>
<view class="portrait-box">
<image src="/pages/mine/static/point_bg_1.png" mode=""></image>
<image class="point-img" src="/pages/mine/static/tradehall.png" />
@@ -41,6 +49,10 @@ import { onLoad, onReachBottom } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import { getPointsData, getMemberPointSum } from '@/api/members.js'
import { getThemeStyle } from '@/utils/theme'
import {
prefetchMpMessageTemplates,
subscribeMpMessageByScenes,
} from '@/js_sdk/lili-pay/wx-pay.js'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
@@ -51,10 +63,29 @@ const params = ref({ pageNumber: 1, pageSize: 10 })
const pointSummary = ref<Record<string, any>>({})
onLoad(() => {
// #ifdef MP-WEIXIN
prefetchMpMessageTemplates()
// #endif
fetchPointSummary()
fetchPointLogList()
})
function handleBack() {
const doBack = () => {
uni.navigateBack({
fail: () => {
uni.switchTab({ url: '/pages/tabbar/user/my' })
},
})
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['POINT_CHANGE'], doBack)
// #endif
// #ifndef MP-WEIXIN
doBack()
// #endif
}
onReachBottom(() => {
params.value.pageNumber++
fetchPointLogList()

View File

@@ -0,0 +1,320 @@
<template>
<view :style="themeStyle" class="notice-page">
<u-navbar title="消息通知" :auto-back="true" :placeholder="true" :border="false"></u-navbar>
<view class="content">
<view class="tip-card">
<u-icon name="volume" color="#ff7a00" size="18"></u-icon>
<text class="tip-text">开启通知后,可第一时间接收订单发货、售后审核及资金变动提醒。</text>
</view>
<!-- 微信公众号通知设置 -->
<view v-if="oaSetting.enabled" class="card">
<view class="card-head">
<view class="card-title-wrap">
<view class="icon-badge oa-badge">
<u-icon name="weixin-fill" color="#fff" size="20"></u-icon>
</view>
<view class="title-box">
<view class="title-row">
<text class="card-title">{{ oaSetting.accountName || '微信公众号通知' }}</text>
<text class="status-tag" :class="oaSetting.bound ? 'status-open' : 'status-close'">
{{ oaSetting.bound ? '已开启' : '未开启' }}
</text>
</view>
<text class="card-desc">关注官方公众号,长期接收服务与订单通知</text>
</view>
</view>
</view>
<view class="card-body">
<view class="notice-points">
<view class="point-item">
<text class="dot">•</text>
<text class="point-text">订单发货、完成及拼团进度实时推送</text>
</view>
<view class="point-item">
<text class="dot">•</text>
<text class="point-text">售后申请审核结果、商家退款提醒</text>
</view>
<view class="point-item">
<text class="dot">•</text>
<text class="point-text">余额变动、提现审核与到账结果通知</text>
</view>
</view>
</view>
<view class="card-foot">
<view
class="action-btn"
:class="oaSetting.bound ? 'btn-bound' : 'btn-primary'"
@click="handleOaAction"
>
{{ oaSetting.bound ? '查看公众号文章' : '关注公众号开启通知' }}
</view>
</view>
</view>
<!-- 微信小程序订阅消息说明 -->
<view class="card">
<view class="card-head">
<view class="card-title-wrap">
<view class="icon-badge mp-badge">
<u-icon name="chat-fill" color="#fff" size="20"></u-icon>
</view>
<view class="title-box">
<view class="title-row">
<text class="card-title">小程序订阅消息</text>
<text class="status-tag status-open">已支持</text>
</view>
<text class="card-desc">在支付成功、售后提交、积分与提现等页面主动提示</text>
</view>
</view>
</view>
<view class="card-body">
<text class="mp-intro">
小程序订阅消息支持:订单发货提醒、订单已完成提醒、拼团成功通知、售后申请审核通知、积分变更提醒、账户余额变动通知、提现结果通知。您在相关操作时点击授权即可生效。
</text>
</view>
</view>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { getWechatOfficialAccountSetting } from '@/api/message.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const oaSetting = ref({
enabled: false,
accountName: '',
articleUrl: '',
bound: false,
})
onShow(() => {
fetchSetting()
})
function fetchSetting() {
getWechatOfficialAccountSetting()
.then((res: any) => {
if (res && res.data && res.data.success && res.data.result) {
oaSetting.value = res.data.result
}
})
.catch(() => {})
}
function handleOaAction() {
const url = (oaSetting.value.articleUrl || '').trim()
if (!url) {
uni.showToast({ title: '暂未配置公众号文章', icon: 'none' })
return
}
// #ifdef MP-WEIXIN
if (wx.openOfficialAccountArticle) {
wx.openOfficialAccountArticle({
url,
fail: () => {
fallbackOpen(url)
},
})
return
}
// #endif
fallbackOpen(url)
}
function fallbackOpen(url: string) {
uni.setClipboardData({
data: url,
success: () => {
uni.showModal({
title: '提示',
content: '公众号引导文章链接已复制到剪贴板,请在微信中粘贴发送并打开关注公众号',
showCancel: false,
})
},
})
}
</script>
<style lang="scss" scoped>
.notice-page {
min-height: 100vh;
background: #f7f8fa;
padding-bottom: 40rpx;
}
.content {
padding: 24rpx;
}
.tip-card {
display: flex;
align-items: center;
background: #fff7eb;
border-radius: 12rpx;
padding: 20rpx 24rpx;
margin-bottom: 24rpx;
}
.tip-text {
flex: 1;
font-size: 24rpx;
color: #ff7a00;
line-height: 1.5;
margin-left: 12rpx;
}
.card {
background: #fff;
border-radius: 20rpx;
padding: 32rpx;
margin-bottom: 24rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.03);
}
.card-head {
display: flex;
align-items: center;
justify-content: space-between;
padding-bottom: 24rpx;
border-bottom: 1px solid #f2f3f5;
}
.card-title-wrap {
display: flex;
align-items: center;
flex: 1;
}
.icon-badge {
width: 72rpx;
height: 72rpx;
border-radius: 18rpx;
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
margin-right: 20rpx;
}
.oa-badge {
background: linear-gradient(135deg, #07c160, #0ab155);
}
.mp-badge {
background: linear-gradient(135deg, #2b85e4, #007aff);
}
.title-box {
flex: 1;
min-width: 0;
}
.title-row {
display: flex;
align-items: center;
}
.card-title {
font-size: 30rpx;
font-weight: 600;
color: #1d2129;
}
.status-tag {
font-size: 20rpx;
padding: 4rpx 14rpx;
border-radius: 20rpx;
margin-left: 14rpx;
font-weight: 500;
}
.status-open {
background: #e8f8f0;
color: #07c160;
}
.status-close {
background: #f2f3f5;
color: #86909c;
}
.card-desc {
display: block;
font-size: 24rpx;
color: #86909c;
margin-top: 6rpx;
}
.card-body {
padding: 24rpx 0 12rpx;
}
.notice-points {
display: flex;
flex-direction: column;
gap: 12rpx;
}
.point-item {
display: flex;
align-items: flex-start;
font-size: 26rpx;
color: #4e5969;
line-height: 1.6;
}
.dot {
color: #07c160;
font-size: 32rpx;
line-height: 1;
margin-right: 12rpx;
}
.point-text {
flex: 1;
}
.card-foot {
margin-top: 24rpx;
}
.action-btn {
height: 80rpx;
line-height: 80rpx;
text-align: center;
border-radius: 40rpx;
font-size: 28rpx;
font-weight: 500;
}
.btn-primary {
background: linear-gradient(135deg, #07c160, #05a04e);
color: #fff;
box-shadow: 0 6rpx 18rpx rgba(7, 193, 96, 0.25);
}
.btn-bound {
background: #f2f3f5;
color: #4e5969;
}
.mp-intro {
font-size: 26rpx;
color: #4e5969;
line-height: 1.8;
}
</style>

View File

@@ -26,6 +26,11 @@
></u-cell>
<!-- #endif -->
<u-cell is-link title="用户注销" v-if="userInfo.id" @click="logoff"></u-cell>
<u-cell
is-link
title="消息通知"
@click="navigateTo('/pages/mine/set/messageNotice')"
></u-cell>
<u-cell is-link title="意见反馈" @click="navigateTo('/pages/mine/set/feedBack')"></u-cell>
<u-cell
is-link
@@ -42,10 +47,10 @@
import { ref, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import config from '@/config/config'
import { isLogin, tipsToLogin, quiteLoginOut, logoff } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
import { isLogin, tipsToLogin, quiteLoginOut, logoff } from '@/utils/filters.js'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const userImage = config.defaultUserPhoto

View File

@@ -1,585 +0,0 @@
<template>
<view :style="themeStyle" class="content">
<view class="u-tabs-box">
<u-tabs
:list="list"
:scrollable="false"
v-model:current="current"
@change="change"
:lineColor="lightColor"
:activeStyle="{ color: lightColor }"
></u-tabs>
</view>
<div class="u-tabs-search">
<u-search
placeholder="请输入订单编号/商品名称/售后单号"
@search="submitSearchOrderList(current)"
@clear="clear(current)"
@custom="submitSearchOrderList(current)"
v-model="keywords"
>
</u-search>
</div>
<scroll-view class="body-view" scroll-y @scrolltolower="renderDate">
<view
class="seller-view"
v-for="(order, orderIndex) in orderList"
:key="orderIndex"
>
<!-- 店铺名称 -->
<view class="seller-info" v-if="current == 0">
<view class="seller-name wes">{{ order.storeName }}</view>
<view class="order-sn wes">订单编号:{{ order.sn }}</view>
</view>
<!-- 申请记录 选项卡 -->
<view class="seller-info" v-if="current != 0">
<view class="order-sn wes">售后单号:{{ order.service_sn || order.sn }}</view>
<view class="order-sn service-type">{{ order.serviceType_text }}</view>
</view>
<view v-for="(sku, goodsIndex) in order.orderItems" :key="goodsIndex">
<view class="goods-item-view" @click="onDetail(order, sku)">
<view class="goods-img">
<u-image
border-radius="6"
width="131rpx"
height="131rpx"
mode="aspectFill"
:src="getGoodsImage(sku, order, goodsIndex)"
></u-image>
</view>
<view class="goods-info">
<view class="goods-title">{{ getGoodsName(sku) }}</view>
<!-- 如果商品多个则不显示每个商品价格-->
<view class="goods-price" v-if="order.orderItems.length <= 1">
¥{{ unitPrice(order.flowPrice) }}
</view>
</view>
<view class="goods-num">
<view>x{{ sku.num }}</view>
</view>
</view>
<view class="description">
<!-- 售后申请 -->
<view v-if="current === 0 && sku.afterSaleStatus">
<view
v-if="sku.afterSaleStatus.includes('ALREADY_APPLIED')"
class="cannot_apply not_center"
>
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品已申请售后服务
</view>
</view>
<view v-if="current === 0 && sku.afterSaleStatus">
<view
v-if="sku.afterSaleStatus.includes('EXPIRED')"
class="cannot_apply not_center"
@click="tipsShow = true"
>
<u-icon class="icon" name="info-circle-fill"></u-icon>
该商品无法申请售后
</view>
</view>
<div v-if="current === 1 || current === 2">
<!-- 申请中 -->
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'RETURN_GOODS'"
>
退货处理-{{serviceStatusList(order.serviceStatus) }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'SUPPLY_AGAIN_GOODS'"
>
补发商品-{{serviceStatusList(order.serviceStatus) }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'RETURN_MONEY'"
>
退款-{{serviceStatusList(order.serviceStatus) }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'EXCHANGE_GOODS'"
>
换货-{{serviceStatusList(order.serviceStatus) }}</view
>
<view
class="cannot_apply not_center"
v-if="order.serviceType == 'CANCEL'"
>
取消订单-{{serviceStatusList(order.serviceStatus) }}</view
>
</div>
<!-- 申请记录 -->
</view>
<view class="btn-view">
<!-- 售后申请 -->
<div class="sale" v-if="current === 0 && sku.afterSaleStatus && !isECouponOrder(order.orderType)">
<div
v-if="
order.flowPrice != 0 &&
sku.afterSaleStatus.includes('NOT_APPLIED') ||
sku.afterSaleStatus.includes('PART_AFTER_SALE')
"
@click="applyService(sku.sn, order, sku)"
>
<view class="default-btn border"> 申请售后 </view>
</div>
</div>
<view class="after-line">
<!-- 申请中 -->
<view
class="default-btn border"
v-if="
current === 2 &&
order.serviceStatus &&
order.serviceStatus == 'PASS' &&
order.serviceType != 'RETURN_MONEY'
"
@click="onExpress(order, sku)"
>
提交物流
</view>
<view
@click="close(order, sku)"
v-if="current === 1"
class="default-btn close"
>
取消售后
</view>
<view
@click="afterDetails(order, sku)"
v-if="current === 1 || current === 2"
class="default-btn border"
>
售后详情
</view>
</view>
</view>
</view>
<view
v-if="
current === 0 &&
order.groupAfterSaleStatus &&
order.groupAfterSaleStatus != 'ALREADY_APPLIED' &&
order.orderItems.length >= 1
"
class="btn-view order-total"
>
<!-- 多个商品显示订单总价格 -->
<view class="cannot_apply">
订单总金额:<span class="countMoney"
>¥{{unitPrice(order.flowPrice) }}</span
>
</view>
</view>
</view>
<u-loadmore bg-color="#f8f8f8" :status="status" />
</scroll-view>
<u-modal
show-cancel-button
@confirm="closeService"
v-model:show="cancelShow"
content="确认取消售后"
></u-modal>
<u-modal
v-model:show="tipsShow"
content="当订单未确认收货|已过售后服务有效期|已申请售后服务时,不能申请售后"
></u-modal>
</view>
</template>
<script setup lang="ts">
import { ref, reactive, computed } from 'vue'
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import { unitPrice, serviceStatusList, parseGoodsImageUrl } from '@/utils/filters.js'
// E_COUPON 订单列表不展示「申请售后」入口(FR-B-04)
import { isECouponOrder } from '@/utils/goodsType.js'
import { getAfterSaleList, cancelAfterSale } from '@/api/after-sale.js'
import { getOrderList } from '@/api/order.js'
import storage from '@/utils/storage'
import { getThemeStyle } from '@/utils/theme'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
const lightColor = computed(() => store.getters.lightColor)
const list = [
{ name: '售后申请' },
{ name: '申请中' },
{ name: '申请记录' },
]
const current = ref(0)
const tipsShow = ref(false)
const cancelShow = ref(false)
const selectedOrder = ref<any>(null)
const orderList = ref<any[]>([])
const params = reactive<Record<string, any>>({
pageNumber: 1,
pageSize: 10,
sort: 'createTime',
flowPrice: 0,
order: 'desc',
})
const logParams = reactive<Record<string, any>>({
pageNumber: 1,
pageSize: 10,
})
const status = ref('loadmore')
const keywords = ref('')
onLoad((options) => {
orderList.value = []
params.pageNumber = 1
if (options?.orderSn) params.keywords = options.orderSn
searchOrderList(current.value)
})
onPullDownRefresh(() => {
change(current.value)
})
function hideLoadingIfNeeded() {
if (store.state.isShowToast) uni.hideLoading()
}
function getGoodsName(sku: any) {
return sku.goodsName || sku.name || ''
}
function getGoodsImage(goods: any, order: any, index: number) {
let image = goods.image || goods.goodsImage || goods.thumbnail
if (!image && order.groupImages) {
const images = String(order.groupImages).split(',')
image = images[index] || images[0]
}
return parseGoodsImageUrl(image)
}
function submitSearchOrderList(tabIndex: number) {
params.pageNumber = 1
logParams.pageNumber = 1
orderList.value = []
searchOrderList(tabIndex)
}
function clear(tabIndex: number) {
params.pageNumber = 1
logParams.pageNumber = 1
params.keywords = ''
orderList.value = []
searchOrderList(tabIndex)
}
function change(e: number | { index: number }) {
const index = typeof e === 'object' && e != null ? e.index : e
current.value = index
Object.assign(params, { pageNumber: 1, pageSize: 10 })
orderList.value = []
searchOrderList(index)
uni.stopPullDownRefresh()
}
function searchOrderList(index: number) {
if (index == 0) {
if (keywords.value) params.keywords = keywords.value
fetchOrderList()
} else {
Object.assign(logParams, {
pageNumber: 1,
pageSize: 10,
sort: 'createTime',
order: 'desc',
})
if (index === 1) {
logParams.serviceStatus = 'APPLY'
}
if (keywords.value) logParams.keywords = keywords.value
orderList.value = []
fetchAfterSaleLogList()
}
}
function fetchOrderList() {
uni.showLoading({ title: '加载中', mask: true })
getOrderList(params).then((res) => {
hideLoadingIfNeeded()
const records = res.data.result.records
if (records.length > 0) {
orderList.value = orderList.value.concat(records)
params.pageNumber += 1
}
status.value = records.length < 10 ? 'nomore' : 'loading'
})
}
function close(order: any, _sku: any) {
selectedOrder.value = order
cancelShow.value = true
}
async function closeService() {
uni.showLoading({ title: '加载中' })
const res = await cancelAfterSale(selectedOrder.value.sn)
if (res.data.success) {
uni.showToast({ title: '取消成功!', duration: 2000, icon: 'none' })
}
orderList.value = []
searchOrderList(current.value)
hideLoadingIfNeeded()
}
function afterDetails(order: any, _sku?: any) {
uni.navigateTo({ url: './applyDetail?sn=' + order.sn })
}
function fetchAfterSaleLogList() {
getAfterSaleList(logParams).then((res) => {
const afterSaleLogList = res.data.result.records
afterSaleLogList.forEach((item: any) => {
item.orderItems = [
{
image: item.goodsImage,
skuId: item.skuId,
name: item.goodsName,
num: item.num,
price: item.flowPrice,
},
]
})
orderList.value = orderList.value.concat(afterSaleLogList)
status.value = afterSaleLogList.length < 10 ? 'nomore' : 'loading'
})
}
function applyService(sn: string, order: any, sku: any) {
storage.setAfterSaleData({ ...order, ...sku })
uni.navigateTo({ url: `/pages/order/afterSales/afterSalesSelect?sn=${sn}` })
}
function onExpress(order: any, sku: any) {
sku.storeName = order.storeName
storage.setAfterSaleData({ ...order, ...sku })
uni.navigateTo({ url: `./afterSalesDetailExpress?serviceSn=${order.sn}` })
}
function onDetail(goods: any, sku: any) {
if (current.value == 0) {
uni.navigateTo({
url: `/pages/product/goods?id=${sku.skuId}&goodsId=${sku.goodsId || sku.goodsId}`,
})
} else {
uni.navigateTo({
url: `/pages/product/goods?id=${goods.skuId}&goodsId=${goods.goodsId || goods.goodsId}`,
})
}
}
function renderDate() {
if (current.value === 0) {
params.pageNumber += 1
fetchOrderList()
} else {
logParams.pageNumber += 1
fetchAfterSaleLogList()
}
}
</script>
<style lang="scss">
page,
.content {
background: $page-color-base;
height: 100%;
}
.body-view {
overflow-y: auto;
height: calc(100vh - 44px - 80rpx - 104rpx);
padding: 0 20rpx;
box-sizing: border-box;
}
.u-tabs-search {
padding: 20rpx;
background: #fff;
}
.countMoney {
margin-left: 7rpx;
color: $main-color;
font-size: 28rpx;
}
.seller-view {
background-color: #fff;
margin: 20rpx 0;
padding: 0 20rpx 24rpx;
border-radius: 20rpx;
.seller-info {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
min-height: 70rpx;
padding: 20rpx 0 16rpx;
gap: 20rpx;
.seller-name {
flex-shrink: 0;
max-width: 40%;
font-size: 28rpx;
font-weight: 600;
color: #333;
}
.order-sn {
flex: 1;
min-width: 0;
font-size: 22rpx;
color: #909399;
text-align: right;
}
.service-type {
flex-shrink: 0;
text-align: right;
}
}
.goods-item-view {
display: flex;
flex-direction: row;
align-items: flex-start;
padding: 16rpx 0;
.goods-img {
flex-shrink: 0;
width: 131rpx;
height: 131rpx;
border-radius: 6rpx;
overflow: hidden;
}
.goods-info {
flex: 1;
min-width: 0;
padding: 0 20rpx;
.goods-title {
margin-bottom: 10rpx;
color: #333333;
font-size: 26rpx;
line-height: 1.4;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
overflow: hidden;
word-break: break-all;
}
.goods-specs {
font-size: 24rpx;
margin-bottom: 10rpx;
color: #cccccc;
}
.goods-price {
font-size: 28rpx;
color: #ff5a10;
}
}
.goods-num {
flex-shrink: 0;
min-width: 60rpx;
text-align: right;
color: $main-color;
font-size: 26rpx;
line-height: 1.4;
}
}
.btn-view {
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
padding: 16rpx 0 0;
.after-line {
display: flex;
flex-direction: row;
align-items: center;
gap: 15rpx;
}
}
.order-total {
justify-content: flex-start;
padding-top: 8rpx;
padding-bottom: 4rpx;
.cannot_apply {
text-align: left;
height: auto;
line-height: 1.5;
}
}
}
.description {
color: #909399;
size: 25rpx;
}
.cannot_apply {
text-align: center;
font-size: 22rpx;
color: #999999;
height: 70rpx;
line-height: 70rpx;
}
.not_center {
text-align: left;
}
.icon {
margin-right: 10rpx;
}
.sale {
width: 100%;
display: flex;
justify-content: flex-end;
}
.default-btn {
background-color: #ffffff;
margin-left: 15rpx;
height: 60rpx;
line-height: 60rpx;
text-align: center;
font-size: 24rpx;
padding: 0 24rpx;
border-radius: 200px;
}
.close {
color: $light-color;
}
.border {
border: 2rpx solid $light-color;
color: $light-color;
}
</style>

View File

@@ -158,7 +158,7 @@ function onSubmit() {
title: '提交成功',
type: 'success',
back: true,
url: '/pages/order/afterSales/afterSales',
url: '/pages/order/myOrder?status=5',
})
}
})

View File

@@ -1,80 +1,275 @@
<template>
<view :style="themeStyle">
<view class="header">
<u-icon name='checkmark' size="150" color="#ff6b35"></u-icon>
<view class="success-text">售后申请提交成功</view>
<view class="btn-view">
<view class="btn-item">
<u-button ripple class="btn1" shape="circle" @click="navigateToAfterSales()">查看记录</u-button>
<view :style="themeStyle" class="apply-success-page">
<u-navbar
title="提交成功"
:border="false"
:fixed="true"
:placeholder="true"
:auto-back="false"
@leftClick="handleBack"
></u-navbar>
<view class="page-body">
<!-- 核心状态卡片 -->
<view class="result-card">
<view class="icon-halo">
<view class="icon-circle">
<u-icon name="checkmark" size="52rpx" color="#ffffff"></u-icon>
</view>
</view>
<view class="btn-item">
<u-button ripple class="btn2" shape="circle" @click="navigateToHome()">回到主页</u-button>
<view class="success-title">售后申请提交成功</view>
<view class="success-sub">商家将尽快为您审核处理,请留意消息通知</view>
<view class="btn-group">
<view class="action-btn btn-outline" @click="navigateToHome()">
回到主页
</view>
<view class="action-btn btn-primary" @click="navigateToAfterSales()">
查看记录
</view>
</view>
</view>
<!-- 温馨提示卡片 -->
<view class="tips-card">
<view class="tips-header">
<view class="tips-bar"></view>
<text class="tips-title">温馨提示</text>
</view>
<view class="tips-list">
<view class="tip-item">
<view class="tip-dot"></view>
<text class="tip-text">商品寄回地址将在商家审核通过后,在「我的订单 - 售后」详情中展示。</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text class="tip-text">提交服务单后,售后专员可能与您电话沟通,请保持手机畅通。</text>
</view>
<view class="tip-item">
<view class="tip-dot"></view>
<text class="tip-text">售后处理完成后,退款金额将原路退回至您的原支付账户中。</text>
</view>
</view>
</view>
</view>
<view class="text-view">
<view style="display: flex; margin-bottom: 20rpx; align-items: center">温馨提示:</view>
<view>• 商品寄回地址将在审核通过后在申请记录中查询。</view>
<view>• 提交服务单后,售后专员可能与您电话沟通,请保持手机畅通。</view>
<view>• 退货处理成功后退款金额将原路返回到您的支持账户中;</view>
</view>
</view>
</template>
<script setup lang="ts">import { computed } from 'vue'
<script setup lang="ts">
import { computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
import {
prefetchMpMessageTemplates,
subscribeMpMessageByScenes,
} from '@/js_sdk/lili-pay/wx-pay.js'
const store = useStore()
const themeStyle = computed(() => getThemeStyle(store.state.theme))
onLoad(() => {
// #ifdef MP-WEIXIN
prefetchMpMessageTemplates()
// #endif
})
function handleBack() {
const doBack = () => {
uni.navigateBack({
fail: () => {
uni.redirectTo({
url: '/pages/order/myOrder?status=5',
})
},
})
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['AFTER_SALE_AUDIT'], doBack)
// #endif
// #ifndef MP-WEIXIN
doBack()
// #endif
}
function navigateToAfterSales() {
uni.redirectTo({
url: '/pages/order/afterSales/afterSales',
})
const goAfterSales = () => {
uni.redirectTo({
url: '/pages/order/myOrder?status=5',
})
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['AFTER_SALE_AUDIT'], goAfterSales)
// #endif
// #ifndef MP-WEIXIN
goAfterSales()
// #endif
}
function navigateToHome() {
uni.switchTab({
url: '/pages/tabbar/home/index',
})
const goHome = () => {
uni.switchTab({
url: '/pages/tabbar/home/index',
})
}
// #ifdef MP-WEIXIN
subscribeMpMessageByScenes(['AFTER_SALE_AUDIT'], goHome)
// #endif
// #ifndef MP-WEIXIN
goHome()
// #endif
}
</script>
<style lang="scss" scoped>
page {
background: $page-color-base;
padding-bottom: 100rpx;
.apply-success-page {
min-height: 100vh;
background: #f5f6fa;
box-sizing: border-box;
}
.btn1 {
background: $light-color;
color: #fff;
.page-body {
padding: 28rpx 24rpx 60rpx;
}
.btn2 {
color: $light-color;
}
.header {
background-color: #fff;
height: 500rpx;
.result-card {
background: #ffffff;
border-radius: 24rpx;
padding: 64rpx 40rpx 52rpx;
display: flex;
flex-direction: column;
align-items: center;
box-shadow: 0 4rpx 20rpx rgba(17, 30, 79, 0.04);
}
.icon-halo {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
background: rgba(255, 107, 53, 0.12);
display: flex;
align-items: center;
justify-content: center;
.success-text {
font-size: 40rpx;
font-weight: 400;
margin: 20rpx 0;
}
.btn-view {
display: flex;
flex-direction: row;
margin: 40rpx 0rpx;
.btn-item {
margin: 0rpx 20rpx;
}
}
.icon-circle {
width: 104rpx;
height: 104rpx;
border-radius: 50%;
background: linear-gradient(135deg, $main-color 0%, $light-color 100%);
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 20rpx rgba(229, 50, 56, 0.25);
}
.success-title {
margin-top: 32rpx;
font-size: 36rpx;
font-weight: 700;
color: #1d2129;
letter-spacing: 0.5rpx;
}
.success-sub {
margin-top: 12rpx;
font-size: 25rpx;
color: #86909c;
text-align: center;
}
.btn-group {
margin-top: 48rpx;
width: 100%;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 24rpx;
}
.action-btn {
flex: 1;
height: 82rpx;
line-height: 82rpx;
border-radius: 999rpx;
font-size: 28rpx;
font-weight: 600;
text-align: center;
box-sizing: border-box;
transition: opacity 0.15s;
&:active {
opacity: 0.85;
}
}
.text-view {
margin: 40rpx;
color: #909399;
.btn-primary {
background: linear-gradient(135deg, $main-color 0%, $light-color 100%);
color: #ffffff;
box-shadow: 0 6rpx 16rpx rgba(229, 50, 56, 0.22);
}
.btn-outline {
background: #fff6f3;
color: $main-color;
border: 2rpx solid rgba(229, 50, 56, 0.28);
}
.tips-card {
margin-top: 24rpx;
background: #ffffff;
border-radius: 24rpx;
padding: 32rpx 32rpx 36rpx;
box-shadow: 0 4rpx 20rpx rgba(17, 30, 79, 0.03);
}
.tips-header {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.tips-bar {
width: 6rpx;
height: 26rpx;
border-radius: 4rpx;
background: linear-gradient(180deg, $main-color 0%, $light-color 100%);
margin-right: 14rpx;
}
.tips-title {
font-size: 28rpx;
font-weight: 600;
color: #1d2129;
}
.tips-list {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.tip-item {
display: flex;
align-items: flex-start;
}
.tip-dot {
flex-shrink: 0;
width: 10rpx;
height: 10rpx;
border-radius: 50%;
background: #c9cdd4;
margin-top: 14rpx;
margin-right: 16rpx;
}
.tip-text {
flex: 1;
font-size: 25rpx;
line-height: 1.65;
color: #4e5969;
}
</style>

View File

@@ -38,6 +38,8 @@
<view class="btn-view u-flex u-row-between">
<view class="description">{{ afterSaleTypeText(order.serviceType) }}</view>
<view class="goods-btn flex flex-a-c">
<view class="cancel-btn" v-if="order.serviceStatus === 'APPLY'" @click="onCancelAfterSale(order)">取消售后</view>
<view class="pay-btn" v-if="order.serviceStatus === 'PASS' && order.serviceType !== 'RETURN_MONEY'" @click="onAfterSaleExpress(order)">提交物流</view>
<view class="pay-btn" @click="openOrder(order)">售后详情</view>
</view>
</view>
@@ -131,6 +133,8 @@
<u-toast ref="uToast" />
<u-modal :confirm-color="lightColor" v-model:show="rogShow" :show-cancel-button="true" :content="'是否确认收货?'"
@confirm="confirmRog"></u-modal>
<u-modal :confirm-color="lightColor" v-model:show="cancelAfterSaleShow" :show-cancel-button="true" content="确认取消售后?"
@confirm="confirmCancelAfterSale"></u-modal>
</view>
</template>
@@ -141,7 +145,8 @@ import { useStore } from '@/store'
import { getThemeStyle } from '@/utils/theme'
import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue'
import { getOrderList, cancelOrder, confirmReceipt } from '@/api/order.js'
import { getClearReason, getAfterSaleList } from '@/api/after-sale.js'
import { getClearReason, getAfterSaleList, cancelAfterSale } from '@/api/after-sale.js'
import storage from '@/utils/storage'
import LiLiWXPay from '@/js_sdk/lili-pay/wx-pay.js'
import {
unitPrice,
@@ -200,6 +205,8 @@ const orderSn = ref('')
const reason = ref('')
const cancelList = ref<any[]>([])
const rogShow = ref(false)
const cancelAfterSaleShow = ref(false)
const pendingAfterSaleSn = ref('')
function hideLoadingIfNeeded() {
if (store.state.isShowToast) uni.hideLoading()
@@ -418,6 +425,30 @@ function openOrder(order: any) {
navigateToOrderDetail(order.sn)
}
function onCancelAfterSale(order: any) {
pendingAfterSaleSn.value = order?.serviceSn || order?.sn || ''
cancelAfterSaleShow.value = true
}
async function confirmCancelAfterSale() {
if (!pendingAfterSaleSn.value) return
uni.showLoading({ title: '加载中' })
const res = await cancelAfterSale(pendingAfterSaleSn.value)
hideLoadingIfNeeded()
if (res?.data?.success) {
uni.showToast({ title: '取消成功!', duration: 2000, icon: 'none' })
initData(tabCurrentIndex.value)
}
}
function onAfterSaleExpress(order: any) {
const sku = (order?.orderItems && order.orderItems[0]) || {}
storage.setAfterSaleData({ ...order, ...sku, storeName: order.storeName })
uni.navigateTo({
url: `./afterSales/afterSalesDetailExpress?serviceSn=${order.serviceSn || order.sn}`,
})
}
function changeTab(e: any) {
// H5 的 swiper change 把下标放在 detail.current。
// 读 target.current 会得到 undefined,选中态被清掉,列表就停在「全部」。

View File

@@ -109,7 +109,7 @@
</view>
<!-- 服务工具卡片(分组化重构) -->
<tool />
<tool :user-info="userInfo" />
</view>
</view>
</template>

View File

@@ -76,6 +76,11 @@
<text class="grid-label">店铺入驻</text>
</view>
<view v-if="hasMerchantPermission" class="service-grid-item" @click="toMerchantWorkbench">
<image class="grid-icon" src="/static/mine/setting.png" mode="aspectFit"></image>
<text class="grid-label">商家工作台</text>
</view>
<view class="service-grid-item" @click="linkMsgDetail()">
<image class="grid-icon" src="/static/mine/mycommit.png" mode="aspectFit"></image>
<text class="grid-label">我的消息</text>
@@ -115,7 +120,7 @@
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { ref, computed } from 'vue'
import { distribution as fetchDistribution } from '@/api/distribution'
import configs from '@/config/config'
import storage from '@/utils/storage'
@@ -128,9 +133,47 @@ import {
DISTRIBUTION_STATUS,
} from '@/utils/distributionStatus'
const props = withDefaults(
defineProps<{
userInfo?: any
}>(),
{
userInfo: () => ({}),
}
)
const sharingShow = ref(false)
const sharingLink = ref('')
// 只有商家权限(店主 haveStore / 绑有 storeId 的店员 / 本地已有有效商家 token)的用户才展示入口
const hasMerchantPermission = computed(() => {
if (storage.getStoreAccessToken()) {
return true
}
const u = (props.userInfo && props.userInfo.id) ? props.userInfo : (storage.getUserInfo() || {})
return Boolean(u.haveStore === true || u.haveStore === 'true' || u.storeId)
})
function toMerchantWorkbench() {
if (!hasMerchantPermission.value) {
uni.showToast({
title: '暂无商家权限',
icon: 'none',
})
return
}
const storeToken = storage.getStoreAccessToken()
if (storeToken) {
uni.navigateTo({
url: '/pages-sub/merchant/pages/index/index',
})
} else {
uni.navigateTo({
url: '/pages-sub/merchant/pages/login/index',
})
}
}
function handleNavigate(url: string) {
uni.navigateTo({ url })
}

View File

@@ -1,152 +1,193 @@
let isDev = process.env.NODE_ENV === "development";
const UUID = isDev ? "uuid_key_dev" : "uuid_key";
const HAS_LOGIN = isDev ? "has_login_key_dev" : "has_login_key";
const ACCESS_TOKEN = isDev ? "access_token_key_dev" : "access_token_key";
const REFRESH_TOKEN = isDev ? "refresh_token_key_dev" : "refresh_token_key";
const USER_INFO = isDev ? "user_info_obj_dev" : "user_info_obj";
const FACE_LOGIN = isDev ? "face_login_dev" : "face_login";
const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login";
const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn";
const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data";
export default {
setInviter(val){
uni.setStorageSync('inviter', val)
},
getInviter(){
return uni.getStorageSync('inviter');
},
//写入自动发券
setAutoCp(val){
uni.setStorageSync('autoCp', val)
},
//获取自动发券时间
getAutoCp(){
return uni.getStorageSync('autoCp');
},
// 写入热门搜索时间戳
setHotWords(val) {
uni.setStorageSync("hotWords", val);
},
// 获取热门搜索时间戳
getHotWords() {
return uni.getStorageSync(`hotWords`);
},
//写入 展示还是不展示
setShow(val) {
uni.setStorageSync("show", val);
},
getShow() {
if (uni.getStorageSync(`show`) === "" || uni.getStorageSync(`show`) === undefined) {
return true;
}
return uni.getStorageSync(`show`);
},
// 获取face id登录
getFaceLogin() {
return uni.getStorageSync(FACE_LOGIN);
},
// 写入face id
setFaceLogin(val) {
uni.setStorageSync(FACE_LOGIN, val);
},
// 获取指纹登录
getFingerLogin() {
return uni.getStorageSync(FINGER_LOGIN);
},
// 写入指纹登录
setFingerLogin(val) {
uni.setStorageSync(FINGER_LOGIN, val);
},
// 写入用户信息
setUserInfo(val) {
uni.setStorageSync(USER_INFO, val);
},
// 获取用户信息
getUserInfo() {
return uni.getStorageSync(USER_INFO);
},
setTalkToUser(val){
uni.setStorageSync("TALK_TO_USER", val);
},
getTalkToUser(){
return uni.getStorageSync("TALK_TO_USER");
},
// 写入uuid
setUuid(val) {
uni.setStorageSync(UUID, val);
},
// 获取uuid
getUuid() {
return uni.getStorageSync(UUID);
},
// 写入登录
setHasLogin(val) {
uni.setStorageSync(HAS_LOGIN, val);
if (val) {
try {
const { flushPendingBind } = require("@/utils/distributionBind.js");
flushPendingBind();
} catch (e) {
// ignore
}
}
},
// 获取是否登录
getHasLogin() {
return uni.getStorageSync(HAS_LOGIN);
},
// 删除uuid
removeUuid() {
uni.removeStorageSync(UUID);
},
// 写入accessToken
setAccessToken(val) {
uni.setStorageSync(ACCESS_TOKEN, val);
},
// 获取accessToken
getAccessToken() {
return uni.getStorageSync(ACCESS_TOKEN);
},
// 后退购物车
setCartBackbtn(val) {
uni.setStorageSync(CART_BACKBTN, val);
},
// 删除token
removeAccessToken() {
uni.removeStorageSync(ACCESS_TOKEN);
},
// 写入刷新token
setRefreshToken(val) {
uni.setStorageSync(REFRESH_TOKEN, val);
},
// 获取刷新token
getRefreshToken() {
return uni.getStorageSync(REFRESH_TOKEN);
},
// 删除token
removeRefreshToken() {
uni.removeStorageSync(REFRESH_TOKEN);
},
setAfterSaleData(val) {
uni.setStorageSync(AFTERSALE_DATA, val);
},
getAfterSaleData() {
return uni.getStorageSync(AFTERSALE_DATA);
},
// 删除token
removeAfterSaleData() {
uni.removeStorageSync(AFTERSALE_DATA);
},
// 是否发送商品连接记录
setImGoodsLink(val) {
uni.setStorageSync('imGoodId', val);
},
getImGoodsLink() {
return uni.getStorageSync('imGoodId');
},
};
let isDev = process.env.NODE_ENV === "development";
const UUID = isDev ? "uuid_key_dev" : "uuid_key";
const HAS_LOGIN = isDev ? "has_login_key_dev" : "has_login_key";
const ACCESS_TOKEN = isDev ? "access_token_key_dev" : "access_token_key";
const REFRESH_TOKEN = isDev ? "refresh_token_key_dev" : "refresh_token_key";
const USER_INFO = isDev ? "user_info_obj_dev" : "user_info_obj";
const FACE_LOGIN = isDev ? "face_login_dev" : "face_login";
const FINGER_LOGIN = isDev ? "finger_login_dev" : "finger_login";
const CART_BACKBTN = isDev ? "cart_backbtn_dev" : "cart_backbtn";
const AFTERSALE_DATA = isDev ? "aftersale_data_dev" : "aftersale_data";
// 商家端专属 Key(与买家隔离)
const STORE_ACCESS_TOKEN = isDev ? "store_access_token_dev" : "store_access_token";
const STORE_REFRESH_TOKEN = isDev ? "store_refresh_token_dev" : "store_refresh_token";
const STORE_INFO = isDev ? "store_info_obj_dev" : "store_info_obj";
export default {
setInviter(val){
uni.setStorageSync('inviter', val)
},
getInviter(){
return uni.getStorageSync('inviter');
},
//写入自动发券
setAutoCp(val){
uni.setStorageSync('autoCp', val)
},
//获取自动发券时间
getAutoCp(){
return uni.getStorageSync('autoCp');
},
// 写入热门搜索时间戳
setHotWords(val) {
uni.setStorageSync("hotWords", val);
},
// 获取热门搜索时间戳
getHotWords() {
return uni.getStorageSync(`hotWords`);
},
//写入 展示还是不展示
setShow(val) {
uni.setStorageSync("show", val);
},
getShow() {
if (uni.getStorageSync(`show`) === "" || uni.getStorageSync(`show`) === undefined) {
return true;
}
return uni.getStorageSync(`show`);
},
// 获取face id登录
getFaceLogin() {
return uni.getStorageSync(FACE_LOGIN);
},
// 写入face id
setFaceLogin(val) {
uni.setStorageSync(FACE_LOGIN, val);
},
// 获取指纹登录
getFingerLogin() {
return uni.getStorageSync(FINGER_LOGIN);
},
// 写入指纹登录
setFingerLogin(val) {
uni.setStorageSync(FINGER_LOGIN, val);
},
// 写入用户信息
setUserInfo(val) {
uni.setStorageSync(USER_INFO, val);
},
// 获取用户信息
getUserInfo() {
return uni.getStorageSync(USER_INFO);
},
setTalkToUser(val){
uni.setStorageSync("TALK_TO_USER", val);
},
getTalkToUser(){
return uni.getStorageSync("TALK_TO_USER");
},
// 写入uuid
setUuid(val) {
uni.setStorageSync(UUID, val);
},
// 获取uuid
getUuid() {
return uni.getStorageSync(UUID);
},
// 写入登录
setHasLogin(val) {
uni.setStorageSync(HAS_LOGIN, val);
if (val) {
try {
const { flushPendingBind } = require("@/utils/distributionBind.js");
flushPendingBind();
} catch (e) {
// ignore
}
}
},
// 获取是否登录
getHasLogin() {
return uni.getStorageSync(HAS_LOGIN);
},
// 删除uuid
removeUuid() {
uni.removeStorageSync(UUID);
},
// 写入accessToken
setAccessToken(val) {
uni.setStorageSync(ACCESS_TOKEN, val);
},
// 获取accessToken
getAccessToken() {
return uni.getStorageSync(ACCESS_TOKEN);
},
// 后退购物车
setCartBackbtn(val) {
uni.setStorageSync(CART_BACKBTN, val);
},
// 删除token
removeAccessToken() {
uni.removeStorageSync(ACCESS_TOKEN);
},
// 写入刷新token
setRefreshToken(val) {
uni.setStorageSync(REFRESH_TOKEN, val);
},
// 获取刷新token
getRefreshToken() {
return uni.getStorageSync(REFRESH_TOKEN);
},
// 删除token
removeRefreshToken() {
uni.removeStorageSync(REFRESH_TOKEN);
},
setAfterSaleData(val) {
uni.setStorageSync(AFTERSALE_DATA, val);
},
getAfterSaleData() {
return uni.getStorageSync(AFTERSALE_DATA);
},
// 删除token
removeAfterSaleData() {
uni.removeStorageSync(AFTERSALE_DATA);
},
// 是否发送商品连接记录
setImGoodsLink(val) {
uni.setStorageSync('imGoodId', val);
},
getImGoodsLink() {
return uni.getStorageSync('imGoodId');
},
// ============== 商家专属 Token 与鉴权方法 ==============
setStoreAccessToken(val) {
uni.setStorageSync(STORE_ACCESS_TOKEN, val);
},
getStoreAccessToken() {
return uni.getStorageSync(STORE_ACCESS_TOKEN);
},
removeStoreAccessToken() {
uni.removeStorageSync(STORE_ACCESS_TOKEN);
},
setStoreRefreshToken(val) {
uni.setStorageSync(STORE_REFRESH_TOKEN, val);
},
getStoreRefreshToken() {
return uni.getStorageSync(STORE_REFRESH_TOKEN);
},
removeStoreRefreshToken() {
uni.removeStorageSync(STORE_REFRESH_TOKEN);
},
setStoreInfo(val) {
uni.setStorageSync(STORE_INFO, val);
},
getStoreInfo() {
return uni.getStorageSync(STORE_INFO);
},
removeStoreInfo() {
uni.removeStorageSync(STORE_INFO);
},
/** 清理商家登录状态,保留买家会话 */
clearStoreAuth() {
uni.removeStorageSync(STORE_ACCESS_TOKEN);
uni.removeStorageSync(STORE_REFRESH_TOKEN);
uni.removeStorageSync(STORE_INFO);
},
};