modify-phone.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <template>
  2. <view class="login-container">
  3. <view class="p30">
  4. <view class="group-bd">
  5. <view class="form-level d-s-c">
  6. <view class="d-s-c field-name">
  7. <text class="orange">*</text>
  8. <text class="gray3">手机号:</text>
  9. </view>
  10. <view class="val flex-1"><input type="text" v-model="formData.mobile" placeholder="请输入要绑定的新手机号" :disabled="is_send" /></view>
  11. </view>
  12. <view class="form-level d-s-c">
  13. <view class="d-s-c field-name">
  14. <text class="orange">*</text>
  15. <text class="gray3">验证码:</text>
  16. </view>
  17. <view class="val flex-1 d-b-c">
  18. <input class="flex-1" type="number" v-model="formData.code" placeholder="请输入验证码" />
  19. <button class="get-code-btn" type="default" @click="sendCode" :disabled="is_send">{{ send_btn_txt }}</button>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="btns p30"><button type="default" @click="formSubmit">提交</button></view>
  25. </view>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. /*表单数据对象*/
  32. formData: {
  33. /*手机号*/
  34. mobile: '',
  35. /*验证码*/
  36. code: '',
  37. },
  38. /*是否已发验证码*/
  39. is_send: false,
  40. /*发送按钮文本*/
  41. send_btn_txt: '获取验证码',
  42. /*当前秒数*/
  43. second: 60,
  44. ip: '',
  45. };
  46. },
  47. onLoad() {
  48. },
  49. methods: {
  50. /*提交*/
  51. formSubmit() {
  52. let self = this;
  53. if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.formData.mobile)) {
  54. uni.showToast({
  55. title: '手机有误,请重填!',
  56. duration: 2000,
  57. icon: 'none'
  58. });
  59. return;
  60. }
  61. if (self.formData.code == '') {
  62. uni.showToast({
  63. title: '验证码不能为空!',
  64. duration: 2000,
  65. icon: 'none'
  66. });
  67. return;
  68. }
  69. uni.showLoading({
  70. title: '正在提交'
  71. });
  72. uni.navigateBack();
  73. self._post(
  74. 'user.userweb/bindMobile',
  75. self.formData,
  76. result => {
  77. uni.showToast({
  78. title: '绑定成功',
  79. duration: 2000
  80. });
  81. setTimeout(function(){
  82. // 执行回调函数
  83. uni.navigateBack();
  84. }, 2000);
  85. },
  86. false,
  87. () => {
  88. uni.hideLoading();
  89. }
  90. );
  91. },
  92. /*发送短信*/
  93. sendCode() {
  94. let self = this;
  95. if (!/^1(3|4|5|6|7|8|9)\d{9}$/.test(self.formData.mobile)) {
  96. uni.showToast({
  97. title: '手机有误,请重填!',
  98. duration: 2000,
  99. icon: 'none'
  100. });
  101. return;
  102. }
  103. self._post(
  104. 'user.userweb/sendCode',
  105. {
  106. mobile: self.formData.mobile
  107. },
  108. result => {
  109. if (result.code == 1) {
  110. uni.showToast({
  111. title: '发送成功'
  112. });
  113. self.is_send = true;
  114. self.changeMsg();
  115. }
  116. }
  117. );
  118. },
  119. /*改变发送验证码按钮文本*/
  120. changeMsg() {
  121. if (this.second > 0) {
  122. this.send_btn_txt = this.second + '秒';
  123. this.second--;
  124. setTimeout(this.changeMsg, 1000);
  125. } else {
  126. this.send_btn_txt = '获取验证码';
  127. this.second = 60;
  128. this.is_send = false;
  129. }
  130. },
  131. }
  132. };
  133. </script>
  134. <style lang="scss" scoped>
  135. .login-container {
  136. background: #ffffff;
  137. }
  138. .login-container input {
  139. height: 88rpx;
  140. line-height: 88rpx;
  141. }
  142. .wechatapp {
  143. padding: 80rpx 0 48rpx;
  144. border-bottom: 1rpx solid #e3e3e3;
  145. margin-bottom: 72rpx;
  146. text-align: center;
  147. }
  148. .wechatapp .header {
  149. width: 190rpx;
  150. height: 190rpx;
  151. border: 2px solid #fff;
  152. margin: 0rpx auto 0;
  153. border-radius: 50%;
  154. overflow: hidden;
  155. box-shadow: 1px 0px 5px rgba(50, 50, 50, 0.3);
  156. }
  157. .auth-title {
  158. color: #585858;
  159. font-size: 34rpx;
  160. margin-bottom: 40rpx;
  161. }
  162. .auth-subtitle {
  163. color: #888;
  164. margin-bottom: 88rpx;
  165. font-size: 28rpx;
  166. }
  167. .login-btn {
  168. padding: 0 20rpx;
  169. }
  170. .login-btn button {
  171. height: 88rpx;
  172. line-height: 88rpx;
  173. background: #04be01;
  174. color: #fff;
  175. font-size: 30rpx;
  176. border-radius: 999rpx;
  177. text-align: center;
  178. }
  179. .no-login-btn {
  180. margin-top: 20rpx;
  181. padding: 0 20rpx;
  182. }
  183. .no-login-btn button {
  184. height: 88rpx;
  185. line-height: 88rpx;
  186. background: #dfdfdf;
  187. color: #fff;
  188. font-size: 30rpx;
  189. border-radius: 999rpx;
  190. text-align: center;
  191. }
  192. .get-code-btn {
  193. width: 200rpx;
  194. height: 80rpx;
  195. line-height: 76rpx;
  196. padding: 0rpx 30rpx;
  197. border-radius: 40rpx;
  198. white-space: nowrap;
  199. border: 1rpx solid $dominant-color;
  200. color: $dominant-color;
  201. font-size: 30rpx;
  202. }
  203. .get-code-btn[disabled='true'] {
  204. border: 1rpx solid #cccccc;
  205. }
  206. .btns button {
  207. height: 90rpx;
  208. line-height: 90rpx;
  209. font-size: 34rpx;
  210. border-radius: 45rpx;
  211. background: $dominant-color;
  212. color: #ffffff;
  213. }
  214. </style>