使用HBuilderX创建vue,做一个登录界面以及登录后界面

一、项目需求分析与调研

项目需求分析:随着人们生活水平的提高,人们不仅仅满足于对于吃好喝好住好穿好,更重要的是满足于精神的提高,音乐作为人们娱乐的一种方式,成为比较重要的方式之一,在以前,音乐的存储形式表现为磁盘以及磁带,这种方式必须要有DVD和mp3才可以播放,携带不是很方便,为了得到更好的体验,为了得到更好的精神体验,需要一个可以随时随地播放音乐的软件,因此对于酷狗这种软件的出现很是必须。

二、项目原型设计

1.登录界面

2.登录后的界面

三、UI设计

1.登录界面

2.登录后的界面

四、编码

1.登录的login.vue

<template>

  <view>

     <!-- 导航登录 -->

     <view class="one">

        <view class="one-left">

           <uni-icons type="closeempty" size="30"></uni-icons>

        </view>

        <view class="one-right">登录</view>

     </view>

    

     <!-- 账号手机号登录 -->

     <view class="two">

        <view class="two-left">账号登录</view>

        <view class="two-right">手机号登录</view>

     </view>

    

     <!-- 账号密码 -->

     <view class="three">

        <view class="three-b">

           <view class="three-b-left">账号</view>

           <input class="three-b-right" placeholder="手机/酷狗id/邮箱/用户名" :value="usernameVal" @input="inputChangeFun($event, 1)"/>

        </view>

        <view class="three-x">

           <view class="three-x-left">密码</view>

           <input class="three-x-right" placeholder="请输入密码" :value="passwordVal" @input="inputChangeFun($event, 2)"/>

        </view>

     </view>

    

     <!-- 登录按钮 -->

     <view class="four">

        <button class="four-b" @click="loginFun">登录</button>

        <view class="four-x">找回账号</view>

     </view>

    

     <!-- 其他方式登录 -->

     <view class="five">

        <view class="five-z">其他方式登录</view>

     </view>

     <view class="six">

        <view class="six-one">

           <uni-icons class="six-one-b" type="weibo" size="35" style="background-color: orangered; border-radius: 50upx;"></uni-icons>

           <view class="six-one-x">微博</view>

        </view>

        <view class="six-one">

           <uni-icons class="six-one-b" type="qq" size="35" style="background-color: skyblue; border-radius: 50upx;"></uni-icons>

           <view class="six-one-x">QQ</view>

        </view>

        <view class="six-one">

           <uni-icons class="six-one-b" type="weixin" size="35" style="background-color: lightgreen; border-radius: 50upx;"></uni-icons>

           <view class="six-one-x">微信</view>

        </view>

     </view>

  </view>

</template>

<script>

  import account from '../../static/js/account.js'

  let thisDom;

  export default {

     data() {

        return {

           usernameVal: "",

           passwordVal: ""

        }

     },

     onLoad() {

       

     },

     methods: {

        loginFun:function(){

           uni.showLoading({

              title: '登录中'

           });

           //调用panduanFun判断是否为空,不为空的话判断账号密码是否符合自己设定

           let fk = this.panduanFun(this.usernameVal, this.passwordVal);

           console.log(fk)

           //如果为真,判断密码账号是否正确

           if(fk){

              console.log(this.usernameVal)

              console.log(this.username)

              console.log(this.usernameVal !== account.account.username)

              if(this.usernameVal !== account.account.username){

                 uni.showToast({

                   title: '用户名或密码错误',     //提示的内容

                    icon: 'error',

                   duration: 3000

                 });

                 uni.hideLoading();

                 return;

              }

              if(this.passwordVal !== account.account.password){

                 uni.showToast({

                   title: '用户名或密码错误',     //提示的内容

                   icon: 'error',

                   duration: 3000

                 });

                 return;

              }

              setTimeout(function(){

                 uni.hideLoading();

                 uni.showToast({

                   title: '登录成功',     //提示的内容

                    icon: 'none',

                   position:'center'

                 });

                 //保存账号信息,

                 uni.setStorage({

                   key: 'account_key',

                   data: account.account,

                   success: function() {

                      uni.navigateTo({

                         url: './grzx'

                      })

                   }

                 });

              }, 3000);

           }

        },

        panduanFun:function(usernameItem, passwordItem){

           if(usernameItem === null || usernameItem === "" || usernameItem === undefined){

             

              //消息提示框

              uni.showToast({

                 title: '用户名不能为空',    //提示的内容

                 icon: "error",    //显示错误的图标

                 duration: 5000    //提示的延时时间:毫秒

              });

             

              return false;

           }

           if(passwordItem === null || passwordItem === "" || passwordItem === undefined){

             

              //消息提示框

              uni.showToast({

                 title: '密码不能为空',    //提示的内容

                 icon: "error",    //显示错误的图标

                 duration: 5000    //提示的延时时间:毫秒

              }, 1000);

              return false

           }

          

           return true;

        },

       

        inputChangeFun:function(e, num){

           if(num===1){   //监听到用户名的输入

              this.usernameVal = e.detail.value;

           }else if(num===2){    //监听到密码的输入

              this.passwordVal = e.detail.value;

             

           }

        },

     }

  }

