首页 > 其他分享 >2024.4.26日团队开发第七天

2024.4.26日团队开发第七天

时间:2024-05-21 17:19:30浏览次数:14  
标签:26 2024.4 title url 100px height width uni 第七天

学习时间 1h
代码行数 50行
博客量 1篇
学习内容 主要完成了视频发布页面的展示代码
<template>
    
    <view style="height: 700px;" >
        <view class="blank"></view>
        <cu-custom bgColor="bg-black" :isBack="true">
            <block slot="backText">返回</block>
            <block slot="content">视频上传</block>
        </cu-custom>
        <view>
            <textarea placeholder="添加作品描述" v-model="information.description">
                
            </textarea>
        </view>

        <view class="flex-wrap">
            <view class="ver-mid">
                <text>
                    请选择视频的封面
                </text>
            </view>
            <view class="selected_img" v-if="imagesrc">
                <view class="uploader_img">
                    <image class="vid" :src="imagesrc" controls="false"></image>
                    <view class="icon_delete_img" @tap="delectImage">×</view>
                </view>    
            </view>
            <view class="select_viedo_border">
                    <image class="select_pic"  @tap="selectCover"  src="../../static/img/sel.png"></image>
            </view>
        </view>
        
        <view class="flex-wrap">
            <view class="ver-mid">
                <text >
                    请选择要上传的视频
                </text>
            </view>
            <view class="selected_viedo" v-if="videosrc">
                <view class="uploader_video">
                    <video class="vid" :src="videosrc" controls="false"></video>
                    <view class="icon_delete_video" @tap="delectVideo">×</view>
                </view>    
            </view>
            <view class="select_viedo_border">
                    <image class="select_pic"  @tap="selectVideo"  src="../../static/img/sel.png"></image>
            </view>
        </view>
        
        
        
        
        <button @click="uploadmes" size="default">上传</button> 
    </view>
</template>
<script>
    export default {
        data() {
            return {
                imagesrc: '',//本地图片的地址
                videosrc:'',//本地视频的地址
                information:{
                    userid:'1',//用户的id
                    description:'',//视频的描述信息
                    cover_url:'',//视频封面url
                    video_url: '',//视频的url
                }
            }
        },
        methods: {
            selectCover:function(){
                var self=this;
                uni.chooseImage({
                    count:1,
                    sizeType: ['original', 'compressed'],
                    success:function(res){
                        self.imagesrc=res.tempFilePaths[0];
                        uni.uploadFile({
                            url: 'http://192.168.179.215:8085/upload', //上传地址
                            name: 'file',
                            filePath:self.imagesrc,
                            success:function(uploadRes){
                                console.log(uploadRes);
                                self.information.cover_url=uploadRes.data;
                                uni.showToast({
                                    title: '上传成功'
                                });
                            },
                            fail:function(error){
                                console.log(error);
                                uni.showToast({
                                    title: '上传失败'
                                });
                            },
                        });
                    }
                });
            },
            selectVideo: function() {
                var self = this;
                uni.chooseVideo({
                    sourceType: ['album'],
                    success: function(res) {
                    self.videosrc = res.tempFilePath;
                    uni.uploadFile({
                            url: 'http://192.168.179.215:8085/upload', //上传地址
                            name: 'file',
                            filePath: self.videosrc,
                            success: function(uploadRes) {
                                console.log(uploadRes);
                                self.information.video_url=uploadRes.data;
                                uni.showToast({
                                    title: '上传成功'
                                });
                            },
                            fail: function(error) {
                                // 上传失败处理逻辑
                                console.log(error);
                                uni.showToast({
                                    title: '上传失败'
                                });
                            },
                    });    
                    },
                });
            },
            delectVideo: function() {
                uni.showModal({
                    title:"提示",
                    content:"是否要删除此视频",
                    success:(res) =>{
                        if(res.confirm){
                            this.videosrc = '';
                            this.information.video_url=''
                        }
                    }
                })
            },
            delectImage: function() {
                uni.showModal({
                    title:"提示",
                    content:"是否要删除此封面图片",
                    success:(res) =>{
                        if(res.confirm){
                            this.imagesrc = '';
                            this.information.cover_url=''
                        }
                    }
                })
            },
            uploadmes:function()
            {
                console.log(this.information);
                if(this.information.video_url==='')
                {
                    uni.showToast({
                        title:"视频不能为空",
                        icon:'error',
                    });
                    return;
                }
                if(this.information.cover_url==='')
                {
                    uni.showToast({
                        title:"封面不能为空",
                        icon:'error',
                    });
                    return;
                }
                if(this.information.description==='')
                {
                    uni.showToast({
                        title:"视频描述不能为空",
                        icon:'error',
                    });
                    return;
                }
                uni.request({
                    method:"POST",
                    url:'http://192.168.179.215:8085/mesupload',
                    data:this.information,
                    success: (res) => {
                        console.log(res.data);
                        uni.showToast({
                            title:"视频上传成功",
                        });
                        uni.switchTab({
                            url:"/pages/index/index"
                        })
                    },
                    fail() {
                        uni.showToast({
                            title:"视频上传失败",
                            icon:'error',
                        });
                    }
                })
            }
        },
    }
</script>

