You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

204 lines
4.4 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <view class="app-container">
  3. <view class="login-content">
  4. <view class="login-font">
  5. <image style="width: 364rpx;height: 200rpx;" src="/static/login/proxy-user-copy.png" alt="" />
  6. </view>
  7. <view class="login-main">
  8. <view class="login-item">
  9. <input type="tel" class="log-phone" placeholder="请输入手机号" v-model="phone" />
  10. </view>
  11. <view class="login-item">
  12. <input type="number" class="log-phone log-code" placeholder="请输入验证码" v-model="sms_code" />
  13. <view class="getCode" @click="getCode" v-if="countdown==0">
  14. 获取验证码
  15. </view>
  16. <view class="getCode" v-else>
  17. 剩余{{countdown}}
  18. </view>
  19. </view>
  20. <view class="login-btn">
  21. <button size="default" type="default" @click="btnLogin"
  22. style="color:#ffffff;backgroundColor:#1783FF;borderColor:#1783FF;border-radius: 50rpx;height: 88rpx;line-height: 88rpx;">登录</button>
  23. </view>
  24. <view class="login-sign">
  25. <u-checkbox-group @change="handleCheck">
  26. <u-checkbox labelSize="13" size="20" shape="circle" name="agree" label="我同意"></u-checkbox>
  27. </u-checkbox-group>
  28. <view class="log-link" @click="handlerApply">
  29. 排队支付代理用户服务协议
  30. </view>
  31. <view class="log-link" @click="handlerProtect">
  32. 隐私保护协议
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <u-modal :show="show" @confirm="confirm" :title="title" :content='content'></u-modal>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. publicSendSms,
  43. agentSmsLogin
  44. } from '../../common/api.js'
  45. import md5 from 'js-md5'
  46. export default {
  47. data() {
  48. return {
  49. phone: '',
  50. sms_code: '',
  51. bgColor: '#bgColor',
  52. checked: false,
  53. show: false,
  54. title: '',
  55. content: '',
  56. countdown: 0
  57. };
  58. },
  59. methods: {
  60. getCode() {
  61. if (!this.phone) {
  62. uni.$u.toast('请填写手机号')
  63. return
  64. }
  65. if (!this.checked) {
  66. uni.$u.toast('需同意协议')
  67. return
  68. }
  69. let phone = this.phone
  70. let nonce_str = md5(Math.random() + '');
  71. let sign = md5(md5(phone) + md5(nonce_str) + nonce_str)
  72. publicSendSms({
  73. phone,
  74. nonce_str,
  75. sign,
  76. type: 2
  77. }).then(() => {
  78. uni.$u.toast('短信已发送')
  79. this.startCountdown()
  80. })
  81. },
  82. startCountdown() {
  83. this.countdown = 60;
  84. let h = setInterval(() => {
  85. this.countdown--
  86. if (this.countdown == 0) {
  87. clearInterval(h)
  88. }
  89. }, 1000)
  90. },
  91. handleCheck(detail) {
  92. console.log(detail)
  93. if (detail.indexOf('agree') != -1) {
  94. this.checked = true
  95. } else {
  96. this.checked = false
  97. }
  98. },
  99. handlerApply() {
  100. this.show = true;
  101. this.title = '排队支付代理用户服务协议';
  102. this.content = '排队支付代理用户服务协议';
  103. },
  104. handlerProtect() {
  105. this.show = true;
  106. this.title = '隐私保护协议';
  107. this.content = '隐私保护协议';
  108. },
  109. confirm() {
  110. this.show = false;
  111. },
  112. btnLogin() {
  113. if (!this.checked) {
  114. uni.$u.toast('需同意协议')
  115. return
  116. }
  117. agentSmsLogin({
  118. phone: this.phone,
  119. sms_code: this.sms_code
  120. }).then(data => {
  121. uni.setStorageSync('agent_token', data.token)
  122. uni.navigateTo({
  123. url: '/pages/index/index'
  124. });
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style lang="scss">
  131. .login-content {
  132. width: 100%;
  133. height: 1500rpx;
  134. padding-left: 30rpx;
  135. padding-right: 30rpx;
  136. background: url(../../static/login/login-bg.png) no-repeat center center;
  137. background-size: cover;
  138. box-sizing: border-box;
  139. .login-font {
  140. width: 364rpx;
  141. height: 200rpx;
  142. padding-top: 80rpx;
  143. }
  144. .login-main {
  145. margin-top: 120rpx;
  146. .login-item {
  147. position: relative;
  148. margin-top: 40rpx;
  149. .log-phone {
  150. width: 100%;
  151. height: 88rpx;
  152. line-height: 88rpx;
  153. padding-left: 50rpx;
  154. border-radius: 44rpx;
  155. border: none;
  156. box-sizing: border-box;
  157. background-color: #fff;
  158. font-size: 16px;
  159. color: #454545;
  160. }
  161. .getCode {
  162. position: absolute;
  163. right: 50rpx;
  164. top: 30rpx;
  165. font-size: 12px;
  166. color: #454545;
  167. cursor: pointer;
  168. }
  169. }
  170. .login-btn {
  171. margin-top: 80rpx;
  172. }
  173. .login-sign {
  174. display: flex;
  175. justify-content: flex-start;
  176. margin-top: 30rpx;
  177. padding-left: 20rpx;
  178. .u-radio-group {
  179. flex-grow: 0;
  180. margin-right: 60rpx;
  181. }
  182. .log-link {
  183. height: 40rpx;
  184. line-height: 40rpx;
  185. font-size: 12px;
  186. }
  187. }
  188. }
  189. }
  190. </style>