123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226 |
- <template>
- <view class="container">
- <view class="row b-b">
- <text class="tit">手机号</text>
- <input class="input" v-model="account" type="text" placeholder="请填写手机号" placeholder-class="placeholder" />
- </view>
- <view>
- <view class="row b-b">
- <text class="tit">验证码</text>
- <input class="input" v-model="captcha" type="text" placeholder="请填写验证码"
- placeholder-class="placeholder" />
- <view class="code" @click="verification">{{ countDown == 0 ? '验证码' : countDown }}</view>
- </view>
- <button class="add-btn" :class="{ 'bg-gray': loding }" @click="loding ? '' : confirm()">提交</button>
- </view>
- <codeImage @openCode='getCode' loginType="BDING_CODE" @close='showAlert=false' :phone="account" ref="alertImage" :show='showAlert'></codeImage>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- import {
- registerReset,
- binding
- } from '@/api/set.js';
- import {
- getUserInfo
- } from '@/api/user.js';
- import codeImage from '@/components/codeImage.vue';
- export default {
- data() {
- return {
- show: true,
- time: '', //保存倒计时对象
- countDown: 0, //倒计时
- account: '', //手机号
- captcha: '', //验证码
- password: '', //新密码
- loding: false ,//是否载入中
- showAlert:false,
- };
- },
- watch: {
- // 监听倒计时
- countDown(i) {
- if (i == 0) {
- clearInterval(this.time);
- }
- }
- },
- computed: {
- ...mapState('user', ['userInfo'])
- },
- components: {
- codeImage
- },
- onLoad() {
- console.log(this.userInfo, '123456');
- if (!this.userInfo.phone) {
- this.account = '';
- } else {
- this.account = this.userInfo.phone;
- this.show = false;
- }
- },
- methods: {
- close() {
- console.log('end')
- this.showAlert = false;
- },
- // 发送验证码
- getCode() {
- const obj = this;
- obj.countDown = 60;
- obj.time = setInterval(() => {
- obj.countDown--;
- }, 1000);
- //调用验证码接口
- },
- //发送验证码
- verification() {
- let obj = this;
- if (this.account == '') {
- this.$api.msg('请输入电话号码');
- return;
- }
- if (!/(^1[2|3|4|5|6|7|8|9][0-9]{9}$)/.test(this.account)) {
- this.$api.msg('请输入正确的手机号');
- return;
- }
- // 判断是否在倒计时
- if (obj.countDown > 0) {
- return false;
- } else {
- obj.showAlert = true;
- obj.$refs.alertImage.getImage()
- }
- },
- confirm(e) {
- let obj = this;
- obj.loding = true;
- binding({
- phone: obj.account,
- captcha: obj.captcha,
- step: 1
- })
- .then(({
- data
- }) => {
- // obj.$api.msg('绑定成功!');
- uni.showToast({
- title:data.msg
- })
- setTimeout(function() {
- obj.loding = false;
- uni.switchTab({
- url: '/pages/user/user'
- });
- }, 1000);
- })
- .catch(res => {
- let that = this;
- if (res.data !== undefined && res.data.is_bind) {
- uni.showModal({
- title: '是否绑定账号',
- content: res.msg,
- confirmText: '绑定',
- success(res) {
- if (res.confirm) {
- binding({
- phone: that.account,
- captcha: that.captcha,
- step: 1
- }).then(res => {
- setTimeout(function() {
- that.loding = false;
- uni.switchTab({
- url: '/pages/user/user'
- });
- }, 1000);
- that.$api.msg('绑定成功!');
- }).catch(err => {
- that.loding = false;
- })
- } else if (res.cancel) {
- that.loding = false;
- that.$api.msg('您已取消绑定!');
- }
- }
- });
- } else {
- that.loding = false;
- // that.$api.msg('绑定成功!');
- uni.showModal({
- title: '错误',
- content: res,
- showCancel: false,
- });
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- page {
- background: $page-color-base;
- }
- .row {
- display: flex;
- align-items: center;
- position: relative;
- padding: 0 30rpx;
- height: 110rpx;
- background: #fff;
- .tit {
- flex-shrink: 0;
- width: 120rpx;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .input {
- flex: 1;
- font-size: 30rpx;
- color: $font-color-dark;
- }
- .iconlocation {
- font-size: 36rpx;
- color: $font-color-light;
- }
- }
- .add-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 690rpx;
- height: 80rpx;
- margin: 60rpx auto;
- font-size: $font-lg;
- color: #fff;
- background-color: $base-color;
- border-radius: 10rpx;
- // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
- }
- .bg-gray {
- background-color: $color-gray;
- }
- .code {
- color: #dc262b;
- font-size: 23rpx;
- border-left: 1px solid #eeeeee;
- width: 150rpx;
- flex-shrink: 0;
- text-align: center;
- }
- </style>
|