当前位置:   article > 正文

HBuilderX uni-app简单实现静态登录页面(实例)_uniapp登录页面模板

uniapp登录页面模板

本章用到......uni-app页面跳转uni.navigateTo方法、uni.navigateBack方法。uni-app简单实现邮箱验证码发送点击后读秒样式。登录账号、密码正则表达式验证等

适合刚入门的小伙伴,大佬就没必要看了

静态页面!静态页面!没有绑定后端数据接口

目录

一、HBuilderX下载

二、创建uni-app项目

pages.json配置文件

三、登录页面

 login.vue页面

login.css文件

四、手机短信验证页面

 phoneVerify.vue页面

 phoneVerify.css文件

五、找回密码页面

findBack.vue页面

findBack.css文件

六、邮箱找回密码页面

 mailFandBack.vue页面

mailFandBack.css文件

七、邮箱发送验证成功页面

 emailFinish.vue页面

emailFinish.css文件


一、HBuilderX下载

https://dcloud.io/hbuilderx.html

 官网直接下载解压即可

二、创建uni-app项目

文件-新建-项目

 我这里直接选择默认模板,Vue版本、uniCloud自行选择即可

 创建完成后自动生成文件夹

 文件名这里自动生成原本是index,文件名自行定义即可

页面文件自己新建Vue文件即可

pages.json配置文件

注意!!这个文件后续如果需要新添加新页面时这个文件里一定要配置参数不然页面出不来,代码格式看下面代码↓↓↓↓↓↓↓↓↓

  1. {
  2. // 设置单页面
  3. "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
  4. {
  5. "path": "pages/login/login",
  6. "style": {
  7. // 设置顶部导航栏
  8. "navigationBarTitleText": "",
  9. "navigationBarBackgroundColor": "#FFFFFF"
  10. }
  11. },
  12. {
  13. "path": "pages/login/findBack",
  14. "style": {
  15. "navigationBarTitleText": "找回密码"
  16. }
  17. },
  18. {
  19. "path": "pages/login/mailFindBack",
  20. "style": {
  21. "navigationBarTitleText": "邮箱找回密码"
  22. }
  23. },
  24. {
  25. "path": "pages/login/phoneVerify",
  26. "style": {
  27. "navigationBarTitleText": "",
  28. "navigationBarBackgroundColor": "#FFFFFF"
  29. }
  30. },
  31. {
  32. "path": "pages/login/emailFinish",
  33. "style": {
  34. "navigationBarTitleText": ""
  35. }
  36. }
  37. {
  38. //新添加的Vue页面配置!!!
  39. "path": "",
  40. "style": {
  41. "navigationBarTitleText": ""
  42. }
  43. }
  44. ],
  45. // 设置全部页面
  46. "globalStyle": {
  47. "navigationBarTextStyle": "black",
  48. "navigationBarTitleText": "uni-app",
  49. "navigationBarBackgroundColor": "#F8F8F8",
  50. "backgroundColor": "#F8F8F8"
  51. },
  52. "uniIdRouter": {},
  53. // 设置底部导航栏
  54. "tabBar": {
  55. }
  56. }

类似navigationBarTitleText(导航栏text)、navigationBarBackgroundColor(导航栏背景色)等等属性可以查看相关资料自行配置即可

pages里设置单页面参数,每个页面配置对应path路径参数

globalStyle里设置全局页面参数

js、josn、scss文件等等其他配置文件这里就不多说了自行研究吧!!!因为我也还没搞清楚到底怎么用哈哈哈

进入正题↓↓↓↓↓↓↓↓↓↓↓↓↓代码看着有些乱........凑合看慢慢理解吧

代码里的src图片链接自行修改!!!!(还有css里的URL)

三、登录页面

