password.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="password-container">
  3. <view class="password-box">
  4. <view class="password-title">请输入配置密码</view>
  5. <view class="password-input-box">
  6. <u-input v-model="password" type="password" :placeholder="'请输入密码'" border="none" :clearable="true" :maxlength="20" @confirm="handleConfirm"></u-input>
  7. </view>
  8. <view class="password-tip" v-if="errorTip">{{ errorTip }}</view>
  9. <view class="password-buttons">
  10. <u-button type="primary" :loading="loading" @click="handleConfirm" class="password-button"> 确认 </u-button>
  11. <u-button type="default" @click="handleCancel" class="password-button"> 取消 </u-button>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script setup>
  17. /*----------------------------------依赖引入-----------------------------------*/
  18. import { ref, reactive } from "vue";
  19. import { onLoad } from "@dcloudio/uni-app";
  20. import { getCurrentInstance } from "vue";
  21. import { controlStores } from "@/store/modules/index";
  22. /*----------------------------------公共变量-----------------------------------*/
  23. const { proxy } = getCurrentInstance();
  24. const controlStore = controlStores();
  25. const password = ref("");
  26. const errorTip = ref("");
  27. const loading = ref(false);
  28. // 默认密码,可以从配置或存储中读取
  29. const defaultPassword = "123456";
  30. /**
  31. * @确认密码
  32. */
  33. function handleConfirm() {
  34. if (!password.value) {
  35. errorTip.value = "请输入密码";
  36. return;
  37. }
  38. loading.value = true;
  39. errorTip.value = "";
  40. // 模拟密码验证(实际可以从存储或服务器验证)
  41. setTimeout(() => {
  42. loading.value = false;
  43. if (password.value === defaultPassword) {
  44. // 密码正确,跳转到配置页面
  45. proxy.$tab.navigateTo("/pages/meeting/setting/index");
  46. } else {
  47. errorTip.value = "密码错误,请重新输入";
  48. password.value = "";
  49. }
  50. }, 300);
  51. }
  52. /**
  53. * @取消
  54. */
  55. function handleCancel() {
  56. proxy.$tab.navigateBack(1);
  57. controlStore.initCamera(); //初始化摄像头
  58. }
  59. onLoad(() => {});
  60. </script>
  61. <style lang="scss" scoped>
  62. .password-container {
  63. width: 100%;
  64. height: 100vh;
  65. display: flex;
  66. align-items: center;
  67. justify-content: center;
  68. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  69. }
  70. .password-box {
  71. width: 90%;
  72. max-width: 400px;
  73. background: #fff;
  74. border-radius: 16px;
  75. padding: 40px 30px;
  76. box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  77. }
  78. .password-title {
  79. font-size: 24px;
  80. font-weight: 600;
  81. color: #333;
  82. text-align: center;
  83. margin-bottom: 30px;
  84. }
  85. .password-input-box {
  86. margin-bottom: 20px;
  87. }
  88. .password-tip {
  89. color: #fa3534;
  90. font-size: 14px;
  91. text-align: center;
  92. margin-bottom: 20px;
  93. min-height: 20px;
  94. }
  95. .password-buttons {
  96. display: flex;
  97. gap: 15px;
  98. }
  99. .password-button {
  100. flex: 1;
  101. }
  102. </style>