code.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="container-mine">
  3. <navbar ref="navbar" :config="config"></navbar>
  4. <view class="top">
  5. <view class="title">输入验证码</view>
  6. <view>我们已向 {{mobile}} 发送验证码短信</view>
  7. <view>请查看短信并输入验证码</view>
  8. </view>
  9. <view class="body">
  10. <u-message-input focus @finish="finish"></u-message-input>
  11. <u-verification-code :seconds="seconds" start-text="重新获取" @end="end" @start="start" ref="uCode"
  12. @change="codeChange"></u-verification-code>
  13. <view class="reset" @tap="getCode">{{tips}}</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import {smsCode} from "@/api/government.js"
  19. let app = getApp()
  20. export default {
  21. data() {
  22. return {
  23. config: {
  24. back: true, //false是tolbar页面 是则不写
  25. title: '',
  26. color: '#fff',
  27. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  28. backgroundColor: [1, '#F9F9F9'],
  29. },
  30. statusBarHeight: app.globalData.statusBarHeight,
  31. mobile: '',
  32. tips: '',
  33. seconds: 60,
  34. cid: null
  35. }
  36. },
  37. onLoad(options) {
  38. if (options && options.mobile) {
  39. this.mobile = options.mobile
  40. }
  41. // #ifdef APP-PLUS
  42. plus.push.getClientInfoAsync((info) => {
  43. let cid = info["clientid"];
  44. console.log('cid',cid)
  45. uni.setStorageSync('cid', cid)
  46. this.cid = cid
  47. });
  48. // #endif
  49. },
  50. mounted() {
  51. this.getCode()
  52. },
  53. methods: {
  54. codeChange(text) {
  55. console.log(text)
  56. this.tips = text;
  57. },
  58. getCode() {
  59. if (this.$refs.uCode.canGetCode) {
  60. // 模拟向后端请求验证码
  61. uni.showLoading({
  62. title: '正在获取验证码'
  63. })
  64. smsCode({mobile:this.mobile}).then(res=>{
  65. this.$u.toast('验证码已发送');
  66. }).finally(e=>{
  67. uni.hideLoading();
  68. // 这里此提示会被this.start()方法中的提示覆盖
  69. this.$refs.uCode.start();
  70. })
  71. } else {
  72. this.$u.toast('倒计时结束后再发送');
  73. }
  74. },
  75. end() {
  76. // this.$u.toast('倒计时结束');
  77. },
  78. start() {
  79. this.$u.toast('请输入验证码');
  80. },
  81. finish(e) {
  82. console.log('输入结束,当前值为:' + e);
  83. this.$yghttp.post('/user/login/captcha', {
  84. captcha: e,
  85. mobile: this.mobile,
  86. cid: this.cid
  87. }).then(res => {
  88. if (res && res.code == 200) {
  89. this.$u.toast('登录成功');
  90. uni.setStorageSync('apiToken', res.data.token);
  91. this.getUsrShopInfo()
  92. uni.switchTab({
  93. url: '/pages/home'
  94. })
  95. } else {
  96. this.$u.toast('验证码错误');
  97. }
  98. })
  99. },
  100. // 获取商城用户店铺信息 商城接口
  101. getUsrShopInfo() {
  102. this.$http.get('/yxt/shop/loadSubShopByUserId').then(res => {
  103. if (res && res.code == 200) {
  104. uni.setStorageSync("shop", res.shop);
  105. }
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style>
  112. page {
  113. background-color: #F9F9F9;
  114. }
  115. </style>
  116. <style lang="scss" scoped>
  117. /deep/ .hx-navbar__icon {
  118. color: #303133 !important;
  119. }
  120. /deep/ .u-char-item{
  121. width: 120rpx !important;
  122. height: 120rpx !important;
  123. background: #ffffff;
  124. border-radius: 20rpx;
  125. border:none !important;
  126. }
  127. /deep/.u-box-active{
  128. border: 2rpx solid #56cbda !important;
  129. }
  130. .lgoin-nav {
  131. width: 100%;
  132. background-color: #fff;
  133. position: fixed;
  134. left: 0;
  135. right: 0;
  136. top: 0;
  137. z-index: 0;
  138. }
  139. .top {
  140. text-align: center;
  141. padding: 80rpx 0 150rpx;
  142. font-size: 30rpx;
  143. .title {
  144. font-size: 60rpx;
  145. margin-bottom: 20rpx;
  146. font-weight: 700;
  147. }
  148. }
  149. .body {
  150. padding: 0 30rpx;
  151. margin-bottom: 200rpx;
  152. .uni-input {
  153. height: 100rpx;
  154. margin-bottom: 20rpx;
  155. border-bottom: 1rpx solid #ccc;
  156. .uni-input-placeholder {
  157. color: #BEBEBE;
  158. }
  159. }
  160. .login-btn {
  161. background-color: #4095E5;
  162. color: #fff;
  163. }
  164. /deep/ .u-char-box {
  165. margin-bottom: 20rpx;
  166. .u-char-flex {
  167. // justify-content: space-between;
  168. }
  169. }
  170. .reset {
  171. // max-width: 300rpx;
  172. padding: 10rpx 80rpx 10rpx;
  173. margin-left: auto;
  174. text-align: right;
  175. color: #56CBD9;
  176. // border: 1rpx solid #3775F6;
  177. border-radius: 8rpx;
  178. cursor: pointer;
  179. }
  180. }
  181. </style>