先看一下效果图

 login.vue页面

  1. <!-- 登录页面 -->
  2. <template>
  3. <view class="flex-col flex-auto group">
  4. <text class="self-center text_2" v-if="type==1000">手机号登录</text>
  5. <text class="self-center text_2" v-if="type==2000">账号登录</text>
  6. <!-- 手机号登录 -->
  7. <view class="" v-if="type==1000">
  8. <view class="flex-col justify-start items-start text-wrapper">
  9. <input type="text" class="font_1" @input="onInput" placeholder="请输入手机号" v-model="phoneNumber">
  10. </view>
  11. <!-- svg画线 -->
  12. <view style="height: 1px;">
  13. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  14. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  15. </svg>
  16. </view>
  17. <view class="flex-col justify-start items-start text-wrapper_2">
  18. <input type="text" password="true" class="font_1" @input="onInput" placeholder="请输入密码" v-model="phonePassword">
  19. </view>
  20. <!-- svg画线 -->
  21. <view style="height: 1px;">
  22. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  23. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  24. </svg>
  25. </view>
  26. </view>
  27. <!-- 账号登录 -->
  28. <view class="" v-if="type==2000">
  29. <view class="flex-col justify-start items-start text-wrapper">
  30. <input type="text" class="font_1" @input="onInput" placeholder="请输入用户名" v-model="idNumber">
  31. </view>
  32. <!-- svg画线 -->
  33. <view style="height: 1px;">
  34. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  35. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  36. </svg>
  37. </view>
  38. <view class="flex-col justify-start items-start text-wrapper_2">
  39. <input type="text" password="true" class="font_1" @input="onInput" placeholder="请输入用户密码" v-model="idPassword">
  40. </view>
  41. <!-- svg画线 -->
  42. <view style="height: 1px;">
  43. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  44. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  45. </svg>
  46. </view>
  47. </view>
  48. <view class="self-start font_1 text_3" @click="type=2000" v-if="type==1000">用账号登录</view>
  49. <view class="self-start font_1 text_3" @click="type=1000" v-if="type==2000">用手机号登录</view>
  50. <!-- 登录按钮1 -->
  51. <view class="flex-col justify-start items-center button" v-if="btnShow">
  52. <button class="font_1 text_4" @click="onSubmit">登 录</button>
  53. </view>
  54. <!-- 登录按钮2 -->
  55. <view class="flex-col justify-start items-center button2" v-else>
  56. <button class="font_1 text_66">登 录</button>
  57. </view>
  58. <view class="flex-row justify-between group_2" v-if="type==1000">
  59. <text class="font_2" @click="onPageJump('/pages/login/phoneVerify')">短信验证码登录</text>
  60. <text class="font_2" @click="onPageJump('/pages/login/findBack')">找回密码</text>
  61. </view>
  62. <view class="flex-row justify-between group_3" v-else>
  63. <text class="font_2" @click="onPageJump('/pages/login/findBack')">找回密码</text>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. components:{
  70. },
  71. data() {
  72. return {
  73. type: 1000, //判断登录类型手机登录或账号登录
  74. phoneNumber:'', //手机账号
  75. phonePassword:'', //手机密码
  76. idNumber:'', //账号
  77. idPassword:'', //账号密码
  78. btnShow:false, //判断登录按钮显示隐藏
  79. timeOut:null, //添加定时器
  80. }
  81. },
  82. onLoad() {
  83. },
  84. created() {
  85. },
  86. // 方法
  87. methods: {
  88. // 找回密码跳转页面
  89. onPageJump(url) {
  90. uni.navigateTo({
  91. url: url
  92. });
  93. },
  94. // 判断显示登录按钮
  95. onInput() {
  96. this.timeOut && clearTimeout(this.timeOut)
  97. this.timeOut = setTimeout(() => {
  98. if (this.type == 1000) {
  99. if (this.phoneNumber && this.phonePassword) {
  100. this.btnShow = true;
  101. } else {
  102. this.btnShow = false;
  103. }
  104. } else {
  105. if (this.idNumber && this.idPassword) {
  106. this.btnShow = true;
  107. } else {
  108. this.btnShow = false;
  109. }
  110. }
  111. }, 100);
  112. },
  113. // 点击登录
  114. onSubmit(){
  115. // 判断登录方式为手机号登录
  116. if(this.type==1000){
  117. // 判断验证手机号
  118. if(!this.phoneNumber){
  119. uni.showToast({
  120. title: '请输入手机号',
  121. icon: 'none',
  122. });
  123. return;
  124. }
  125. const phoneNumber= /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
  126. if(!phoneNumber.test(this.phoneNumber)){
  127. uni.showToast({
  128. title: '手机号输入不正确',
  129. icon: 'none',
  130. });
  131. return;
  132. }
  133. // 判断验证手机密码
  134. if(!this.phonePassword){
  135. uni.showToast({
  136. title: '请输入密码',
  137. icon: 'none',
  138. });
  139. return;
  140. }
  141. uni.showToast({
  142. title: '正在登录',
  143. icon: 'loading',
  144. });
  145. }else{
  146. // 判断验证账号
  147. if(!this.idNumber){
  148. uni.showToast({
  149. title: '请输入账号',
  150. icon: 'none',
  151. });
  152. return;
  153. }
  154. // 判断验证账号密码
  155. if(!this.idPassword){
  156. uni.showToast({
  157. title: '请输入账号密码',
  158. icon: 'none',
  159. });
  160. return;
  161. }
  162. uni.showToast({
  163. title: '正在登录',
  164. icon: 'loading',
  165. });
  166. }
  167. },
  168. }
  169. }
  170. </script>
  171. <style>
  172. @import"../../style/css/login.css";
  173. </style>

一个小tips:

先说一下这个页面↑↑↑↑↑↑↑↑↑↑↑↑↑↑

svg因为我这里账号、密码input输入框的border边框要设置成小数1px以下0.1px、0.2px、0.3px等等,所以这里用了svg的画图,如果有小伙伴碰到同样问题可以参考一下,不需要的直接style里直接设置border参数即可

uni.showToast是uni-app弹出框的方法直接用就行,参数么。。自己研究研究就行   (例:icon图标参数有四种类型none、loading、success、error)

style外部引用css样式直接用@import相对路径即可

login.css文件

