forgotPassword.vue 5.3 KB

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