完善文案的状态流转
This commit is contained in:
@@ -25,8 +25,8 @@ interface EnvConfig {
|
||||
const API_CONFIG: Record<EnvType, EnvConfig> = {
|
||||
// 开发环境 - 本地开发
|
||||
dev: {
|
||||
baseURL: 'http://localhost:8080', // 本地Go服务
|
||||
pythonURL: 'http://localhost:8000', // 本地Python服务
|
||||
baseURL: 'http://192.168.17.127:8080', // 本地Go服务
|
||||
pythonURL: 'http://192.168.17.127:8000', // 本地Python服务
|
||||
timeout: 90000
|
||||
},
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@ Page({
|
||||
currentCopy: null as any, // 当前显示的文案
|
||||
loading: false,
|
||||
claiming: false, // 领取中
|
||||
publishing: false // 发布中
|
||||
publishing: false, // 发布中
|
||||
rejecting: false // 拒绝中
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
@@ -150,7 +151,7 @@ Page({
|
||||
|
||||
// 换一个文案
|
||||
changeArticle() {
|
||||
if (this.data.claiming || this.data.publishing) return;
|
||||
if (this.data.claiming || this.data.publishing || this.data.rejecting) return;
|
||||
|
||||
const { allCopies, currentIndex } = this.data;
|
||||
|
||||
@@ -162,19 +163,25 @@ Page({
|
||||
return;
|
||||
}
|
||||
|
||||
// 切换到下一个文案
|
||||
const nextIndex = (currentIndex + 1) % allCopies.length;
|
||||
|
||||
this.setData({
|
||||
currentIndex: nextIndex,
|
||||
currentCopy: allCopies[nextIndex]
|
||||
// 显示加载动画
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
wx.showToast({
|
||||
title: `${nextIndex + 1}/${allCopies.length}`,
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
});
|
||||
// 模拟加载效果,让切换更平滑
|
||||
setTimeout(() => {
|
||||
// 切换到下一个文案
|
||||
const nextIndex = (currentIndex + 1) % allCopies.length;
|
||||
|
||||
this.setData({
|
||||
currentIndex: nextIndex,
|
||||
currentCopy: allCopies[nextIndex]
|
||||
});
|
||||
|
||||
// 隐藏加载动画
|
||||
wx.hideLoading();
|
||||
}, 300);
|
||||
},
|
||||
|
||||
// 一键发布(先领取,再发布)
|
||||
@@ -281,6 +288,84 @@ Page({
|
||||
};
|
||||
},
|
||||
|
||||
// 拒绝文案
|
||||
async rejectArticle() {
|
||||
if (!this.data.currentCopy) {
|
||||
wx.showToast({
|
||||
title: '请先选择文案',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
wx.showModal({
|
||||
title: '确认拒绝',
|
||||
content: '确定要拒绝这篇文案吗?',
|
||||
confirmText: '拒绝',
|
||||
confirmColor: '#ff4d4f',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
await this.doRejectArticle();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 执行拒绝操作
|
||||
async doRejectArticle() {
|
||||
this.setData({ rejecting: true });
|
||||
|
||||
try {
|
||||
const response = await EmployeeService.updateArticleStatus(
|
||||
this.data.currentCopy.id,
|
||||
'rejected'
|
||||
);
|
||||
|
||||
if (response.code === 200) {
|
||||
wx.showToast({
|
||||
title: '已拒绝',
|
||||
icon: 'success',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
// 从列表中移除当前文案
|
||||
const { allCopies, currentIndex } = this.data;
|
||||
allCopies.splice(currentIndex, 1);
|
||||
|
||||
// 更新显示
|
||||
if (allCopies.length > 0) {
|
||||
const newIndex = currentIndex >= allCopies.length ? 0 : currentIndex;
|
||||
this.setData({
|
||||
allCopies,
|
||||
currentIndex: newIndex,
|
||||
currentCopy: allCopies[newIndex],
|
||||
rejecting: false
|
||||
});
|
||||
} else {
|
||||
// 没有更多文案了
|
||||
this.setData({
|
||||
allCopies: [],
|
||||
currentCopy: null,
|
||||
rejecting: false
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
wx.navigateBack();
|
||||
}, 1500);
|
||||
}
|
||||
} else {
|
||||
throw new Error(response.message || '拒绝失败');
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('拒绝失败:', error);
|
||||
this.setData({ rejecting: false });
|
||||
wx.showToast({
|
||||
title: error.message || '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 分享到朋友圈
|
||||
onShareTimeline() {
|
||||
return {
|
||||
|
||||
@@ -53,16 +53,24 @@
|
||||
<!-- 底部操作栏 -->
|
||||
<view class="action-bar" wx:if="{{currentCopy}}">
|
||||
<button
|
||||
class="action-btn secondary"
|
||||
class="action-btn refresh"
|
||||
bindtap="changeArticle"
|
||||
disabled="{{claiming || publishing}}"
|
||||
disabled="{{claiming || publishing || rejecting}}"
|
||||
>
|
||||
<text class="btn-text">换一换</text>
|
||||
</button>
|
||||
<button
|
||||
class="action-btn reject"
|
||||
bindtap="rejectArticle"
|
||||
disabled="{{claiming || publishing || rejecting}}"
|
||||
loading="{{rejecting}}"
|
||||
>
|
||||
<text class="btn-text">{{rejecting ? '拒绝中...' : '拒绝'}}</text>
|
||||
</button>
|
||||
<button
|
||||
class="action-btn primary"
|
||||
bindtap="publishArticle"
|
||||
disabled="{{claiming || publishing}}"
|
||||
disabled="{{claiming || publishing || rejecting}}"
|
||||
loading="{{claiming || publishing}}"
|
||||
>
|
||||
<text class="btn-text">{{claiming ? '领取中...' : (publishing ? '发布中...' : '一键发布')}}</text>
|
||||
|
||||
@@ -173,7 +173,7 @@ page {
|
||||
left: 0;
|
||||
right: 0;
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
gap: 16rpx;
|
||||
padding: 20rpx 30rpx;
|
||||
background: white;
|
||||
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
@@ -182,11 +182,11 @@ page {
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
height: 80rpx;
|
||||
height: 88rpx;
|
||||
border: none;
|
||||
border-radius: 40rpx;
|
||||
border-radius: 44rpx;
|
||||
font-size: 28rpx;
|
||||
font-weight: 500;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -198,20 +198,34 @@ page {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.action-btn.secondary {
|
||||
flex: 0 0 180rpx;
|
||||
/* 换一换按钮 */
|
||||
.action-btn.refresh {
|
||||
flex: 0 0 220rpx;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.action-btn.secondary:active {
|
||||
.action-btn.refresh:active {
|
||||
background: #e8e8e8;
|
||||
}
|
||||
|
||||
/* 拒绝按钮 */
|
||||
.action-btn.reject {
|
||||
flex: 0 0 180rpx;
|
||||
background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.action-btn.reject:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* 一键发布按钮 */
|
||||
.action-btn.primary {
|
||||
flex: 1;
|
||||
background: #07c160;
|
||||
background: linear-gradient(135deg, #07c160 0%, #0ae97a 100%);
|
||||
color: white;
|
||||
box-shadow: 0 4rpx 16rpx rgba(7, 193, 96, 0.3);
|
||||
}
|
||||
|
||||
.action-btn.primary:active {
|
||||
@@ -219,7 +233,7 @@ page {
|
||||
}
|
||||
|
||||
.action-btn[disabled] {
|
||||
opacity: 0.6;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
|
||||
@@ -210,4 +210,13 @@ export class EmployeeService {
|
||||
publish_time: string;
|
||||
}>(`/api/employee/publish-record/${recordId}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新文案状态(通过/拒绝)
|
||||
*/
|
||||
static async updateArticleStatus(articleId: number, status: 'approved' | 'rejected') {
|
||||
return post(`/api/employee/article/${articleId}/status`, {
|
||||
status
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user