style样式最好还是用自己写的就别直接复制了,我这里用的是平台自动生成的所以比较乱随便看看就行了看多了头疼(仅供参考全局样式可以直接略过)

  1. /************************************************************
  2. ** 全局样式 ** **
  3. ************************************************************/
  4. html {
  5. font-size: 16px;
  6. }
  7. body {
  8. margin: 0;
  9. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  10. 'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. }
  14. view,
  15. image,
  16. text {
  17. box-sizing: border-box;
  18. flex-shrink: 0;
  19. }
  20. #app {
  21. width: 100vw;
  22. height: 100vh;
  23. }
  24. .flex-row {
  25. display: flex;
  26. flex-direction: row;
  27. }
  28. .flex-col {
  29. display: flex;
  30. flex-direction: column;
  31. }
  32. .justify-start {
  33. justify-content: flex-start;
  34. }
  35. .justify-end {
  36. justify-content: flex-end;
  37. }
  38. .justify-center {
  39. justify-content: center;
  40. }
  41. .justify-between {
  42. justify-content: space-between;
  43. }
  44. .justify-around {
  45. justify-content: space-around;
  46. }
  47. .justify-evenly {
  48. justify-content: space-evenly;
  49. }
  50. .items-start {
  51. align-items: flex-start;
  52. }
  53. .items-end {
  54. align-items: flex-end;
  55. }
  56. .items-center {
  57. align-items: center;
  58. }
  59. .items-baseline {
  60. align-items: baseline;
  61. }
  62. .items-stretch {
  63. align-items: stretch;
  64. }
  65. .self-start {
  66. align-self: flex-start;
  67. }
  68. .self-end {
  69. align-self: flex-end;
  70. }
  71. .self-center {
  72. align-self: center;
  73. }
  74. .self-baseline {
  75. align-self: baseline;
  76. }
  77. .self-stretch {
  78. align-self: stretch;
  79. }
  80. .flex-1 {
  81. flex: 1 1 0%;
  82. }
  83. .flex-auto {
  84. flex: 1 1 auto;
  85. }
  86. .grow {
  87. flex-grow: 1;
  88. }
  89. .grow-0 {
  90. flex-grow: 0;
  91. }
  92. .shrink {
  93. flex-shrink: 1;
  94. }
  95. .shrink-0 {
  96. flex-shrink: 0;
  97. }
  98. .relative {
  99. position: relative;
  100. }
  101. /* ---------------------------------------------------------------------- */
  102. .group {
  103. padding: 20px 40px 10px;
  104. overflow-y: auto;
  105. }
  106. .text_2 {
  107. color: #020202;
  108. font-size: 20px;
  109. font-family: 'PingFang SC';
  110. line-height: 28px;
  111. text-align: center;
  112. }
  113. .text-wrapper {
  114. margin-top: 42px;
  115. padding-bottom: 12px;
  116. /* border-bottom: solid 1px #888888; */
  117. }
  118. .font_1 {
  119. width: 100%;
  120. font-size: 15px;
  121. font-family: 'PingFang SC';
  122. line-height: 21px;
  123. color: #00000;
  124. }
  125. .text-wrapper_2 {
  126. padding: 20px 0 12px;
  127. /* border-bottom: solid 1px #888888; */
  128. }
  129. .text_3 {
  130. margin-top: 22px;
  131. color: #166bf8;
  132. }
  133. /* 登录按钮1 */
  134. .button button {
  135. margin-top: 324px;
  136. padding: 8px 0 11px;
  137. /* background-color: #166bf880; */
  138. background-image: url('。。。。。。。。。。。。。。。。。。。。');
  139. background-size: 100% 100%;
  140. background-repeat: no-repeat;
  141. border-radius: 5px;
  142. width: 100%;
  143. }
  144. .text_4 {
  145. color: #ffffff;
  146. }
  147. .group_2 {
  148. padding: 50px 62px;
  149. }
  150. .group_3 {
  151. padding: 50px 42%;
  152. }
  153. .font_2 {
  154. font-size: 12px;
  155. font-family: 'PingFang SC';
  156. line-height: 17px;
  157. color: #555555;
  158. }
  159. /* 登录按钮2*/
  160. .button2 button{
  161. width: 100%;
  162. margin-top: 324px;
  163. padding: 8px 0 11px;
  164. background-color: #166bf880;
  165. border-radius: 5px;
  166. line-height: 21px;
  167. font-size: 15px;
  168. }
  169. .text_66 {
  170. color: #ffffff;
  171. }

四、手机短信验证页面

点击登录页面上的短信验证码登录后跳转到此页,跳转方法会用到uni.navigateTo方法在登录页面看代码自行理解吧↑↑↑↑↑↑↑↑↑↑↑

跳转、返回的方法参考文档:

https://www.bookstack.cn/read/uniapp-api/spilt.5.ead34267bd06d88a.mdhttps://www.bookstack.cn/read/uniapp-api/spilt.5.ead34267bd06d88a.md

注意!!添加新页面的时候上面的↑↑↑↑↑↑↑↑↑↑↑pages.json配置文件也需要添加对应的页面配置才行不然页面出不来

