index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <cwg-page-wrapper class="create-page" :isHeaderFixed="true">
  3. <uni-card class="create-content" :margin="0" :spacing="0">
  4. <view class="content-title">
  5. Create A New Account
  6. </view>
  7. <uni-row class="demo-uni-row">
  8. <cwg-match-media :min-width="991">
  9. </cwg-match-media>
  10. <uni-col :xs="24" :sm="24" :md="12" :lg="10" :xl="8" class="right-f">
  11. <navigator url="/pages/login/regist" class="account-tip">
  12. {{ t("signin.words") }}
  13. <text>{{ t("signin.signup") }}</text>
  14. </navigator>
  15. <cwg-match-media :min-width="791">
  16. </cwg-match-media>
  17. </uni-col>
  18. </uni-row>
  19. </uni-card>
  20. </cwg-page-wrapper>
  21. </template>
  22. <script setup>
  23. import { ref, onMounted, computed } from "vue";
  24. import QrCode from "@/components/QrCode.vue";
  25. import { post } from "@/utils/request";
  26. import { userToken } from "@/composables/config";
  27. import { userApi } from "@/api/user";
  28. import { ucardApi } from "@/api/ucard";
  29. import useUserStore from "@/stores/use-user-store";
  30. import useRouter from "@/hooks/useRouter";
  31. import { useI18n } from "vue-i18n";
  32. import logoImage from "/static/images/logo3.png";
  33. const router = useRouter();
  34. const { t } = useI18n();
  35. const userStore = useUserStore();
  36. // 响应式表单数据
  37. const form = ref({
  38. loginName: "",
  39. password: "",
  40. });
  41. function submit() {
  42. if (!form.value.loginName) {
  43. uni.$u.toast(t("signin.form.email"));
  44. return;
  45. }
  46. if (!form.value.password) {
  47. uni.$u.toast(t("signin.form.password"));
  48. return;
  49. }
  50. handleLogin();
  51. }
  52. const fetchUserList = (params) => post("/Login/AcctLogin", params);
  53. async function handleLogin() {
  54. try {
  55. const res = await userApi.login({
  56. loginName: form.value.loginName,
  57. password: form.value.password,
  58. });
  59. if (res.code === 200) {
  60. userToken.value = res.data;
  61. uni.$u.toast(t("login.msg0_1"));
  62. getUserInfo();
  63. reasonsRefusalList();
  64. if (remenber.value.length) {
  65. userStore.saveAccountInfo({
  66. loginName: form.value.loginName,
  67. password: form.value.password,
  68. rememberPassword: true,
  69. });
  70. } else {
  71. userStore.saveAccountInfo({
  72. loginName: "",
  73. password: "",
  74. rememberPassword: false,
  75. });
  76. }
  77. // console.log(1111);
  78. } else {
  79. // console.log(12112);
  80. }
  81. } catch (error) {
  82. // console.log(error, 19089);
  83. }
  84. }
  85. async function getUserInfo() {
  86. try {
  87. const res = await ucardApi.getSingle();
  88. userStore.saveUserInfo(res.data);
  89. if (res.code === 200) {
  90. if (!res.data || res.data.approveStatus != 2) {
  91. router.push("/pages/mine/improve");
  92. } else {
  93. router.push("/pages/card/index");
  94. }
  95. } else {
  96. uni.$u.toast(res.msg || t("login.msg0"));
  97. }
  98. } catch (error) {
  99. // console.log(error, 111);
  100. }
  101. }
  102. async function reasonsRefusalList() {
  103. try {
  104. const res = await ucardApi.reasonsRefusalList();
  105. if (res.code === 200) {
  106. pickFields(res.data);
  107. } else {
  108. uni.$u.toast(res.msg || t("login.msg0"));
  109. }
  110. } catch (error) {
  111. // console.log(error, 111);
  112. }
  113. }
  114. function pickFields(source, fields = ['content', 'enContent']) {
  115. const result = {}
  116. Object.entries(source).forEach(([key, value]) => {
  117. result[key] = fields.reduce((acc, f) => {
  118. acc[f] = value[f] ?? null
  119. return acc
  120. }, {})
  121. })
  122. userStore.saveReasonsOptions(result);
  123. }
  124. onMounted(() => {
  125. const accountInfo = userStore.accountInfo;
  126. if (accountInfo?.rememberPassword) {
  127. form.value.loginName = accountInfo?.loginName || "";
  128. form.value.password = accountInfo?.password || "";
  129. remenber.value = ["记住我"];
  130. } else {
  131. form.value.loginName = "";
  132. form.value.password = "";
  133. remenber.value = [];
  134. }
  135. });
  136. const inputType = ref("password");
  137. </script>
  138. <style lang="scss" scoped>
  139. @import "@/uni.scss";
  140. .create-page {
  141. height: 100vh;
  142. border: none;
  143. padding: 0;
  144. }
  145. .create-content{
  146. margin: 0;
  147. }
  148. .demo-uni-row {
  149. margin: 0 !important;
  150. .left-bg {
  151. height: calc(100vh - 60px);
  152. background-image: url(/static/images/login-bg.gif);
  153. background-repeat: no-repeat;
  154. background-size: cover;
  155. background-position: center center;
  156. .left-box {
  157. display: flex;
  158. flex-direction: column;
  159. justify-content: center;
  160. align-items: center;
  161. .h1 {
  162. // text-align: center;
  163. line-height: 20px;
  164. color: #fff;
  165. font-size: 30px;
  166. margin-top: 30px;
  167. font-size: 700;
  168. line-height: 1.5;
  169. }
  170. .h6 {
  171. text-align: start;
  172. line-height: 20px;
  173. color: #fff;
  174. font-size: 14px;
  175. margin-top: 10px;
  176. }
  177. .company {
  178. padding: px2rpx(40) 0 px2rpx(50) 0;
  179. position: relative;
  180. align-items: flex-start !important;
  181. }
  182. }
  183. .left-content {
  184. .h1 {
  185. // text-align: center;
  186. line-height: 20px;
  187. color: #fff;
  188. font-size: 30px;
  189. margin-top: 30px;
  190. font-size: 700;
  191. line-height: 1.5;
  192. }
  193. .h6 {
  194. line-height: 20px;
  195. color: #fff;
  196. font-size: 14px;
  197. margin-top: 10px;
  198. }
  199. }
  200. }
  201. .right-f {
  202. background-color: #fff;
  203. padding: 0 px2rpx(24);
  204. box-sizing: border-box;
  205. .account {
  206. background-color: #ffffff;
  207. position: relative;
  208. height: calc(100vh - 60px);
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. padding: 0 10%;
  213. .company {
  214. padding: px2rpx(50) 0 px2rpx(20) 0;
  215. position: relative;
  216. align-items: center !important;
  217. }
  218. .company-icon {
  219. width: px2rpx(234);
  220. }
  221. }
  222. }
  223. }
  224. .bottom-box {
  225. width: 100%;
  226. height: 60px;
  227. background-color: #fff;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. color: #000;
  232. .bottom-title {
  233. text-align: center;
  234. font-size: px2rpx(14);
  235. font-weight: 500;
  236. line-height: 1.5;
  237. color: #666666;
  238. }
  239. .ellipsis {
  240. width: px2rpx(200);
  241. white-space: nowrap;
  242. overflow: hidden;
  243. text-overflow: ellipsis;
  244. }
  245. .cwg-button {
  246. width: 120px !important;
  247. padding: px2rpx(4) 0 !important;
  248. }
  249. }
  250. button {
  251. background-color: #ea002a;
  252. font-size: px2rpx(14);
  253. font-weight: normal;
  254. height: px2rpx(44);
  255. line-height: px2rpx(44);
  256. }
  257. .company {
  258. padding: px2rpx(50) 0 px2rpx(200) 0;
  259. position: relative;
  260. align-items: flex-start !important;
  261. }
  262. .logo {
  263. margin-left: px2rpx(48);
  264. }
  265. .title {
  266. margin: px2rpx(32) 0;
  267. font-size: px2rpx(24);
  268. font-weight: bolder;
  269. color: #e4e4e4;
  270. text-align: center;
  271. i {
  272. margin-right: px2rpx(10);
  273. }
  274. .tit1 {
  275. font-size: px2rpx(34);
  276. line-height: 1.5;
  277. font-weight: bold;
  278. color: #000000;
  279. }
  280. .tit2 {
  281. font-size: px2rpx(16);
  282. line-height: 1.5;
  283. color: #cecece;
  284. font-weight: 500;
  285. }
  286. }
  287. .qr-title {
  288. font-size: px2rpx(16);
  289. line-height: 1.5;
  290. color: #cecece;
  291. font-weight: 500;
  292. text-align: center;
  293. margin: px2rpx(40) 0;
  294. display: flex;
  295. align-items: center;
  296. justify-content: center;
  297. .line {
  298. flex: 1;
  299. height: 1px;
  300. background-color: #e4e4e4;
  301. }
  302. .qr-tit2 {
  303. margin: 0 px2rpx(12);
  304. }
  305. }
  306. .input {
  307. height: px2rpx(44);
  308. border-radius: px2rpx(8);
  309. background: #f7f8fa;
  310. padding: 0 px2rpx(20) !important;
  311. position: relative;
  312. }
  313. .account-icon {
  314. width: px2rpx(12);
  315. height: px2rpx(14) !important;
  316. margin-right: px2rpx(5);
  317. }
  318. :deep(.u-input__content__prefix-icon) {
  319. height: px2rpx(20);
  320. }
  321. .regiset-btn {
  322. margin: px2rpx(20) 0;
  323. }
  324. .account-tip {
  325. color: #666666;
  326. font-size: px2rpx(14);
  327. text-align: center;
  328. text {
  329. color: #ea002a;
  330. }
  331. }
  332. :deep(.u-form-item__body) {
  333. padding: 0 !important;
  334. padding-bottom: px2rpx(24) !important;
  335. }
  336. :deep(.wcg-checkbox) {
  337. padding: 0 !important;
  338. }
  339. .cwg-button {
  340. padding: px2rpx(34) 0 !important;
  341. }
  342. </style>