</script>

<style lang="scss">

  .one{

     width: 700upx;

     display: flex;

     flex-direction: row;

     height: 80upx;

     margin-left: 25upx;

     .one-left{

        margin-left: 25upx;

        font-size: 65upx;

     }

     .one-right{

        margin-left: 30upx;

        margin-top: 10upx;

        font-size: 50upx;

     }

  }

  .two{

     width: 700upx;

     display: flex;

     flex-direction: row;

     margin-left: 25upx;

     margin-top: 50upx;

     .two-left{

        margin-left: 70upx;

        font-size: 45upx;

        font-weight: 80upx;

     }

     .two-right{

        margin-left: 130upx;

        font-size: 45upx;

        font-weight: 80upx;

     }

  }

  .three{

     width: 700upx;

     background-color: #F2F3F1;

     display: flex;

     flex-direction: column;

     margin-left: 25upx;

     margin-top: 50upx;

     height: 180upx;

     .three-b{

        display: flex;

        flex-direction: row;

        margin-left: 15upx;

        font-size: 40upx;

        height: 80upx;

        border-bottom:1upx solid black;

        .three-b-right{

           margin-top: 5upx;

           margin-left: 15upx;

           font-size: 35upx;

        }

     }

     .three-x{

        margin-top: 20upx;

        display: flex;

        flex-direction: row;

        margin-left: 15upx;

        font-size: 40upx;

        .three-x-right{

           margin-top: 5upx;

           margin-left: 15upx;

           font-size: 35upx;

        }

     }

  }

  .four{

     display: flex;

     flex-direction: column;

     .four-b{

        background-color: #00afff;

        margin-left: 25upx;

        margin-top: 50upx;

        width: 700upx;

        display: flex;

        flex-direction: column;

        align-items: center;

        font-size: 50upx;

        color: #F2F3F1;

        border-radius: 50upx;

     }

     .four-x{

        color: #00afff;

        font-size: 40upx;

        margin-top: 40upx;

        margin-left: 550upx;

     }

  }

  .five{

     width: 700upx;

     font-size: 30upx;

     display: flex;

     flex-direction: row;

     justify-content: center;

     position: fixed;

     bottom: 200upx;

     color: #F2F3F1;

  }

  .six{

     display: flex;

     flex-direction: row;

     width: 700upx;

     margin-left: 5upx;

     justify-content: center;

     height: 100upx;

     position: fixed;

     bottom: 80upx;

     .six-one{

        width: 100upx;

        justify-content: center;

        height: 50upx;

        margin-left: 100upx;

        border-radius: 50upx;

     }

  }

</style>

2.登录后的grzx.vue

