changeMobileNumber.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <view>
  3. <u-navbar :back-text="i18n('Back')" title-width="300" :back-text-style="backStyle" back-icon-color="#fff" title-color="#fff"
  4. :background="background" :title="$i18n.locale=='zh'?'更改手机号':'Change mobile number'"></u-navbar>
  5. <view class="Unbundling">
  6. {{i18n('remarkSecPhone1')}}:{{salfPhone}}
  7. </view>
  8. <view class="Unbundling" style="font-size: 22upx;">{{i18n('remarkSecPhone2')}}</view>
  9. <view class="Unbundling-input">
  10. <u-form :model="form" ref="uForm">
  11. <!-- <u-form-item label="手机号" :label-width="120">
  12. <u-input v-model="form.moblie" :border="true" placeholder="请输入手机号" />
  13. </u-form-item> -->
  14. <u-form-item label="" :label-width="120" style="">
  15. <u-input v-model="form.code" :border="true" :placeholder="i18n('EnterVerification')" />
  16. <text class="code-send" v-if="showText==true" @click="getCodeFor">{{i18n('GetVerification')}}</text>
  17. <text v-else class=" code">{{second}}s{{i18n('resend')}}</text>
  18. </u-form-item>
  19. </u-form>
  20. <view class="next">
  21. <u-button type="primary" @click="validCode">{{i18n('Next')}}</u-button>
  22. </view>
  23. </view>
  24. <u-toast ref="uToast" />
  25. </view>
  26. </template>
  27. <script>
  28. import listCell from '@/components/JumpBox';
  29. export default {
  30. components: {
  31. listCell
  32. },
  33. data() {
  34. return {
  35. second: 60,
  36. showText: true,
  37. form: {
  38. code: '', //验证码
  39. },
  40. moblieNum: '', //手机号
  41. moblie: '', //手机号
  42. salfPhone: '',
  43. phoneUserNum: "",
  44. background: {
  45. backgroundImage: 'linear-gradient(270deg, #4BC0E2 0%, #538BE7 100%)',
  46. },
  47. backStyle: {
  48. color: '#FFFFFF',
  49. },
  50. };
  51. },
  52. onShow() {
  53. // this.phoneUserNum = uni.getStorageSync('loginAccount');
  54. this.getUserInfoById();
  55. },
  56. methods: {
  57. async getUserInfoById() {
  58. const result = await this.$myRequest({
  59. url: '/uc/securitySetting/getUserInfoById',
  60. });
  61. this.moblie = result.data.userPreferredMobile;
  62. if (result) {
  63. // this.moblieNum = JSON.stringify(result.data.userPreferredMobile);
  64. this.moblieNum = result.data.userPreferredMobile;
  65. if (this.moblieNum.length < 12) {
  66. this.salfPhone = this.moblieNum.substr(0, 3) + '****' + this.moblieNum.substr(7, 4);
  67. }else{
  68. this.salfPhone = this.moblieNum.substr(4, 3) + '****' + this.moblieNum.substr(11, 4);
  69. }
  70. console.log(this.moblieNum)
  71. console.log(this.salfPhone)
  72. } else {
  73. this.msg(result.msg, "error");
  74. }
  75. },
  76. // 通用跳转
  77. navTo(route) {
  78. this.$mRouter.push({
  79. route
  80. });
  81. },
  82. //校验验证码
  83. async validCode() {
  84. if (!this.form.code) {
  85. this.msg(this.i18n('Verificationcodecannotbeempty'), "warning");
  86. return false;
  87. }
  88. const result = await this.$myRequest({
  89. url: '/uc/securitySetting/validCode',
  90. data: {
  91. mobile: this.moblie,
  92. code: this.form.code
  93. }
  94. });
  95. if (result.status == '200') {
  96. this.$mRouter.push({
  97. route: '/pages/profile/profileSetUp/changeNewMobileNumber'
  98. });
  99. } else {
  100. this.msg(result.msg, "error");
  101. }
  102. },
  103. //获取验证码信息
  104. async getCodeFor() {
  105. let language = this.$i18n.locale;
  106. //获取验证码信息
  107. const result = await this.$myRequest({
  108. url: '/ums/umsUsers/registCode',
  109. data: {
  110. account: this.moblie,
  111. service: "TX",
  112. language
  113. }
  114. });
  115. if (result.status == '200') {
  116. this.msg(this.i18n('Verificationcodehasbeensent'), "success");
  117. } else {
  118. this.msg(result.msg, "error");
  119. }
  120. this.showText = false
  121. let interval = setInterval(() => {
  122. let times = --this.second
  123. }, 1000)
  124. setTimeout(() => {
  125. clearInterval(interval)
  126. this.second = 60
  127. this.showText = true
  128. }, 60000)
  129. },
  130. msg(msg, type) {
  131. if (msg == 'error') {
  132. msg = this.i18n('ThesystemisbusyPleasetryagainlater') + "!" //系统繁忙,请稍后再试
  133. }
  134. return this.$refs.uToast.show({
  135. title: msg,
  136. type: type,
  137. // url: '/pages/user/index'
  138. })
  139. },
  140. i18n(data) {
  141. return this.$t('common.' + data);
  142. },
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. page,
  148. body.pages-profile-profileSetUp-setUp uni-page-body {
  149. background-color: #fff !important;
  150. .Unbundling {
  151. margin: 30upx 40upx 40upx 40upx;
  152. color: #333;
  153. font-size: 38upx;
  154. text-align: center;
  155. }
  156. .Unbundling-input {
  157. margin: 0 40upx;
  158. .uni-input {
  159. display: inline-block;
  160. font-size: 30upx;
  161. line-height: 90upx;
  162. height: 90upx;
  163. min-height: 90upx;
  164. overflow: hidden;
  165. border: 1px solid #ccc;
  166. width: 70%;
  167. vertical-align: middle;
  168. text-indent: 2em;
  169. }
  170. .getCode {
  171. margin-left: 20upx;
  172. color: #0000ff;
  173. }
  174. .send {
  175. margin-left: 20upx;
  176. }
  177. .code-send {
  178. margin-left: 48upx;
  179. color: #0000BF;
  180. }
  181. .next {
  182. margin-top: 100upx;
  183. }
  184. }
  185. }
  186. </style>