index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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. }
  93. } else {
  94. uni.$u.toast(res.msg || t("login.msg0"));
  95. }
  96. } catch (error) {
  97. // console.log(error, 111);
  98. }
  99. }
  100. async function reasonsRefusalList() {
  101. try {
  102. const res = await ucardApi.reasonsRefusalList();
  103. if (res.code === 200) {
  104. pickFields(res.data);
  105. } else {
  106. uni.$u.toast(res.msg || t("login.msg0"));
  107. }
  108. } catch (error) {
  109. // console.log(error, 111);
  110. }
  111. }
  112. function pickFields(source, fields = ['content', 'enContent']) {
  113. const result = {}
  114. Object.entries(source).forEach(([key, value]) => {
  115. result[key] = fields.reduce((acc, f) => {
  116. acc[f] = value[f] ?? null
  117. return acc
  118. }, {})
  119. })
  120. userStore.saveReasonsOptions(result);
  121. }
  122. onMounted(() => {
  123. const accountInfo = userStore.accountInfo;
  124. if (accountInfo?.rememberPassword) {
  125. form.value.loginName = accountInfo?.loginName || "";
  126. form.value.password = accountInfo?.password || "";
  127. remenber.value = ["记住我"];
  128. } else {
  129. form.value.loginName = "";
  130. form.value.password = "";
  131. remenber.value = [];
  132. }
  133. });
  134. const inputType = ref("password");
  135. </script>
  136. <style lang="scss" scoped>
  137. @import "@/uni.scss";
  138. .create-page {
  139. height: 100vh;
  140. border: none;
  141. padding: 0;
  142. }
  143. .create-content{
  144. margin: 0;
  145. }
  146. .demo-uni-row {
  147. margin: 0 !important;
  148. .left-bg {
  149. height: calc(100vh - 60px);
  150. background-image: url(/static/images/login-bg.gif);
  151. background-repeat: no-repeat;
  152. background-size: cover;
  153. background-position: center center;
  154. .left-box {
  155. display: flex;
  156. flex-direction: column;
  157. justify-content: center;
  158. align-items: center;
  159. .h1 {
  160. // text-align: center;
  161. line-height: 20px;
  162. color: #fff;
  163. font-size: 30px;
  164. margin-top: 30px;
  165. font-size: 700;
  166. line-height: 1.5;
  167. }
  168. .h6 {
  169. text-align: start;
  170. line-height: 20px;
  171. color: #fff;
  172. font-size: 14px;
  173. margin-top: 10px;
  174. }
  175. .company {
  176. padding: px2rpx(40) 0 px2rpx(50) 0;
  177. position: relative;
  178. align-items: flex-start !important;
  179. }
  180. }
  181. .left-content {
  182. .h1 {
  183. // text-align: center;
  184. line-height: 20px;
  185. color: #fff;
  186. font-size: 30px;
  187. margin-top: 30px;
  188. font-size: 700;
  189. line-height: 1.5;
  190. }
  191. .h6 {
  192. line-height: 20px;
  193. color: #fff;
  194. font-size: 14px;
  195. margin-top: 10px;
  196. }
  197. }
  198. }
  199. .right-f {
  200. background-color: #fff;
  201. padding: 0 px2rpx(24);
  202. box-sizing: border-box;
  203. .account {
  204. background-color: #ffffff;
  205. position: relative;
  206. height: calc(100vh - 60px);
  207. display: flex;
  208. flex-direction: column;
  209. justify-content: center;
  210. padding: 0 10%;
  211. .company {
  212. padding: px2rpx(50) 0 px2rpx(20) 0;
  213. position: relative;
  214. align-items: center !important;
  215. }
  216. .company-icon {
  217. width: px2rpx(234);
  218. }
  219. }
  220. }
  221. }
  222. .bottom-box {
  223. width: 100%;
  224. height: 60px;
  225. background-color: #fff;
  226. display: flex;
  227. justify-content: center;
  228. align-items: center;
  229. color: #000;
  230. .bottom-title {
  231. text-align: center;
  232. font-size: px2rpx(14);
  233. font-weight: 500;
  234. line-height: 1.5;
  235. color: #666666;
  236. }
  237. .ellipsis {
  238. width: px2rpx(200);
  239. white-space: nowrap;
  240. overflow: hidden;
  241. text-overflow: ellipsis;
  242. }
  243. .cwg-button {
  244. width: 120px !important;
  245. padding: px2rpx(4) 0 !important;
  246. }
  247. }
  248. button {
  249. background-color: #ea002a;
  250. font-size: px2rpx(14);
  251. font-weight: normal;
  252. height: px2rpx(44);
  253. line-height: px2rpx(44);
  254. }
  255. .company {
  256. padding: px2rpx(50) 0 px2rpx(200) 0;
  257. position: relative;
  258. align-items: flex-start !important;
  259. }
  260. .logo {
  261. margin-left: px2rpx(48);
  262. }
  263. .title {
  264. margin: px2rpx(32) 0;
  265. font-size: px2rpx(24);
  266. font-weight: bolder;
  267. color: #e4e4e4;
  268. text-align: center;
  269. i {
  270. margin-right: px2rpx(10);
  271. }
  272. .tit1 {
  273. font-size: px2rpx(34);
  274. line-height: 1.5;
  275. font-weight: bold;
  276. color: #000000;
  277. }
  278. .tit2 {
  279. font-size: px2rpx(16);
  280. line-height: 1.5;
  281. color: #cecece;
  282. font-weight: 500;
  283. }
  284. }
  285. .qr-title {
  286. font-size: px2rpx(16);
  287. line-height: 1.5;
  288. color: #cecece;
  289. font-weight: 500;
  290. text-align: center;
  291. margin: px2rpx(40) 0;
  292. display: flex;
  293. align-items: center;
  294. justify-content: center;
  295. .line {
  296. flex: 1;
  297. height: 1px;
  298. background-color: #e4e4e4;
  299. }
  300. .qr-tit2 {
  301. margin: 0 px2rpx(12);
  302. }
  303. }
  304. .input {
  305. height: px2rpx(44);
  306. border-radius: px2rpx(8);
  307. background: #f7f8fa;
  308. padding: 0 px2rpx(20) !important;
  309. position: relative;
  310. }
  311. .account-icon {
  312. width: px2rpx(12);
  313. height: px2rpx(14) !important;
  314. margin-right: px2rpx(5);
  315. }
  316. :deep(.u-input__content__prefix-icon) {
  317. height: px2rpx(20);
  318. }
  319. .regiset-btn {
  320. margin: px2rpx(20) 0;
  321. }
  322. .account-tip {
  323. color: #666666;
  324. font-size: px2rpx(14);
  325. text-align: center;
  326. text {
  327. color: #ea002a;
  328. }
  329. }
  330. :deep(.u-form-item__body) {
  331. padding: 0 !important;
  332. padding-bottom: px2rpx(24) !important;
  333. }
  334. :deep(.wcg-checkbox) {
  335. padding: 0 !important;
  336. }
  337. .cwg-button {
  338. padding: px2rpx(34) 0 !important;
  339. }
  340. </style>