开始

绑定邮箱。和修改密码页面是差不多的。
image.png
新建页面:user-set-email
image.png

image.png

image.png

  1. "style" :
  2. {
  3. "navigationBarTitleText": "修改邮箱",
  4. "enablePullDownRefresh": false,
  5. "app-plus": {
  6. "scrollIndicator": "none"
  7. }
  8. }

上节课的修改密码。
image.png
复制修改密码的页面
image.png

  1. <input type="text" v-model="oldpassword" class="uni-input common-input" placeholder="输入旧密码" />
  2. <input type="text" v-model="newpassword" class="uni-input common-input" placeholder="输入新密码" />
  3. <input type="text" v-model="renewpassword" class="uni-input common-input" placeholder="输入确认密码" />
  4. <button class="user-set-btn"
  5. :class="{'user-set-btn-disable':disabled}"
  6. :loading="loading"
  7. @tap="submit" type="primary" :disabled="disabled">完成</button>

跳转

user-set页面进行跳转
image.png

  1. {
  2. icon: "",
  3. name: "绑定邮箱",
  4. clicktype: "navigateTo",
  5. url: "../../pages/user-set-email/user-set-email"
  6. },

image.png

image.png
修改正确
image.png

image.png
复制修改密码的页面布局
image.png
引入公共的css
image.png

  1. @import url('@/common/form.css');

image.png

需要的数据
image.png

  1. return {
  2. email:'',
  3. password:"",
  4. disabled:true,
  5. loading:false
  6. }

watch复制过来
image.png
image.png

  1. watch:{
  2. email(val){
  3. this.change();
  4. },
  5. password(val){
  6. this.change();
  7. }
  8. },

image.png

image.png

  1. // 监听输入框
  2. change(){
  3. console.log('change事件');
  4. if(this.email && this.password){
  5. this.disabled=false;
  6. console.log('change事件,修改disable为false');
  7. return;
  8. }
  9. this.disabled=true;
  10. },
  11. check() {
  12. if (!this.email || this.email == "") {
  13. uni.showToast({
  14. title: '邮箱不能为空',
  15. icon: "none"
  16. });
  17. return false;
  18. }
  19. if (!this.password || this.password == "") {
  20. uni.showToast({
  21. title: '密码不能为空',
  22. icon: "none"
  23. });
  24. return false;
  25. }
  26. return true;
  27. },

image.png
为了投屏 先把密码类型删掉
image.png

image.png

本节代码

  1. <template>
  2. <view class="body">
  3. <input type="text" v-model="email"
  4. class="uni-input common-input"
  5. placeholder="输入旧密码" />
  6. <input type="text" v-model="password"
  7. class="uni-input common-input"
  8. placeholder="输入新密码" />
  9. <button class="user-set-btn"
  10. :class="{'user-set-btn-disable':disabled}"
  11. :loading="loading"
  12. @tap="submit" type="primary" :disabled="disabled">完成</button>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. email:'',
  20. password:"",
  21. disabled:true,
  22. loading:false
  23. }
  24. },
  25. watch:{
  26. email(val){
  27. this.change();
  28. },
  29. password(val){
  30. this.change();
  31. }
  32. },
  33. methods: {
  34. // 监听输入框
  35. change(){
  36. console.log('change事件');
  37. if(this.email && this.password){
  38. this.disabled=false;
  39. console.log('change事件,修改disable为false');
  40. return;
  41. }
  42. this.disabled=true;
  43. },
  44. // 验证层
  45. check() {
  46. if (!this.email || this.email == "") {
  47. uni.showToast({
  48. title: '邮箱不能为空',
  49. icon: "none"
  50. });
  51. return false;
  52. }
  53. if (!this.password || this.password == "") {
  54. uni.showToast({
  55. title: '密码不能为空',
  56. icon: "none"
  57. });
  58. return false;
  59. }
  60. return true;
  61. },
  62. // 提交
  63. submit() {
  64. this.loading=true;
  65. this.disabled=true;
  66. if(!this.check()){
  67. this.loading=false;
  68. this.disabled=false
  69. console.log('审核没过,直接pass');
  70. return;
  71. }
  72. uni.showToast({
  73. title:'验证通过',
  74. mask:false,
  75. duration:1500
  76. });
  77. this.loading=false;
  78. this.disabled=false;
  79. }
  80. }
  81. }
  82. </script>
  83. <style>
  84. @import url('@/common/form.css');
  85. </style>

结束