modify-password.vue 4.8 KB

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