pwd.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <view class="container">
  3. <view class="wrapper">
  4. <view class="input-content">
  5. <!-- <view class="cu-form-group" style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
  6. <text class="title">旧密码</text>
  7. <input type="password" :value="oldPwd" placeholder="请输入旧密码" placeholder-class="input-empty" maxlength="20"
  8. minlength="6" data-key="oldpassword" @input="inputChange" @confirm="toLogin" />
  9. </view> -->
  10. <view class="cu-form-group"
  11. style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
  12. <text class="title">新密码</text>
  13. <input type="password" :value="pwd" placeholder="请设置新密码" placeholder-class="input-empty"
  14. maxlength="6" minlength="6" data-key="password" @input="inputChange" />
  15. </view>
  16. <view class="cu-form-group"
  17. style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
  18. <text class="title">确认密码</text>
  19. <input type="password" :value="newpwd" placeholder="请设置新密码" placeholder-class="input-empty"
  20. maxlength="6" minlength="6" data-key="password" @input="inputChanges" />
  21. </view>
  22. </view>
  23. <button class="confirm-btn" @click="toLogin">修改密码</button>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. code: '',
  32. phone: '',
  33. password: '',
  34. oldpassword: '',
  35. sending: false,
  36. sendTime: '获取验证码',
  37. count: 60,
  38. logining: false,
  39. oldPwd: '',
  40. pwd: '',
  41. newpwd: '',
  42. username: ''
  43. }
  44. },
  45. onLoad() {
  46. this.getUserInfo()
  47. },
  48. methods: {
  49. getUserInfo() {
  50. this.$Request.getA("/sys/user/info").then(res => {
  51. if (res.code == 0) {
  52. this.phone = res.user.mobile
  53. this.salt = res.user.salt
  54. this.username = res.user.username
  55. }
  56. });
  57. },
  58. sendMsg() {
  59. const {
  60. phone
  61. } = this;
  62. if (!phone) {
  63. this.$queue.showToast("请输入手机号");
  64. } else if (phone.length !== 11) {
  65. this.$queue.showToast("请输入正确的手机号");
  66. } else {
  67. this.$queue.showLoading("正在发送验证码...");
  68. this.$Request.getT('/appLogin/sendMsg/' + phone + '/forget').then(res => {
  69. if (res.code === 0) {
  70. this.sending = true;
  71. this.$queue.showToast('验证码发送成功请注意查收');
  72. this.countDown();
  73. uni.hideLoading();
  74. } else {
  75. uni.hideLoading();
  76. uni.showModal({
  77. showCancel: false,
  78. title: '短信发送失败',
  79. content: res.msg ? res.msg : '请一分钟后再获取验证码'
  80. });
  81. }
  82. });
  83. }
  84. },
  85. countDown() {
  86. const {
  87. count
  88. } = this;
  89. if (count === 1) {
  90. this.count = 60;
  91. this.sending = false;
  92. this.sendTime = '获取验证码'
  93. } else {
  94. this.count = count - 1;
  95. this.sending = true;
  96. this.sendTime = count - 1 + '秒后重新获取';
  97. setTimeout(this.countDown.bind(this), 1000);
  98. }
  99. },
  100. inputChange(e) {
  101. // console.log(e, '----------')
  102. const key = e.currentTarget.dataset.key;
  103. this.pwd = e.detail.value;
  104. },
  105. inputChanges(e) {
  106. // console.log(e, '----------')
  107. const key = e.currentTarget.dataset.key;
  108. this.newpwd = e.detail.value;
  109. },
  110. navBack() {
  111. uni.navigateBack();
  112. },
  113. toLogin() {
  114. console.log(this.pwd.length)
  115. if (this.pwd.length != 6) {
  116. this.$queue.showToast("请输入六位数密码");
  117. } else if (this.newpwd.length != 6) {
  118. this.$queue.showToast("请再次输入六位数密码");
  119. } else if (this.pwd != this.newpwd) {
  120. this.$queue.showToast("密码不一致");
  121. } else {
  122. this.logining = true;
  123. this.$queue.showLoading("正在修改密码中...");
  124. let data = {
  125. mobile: this.phone,
  126. password: this.pwd,
  127. salt: this.salt,
  128. username: this.username
  129. }
  130. this.$Request.postJson("/sys/user/updateShop", data).then(res => {
  131. uni.hideLoading();
  132. if (res.code === 0) {
  133. this.$queue.showToast('密码修改成功!下次请使用新密码登录!')
  134. setTimeout(function() {
  135. uni.navigateBack()
  136. }, 1000)
  137. } else {
  138. uni.showModal({
  139. showCancel: false,
  140. title: '密码修改失败',
  141. content: res.msg,
  142. });
  143. }
  144. });
  145. }
  146. },
  147. },
  148. }
  149. </script>
  150. <style lang='scss'>
  151. page {
  152. height: 100%;
  153. background: #FFFFFF !important;
  154. }
  155. .container {
  156. /* padding-top: 32upx; */
  157. position: relative;
  158. width: 100%;
  159. height: 100%;
  160. overflow: hidden;
  161. background: #FFFFFF !important;
  162. }
  163. .wrapper {
  164. position: relative;
  165. z-index: 90;
  166. background: #ffffff;
  167. padding-bottom: 20px;
  168. }
  169. .input-content {
  170. padding: 32upx 80upx;
  171. }
  172. .confirm-btn {
  173. width: 600upx;
  174. height: 80upx;
  175. line-height: 80upx;
  176. border-radius: 60upx;
  177. margin-top: 32upx;
  178. background: #FCD202;
  179. /* color: #fff; */
  180. font-size: 32upx;
  181. &:after {
  182. border-radius: 60px;
  183. }
  184. }
  185. </style>