效果图:

 phoneVerify.vue页面

  1. <!-- 手机验证找回密码 -->
  2. <template>
  3. <view class="flex-col flex-auto group">
  4. <text class="self-center text_2">手机号+短信验证码登录</text>
  5. <view class="flex-col group_2 space-y-10">
  6. <input type="number" class="self-start font_1" @input="onInput" placeholder="请输入手机号码" v-model="phoneNumber">
  7. <!-- svg画线 -->
  8. <view style="height: 1px;">
  9. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  10. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  11. </svg>
  12. </view>
  13. <view class="flex-row justify-between group_3">
  14. <input type="number" class="self-start font_1 text_4" maxlength="6" @input="onInput" placeholder="请输入验证码" v-model="code">
  15. <view class="flex-col justify-start items-center self-center text-wrapper">
  16. <!-- <text class="font_1 text_3" @click="onSetCode()">获取验证码</text> -->
  17. <text v-bind:class="{acquire:isGrey,again:!isGrey}"
  18. v-bind:disabled="dis" type="primary"
  19. @click="onSetCode">
  20. <span v-if="show">获取验证码</span>
  21. <span v-else>重新发送({{count}}s)</span>
  22. </text>
  23. </view>
  24. </view>
  25. <!-- svg画线 -->
  26. <view style="height: 1px;">
  27. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  28. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  29. </svg>
  30. </view>
  31. </view>
  32. <view class="self-start font_1 text_5" @click="onPageJump('/pages/login/login')">用密码登录</view>
  33. <view class="flex-col justify-start items-center button" v-if="btnShow">
  34. <button class="font_1 text_6" @click="onSubmit()">登 录</button>
  35. </view>
  36. <!-- 登录按钮2 -->
  37. <view class="flex-col justify-start items-center button2" v-else>
  38. <button class="font_1 text_66">登 录</button>
  39. </view>
  40. <text class="self-center text_7" @click="onPageJump('/pages/login/findBack')">找回密码</text>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. components: {
  46. },
  47. data() {
  48. return {
  49. phoneNumber:'', //手机号验证
  50. code:'', //验证码
  51. dis: false, //判断是否禁用状态
  52. show: true, //判断显示为发送还是重新发送
  53. isGrey: false, //class判断按钮样式
  54. timer: null, //设置计时器,
  55. count: "", //定义常量
  56. num:'', //判断是否为第一次点击
  57. btnShow:false, //判断登录按钮显示隐藏
  58. timeOut:null, //添加定时器
  59. };
  60. },
  61. // 方法
  62. methods: {
  63. // 找回密码跳转页面
  64. onPageJump(url) {
  65. uni.navigateTo({
  66. url: url
  67. });
  68. },
  69. // 发送验证码
  70. onSetCode() {
  71. let TIME_COUNT = 60;
  72. if (!this.timer) {
  73. uni.showToast({
  74. title: '已发送验证码',
  75. icon: 'success',
  76. });
  77. this.count = TIME_COUNT;
  78. this.isGrey = true;
  79. this.show = false;
  80. this.dis = true;
  81. this.timer = setInterval(() => {
  82. if (this.count > 0 && this.count <= TIME_COUNT) {
  83. this.count--;
  84. } else {
  85. this.dis = false;
  86. this.isGrey = false;
  87. this.show = true;
  88. clearInterval(this.timer);
  89. this.timer = null;
  90. }
  91. }, 1000);
  92. }
  93. },
  94. // 判断显示登录按钮
  95. onInput() {
  96. this.timeOut && clearTimeout(this.timeOut)
  97. this.timeOut = setTimeout(() => {
  98. if (this.phoneNumber && this.code) {
  99. this.btnShow = true;
  100. } else {
  101. this.btnShow = false;
  102. }
  103. }, 100);
  104. },
  105. //点击登录
  106. onSubmit(){
  107. // 判断验证手机号
  108. if(!this.phoneNumber){
  109. uni.showToast({
  110. title: '请输入手机号',
  111. icon: 'none',
  112. });
  113. return;
  114. }
  115. const phoneNumber= /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/;
  116. if(!phoneNumber.test(this.phoneNumber)){
  117. uni.showToast({
  118. title: '手机号输入不正确',
  119. icon: 'none',
  120. });
  121. return;
  122. }
  123. // 判断验证码
  124. if(!this.code){
  125. uni.showToast({
  126. title: '请输入验证码',
  127. icon: 'none',
  128. });
  129. return;
  130. }
  131. uni.showToast({
  132. title: '请稍后...',
  133. icon: 'loading',
  134. });
  135. },
  136. },
  137. };
  138. </script>
  139. <style>
  140. @import"../../style/css/phoneVerify.css";
  141. /* 验证码按钮样式 */
  142. .acquire{
  143. padding: 3px 0px;
  144. background-color: #eeeeee;
  145. border-radius: 5px;
  146. width: 92px;
  147. height: 29px;
  148. color: #666;
  149. font-size: 14px;
  150. line-height: 20px;
  151. text-align: center;
  152. }
  153. .again{
  154. padding: 3px 0px;
  155. background-color: #eeeeee;
  156. border-radius: 5px;
  157. width: 92px;
  158. height: 29px;
  159. color: #000000;
  160. font-size: 14px;
  161. line-height: 20px;
  162. text-align: center;
  163. }
  164. </style>

这个页面因为是静态的没有后端接口只是做的样式,所以验证码读秒这块内容刷新页面时会重置重新开始读秒这里注意一下就行,如果接后端接口实现的话原理也差不多自己慢慢理解就行

大概就长这样:

至于左上角这个返回键的小钮钮是uni-app创建项目时自带的 pages.json配置文件可以配置关闭 用("navigationStyle":"custom")这个参数就能关闭,单页面关闭在pages里配置,全部关闭在globalStyle里配置。

大概长这样:

