• uniapp登录页面( 适配:pc、小程序、h5)


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

    参考文章:

    复制了这个博主的大部分html结构和部分css(目前放置的是我初版的样式和代码后续根据业务调整了下,同时为了适配兼容修改成弹性布局及动态宽度)

    uni-app 微信小程序之好看的ui登录页面(一)_微信小程序登录页面-CSDN博客 

    uni-app 微信小程序之好看的ui登录页面(四)_微信小程序 登录页 样式-CSDN博客

  • 相关阅读:
    并发编程 --- 信号量线程同步
    excel中的引用与查找函数篇3
    【产品运营】产品需求应该如何管理
    unable to access xxxx: Failed to connect to xxxx
    Vue中的SSR 服务端渲染技术概述
    C# 异步操作汇总
    【C++初阶学习】第十二弹——stack和queue的介绍和使用
    Feign的简介及使用
    AI时代设计工具Motiff亮相世界互联网大会 带来AI在SaaS领域落地应用案例
    Leetcode刷题287. 寻找重复数
  • 原文地址:https://blog.csdn.net/m0_72196169/article/details/142102228