editpassword.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. let that = this;
  107. this.$http.post("/ibps/platform/v3/user/change/passwd", data).then(res => {
  108. if (res.data.state == 200) {
  109. that.$tip.toast("修改成功")
  110. uni.navigateTo({
  111. url: "/pages/index/index"
  112. })
  113. } else {
  114. this.$tip.toast("发送异常");
  115. }
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style>
  122. .page {
  123. height: 100Vh;
  124. width: 100vw;
  125. }
  126. .page.show {
  127. overflow: hidden;
  128. }
  129. .switch-sex::after {
  130. content: "\e716";
  131. }
  132. .switch-sex::before {
  133. content: "\e7a9";
  134. }
  135. .switch-music::after {
  136. content: "\e66a";
  137. }
  138. .switch-music::before {
  139. content: "\e6db";
  140. }
  141. .example-body {
  142. padding: 10px;
  143. padding-top: 0;
  144. }
  145. .custom-image-box {
  146. /* #ifndef APP-NVUE */
  147. display: flex;
  148. /* #endif */
  149. flex-direction: row;
  150. justify-content: space-between;
  151. align-items: center;
  152. }
  153. .text {
  154. font-size: 14px;
  155. color: #333;
  156. }
  157. </style>