payment.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. },
  47. watch: {
  48. // 监听倒计时
  49. countDown(i) {
  50. if (i == 0) {
  51. clearInterval(this.time);
  52. }
  53. }
  54. },
  55. //下拉刷新
  56. onPullDownRefresh() {
  57. this.loadData();
  58. },
  59. methods: {
  60. updatalogin() {
  61. let obj = this;
  62. if (obj.password == '') {
  63. obj.$api.msg('请输入新密码');
  64. return;
  65. }
  66. if (obj.password2 == '') {
  67. obj.$api.msg('请再次输入密码');
  68. return;
  69. }
  70. if (obj.password2 != obj.password) {
  71. obj.$api.msg('两次密码不正确');
  72. return;
  73. }
  74. if (obj.code == '') {
  75. obj.$api.msg('请输入验证码');
  76. return;
  77. }
  78. registerReset({
  79. account: obj.phone, //账号
  80. password:obj.password,
  81. password2:obj.password2,
  82. type:2,
  83. captcha: obj.code
  84. }).then(function(e) {
  85. obj.$api.msg(e.msg);
  86. uni.switchTab({
  87. url: '/pages/user/user'
  88. })
  89. }).catch((e) => {
  90. console.log(e);
  91. });
  92. },
  93. //发送验证码
  94. verification() {
  95. let obj = this;
  96. // 判断是否在倒计时
  97. if (obj.countDown > 0) {
  98. return false;
  99. } else {
  100. obj.countDown = 60;
  101. obj.time = setInterval(() => {
  102. obj.countDown--;
  103. }, 1000);
  104. //调用验证码接口
  105. verify({
  106. phone: obj.phone,
  107. type: 'login'
  108. })
  109. .then(({ data }) => {})
  110. .catch(err => {
  111. console.log(err);
  112. });
  113. }
  114. },
  115. }
  116. };
  117. </script>
  118. <style lang="scss">
  119. page {
  120. min-height: 100%;
  121. background-color: #ffffff;
  122. .container {
  123. width: 100%;
  124. padding: 27rpx 31rpx;
  125. }
  126. }
  127. .list-box{
  128. .list-title{
  129. font-size: 30rpx;
  130. font-weight: 500;
  131. color: #333333;
  132. margin-bottom: 61rpx;
  133. .tip{
  134. width: 2rpx;
  135. height: 30rpx;
  136. background: #4C5D97;
  137. margin-right:17rpx ;
  138. }
  139. }
  140. .list-cell{
  141. margin-bottom: 70rpx;
  142. .cell-name{
  143. width: 30%;
  144. font-size: 26rpx;
  145. font-weight: 500;
  146. color: #333333;
  147. }
  148. .nameCode{
  149. width: 42% !important;
  150. }
  151. .code-box{
  152. width: 100% !important;
  153. input{
  154. width: 50%;
  155. }
  156. .code{
  157. font-size: 26rpx;
  158. font-weight: 500;
  159. color: #44969D;;
  160. }
  161. }
  162. input{
  163. width: 60%;
  164. text-align: left;
  165. font-size: 26rpx;
  166. font-weight: 500;
  167. }
  168. }
  169. }
  170. .submit {
  171. background: linear-gradient(90deg, #60BAB0, #60BAB0, #45969B);
  172. margin-top: 20rpx;
  173. color: #FFFFFF;
  174. text-align: center;
  175. padding: 20rpx 0rpx;
  176. border-radius: 50rpx;
  177. margin-top: 60rpx;
  178. }
  179. </style>