modify-password.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="container">
  3. <uNavBar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  4. :title="title" @clickLeft="toBack">
  5. </uNavBar>
  6. <view class="content">
  7. <view class="form">
  8. <view class="cell">
  9. <view class="name"><text style="color: #FF0000; font-weight: bold;font-size: 20px;">*</text>旧密码
  10. </view>
  11. <input type="text" password="true" placeholder="输入旧密码" v-model="oldPassword" class="ipt" placeholder-class="hold" />
  12. </view>
  13. <view class="cell">
  14. <view class="name"><text style="color: #FF0000; font-weight: bold;font-size: 20px;">*</text>新密码
  15. </view>
  16. <input type="text" password="true" placeholder="输入新密码" v-model="newPassword" class="ipt" placeholder-class="hold" />
  17. </view>
  18. <view class="cell">
  19. <view class="name"><text style="color: #FF0000; font-weight: bold;font-size: 20px;">*</text>确认新密码
  20. </view>
  21. <input type="text" password="true" placeholder="再次输入新密码" v-model="newPassword1" class="ipt"
  22. placeholder-class="hold" />
  23. </view>
  24. <u-gap height="50"></u-gap>
  25. <view class="cell">
  26. <view style="width: 100%;">
  27. <button type="warn" @click="formSubmit()">提交</button>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import http from '@/http/api.js'
  36. import md5 from '@/utils/md5.js'
  37. import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
  38. export default {
  39. components: {
  40. uNavBar
  41. },
  42. data() {
  43. return {
  44. title:'修改密码',
  45. oldPassword: '',
  46. newPassword: '',
  47. newPassword1: ''
  48. };
  49. },
  50. onLoad() {
  51. },
  52. methods: {
  53. toBack() {
  54. uni.navigateBack({
  55. delta: 1
  56. })
  57. },
  58. formSubmit: function() {
  59. const that = this;
  60. if (this.oldPassword.length > 0 && this.newPassword.length > 0 && this.newPassword1.length > 0) {
  61. uni.showModal({
  62. content: '确定修改密码?',
  63. showCancel: true,
  64. success(res) {
  65. if (res.confirm) {
  66. let oldPassword = md5(that.oldPassword);
  67. let newPassword = md5(that.newPassword);
  68. let newPassword1 = md5(that.newPassword1);
  69. http.request({
  70. url: '/galaxy-user/update-password',
  71. method: 'POST',
  72. params: {
  73. oldPassword,
  74. newPassword,
  75. newPassword1
  76. }
  77. }).then(res => {
  78. console.log(JSON.stringify(res.data))
  79. if (res.success) {
  80. uni.showModal({
  81. content: '修改已成功',
  82. showCancel: false,
  83. success(res) {
  84. if (res.confirm) {
  85. that.$u.func.logout();
  86. }
  87. }
  88. });
  89. }
  90. }).catch(err => {
  91. console.log(err)
  92. })
  93. }
  94. }
  95. });
  96. } else {
  97. uni.showModal({
  98. content: '请确认必填项',
  99. showCancel: false
  100. });
  101. }
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss">
  107. .container {
  108. background-color: #f7f7f7;
  109. min-height: 100vh;
  110. padding: 0 0 200rpx;
  111. overflow: hidden;
  112. }
  113. .complie {
  114. vertical-align: middle;
  115. padding: 10rpx 20rpx;
  116. font-size: 32rpx;
  117. font-family: Source Han Sans CN;
  118. font-weight: 400;
  119. color: #14b9c8;
  120. }
  121. .content {
  122. background-color: #ffffff;
  123. overflow: hidden;
  124. }
  125. .avatar {
  126. margin-top: 30rpx;
  127. display: flex;
  128. justify-content: center;
  129. align-items: center;
  130. flex-direction: column;
  131. font-size: 30rpx;
  132. font-family: Source Han Sans CN;
  133. font-weight: 400;
  134. color: #14b9c8;
  135. .avatar-image {
  136. width: 162rpx;
  137. height: 162rpx;
  138. background: #ffffff;
  139. border-radius: 50%;
  140. background-color: #82848a;
  141. margin-bottom: 15rpx;
  142. }
  143. }
  144. .form {
  145. padding: 0 36rpx;
  146. .cell {
  147. display: flex;
  148. justify-content: space-between;
  149. align-items: center;
  150. padding: 40rpx 0;
  151. font-size: 30rpx;
  152. font-family: Source Han Sans CN;
  153. font-weight: bold;
  154. color: #666666;
  155. &:not(:last-of-type) {
  156. border-bottom: 2rpx solid #efefef;
  157. }
  158. .ipt {
  159. flex: 1;
  160. margin-left: 40rpx;
  161. text-align: right;
  162. font-size: 23rpx;
  163. font-family: Source Han Sans CN;
  164. font-weight: bold;
  165. color: #333333;
  166. }
  167. .hold {
  168. font-size: 27rpx;
  169. font-family: Source Han Sans CN;
  170. font-weight: bold;
  171. color: #c8c8ce;
  172. }
  173. }
  174. }
  175. .back {
  176. margin-top: 40rpx;
  177. text-align: center;
  178. height: 109rpx;
  179. background: #ffffff;
  180. font-size: 34rpx;
  181. font-family: Source Han Sans CN;
  182. font-weight: bold;
  183. color: #141414;
  184. line-height: 109rpx;
  185. }
  186. </style>