phone.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <view class="all">
  3. <ujp-navbar title="修改手机号"></ujp-navbar>
  4. <view class="login-form">
  5. <view class="login-form-item">
  6. <view class="input">
  7. <u-input :customStyle="customStyle" :placeholderStyle="placeholderStyle" v-model="form.telephone" type="number" placeholder="请输入手机号" placeholder-style="font-size:16px;color:#ccc;"/>
  8. </view>
  9. </view>
  10. <view class="login-form-item">
  11. <view class="input">
  12. <u-input :customStyle="customStyle" :placeholderStyle="placeholderStyle" v-model="form.verifyCode" type="number" placeholder="请输入验证码" placeholder-style="font-size:16px;color:#ccc;"/>
  13. <view class="code" @click="getCode">{{codeTips}}</view>
  14. </view>
  15. </view>
  16. </view>
  17. <u-button class="login-btn" type="success" shape="circle" @click="sure">确定修改</u-button>
  18. <u-verification-code :seconds="sendMsgSecond" ref="uCode" @change="codeChange" @end="end" @start="start" change-text="已发送(Xs)">
  19. </u-verification-code>
  20. </view>
  21. </template>
  22. <script>
  23. import * as userApi from '@/apis/user.js'
  24. import * as loginApi from '@/apis/login.js'
  25. import {
  26. checkPhone
  27. } from '@/utils'
  28. export default {
  29. data() {
  30. return {
  31. elderMode:false,
  32. customStyle:{
  33. 'font-size':'28rpx'
  34. },
  35. placeholderStyle:"font-size:28rpx",
  36. form: {
  37. telephone: '',
  38. verifyCode: '',
  39. },
  40. isSendMsgIng: false,
  41. sendMsgSecond: 60,
  42. codeTips: '',
  43. jpcode: 'toLogin',
  44. }
  45. },
  46. methods: {
  47. codeChange(text) {
  48. this.codeTips = text;
  49. },
  50. start() {
  51. if (!this.isSendMsgIng) {
  52. uni.showLoading({
  53. title: "加载中",
  54. mask: true,
  55. })
  56. loginApi.getVerifyCode(this.form.telephone).then((response) => {
  57. uni.hideLoading();
  58. this.carhelp.set("getvcodetime", new Date().getTime());
  59. if (!"") {
  60. //倒计时
  61. uni.showToast({
  62. title: "发送成功"
  63. })
  64. } else {
  65. uni.showToast({
  66. title: "您的验证码已经发送[5分钟有效],请勿重复点击"
  67. })
  68. }
  69. }).catch(error => {
  70. uni.showToast({
  71. title: error,
  72. icon: "none"
  73. })
  74. })
  75. }
  76. },
  77. //倒计时
  78. end() {
  79. this.sendMsgSecond = 60;
  80. this.isSendMsgIng = false;
  81. },
  82. // 获取验证码
  83. getCode() {
  84. if (this.$refs.uCode.canGetCode) {} else {
  85. uni.showToast({
  86. title: '倒计时结束后再发送',
  87. icon: "none"
  88. })
  89. return
  90. }
  91. var checkPhoneResult = checkPhone(this.form.telephone);
  92. if (checkPhoneResult !== true) {
  93. uni.showToast({
  94. title: checkPhoneResult,
  95. })
  96. return;
  97. }
  98. this.$refs.uCode.start();
  99. },
  100. sure() {
  101. var checkPhoneResult = checkPhone(this.form.telephone);
  102. if(!this.form.telephone || checkPhoneResult != true) {
  103. uni.showToast({
  104. title: checkPhoneResult,
  105. icon: "none"
  106. })
  107. return;
  108. }
  109. if(!this.form.verifyCode) {
  110. uni.showToast({
  111. title: "请输入验证码",
  112. icon: "none"
  113. })
  114. return
  115. }
  116. uni.showLoading({
  117. title: "加载中",
  118. mask: true,
  119. })
  120. userApi.changePhone(this.form).then((response) => {
  121. uni.hideLoading();
  122. uni.reLaunch({
  123. url: '/pages/index/index?jpcode=' + this.jpcode
  124. })
  125. }).catch(error => {
  126. uni.showToast({
  127. title: error,
  128. icon: "none"
  129. })
  130. })
  131. },
  132. theme(type) {
  133. if(type == 'elder')
  134. {
  135. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  136. let data = {
  137. "font-size":'32rpx',
  138. };
  139. this.customStyle = data;
  140. this.placeholderStyle = "font-size:32rpx";//data;
  141. }
  142. else
  143. {
  144. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  145. let data = {
  146. "font-size":'28rpx'
  147. };
  148. this.customStyle = data;
  149. this.placeholderStyle = "font-size:28rpx";//data;
  150. }
  151. }
  152. },
  153. onReady(){
  154. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  155. if(this.elderMode)
  156. this.theme('elder')
  157. else
  158. this.theme('standard')
  159. }
  160. }
  161. </script>
  162. <style>
  163. page{
  164. background-color: #fff;
  165. }
  166. </style>
  167. <style lang="scss" scoped>
  168. @import "@/_theme.scss";
  169. .all{
  170. @include themeify{
  171. font-size: themed('font-size2');
  172. }
  173. }
  174. .login-form{
  175. background-color: #fff;
  176. padding: 12px 28px;
  177. }
  178. .login-form-item{
  179. .title{
  180. margin-bottom: 8px;
  181. }
  182. .input {
  183. padding: 4px 0;
  184. border-bottom: 1px solid #f7f7f7;
  185. position: relative;
  186. }
  187. .code{
  188. position: absolute;
  189. right: 0;
  190. top:12px;
  191. color:#1677FF;
  192. }
  193. .tips {
  194. color: $u-type-info;
  195. margin-top: 12px;
  196. @include themeify{
  197. font-size: themed('font-size1');
  198. }
  199. /* font-size: 12px;*/
  200. span{
  201. color:#3fbd70;
  202. }
  203. }
  204. }
  205. .login-btn {
  206. margin: 28px ;
  207. background-color:#00B962!important;
  208. border-color: #00B962!important;
  209. color:#fff!important;
  210. }
  211. </style>