changePass.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="content">
  3. <view class="box">
  4. <!-- <view class="box-top">
  5. <view class="shu" style="">
  6. </view>
  7. <view class="pass-title">
  8. 密码
  9. </view>
  10. </view> -->
  11. <view class="box-bottom">
  12. <view class="ipt">
  13. <view class="text">
  14. 手机号
  15. </view> <input type="phone" class="input" value="" placeholder="请输入手机号" />
  16. </view>
  17. <view class="ipt">
  18. <view class="text">
  19. 新密码
  20. </view> <input type="password" class="input" value="" placeholder="请输入新的密码" />
  21. </view>
  22. <view class="ipt">
  23. <view class="text">
  24. 重复密码
  25. </view><input type="password" class="input" value="" placeholder="请重复输入密码" />
  26. </view>
  27. <view class="ipt">
  28. <view class="text">
  29. 验证码
  30. </view> <input type="number" class="input" value="" placeholder="请输入验证码"/>
  31. <view class="yzm" @click="getDjs()" v-if="!isDjs">
  32. 验证码
  33. </view>
  34. <view class="yzm" v-else>
  35. {{countDown}}
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <button class="button">确认</button>
  41. <!-- <image style="z-index: 99;" src="../../static/game/game13.png" mode=""></image>
  42. <image style="z-index: 99;" src="../../static/game/reb01.png" mode=""></image> -->
  43. </view>
  44. </template>
  45. <script>
  46. import {
  47. verify
  48. } from '@/api/login.js';
  49. import {
  50. mapState
  51. } from 'vuex';
  52. import {
  53. registerReset
  54. } from '@/api/set.js';
  55. export default {
  56. data() {
  57. return {
  58. phone:'',//手机号
  59. time: '', //保存倒计时对象
  60. countDown: 0, //倒计时
  61. account: '', //手机号
  62. captcha: '', //验证码
  63. password: '', //新密码
  64. loding: false, //是否载入中
  65. isDjs:false,//是否在倒计时
  66. };
  67. },
  68. computed: {
  69. ...mapState(['userInfo'])
  70. },
  71. onLoad() {
  72. if (this.userInfo.phone == null) {
  73. this.account = '';
  74. } else {
  75. this.account = this.userInfo.phone;
  76. this.show = false;
  77. }
  78. },
  79. watch: {
  80. // 监听倒计时
  81. countDown(i) {
  82. if (i == 0) {
  83. clearInterval(this.time);
  84. }
  85. }
  86. },
  87. methods: {
  88. getDjs(){
  89. this.isDjs = true
  90. this.countDown= 10
  91. let time = setInterval(e=>{
  92. this.countDown--
  93. console.log(this.countDown);
  94. if(this.countDown==0){
  95. clearInterval(time)
  96. console.log('倒计时结束');
  97. console.log(this.countDown,'打印');
  98. }
  99. },1000)
  100. },
  101. //发送验证码
  102. verification() {
  103. let obj = this;
  104. if (this.account == '') {
  105. this.$api.msg('请输入电话号码');
  106. return;
  107. }
  108. if (!/(^1[3|4|5|7|8][0-9]{9}$)/.test(this.account)) {
  109. this.$api.msg('请输入正确的手机号');
  110. return;
  111. }
  112. // 判断是否在倒计时
  113. if (obj.countDown > 0) {
  114. return false;
  115. } else {
  116. obj.countDown = 60;
  117. obj.time = setInterval(() => {
  118. obj.countDown--;
  119. }, 1000);
  120. //调用验证码接口
  121. verify({
  122. phone: obj.account,
  123. type: ''
  124. })
  125. .then(({
  126. data
  127. }) => {})
  128. .catch(err => {
  129. console.log(err);
  130. });
  131. }
  132. },
  133. confirm(e) {
  134. this.loding = true;
  135. registerReset({
  136. account: this.account,
  137. captcha: this.captcha,
  138. password: this.password,
  139. })
  140. .then(({
  141. data
  142. }) => {
  143. this.loding = false;
  144. this.$api.msg('修改成功');
  145. })
  146. .catch(err => {
  147. this.loding = false;
  148. console.log(err);
  149. });
  150. }
  151. }
  152. };
  153. </script>
  154. <style lang="scss">
  155. page,
  156. .content {
  157. width: 750rpx;
  158. height: 100%;
  159. background: #111111;
  160. .box {
  161. background: #222222;
  162. .box-top {
  163. height: 100rpx;
  164. display: flex;
  165. align-items: center;
  166. .shu {
  167. width: 2rpx;
  168. height: 30rpx;
  169. background: #A581FF;
  170. display: inline-block;
  171. margin: 0 20rpx 0 30rpx;
  172. line-height: 100rpx;
  173. }
  174. .pass-title {
  175. line-height: 100rpx;
  176. display: inline-block;
  177. font-size: 30rpx;
  178. font-weight: 500;
  179. color: #FFFFFF;
  180. }
  181. }
  182. .box-bottom {
  183. margin-top: 50rpx;
  184. .ipt{
  185. border-top:2rpx solid #F3F3F3;
  186. padding: 0 30rpx;
  187. display: flex;
  188. align-items: center;
  189. // justify-content: space-between;
  190. .text{
  191. width: 150rpx;
  192. font-size: 26rpx;
  193. font-weight: 500;
  194. color: #FFFFFF;
  195. line-height: 80rpx;
  196. }
  197. .input{
  198. }
  199. .yzm{
  200. margin-left: 140rpx;
  201. font-size: 26rpx;
  202. font-weight: 500;
  203. color: #A581FF;
  204. line-height: 100rpx;
  205. }
  206. }
  207. }
  208. }
  209. .button {
  210. margin-top: 60rpx;
  211. width: 600rpx;
  212. height: 90rpx;
  213. background: linear-gradient(270deg, #6E8DF7, #9977F6);
  214. border-radius: 10px;
  215. font-size: 30rpx;
  216. font-weight: bold;
  217. color: #FFFFFF;
  218. line-height: 90rpx;
  219. }
  220. }
  221. </style>