index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <script setup>
  2. import { ref, onMounted, computed } from "vue";
  3. import QrCode from "@/components/QrCode.vue";
  4. import { post } from "@/utils/request";
  5. import { userToken } from "@/composables/config";
  6. import { userApi } from "@/api/user";
  7. import { ucardApi } from "@/api/ucard";
  8. import { customApi } from "@/service/custom";
  9. import useUserStore from "@/stores/use-user-store";
  10. import useRouter from "@/hooks/useRouter";
  11. import { useI18n } from "vue-i18n";
  12. import logoImage from "/static/images/logo3.png";
  13. const router = useRouter();
  14. const { t } = useI18n();
  15. const userStore = useUserStore();
  16. // 响应式表单数据
  17. const form = ref({
  18. loginName: "",
  19. password: "",
  20. });
  21. function submit() {
  22. if (!form.value.loginName) {
  23. uni.$u.toast(t("signin.form.email"));
  24. return;
  25. }
  26. if (!form.value.password) {
  27. uni.$u.toast(t("signin.form.password"));
  28. return;
  29. }
  30. handleLogin();
  31. }
  32. const customStyle = {
  33. height: "44px",
  34. "border-radius": "8px",
  35. background: "#f7f8fa",
  36. padding: "0 20px !important",
  37. position: "relative",
  38. };
  39. const remenber = ref([]);
  40. const checkboxChange = (e) => {
  41. remenber.value = e;
  42. };
  43. const fetchUserList = (params) => post("/Login/AcctLogin", params);
  44. async function handleLogin() {
  45. try {
  46. const res = await userApi.login({
  47. loginName: form.value.loginName,
  48. password: form.value.password,
  49. });
  50. if (res.code === 200) {
  51. userToken.value = res.data;
  52. uni.$u.toast(t("login.msg0_1"));
  53. getCustomLoginInfo();
  54. // getCardUserInfo();
  55. reasonsRefusalList();
  56. if (remenber.value.length) {
  57. userStore.saveAccountInfo({
  58. loginName: form.value.loginName,
  59. password: form.value.password,
  60. rememberPassword: true,
  61. });
  62. } else {
  63. userStore.saveAccountInfo({
  64. loginName: "",
  65. password: "",
  66. rememberPassword: false,
  67. });
  68. }
  69. // console.log(1111);
  70. } else {
  71. // console.log(12112);
  72. }
  73. } catch (error) {
  74. // console.log(error, 19089);
  75. }
  76. }
  77. async function getCustomLoginInfo() {
  78. try {
  79. const res = await userApi.getUserInfo();
  80. userStore.saveUserInfo(res.data);
  81. if (res.code === 200) {
  82. router.push("/pages/customer/index");
  83. } else {
  84. uni.$u.toast(res.msg || t("login.msg0"));
  85. }
  86. } catch (error) {
  87. // console.log(error, 111);
  88. }
  89. }
  90. async function getCardUserInfo() {
  91. try {
  92. const res = await ucardApi.getSingle();
  93. userStore.saveUserInfo(res.data);
  94. if (res.code === 200) {
  95. if (!res.data || res.data.approveStatus != 2) {
  96. router.push("/pages/mine/improve");
  97. } else {
  98. router.push("/pages/card/index");
  99. }
  100. } else {
  101. uni.$u.toast(res.msg || t("login.msg0"));
  102. }
  103. } catch (error) {
  104. // console.log(error, 111);
  105. }
  106. }
  107. async function reasonsRefusalList() {
  108. try {
  109. const res = await customApi.reasonsRefusalList();
  110. if (res.code === 200) {
  111. pickFields(res.data);
  112. } else {
  113. uni.$u.toast(res.msg || t("login.msg0"));
  114. }
  115. } catch (error) {
  116. // console.log(error, 111);
  117. }
  118. }
  119. function pickFields(source, fields = ['content', 'enContent']) {
  120. const result = {}
  121. Object.entries(source).forEach(([key, value]) => {
  122. result[key] = fields.reduce((acc, f) => {
  123. acc[f] = value[f] ?? null
  124. return acc
  125. }, {})
  126. })
  127. userStore.saveReasonsOptions(result);
  128. }
  129. onMounted(() => {
  130. const accountInfo = userStore.accountInfo;
  131. if (accountInfo?.rememberPassword) {
  132. form.value.loginName = accountInfo?.loginName || "";
  133. form.value.password = accountInfo?.password || "";
  134. remenber.value = ["记住我"];
  135. } else {
  136. form.value.loginName = "";
  137. form.value.password = "";
  138. remenber.value = [];
  139. }
  140. });
  141. const inputType = ref("password");
  142. </script>
  143. <template>
  144. <view class="login-page" :isHeaderFixed="true" :isLoginPage="true">
  145. <uni-row class="demo-uni-row">
  146. <cwg-match-media :min-width="991">
  147. <uni-col :xs="24" :sm="24" :md="12" :lg="14" :xl="16" class="left-bg">
  148. <view class="company logo u-flex-y u-flex-y-center">
  149. <image src="/static/images/logo4.png" class="company-icon" mode="widthFix"></image>
  150. </view>
  151. <view class="left-box">
  152. <view class="left-content">
  153. <view class="h1">
  154. <text>{{ t('newLoop.item12') }}</text>
  155. <br />
  156. <text class="color-white">{{ t('newLoop.item13') }}</text>
  157. </view>
  158. <view class="h6 text-white">{{ t('newLoop.item14') }}</view>
  159. <view class="company u-flex-y u-flex-y-center">
  160. <image src="/static/images/trust-pilot.png" class="company-icon" mode="widthFix"></image>
  161. </view>
  162. </view>
  163. </view>
  164. </uni-col>
  165. </cwg-match-media>
  166. <uni-col :xs="24" :sm="24" :md="12" :lg="10" :xl="8" class="right-f">
  167. <view class="account">
  168. <cwg-match-media :max-width="991">
  169. <view class="company u-flex-y u-flex-y-center">
  170. <image src="/static/images/logo.png" class="company-icon" mode="widthFix"></image>
  171. </view>
  172. </cwg-match-media>
  173. <view class="title">
  174. <view class="tit1">{{ t('newSignin.item1') }}</view>
  175. <view class="tit2">{{ t('newSignin.item2') }}</view>
  176. </view>
  177. <view>
  178. <up-form :model="form" ref="uFormRef">
  179. <up-form-item label="" prop="loginName">
  180. <up-input :customStyle="customStyle" v-model="form.loginName" border="none"
  181. :placeholder="t('signin.form.email')">
  182. <template #prefix>
  183. <cwg-icon name="email-outline" :size="20" color="#000" />
  184. </template>
  185. </up-input>
  186. </up-form-item>
  187. <up-form-item label="" prop="password">
  188. <up-input :customStyle="customStyle" v-model="form.password" :type="inputType" border="none"
  189. :placeholder="t('signin.form.password')">
  190. <template #prefix>
  191. <cwg-icon name="lock-outline" :size="20" color="#000" />
  192. </template>
  193. </up-input>
  194. </up-form-item>
  195. </up-form>
  196. </view>
  197. <view class="u-flex u-flex-between u-flex-y-center mb1">
  198. <view class="check-box">
  199. <up-checkbox-group v-model="remenber" @change="checkboxChange">
  200. <up-checkbox size="14" labelSize="14" labelColor="#666666" activeColor="#ea002a"
  201. :label="t('newSignin.item5')" name="记住我" class="wcg-checkbox"></up-checkbox>
  202. </up-checkbox-group>
  203. </view>
  204. <navigator url="/pages/login/reset" class="account-tip">
  205. <text>{{ t("signin.forget") }}</text>
  206. </navigator>
  207. </view>
  208. <view class="cwg-button">
  209. <u-button type="primary" class="" @click="submit">
  210. {{ t("signin.login") }}
  211. </u-button>
  212. </view>
  213. <navigator url="/pages/login/regist" class="account-tip">
  214. {{ t("signin.words") }}
  215. <text>{{ t("signin.signup") }}</text>
  216. </navigator>
  217. <cwg-match-media :min-width="791">
  218. <view class="qr-container">
  219. <view class="qr-title">
  220. <view class="line"></view>
  221. <view class="qr-tit2">{{ t('newSignin.item2') }}</view>
  222. <view class="line"></view>
  223. </view>
  224. <QrCode width="200" height="200" text="cardGuide" :logo="logoImage"></QrCode>
  225. </view>
  226. </cwg-match-media>
  227. </view>
  228. </uni-col>
  229. </uni-row>
  230. <view class="bottom-box">
  231. <cwg-match-media :max-width="791">
  232. <view class="bottom-title ellipsis">{{ t('newSignin.item12') }}</view>
  233. </cwg-match-media>
  234. <cwg-match-media :min-width="791">
  235. <view class="bottom-title">{{ t('newSignin.item12') }}</view>
  236. </cwg-match-media>
  237. <view class="cwg-button">
  238. <u-button type="primary" class="" @click="">
  239. {{ t("News.More") }}
  240. </u-button>
  241. </view>
  242. </view>
  243. </view>
  244. </template>
  245. <style lang="scss" scoped>
  246. @import "@/uni.scss";
  247. :deep(uni-content) {
  248. padding-left: 0 !important;
  249. }
  250. .login-page {
  251. height: 100vh;
  252. border: none;
  253. padding: 0;
  254. }
  255. .demo-uni-row {
  256. margin: 0 !important;
  257. .left-bg {
  258. height: calc(100vh - 60px);
  259. background-image: url(/static/images/login-bg.gif);
  260. background-repeat: no-repeat;
  261. background-size: cover;
  262. background-position: center center;
  263. .left-box {
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: center;
  267. align-items: center;
  268. .h1 {
  269. // text-align: center;
  270. line-height: 20px;
  271. color: #fff;
  272. font-size: 30px;
  273. margin-top: 30px;
  274. font-size: 700;
  275. line-height: 1.5;
  276. }
  277. .h6 {
  278. text-align: start;
  279. line-height: 20px;
  280. color: #fff;
  281. font-size: 14px;
  282. margin-top: 10px;
  283. }
  284. .company {
  285. padding: px2rpx(40) 0 px2rpx(50) 0;
  286. position: relative;
  287. align-items: flex-start !important;
  288. }
  289. }
  290. .left-content {
  291. .h1 {
  292. // text-align: center;
  293. line-height: 20px;
  294. color: #fff;
  295. font-size: 30px;
  296. margin-top: 30px;
  297. font-size: 700;
  298. line-height: 1.5;
  299. }
  300. .h6 {
  301. line-height: 20px;
  302. color: #fff;
  303. font-size: 14px;
  304. margin-top: 10px;
  305. }
  306. }
  307. }
  308. .right-f {
  309. background-color: var(--color-white);
  310. padding: 0 px2rpx(24);
  311. box-sizing: border-box;
  312. .account {
  313. background-color: var(--color-white);
  314. position: relative;
  315. height: calc(100vh - 60px);
  316. display: flex;
  317. flex-direction: column;
  318. justify-content: center;
  319. padding: 0 10%;
  320. .company {
  321. padding: px2rpx(50) 0 px2rpx(20) 0;
  322. position: relative;
  323. align-items: center !important;
  324. }
  325. .company-icon {
  326. width: px2rpx(234);
  327. }
  328. }
  329. }
  330. }
  331. .bottom-box {
  332. width: 100%;
  333. height: 60px;
  334. background-color: var(--color-white);
  335. display: flex;
  336. justify-content: center;
  337. align-items: center;
  338. color: #000;
  339. .bottom-title {
  340. text-align: center;
  341. font-size: px2rpx(14);
  342. font-weight: 500;
  343. line-height: 1.5;
  344. color: #666666;
  345. }
  346. .ellipsis {
  347. width: px2rpx(200);
  348. white-space: nowrap;
  349. overflow: hidden;
  350. text-overflow: ellipsis;
  351. }
  352. .cwg-button {
  353. width: 120px !important;
  354. padding: px2rpx(4) 0 !important;
  355. }
  356. }
  357. button {
  358. background-color: #ea002a;
  359. font-size: px2rpx(14);
  360. font-weight: normal;
  361. height: px2rpx(44);
  362. line-height: px2rpx(44);
  363. }
  364. .company {
  365. padding: px2rpx(50) 0 px2rpx(200) 0;
  366. position: relative;
  367. align-items: flex-start !important;
  368. }
  369. .logo {
  370. margin-left: px2rpx(48);
  371. }
  372. .title {
  373. margin: px2rpx(32) 0;
  374. font-size: px2rpx(24);
  375. font-weight: bolder;
  376. color: #e4e4e4;
  377. text-align: center;
  378. i {
  379. margin-right: px2rpx(10);
  380. }
  381. .tit1 {
  382. font-size: px2rpx(34);
  383. line-height: 1.5;
  384. font-weight: bold;
  385. color: #000000;
  386. }
  387. .tit2 {
  388. font-size: px2rpx(16);
  389. line-height: 1.5;
  390. color: #cecece;
  391. font-weight: 500;
  392. }
  393. }
  394. .qr-title {
  395. font-size: px2rpx(16);
  396. line-height: 1.5;
  397. color: #cecece;
  398. font-weight: 500;
  399. text-align: center;
  400. margin: px2rpx(40) 0;
  401. display: flex;
  402. align-items: center;
  403. justify-content: center;
  404. .line {
  405. flex: 1;
  406. height: 1px;
  407. background-color: #e4e4e4;
  408. }
  409. .qr-tit2 {
  410. margin: 0 px2rpx(12);
  411. }
  412. }
  413. .input {
  414. height: px2rpx(44);
  415. border-radius: px2rpx(8);
  416. background: #f7f8fa;
  417. padding: 0 px2rpx(20) !important;
  418. position: relative;
  419. }
  420. .account-icon {
  421. width: px2rpx(12);
  422. height: px2rpx(14) !important;
  423. margin-right: px2rpx(5);
  424. }
  425. :deep(.u-input__content__prefix-icon) {
  426. height: px2rpx(20);
  427. }
  428. .regiset-btn {
  429. margin: px2rpx(20) 0;
  430. }
  431. .account-tip {
  432. color: #666666;
  433. font-size: px2rpx(14);
  434. text-align: center;
  435. text {
  436. color: #ea002a;
  437. }
  438. }
  439. :deep(.u-form-item__body) {
  440. padding: 0 !important;
  441. padding-bottom: px2rpx(24) !important;
  442. }
  443. :deep(.wcg-checkbox) {
  444. padding: 0 !important;
  445. }
  446. .cwg-button {
  447. padding: px2rpx(34) 0 !important;
  448. }
  449. </style>