index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view>
  3. <view class="loginway">
  4. <view class="navigation"></view>
  5. <image class="loginimg" mode="widthFix" src="/static/login/logo_word.png" />
  6. <view class="input_wrap">
  7. <!-- 使用原生 input 保证 Vue3 下 v-model 可靠 -->
  8. <view class="input_row">
  9. <image class="input_icon" src="/static/login/icon-account.png" mode="aspectFit" />
  10. <input
  11. class="input_field"
  12. v-model="username"
  13. type="text"
  14. placeholder="请输入账号"
  15. placeholder-class="input_placeholder"
  16. />
  17. </view>
  18. <view class="input_row">
  19. <image class="input_icon" src="/static/login/icon-password.png" mode="aspectFit" />
  20. <input
  21. class="input_field"
  22. v-model="password"
  23. type="text"
  24. password
  25. placeholder="请输入密码"
  26. placeholder-class="input_placeholder"
  27. />
  28. </view>
  29. <view class="input_row row_remember">
  30. <u-checkbox-group v-model="checkboxs" placement="column" @change="changeRemember">
  31. <u-checkbox label="记住密码" name="remember" />
  32. </u-checkbox-group>
  33. </view>
  34. <view class="input_row agree_form_item">
  35. <view class="agree_row">
  36. <u-checkbox-group v-model="agreePrivacyList" placement="row" @change="onAgreeChange">
  37. <u-checkbox name="agree" />
  38. </u-checkbox-group>
  39. <text class="agree_text">我已阅读并同意</text>
  40. <text class="agree_link" @click="toPrivacy">《隐私政策》</text>
  41. </view>
  42. </view>
  43. <view class="input_row btn_row">
  44. <u-button type="primary" text="登录" shape="circle" @click="handleLogin" />
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. export default {
  52. data() {
  53. return {
  54. firstLoginState: "",
  55. username: "",
  56. password: "",
  57. form: {
  58. username: "",
  59. password: "",
  60. systemCode: "system_crm",
  61. clientFlag: "2",
  62. code: "996007qa.code",
  63. uuid: "123",
  64. agreePrivacy: false
  65. },
  66. checkboxs: [],
  67. agreePrivacyList: []
  68. };
  69. },
  70. computed: {
  71. systemList() {
  72. return this.$store.state.user.systemList;
  73. },
  74. remember: {
  75. get() {
  76. return this.checkboxs.length > 0;
  77. },
  78. set(value) {
  79. this.checkboxs = value ? ["remember"] : [];
  80. }
  81. }
  82. },
  83. mounted() {
  84. this.systemChange(this.form.systemCode);
  85. this.getUserByCache();
  86. },
  87. onLoad(option) {
  88. const { shiYuWxLogin } = option || {};
  89. this.firstLoginState = shiYuWxLogin;
  90. },
  91. methods: {
  92. onAgreeChange(list) {
  93. this.form.agreePrivacy = (list || []).includes("agree");
  94. },
  95. toPrivacy() {
  96. uni.navigateTo({ url: "/pages/privacy/index" });
  97. },
  98. changeRemember(value) {
  99. if ((value || []).length > 0) {
  100. uni.setStorageSync("username", this.username);
  101. uni.setStorageSync("password", this.password);
  102. } else {
  103. uni.removeStorageSync("username");
  104. uni.removeStorageSync("password");
  105. }
  106. },
  107. getUserByCache() {
  108. const savedUsername = uni.getStorageSync("username");
  109. const savedPassword = uni.getStorageSync("password");
  110. if (savedUsername && savedPassword) {
  111. this.username = savedUsername;
  112. this.password = savedPassword;
  113. this.form.username = savedUsername;
  114. this.form.password = savedPassword;
  115. this.checkboxs = ["remember"];
  116. }
  117. },
  118. handleToConfiguration() {
  119. uni.navigateTo({
  120. url: "/pages/configuration/index"
  121. });
  122. },
  123. systemChange(e) {
  124. if (!e) return;
  125. uni.$u.api
  126. .getAppSystemList()
  127. .then((res) => {
  128. const systemCodeList = res.data;
  129. this.$store.dispatch("user/setSystemlist", systemCodeList);
  130. const system = this.systemList.find((v) => v.value === e);
  131. this.$store.commit("user/SET_SYSTEM", system);
  132. })
  133. .catch(() => {
  134. uni.$u.toast("服务网络不通");
  135. });
  136. },
  137. handleLogin() {
  138. const name = (this.username || "").trim();
  139. const pwd = this.password || "";
  140. if (!name) {
  141. uni.$u.toast("请输入账号");
  142. return;
  143. }
  144. if (!pwd) {
  145. uni.$u.toast("请输入密码");
  146. return;
  147. }
  148. if (!this.form.agreePrivacy) {
  149. uni.$u.toast("请阅读并同意《隐私政策》");
  150. return;
  151. }
  152. // 同步到 form,供接口使用
  153. this.form.username = name;
  154. this.form.password = pwd;
  155. if (this.remember) {
  156. uni.setStorageSync("username", this.username);
  157. uni.setStorageSync("password", this.password);
  158. } else {
  159. uni.removeStorageSync("username");
  160. uni.removeStorageSync("password");
  161. }
  162. this.$store
  163. .dispatch("user/login", this.form)
  164. .then(() => {
  165. uni.switchTab({
  166. url: "/pages/person/index",
  167. success: () => {
  168. this.$store.dispatch("app/register");
  169. uni.$u.toast("登录成功");
  170. }
  171. });
  172. })
  173. .catch((res) => {
  174. const msg =
  175. (res && (res.message || res.msg)) ||
  176. (typeof res === "string" ? res : "登录失败");
  177. uni.$u.toast(msg);
  178. });
  179. }
  180. }
  181. };
  182. </script>
  183. <style lang="scss">
  184. .network_configuration_box {
  185. margin: auto;
  186. .netWrokSet {
  187. display: flex;
  188. align-items: center;
  189. image {
  190. width: 30rpx;
  191. height: 30rpx;
  192. }
  193. .text {
  194. margin-left: 10rpx;
  195. font-size: 26rpx;
  196. }
  197. }
  198. }
  199. .systemLabel_wrap {
  200. display: flex;
  201. align-items: center;
  202. .label {
  203. margin-left: 10rpx;
  204. }
  205. }
  206. .systemCode_wrap {
  207. position: relative;
  208. ::v-deep .uni-select {
  209. border-radius: 100px;
  210. border: 1px solid #dadbde;
  211. height: 40px;
  212. padding: 0px 10px 0px 46px;
  213. &:before {
  214. content: "";
  215. display: block;
  216. width: 16px;
  217. height: 16px;
  218. background-image: url("../../static/login/icon-system.png");
  219. background-size: 16px 16px;
  220. position: absolute;
  221. left: 20px;
  222. top: 50%;
  223. transform: translate(0%, -50%);
  224. }
  225. .uni-select__input-placeholder {
  226. font-size: 14px;
  227. color: rgb(192, 196, 204);
  228. }
  229. }
  230. .system_debt {
  231. ::v-deep .uni-select {
  232. &:before {
  233. background-image: url("../../static/outbound/icon-zycs.png");
  234. }
  235. }
  236. }
  237. .system_debt_ccb {
  238. ::v-deep .uni-select {
  239. &:before {
  240. background-image: url("../../static/outbound/icon-zycs.png");
  241. }
  242. }
  243. }
  244. .system_debt_spdb {
  245. ::v-deep .uni-select {
  246. &:before {
  247. background-image: url("../../static/outbound/icon-zycs.png");
  248. }
  249. }
  250. }
  251. .system_debt_public {
  252. ::v-deep .uni-select {
  253. &:before {
  254. background-image: url("../../static/outbound/icon-zycs.png");
  255. }
  256. }
  257. }
  258. .system_debt_dfkl {
  259. ::v-deep .uni-select {
  260. &:before {
  261. background-image: url("../../static/outbound/icon-zycs.png");
  262. }
  263. }
  264. }
  265. .system_debt_cib {
  266. ::v-deep .uni-select {
  267. &:before {
  268. background-image: url("../../static/outbound/icon-zycs.png");
  269. }
  270. }
  271. }
  272. .system_debt_icbc_h {
  273. ::v-deep .uni-select {
  274. &:before {
  275. background-image: url("../../static/outbound/icon-zycs.png");
  276. }
  277. }
  278. }
  279. .system_debt_tjxt {
  280. ::v-deep .uni-select {
  281. &:before {
  282. background-image: url("../../static/outbound/icon-zycs.png");
  283. }
  284. }
  285. }
  286. // .systemIcon{
  287. // width: 16px;
  288. // height: 16px;
  289. // position: absolute;
  290. // left: 20px;
  291. // top: 50%;
  292. // transform: translate(0%, -50%);
  293. // display: none;
  294. // }
  295. }
  296. .inputFormWrap {
  297. ::v-deep .u-border {
  298. border: 1px solid #dadbde !important;
  299. }
  300. }
  301. .agree_form_item {
  302. ::v-deep .u-form-item__body__right {
  303. flex: 1;
  304. }
  305. }
  306. .agree_row {
  307. display: flex;
  308. align-items: center;
  309. flex-wrap: wrap;
  310. }
  311. .agree_text {
  312. font-size: 26rpx;
  313. color: #606266;
  314. margin-left: 8rpx;
  315. }
  316. .agree_link {
  317. font-size: 26rpx;
  318. color: #108cff;
  319. margin-left: 4rpx;
  320. }
  321. .max {
  322. width: 500rpx;
  323. height: 500rpx;
  324. }
  325. page {
  326. background: #fff;
  327. }
  328. .loginway {
  329. display: flex;
  330. flex-direction: column;
  331. height: 100vh;
  332. .navigation {
  333. background-color: #108cff;
  334. width: 100%;
  335. height: 120rpx;
  336. }
  337. .loginimg {
  338. display: block;
  339. width: 100%;
  340. height: 100%;
  341. }
  342. .input_wrap {
  343. padding: 20rpx 30rpx;
  344. }
  345. .input_row {
  346. display: flex;
  347. align-items: center;
  348. border: 1px solid #dadbde;
  349. border-radius: 100px;
  350. padding: 0 20rpx 0 36rpx;
  351. margin-bottom: 24rpx;
  352. background: #fff;
  353. box-sizing: border-box;
  354. }
  355. .input_icon {
  356. width: 32rpx;
  357. height: 32rpx;
  358. margin-right: 16rpx;
  359. flex-shrink: 0;
  360. }
  361. .input_field {
  362. flex: 1;
  363. height: 88rpx;
  364. line-height: 88rpx;
  365. font-size: 28rpx;
  366. color: #303133;
  367. }
  368. .input_placeholder {
  369. color: #c0c4cc;
  370. }
  371. .row_remember,
  372. .agree_form_item {
  373. border: none;
  374. padding: 0;
  375. margin-bottom: 16rpx;
  376. background: transparent;
  377. }
  378. .btn_row {
  379. border: none;
  380. padding: 24rpx 0 0;
  381. margin-bottom: 0;
  382. background: transparent;
  383. }
  384. }
  385. </style>