也可以在Vue页面的方法里用uni.navigateBack方法自己写一个返回的方法。uni.navigateBack返回页面的方法具体怎么用↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓后面的页面会有用到

 phoneVerify.css文件

  1. /************************************************************
  2. ** 全局样式 **
  3. ************************************************************/
  4. html {
  5. font-size: 16px;
  6. }
  7. body {
  8. margin: 0;
  9. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  10. 'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. }
  14. view,
  15. image,
  16. text {
  17. box-sizing: border-box;
  18. flex-shrink: 0;
  19. }
  20. #app {
  21. width: 100vw;
  22. height: 100vh;
  23. }
  24. .flex-row {
  25. display: flex;
  26. flex-direction: row;
  27. }
  28. .flex-col {
  29. display: flex;
  30. flex-direction: column;
  31. }
  32. .justify-start {
  33. justify-content: flex-start;
  34. }
  35. .justify-end {
  36. justify-content: flex-end;
  37. }
  38. .justify-center {
  39. justify-content: center;
  40. }
  41. .justify-between {
  42. justify-content: space-between;
  43. }
  44. .justify-around {
  45. justify-content: space-around;
  46. }
  47. .justify-evenly {
  48. justify-content: space-evenly;
  49. }
  50. .items-start {
  51. align-items: flex-start;
  52. }
  53. .items-end {
  54. align-items: flex-end;
  55. }
  56. .items-center {
  57. align-items: center;
  58. }
  59. .items-baseline {
  60. align-items: baseline;
  61. }
  62. .items-stretch {
  63. align-items: stretch;
  64. }
  65. .self-start {
  66. align-self: flex-start;
  67. }
  68. .self-end {
  69. align-self: flex-end;
  70. }
  71. .self-center {
  72. align-self: center;
  73. }
  74. .self-baseline {
  75. align-self: baseline;
  76. }
  77. .self-stretch {
  78. align-self: stretch;
  79. }
  80. .flex-1 {
  81. flex: 1 1 0%;
  82. }
  83. .flex-auto {
  84. flex: 1 1 auto;
  85. }
  86. .grow {
  87. flex-grow: 1;
  88. }
  89. .grow-0 {
  90. flex-grow: 0;
  91. }
  92. .shrink {
  93. flex-shrink: 1;
  94. }
  95. .shrink-0 {
  96. flex-shrink: 0;
  97. }
  98. .relative {
  99. position: relative;
  100. }
  101. /* ------------------------------------------------ */
  102. .group {
  103. padding: 30px 40px 60px;
  104. overflow-y: auto;
  105. }
  106. .text_2 {
  107. color: #020202;
  108. font-size: 20px;
  109. font-family: 'PingFang SC';
  110. line-height: 28px;
  111. }
  112. .group_2 {
  113. margin-top: 42px;
  114. /* border-bottom: solid 1px #888888; */
  115. }
  116. .space-y-10 > view:not(:first-child),
  117. .space-y-10 > text:not(:first-child),
  118. .space-y-10 > image:not(:first-child) {
  119. margin-top: 10px;
  120. }
  121. .font_1 {
  122. font-size: 15px;
  123. font-family: 'PingFang SC';
  124. line-height: 21px;
  125. color: #000000;
  126. }
  127. .group_3 {
  128. padding: 5px 0;
  129. /* border-top: solid 1px #888888; */
  130. }
  131. .text_4 {
  132. margin-top: 8px;
  133. }
  134. .text-wrapper {
  135. padding: 4px 0;
  136. background-color: #eeeeee;
  137. border-radius: 5px;
  138. width: 92px;
  139. height: 29px;
  140. }
  141. .text_3 {
  142. color: #000000;
  143. font-size: 14px;
  144. line-height: 20px;
  145. }
  146. .text_5 {
  147. margin-top: 22px;
  148. color: #166bf8;
  149. }
  150. .button button{
  151. margin-top: 324px;
  152. padding: 8px 0 11px;
  153. /* background-color: #166bf880; */
  154. background-image: url('。。。。。。。。。。。。。。。。。。。。。。');
  155. background-size: 100% 100%;
  156. background-repeat: no-repeat;
  157. border-radius: 5px;
  158. width: 100%;
  159. }
  160. .text_6 {
  161. color: #ffffff;
  162. }
  163. .text_7 {
  164. margin-top: 50px;
  165. color: #555555;
  166. font-size: 12px;
  167. font-family: 'PingFang SC';
  168. line-height: 17px;
  169. }
  170. /* 登录按钮2*/
  171. .button2 button{
  172. width: 100%;
  173. margin-top: 324px;
  174. padding: 8px 0 11px;
  175. background-color: #166bf880;
  176. border-radius: 5px;
  177. line-height: 21px;
  178. font-size: 15px;
  179. }
  180. .text_66 {
  181. color: #ffffff;
  182. }

五、找回密码页面

在登录页面点击找回密码后跳转到此页面

同样在pages.json文件里配置对应页面参数↑↑↑↑↑↑↑↑↑

效果图:

 点击通过手机号跳转到手机短信验证页面 也就是第四步的页面点击通过邮箱验证跳转到邮箱验证页面 也就是第六步的页面

