payment.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 { updatalogin } 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(option){
  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. updatalogin({
  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. if (this.phone == '') {
  97. this.$api.msg('请输入电话号码');
  98. return;
  99. }
  100. if (this.phone.length < 11) {
  101. this.$api.msg('请输入正确的手机号');
  102. return;
  103. }
  104. // 判断是否在倒计时
  105. if (obj.countDown > 0) {
  106. return false;
  107. } else {
  108. obj.countDown = 60;
  109. obj.time = setInterval(() => {
  110. obj.countDown--;
  111. }, 1000);
  112. //调用验证码接口
  113. verify({
  114. phone: obj.phone,
  115. type: 'login'
  116. })
  117. .then(({ data }) => {})
  118. .catch(err => {
  119. console.log(err);
  120. });
  121. }
  122. },
  123. }
  124. };
  125. </script>
  126. <style lang="scss">
  127. page {
  128. min-height: 100%;
  129. background-color: #ffffff;
  130. .container {
  131. width: 100%;
  132. padding: 27rpx 31rpx;
  133. }
  134. }
  135. .list-box{
  136. .list-title{
  137. font-size: 30rpx;
  138. font-weight: 500;
  139. color: #333333;
  140. margin-bottom: 61rpx;
  141. .tip{
  142. width: 2rpx;
  143. height: 30rpx;
  144. background: #4C5D97;
  145. margin-right:17rpx ;
  146. }
  147. }
  148. .list-cell{
  149. margin-bottom: 70rpx;
  150. .cell-name{
  151. width: 30%;
  152. font-size: 26rpx;
  153. font-weight: 500;
  154. color: #333333;
  155. }
  156. .nameCode{
  157. width: 42% !important;
  158. }
  159. .code-box{
  160. width: 100% !important;
  161. input{
  162. width: 50%;
  163. }
  164. .code{
  165. font-size: 26rpx;
  166. font-weight: 500;
  167. color: #FF6600;
  168. }
  169. }
  170. input{
  171. width: 60%;
  172. text-align: left;
  173. font-size: 26rpx;
  174. font-weight: 500;
  175. }
  176. }
  177. }
  178. .submit {
  179. background-color: #141E47;
  180. margin-top: 20rpx;
  181. color: #FFFFFF;
  182. text-align: center;
  183. padding: 20rpx 0rpx;
  184. border-radius: 50rpx;
  185. margin-top: 60rpx;
  186. }
  187. </style>