index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view :data-theme="'theme-' + proxy.$settingStore.themeColor.name" class="secure-container">
  3. <view class="content-section">
  4. <view class="menu-list mt0 mlr0">
  5. <view></view>
  6. <image style="width: 100%; height: 160px" src="@/static/images/index/banner2.jpg" mode="widthFix"></image>
  7. </view>
  8. <view class="menu-list mt0 mlr0">
  9. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改手机号')">
  10. <view class="menu-item-box">
  11. <view class="title">手机号码</view>
  12. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.phonenumber }}</view>
  13. </view>
  14. </view>
  15. <view class="list-cell list-cell-arrow" @click="handleUserModal('修改密码')">
  16. <view class="menu-item-box">
  17. <view class="title">密码</view>
  18. <view style="margin: 0 15px 0 auto; font-size: 14px; color: #909399">{{ user.password ? "已设置" : "未设置" }}</view>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="menu-list mt0 mlr0">
  23. <!-- #ifdef APP-PLUS || MP-WEIXIN -->
  24. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  25. <!-- <view class="list-cell list-cell-arrow" @click="proxy.$tab.navigateTo(`/pages/mine/secure/fingerprint/index`)"> -->
  26. <view class="menu-item-box">
  27. <view class="title">指纹登录</view>
  28. </view>
  29. </view>
  30. <!-- #endif -->
  31. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  32. <view class="menu-item-box">
  33. <view class="title">人脸</view>
  34. </view>
  35. </view>
  36. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  37. <view class="menu-item-box">
  38. <view class="title">手势密码</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="menu-list mt0 mlr0">
  43. <view class="list-cell list-cell-arrow" @click="proxy.$tab.navigateTo(`/pages/mine/secure/loginLog/index`)">
  44. <view class="menu-item-box">
  45. <view class="title">登录日志</view>
  46. </view>
  47. </view>
  48. <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
  49. <view class="menu-item-box">
  50. <view class="title">常用设备管理</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <u-modal :show="modalShow" :showConfirmButton="true" :showCancelButton="true" @cancel="modalShow = false" @confirm="handleConfirm">
  57. <view class="slot-content" style="width: 100%">
  58. <view class="mb15" style="color: #909399">{{ modalTitle }}</view>
  59. <view v-if="modalTitle === '修改手机号'">
  60. <u--input v-model="userArr.phonenumber" :maxlength="11" :placeholder="modalTitle" border="bottom" clearable></u--input>
  61. </view>
  62. <view v-if="modalTitle === '修改密码'">
  63. <u-input class="mb15" v-model="oldPassword" placeholder="请输入旧密码" :password="oldPasswordBool" border="bottom">
  64. <template #suffix>
  65. <text :class="!oldPasswordBool ? 'iconfont ucicon-eye' : 'iconfont ucicon-eye-close'" @click="oldPasswordBool = !oldPasswordBool"></text>
  66. </template>
  67. </u-input>
  68. <u-input class="mb15" v-model="newPassword" placeholder="请输入新密码" :password="newPasswordBool" border="bottom">
  69. <template #suffix>
  70. <text :class="!newPasswordBool ? 'iconfont ucicon-eye' : 'iconfont ucicon-eye-close'" @click="newPasswordBool = !newPasswordBool"></text>
  71. </template>
  72. </u-input>
  73. <u-input v-model="confirmPassword" placeholder="请再次输入新的密码" :password="confirmPasswordBool" border="bottom">
  74. <template #suffix>
  75. <text :class="!confirmPasswordBool ? 'iconfont ucicon-eye' : 'iconfont ucicon-eye-close'" @click="confirmPasswordBool = !confirmPasswordBool"></text>
  76. </template>
  77. </u-input>
  78. </view>
  79. </view>
  80. </u-modal>
  81. </template>
  82. <script setup>
  83. import config from "@/config";
  84. import storage from "@/utils/storage";
  85. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  86. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  87. import { publicStores, useStores } from "@/store/modules/index";
  88. import { updateUserProfile, updateUserPwd } from "@/api/system/user";
  89. const useStore = useStores();
  90. const { proxy } = getCurrentInstance();
  91. const avatar = computed(() => {
  92. return useStore.$state.avatar;
  93. });
  94. const user = computed(() => {
  95. return useStore.$state.user;
  96. });
  97. const userArr = computed(() => {
  98. return useStore.$state.userArr;
  99. });
  100. const data = reactive({
  101. modalShow: false,
  102. modalTitle: "",
  103. oldPassword: undefined,
  104. oldPasswordBool: true,
  105. newPassword: undefined,
  106. newPasswordBool: true,
  107. confirmPassword: undefined,
  108. confirmPasswordBool: true,
  109. });
  110. const { modalShow, modalTitle, oldPassword, oldPasswordBool, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool } = toRefs(data);
  111. function handleUserModal(title) {
  112. modalShow.value = true;
  113. modalTitle.value = title;
  114. }
  115. function handleConfirm() {
  116. if (modalTitle.value == "修改手机号") {
  117. if (!userArr.value.phonenumber) {
  118. proxy.$modal.showToast("手机号码不能为空");
  119. return;
  120. }
  121. if (!/^1[3|4|5|6|7|8|9][0-9]\d{8}$/.test(userArr.value.phonenumber)) {
  122. proxy.$modal.showToast("请输入正确的手机号码");
  123. return;
  124. }
  125. }
  126. if (modalTitle.value == "修改密码") {
  127. if (!oldPassword.value) {
  128. proxy.$modal.showToast("旧密码不能为空");
  129. return;
  130. }
  131. if (!newPassword.value) {
  132. proxy.$modal.showToast("新密码不能为空");
  133. return;
  134. }
  135. if (newPassword.value.length < 6 && newPassword.value.length > 20) {
  136. proxy.$modal.showToast("长度在 6 到 20 个字符");
  137. return;
  138. }
  139. if (!confirmPassword.value) {
  140. proxy.$modal.showToast("确认密码不能为空");
  141. return;
  142. }
  143. if (confirmPassword.value != newPassword.value) {
  144. proxy.$modal.showToast("两次输入的密码不一致");
  145. return;
  146. }
  147. }
  148. if (modalTitle.value == "修改手机号") {
  149. updateUserProfile(userArr.value).then((response) => {
  150. proxy.$modal.msgSuccess("修改成功");
  151. modalShow.value = false;
  152. useStore.getUser();
  153. });
  154. } else if (modalTitle.value == "修改密码") {
  155. updateUserPwd(oldPassword.value, newPassword.value).then((response) => {
  156. proxy.$modal.msgSuccess("修改成功");
  157. modalShow.value = false;
  158. oldPassword.value = undefined;
  159. oldPasswordBool.value = true;
  160. newPassword.value = undefined;
  161. newPasswordBool.value = true;
  162. confirmPassword.value = undefined;
  163. confirmPasswordBool.value = true;
  164. useStore.getUser();
  165. });
  166. }
  167. }
  168. onLoad((options) => {
  169. useStore.getUser();
  170. });
  171. onReady(() => {});
  172. onShow(() => {
  173. //调用系统主题颜色
  174. proxy.$settingStore.systemThemeColor([1]);
  175. });
  176. // 自定义导航事件
  177. onNavigationBarButtonTap((e) => {
  178. if (e.float == "right") {
  179. proxy.$tab.navigateTo("/pages/mine/setting/index");
  180. }
  181. });
  182. </script>
  183. <style lang="scss" scoped></style>