first commit
This commit is contained in:
328
pages/video_list/video_list.js
Normal file
328
pages/video_list/video_list.js
Normal file
@@ -0,0 +1,328 @@
|
||||
const app = getApp();
|
||||
|
||||
Page({
|
||||
data: {
|
||||
inputValue: '', // 输入框的内容
|
||||
detectResult: '', // 识别结果
|
||||
detectType: 'text', // 默认识别类型为文本
|
||||
maxLength: 20000, // 最大允许的字节数
|
||||
inputLength: 0, // 当前输入的字节数
|
||||
task_id: '', // 任务ID
|
||||
detectButtonDisabled: false, // 文本检测按钮是否禁用
|
||||
modifyButtonDisabled: false // 智能修改按钮是否禁用
|
||||
},
|
||||
|
||||
onLoad: function(e) {
|
||||
wx.showShareMenu({
|
||||
withShareTicket: true,
|
||||
menus: ["shareAppMessage", "shareTimeline"]
|
||||
});
|
||||
},
|
||||
|
||||
onShow: function() {
|
||||
var t = this;
|
||||
t.resetData()
|
||||
app.getCurrentTabbar(2, this);
|
||||
app.checkUpdateVersion();
|
||||
app.getUserInfo().then(() => {
|
||||
console.log('获取用户信息完成');
|
||||
console.log(wx.getStorageSync('defaultDailyFreeParseNum'));
|
||||
const rewrittenText = wx.getStorageSync('rewrittenText'); // 从缓存中获取存储的文案
|
||||
if (rewrittenText) {
|
||||
this.setData({
|
||||
inputValue: rewrittenText // 设置到页面的数据中
|
||||
});
|
||||
wx.removeStorageSync('rewrittenText'); // 清除数据,避免下次重复加载
|
||||
wx.showToast({
|
||||
title: '点击开始检测按钮检测文本违规词。',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
}).catch(error => {
|
||||
console.error('获取用户信息失败:', error);
|
||||
}).finally(() => {
|
||||
console.log('getUserInfo调用完成');
|
||||
});
|
||||
},
|
||||
resetData: function() {
|
||||
// 重置页面数据为默认值
|
||||
this.setData({
|
||||
inputValue: '', // 输入框的内容
|
||||
detectResult: '', // 识别结果
|
||||
detectType: 'text', // 默认识别类型为文本
|
||||
inputLength: 0, // 当前输入的字节数
|
||||
task_id: '', // 任务ID
|
||||
detectButtonDisabled: false, // 文本检测按钮是否禁用
|
||||
modifyButtonDisabled: false // 智能修改按钮是否禁用
|
||||
});
|
||||
},
|
||||
// 切换识别类型
|
||||
switchDetectType(e) {
|
||||
const detectType = e.currentTarget.dataset.type;
|
||||
this.recordClick(detectType);
|
||||
this.setData({
|
||||
detectType,
|
||||
detectResult: '' // 切换时清空结果
|
||||
});
|
||||
|
||||
if (detectType === 'audio' || detectType === 'video') {
|
||||
wx.showToast({
|
||||
title: '该功能正在开发中',
|
||||
icon: 'none'
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '切换到文本识别',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 文本识别函数
|
||||
detectText() {
|
||||
const { inputValue, maxLength } = this.data;
|
||||
const byteSize = this.getByteLength(inputValue);
|
||||
|
||||
// 检查文本是否为空或长度过短
|
||||
if (!inputValue.trim() || this.getByteLength(inputValue) < 10) {
|
||||
wx.showToast({
|
||||
title: '请输入有效的文本',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 超出字节长度检测
|
||||
if (byteSize > maxLength) {
|
||||
wx.showToast({
|
||||
title: `内容不能超过 ${maxLength} 字节`,
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// 禁用检测按钮
|
||||
this.setData({ detectButtonDisabled: true });
|
||||
|
||||
wx.showLoading({
|
||||
title: '正在检测...',
|
||||
});
|
||||
|
||||
// 调用后端审核接口
|
||||
app.apiRequest({
|
||||
url: '/myapp/text_review/',
|
||||
method: 'POST',
|
||||
data: {
|
||||
text: inputValue,
|
||||
openid: wx.getStorageSync('openid'),
|
||||
nickname: wx.getStorageSync('uuid')
|
||||
},
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ detectButtonDisabled: false }); // 启用检测按钮
|
||||
if (res.data.code === 200) {
|
||||
// 审核成功
|
||||
this.setData({
|
||||
detectResult: res.data.data.result,
|
||||
task_id: res.data.task_id
|
||||
});
|
||||
console.log(res.data.data.result);
|
||||
wx.showToast({
|
||||
title: '检测成功',
|
||||
icon: 'success'
|
||||
});
|
||||
if (res.data.data.result.conclusion === '不合规') {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "检测结果不合规,是否使用智能合规功能一键修改文案?",
|
||||
confirmText: "一键修改",
|
||||
cancelText: "取消",
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
this.modifyContent(); // 调用一键合规函数
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (res.data.code === 400 && res.data.message === '余额不足') {
|
||||
// 积分不足,提示充值
|
||||
wx.showModal({
|
||||
title: "检测文本",
|
||||
content: '创意点不足!',
|
||||
confirmColor: "#00B269",
|
||||
cancelColor: "#858585",
|
||||
success: function(e) {
|
||||
if (e.confirm) {
|
||||
console.log("确定");
|
||||
wx.navigateTo({
|
||||
url: "../vip_recharge/vip_recharge?show=true"
|
||||
});
|
||||
} else {
|
||||
console.log("取消");
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 其他失败情况
|
||||
wx.showToast({
|
||||
title: res.data.message || '检测失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ detectButtonDisabled: false }); // 启用检测按钮
|
||||
console.error('请求失败:', err);
|
||||
wx.showToast({
|
||||
title: '网络异常,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 计算文本的字节长度(区分中英文)
|
||||
getByteLength(text) {
|
||||
return text.replace(/[^\x00-\xff]/g, 'aa').length;
|
||||
},
|
||||
|
||||
// 处理输入框内容变化
|
||||
bindInput(e) {
|
||||
const inputValue = e.detail.value;
|
||||
const inputLength = this.getByteLength(inputValue);
|
||||
|
||||
// 更新输入内容和字节长度
|
||||
this.setData({
|
||||
inputValue,
|
||||
inputLength
|
||||
});
|
||||
|
||||
// 如果字数超出最大限制,提示用户
|
||||
if (inputLength > this.data.maxLength) {
|
||||
wx.showToast({
|
||||
title: `已超出 ${this.data.maxLength} 字节`,
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// 复制内容
|
||||
copyContent() {
|
||||
wx.setClipboardData({
|
||||
data: this.data.inputValue,
|
||||
success() {
|
||||
wx.showToast({
|
||||
title: '内容已复制',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 清空输入框内容
|
||||
clearInput() {
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "确定要清空所有内容吗?",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.setData({
|
||||
inputValue: '',
|
||||
inputLength: 0,
|
||||
detectResult: ''
|
||||
});
|
||||
wx.showToast({
|
||||
title: '已清空内容',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 调用智能修改(AI合规)
|
||||
modifyContent() {
|
||||
// 禁用智能修改按钮
|
||||
this.setData({ modifyButtonDisabled: true });
|
||||
|
||||
wx.showLoading({
|
||||
title: '正在修改...',
|
||||
});
|
||||
|
||||
app.apiRequest({
|
||||
url: '/myapp/ai_modify_text/',
|
||||
method: 'POST',
|
||||
data: {
|
||||
task_id: this.data.task_id,
|
||||
openid: wx.getStorageSync('openid')
|
||||
},
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ modifyButtonDisabled: false }); // 启用智能修改按钮
|
||||
if (res.data.code === 200) {
|
||||
// 修改成功
|
||||
this.setData({
|
||||
inputValue: res.data.data.modified_text,
|
||||
detectResult: '' // 清空检测结果
|
||||
});
|
||||
wx.showToast({
|
||||
title: '修改成功',
|
||||
icon: 'success'
|
||||
});
|
||||
}else if (res.data.code === 400 && res.data.message === '积分不足,请充值') {
|
||||
// 积分不足,提示用户充值并引导
|
||||
wx.showModal({
|
||||
title: "提示",
|
||||
content: "您的积分不足,无法进行智能修改,请充值后再尝试。",
|
||||
confirmText: "去充值",
|
||||
cancelText: "取消",
|
||||
success: (modalRes) => {
|
||||
if (modalRes.confirm) {
|
||||
wx.navigateTo({
|
||||
url: "../vip_recharge/vip_recharge?show=true"
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 其他失败情况
|
||||
wx.showToast({
|
||||
title: res.data.message || '修改失败,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
wx.hideLoading();
|
||||
this.setData({ modifyButtonDisabled: false }); // 启用智能修改按钮
|
||||
console.error('请求失败:', err);
|
||||
wx.showToast({
|
||||
title: '网络异常,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 记录点击的功能类型
|
||||
recordClick(functionClicked) {
|
||||
app.apiRequest({
|
||||
url: `/myapp/record_click/`, // 点击统计接口
|
||||
method: 'POST',
|
||||
data: {
|
||||
openid: wx.getStorageSync('openid'),
|
||||
nickname: wx.getStorageSync('uuid'),
|
||||
function_clicked: functionClicked
|
||||
},
|
||||
header: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
success: (res) => {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
7
pages/video_list/video_list.json
Normal file
7
pages/video_list/video_list.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "违规词识别",
|
||||
"navigationBarBackgroundColor": "#222238",
|
||||
"navigationBarTextStyle": "white",
|
||||
"component": true,
|
||||
"custom-tab-bar": "/custom-tab-bar/index"
|
||||
}
|
||||
85
pages/video_list/video_list.wxml
Normal file
85
pages/video_list/video_list.wxml
Normal file
@@ -0,0 +1,85 @@
|
||||
<view class="container">
|
||||
<!-- 顶部按钮组 -->
|
||||
<view class="header">
|
||||
<view class="button-group">
|
||||
<button class="detect-button active" data-type="text" bindtap="switchDetectType">文本识别</button>
|
||||
<button class="detect-button" data-type="audio" bindtap="switchDetectType">音频识别</button>
|
||||
<button class="detect-button" data-type="video" bindtap="switchDetectType">视频识别</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 输入框区域 -->
|
||||
<view class="input-area">
|
||||
|
||||
<textarea class="input-field"
|
||||
bindinput="bindInput"
|
||||
value="{{inputValue}}"
|
||||
placeholder-class="b-palceholder"
|
||||
placeholder="输入或粘贴文本,自动识别违规内容并智能修改..."
|
||||
maxlength="20000">
|
||||
</textarea>
|
||||
|
||||
<!-- 字数统计及提示信息 -->
|
||||
<view class="text-counter">
|
||||
<text>{{inputLength}} / {{maxLength}}</text>
|
||||
<text wx:if="{{inputLength > maxLength}}" class="error-text">内容不能超过 {{maxLength}} 字节</text>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 第一行:检测和智能修改 -->
|
||||
<view class="button-group">
|
||||
<button class="detect-button" disabled="{{detectButtonDisabled}}" bindtap="detectText">开始检测</button>
|
||||
<button class="modify-button" disabled="{{modifyButtonDisabled}}" bindtap="modifyContent">一键合规</button>
|
||||
</view>
|
||||
|
||||
<!-- 操作按钮 第二行:复制和清空 -->
|
||||
<view class="button-group">
|
||||
<button class="copy-button" bindtap="copyContent">复制内容</button>
|
||||
<button class="clear-button" bindtap="clearInput">清空输入</button>
|
||||
</view>
|
||||
<view class="disclaimer">
|
||||
<text>单次消耗3创意点。检测中请勿退出本页面,很快完成</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="report-container" wx:if="{{detectResult}}">
|
||||
<!-- 报告标题 -->
|
||||
<view class="report-title">检测报告</view>
|
||||
|
||||
<!-- 检测结果 -->
|
||||
<view class="result-summary">
|
||||
<text class="{{detectResult.conclusion === '合规' ? 'compliant' : 'non-compliant'}}">
|
||||
检测结果: {{detectResult.conclusion}}
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<!-- 表格 -->
|
||||
<view class="result-table">
|
||||
<!-- 表头 -->
|
||||
<view class="table-row table-header">
|
||||
<view class="table-cell">疑似命中</view>
|
||||
<view class="table-cell">关键词</view>
|
||||
<view class="table-cell">字符位置</view>
|
||||
<view class="table-cell">置信度</view>
|
||||
</view>
|
||||
|
||||
<!-- 表格内容 -->
|
||||
<block wx:for="{{detectResult.data}}" wx:key="index">
|
||||
<view class="table-row">
|
||||
<view class="table-cell">{{item.reason}}</view>
|
||||
<view class="table-cell">{{item.keyword}}</view>
|
||||
<view class="table-cell">{{item.position}}</view>
|
||||
<view class="table-cell">{{item.confidence}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
<!-- 设置底部间距 -->
|
||||
<view class="bottom-space"></view>
|
||||
<view class="disclaimer">
|
||||
<text>功能介绍:本功能用于检测文本中可能存在的违规内容,帮助用户规避潜在风险。\n</text>
|
||||
<text>免责声明:本检测结果仅供参考,具体结果请以实际情况为准,平台不承担由此产生的任何法律责任。</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
</view>
|
||||
204
pages/video_list/video_list.wxss
Normal file
204
pages/video_list/video_list.wxss
Normal file
@@ -0,0 +1,204 @@
|
||||
page {
|
||||
background-color: #222238;
|
||||
border-top: 1px solid hsla(0,31%,87%,.5);
|
||||
}
|
||||
|
||||
.container {
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
margin-bottom: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.detect-button{
|
||||
width: 30%;
|
||||
height: 35px;
|
||||
font-size: 12px;
|
||||
line-height: 35px;
|
||||
background: linear-gradient(90deg, #8d72d2, #7183f3);
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
box-shadow: 0 4px 10px rgba(141, 114, 210, 0.4);
|
||||
transition: background 0.3s, transform 0.3s;
|
||||
}
|
||||
|
||||
.detect-button:hover {
|
||||
background: linear-gradient(90deg, #664da5, #4e66d8);
|
||||
|
||||
}
|
||||
|
||||
.active {
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.input-area {
|
||||
width: 100%;
|
||||
background-color: #222238;
|
||||
box-shadow: 0 4px 10px rgba(141, 114, 210, 0.4);
|
||||
padding: 20px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.input-field {
|
||||
background: #33334c;
|
||||
color: #a790e2;
|
||||
padding: 15px;
|
||||
box-sizing: border-box;
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
height: 230px;
|
||||
border: 1px solid #a790e2;
|
||||
outline: none;
|
||||
resize: none;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.input-field:hover {
|
||||
border-color: #fff;
|
||||
}
|
||||
|
||||
.button-group {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.copy-button, .modify-button ,.detect-button, .clear-button{
|
||||
width: 30%;
|
||||
|
||||
box-sizing: border-box;
|
||||
background: linear-gradient(90deg, #8d72d2, #7183f3);
|
||||
border-radius: 5px;
|
||||
text-align: center;
|
||||
color: white;
|
||||
font-size: 14px;
|
||||
|
||||
box-shadow: 0 4px 10px rgba(141, 114, 210, 0.4);
|
||||
transition: background 0.3s, transform 0.3s;
|
||||
}
|
||||
|
||||
.copy-button:hover, .modify-button:hover {
|
||||
background: linear-gradient(90deg, #664da5, #4e66d8);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.result-area {
|
||||
margin-top: 20px;
|
||||
background: linear-gradient(135deg, #a3a3df, #eaeaf5); /* 浅色渐变背景 */
|
||||
width: 90%;
|
||||
padding: 15px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); /* 添加轻微阴影效果 */
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #ddd; /* 增加边框 */
|
||||
}
|
||||
.text-counter{
|
||||
font-size: 12px;
|
||||
color: white;
|
||||
text-align: left;
|
||||
margin:2px;
|
||||
}
|
||||
.error-text {
|
||||
color: red;
|
||||
margin-left: 60px;
|
||||
}
|
||||
|
||||
/* 报告容器样式 */
|
||||
.report-container {
|
||||
width: 95%;
|
||||
background-color: #f5f8ff;
|
||||
padding: 20rpx;
|
||||
border-radius: 15rpx;
|
||||
box-shadow: 0rpx 5rpx 15rpx rgba(0, 0, 0, 0.1);
|
||||
margin-top: 20rpx;
|
||||
margin-bottom: 45px;
|
||||
}
|
||||
|
||||
/* 标题样式 */
|
||||
.report-title {
|
||||
font-size: 36rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
margin-bottom: 2rpx;
|
||||
}
|
||||
|
||||
/* 检测结果样式 */
|
||||
.result-summary {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-bottom: 20rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 合规与不合规文本样式 */
|
||||
.compliant {
|
||||
color: #00b269; /* 绿色 */
|
||||
}
|
||||
|
||||
.non-compliant {
|
||||
color: #ff4d4f; /* 红色 */
|
||||
}
|
||||
|
||||
/* 表格样式 */
|
||||
.result-table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* 表格行样式 */
|
||||
.table-row {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 10rpx 0;
|
||||
border-bottom: 1rpx solid #eaeaea;
|
||||
}
|
||||
|
||||
/* 表格头部样式 */
|
||||
.table-header {
|
||||
font-weight: bold;
|
||||
background-color: #eef1f8;
|
||||
padding: 10rpx 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* 表格单元格样式 */
|
||||
.table-cell {
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
font-size: 26rpx;
|
||||
color: #333;
|
||||
padding: 10rpx 0;
|
||||
}
|
||||
|
||||
/* 底部空白区 */
|
||||
.bottom-space {
|
||||
height: 50rpx;
|
||||
}
|
||||
|
||||
/* Disclaimer styling */
|
||||
.disclaimer {
|
||||
margin-top: 20rpx;
|
||||
padding: 10rpx;
|
||||
color: #999;
|
||||
font-size: 22rpx; /* 小号字体 */
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user