<template>

   <view>

          <!-- 导航栏 -->

          <view class="one">

                 <view class="music">音乐</view>

                 <view class="listen">音频</view>

                 <view class="story">小说</view>

                 <view class="icon1">

                        <uni-icons type="more"></uni-icons>

                        <uni-icons type="bars"></uni-icons>

                 </view>

          </view>

          <!-- 搜索框 -->

          <view class="search">

                 <uni-nav-bar color="#333333" backgroundColor="#ffffff">

                        <view class="input-view">

                               <uni-icons class="input-uni-icon" type="search" size="22" color="#66666"></uni-icons>

                               <input confirm-type="search" class="nav-bar-input" type="text" placeholder="输入搜索关键词" />

                        </view>

                 </uni-nav-bar>

                 <uni-icons type="mic-filled"></uni-icons>

          </view>

          <!-- 音乐图的轮播图 -->

          <view>

                 <swiper class="swiper" circular autoplay="true" interval="2000" duration="500">

                        <swiper-item class="swiper-item"><image src="../../static/page/lunbo1.png"></image></swiper-item>

                        <swiper-item class="swiper-item"><image src="../../static/page/lunbo2.png"></image></swiper-item>

                        <swiper-item class="swiper-item"><image src="../../static/page/lunbo3.png"></image></swiper-item>

                        <swiper-item class="swiper-item"><image src="../../static/page/lunbo4.png"></image></swiper-item>

                 </swiper>

          </view>

          <!-- 一些操作 -->

          <view class="two">

                 <view class="two-mode">

                        <text class="iconfont" style="color: #fff; border: 1upx solid #00acd9; background-color: skyblue;">&#xe6e8;</text>

                        <text class="two-mode-text">乐库</text>

                 </view>

                 <view class="two-mode">

                        <text class="iconfont" style="color: #fff; border: 1upx solid #00acd9; background-color: skyblue;">&#xe609;</text>

                        <text class="two-mode-text">猜你喜欢</text>

                 </view>

                 <view class="two-mode">

                        <text class="iconfont" style="color: #fff; border: 1upx solid #00acd9; background-color: skyblue;">&#xe6e9;</text>

                        <text class="two-mode-text">每日推荐</text>

                 </view>

                 <view class="two-mode">

                        <text class="iconfont" style="color: #fff; border: 1upx solid #00acd9; background-color: skyblue;">&#xe611;</text>

                        <text class="two-mode-text">排行榜</text>

                 </view>

                 <view class="two-mode">

                        <text class="iconfont" style="color: #fff; border: 1upx solid #00acd9; background-color: skyblue;">&#xe8a6;</text>

                        <text class="two-mode-text">更多</text>

                 </view>

          </view>

          <!-- 专属推荐 -->

          <view class="three">

                 <view class="three-mode">

                        <view class="three-mode-text">专属推荐</view>

                        <view class="three-mode-one">

                               <text class="iconfont">&#xec8d;</text>

                               <text>选场景</text>

                        </view>

                        <view class="three-mode-two">

                               <text class="iconfont">&#xe608;</text>

                        </view>

                        <view class="three-mode-three">

                               <text class="iconfont">&#xe6e8;</text>

                        </view>

                 </view>

                 <view class="three-mode-image">

                        <view class="three-mode-image-i">

                               <view>

                                      <image src="../../static/page/1.png" style="width: 200upx; height: 200upx;"></image>

                               </view>

                               <text>100首听到失声痛苦的伤感音乐</text>

                        </view>

                        <view class="three-mode-image-i">

                               <view class="three-mode-image-ii">

                                      <image src="../../static/page/2.png" style="width: 200upx; height: 200upx;"></image>

                               </view>

                               <text>民谣歌单:城市的风很大,累了</text>

                        </view>

                        <view class="three-mode-image-i">

                               <view>

                                      <image src="../../static/page/3.png" style="width: 200upx; height: 200upx;"></image>

                               </view>

                               <text>曾经称霸劲舞团的韩语神曲,你</text>

                        </view>

                        <view class="three-mode-image-i">

                               <view>

                                      <image src="../../static/page/4.png" style="width: 200upx; height: 200upx;"></image>

                               </view>

                               <text>曾经称霸劲舞团的韩语神曲,你</text>

                        </view>

                 </view>

          </view>

          <!-- 听歌按钮显示 -->

          <view class="four"></view>

   </view>

</template>

<script>

export default {

   data() {

          return {

                

          };

   },

   methods: {

         

   }

};

</script>

<style lang="scss">

   .one {

          display: flex;

          flex-direction: row;

          width: 700upx;

          height: 150upx;

          line-height: 150upx;

          margin-left: 25upx;

          .music {

                 font-size: 45upx;

          }

          .listen {

                 margin-left: 20upx;

          }

          .story {

                 margin-left: 20upx;

          }

          .icon1 {

                 margin-left: 300upx;

                 size: 50upx;

          }

   }

   .search {

          display: flex;

          flex-direction: row;

          flex-wrap: wrap;

          justify-content: center;

          padding: 0;

          font-size: 14px;

          background-color: #ffffff;

          padding: 0;

   }

   .input-view {

          display: flex;

          flex-direction: row;

          flex: 1;

          background-color: #f8f8f8;

          height: 30px;

          border-radius: 15px;

          flex-wrap: nowrap;

          margin: 7px 0;

          line-height: 30px;

   }

   .input-uni-icon {

          line-height: 30px;

   }

   .uni-nav-bar-text {

          font-size: 14px;

   }

   .nav-bar-input {

          height: 30px;

          line-height: 30px;

          width: 500upx;

          padding: 0 5px;

          font-size: 14px;

          background-color: #f8f8f8;

   }

   .swiper {

          height: 300upx;

   }

   .swiper-item {

          text-align: center;

          height: 100%;

          image {

                 width: 90%;

                 height: 100%;

          }

   }

   .two{

          display: flex;

          flex-direction: row;

          width: 700upx;

          margin-left: 25upx;

          margin-top: 40upx;

          justify-content: space-between;

          .two-mode{

                 display: flex;

                 flex-direction: column;

                 align-items: center;

                 width: 140upx;

                 .iconfont{

                        font-size: 40upx;

                        height: 70upx;

                        line-height: 70upx;

                        width: 70upx;

                        text-align: center;

                        border-radius: 50upx;

                 }

                 .two-mode-text{

                        margin-top: 20upx;

                        font-size: 30upx;

                 }

          }

   }

   .three{

          display: flex;

          flex-direction: column;

          width: 700upx;

          margin-left: 25upx;

          margin-top: 40upx;

          .three-mode{

                 display: flex;

                 flex-direction: row;

                 height: 70upx;

          }

          .three-mode-text{

                 font-size: 40upx;

                 align-items: center;

          }

          .three-mode-one{

                 margin-left: 30upx;

                 background-color: #f8f8f8;

                 border-radius: 10upx;

                 align-items: center;

                 margin-top: 10upx;

          }

          .three-mode-two{

                 margin-left: 250upx;

                 margin-top: 20upx;

          }

          .three-mode-three{

                 margin-left: 25upx;

                 margin-top: 20upx;

          }

          .three-mode-image{

                 display: flex;

                 flex-direction: row;

                 flex-wrap: wrap;

                 width: 700upx;

                 .three-mode-image-i{

                        display: flex;

                        flex-direction: column;

                        margin-left: 20upx;

                        width: 200upx;

                        .three-mode-image-ii{

                               display: flex;

                               flex-direction: row;

                        }

                 }

                

          }

   }

