payment.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <template>
  2. <view class="container">
  3. <view class="list-box">
  4. <view class="flex_item list-title">
  5. <view class="tip"></view>
  6. <view class="title">支付密码</view>
  7. </view>
  8. <view class="list-cell flex_item">
  9. <view class="cell-name">新密码</view>
  10. <input type="password" v-model="password" placeholder="请输入6位数的密码" />
  11. </view>
  12. <view class="list-cell flex_item">
  13. <view class="cell-name">重复密码</view>
  14. <input type="password" v-model="password2" placeholder="请重复输入密码" />
  15. </view>
  16. <view class="list-cell flex_item">
  17. <view class="cell-name nameCode">验证码</view>
  18. <view class="code-box flex">
  19. <input type="number" v-model="code" placeholder="请输入验证码" />
  20. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="submit" @click="updatalogin">确认</view>
  25. </view>
  26. </template>
  27. <script>
  28. import { registerReset } from '@/api/set.js';
  29. import { verify } from '@/api/login.js';
  30. export default {
  31. data() {
  32. return {
  33. phone: '', //用户
  34. code: '', //验证码
  35. password2: '',
  36. password: '',
  37. time: '', //保存倒计时对象
  38. countDown: 0 //倒计时
  39. };
  40. },
  41. onLoad() {
  42. let userInfo = uni.getStorageSync('userInfo') || '';
  43. this.phone = userInfo.account;
  44. },
  45. onShow() {},
  46. watch: {
  47. // 监听倒计时
  48. countDown(i) {
  49. if (i == 0) {
  50. clearInterval(this.time);
  51. }
  52. }
  53. },
  54. //下拉刷新
  55. onPullDownRefresh() {
  56. this.loadData();
  57. },
  58. methods: {
  59. updatalogin() {
  60. let obj = this;
  61. if (obj.password == '') {
  62. obj.$api.msg('请输入新密码');
  63. return;
  64. }
  65. if (obj.password2 == '') {
  66. obj.$api.msg('请再次输入密码');
  67. return;
  68. }
  69. if (obj.password2 != obj.password) {
  70. obj.$api.msg('两次密码不正确');
  71. return;
  72. }
  73. if (obj.code == '') {
  74. obj.$api.msg('请输入验证码');
  75. return;
  76. }
  77. registerReset({
  78. account: obj.phone, //账号
  79. password: obj.password,
  80. password2: obj.password2,
  81. type: 2,
  82. captcha: obj.code
  83. })
  84. .then(function(e) {
  85. obj.$api.msg(e.msg);
  86. uni.switchTab({
  87. url: '/pages/user/user'
  88. });
  89. })
  90. .catch(e => {
  91. console.log(e);
  92. });
  93. },
  94. //发送验证码
  95. verification() {
  96. let obj = this;
  97. // 判断是否在倒计时
  98. if (obj.countDown > 0) {
  99. return false;
  100. } else {
  101. obj.countDown = 60;
  102. obj.time = setInterval(() => {
  103. obj.countDown--;
  104. }, 1000);
  105. //调用验证码接口
  106. verify({
  107. phone: obj.phone,
  108. type: 'login'
  109. })
  110. .then(({ data }) => {})
  111. .catch(err => {
  112. console.log(err);
  113. });
  114. }
  115. }
  116. }
  117. };
  118. </script>
  119. <style lang="scss">
  120. page {
  121. min-height: 100%;
  122. .container {
  123. width: 100%;
  124. }
  125. }
  126. .list-box {
  127. margin-top: 20rpx;
  128. padding: 27rpx 30rpx 10rpx;
  129. background-color: #FFFFFF;
  130. .list-title {
  131. font-size: 30rpx;
  132. font-weight: 500;
  133. color: #333333;
  134. margin-bottom: 61rpx;
  135. .tip {
  136. width: 2px;
  137. height: 30rpx;
  138. background: #2E58FF;
  139. margin-right: 17rpx;
  140. }
  141. }
  142. .list-cell {
  143. margin-bottom: 70rpx;
  144. .cell-name {
  145. width: 30%;
  146. font-size: 26rpx;
  147. font-weight: 500;
  148. color: #333333;
  149. }
  150. .nameCode {
  151. width: 42% !important;
  152. }
  153. .code-box {
  154. width: 100% !important;
  155. input {
  156. width: 50%;
  157. }
  158. .code {
  159. font-size: 26rpx;
  160. font-weight: 500;
  161. color: #2e58ff;
  162. }
  163. }
  164. input {
  165. width: 60%;
  166. text-align: left;
  167. font-size: 26rpx;
  168. font-weight: 500;
  169. }
  170. }
  171. }
  172. .submit {
  173. width: 690rpx;
  174. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  175. color: #ffffff;
  176. text-align: center;
  177. padding: 20rpx 0rpx;
  178. border-radius: 50rpx;
  179. margin: 60rpx auto 0;
  180. }
  181. </style>