123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <template>
- <view class="container register">
- <view class="register-main first clearfix">
- <view class="register-row clearfix">
- <view class="register-from">
- <input
- class="row-input"
- type="number"
- v-model="params.mobile"
- placeholder="请输入原手机号"
- @input="handleInput"
- placeholder-class="place-holder"
- maxlength="11"
- disabled="true"
- />
- </view>
- </view>
- <view class="register-row clearfix">
- <view class="register-from code">
- <input
- class="row-input"
- type="number"
- v-model="params.smsCode"
- placeholder="请输入原手机号验证码"
- placeholder-class="place-holder"
- maxlength="6"
- />
- </view>
- <view class="register-from btn" :class="{ disabled: disabled1, disabled: isMobileDisabled }">
- <button
- class="row-input"
- type="button"
- @click.stop="getNewMobileCodeFn(1)"
- :disabled="isMobileDisabled"
- >
- {{ mobileCodeText }}
- </button>
- </view>
- </view>
- <view class="register-row clearfix">
- <view class="register-from">
- <input
- class="row-input"
- type="number"
- v-model="params.newMobile"
- placeholder="请输入新手机号"
- @input="handleInput"
- placeholder-class="place-holder"
- maxlength="11"
- />
- </view>
- </view>
- <view class="register-row clearfix">
- <view class="register-from code">
- <input
- class="row-input"
- type="number"
- v-model="params.newSmsCode"
- placeholder="请输入验证码"
- placeholder-class="place-holder"
- maxlength="6"
- />
- </view>
- <view class="register-from btn" :class="{ disabled: disabled2, disabled: isNewMobileDisabled }">
- <button
- class="row-input"
- type="button"
- @click.stop="getNewMobileCodeFn(2)"
- :disabled="isNewMobileDisabled"
- >
- {{ newMobileCodeText }}
- </button>
- </view>
- </view>
- <view class="register-row clearfix" style="border: 0;">
- <button
- class="register-btn"
- :disabled="disabled"
- :class="disabled ? 'disabled' : ''"
- @click="btnConfirm"
- >
- 确定
- </button>
- <view class="register-btn-text"> 注意:本操作更换的是机构联系人的手机号,不是运营人员的手机号。 </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import { mapMutations } from 'vuex'
- var self
- export default {
- data() {
- return {
- newCount: '', //倒计时
- codeTimeNew: null,
- newMobileCodeText: '获取验证码',
- isNewMobileDisabled: true, //手机验证码按钮控制
- count: '', //倒计时
- codeTime: null,
- mobileCodeText: '获取验证码',
- isMobileDisabled: false, //手机验证码按钮控制
- params: {
- mobile: '', //旧手机号
- newMobile: '', //新联系人手机号
- smsCode: '', //原手机号验证码
- newSmsCode: '', //新手机号手机验证码
- userId: 0
- },
- codeParams:{
- mobile: '',
- isCheckCaptcha: 1,
- activateCodeType: 11,
- platformType: 0
- }
- }
- },
- computed: {
- disabled1() {
- return !this.params.mobile.length === 11
- },
- disabled2() {
- return !this.params.newMobile.length === 11
- },
- disabled() {
- return !(this.params.mobile && this.params.smsCode && this.params.newMobile && this.params.newSmsCode)
- }
- },
- onLoad(option) {
- this.params.mobile = option.phone
-
- },
- methods: {
- // 监听输入手机号
- handleInput(e) {
- this.params.newMobile = e.detail.value
- if (this.params.newMobile.length === 11) {
- this.isNewMobileDisabled = false
- }
- },
- // 确认更换
- async btnConfirm() {
- const use = await this.$api.getStorage()
- this.params.userId = use.userId
- if (!this.$reg.isMobile(this.params.newMobile)) {
- this.$util.msg('新手机号格式不正确', 2000)
- return
- }
- try {
- const res = await this.UserService.UserUpdateMobile(this.params)
- this.$util.msg(res.msg, 1500, true, 'success')
- setTimeout(() => {
- uni.navigateBack({ delta: 2 })
- }, 2000)
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- }
- },
- getNewMobileCodeFn(type) {
- if (type === 1) {
- //旧手机号验证码
- this.codeParams.mobile =this.params.mobile
- this.codeParams.activateCodeType =11
- this.getMobileCode(this.codeParams)
- } else {
- if (!this.$reg.isMobile(this.params.newMobile)) {
- this.$util.msg('请输入正确的新手机号', 2000)
- return
- }
- this.codeParams.mobile =this.params.newMobile
- this.codeParams.activateCodeType =12
- this.getNewMobileCode(this.codeParams)
- }
- },
- //获取就手机号验证码
- async getMobileCode(params) {
- try {
- const TIME_COUNT = 60
- this.isMobileDisabled = true
- const res = await this.PublicService.GetRegisterMobileCode(params)
- this.$util.msg(res.data, 2000)
- if (!this.codeTime) {
- this.count = TIME_COUNT
- this.isMobileDisabled = true
- this.codeTime = setInterval(() => {
- if (this.count > 1 && this.count <= TIME_COUNT) {
- this.count--
- this.mobileCodeText = this.count + 's重新发送'
- } else {
- this.isMobileDisabled = false
- clearInterval(this.codeTime)
- this.codeTime = null
- this.mobileCodeText = '获取验证码'
- }
- }, 1000)
- }
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- this.isMobileDisabled = false
- }
- },
- //获取新手机号短信
- async getNewMobileCode(params) {
- try {
- const TIME_COUNT = 60
- this.isNewMobileDisabled = true
- const res = await this.PublicService.GetRegisterMobileCode(params)
- this.$util.msg(res.data, 2000)
- if (!this.codeTimeNew) {
- this.newCount = TIME_COUNT
- this.isNewMobileDisabled = true
- this.codeTimeNew = setInterval(() => {
- if (this.newCount > 1 && this.newCount <= TIME_COUNT) {
- this.newCount--
- this.newMobileCodeText = this.newCount + 's重新发送'
- } else {
- this.isNewMobileDisabled = false
- clearInterval(this.codeTimeNew)
- this.codeTimeNew = null
- this.newMobileCodeText = '获取验证码'
- }
- }, 1000)
- }
- } catch (error) {
- this.$util.msg(error.msg, 2000)
- this.isNewMobileDisabled = false
- }
- }
- },
- onShow() {
-
- }
- }
- </script>
- <style lang="scss">
- .register {
- width: 100%;
- height: auto;
- border-top: 1px solid #f7f7f7;
- .model-warp.none {
- display: none;
- }
- .model-warp.show {
- display: block;
- }
- .register-main {
- width: 100%;
- height: auto;
- &.detailed {
- padding-bottom: 300rpx;
- }
- &.first {
- padding-top: 40rpx;
- }
- .register-tips {
- display: flex;
- flex-direction: column;
- align-items: center;
- line-height: 44rpx;
- font-size: $font-size-24;
- color: #ff0000;
- margin-bottom: 40rpx;
- .iconfont {
- font-size: $font-size-24;
- }
- }
- .register-row {
- width: 702rpx;
- height: auto;
- margin: auto;
- // margin-bottom: 20rpx;
- border-bottom: 2rpx solid #e1e1e1;
- &.none {
- border-bottom: none;
- }
- .register-title {
- line-height: 60rpx;
- font-size: $font-size-32;
- color: $text-color;
- text-align: left;
- padding-left: 20rpx;
- .txt {
- font-size: $font-size-26;
- font-weight: normal;
- }
- }
- .row-btn {
- position: absolute;
- right: 24rpx;
- top: 0;
- line-height: 88rpx;
- text-align: center;
- font-size: $font-size-28;
- color: $color-system;
- }
- .register-from {
- width: 702rpx;
- height: 64rpx;
- padding: 24rpx 0;
- position: relative;
- .label {
- text-align: left;
- font-size: $font-size-28;
- color: #666666;
- line-height: 64rpx;
- float: left;
- }
- .row-input {
- width: 440rpx;
- padding-left: 10rpx;
- font-size: $font-size-28;
- color: $text-color;
- line-height: 64rpx;
- float: left;
- height: 64rpx;
- &.none {
- color: #999999;
- }
- }
- &.code {
- width: 410rpx;
- float: left;
- margin-right: 20rpx;
- .row-input {
- width: 390rpx;
- }
- }
- &.btn {
- width: 180rpx;
- height: 64rpx;
- float: right;
- padding: 0;
- border-radius: 32rpx;
- background: $btn-confirm;
- .row-input {
- width: 180rpx;
- height: 64rpx;
- line-height: 64rpx;
- padding: 0;
- background: $btn-confirm;
- color: #ffffff;
- text-align: center;
- border-radius: 45rpx;
- font-size: $font-size-24;
- &.none {
- background: #f7f7f7;
- }
- }
- &.disabled {
- background: #f7f7f7;
- .row-input {
- background: #f7f7f7;
- color: #999999;
- }
- }
- }
- &.btn {
- margin-top: 20rpx;
- }
- }
- }
- .register-btn {
- width: 600rpx;
- height: 88rpx;
- border-radius: 44rpx;
- font-size: $font-size-28;
- line-height: 88rpx;
- color: #ffffff;
- margin: 0 auto;
- text-align: center;
- background: $btn-confirm;
- margin-top: 100rpx;
- &.disabled {
- background: #e2e2e2;
- }
- }
- .register-btn-text {
- width: 500rpx;
- height: auto;
- font-size: $font-size-24;
- line-height: 44rpx;
- color: #f85050;
- margin: 40rpx auto;
- text-align: justify;
- }
- }
- }
- .register-text {
- width: 506rpx;
- color: #fea785;
- font-size: 22rpx;
- line-height: 32rpx;
- margin: 30rpx auto;
- text-align: center;
- }
- .place-holder {
- color: #b2b2b2;
- }
- </style>
|