1
0
forked from dyf/APP

操作视频,增删改查,接口联调

This commit is contained in:
fengerli
2025-07-11 15:56:50 +08:00
parent 6ada4657fb
commit ceeb4772ca
10 changed files with 1665 additions and 1668 deletions

View File

@ -1,50 +1,60 @@
<template>
<view class="device-page">
<!-- 表单内容 -->
<view class="form-content">
<!-- 名称输入框 -->
<view class="input-group">
<text class="label">名称</text>
<input class="input" type="text" placeholder="请输入名称" v-model="name" />
<view>
<custom-navbar :title="navTitle" :showBack="true" backgroundColor="#202020" color="#FFFFFF"></custom-navbar>
<view class="device-page" :style="{ paddingTop: navBarHeight + 'px' }">
<!-- 表单内容 -->
<view class="form-content">
<!-- 名称输入框 -->
<view class="input-group">
<text class="label">名称</text>
<input class="input" type="text" placeholder="请输入名称" v-model="name" />
</view>
<!-- 视频链接输入框 -->
<view class="input-group">
<text class="label">视频链接</text>
<input class="input" type="text" placeholder="请输入视频链接" v-model="videoLink" />
</view>
</view>
<!-- 视频链接输入框 -->
<view class="input-group">
<text class="label">视频链接</text>
<input class="input" type="text" placeholder="请输入视频链接" v-model="videoLink" />
</view>
</view>
<!-- 保存按钮 -->
<button class="save-button" @click="saveData"> </button>
<!-- 保存按钮 -->
<button class="save-button" @click="saveData"> </button>
<!--===================== 保存成功提示框================== -->
<view class="agreement-mask" v-if="showModal">
<!-- 上传画面弹窗 -->
<view class="agreement-popupC">
<view class="popup-content">
<image src="/static/images/path2.png" mode="" class="path2"></image>
<view class="popup-Title">
<view>保存成功</view>
<!--===================== 保存成功提示框================== -->
<view class="agreement-mask" v-if="showModal">
<!-- 上传画面弹窗 -->
<view class="agreement-popupC">
<view class="popup-content">
<image src="/static/images/path2.png" mode="" class="path2"></image>
<view class="popup-Title">
<view>保存成功</view>
</view>
</view>
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="btn agreeBtn" @click="handleBtn">确定</button>
</view>
</view>
<!-- 按钮组 -->
<view class="popup-buttons">
<button class="btn agreeBtn" @click="handleBtn">确定</button>
</view>
</view>
</view>
</view>
</template>
<script>
import {
addOperationVideo,
editOperationVideo
} from '@/api/common/operationVideo/index.js'
export default {
data() {
return {
navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight,
navTitle: '添加',
name: '',
videoLink: '',
showModal: false
showModal: false,
deviceID: "",
id: ''
};
},
methods: {
@ -59,20 +69,63 @@
})
return false
}
if (this.videoLink == '') {
if (this.videoLink == '') {
uni.showToast({
icon: 'none',
title: '视频链接不为空'
})
return false
}
this.showModal = true
uni.navigateBack()
let data = {
videoName: this.name,
videoUrl: this.videoLink,
deviceId: this.deviceID,
id: this.id
}
// 添加编辑
const apiMethod = this.editData ? editOperationVideo : addOperationVideo;
console.log('apiMethod:', apiMethod);
apiMethod(data).then(res => {
if (res.code == 200) {
this.showModal = true;
setTimeout(() => {
uni.navigateBack();
}, 1500);
} else {
uni.showToast({
title: res.msg,
icon: 'none'
});
}
}).catch(err => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
});
});
},
// 确定提示框
handleBtn() {
this.showModal = false
}
},
onLoad(options) {
if (options.item) {
// 解析传递过来的item对象
this.editData = JSON.parse(decodeURIComponent(options.item));
// 回显数据
this.name = this.editData.videoName || '';
this.videoLink = this.editData.videoUrl || '';
this.deviceID = this.editData.deviceId || '';
this.id = this.editData.id
// 修改导航标题
this.navTitle = '编辑';
} else if (options.id) {
this.deviceID = options.id;
this.navTitle = '添加';
this.editData = null; // 明确设置为 null
}
}
};
</script>