findBack.vue页面

  1. <!-- 找回密码 -->
  2. <template>
  3. <view class="flex-col justify-start flex-auto group_3">
  4. <view class="flex-col section">
  5. <view class="flex-row justify-between items-center group_4" @click="onPageJump('/pages/login/phoneVerify')">
  6. <text class="font_1">通过已绑定手机号,用短信验证登录</text>
  7. <image
  8. class="image_5"
  9. src="https://codefun-proj-user-res-1256085488.cos.ap-guangzhou.myqcloud.com/637d8bf95a7e3f031010c80e/63e351ec66570000128a304a/16758423632990405565.png"
  10. />
  11. </view>
  12. <view class="flex-row justify-between items-center group_4" @click="onPageJump('/pages/login/mailFindBack')">
  13. <text class="font_1">通过已绑定邮箱重设密码</text>
  14. <image
  15. class="image_5"
  16. src="。。。。。。。。。。。。。。。"
  17. />
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. components: {},
  25. data() {
  26. return {
  27. };
  28. },
  29. methods: {
  30. onPageJump(url) {
  31. uni.navigateTo({
  32. url:url
  33. })
  34. },
  35. },
  36. };
  37. </script>
  38. <style>
  39. @import"../../style/css/findBack.css";
  40. </style>

findBack.css文件

  1. /************************************************************
  2. ** 全局样式 **
  3. ************************************************************/
  4. html {
  5. font-size: 16px;
  6. }
  7. body {
  8. margin: 0;
  9. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  10. 'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. }
  14. view,
  15. image,
  16. text {
  17. box-sizing: border-box;
  18. flex-shrink: 0;
  19. }
  20. #app {
  21. width: 100vw;
  22. height: 100vh;
  23. }
  24. .flex-row {
  25. display: flex;
  26. flex-direction: row;
  27. }
  28. .flex-col {
  29. display: flex;
  30. flex-direction: column;
  31. }
  32. .justify-start {
  33. justify-content: flex-start;
  34. }
  35. .justify-end {
  36. justify-content: flex-end;
  37. }
  38. .justify-center {
  39. justify-content: center;
  40. }
  41. .justify-between {
  42. justify-content: space-between;
  43. }
  44. .justify-around {
  45. justify-content: space-around;
  46. }
  47. .justify-evenly {
  48. justify-content: space-evenly;
  49. }
  50. .items-start {
  51. align-items: flex-start;
  52. }
  53. .items-end {
  54. align-items: flex-end;
  55. }
  56. .items-center {
  57. align-items: center;
  58. }
  59. .items-baseline {
  60. align-items: baseline;
  61. }
  62. .items-stretch {
  63. align-items: stretch;
  64. }
  65. .self-start {
  66. align-self: flex-start;
  67. }
  68. .self-end {
  69. align-self: flex-end;
  70. }
  71. .self-center {
  72. align-self: center;
  73. }
  74. .self-baseline {
  75. align-self: baseline;
  76. }
  77. .self-stretch {
  78. align-self: stretch;
  79. }
  80. .flex-1 {
  81. flex: 1 1 0%;
  82. }
  83. .flex-auto {
  84. flex: 1 1 auto;
  85. }
  86. .grow {
  87. flex-grow: 1;
  88. }
  89. .grow-0 {
  90. flex-grow: 0;
  91. }
  92. .shrink {
  93. flex-shrink: 1;
  94. }
  95. .shrink-0 {
  96. flex-shrink: 0;
  97. }
  98. .relative {
  99. position: relative;
  100. }
  101. .font_1 {
  102. font-size: 16px;
  103. font-family: 'PingFang SC';
  104. line-height: 22px;
  105. color: #020202;
  106. }
  107. .group_3 {
  108. padding: 10px 0 586px;
  109. overflow-y: auto;
  110. }
  111. .section {
  112. padding: 0px 16px;
  113. background-color: #ffffff;
  114. }
  115. .group_4 {
  116. padding: 18px 0;
  117. border-bottom: solid 1px #979797;
  118. }
  119. .image_5 {
  120. margin-right: 14px;
  121. width: 12px;
  122. height: 12px;
  123. }

六、邮箱找回密码页面

效果图:

 mailFandBack.vue页面

  1. <!-- 邮件找回密码 -->
  2. <template>
  3. <view class="flex-col flex-auto group">
  4. <text class="self-center text_2">通过邮箱找回密码</text>
  5. <input type="text" class="self-start font_1 text_3" @input="onInput" placeholder="请输入您绑定的邮箱地址" v-model="email">
  6. <!-- svg画线 -->
  7. <view style="height: 1px;">
  8. <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
  9. <line x1="0" y1="0" x2="400" y2="0" style="stroke:rgb(0,0,0);stroke-width:0.2" />
  10. </svg>
  11. </view>
  12. <view class="flex-col justify-start items-center button" v-if="btnShow">
  13. <text class="font_1 text_4" @click="onSubmit()">下一步</text>
  14. </view>
  15. <!-- 下一步按钮2 -->
  16. <view class="flex-col justify-start items-center button2" v-else>
  17. <button class="font_1 text_66">下一步</button>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. components: {
  24. },
  25. data() {
  26. return {
  27. email:'', //邮箱
  28. btnShow:false, //判断登录按钮显示隐藏
  29. timeOut:null, //添加定时器
  30. };
  31. },
  32. methods: {
  33. // 判断显示下一步按钮
  34. onInput() {
  35. this.timeOut && clearTimeout(this.timeOut)
  36. this.timeOut = setTimeout(() => {
  37. if (this.email) {
  38. this.btnShow = true;
  39. } else {
  40. this.btnShow = false;
  41. }
  42. }, 100);
  43. },
  44. // 点击下一步
  45. onSubmit(){
  46. if(!this.email){
  47. uni.showToast({
  48. title: '请输入邮箱',
  49. icon: 'none',
  50. });
  51. return;
  52. }
  53. const email= /^\w{3,}@\w{2,}\.(com|cn|net|com\.cn)$/;
  54. if(!email.test(this.email)){
  55. uni.showToast({
  56. title: '邮箱输入不正确',
  57. icon: 'none',
  58. });
  59. return;
  60. }
  61. uni.showToast({
  62. title: '请稍后...',
  63. icon: 'loading',
  64. });
  65. // 添加定时器延时跳转页面
  66. setTimeout(function(){
  67. uni.navigateTo({
  68. url: '/pages/login/emailFinish'
  69. });
  70. },2000)
  71. }
  72. },
  73. };
  74. </script>
  75. <style>
  76. @import"../../style/css/mailFindBack.css";
  77. </style>

