phone.vue 7.8 KB

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