</style>

五、测试

1.登录界面

2.当只输入密码不输入账号的时候,点击登录,就会出现用户名不能为空的弹窗

3.当只输入账号,不输入密码的时候,点击登录,就会出现密码不能为空的弹窗

4.当输入账号和密码错误的时候,就会弹出用户名或密码错误的界面

5.当输入账号和密码正确的时候,就会进入酷狗的首页,账号为xiaodu,密码为123456

6.当账号和密码正确的时候,就会跳转到酷狗的首页

7.可以看见中间使用了一个轮播图

  • 49
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 我可以回答这个问题。首先,你需要下载并安装 Node.js。然后,你可以在命令行中使用 npm install -g @vue/cli 命令来安装 Vue CLI。接下来,你可以在 HBuilderX创建一个 Vue 项目,然后开始开发。希望这可以帮助你。 ### 回答2: HBuilderX是一款功能强大的集成开发环境,可用于开发各种前端项目,包括Vue.js项目。 安装Vue.js项目的步骤如下: 1. 首先,确保已经成功安装并打开HBuilderX。 2. 在HBuilderX界面的左侧导航栏中找到“插件市场”选项,点击打开。 3. 在搜索框中输入“Vue”,然后按下Enter键进行搜索。HBuilderX将显示与Vue.js相关的插件列表。 4. 从列表中选择一个Vue.js插件,比如“Vue Language Support”或“VueHelper”,然后点击“安装”按钮。 5. 安装完成后,HBuilderX会自动为你安装Vue.js相关的依赖项。 6. 在你的项目中,新建一个Vue.js的文件(如.vue文件),HBuilderX将会自动识别并设置合适的语法高亮和代码提示。 7. 如果你的项目中已经有了Vue.js相关的依赖项,你可以通过在项目的目录中右键点击“工具”->“集成控制台”来执行相关的命令,如安装依赖、运行项目等。 总结: 通过HBuilderX的插件市场,我们可以方便地安装Vue.js相关的插件,然后在项目中使用Vue.js进行开发HBuilderX提供了丰富的功能,包括语法高亮、代码提示、依赖管理等,使得我们可以更加高效地进行Vue.js项目的开发。在项目中,我们可以通过集成控制台执行相关的命令,如安装依赖、运行项目等。 ### 回答3: 要在HBuilderX中安装Vue,您可以按照以下步骤操作: 1. 打开HBuilderX编辑器,点击菜单栏中的「工具」选项。 2. 在弹出的下拉菜单中,选择「插件管理器」。 3. 在插件管理器中的搜索栏中,输入「Vue」,并点击搜索按钮。 4. 在搜索结果列表中,找到「Vue for HBuilderX」插件,并点击「安装」按钮。 5. 安装完成后,关闭插件管理器。 安装Vue插件后,您可以在HBuilderX中进行Vue项目的开发和管理。以下是一些使用Vue插件的常见功能: 1. 创建Vue项目:在HBuilderX中,您可以通过选择「菜单栏 > 文件 > 新建 > Vue项目」来创建一个新的Vue项目。填写项目名称和保存路径后,点击「确定」即可创建项目。 2. Vue语法提示:在Vue项目中,HBuilderX的代码编辑器会提供Vue语法提示功能,以帮助您更方便地编写Vue代码。 3. Vue组件预览:在HBuilderX中,您可以使用「菜单栏 > 工具 > Vue组件预览」来预览Vue组件的效果。 4. 项目构建与打包:使用HBuilderX,您可以通过「菜单栏 > 发布 > Uni-app > 运行到小程序模拟器」等选项来进行Vue项目的构建、打包和发布。 通过以上步骤,您可以轻松安装Vue插件并在HBuilderX中开展Vue项目的开发工作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值