forgotPassword.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <view class="tab-page">
  3. <view class="backimage">
  4. <image class="back" src="/static/image/login/back.png" mode=""></image>
  5. <image class="title-img" src="/static/image/login/forgotPassword.png" mode=""></image>
  6. <image class="title" src="/static/image/login/title.png" mode=""></image>
  7. </view>
  8. <view class="info">
  9. <u--form labelPosition="left" :model="info" ref="ownerForm" labelWidth="60" errorType="message"
  10. :labelStyle="{fontWeight:'bold',color:'#333'}">
  11. <u-form-item label="手机号" borderBottom>
  12. <u--input v-model="info.mobile" border="none" clearable placeholder="请输入手机号" maxlength="11"
  13. placeholderStyle="color:#999"></u--input>
  14. </u-form-item>
  15. <u-form-item label="验证码" borderBottom>
  16. <u--input v-model="info.smsCode" border="none" clearable placeholder="请输入手机验证码" maxlength="6"
  17. placeholderStyle="color:#999">
  18. </u--input>
  19. <view class="suffixClass dis">
  20. <u-code ref="uCode2" @change="codeChange2" keep-running start-text="发送验证码"
  21. style="color: #F9E000;" uniqueKey="forgotPassword"></u-code>
  22. <view @tap="getCode2" :text="tips2" class="u-page__code-text">{{tips2}}</view>
  23. </view>
  24. </u-form-item>
  25. <u-form-item label="新密码" borderBottom>
  26. <u--input v-model="info.password" border="none" clearable placeholder="请输入密码"
  27. placeholderStyle="color:#999" :password="isHidePassword">
  28. </u--input>
  29. <view class="suffixClass">
  30. <image class="icon-img"
  31. :src="isHidePassword?'/static/image/login/icon-hide.png':'/static/image/login/icon-show.png'"
  32. mode="" @tap="isHidePassword=!isHidePassword"></image>
  33. </view>
  34. </u-form-item>
  35. </u--form>
  36. <view class="performLogin">
  37. <view class="buttom dis a-c j-c " @click="confirm">
  38. <text>确定</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. export default {
  46. data() {
  47. return {
  48. isHidePassword: true, //是否隐藏密码
  49. tips2: '',
  50. info: {
  51. mobile: "",
  52. password: "",
  53. smsCode: "",
  54. }
  55. }
  56. },
  57. onLoad(params) {
  58. if (params.phone) {
  59. this.info.mobile = params.phone;
  60. }
  61. },
  62. onShow() {},
  63. methods: {
  64. //修改密码
  65. async confirm() {
  66. if (!this.info.mobile) {
  67. return uni.showToast({
  68. title: '请输入手机号',
  69. icon: 'none'
  70. });
  71. }
  72. if (!this.info.smsCode) {
  73. return uni.showToast({
  74. title: '验证码不能为空',
  75. icon: 'none'
  76. });
  77. }
  78. if (!this.info.password) {
  79. return uni.showToast({
  80. title: '新密码不能为空',
  81. icon: 'none'
  82. });
  83. }
  84. let res = await this.$http.post('/auth/forgotPassword', this.info);
  85. if (res.code == '200') {
  86. uni.showToast({
  87. title: '密码修改成功',
  88. icon: 'none'
  89. });
  90. uni.navigateTo({
  91. url: "/pages/login/login"
  92. })
  93. } else {
  94. uni.showToast({
  95. title: res.msg,
  96. icon: 'none'
  97. });
  98. }
  99. },
  100. codeChange2(text) {
  101. this.tips2 = text;
  102. },
  103. getCode2() {
  104. if (!this.info.mobile) {
  105. uni.showToast({
  106. title: '手机号为空',
  107. icon: 'none'
  108. });
  109. return;
  110. }
  111. if (this.$refs.uCode2.canGetCode) {
  112. this.smsCode(); // 向后端请求验证码
  113. uni.showLoading({
  114. title: '正在获取验证码'
  115. })
  116. setTimeout(() => {
  117. uni.hideLoading();
  118. // 这里此提示会被this.start()方法中的提示覆盖
  119. uni.$u.toast('验证码已发送');
  120. // 通知验证码组件内部开始倒计时
  121. this.$refs.uCode2.start();
  122. }, 1000);
  123. } else {
  124. uni.$u.toast('倒计时结束后再发送');
  125. }
  126. },
  127. async smsCode() {
  128. let res = await this.$http.get('/auth/sendSmsCode?mobile=' + this.info.mobile);
  129. },
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. page {
  135. background-color: #fff;
  136. }
  137. .backimage {
  138. width: 100%;
  139. height: 503rpx;
  140. background-color: #fff;
  141. position: relative;
  142. .back {
  143. width: 100%;
  144. height: 100%;
  145. }
  146. .title-img {
  147. position: absolute;
  148. top: 247rpx;
  149. left: 60rpx;
  150. width: 258rpx;
  151. height: 91rpx;
  152. }
  153. .title {
  154. position: absolute;
  155. top: 347rpx;
  156. left: 60rpx;
  157. width: 468rpx;
  158. height: 36rpx;
  159. }
  160. }
  161. .info {
  162. padding: 0 75rpx;
  163. box-sizing: border-box;
  164. .icon-img {
  165. width: 30rpx;
  166. height: 30rpx;
  167. }
  168. }
  169. //登录
  170. .performLogin {
  171. margin-top: 100rpx;
  172. .buttom {
  173. width: 100%;
  174. padding: 19rpx;
  175. box-sizing: border-box;
  176. background-color: #FDE935;
  177. border-radius: 45rpx;
  178. font-weight: bold;
  179. font-size: 36rpx;
  180. color: #1f1f1f;
  181. }
  182. .arigon {
  183. font-size: 28rpx;
  184. color: #666;
  185. padding: 0 30rpx;
  186. box-sizing: border-box;
  187. }
  188. }
  189. .footer {
  190. position: fixed;
  191. left: 0;
  192. right: 0;
  193. bottom: 62rpx;
  194. text {
  195. font-size: 26rpx;
  196. color: #999;
  197. }
  198. }
  199. .codemodal {
  200. padding: 40rpx;
  201. box-sizing: border-box;
  202. .buttom {
  203. width: 100%;
  204. padding: 19rpx;
  205. box-sizing: border-box;
  206. background-color: #FDE935;
  207. border-radius: 45rpx;
  208. font-weight: bold;
  209. font-size: 36rpx;
  210. color: #1f1f1f;
  211. }
  212. }
  213. .sendcode {
  214. font-size: 28rpx;
  215. color: #F9E000;
  216. }
  217. .u-page__code-text {
  218. padding: 4rpx 18rpx;
  219. background: rgba(253, 233, 53, 0.2);
  220. border-radius: 6rpx 6rpx 6rpx 6rpx;
  221. border: 1rpx solid #FDE935;
  222. color: #333333;
  223. font-size: 26rpx;
  224. }
  225. .suffixClass {
  226. margin-left: 10rpx;
  227. font-size: 30rpx;
  228. }
  229. ::v-deep {
  230. .u-form-item__body {
  231. padding: 34rpx 0;
  232. }
  233. }
  234. </style>