editpassword.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view>
  3. <scroll-view scroll-y class="page">
  4. <cu-custom bgColor="bg-luohu" :isBack="true">
  5. <block slot="backText">返回</block>
  6. <block slot="content">修改密码</block>
  7. </cu-custom>
  8. <view class="example-body " style="display: flex;justify-content: center; margin-top: 80rpx;">
  9. <u-avatar :src="photo" size="160">
  10. </u-avatar>
  11. </view>
  12. <uni-card>
  13. <view class="cu-list menu">
  14. <view class="cu-form-group">
  15. <view class="title">密码</view>
  16. <input placeholder="请输入六位以上密码" name="input" type="password" v-model="password"></input>
  17. </view>
  18. <view class="cu-form-group">
  19. <view class="title">确认</view>
  20. <input placeholder="请再输入一遍密码" name="input" type="password" v-model="again"></input>
  21. </view>
  22. </view>
  23. </uni-card>
  24. <view class="padding flex flex-direction" style="margin-bottom: 100rpx;">
  25. <button class="cu-btn bg-blue lg btn-back-color" @click="submit">确认修改</button>
  26. </view>
  27. </scroll-view>
  28. </view>
  29. </template>
  30. <script>
  31. import {
  32. ACCESS_TOKEN,
  33. USER_NAME,
  34. USER_INFO
  35. } from "@/common/util/constants"
  36. import api from '@/api/api.js'
  37. import http from '@/common/service/http.js'
  38. export default {
  39. data() {
  40. return {
  41. password: "",
  42. again: "",
  43. id: '',
  44. photo: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg'
  45. };
  46. },
  47. onLoad() {
  48. let user = uni.getStorageSync(USER_INFO).user;
  49. this.id = user.id
  50. this.loadinfo()
  51. },
  52. methods: {
  53. loadinfo() {
  54. let token = uni.getStorageSync(ACCESS_TOKEN)
  55. this.$http.get('ibps/platform/v3/employee/load', {
  56. params: {
  57. employeeId: this.id
  58. }
  59. }).then(res => {
  60. if (res.data.state == '200') {
  61. let result = res.data.data
  62. this.user = result
  63. if (result.photo != '') {
  64. this.photo = http.apiHosp + 'ibps/platform/v3' + this.user.photo +
  65. '&access_token=' +
  66. token + '&tenantId='
  67. }
  68. }
  69. }).catch(e => {})
  70. },
  71. submit() {
  72. if (!this.password || this.password.length < 6) {
  73. uni.showToast({
  74. title: '密码长度不小于6位',
  75. icon: 'none',
  76. duration: 2000
  77. })
  78. return false
  79. }
  80. if (this.password != this.again) {
  81. uni.showToast({
  82. title: '两次输入不一致 ',
  83. icon: 'none',
  84. duration: 2000
  85. })
  86. return false
  87. }
  88. let reg = new RegExp(/^(?![^a-zA-Z]+$)(?!\D+$)/)
  89. if (!reg.test(this.password)) {
  90. uni.showToast({
  91. title: '密码必须包含数字和字母',
  92. icon: 'none',
  93. duration: 2000
  94. })
  95. return false
  96. }
  97. let data = {
  98. "userIds": [
  99. this.id,
  100. ],
  101. "newPassword": this.password,
  102. "repeatPassword": this.again,
  103. "primitivePassword": "",
  104. "reset": 1
  105. };
  106. this.$methCommon.getShowLoading()
  107. let that = this;
  108. this.$http.post("/ibps/platform/v3/user/change/passwd", data).then(res => {
  109. if (res.data.state == 200) {
  110. that.$tip.toast("修改成功")
  111. uni.reLaunch({
  112. url: "/pages/index/index"
  113. })
  114. uni.hideLoading()
  115. } else {
  116. this.$methCommon.getPrompt('修改失败!', 'fail')
  117. uni.hideLoading()
  118. }
  119. })
  120. }
  121. }
  122. }
  123. </script>
  124. <style>
  125. .page {
  126. height: 100Vh;
  127. width: 100vw;
  128. }
  129. .page.show {
  130. overflow: hidden;
  131. }
  132. .switch-sex::after {
  133. content: "\e716";
  134. }
  135. .switch-sex::before {
  136. content: "\e7a9";
  137. }
  138. .switch-music::after {
  139. content: "\e66a";
  140. }
  141. .switch-music::before {
  142. content: "\e6db";
  143. }
  144. .example-body {
  145. padding: 10px;
  146. padding-top: 0;
  147. }
  148. .custom-image-box {
  149. /* #ifndef APP-NVUE */
  150. display: flex;
  151. /* #endif */
  152. flex-direction: row;
  153. justify-content: space-between;
  154. align-items: center;
  155. }
  156. .text {
  157. font-size: 14px;
  158. color: #333;
  159. }
  160. </style>