moneyPwd.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="container">
  3. <view class="row b-b" v-if="type == 2">
  4. <text class="tit">手机号</text>
  5. <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
  6. </view>
  7. <view class="row b-b" v-if="type == 2">
  8. <text class="tit">验证码</text>
  9. <input class="input" v-model="captcha" type="text" placeholder="请填写验证码" placeholder-class="placeholder" />
  10. <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
  11. </view>
  12. <view class="row b-b">
  13. <text class="tit">新密码</text>
  14. <input class="input" v-model="password" type="password" placeholder="请填写6位新密码"
  15. placeholder-class="placeholder" />
  16. </view>
  17. <view class="row b-b">
  18. <text class="tit">再次输入</text>
  19. <input class="input" v-model="yzpassword" type="password" placeholder="请重新填写6位新密码"
  20. placeholder-class="placeholder" />
  21. </view>
  22. <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</button>
  23. <codeImage @openCode='getCode' loginType="" @close='showAlert=false' :phone="account" ref="alertImage" :show='showAlert'></codeImage>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState
  29. } from 'vuex';
  30. import {
  31. is_pas,
  32. transaction
  33. } from '@/api/set.js';
  34. import codeImage from '@/components/codeImage.vue';
  35. export default {
  36. data() {
  37. return {
  38. type: 1,
  39. time: '', //保存倒计时对象
  40. countDown: 0, //倒计时
  41. account: '', //手机号
  42. captcha: '', //验证码
  43. password: '', //新密码
  44. yzpassword: '', //重复输入
  45. loding: false, //是否载入中
  46. showAlert: false,
  47. };
  48. },
  49. components: {
  50. codeImage
  51. },
  52. computed: {
  53. ...mapState('user', ['userInfo'])
  54. },
  55. onLoad() {
  56. is_pas().then(({
  57. data
  58. }) => {
  59. console.log();
  60. if (data.status != 0) {
  61. this.type = 2;
  62. }
  63. });
  64. },
  65. watch: {
  66. // 监听倒计时
  67. countDown(i) {
  68. if (i == 0) {
  69. clearInterval(this.time);
  70. }
  71. }
  72. },
  73. methods: {
  74. close() {
  75. console.log('end')
  76. this.showAlert = false;
  77. },
  78. // 发送验证码
  79. getCode() {
  80. const obj = this;
  81. obj.countDown = 60;
  82. obj.time = setInterval(() => {
  83. obj.countDown--;
  84. }, 1000);
  85. //调用验证码接口
  86. },
  87. verification() {
  88. let obj = this;
  89. if (this.account == '') {
  90. this.$api.msg('请输入电话号码');
  91. return;
  92. }
  93. if (!/(^1[2|3|4|5|7|8|9][0-9]{9}$)/.test(this.account)) {
  94. this.$api.msg('请输入正确的手机号');
  95. return;
  96. }
  97. // 判断是否在倒计时
  98. if (obj.countDown > 0) {
  99. return false;
  100. } else {
  101. obj.showAlert = true;
  102. obj.$refs.alertImage.getImage()
  103. }
  104. },
  105. confirm(e) {
  106. const reg = /^[0-9]{6}$/;
  107. console.log(this.yzpassword);
  108. if (!reg.test(this.yzpassword)) {
  109. uni.showModal({
  110. title: '错误',
  111. content: '请输入6位数字支付密码',
  112. showCancel: false
  113. });
  114. return false;
  115. }
  116. if (this.yzpassword != this.password) {
  117. uni.showModal({
  118. title: '错误',
  119. content: '密码不一致请重新输入',
  120. showCancel: false
  121. });
  122. return false;
  123. }
  124. this.loding = true;
  125. transaction({
  126. type: this.type,
  127. payment: this.password,
  128. account: this.account,
  129. captcha: this.captcha
  130. })
  131. .then(({
  132. data
  133. }) => {
  134. this.loding = false;
  135. uni.showModal({
  136. title: '提示',
  137. content: '修改成功',
  138. showCancel: false,
  139. confirmText: '返回个人中心',
  140. success: res => {
  141. uni.switchTab({
  142. url: '/pages/user/user'
  143. });
  144. }
  145. });
  146. })
  147. .catch(err => {
  148. this.loding = false;
  149. console.log(err);
  150. });
  151. }
  152. }
  153. };
  154. </script>
  155. <style lang="scss">
  156. page {
  157. background: $page-color-base;
  158. }
  159. .container {
  160. padding-top: 30rpx;
  161. }
  162. .row {
  163. display: flex;
  164. align-items: center;
  165. position: relative;
  166. padding: 0 30rpx;
  167. height: 110rpx;
  168. background: #fff;
  169. .tit {
  170. flex-shrink: 0;
  171. width: 120rpx;
  172. font-size: 30rpx;
  173. color: $font-color-dark;
  174. }
  175. .input {
  176. flex: 1;
  177. font-size: 30rpx;
  178. color: $font-color-dark;
  179. }
  180. .iconlocation {
  181. font-size: 36rpx;
  182. color: $font-color-light;
  183. }
  184. }
  185. .add-btn {
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. width: 690rpx;
  190. height: 80rpx;
  191. margin: 60rpx auto;
  192. font-size: $font-lg;
  193. color: #fff;
  194. background: #dc262b;
  195. border-radius: 10rpx;
  196. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  197. }
  198. .bg-gray {
  199. background-color: $color-gray;
  200. }
  201. .code {
  202. color: #dc262b;
  203. font-size: 23rpx;
  204. border-left: 1px solid #eeeeee;
  205. width: 150rpx;
  206. flex-shrink: 0;
  207. text-align: center;
  208. }
  209. </style>