payment.vue 3.8 KB

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