123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290 |
- <template>
- <view class="container">
- <uni-nav-bar id="nav-bar" status-bar="true" @clickLeft="onBack" :title="pageTitle" color="#000000" fixed="true"
- :border="false">
- <view slot="left">
- <view class=" flex align-center margin-left">
- <image class="p-left-arrow" src="../../../static/p-left-arrow.png"></image>
- </view>
- </view>
- </uni-nav-bar>
- <view style="height:6px ;width: 100%; background-color: #f2eff2;"></view>
- <!-- 手机端登录,获取验证码 -->
- <view class="input-container" style="margin: 32px 102rpx 0 68rpx;">
- <view class="make-text-bPurple text-bold margin-bottom" style="font-size: 20px;">绑定手机</view>
- <view class="input-row padding" style="width: 318px;">
- <m-input type="number" maxlength="11" clearable v-model="account" placeholder="请填写11位手机号码"></m-input>
- </view>
- </view>
- <view class="flex justify-between" style="margin: 32px 96rpx 0 68rpx; ">
- <view class="text-22px make-text-bPurple">输入验证码</view>
- <view v-if="bCodeDisabled" class="btn-code" style="background-color: rgb(0,0,0);opacity: 0.5;">重新获取({{count}})</view>
- <view v-else class="btn-code" @tap="onGetCode">获取验证码</view>
- </view>
- <!-- 手机端登录 -->
- <view class="text-16px text-gray" style="margin: 20px 0 0 96rpx;">已发送4位验证码...</view>
- <view class="code-input-main">
- <view class="inputLine">
- <view class="input-item">{{inputCode[0]}}</view>
- <view class="input-item">{{inputCode[1]}}</view>
- <view class="input-item">{{inputCode[2]}}</view>
- <view class="input-item">{{inputCode[3]}}</view>
- </view>
- <input class="code-input-input" v-model="inputCode" maxlength="4" type="number" />
- </view>
- <view class="btn-row">
- <view class="btn-confirm" :disabled="inputCode.length<4" @tap="onConfirm">确认绑定</view>
- </view>
- <input class='ipt' type="number" :maxlength="Length" :focus="bFocus"></input>
- </view>
- </template>
- <script>
- import mInput from '@/components/m-input.vue'
- import config from '@/common/config.js';
- import reqUtil from "@/util/util-js/requstUtil.js";
- import verify from '@/util/util-js/verify.js'
- import {
- mapState,
- mapMutations
- } from 'vuex'
- export default {
- components: {
- mInput
- },
- data() {
- return {
- //获取验证码页面
- bGetCode: true,
- bMobileLogin: true,
- providerList: [],
- hasProvider: true,
- account: '',
- password: '',
- positionTop: 0,
- //输入框参数
- Length: 4, //输入框个数
- bFocus: false, //聚焦
- Value: "", //输入的内容
- inputCode: '',
- pageTitle: "绑定手机",
- bConfirm: false,
- }
- },
- computed: mapState(['bNewUser', 'forcedLogin', 'phoneNumber', 'bCodeDisabled', 'count']),
- methods: {
- ...mapMutations(['countDown','resetCountDown']),
- onBack() {
- uni.navigateBack({
- delta: 1
- })
- },
- onGetCode() {
- if (!verify.checkPhone(this.account)) {
- uni.showToast({
- icon: 'none',
- title: '输入手机号错误'
- });
- return;
- }
- // this.$store.state.phoneNumber = this.account;
- //置灰状态
- if (this.bCodeDisabled) return;
- //调用store 倒计时
- this.countDown(this.account);
- },
- inputEvent(res) {
- console.log("input 1 input inputCode components : ", res.detail.value);
- },
- //验证码操作
- //注册
- onConfirm() {
- var _self = this;
- if (!verify.checkPhone(_self.account)) {
- uni.showToast({
- icon: 'none',
- title: '输入手机号错误'
- });
- return;
- }
- if (_self.bConfirm) return;
-
- uni.showToast({
- title:"",
- icon:"loading",
- mask:true,
- duration:10000
- })
- _self.bConfirm = true;
-
- reqUtil.requestData(config.URL.BINDPHONE, {
- "phoneNumber": _self.account,
- "code": _self.inputCode
- }).then(res => {
- console.log('requestData BINDPHONE =====', res);
- uni.hideToast();
- _self.bConfirm = false;
- if (res.code == 0) {
- uni.showToast({
- title: "绑定手机号成功",
- mask: true,
- duration: 1000
- })
- _self.$store.state.phoneNumber = _self.account;
-
- _self.resetCountDown();
- // 绑定电话成功后,回退页面
- uni.navigateBack({
- delta: 1
- })
- } else if (res.code == 213) {
- uni.showToast({
- title: "手机号已使用过,请换个号码",
- mask: true,
- icon: 'none',
- duration: 3000
- })
- } else {
- uni.showToast({
- title: "绑定失败",
- mask: true,
- icon: 'none',
- duration: 1000
- })
- }
-
-
- },
- e => {
- console.log(e);
- uni.hideToast();
- _self.bConfirm = false;
- });
- }
- }
- }
- </script>
- <style>
- .input-row {
- display: flex;
- flex-direction: row;
- position: relative;
- }
- .btn-row {
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .container {
- position: absolute;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: #FFFFFF;
- }
- .input-container {
- border-bottom: 1rpx solid #e7e9eb;
- }
- .btn-code {
- width: 235rpx;
- height: 63rpx;
- background-color: rgba(151, 151, 255, 1);
- border-radius: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 15px;
- color: #FFFFFF;
- }
- .btn-confirm {
- width: 636rpx;
- height: 102rpx;
- background-color: rgba(151, 151, 255, 1);
- border-radius: 10px;
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 17px;
- color: #FFFFFF;
- }
- .code-input-main {
- display: flex;
- flex-direction: column;
- width: 100%;
- /* border: 1rpx solid #000000; */
- height: 150px;
- position: relative;
- }
- .input-item {
- width: 106rpx;
- height: 118rpx;
- font-size: 20px;
- line-height: 118rpx;
- background-color: rgba(244, 241, 244, 255);
- /* border: 1rpx solid #ddd; */
- text-align: center;
- border-radius: 8px;
- margin-left: 44rpx;
- /* margin-right: 40upx; */
- color: rgba(86, 86, 86, 1);
- font-weight: bold;
- }
- .inputLine {
- display: flex;
- justify-content: flex-start;
- width: 100%;
- top: 80rpx;
- left: 52rpx;
- position: absolute;
- z-index: 1;
- }
- .code-input-input {
- height: 150px;
- position: absolute;
- width: 100%;
- outline: none;
- color: transparent;
- text-shadow: 0 0 0 transparent;
- width: 300%;
- left: -100%;
- top: 0;
- /* background: #000000; */
- /* border: 1rpx solid #007AFF; */
- z-index: 10;
- }
- .ipt {
- width: 0;
- height: 0;
- }
- </style>
|