mailFandBack.css文件

  1. /************************************************************
  2. ** 全局样式 **
  3. ************************************************************/
  4. html {
  5. font-size: 16px;
  6. }
  7. body {
  8. margin: 0;
  9. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  10. 'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. }
  14. view,
  15. image,
  16. text {
  17. box-sizing: border-box;
  18. flex-shrink: 0;
  19. }
  20. #app {
  21. width: 100vw;
  22. height: 100vh;
  23. }
  24. .flex-row {
  25. display: flex;
  26. flex-direction: row;
  27. }
  28. .flex-col {
  29. display: flex;
  30. flex-direction: column;
  31. }
  32. .justify-start {
  33. justify-content: flex-start;
  34. }
  35. .justify-end {
  36. justify-content: flex-end;
  37. }
  38. .justify-center {
  39. justify-content: center;
  40. }
  41. .justify-between {
  42. justify-content: space-between;
  43. }
  44. .justify-around {
  45. justify-content: space-around;
  46. }
  47. .justify-evenly {
  48. justify-content: space-evenly;
  49. }
  50. .items-start {
  51. align-items: flex-start;
  52. }
  53. .items-end {
  54. align-items: flex-end;
  55. }
  56. .items-center {
  57. align-items: center;
  58. }
  59. .items-baseline {
  60. align-items: baseline;
  61. }
  62. .items-stretch {
  63. align-items: stretch;
  64. }
  65. .self-start {
  66. align-self: flex-start;
  67. }
  68. .self-end {
  69. align-self: flex-end;
  70. }
  71. .self-center {
  72. align-self: center;
  73. }
  74. .self-baseline {
  75. align-self: baseline;
  76. }
  77. .self-stretch {
  78. align-self: stretch;
  79. }
  80. .flex-1 {
  81. flex: 1 1 0%;
  82. }
  83. .flex-auto {
  84. flex: 1 1 auto;
  85. }
  86. .grow {
  87. flex-grow: 1;
  88. }
  89. .grow-0 {
  90. flex-grow: 0;
  91. }
  92. .shrink {
  93. flex-shrink: 1;
  94. }
  95. .shrink-0 {
  96. flex-shrink: 0;
  97. }
  98. .relative {
  99. position: relative;
  100. }
  101. /* ------------------------------------------------------------------------------ */
  102. .group {
  103. padding: 25px 40px 127px;
  104. overflow-y: auto;
  105. }
  106. .text_2 {
  107. color: #020202;
  108. font-size: 20px;
  109. font-family: 'PingFang SC';
  110. line-height: 28px;
  111. }
  112. .font_1 {
  113. font-size: 15px;
  114. font-family: 'PingFang SC';
  115. line-height: 21px;
  116. }
  117. .text_3 {
  118. margin-top: 42px;
  119. margin-bottom: 12px;
  120. color: #999999;
  121. }
  122. /* .section {
  123. margin-top: 12px;
  124. background-color: #888888;
  125. height: 1px;
  126. } */
  127. .button {
  128. margin-top: 324px;
  129. padding: 8px 0 11px;
  130. /* background-color: #166bf880; */
  131. background-image: url('。。。。。。。。。。。。');
  132. background-size: 100% 100%;
  133. background-repeat: no-repeat;
  134. border-radius: 5px;
  135. }
  136. .text_4 {
  137. color: #ffffff;
  138. }
  139. /* 下一步按钮2*/
  140. .button2 button{
  141. width: 100%;
  142. margin-top: 324px;
  143. padding: 8px 0 11px;
  144. background-color: #166bf880;
  145. border-radius: 5px;
  146. line-height: 21px;
  147. font-size: 15px;
  148. }
  149. .text_66 {
  150. color: #ffffff;
  151. }

七、邮箱发送验证成功页面

