phone.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <view class="container register">
  3. <view class="register-main first clearfix">
  4. <view class="register-row clearfix">
  5. <view class="register-from">
  6. <view class="label">原手机号:</view>
  7. <view class="row-input">{{bindMobile}}</view>
  8. </view>
  9. </view>
  10. <view class="register-row clearfix">
  11. <view class="register-from code">
  12. <input class="row-input" type="number" v-model="mobileCode" placeholder="请输入原手机号的验证码" placeholder-class="place-holder" maxlength="6"/>
  13. </view>
  14. <view class="register-from btn" :class="[isMobileDisabled ? 'disabled' : '']">
  15. <button class="row-input" type="button" @click.stop="getMobileCodeFn" :disabled="isMobileDisabled">{{ mobileCodeText }}</button>
  16. </view>
  17. </view>
  18. <view class="register-row clearfix">
  19. <view class="register-from">
  20. <input class="row-input" type="number" v-model="contractMobile" placeholder="请输入新手机号" placeholder-class="place-holder" maxlength="11"/>
  21. </view>
  22. </view>
  23. <view class="register-row clearfix">
  24. <view class="register-from code">
  25. <input class="row-input" type="number" v-model="newMobileCode" placeholder="请输入新手机号的验证码" placeholder-class="place-holder" maxlength="6"/>
  26. </view>
  27. <view class="register-from btn" :class="[isNewMobileDisabled ? 'disabled' : '']" >
  28. <button class="row-input" type="button" @click.stop="getNewMobileCodeFn" :disabled="isNewMobileDisabled">{{ newMobileCodeText }}</button>
  29. </view>
  30. </view>
  31. <view class="register-row clearfix" style="border: 0;">
  32. <view class="register-btn" @click="bindMobileCheck">确定</view>
  33. </view>
  34. <view class="register-text clearfix">
  35. <view >注意:本操作更换的是机构联系人的手机号,不是运营人员的手机号!</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import { mapMutations } from 'vuex';
  42. import { getClubMobileCode,getClubNewMobileCode } from "@/services/public.js"
  43. import { changeMobile } from "@/services/use.js"
  44. var self;
  45. export default{
  46. data() {
  47. return{
  48. userID:'', //用户ID
  49. count: '', //倒计时
  50. newCount: '', //倒计时
  51. codeTime: null,
  52. codeTimeNew: null,
  53. bindMobile:'', //联系人手机号
  54. contractMobile:'', //新联系人手机号
  55. mobileCode:'', //手机号验证码
  56. newMobileCode:'', //新手机号手机验证码
  57. mobileCodeText: '获取验证码',
  58. newMobileCodeText: '获取验证码',
  59. isMobileDisabled: false, //手机验证码按钮控制
  60. isNewMobileDisabled: false, //手机验证码按钮控制
  61. }
  62. },
  63. onLoad(option) {
  64. this.bindMobile = option.phone
  65. },
  66. methods:{
  67. bindMobileCheck(){
  68. let params = {
  69. contractMobile2:this.bindMobile,
  70. contractMobile:this.contractMobile,
  71. mobileCode:this.mobileCode,
  72. newMobileCode:this.newMobileCode,
  73. userID:this.userID
  74. }
  75. changeMobile(params).then(response =>{
  76. this.$util.msg('修改成功',1500,true,'success')
  77. setTimeout(()=>{
  78. uni.navigateBack({delta: 1})
  79. },2000)
  80. }).catch( error =>{
  81. this.$util.msg(error.msg,2000);
  82. })
  83. },
  84. getMobileCodeFn(){
  85. if( this.bindMobile == ''){
  86. this.$util.msg('请输入手机号',2000);
  87. return
  88. }
  89. if(!this.$reg.isMobile(this.bindMobile)){
  90. this.$util.msg('请输入正确的手机号',2000);
  91. return
  92. }
  93. let params = { mobile : this.bindMobile }
  94. this.isMobileDisabled = true;
  95. getClubMobileCode(params).then(response =>{
  96. this.$util.msg('验证短信已发送',2000);
  97. const TIME_COUNT = 60;
  98. if (!this.codeTime) {
  99. this.count = TIME_COUNT;
  100. this.isMobileDisabled = true;
  101. this.codeTime = setInterval(() => {
  102. if (this.count > 1 && this.count <= TIME_COUNT) {
  103. this.count--
  104. this.mobileCodeText = this.count +'s重新发送'
  105. } else {
  106. this.isMobileDisabled = false;
  107. clearInterval(this.codeTime)
  108. this.codeTime = null
  109. this.mobileCodeText = '获取验证码'
  110. }
  111. },1000)
  112. }
  113. }).catch( error =>{
  114. this.$util.msg(error.msg,2000);
  115. this.isMobileDisabled = false;
  116. })
  117. },
  118. getNewMobileCodeFn(){
  119. if( this.contractMobile == ''){
  120. this.$util.msg('请输入手机号',2000);
  121. return
  122. }
  123. if(!this.$reg.isMobile(this.contractMobile)){
  124. this.$util.msg('请输入正确的手机号',2000);
  125. return
  126. }
  127. let params = { newMobile : this.contractMobile }
  128. this.isNewMobileDisabled = true;
  129. getClubNewMobileCode(params).then(response =>{
  130. this.$util.msg('验证短信已发送',2000);
  131. const TIME_COUNT = 60;
  132. if (!this.codeTimeNew) {
  133. this.newCount = TIME_COUNT;
  134. this.isNewMobileDisabled = true;
  135. this.codeTimeNew = setInterval(() => {
  136. if (this.newCount > 1 && this.newCount <= TIME_COUNT) {
  137. this.newCount--
  138. this.newMobileCodeText = this.newCount +'s重新发送'
  139. } else {
  140. this.isNewMobileDisabled = false;
  141. clearInterval(this.codeTimeNew)
  142. this.codeTimeNew = null
  143. this.newMobileCodeText = '获取验证码'
  144. }
  145. },1000)
  146. }
  147. }).catch( error =>{
  148. this.$util.msg(error.msg,2000);
  149. this.isNewMobileDisabled = false;
  150. })
  151. }
  152. },
  153. onShow() {
  154. this.$api.getStorage().then((resolve) =>{
  155. this.userID = resolve.userID
  156. })
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. .register{
  162. width: 100%;
  163. height: auto;
  164. border-top: 1px solid #F7F7F7;
  165. .model-warp.none{
  166. display: none;
  167. }
  168. .model-warp.show{
  169. display: block;
  170. }
  171. .register-main{
  172. width: 100%;
  173. height: auto;
  174. &.detailed{
  175. padding-bottom: 300rpx;
  176. }
  177. &.first{
  178. padding-top: 40rpx;
  179. }
  180. .register-tips{
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. line-height: 44rpx;
  185. font-size: $font-size-24;
  186. color: #FF0000;
  187. margin-bottom: 40rpx;
  188. .iconfont{
  189. font-size: $font-size-24;
  190. }
  191. }
  192. .register-row{
  193. width: 702rpx;
  194. height: auto;
  195. margin: auto;
  196. // margin-bottom: 20rpx;
  197. border-bottom: 2rpx solid #e1e1e1;
  198. .register-title{
  199. line-height: 60rpx;
  200. font-size: $font-size-32;
  201. color: $text-color;
  202. text-align: left;
  203. padding-left: 20rpx;
  204. .txt{
  205. font-size: $font-size-26;
  206. font-weight: normal;
  207. }
  208. }
  209. .row-btn{
  210. position: absolute;
  211. right: 24rpx;
  212. top: 0;
  213. line-height: 88rpx;
  214. text-align: center;
  215. font-size: $font-size-28;
  216. color: $color-system;
  217. }
  218. .register-from{
  219. width: 702rpx;
  220. height: 64rpx;
  221. padding: 24rpx 0;
  222. position: relative;
  223. .label{
  224. text-align: left;
  225. font-size: $font-size-28;
  226. color: #666666;
  227. line-height: 64rpx;
  228. float: left;
  229. }
  230. .row-input{
  231. width: 440rpx;
  232. padding-left:10rpx;
  233. font-size: $font-size-28;
  234. color: $text-color;
  235. line-height: 64rpx;
  236. float: left;
  237. height: 64rpx;
  238. &.none{
  239. color: #999999;
  240. }
  241. }
  242. &.code{
  243. width: 410rpx;
  244. float: left;
  245. margin-right: 20rpx;
  246. .row-input{
  247. width: 390rpx;
  248. }
  249. }
  250. &.btn{
  251. width: 180rpx;
  252. height:64rpx;
  253. float: right;
  254. padding: 0;
  255. border: 2rpx solid #e15616;
  256. border-radius: 45rpx;
  257. .row-input{
  258. width: 180rpx;
  259. height: 64rpx;
  260. line-height: 64rpx;
  261. padding: 0;
  262. color:#E15616;
  263. text-align: center;
  264. border-radius: 45rpx;
  265. font-size: $font-size-24;
  266. &.none{
  267. background: #F7F7F7;
  268. }
  269. }
  270. &.disabled{
  271. background: #F7F7F7;
  272. border: 2rpx solid #F7F7F7;
  273. .row-input{
  274. background: #F7F7F7;
  275. color: #999999;
  276. }
  277. }
  278. }
  279. &.btn{
  280. margin-top: 20rpx;
  281. }
  282. }
  283. }
  284. .register-btn{
  285. width: 600rpx;
  286. height: 90rpx;
  287. border-radius: 45rpx;
  288. font-size: $font-size-28;
  289. line-height: 88rpx;
  290. color: #FFFFFF;
  291. margin: 0 auto;
  292. text-align: center;
  293. background: $btn-confirm;
  294. margin-top: 96rpx;
  295. &.sub{
  296. margin-top: 0;
  297. }
  298. }
  299. }
  300. }
  301. .register-text{
  302. width: 506rpx;
  303. color: #fea785;
  304. font-size: 22rpx;
  305. line-height: 32rpx;
  306. margin: 30rpx auto;
  307. text-align: center
  308. }
  309. .place-holder{
  310. color: #b2b2b2;
  311. }
  312. </style>