changeMailbox.vue 5.1 KB

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