View File

@ -139,7 +139,8 @@
// 获取图片列表
callOtherApi() {
let data = {
deviceId: this.deviceID
deviceId: this.deviceID,
fileType: '1' //文件类型(1:操作说明2:产品参数)
}
fileInfo(data).then((res) => {
if (res.code == 200) {

View File

@ -4,17 +4,17 @@
<custom-navbar title="操作视频" :showBack="true" backgroundColor="#202020" color="#FFFFFF"></custom-navbar>
<view class="device-page" :style="{ paddingTop: navBarHeight + 'px' }">
<scroll-view scroll-y>
<uni-swipe-action >
<uni-swipe-action>
<block v-for="(item, index) in videoList" :key="index">
<uni-swipe-action-item :right-options="item.showConfirm ? confirmOptions : deleteOptions"
@click="handleSwipeClick($event, index)" class="content">
<view class="image-box" @click="openVideoUrl(item.url)">
@click="handleSwipeClick($event, index,item)" class="content">
<view class="image-box" @click="openVideoUrl(item.videoUrl)">
<view class="deviceIMG">
<image src="/static/images/video.png" mode="" class="video"></image>
</view>
<view class="">
<view class="file-title">{{item.title}}</view>
<view class="file-baidu">{{item.url}}</view>
<view class="file-title">{{item.videoName}}</view>
<view class="file-baidu">{{item.videoUrl}}</view>
</view>
</view>
<image src="/static/images/cires.png" class="circle"></image>
@ -30,12 +30,17 @@
</template>
<script>
import {
listOperationVideos,
deleteOperationVideo
} from '@/api/common/operationVideo/index.js'
export default {
data() {
return {
navTitle: '操作视频',
navBarHeight: 70 + uni.getSystemInfoSync().statusBarHeight,
videoList: [],
deviceID: '',
deleteOptions: [{
text: '编辑',
style: {
@ -68,27 +73,46 @@
// 添加视频
addvideo() {
uni.navigateTo({
url: '/pages/6170/addvideo/index'
url: `/pages/common/addvideo/index??id=${this.deviceID}`
})
},
// 处理滑动按钮点击
handleSwipeClick(e, index) {
handleSwipeClick(e, index, item) {
console.log(item, 'eeeee');
const {
content
} = e;
// 如果是确认删除操作
if (content.text === '确认删除') {
this.videoList.splice(index, 1);
uni.showToast({
title: '删除成功',
icon: 'success'
});
return;
let ids = item.id
let data ={
ids:item.id
}
deleteOperationVideo(ids).then((res) => {
if (res.code == 200) {
uni.showToast({
title: res.msg,
icon: 'success'
});
this.getData()
} else {
uni.showToast({
title: res.msg,
icon: 'success'
});
}
})
// return;
}
// 编辑操作
if (content.text === '编辑') {
this.editVideo(this.videoList[index].id);
console.log('编辑');
uni.navigateTo({
url: `/pages/common/addvideo/index?item=${encodeURIComponent(JSON.stringify(item))}`
});
}
// 删除操作
else if (content.text === '删除') {
@ -103,12 +127,6 @@
}
},
// 编辑视频
editVideo(id) {
uni.navigateTo({
url: `/pages/6170/editVideo/index?id=${id}`
});
},
// 打开视频URL
openVideoUrl(url) {
console.log(url, 'url333');
@ -127,6 +145,29 @@
});
}
},
getData() {
let data = {
deviceId: this.deviceID
}
listOperationVideos(data).then((res) => {
console.log(res, 'resss');
if (res.code == 200) {
this.videoList = res.data
} else {
uni.showToast({
title: res.msg,
icon: 'none'
})
}
})
}
},
onShow() {
this.getData()
},
onLoad(options) {
this.deviceID = options.id
}
}
</script>

View File

@ -139,7 +139,8 @@
// 获取图片列表
callOtherApi() {
let data = {
deviceId: this.deviceID
deviceId: this.deviceID,
fileType: '2' //文件类型(1:操作说明2:产品参数)
}
fileInfo(data).then((res) => {
if (res.code == 200) {