index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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">
  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">
  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">
  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">
  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">
  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">
  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">
  50. <view class="title">常用设备管理</view>
  51. </view>
  52. </view>
  53. </view>
  54. <view class="menu-list mt0 mlr0" @click="handleUserModal('手机号验证')">
  55. <view class="list-cell">
  56. <view class="menu-item">
  57. <view class="button error">注 销 账 号</view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <u-modal :show="modalShow" :showConfirmButton="true" :showCancelButton="true" @cancel="handleCancel()" @close="handleCancel()" @confirm="handleConfirm()">
  64. <view class="slot-content" style="width: 100%">
  65. <view v-if="modalTitle === '修改手机号'">
  66. <view class="mb15" style="text-align: center; color: #000; font-weight: 600">{{ modalTitle }}</view>
  67. <u-input v-model="phone" placeholder="请输入手机号" :maxlength="11" border="bottom" />
  68. <u-input v-model="verify" placeholder="请输入验证码" :maxlength="6" border="bottom">
  69. <template #suffix>
  70. <button class="verify" @click="getVerifyCode">{{ !useStore.codeTime ? "获取验证码" : useStore.codeTime + "s" }}</button>
  71. </template>
  72. </u-input>
  73. </view>
  74. <view v-if="modalTitle === '修改密码'">
  75. <view class="mb15" style="text-align: center; color: #000; font-weight: 600">{{ modalTitle }}</view>
  76. <u-input class="mb15" v-model="oldPassword" placeholder="请输入旧密码" :password="oldPasswordBool" border="bottom">
  77. <template #suffix>
  78. <text :class="!oldPasswordBool ? 'iconfont oaIcon-eye' : 'iconfont oaIcon-eye-close'" @click="oldPasswordBool = !oldPasswordBool"></text>
  79. </template>
  80. </u-input>
  81. <u-input class="mb15" v-model="newPassword" placeholder="请输入新密码" :password="newPasswordBool" border="bottom">
  82. <template #suffix>
  83. <text :class="!newPasswordBool ? 'iconfont oaIcon-eye' : 'iconfont oaIcon-eye-close'" @click="newPasswordBool = !newPasswordBool"></text>
  84. </template>
  85. </u-input>
  86. <u-input v-model="confirmPassword" placeholder="请再次输入新的密码" :password="confirmPasswordBool" border="bottom">
  87. <template #suffix>
  88. <text :class="!confirmPasswordBool ? 'iconfont oaIcon-eye' : 'iconfont oaIcon-eye-close'" @click="confirmPasswordBool = !confirmPasswordBool"></text>
  89. </template>
  90. </u-input>
  91. </view>
  92. <view v-if="modalTitle === '手机号验证'">
  93. <view class="mb5" style="text-align: center; color: #000; font-weight: 600">{{ modalTitle }}</view>
  94. <view class="mb15" style="text-align: center; color: #000; font-size: 0.75rem; width: 90%; margin: 0 auto"> 请填写完整的手机号 {{ user.phonenumber }} 以验证身份 </view>
  95. <u-input v-model="phone" placeholder="请输入手机号" :maxlength="11" border="bottom" />
  96. <u-input v-model="verify" placeholder="请输入验证码" :maxlength="6" border="bottom">
  97. <template #suffix>
  98. <button class="verify" @click="getVerifyCode">{{ !useStore.codeTime ? "获取验证码" : useStore.codeTime + "s" }}</button>
  99. </template>
  100. </u-input>
  101. </view>
  102. </view>
  103. </u-modal>
  104. </template>
  105. <script setup>
  106. import config from "@/config";
  107. import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  108. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  109. import { useStores, commonStores } from "@/store/modules/index";
  110. import { updateUserProfile, updateUserPwd } from "@/api/system/user";
  111. const useStore = useStores();
  112. const { proxy } = getCurrentInstance();
  113. const data = reactive({
  114. modalShow: false,
  115. modalTitle: "",
  116. oldPassword: undefined,
  117. oldPasswordBool: true,
  118. newPassword: undefined,
  119. newPasswordBool: true,
  120. confirmPassword: undefined,
  121. confirmPasswordBool: true,
  122. phone: undefined,
  123. verify: undefined,
  124. });
  125. const { modalShow, modalTitle, oldPassword, oldPasswordBool, newPassword, newPasswordBool, confirmPassword, confirmPasswordBool, phone, verify } = toRefs(data);
  126. const { avatar, user, userArr } = toRefs(useStore);
  127. function handleUserModal(title) {
  128. modalShow.value = true;
  129. modalTitle.value = title;
  130. }
  131. /** 确定按钮 */
  132. function handleConfirm() {
  133. if (modalTitle.value == "修改手机号") {
  134. useStore.PhoneVerify({
  135. data: {
  136. phone: phone.value,
  137. verify: verify.value,
  138. },
  139. success: (res) => {
  140. userArr.value.phonenumber = phone.value;
  141. updateUserProfile(userArr.value).then((response) => {
  142. proxy.$modal.msgSuccess("修改成功");
  143. handleCancel(); //调用取消按钮
  144. useStore.GetUser();
  145. });
  146. },
  147. error: (res) => {
  148. return false;
  149. },
  150. });
  151. }
  152. if (modalTitle.value == "修改密码") {
  153. if (!oldPassword.value) {
  154. proxy.$modal.showToast("旧密码不能为空");
  155. return;
  156. }
  157. if (!newPassword.value) {
  158. proxy.$modal.showToast("新密码不能为空");
  159. return;
  160. }
  161. if (newPassword.value.length < 6 && newPassword.value.length > 20) {
  162. proxy.$modal.showToast("长度在 6 到 20 个字符");
  163. return;
  164. }
  165. if (!confirmPassword.value) {
  166. proxy.$modal.showToast("确认密码不能为空");
  167. return;
  168. }
  169. if (confirmPassword.value != newPassword.value) {
  170. proxy.$modal.showToast("两次输入的密码不一致");
  171. return;
  172. }
  173. updateUserPwd(oldPassword.value, newPassword.value).then((response) => {
  174. proxy.$modal.msgSuccess("修改成功");
  175. handleCancel(); //调用取消按钮
  176. useStore.GetUser();
  177. });
  178. }
  179. if (modalTitle.value == "手机号验证") {
  180. if (phone.value != userArr.value.phonenumber) {
  181. proxy.$modal.msg("请输入正确的手机号");
  182. return;
  183. }
  184. useStore.PhoneVerify({
  185. data: {
  186. phone: phone.value,
  187. verify: verify.value,
  188. },
  189. success: (res) => {
  190. useStore.UserDel({
  191. data: {
  192. id: user.value.userId,
  193. },
  194. success: (res) => {
  195. proxy.$modal.msgSuccess("用户注销成功");
  196. handleCancel(); //调用取消按钮
  197. useStore.LogOut().then(() => {
  198. proxy.$tab.reLaunch("/pages/index");
  199. });
  200. },
  201. });
  202. },
  203. error: (res) => {
  204. return false;
  205. },
  206. });
  207. }
  208. }
  209. /** 取消按钮 */
  210. function handleCancel() {
  211. modalShow.value = false;
  212. modalTitle.value = "";
  213. oldPassword.value = undefined;
  214. oldPasswordBool.value = true;
  215. newPassword.value = undefined;
  216. newPasswordBool.value = true;
  217. confirmPassword.value = undefined;
  218. confirmPasswordBool.value = true;
  219. phone.value = undefined;
  220. verify.value = undefined;
  221. }
  222. /** 点击发送验证码 */
  223. function getVerifyCode() {
  224. if (modalTitle.value == "手机号验证" && phone.value != userArr.value.phonenumber) {
  225. proxy.$modal.msg("请输入正确的手机号");
  226. return;
  227. }
  228. verify.value = undefined;
  229. useStore.GetCodeImg({
  230. phone: phone.value,
  231. success: (res) => {
  232. proxy.$modal.msgSuccess("发送成功");
  233. },
  234. });
  235. }
  236. onLoad((options) => {
  237. useStore.GetUser();
  238. });
  239. onReady(() => {});
  240. onShow(() => {
  241. //调用系统主题颜色
  242. proxy.$settingStore.systemThemeColor([1]);
  243. });
  244. // 自定义导航事件
  245. onNavigationBarButtonTap((e) => {
  246. if (e.float == "right") {
  247. proxy.$tab.navigateTo("/pages/mine/setting/index");
  248. }
  249. });
  250. </script>
  251. <style lang="scss" scoped></style>