基于vue实现bilibili网页

学校要求的实验设计,基于vue实现bilibili网页版,可实现以下功能

(1)基本的悬浮动画和页面渲染

(2)可实现登录和未登录的页面变化

(3)在登录页面的,实现密码判断,或者短信验证方式的倒数功能

(4)实现轮播图

(5)实现预览视频(GIF)

(6)页面下拉到一定高度出现top栏以及右下角的返回功能

由于篇幅,代码较长,本文仅罗列一些基本代码,要源码的伙伴直接在本文评论即可

1.基本页面

1.1未登录

1.2已登录

以下是基本框架代码

css 复制代码
<template>
  <div id="App">
    <el-container>
      <!--登录框-->
      <EntryBox :isEntry="isEntry" @changeIsEntry_EB="handleChangeIsEntry" :qcImg="qcImg" :hasLogin="hasLogin"
        @changeIsLogin="changeIsLogin_Eb"></EntryBox> 
      <MoveTop :isEntry="isEntry" @changeIsEntry="handleChangeIsEntry" :hasLogin="hasLogin"
        @changeIslogin="changeIsLogin" v-if="isTopShow"></MoveTop>
      <!--头部-->
      <el-header>
        <NavBar :isEntry="isEntry" @changeIsEntry="handleChangeIsEntry" :hasLogin="hasLogin"
        @changeIslogin="changeIsLogin"></NavBar>
        <!--头部背景-->
        <div class="banner">
          <img src="./assets/img/bac.png" alt="" />
        </div>
      </el-header>
      <!-- 主体 -->
      <el-main>
       <TabBox></TabBox>
        <MainTop></MainTop>
        <MainBottom></MainBottom>
      </el-main>
      <BottomBox v-if="bottomShow"></BottomBox>
    </el-container>
  </div>
</template>

2.登录页面

2.1实现锁定密码框时,左右下角图片的变化

css 复制代码
<img src="../assets/img/login_L.png" alt="" class="e-l-img" v-if="isFocus">
            <img src="../assets/img/closeL.png" alt="" class="e-l-img" v-else>
            <img src="../assets/img/login_R.png" alt="" class="e-r-img" v-if="isFocus">
            <img src="../assets/img/closeR.png" alt="" class="e-r-img" v-else>

利用v-if即可,在获得输入框获得焦点时候,让isFocus相对应变化即可

2.2自由切换短信/密码登录

利用点击事件切换对应变量的值即可

html 复制代码
<el-form labor-width="150px" class="entry_Form" v-if="EntryMethod === 'mima'">
                <el-form-item label="账号" class="userInput">
                  <el-input placeholder="请输入账号" v-model="UserNameInput"></el-input>
                </el-form-item>
                <el-form-item label="密码" class="passInput" 
                >
                  <el-input placeholder="请输入密码" @focus="isFocus=false" @blur="isFocus=true" ref="PassInput"  :type="inputType" v-model="passWordInput" @keyup.enter.native="handleLogin"></el-input>
                  <div class="p-right" v-if="!isCheck">
                    <span><i class="iconfont icon-chakanmima" @mousedown.prevent="handleEyeClose"></i></span>
                    <a href="javascript:;">忘记密码?</a>
                  </div>
                  <div class="p-right" v-else>
                    <span><i class="iconfont icon-chakanmima1" @mousedown.prevent="handleEyeOpen"></i></span>
                    <a href="javascript:;">忘记密码?</a>
                  </div>
                </el-form-item>
              </el-form>
              <el-form labor-width="150px" class="entry_Form" v-else>
                <el-form-item label="+86" class="userInput">
                  <el-input placeholder="请输入手机号" v-model="PhoneNumInput"></el-input>
                  <el-divider class="en-divider" direction="horizontal"></el-divider>
                  <el-button :disabled="(!isPhoneNumberValid ) || (downCount !== 0)" @click="handleGetCaptcha">{{ GetButtonText }}</el-button>
                </el-form-item>
                <el-form-item label="验证码" class="passInput" >
                  <el-input placeholder="请输入验证码" @focus="isFocus=false" @blur="isFocus=true" ref="passwordInput" v-model="CaptchaInput" @keyup.enter.native="handleLoginByCaptcha"></el-input>
                </el-form-item>
              </el-form>

2.3只有当手机号输入为11位数字的时候,按钮才启动

2.4对应的错误提示弹框

javascript 复制代码
 handleLoginByCaptcha(){
        if(this.CaptchaInput === '12345'){
          this.UserNameInput = ''
        this.passWordInput = ''
        this.$emit('changeIsLogin',true)
        this.handleClick_entryBox()
        clearInterval(this.timer_ET);
        this.downCount = 0
        }else if(this.CaptchaInput === ''){
          this.getErrorShowText = '请输入验证码'
          this.passWordError = true
          setTimeout(() => {
            this.passWordError = false;
          },1000)
        }else{
          this.getErrorShowText = '验证码错误'
          this.passWordError = true
          setTimeout(() => {
            this.passWordError = false;
          },1000)
        }
      },
      handleGetCaptcha(){
        if (!(/^\d{11}$/.test(this.PhoneNumInput))) {
          this.getErrorShowText = '请输入正确的手机号'
          this.passWordError = true
          setTimeout(() => {
            this.passWordError = false;
          },1000)
        return;
    }

2.5获取验证码倒计时

javascript 复制代码
 startCountDown(){
        this.downCount = 60;
        this.timer_ET = setInterval(() => {
          if(this.downCount > 0){
            this.downCount--;
          }else{
            clearInterval(this.timer_ET);
            this.timer_ET = null
          }
        },1000)
      },

3.底部右下角

3.1悬浮展开

3.2点击回到顶部

javascript 复制代码
 <div class="backBox" @click="scrollToTop">
        <i class="iconfont icon-jiantou_down"></i>
        <div>顶部</div>
    </div>
javascript 复制代码
scrollToTop() {
      window.scrollTo(0, 0);
    },

4.总结

还有其他功能由于篇幅问题就不全部展示,需要源码的伙伴直接文字评论即可

相关推荐
我狸才不是赔钱货8 分钟前
前端技术栈全景图:从HTML到现代框架的演进之路
前端·html
百花~36 分钟前
前端三剑客之一 HTML~
前端·html
lang201509281 小时前
Spring远程调用与Web服务全解析
java·前端·spring
Sheldon一蓑烟雨任平生2 小时前
Vue3 依赖注入(provide 和 inject)
vue.js·inject·provide·vue3 依赖注入·跨级别组件通信
listhi5203 小时前
利用React Hooks简化状态管理
前端·javascript·react.js
paopaokaka_luck3 小时前
基于SpringBoot+Vue的助农扶贫平台(AI问答、WebSocket实时聊天、快递物流API、协同过滤算法、Echarts图形化分析、分享链接到微博)
java·vue.js·spring boot·后端·websocket·spring
一点一木3 小时前
🚀 2025 年 10 月 GitHub 十大热门项目排行榜 🔥
前端·人工智能·github
华仔啊4 小时前
这个Vue3旋转菜单组件让项目颜值提升200%!支持多种主题,拿来即用
前端·javascript·css
非凡ghost4 小时前
Adobe Lightroom安卓版(手机调色软件)绿色版
前端·windows·adobe·智能手机·软件需求
Sheldon一蓑烟雨任平生4 小时前
Vue3 重构待办事项(主要练习组件化)
vue.js·重构·vue3·组件化练习