uniapp学习-登录/注册页面搭建

1.创建路由

2.页面搭建

点击登录/注册切换页面

效果:

代码:

<style lang="scss">
  .container {
    font-family: PingFangSC, PingFang SC;
  }

  .top {
    position: relative;
    left: 0;
    top: 0;

    .title {
      display: inline-block;
      width: 440rpx;
      padding: 3rpx;
      color: #ffffff;
      font-size: 44rpx;
      line-height: 62rpx;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }

  .box {
    width: 100%;
    display: flex;
    justify-content: center;

    .main {
      position: relative;
      width: 670rpx;
      height: 590rpx;
      background-color: #ffffff;
      box-shadow: 0px 0px 9px 0px rgba(10, 53, 74, 0.19);
      border-radius: 40rpx;
      margin-top: -150rpx;
    }
  }

  .box2 {
    width: 100%;
    padding: 39rpx;
    display: flex;
    align-items: center;

    view {
      margin-right: 50rpx;
      font-size: 28rpx;
      color: #999999;
      line-height: 40rpx;
      font-weight: 600;
    }

    .active {
      font-size: 46rpx;
      font-weight: 600;
      color: #333333;
      line-height: 65rpx;
    }

    .line {
      width: 100%;
      height: 6rpx;
      background: linear-gradient(122deg, #2AB1E7 0%, #51B1FF 100%);
      border-radius: 3rpx;
      position: relative;
      left: 0;
      top: 0;

      .y {
        width: 30rpx;
        height: 30rpx;
        background: rgba(0, 145, 255, 0.2);
        border-radius: 15rpx;
        position: absolute;
        right: -15rpx;
        top: -15rpx;
        margin-right: 0;
      }
    }
  }

  .box3 {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .items {
      width: 550rpx;
      height: 92rpx;
      background: #F8F8F8;
      border-radius: 10rpx;
      display: flex;
      align-items: center;
      padding: 0 30rpx;
    }

    .uni-input-placeholder {
      color: #C7D4DD;
    }

    .uni-input {
      flex: 1;
      font-size: 26rpx;
      font-weight: 400;
      color: #333333;
      line-height: 37rpx;
    }

    .input2 {
      width: 200rpx;
      flex: none;
    }

    .yzm {
      font-size: 22rpx;
      font-weight: 400;
      color: #0087C9;
      line-height: 30rpx;
      padding: 6rpx 25rpx;
      border-left: 1rpx solid #C7D4DD;
    }
  }

  .submitValue {
    width: 56rpx;
    height: 32rpx;
    font-size: 28rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 32rpx;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -0);
  }
</style>

 3.逻辑

 页面

<template>
  <view class="container">
    <view class="top">
      <image src="../static/login/login.png" mode="widthFix" style="width: 100%;"></image>
      <text class="title">泡面dididid管理系统</text>
    </view>
    <view class="box">
      <view class="main">
        <view class="box2">
          <view :class="navId=='login'?'active':'unactive'" @click="itemclick('login')">登录
            <view class="line" v-show="navId=='login'">
              <view class="y"></view>
            </view>
          </view>
          <view :class="navId=='register'?'active':'unactive'" @click="itemclick('register')">注册
            <view class="line" v-show="navId=='register'">
              <view class="y"></view>
            </view>
          </view>
        </view>
        <!-- 登录 -->
        <view class="box3" v-show="navId=='login'">
          <view class="items">
            <uni-icons type="person" size="20" style="margin-right:16rpx ;color: #C7D4DD;"></uni-icons>
            <input class="uni-input" focus placeholder="请输入账号" v-model="submitParams.username" />
          </view>
          <view class="items" style="margin-top: 30rpx;justify-content: space-between;">
            <view class="" style="display: flex;justify-content: center;">
              <image src="../static/login/lock.png" mode="widthFix" style="width: 40rpx;margin-right:16rpx ;"></image>
              <input class="uni-input input2" placeholder="请输入验证码" v-model="submitParams.yzm">
            </view>
            <view class="yzm" @click="getYZM(yanzhengma)">{{yanzhengma}}</view>
          </view>
          <view class="" style="position: relative;left: 0;top: 0;" @click="login()">
            <image src="../static/login/submit1.png" mode="widthFix" style="width: 550rpx;margin-top: 40rpx;"></image>
            <text class="submitValue">确认</text>
          </view>

        </view>
        <!-- 注册 -->
        <view class="box3" v-show="navId=='register'">
          注册
        </view>
      </view>
    </view>
    <view class="" style="width: 100%;text-align: center;font-size: 24rpx;line-height: 33rpx;margin-top: 93rpx;">
      登录即同意 <text style="color: #1C85C8;"> <text @click="userText">用户协议</text>、<text
          @click="SecretText">隐私协议</text></text>
    </view>
  </view>
</template>

逻辑

<script>
  export default {
    data() {
      return {
        navId: 'login',
        yanzhengma: '获取验证码',
        submitParams: {
          username: "",
          yzm: ""
        },
        token: "",
      };
    },
    mounted() {
      // 判断登录状态。已登录就跳转到首页
      this.getToken();
      if (this.token != '' && this.token != null) {
        // 跳转主页
        uni.navigateTo({
          url: '/pages/home'
        });
      } else {
        this.getAccount();
      }
    },
    methods: {
      saveToken(token) {
        // 本地缓存存储token
        uni.setStorageSync('token', token);
      },
      getToken() {
        // 本地缓存获取token
        this.token = uni.getStorageSync('token');
      },
      saveAccount() {
        // 本地缓存存储
        uni.setStorageSync('username', this.submitParams.username);
      },
      getAccount() {
        // 本地缓存获取
        let username = uni.getStorageSync('username');
        if (username && username != '') {
          this.submitParams.username = username;
        }
      },
      //切换登录or注册
      itemclick(value) {
        this.navId = value
      },
      //获取验证码
      getYZM(yzm) {
        if (this.yanzhengma == '获取验证码') {
          //调接口
          let time = 60
          let timer = setInterval(() => {
            this.yanzhengma = `( ${time--} )`
            if (time == -1) {
              clearInterval(timer)
              this.yanzhengma = '获取验证码'
            }
          }, 1000)
        }
      },
      //登录
      login() {
        const params = this.submitParams
        if (params.username == '' || params.username == null) {
          uni.showToast({
            title: '请输入账号',
            icon: 'none',
            duration: 2000
          })
        } else if (params.yzm == '' || params.yzm == null) {
          uni.showToast({
            title: '请输入验证码',
            icon: 'none',
            duration: 2000
          })
        } else {
          // 调用登录接口
          // 调用成功后执行下述
          const res = {
            roken: '1234567890'
          }
          this.saveToken(res.token)
          this.saveAccount();
          // 跳转路由
          uni.navigateTo({
            url: '/pages/home'
          });
          console.log('登录成功')
        }
      },
      //用户协议
      userText() {
        // 跳转
      },
      //隐私协议
      SecretText() {
        //跳转
      }
    }
  }
</script>

 样式

<style lang="scss">
  .container {
    font-family: PingFangSC, PingFang SC;
  }

  .top {
    position: relative;
    left: 0;
    top: 0;

    .title {
      display: inline-block;
      width: 440rpx;
      padding: 3rpx;
      color: #ffffff;
      font-size: 44rpx;
      line-height: 62rpx;
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
    }
  }

  .box {
    width: 100%;
    display: flex;
    justify-content: center;

    .main {
      position: relative;
      width: 670rpx;
      height: 590rpx;
      background-color: #ffffff;
      box-shadow: 0px 0px 9px 0px rgba(10, 53, 74, 0.19);
      border-radius: 40rpx;
      margin-top: -150rpx;
    }
  }

  .box2 {
    width: 100%;
    padding: 39rpx;
    display: flex;
    align-items: center;

    view {
      margin-right: 50rpx;
      font-size: 28rpx;
      color: #999999;
      line-height: 40rpx;
      font-weight: 600;
    }

    .active {
      font-size: 46rpx;
      font-weight: 600;
      color: #333333;
      line-height: 65rpx;
    }

    .line {
      width: 100%;
      height: 6rpx;
      background: linear-gradient(122deg, #2AB1E7 0%, #51B1FF 100%);
      border-radius: 3rpx;
      position: relative;
      left: 0;
      top: 0;

      .y {
        width: 30rpx;
        height: 30rpx;
        background: rgba(0, 145, 255, 0.2);
        border-radius: 15rpx;
        position: absolute;
        right: -15rpx;
        top: -15rpx;
        margin-right: 0;
      }
    }
  }

  .box3 {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .items {
      width: 550rpx;
      height: 92rpx;
      background: #F8F8F8;
      border-radius: 10rpx;
      display: flex;
      align-items: center;
      padding: 0 30rpx;
    }

    .uni-input-placeholder {
      color: #C7D4DD;
    }

    .uni-input {
      flex: 1;
      font-size: 26rpx;
      font-weight: 400;
      color: #333333;
      line-height: 37rpx;
    }

    .input2 {
      width: 200rpx;
      flex: none;
    }

    .yzm {
      font-size: 22rpx;
      font-weight: 400;
      color: #0087C9;
      line-height: 30rpx;
      padding: 6rpx 25rpx;
      border-left: 1rpx solid #C7D4DD;
    }
  }

  .submitValue {
    width: 56rpx;
    height: 32rpx;
    font-size: 28rpx;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    color: #FFFFFF;
    line-height: 32rpx;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -0);
  }
</style>

组件应用

1. image组件

官网地址:https://uniapp.dcloud.net.cn/component/image.html#image

属性:

mode 有 14 种模式,其中 5 种是缩放模式,9 种是裁剪模式:

 

2.input

官网地址input | uni-app官网 (dcloud.net.cn)

 

3.icon

官网地址:uni-icons 图标 | uni-app官网 (dcloud.net.cn)

  • 14
    点赞
  • 81
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
回答: 面试中经常会问到线程和进程的区别。进程是指一个运行中的程序,它在计算机中拥有独立的内存空间和系统资源,可以进行通信、同步和竞争,并在某些情况下可能出现死锁。而线程是进程中的执行上下文或执行序列,它是为了实现在CPU上同时执行多个任务而引入的概念。与进程不同的是,线程共享进程的内存空间,可以方便地进行通信。\[3\]进程与线程的区别还可以从内存结构、通信方式等方面进行深入探讨。进程与进程之间不能共享内存,而线程可以共享进程的内存空间。进程之间的通信相对不方便,而线程之间的通信更加方便。进程之间的通信方式包括管道、消息队列、共享内存等,而线程之间的通信可以直接通过共享内存进行。不同的通信方式有各自的优劣点,需要根据具体的场景来选择合适的方式。\[2\]了解这些内容可以帮助你更好地回答面试中关于线程和进程的区别的问题。 #### 引用[.reference_title] - *1* *2* *3* [面试高频题:线程与进程的区别](https://blog.csdn.net/J_avaSmallWhite/article/details/111320085)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down28v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值