logoutVerificationCode.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="page">
  3. <!-- 头部吸顶区域 -->
  4. <u-sticky z-index="999" h5-nav-height="0">
  5. <view class="navbar dis a-c j-s ">
  6. <u-icon name="arrow-left" color="#333" size="40" @tap="back"></u-icon>
  7. </view>
  8. </u-sticky>
  9. <view class="content dis a-c f-c">
  10. <text class="title">请输入验证码</text>
  11. <text class="phone mt-1">验证码已发送至:+86 {{phone}}</text>
  12. <view class="code dis a-c j-s ">
  13. <u-input v-model="info.value" type="text" placeholder="请输入短信验证码" />
  14. <view class="verificationCode" @tap="getCheckNum" :class="codetime?'verificationCode1':''">
  15. {{!codetime?'获取验证码':codetime+' S'+'后重新获取'}}
  16. </view>
  17. </view>
  18. </view>
  19. <view class="footer">
  20. <view class="btn dis a-c j-c " @click="confirmLogout">
  21. 确定注销
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState,
  29. mapMutations
  30. } from "vuex"
  31. export default {
  32. data() {
  33. return {
  34. info: {
  35. userId: "",
  36. value: "",
  37. },
  38. phone: "",
  39. codetime: 0, //验证码获取倒计时
  40. }
  41. },
  42. computed: {
  43. ...mapState(['userInfo']),
  44. },
  45. onShow() {
  46. },
  47. onLoad(options) {
  48. if (options) {
  49. this.info.userId = options.userId;
  50. this.phone = options.phone;
  51. }
  52. },
  53. methods: {
  54. ...mapMutations(['emptyUserInfo']),
  55. async confirmLogout() {
  56. let res = await this.$http.get('/user/userLogout?userId=' + this.userInfo
  57. .sysUser.id + '&valiCode=2080')
  58. if (res.code == 200) {
  59. uni.showToast({
  60. title: res.msg,
  61. icon: 'none'
  62. });
  63. this.emptyUserInfo();
  64. setTimeout(() => {
  65. uni.reLaunch({
  66. url: "/pages/login/login"
  67. })
  68. return true;
  69. }, 500);
  70. } else {
  71. uni.showToast({
  72. title: res.msg,
  73. icon: 'none'
  74. });
  75. }
  76. },
  77. // 获取验证码
  78. async getCheckNum() {
  79. uni.hideKeyboard();
  80. if (this.codetime > 0) return;
  81. // 验证手机号合法性
  82. if (!this.phone) {
  83. return uni.showToast({
  84. title: '请输入手机号',
  85. icon: 'none'
  86. });
  87. }
  88. if (!this.$base.phoneRegular.test(this.phone)) {
  89. return uni.showToast({
  90. title: '请输入正确的手机号码',
  91. icon: 'none'
  92. });
  93. }
  94. // 请求服务器,发送验证码
  95. let res = await this.$http.get('/sendMsg', {
  96. phone: this.phone,
  97. type: "2"
  98. });
  99. // 请求失败处理
  100. if (res.code != 200) {
  101. return uni.showToast({
  102. title: res.data.msg,
  103. icon: "none"
  104. });
  105. } else {
  106. uni.showToast({
  107. title: "发送成功",
  108. icon: "none"
  109. });
  110. }
  111. // 发送成功,开启倒计时
  112. this.codetime = 60;
  113. let timer = setInterval(() => {
  114. this.codetime--;
  115. if (this.codetime < 1) {
  116. clearInterval(timer);
  117. this.codetime = 0;
  118. }
  119. }, 1000);
  120. },
  121. back() {
  122. uni.navigateBack(-1)
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. page {
  129. background-color: #F8FAFE;
  130. }
  131. .navbar {
  132. padding: 58px 15px 8px;
  133. box-sizing: border-box;
  134. position: relative;
  135. z-index: 9999;
  136. background-color: #F8FAFE;
  137. text {
  138. font-size: 36rpx;
  139. color: #333;
  140. font-weight: bold;
  141. }
  142. }
  143. .content {
  144. padding: 0 30rpx;
  145. box-sizing: border-box;
  146. .title {
  147. font-size: 42rpx;
  148. color: #333;
  149. font-weight: bold;
  150. margin-top: 75rpx;
  151. }
  152. .phone {
  153. font-size: 30rpx;
  154. color: #666;
  155. }
  156. .code {
  157. width: 100%;
  158. padding: 24rpx;
  159. box-sizing: border-box;
  160. background: #FFFFFF;
  161. box-shadow: 0rpx 4rpx 13rpx 0rpx rgba(218, 227, 244, 0.2);
  162. border-radius: 13rpx 13rpx 13rpx 13rpx;
  163. margin-top: 58rpx;
  164. .verificationCode {
  165. font-size: 30rpx;
  166. color: #0052FF;
  167. }
  168. .verificationCode1 {
  169. font-size: 30rpx;
  170. color: #B2B2B2;
  171. }
  172. }
  173. }
  174. .footer {
  175. position: fixed;
  176. bottom: 0;
  177. left: 0;
  178. right: 0;
  179. padding: 25rpx 33rpx;
  180. box-sizing: border-box;
  181. background: #FFFFFF;
  182. box-shadow: 0rpx -4rpx 10rpx 0rpx rgba(218, 227, 244, 0.2);
  183. border-radius: 0rpx 0rpx 0rpx 0rpx;
  184. .btn {
  185. width: 100%;
  186. padding: 15rpx;
  187. box-sizing: border-box;
  188. font-size: 33rpx;
  189. color: #fff;
  190. background: linear-gradient(90deg, #499DFF 0%, #0052FF 100%);
  191. border-radius: 8rpx 8rpx 8rpx 8rpx;
  192. }
  193. }
  194. </style>