modifyPass.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <view class="modify-pass">
  3. <navbar ref="navbar" :config="config" backColor="#666"></navbar>
  4. <form @submit="formSubmit">
  5. <view class="middle">
  6. <view class="password">
  7. 原密码
  8. </view>
  9. <input type="text" password="true" name="phone" @input="onPhone"
  10. placeholder-style="font-size: 28rpx;font-weight: 500;color:#CCCCCC;line-height: 28px;"
  11. maxlength="13" placeholder="请输入您的原密码" />
  12. </view>
  13. <view class="distance">
  14. </view>
  15. <view class="box">
  16. <view class="new-pass">
  17. <view class="new">
  18. 新密码
  19. </view>
  20. <input type="text" password="true" value="" name="newPass" @input="newPass"
  21. placeholder-style="font-size: 28rpx;font-weight: 500;color:#CCCCCC;line-height: 28px;"
  22. maxlength="13" placeholder="请输入您的新密码" />
  23. </view>
  24. <view class="determine-pass">
  25. <view class="determine">
  26. 确认密码
  27. </view>
  28. <input type="text" password="true" value="" name="confirm" @input="confirm"
  29. placeholder-style="font-size: 28rpx;font-weight: 500;color:#CCCCCC;line-height: 28px;"
  30. maxlength="13" placeholder="请再次输入您的新密码" />
  31. </view>
  32. </view>
  33. <view class="button">
  34. <button class="submit" form-type="submit">
  35. 确认修改
  36. </button>
  37. </view>
  38. </form>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. modifyPass
  44. } from "../../../api/login.js"
  45. export default {
  46. data() {
  47. return {
  48. config: {
  49. back: true, //false是tolbar页面 是则不写
  50. title: '修改密码',
  51. color: '#1A1A1A',
  52. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  53. backgroundColor: [1, "#FFFFFF"],
  54. statusBarFontColor: '#1A1A1A',
  55. // backTabPage: "/pages/index/my"
  56. },
  57. phone: "", //原密码
  58. pass: "", //新密码
  59. confirmPass: "", //确认密码
  60. }
  61. },
  62. methods: {
  63. //确认提交
  64. formSubmit(e) {
  65. let target = e.detail.value
  66. if (!target.phone) {
  67. this.$mUtil.toast("请输入原密码")
  68. return false
  69. }
  70. if (!target.newPass) {
  71. this.$mUtil.toast("请输入新密码")
  72. return false
  73. }
  74. if (!target.confirm) {
  75. this.$mUtil.toast("请输入确认密码")
  76. return false
  77. }
  78. if (!(target.newPass.match(target.confirm))) {
  79. this.$mUtil.toast("两次密码不一致")
  80. return false
  81. }
  82. // if(target.newPass!=target.confirm){
  83. // this.$mUtil.toast("两次密码不一致")
  84. // return false
  85. // }
  86. console.log(666)
  87. let param = {
  88. password: target.phone,
  89. new_password: target.newPass,
  90. }
  91. this.$http.post(modifyPass, param)
  92. .then(res => {
  93. console.log(res)
  94. if (res.code == 200) {
  95. this.$mUtil.toast("修改密码成功")
  96. this.$http.post("/account/logout").then(res => {
  97. if (res && res.code == 200) {
  98. setTimeout(() => {
  99. uni.clearStorageSync()
  100. uni.reLaunch({
  101. url: "../register/login"
  102. })
  103. }, 2000)
  104. }
  105. })
  106. } else {
  107. this.$mUtil.toast("原密码不正确")
  108. }
  109. })
  110. },
  111. //原密码
  112. onPhone(e) {
  113. this.phone = e.detail.value
  114. },
  115. //新密码
  116. newPass(e) {
  117. this.pass = e.detail.value
  118. },
  119. //确认密码
  120. confirm(e) {
  121. this.confirmPass = e.detail.value
  122. console.log(this.confirmPass)
  123. }
  124. }
  125. }
  126. </script>
  127. <style scoped lang="scss">
  128. .button {
  129. display: flex;
  130. margin-top: 800rpx;
  131. justify-content: center;
  132. .submit {
  133. font-size: 36rpx;
  134. font-weight: 400;
  135. color: #ffffff;
  136. padding: 0 274rpx;
  137. background-color: #0B844A;
  138. border-radius: 43rpx;
  139. }
  140. }
  141. .box {
  142. padding: 0 30rpx;
  143. .determine-pass {
  144. padding: 34rpx 0 30rpx;
  145. border-bottom: 1rpx solid #E6E6E6;
  146. display: flex;
  147. align-items: center;
  148. .determine {
  149. font-size: 28rpx;
  150. color: #1A1A1A;
  151. font-weight: 400;
  152. }
  153. input {
  154. margin-left: 60rpx;
  155. }
  156. }
  157. .new-pass {
  158. padding: 23rpx 0rpx 30rpx;
  159. display: flex;
  160. align-items: center;
  161. border-bottom: 1rpx solid #E6E6E6;
  162. .new {
  163. font-size: 28rpx;
  164. color: #1A1A1A;
  165. font-weight: 400;
  166. }
  167. input {
  168. margin-left: 88rpx;
  169. }
  170. }
  171. }
  172. .distance {
  173. height: 10rpx;
  174. background-color: #F5F5F5;
  175. }
  176. .middle {
  177. padding: 26rpx 30rpx 30rpx;
  178. display: flex;
  179. align-items: center;
  180. .password {
  181. font-size: 28rpx;
  182. font-weight: 400;
  183. color: #1A1A1A;
  184. }
  185. input {
  186. margin-left: 88rpx;
  187. }
  188. }
  189. </style>