login.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view class="login-page">
  3. <view class="title">
  4. <view>欢迎使用WORKARK</view>
  5. </view>
  6. <view class="form-box">
  7. <view class="form-tab">
  8. <view :class="loginType == 1 ? 'tab-item select type1' : 'tab-item type1'" @click="loginType=1">
  9. 验证码登录
  10. </view>
  11. <view :class="loginType == 2 ? 'tab-item select type2' : 'tab-item type2'" @click="loginType=2">
  12. 账号密码登陆
  13. </view>
  14. </view>
  15. <view class="form-input">
  16. <view class="input-box">
  17. <view class="account">
  18. <input class="input-inner" type="number" v-model="account" :adjust-position="false"
  19. placeholder="手机号" />
  20. </view>
  21. <view class="password" v-if="loginType==2">
  22. <input class="input-inner" :type="pwdShow? 'text' : 'password'" v-model="password"
  23. :adjust-position="false" placeholder="密码" />
  24. <uv-icon :name="pwdShow? 'eye-fill' : 'eye-off'" size="50rpx" color="#cccccc"
  25. @click="pwdShow=!pwdShow">
  26. </uv-icon>
  27. </view>
  28. <view class="vcode" v-if="loginType==1">
  29. <input class="input-inner" type="number" v-model="vcode" :adjust-position="false"
  30. placeholder="验证码" />
  31. <uv-button type="primary" :text="codeTips" @click="getCode" size="small"
  32. :disabled="codeDisabled">
  33. </uv-button>
  34. </view>
  35. </view>
  36. <view class="button">
  37. <view class="button-item" @click="login">
  38. 登录
  39. </view>
  40. </view>
  41. <uv-code ref="code" :seconds="seconds" @end="codeDisabled = false" @start="codeDisabled = true"
  42. @change="text => codeTips = text">
  43. </uv-code>
  44. </view>
  45. </view>
  46. <view class="pact">
  47. <uv-checkbox-group v-model="pactChecked" shape="circle" placement="column" customStyle="maxWidth:208rpx;"
  48. labelSize="24rpx">
  49. <uv-checkbox name="apple" label="我已阅读并同意"></uv-checkbox>
  50. </uv-checkbox-group>
  51. <uv-text text="《用户协议》" size="24rpx" type="primary" @click="toPact"></uv-text>
  52. <uv-text text="和" size="24rpx"></uv-text>
  53. <uv-text text="《隐私协议》" size="24rpx" type="primary" @click="toPact"></uv-text>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. account: "",
  62. password: "",
  63. vcode: "",
  64. loginType: 1,
  65. pwdShow: false,
  66. pactChecked: false,
  67. vcodeTime: 0,
  68. vcodeTimer: null,
  69. codeTips: '',
  70. seconds: 60,
  71. codeDisabled: false
  72. }
  73. },
  74. onLoad() {
  75. },
  76. methods: {
  77. getCode() {
  78. if (this.$refs.code.canGetCode) {
  79. // 模拟向后端请求验证码
  80. uni.showLoading({
  81. title: '正在获取验证码'
  82. })
  83. setTimeout(() => {
  84. uni.hideLoading();
  85. // 这里此提示会被this.start()方法中的提示覆盖
  86. this.$toast('验证码已发送');
  87. // 通知验证码组件内部开始倒计时
  88. this.$refs.code.start();
  89. }, 2000);
  90. }
  91. },
  92. login() {
  93. uni.showToast({
  94. title: "登录方式" + this.loginType,
  95. icon: 'none'
  96. })
  97. },
  98. getVcode() {},
  99. pactChange() {
  100. this.pactChecked = !this.pactChecked
  101. },
  102. toPact() {
  103. uni.showToast({
  104. title: "协议",
  105. icon: 'none'
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style lang="scss" scoped>
  112. .login-page {
  113. min-height: 100vh;
  114. background: url("https://images.unsplash.com/photo-1519751138087-5bf79df62d5b?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wyMDUzMDJ8MHwxfHNlYXJjaHwyMHx8YmFja2dyb3VuZHxlbnwxfHx8fDE3MjExOTc4NjJ8MA&ixlib=rb-4.0.3&q=80&w=1080") no-repeat top center;
  115. background-size: 100%;
  116. display: flex;
  117. flex-direction: column;
  118. justify-content: space-between;
  119. }
  120. .form-box {
  121. flex: 1;
  122. margin: 0 30rpx;
  123. border-radius: 40rpx;
  124. background-color: #fff;
  125. overflow: hidden;
  126. }
  127. .form-input {
  128. background-color: #fff;
  129. }
  130. .input-box {
  131. padding: 150rpx 32rpx 0;
  132. margin-bottom: 80rpx;
  133. }
  134. .account,
  135. .password,
  136. .vcode {
  137. height: 96rpx;
  138. border-radius: 20rpx;
  139. padding: 0 48rpx;
  140. display: flex;
  141. align-items: center;
  142. background-color: #f7fafc;
  143. .input-inner {
  144. flex: 1;
  145. }
  146. }
  147. .account {
  148. margin-bottom: 48rpx;
  149. }
  150. .vcode-text {
  151. text-wrap: nowrap;
  152. font-size: 26rpx;
  153. background-color: #fff;
  154. padding: 14rpx 30rpx;
  155. border-radius: 12rpx;
  156. }
  157. .button {
  158. padding: 0 32rpx;
  159. .button-item {
  160. line-height: 96rpx;
  161. border-radius: 20rpx;
  162. text-align: center;
  163. font-size: 32rpx;
  164. background-color: $uv-primary;
  165. color: #fff;
  166. }
  167. }
  168. .pact {
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. padding-top: 20rpx;
  173. padding-bottom: 120rpx;
  174. font-size: 24rpx;
  175. height: 40rpx;
  176. ::v-deep .uv-text {
  177. width: auto;
  178. flex: inherit;
  179. }
  180. }
  181. .title {
  182. padding-top: 180rpx;
  183. padding-bottom: 40rpx;
  184. padding-left: 64rpx;
  185. font-size: 48rpx;
  186. font-weight: 700;
  187. color: #383838;
  188. }
  189. .form-tab {
  190. display: flex;
  191. align-items: center;
  192. justify-content: space-between;
  193. background-color: #ecf1fb;
  194. height: 100rpx;
  195. background: linear-gradient(180deg, #e3ebf9 0%, #ffffff 100%);
  196. .tab-item {
  197. width: 340rpx;
  198. line-height: 100rpx;
  199. text-align: center;
  200. color: #9e9e9e;
  201. position: relative;
  202. &::after {
  203. content: '';
  204. width: 50rpx;
  205. height: 8rpx;
  206. display: block;
  207. background-color: $uv-primary;
  208. border-radius: 4rpx;
  209. position: absolute;
  210. left: 50%;
  211. bottom: 14rpx;
  212. transform: translateX(-50%);
  213. opacity: 0;
  214. }
  215. &.select {
  216. background-color: #fff;
  217. color: $uv-primary;
  218. }
  219. &.type1.select {
  220. border-radius: 0 40rpx 0 0;
  221. }
  222. &.type2.select {
  223. border-radius: 40rpx 0 0;
  224. }
  225. &.select::after {
  226. opacity: 1;
  227. }
  228. }
  229. }
  230. </style>