password.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="container">
  3. <!-- <view class="row b-b">
  4. <text class="tit">手机号</text>
  5. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  6. </view>
  7. <view class="row b-b">
  8. <text class="tit">验证码</text>
  9. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  10. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  11. </view>
  12. <view class="row b-b">
  13. <text class="tit">新密码</text>
  14. <input class="input" v-model="password" type="password" placeholder="请填写新密码" placeholder-class="placeholder" />
  15. </view>
  16. <button class="add-btn" :class="{'bg-gray':loding}" @click="loding?'':confirm()">提交</button> -->
  17. <view class="container_text" ></view>
  18. <view class="top_bar" @click="fallback()">
  19. <view class="top_img">
  20. <image src="../../static/img/img03.png" ></image>
  21. </view>
  22. <view class="top_tit">修改密码</view>
  23. </view>
  24. <view class="login_text">
  25. <view class="login_input flex-upDown-center">
  26. <view class="login_img one"></view>
  27. <input class="input" v-model="account" type="number" maxlength="11" placeholder="请填写手机号" placeholder-class="placeholder" />
  28. </view>
  29. <view class="login_input flex-upDown-center">
  30. <view class="login_img two"></view>
  31. <input class="input" v-model="password" type="password" placeholder="请填写新密码" placeholder-class="placeholder" />
  32. </view>
  33. <view class="login_input flex-upDown-center">
  34. <view class="login_img two"></view>
  35. <input class="input" v-model="passwords" type="password" placeholder="请重复输入新密码" placeholder-class="placeholder" />
  36. </view>
  37. <view class="login_input flex-upDown-center ">
  38. <view class="flex-upDown-center">
  39. <view class="login_img three"></view>
  40. <input class="input" v-model="captcha" type="text" placeholder="请输入验证码" placeholder-class="placeholder" />
  41. </view>
  42. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  43. </view>
  44. <view><button class="uni-button" :class="{'bg-gray':loding}" @click="loding?'':confirm()">修改密码</button></view>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import { verify } from '@/api/login.js';
  50. import { registerReset } from '@/api/set.js';
  51. export default {
  52. data() {
  53. return {
  54. time: '', //保存倒计时对象
  55. countDown: 0, //倒计时
  56. account: '', //手机号
  57. captcha: '', //验证码
  58. password: '' ,//新密码
  59. passwords:'',
  60. loding:false,//是否载入中
  61. };
  62. },
  63. watch: {
  64. // 监听倒计时
  65. countDown(i) {
  66. if (i == 0) {
  67. clearInterval(this.time);
  68. }
  69. }
  70. },
  71. methods: {
  72. fallback() {
  73. console.log(1);
  74. uni.navigateTo({
  75. url:'/pages/set/set'
  76. });
  77. },
  78. //发送验证码
  79. verification() {
  80. let obj = this;
  81. if (this.account == '') {
  82. console.log(this.account);
  83. this.$api.msg('请输入电话号码');
  84. return;
  85. }
  86. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  87. this.$api.msg('请输入正确的手机号');
  88. return;
  89. }
  90. if(this.password == ''){
  91. this.$api.msg('请输入新密码');
  92. return;
  93. }
  94. if(this.password != this.passwords){
  95. this.$api.msg('两次密码输入不同');
  96. return;
  97. }
  98. // 判断是否在倒计时
  99. if (obj.countDown > 0) {
  100. return false;
  101. } else {
  102. obj.countDown = 60;
  103. obj.time = setInterval(() => {
  104. obj.countDown--;
  105. }, 1000);
  106. //调用验证码接口
  107. verify({
  108. phone: obj.account,
  109. type: 'reset'
  110. })
  111. .then(({ data }) => {})
  112. .catch(err => {
  113. console.log(err);
  114. });
  115. }
  116. },
  117. confirm(e) {
  118. this.loding = true;
  119. registerReset({
  120. account: this.account,
  121. captcha: this.captcha,
  122. password: this.password,
  123. })
  124. .then(({ data }) => {
  125. this.loding = false;
  126. this.$api.msg('修改成功');
  127. setTimeout(() => {
  128. uni.switchTab({
  129. url: '/pages/user/user'
  130. });
  131. }, 1000);
  132. })
  133. .catch(err => {
  134. this.loding = true;
  135. console.log(err);
  136. });
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="scss">
  142. page {
  143. background: $page-color-base;
  144. }
  145. .row {
  146. display: flex;
  147. align-items: center;
  148. position: relative;
  149. background: #fff;
  150. .tit {
  151. flex-shrink: 0;
  152. width: 120rpx;
  153. font-size: 30rpx;
  154. color: $font-color-dark;
  155. }
  156. .input {
  157. flex: 1;
  158. font-size: 30rpx;
  159. color: $font-color-dark;
  160. }
  161. .iconlocation {
  162. font-size: 36rpx;
  163. color: $font-color-light;
  164. }
  165. }
  166. .add-btn {
  167. display: flex;
  168. align-items: center;
  169. justify-content: center;
  170. width: 690rpx;
  171. height: 80rpx;
  172. margin: 60rpx auto;
  173. font-size: $font-lg;
  174. color: #fff;
  175. background-color: $base-color;
  176. border-radius: 10rpx;
  177. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  178. }
  179. .bg-gray{
  180. background-color: $color-gray;
  181. }
  182. .login_text {
  183. position: absolute;
  184. top: -150rpx;
  185. margin:0 25rpx;
  186. background-color: #ffffff;
  187. border-radius: 20rpx;
  188. padding: 0rpx 60rpx 215rpx 90rpx;
  189. position:relative;
  190. z-index: 10;
  191. .login_input {
  192. padding-top: 65rpx;
  193. border-bottom: 1px solid #F0F0F0;
  194. padding-bottom: 10rpx;
  195. color: #999999;
  196. &:nth-child(4){
  197. justify-content: space-between;
  198. }
  199. .login_img{
  200. width:30rpx;
  201. height: 35rpx;
  202. margin-right: 20rpx;
  203. }
  204. .one{
  205. background: url(../../static/password/img01.png) no-repeat center;
  206. background-size: 30rpx 35rpx;
  207. }
  208. .two{
  209. background: url(../../static/password/img02.png) no-repeat center;
  210. background-size: 30rpx 35rpx;
  211. }
  212. .three{
  213. background: url(../../static/password/img03.png) no-repeat center;
  214. background-size: 30rpx 35rpx;
  215. }
  216. .input {
  217. width: 400rpx;
  218. font-size: 28rpx;
  219. letter-spacing: 3rpx;
  220. color: #999999;
  221. display: block;
  222. }
  223. .code {
  224. color: #FA2740;
  225. font-size: 23rpx;
  226. }
  227. }
  228. .uni-button {
  229. height: 80rpx;
  230. line-height: 80rpx;
  231. font-size:30rpx;
  232. color: #ffffff;
  233. background:linear-gradient(#FE5544, #FA2740);
  234. margin-top: 40rpx;
  235. border-radius:40rpx;
  236. }
  237. }
  238. .container_text {
  239. width: 100%;
  240. height: 500rpx;
  241. background:linear-gradient(#FE5544, #FA2740);
  242. }
  243. .top_bar{
  244. width: 750rpx;
  245. padding: 30rpx 30rpx;
  246. position: absolute;
  247. top: 0;
  248. .top_img{
  249. float: left;
  250. width: 5%;
  251. image{
  252. width: 21rpx;
  253. height: 36rpx
  254. }
  255. }
  256. .top_tit{
  257. float: left;
  258. font-size:36rpx;
  259. color:#ffffff;
  260. width:95%;
  261. text-align: center;
  262. }
  263. }
  264. </style>