index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. <template>
  2. <view class="page-box login-box">
  3. <view class="login-form sys-radius-50">
  4. <view class="from-title">
  5. <view class="title-list">
  6. <view class="title-text sys-size-28 text-center sys-weight-600" :class="{'default-text':type===1}"
  7. @click="setType(1)">验证码登录</view>
  8. <view class="title-text sys-size-28 text-center sys-weight-600" :class="{'default-text':type===2}"
  9. @click="setType(2)">密码登录</view>
  10. </view>
  11. <view class="title-bg sys-background-fff" :class="{'title-bg-two':type===2}">
  12. <view class="bg-icon sys-background-dominant "></view>
  13. </view>
  14. </view>
  15. <view class="from-box sys-background-fff " :class="{'one-from':type===1,'two-from':type===2}">
  16. <view class="from-animation animate__animated animate__fadeIn" v-if="type===1">
  17. <view class="input-item sys-from-background-color sys-radius-30 "
  18. :class="{'apply-shake':phoneShake}">
  19. <en-input type="number" class="login-input" placeholder="请输入手机号" v-model="loginData.phone"
  20. maxlength="11"></en-input>
  21. </view>
  22. <view class="input-item input-send sys-from-background-color sys-radius-30"
  23. :class="{'apply-shake':codedShake}">
  24. <en-input type="number" class="login-input" placeholder="请输入验证码" v-model="loginData.code"
  25. maxlength="6"></en-input>
  26. <view class="login-send text-color-dominant sys-size-28 sys-weight-400" v-if="timeNum<=0">发送验证码</view>
  27. <view class="login-send text-color-dominant sys-size-28 sys-weight-400" v-else>{{ timeNum }} s
  28. </view>
  29. </view>
  30. </view>
  31. <view class="from-animation animate__animated animate__fadeIn" v-else>
  32. <view class="input-item sys-from-background-color sys-radius-30 "
  33. :class="{'apply-shake':phoneShake}">
  34. <en-input type="number" class="login-input" placeholder="请输入手机号" v-model="loginData.phone"
  35. maxlength="11"></en-input>
  36. </view>
  37. <view class="input-item input-send sys-from-background-color sys-radius-30"
  38. :class="{'apply-shake':passwordShake}">
  39. <en-input type="password" class="login-input" placeholder="请输入密码"
  40. v-model="loginData.password"></en-input>
  41. <view class="login-send text-color-dominant sys-size-28 sys-weight-400" @click="goToUrl(2)">
  42. 忘记密码?</view>
  43. </view>
  44. </view>
  45. <agreement v-model="isConsent" ref="agreement"></agreement>
  46. <view class="input-but sys-background-dominant text-color-fff sys-size-30 sys-radius-100 sys-weight-600"
  47. :class="{'sys-selected-but':isLogin,'sys-unselected-but':!isLogin}" @click="login">登陆</view>
  48. </view>
  49. </view>
  50. <view class="register-box">
  51. <view class="register-text sys-weight-400 sys-size-24 text-color-666">还没有账号?</view>
  52. <view class="register-text text-color-dominant sys-size-24 sys-weight-400" @click="goToUrl(1)">立即注册</view>
  53. </view>
  54. <view class="wx-box">
  55. <view class="wx-title">
  56. <view class="wx-wire"></view>
  57. <view class="wx-text sys-size-24 text-color-7c sys-weight-400">第三方登录</view>
  58. <view class="wx-wire"></view>
  59. </view>
  60. <image class="wx-logo"
  61. src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/login/wx-img.png"
  62. mode="aspectFill"></image>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import tools from "@/service/tools";
  68. import EnInput from "@/components/en-from/en-input/index.vue";
  69. import Agreement from "@/pages/login/model/agreement.vue";
  70. export default {
  71. components: {
  72. Agreement,
  73. EnInput
  74. },
  75. data() {
  76. return {
  77. type: 1,
  78. loginData: {
  79. phone: '',
  80. password: '',
  81. code: '',
  82. },
  83. phoneShake: false,
  84. passwordShake: false,
  85. codedShake: false,
  86. consentShake: false,
  87. isConsent: false,
  88. isLogin: false,
  89. timeNum: 0,
  90. timer: null,
  91. }
  92. },
  93. watch: {
  94. 'loginData': {
  95. handler() {
  96. this.verifyData()
  97. },
  98. deep: true
  99. },
  100. 'isConsent': function() {
  101. this.verifyData()
  102. }
  103. },
  104. mounted() {},
  105. methods: {
  106. wxLogin() {
  107. if (this.isAjax) {
  108. return false;
  109. }
  110. this.isAjax = true;
  111. setTimeout(() => {
  112. //跳转至注册页面
  113. uni.navigateTo({
  114. url: '/pages/login/register'
  115. });
  116. }, 1500)
  117. },
  118. goToUrl(type) {
  119. if (type === 1) {
  120. uni.navigateTo({
  121. 'url': '/pages/login/register'
  122. })
  123. } else if (type === 2) {
  124. uni.navigateTo({
  125. 'url': '/pages/login/forget'
  126. })
  127. } else {
  128. }
  129. },
  130. setShake(type) {
  131. if (type === 1) {
  132. this.phoneShake = true
  133. } else if (type === 2) {
  134. this.passwordShake = true
  135. } else if (type === 3) {
  136. this.codedShake = true
  137. } else if (type === 4) {
  138. this.$refs.agreement.setConsentShake()
  139. }
  140. setTimeout(() => {
  141. this.phoneShake = false
  142. this.passwordShake = false
  143. this.codedShake = false
  144. }, 500)
  145. },
  146. login() {
  147. if (this.loginData.phone === '') {
  148. tools.error('请输入手机号码');
  149. this.setShake(1)
  150. return;
  151. }
  152. if (this.type !== 1) {
  153. if (this.loginData.password === '') {
  154. this.setShake(2)
  155. tools.error('请输入登陆密码');
  156. return;
  157. }
  158. } else {
  159. if (this.loginData.code === '') {
  160. this.setShake(3)
  161. tools.error('请输入验证码');
  162. return;
  163. }
  164. }
  165. if (!this.isConsent) {
  166. this.setShake(4)
  167. tools.error('请阅读并同意协议');
  168. return;
  169. }
  170. this.loginData.tabType = this.type === 1 ? 1 : 0
  171. uni.reLaunch({
  172. url: '/pages/loan/loan'
  173. });
  174. },
  175. verifyData() {
  176. if (this.type === 1) {
  177. this.isLogin = this.loginData.phone !== '' && this.loginData.code !== '' && this.isConsent
  178. } else {
  179. this.isLogin = this.loginData.phone !== '' && this.loginData.password !== '' && this.isConsent
  180. }
  181. },
  182. setIsConsent() {
  183. this.isConsent = !this.isConsent
  184. },
  185. setType(type) {
  186. if (type !== this.type) {
  187. this.type = type
  188. }
  189. },
  190. },
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. @import "/static/css/login.css";
  195. .page-box {
  196. position: relative;
  197. padding-top: 370rpx;
  198. .login-form {
  199. margin: 0 30rpx;
  200. border-radius: 50rpx;
  201. background-color: rgba(255, 255, 255, 0.5);
  202. .from-title {
  203. border-radius: 50rpx 50rpx 0 0;
  204. height: 110rpx;
  205. position: relative;
  206. .title-bg {
  207. position: absolute;
  208. border-radius: 50rpx 50rpx 0 0;
  209. top: 0;
  210. left: 0;
  211. height: 110rpx;
  212. width: 50%;
  213. transition: .5s ease;
  214. z-index: 0;
  215. .bg-icon {
  216. margin: 86rpx auto 0 auto;
  217. width: 36rpx;
  218. height: 6rpx;
  219. border-radius: 99rpx;
  220. }
  221. }
  222. .title-bg-two {
  223. left: 50%;
  224. transition: .5s ease;
  225. }
  226. //.title-bg::after {
  227. // content: '';
  228. // position: absolute;
  229. // right: -50rpx;
  230. // bottom: 0;
  231. // width: 50rpx;
  232. // height:50rpx;
  233. // background-color: #fff;
  234. // border-radius: 50rpx 50rpx 50rpx 0;
  235. //}
  236. .title-list {
  237. display: flex;
  238. justify-content: space-between;
  239. z-index: 1;
  240. position: relative;
  241. .title-text {
  242. width: 50%;
  243. height: 110rpx;
  244. line-height: 102rpx;
  245. color: #333333;
  246. }
  247. .default-text {
  248. color: #10B261;
  249. }
  250. .title-text:first-child {
  251. background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/login/right.png");
  252. background-repeat: no-repeat;
  253. background-position: right bottom;
  254. }
  255. .title-text:last-child {
  256. background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/new-xcx/login/left.png");
  257. background-repeat: no-repeat;
  258. background-position: left bottom;
  259. }
  260. }
  261. }
  262. .from-box {
  263. box-shadow: 0rpx 4rpx 36rpx 0rpx rgba(196, 196, 196, 0.25);
  264. border-radius: 0 0 50rpx 50rpx;
  265. padding: 50rpx 45rpx;
  266. .input-item {
  267. height: 96rpx;
  268. padding: 28rpx 40rpx;
  269. box-sizing: border-box;
  270. .login-input {
  271. width: 100%;
  272. border: none;
  273. }
  274. }
  275. .input-item:last-child {
  276. margin-top: 30rpx;
  277. }
  278. .input-send {
  279. display: flex;
  280. justify-content: flex-start;
  281. align-items: center;
  282. .login-input {
  283. width: calc(100% - 140rpx);
  284. border: none;
  285. }
  286. .login-send {
  287. width: 140rpx;
  288. text-align: center;
  289. }
  290. }
  291. .input-but {
  292. margin-top: 40rpx;
  293. width: 100%;
  294. height: 96rpx;
  295. line-height: 96rpx;
  296. text-align: center;
  297. }
  298. }
  299. .one-from {
  300. border-radius: 0 50rpx 50rpx 50rpx;
  301. transition: 0.85s ease;
  302. }
  303. .two-from {
  304. border-radius: 50rpx 0 50rpx 50rpx;
  305. transition: 0.85s ease;
  306. }
  307. }
  308. .register-box {
  309. display: flex;
  310. justify-content: center;
  311. align-items: center;
  312. margin-top: 60rpx;
  313. .register-text {
  314. height: 34rpx;
  315. line-height: 34rpx;
  316. }
  317. .register-text:last-child {
  318. margin-right: 5rpx;
  319. }
  320. }
  321. .wx-box {
  322. position: absolute;
  323. bottom: calc(60rpx + env(safe-area-inset-bottom));
  324. left: 0;
  325. width: 100%;
  326. display: flex;
  327. flex-direction: column;
  328. justify-content: center;
  329. .wx-title {
  330. display: flex;
  331. justify-content: center;
  332. align-items: center;
  333. .wx-wire {
  334. background: linear-gradient(90deg, #D9D9D9 0%, rgba(115, 115, 115, 0) 100%);
  335. width: 174rpx;
  336. height: 2rpx;
  337. border-radius: 50%;
  338. }
  339. .wx-text {
  340. margin: 0 15rpx;
  341. height: 34rpx;
  342. line-height: 34rpx;
  343. }
  344. }
  345. .wx-logo {
  346. margin: 25rpx auto 0 auto;
  347. width: 80rpx;
  348. height: 80rpx;
  349. }
  350. }
  351. }
  352. ::v-deep .en-input {
  353. border: none;
  354. font-size: 14px
  355. }
  356. </style>