效果图:

 emailFinish.vue页面

  1. <template>
  2. <view class="flex-col flex-auto group">
  3. <view class="flex-col group_2">
  4. <image
  5. class="self-center image_5"
  6. src="。。。。。。。。。。。。。。"
  7. />
  8. <text class="self-center text_2">请访问邮件中给出的网页链接地址,根据页面提示完成密码重设。</text>
  9. <view class="flex-col justify-start items-center button">
  10. <button class="text_3" @click="Back">确定</button>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. components: {
  18. },
  19. data() {
  20. return {
  21. };
  22. },
  23. methods: {
  24. // 点击确定返回上一页
  25. Back(){
  26. // 返回到上一个页面
  27. uni.navigateBack({
  28. delta:1,//返回层数,2则上上页,默认delta:1
  29. })
  30. },
  31. },
  32. };
  33. </script>
  34. <style>
  35. @import"../../style/css/emailFinish.css";
  36. </style>

点击返回上一页面可以用uni.navigateBack方法

点击跳转到指定页面可以用uni.navigateTo方法(因为都属于跳转页面也可以用这个方法返回上一页自行理解吧)

大概长这样:

emailFinish.css文件

  1. /************************************************************
  2. ** 全局样式 **
  3. ************************************************************/
  4. html {
  5. font-size: 16px;
  6. }
  7. body {
  8. margin: 0;
  9. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans',
  10. 'Droid Sans', 'Helvetica Neue', 'Microsoft Yahei', sans-serif;
  11. -webkit-font-smoothing: antialiased;
  12. -moz-osx-font-smoothing: grayscale;
  13. }
  14. view,
  15. image,
  16. text {
  17. box-sizing: border-box;
  18. flex-shrink: 0;
  19. }
  20. #app {
  21. width: 100vw;
  22. height: 100vh;
  23. }
  24. .flex-row {
  25. display: flex;
  26. flex-direction: row;
  27. }
  28. .flex-col {
  29. display: flex;
  30. flex-direction: column;
  31. }
  32. .justify-start {
  33. justify-content: flex-start;
  34. }
  35. .justify-end {
  36. justify-content: flex-end;
  37. }
  38. .justify-center {
  39. justify-content: center;
  40. }
  41. .justify-between {
  42. justify-content: space-between;
  43. }
  44. .justify-around {
  45. justify-content: space-around;
  46. }
  47. .justify-evenly {
  48. justify-content: space-evenly;
  49. }
  50. .items-start {
  51. align-items: flex-start;
  52. }
  53. .items-end {
  54. align-items: flex-end;
  55. }
  56. .items-center {
  57. align-items: center;
  58. }
  59. .items-baseline {
  60. align-items: baseline;
  61. }
  62. .items-stretch {
  63. align-items: stretch;
  64. }
  65. .self-start {
  66. align-self: flex-start;
  67. }
  68. .self-end {
  69. align-self: flex-end;
  70. }
  71. .self-center {
  72. align-self: center;
  73. }
  74. .self-baseline {
  75. align-self: baseline;
  76. }
  77. .self-stretch {
  78. align-self: stretch;
  79. }
  80. .flex-1 {
  81. flex: 1 1 0%;
  82. }
  83. .flex-auto {
  84. flex: 1 1 auto;
  85. }
  86. .grow {
  87. flex-grow: 1;
  88. }
  89. .grow-0 {
  90. flex-grow: 0;
  91. }
  92. .shrink {
  93. flex-shrink: 1;
  94. }
  95. .shrink-0 {
  96. flex-shrink: 0;
  97. }
  98. .relative {
  99. position: relative;
  100. }
  101. /* ------------------------------------------------------------------------------ */
  102. .group {
  103. padding: 25px 40px 127px;
  104. overflow-y: auto;
  105. }
  106. .text_2 {
  107. color: #020202;
  108. font-size: 20px;
  109. font-family: 'PingFang SC';
  110. line-height: 28px;
  111. }
  112. .font_1 {
  113. font-size: 15px;
  114. font-family: 'PingFang SC';
  115. line-height: 21px;
  116. }
  117. .text_3 {
  118. margin-top: 42px;
  119. margin-bottom: 12px;
  120. color: #999999;
  121. }
  122. /* .section {
  123. margin-top: 12px;
  124. background-color: #888888;
  125. height: 1px;
  126. } */
  127. .button {
  128. margin-top: 324px;
  129. padding: 8px 0 11px;
  130. /* background-color: #166bf880; */
  131. background-image: url('。。。。。。。。。。。。。。。');
  132. background-size: 100% 100%;
  133. background-repeat: no-repeat;
  134. border-radius: 5px;
  135. }
  136. .text_4 {
  137. color: #ffffff;
  138. }
  139. /* 下一步按钮2*/
  140. .button2 button{
  141. width: 100%;
  142. margin-top: 324px;
  143. padding: 8px 0 11px;
  144. background-color: #166bf880;
  145. border-radius: 5px;
  146. line-height: 21px;
  147. font-size: 15px;
  148. }
  149. .text_66 {
  150. color: #ffffff;
  151. }

本章也是自己参考相关资料和各位大佬的文章自行整理仅供参考,希望可以帮助到和我一样菜鸡的小伙伴

参考资料:

https://blog.csdn.net/weixin_40614372/article/details/101537653

uni-app官网:

https://uniapp.dcloud.net.cn/component/

登录页面完成后我用的是Strophe.js对接Openfire的接口,然后把Strophe.js的用法加到↑本文的登录页里使用

链接:

基于XMPP服务的Strophe.js用法_和风微凉的博客-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/293606
推荐阅读
相关标签
  

闽ICP备14008679号