phone.vue 9.0 KB

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