ToB企服应用市场:ToB评测及商务社交产业平台

标题: uniapp登录页面( 适配:pc、小步伐、h5) [打印本页]

作者: 惊雷无声    时间: 2024-12-12 06:25
标题: uniapp登录页面( 适配:pc、小步伐、h5)


  1. <!-- 简洁登录页面 -->
  2. <template>
  3.         <view class="login-bg">
  4.                 <image class="img-a" src="https://zhoukaiwen.com/img/loginImg/2.png"></image>
  5.                 <image class="img-b" src="https://zhoukaiwen.com/img/loginImg/3.png"></image>
  6.                 <!-- 标题 -->
  7.                 <view class="t-b">{{ title }}</view>
  8.                 <view class="t-b2">欢迎登录</view>
  9.                 <view class="t-login">
  10.                         <form class="cl">
  11.                                 <view class="t-a">
  12.                                         <image src="https://zhoukaiwen.com/img/loginImg/user.png"></image>
  13.                                         <input type="number" name="phone" placeholder="请输入账号" maxlength="11" v-model="phone" />
  14.                                 </view>
  15.                                 <view class="t-a">
  16.                                         <image src="https://zhoukaiwen.com/img/loginImg/pwd.png"></image>
  17.                                         <input type="password" name="code" maxlength="6" placeholder="请输入密码" v-model="pwd" />
  18.                                 </view>
  19.                                 <button @tap="login()">登 录</button>
  20.                                 <view class="t-c">
  21.                                         <text class="t-c-txt" @tap="reg()">注册账号</text>
  22.                                         <text>返回首页</text>
  23.                                 </view>
  24.                         </form>
  25.                         <view class="t-f">
  26.                                 <span :style="{width:width+'px'}"></span>
  27.                                 <text class="qt"> 其他登录方式 </text>
  28.                                 <span :style="{width:width+'px'}"></span>
  29.                         </view>
  30.                         <view class="t-e cl">
  31.                                 <view class="t-g" @tap="wxLogin()">
  32.                                         <image src="https://zhoukaiwen.com/img/loginImg/wx2.png"></image>
  33.                                 </view>
  34.                                 <view class="t-g" @tap="zfbLogin()">
  35.                                         <image src="https://zhoukaiwen.com/img/loginImg/qq2.png"></image>
  36.                                 </view>
  37.                                 <view class="t-g" @tap="zfbLogin()">
  38.                                         <image src="https://zhoukaiwen.com/img/loginImg/wb.png"></image>
  39.                                 </view>
  40.                         </view>
  41.                 </view>
  42.                 <image class="img-a" src="https://zhoukaiwen.com/img/loginImg/bg1.png"></image>
  43.         </view>
  44. </template>
  45. <script>
  46.         export default {
  47.                 data() {
  48.                         return {
  49.                                 title: '数字政务!', //填写logo或者app名称,也可以用:欢迎回来,看您需求
  50.                                 phone: '', //手机号码
  51.                                 pwd: '', //密码
  52.                                 width: ''
  53.                         };
  54.                 },
  55.                 onLoad() {
  56.                         setTimeout(() => {
  57.                                 let query = uni.createSelectorQuery();
  58.                                 query.select('.qt').boundingClientRect()
  59.                                 query.select('.t-f').boundingClientRect()
  60.                                 query.exec((res) => {
  61.                                         console.log("res[0]", res[0]);
  62.                                         console.log("res[1]", res[1])
  63.                                         this.width = ((res[1].width - res[0].width) / 2) - 15
  64.                                 })
  65.                         }, 200)
  66.                 },
  67.                 methods: {
  68.                         //当前登录按钮操作
  69.                         login() {
  70.                                 var that = this;
  71.                                 if (!that.phone) {
  72.                                         uni.showToast({
  73.                                                 title: '请输入手机号',
  74.                                                 icon: 'none'
  75.                                         });
  76.                                         return;
  77.                                 }
  78.                                 if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(that.phone)) {
  79.                                         uni.showToast({
  80.                                                 title: '请输入正确手机号',
  81.                                                 icon: 'none'
  82.                                         });
  83.                                         return;
  84.                                 }
  85.                                 if (!that.pwd) {
  86.                                         uni.showToast({
  87.                                                 title: '请输入密码',
  88.                                                 icon: 'none'
  89.                                         });
  90.                                         return;
  91.                                 }
  92.                                 uni.showToast({
  93.                                         title: '登录成功!',
  94.                                         icon: 'none'
  95.                                 });
  96.                         },
  97.                         //立刻注册
  98.                         reg() {
  99.                                 uni.showToast({
  100.                                         title: '注册账号',
  101.                                         icon: 'none'
  102.                                 });
  103.                         }
  104.                 }
  105.         };
  106. </script>
  107. <style scoped>
  108.         .img-a {
  109.                 position: absolute;
  110.                 width: 100%;
  111.                 top: -150rpx;
  112.                 right: 0;
  113.                 z-index: -1;
  114.         }
  115.         .img-b {
  116.                 position: absolute;
  117.                 width: 50%;
  118.                 bottom: 0;
  119.                 left: -50rpx;
  120.                 z-index: -1;
  121.         }
  122.         .login-bg {
  123.                 max-width: 750px;
  124.                 width: 100vw;
  125.                 min-height: 100vh;
  126.         }
  127.         .t-b {
  128.                 text-indent: 40rpx;
  129.                 font-size: 46rpx;
  130.                 color: #000;
  131.                 padding: 200rpx 0 30rpx 0;
  132.                 font-weight: bold;
  133.         }
  134.         .t-b2 {
  135.                 text-indent: 40rpx;
  136.                 font-size: 32rpx;
  137.                 color: #aaaaaa;
  138.                 padding: 0rpx 0 60rpx 0;
  139.         }
  140.         .t-login {
  141.                 width: 80%;
  142.                 padding: 55rpx;
  143.                 margin: 0rpx auto 0 auto;
  144.                 font-size: 28rpx;
  145.                 z-index: 9;
  146.         }
  147.         .t-login button {
  148.                 font-size: 28rpx;
  149.                 background: linear-gradient(to right, #5677fc, hsla(217 100% 56% / 1));
  150.                 /* background-image: linear-gradient(325deg,
  151.                                 hsla(217 100% 56% / 1) 0%,
  152.                                 hsla(194 100% 69% / 1) 55%,
  153.                                 hsla(217 100% 56% / 1) 90%); */
  154.                 color: #fff;
  155.                 height: 90rpx;
  156.                 line-height: 90rpx;
  157.                 border-radius: 50rpx;
  158.         }
  159.         .t-login input {
  160.                 padding: 0 20rpx 0 120rpx;
  161.                 height: 90rpx;
  162.                 line-height: 90rpx;
  163.                 margin-bottom: 50rpx;
  164.                 background: #f6f6f6;
  165.                 border: 1px solid #f6f6f6;
  166.                 font-size: 28rpx;
  167.                 border-radius: 50rpx;
  168.         }
  169.         .t-login .t-a {
  170.                 position: relative;
  171.         }
  172.         .t-login .t-a image {
  173.                 width: 40rpx;
  174.                 height: 40rpx;
  175.                 position: absolute;
  176.                 left: 40rpx;
  177.                 top: 28rpx;
  178.         }
  179.         .t-login .t-b {
  180.                 text-align: left;
  181.                 font-size: 46rpx;
  182.                 color: #000;
  183.                 padding: 300rpx 0 120rpx 0;
  184.                 font-weight: bold;
  185.         }
  186.         .t-login .t-d {
  187.                 text-align: center;
  188.                 color: #999;
  189.                 margin: 80rpx 0;
  190.         }
  191.         .t-login .t-c {
  192.                 display: flex;
  193.                 justify-content: space-evenly;
  194.                 color: #666666;
  195.                 margin: 30rpx 30rpx 40rpx 0;
  196.         }
  197.         .t-login .t-c .t-c-txt {
  198.                 margin-right: 300rpx;
  199.         }
  200.         .t-login .t-e {
  201.                 text-align: center;
  202.                 width: 80%;
  203.                 margin: 40rpx auto 0;
  204.         }
  205.         .t-login .t-g {
  206.                 float: left;
  207.                 width: 33.33%;
  208.         }
  209.         .t-login .t-e image {
  210.                 width: 70rpx;
  211.                 height: 70rpx;
  212.         }
  213.         .t-login .t-f {
  214.                 width: 100%;
  215.                 display: flex;
  216.                 align-items: center;
  217.                 justify-content: space-between;
  218.                 margin: 80rpx 0 0 0;
  219.                 color: #999;
  220.                 position: relative;
  221.         }
  222.         .t-login .t-f text {
  223.                 color: #b9b9b9;
  224.                 font-size: 27rpx;
  225.         }
  226.         .t-login .t-f span {
  227.                 display: block;
  228.                 background-color: #000;
  229.                 width: auto;
  230.                 height: 1.5rpx;
  231.         }
  232.         .t-login .uni-input-placeholder {
  233.                 color: #aeaeae;
  234.         }
  235.         .cl {
  236.                 zoom: 1;
  237.         }
  238.         .cl:after {
  239.                 clear: both;
  240.                 display: block;
  241.                 visibility: hidden;
  242.                 height: 0;
  243.                 content: '\20';
  244.         }
  245. </style>
复制代码
参考文章:
复制了这个博主的大部门html结构和部门css(现在放置的是我初版的样式和代码后续根据业务调整了下,同时为了适配兼容修改成弹性布局及动态宽度)
uni-app 微信小步伐之好看的ui登录页面(一)_微信小步伐登录页面-CSDN博客 
uni-app 微信小步伐之好看的ui登录页面(四)_微信小步伐 登录页 样式-CSDN博客

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4