<style lang="scss">
    
    .flex-wrap{
        margin: 5px;
          display: flex;
          flex-wrap: wrap;
    }
    .selected_viedo 
    {
        width: 100px;
        height: 100px;
        position: relative;
    }
    .uploader_video{
        margin-left: 5px;
        width: 100px;
        height: 100px;
    }
    .icon_delete_video{
        position:absolute;
        top: 1px;
        right: 1px;
        background-color: #888;
        color: #fff;
        border-radius: 50%;
        width: 10px;
        height: 10px;
        font-size: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .selected_img 
    {
        width: 100px;
        height: 100px;
        position: relative;
    }
    .uploader_img{
        margin-left: 5px;
        width: 100px;
        height: 100px;
    }
    .icon_delete_img{
        position:absolute;
        top: 5px;
        right: 5px;
        background-color: #888;
        color: #fff;
        border-radius: 50%;
        width: 10px;
        height: 10px;
        font-size: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .vid {
        margin-left: 6px;
        margin-top: 6px;
        width: 88px;
        height: 88px;
        border-radius: 10%;
    }
    .select_viedo_border{
        margin-left: 5px;
        height: 100px;
        width: 100px;
        border:2px solid #000000;
        border-radius: 10px;
    }
        
    .select_pic{
        height: 80px;
        width: 80px;
        opacity: 0.6;
        display: block;
        margin: 0 auto;
        margin-top: 10px;
    }
    .ver-mid{
        height: 100px;
        width: 100px;
        font-size: 20px;
        text-align: center;
        line-height: 30px;
        margin-top: 20px;
    }
    textarea{
        margin-left: 5px;
        width: 360px;
        height: 170px;
        border-radius: 10px;
        border: 1px solid #000000;
    }
    textarea:-ms-input-placeholder{
        color: #000000;
    }
    .blank{
        height: 20px;
        opacity: 1;
    }
    button{
        height: 50px;
        width: 180px;
        border-radius: 10px;
        text-align:center;
        border: 1px solid #000000;
    }
</style>

 

   

标签:26,2024.4,title,url,100px,height,width,uni,第七天
From: https://www.cnblogs.com/dmx-03/p/18204564

相关文章

  • 软件工程日报026
     第26天第二天第三天第四天第五天所花时间(包括上课) 3h    代码量(行) 400    博客园(篇) 1    所学知识 vue的基本内容    ......
  • esp8266-01 使用介绍
    一、直接使用接线esp8266USB转TTl说明TXRX------RXTX------EN3.3V  AT命令需要拉高------3V33.3V------IO0不接IO0接地进入烧录模式GNDGND------二、固件烧写前提说明一般是模块固件损坏或者买回来里面可能被别人刷过固件需要擦除或者......
  • ESP8266串口WiFi模块 - WiFi杀手
    Tips:当你看到这个提示的时候,说明当前的文章是由原emlog博客系统搬迁至此的,文章发布时间已过于久远,编排和内容不一定完整,还请谅解`ESP8266串口WiFi模块-WiFi杀手日期:2020-2-3阿珏折腾代码浏览:2635次评论:21条前段时间买了个ESP8266,准备拿来耍耍。实际吃灰数月,然后就拖到......
  • 二叉树 | 迭代法 102.二叉树的层序遍历 429. N 叉树的层序遍历 226.翻转二叉树
    leetcode102.二叉树的层序遍历题目102.二叉树的层序遍历给你二叉树的根节点root,返回其节点值的层序遍历。(即逐层地,从左到右访问所有节点)。解题思路实现代码classTreeNode:def__init__(self,val=0,left=None,right=None):self.val=valse......
  • HTML 26 - Head Element
     TheHTMLheaderTheheaderpartofanHTMLdocumentisrepresentedbythe<head>tag.Itserveasacontainerofvariousotherimportanttagslike<title>,<meta>,<link>,<base>,<style>,<script>,and<nosc......
  • Weblogic T3反序列化漏洞(CVE-2018-2628)
    目录前言T3协议概述漏洞复现修复方案前言WebLogicServer是一个企业级的应用服务器,由Oracle公司开发,支持完整的JavaEE规范,包括EJB、JSP、Servlet、JMS等,适合大型分布式应用和高负载场景。T3协议概述T3协议(Two-TierTCP/IPProtocol),是WebLogic中的一种专有协议,建立在TCP/IP协......
  • CVE-2018-2628
    WeblogicWLSCoreComponents反序列化命令执行漏洞(CVE-2018-2628)Oracle2018年4月补丁中,修复了WeblogicServerWLSCoreComponents中出现的一个反序列化漏洞(CVE-2018-2628),该漏洞通过t3协议触发,可导致未授权的用户在远程服务器执行任意命令。漏洞环境cdweblogic/CVE-2018-2......
  • 基于LoRa的智慧农业解决方案--ASR6601、SX1278、SX1262
    我国《数字乡村发展战略纲要》明确指出“要推进农业数字化转型”,加快推广云计算、大数据、物联网、人工智能在农业生产经营管理中的运用。然而,目前我国的农业数字化转型还面临着诸多挑战。我国整体农业机械化程度和自动化控制水平仍然较低。由于农田面积广袤,大量的区域没有信......
  • 【django学习-26】图片验证码
    1.我们在登录的时候,经常看到输入用户名、密码之外。还需要输入验证码。这个验证码是怎么实现的呢?2.前端{%loadstatic%}<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><linkrel="styleshee......
  • 264 ugly number II 丑数
    问题描述Anuglynumberisapositiveintegerwhoseprimefactorsarelimitedto2,3,and5.Givenanintegern,returnthenth*uglynumber*.解释:一个丑数是一个正整数,其公因子只有2,3,5。给定数字n,求第n个丑数案例:Input:n=10Output:12Explanation:[1,2,......