移动端
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

297 righe
9.2 KiB

  1. <template>
  2. <div class="home_wrapper">
  3. <div class="return_btn" @click="onClickLeft"></div>
  4. <div class="focus_head">
  5. </div>
  6. <div class="focus_info">
  7. <div class="icon"></div>
  8. <div class="title"></div>
  9. </div>
  10. <van-form @submit="handleLogin">
  11. <div class="login_from">
  12. <div class="flex_block">
  13. <div class="flex_input_main">
  14. <div class="icon_wrap user"></div>
  15. <div class="input_wrap">
  16. <input type="text" v-model="formData.name" class="ipt" placeholder="姓名"/>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="flex_block">
  21. <div class="flex_input_main">
  22. <div class="icon_wrap password"></div>
  23. <div class="input_wrap">
  24. <input type="text" v-model="formData.idcard" class="ipt" placeholder="身份证号码"/>
  25. </div>
  26. </div>
  27. </div>
  28. <van-checkbox v-model="formData.rememberMe">记住我的信息</van-checkbox>
  29. </div>
  30. <div class="login_btn">
  31. <van-button
  32. class="btn"
  33. round
  34. block
  35. type="info"
  36. native-type="submit"
  37. color="linear-gradient(to right, #2ec8c4, #30c271)"
  38. :loading="loading"
  39. >验证</van-button>
  40. </div>
  41. </van-form>
  42. </div>
  43. </template>
  44. <script>
  45. import { getCodeImg, getSmsCode } from "@/api/login";
  46. import { checkFarmer, allowFaceVerify } from "@/api/sunVillage_info/fixedAssets";
  47. import { getFamilyMemberList } from "@/api/sunVillage_info/homestead/familyMember";
  48. import Cookies from "js-cookie";
  49. import { encrypt, decrypt } from "../../utils/jsencrypt";
  50. //引用wx sdk
  51. import wx from "weixin-js-sdk";
  52. import {farmerLogin} from "@/api/register";
  53. export default {
  54. name: "loginFarmer",
  55. data() {
  56. return {
  57. formData: {
  58. name: '',
  59. idcard: '',
  60. rememberMe: false,
  61. },
  62. loading: false,
  63. codeUrl: "", //验证码
  64. isSmsLogin: false, //是否手机验证码
  65. computeTime: 0,
  66. height:0,
  67. show:true
  68. };
  69. },
  70. created() {
  71. this.height = document.body.clientHeight
  72. this.getCookie();
  73. },
  74. methods: {
  75. getCookie() {
  76. const memberName = Cookies.get("memberName");
  77. const idcard = Cookies.get("idcard");
  78. const rememberMe = Cookies.get("rememberInformation");
  79. if(memberName !== undefined)
  80. this.formData.name = memberName;
  81. if(idcard !== undefined)
  82. this.formData.idcard = idcard;
  83. if(rememberMe !== undefined)
  84. this.formData.rememberMe = Boolean(rememberMe);
  85. },
  86. remember() {
  87. if (this.formData.rememberMe) {
  88. Cookies.set("memberName", this.formData.name, { expires: 30 });
  89. Cookies.set("idcard", this.formData.idcard, { expires: 30 });
  90. Cookies.set("rememberInformation", this.formData.rememberMe, { expires: 30 });
  91. } else {
  92. Cookies.remove("username");
  93. Cookies.remove("password");
  94. Cookies.remove("rememberInformation");
  95. }
  96. },
  97. validate() {
  98. if (this.formData.name == "") {
  99. this.$dialog.alert({
  100. message: '姓名不能为空',
  101. });
  102. return false;
  103. } else if (this.formData.idcard == "") {
  104. this.$dialog.alert({
  105. message: '身份证不能为空',
  106. });
  107. return false;
  108. }
  109. return true;
  110. },
  111. handleLogin(values) {
  112. this.remember();
  113. if(!this.validate())
  114. return;
  115. farmerLogin(this.formData).then(response => {
  116. const farmer = response.data;
  117. let seconds = 3600;
  118. let expires = new Date(new Date() * 1 + seconds * 1000);
  119. Cookies.set("bookName", farmer.bookName, {
  120. expires: 30,
  121. });
  122. Cookies.set("deptName", farmer.deptName, {
  123. expires: 30,
  124. });
  125. Cookies.set("bookId", farmer.bookId, {
  126. expires: 30,
  127. });
  128. Cookies.set("deptId", farmer.deptId, {
  129. expires: 30,
  130. });
  131. const farmerCode = farmer.hzFarmerCode;
  132. Cookies.set("farmerCode",farmerCode, { expires: 30 });
  133. Cookies.set("user", farmer, { expires: expires });
  134. allowFaceVerify().then(resp => {
  135. if(resp.data === 'true' || 1)
  136. {
  137. this.$router.push({
  138. path: '/sunVillage_info/identity_check',
  139. query: {
  140. responseData: response.data,
  141. redirectPath: '/sunVillage_info/index_farmer',
  142. }});
  143. }
  144. else
  145. this.$router.push({path:'/sunVillage_info/index_farmer'});
  146. });
  147. });
  148. },
  149. },
  150. };
  151. </script>
  152. <style scoped lang="scss">
  153. /deep/ .van-checkbox__label{
  154. color: #ffffff;
  155. }
  156. /deep/ .van-checkbox{
  157. justify-content: right;
  158. }
  159. .home_wrapper{
  160. background: #f1f2f2;
  161. width: 100vw;
  162. min-height: 100vh;
  163. .return_btn {
  164. width: 24px;
  165. height: 43.2px;
  166. background: url('../../assets/images/sunVillage_info/list_icon_5.png') center center no-repeat;
  167. background-size: 20px 36px;
  168. position: absolute;
  169. left: 38px;
  170. top: 36px;
  171. }
  172. .focus_head{
  173. height: 450px;
  174. background: url('../../assets/images/sunVillage_info/login_head_code_green.png') no-repeat;
  175. background-size: 100% 100%;
  176. }
  177. .focus_info{
  178. margin-top: -74px;
  179. .icon{
  180. background: url('../../assets/images/sunVillage_info/login_head_t.png') no-repeat;
  181. background-size: 100% 100%;
  182. width: 145px;
  183. height: 148px;
  184. margin:0 auto;
  185. }
  186. .title{
  187. width: 180PX;
  188. height: 52px;
  189. background: url('../../assets/images/sunVillage_info/login_head_nr_code.png') no-repeat;
  190. background-size: 100% 100%;
  191. margin:30px auto 0;
  192. }
  193. }
  194. .login_from{
  195. width: 676px;
  196. height: 350px;
  197. background: url('../../assets/images/sunVillage_info/login_main_green.png') no-repeat;
  198. background-size: 100% 100%;
  199. margin: 50px auto 0;
  200. padding:60px 50px 0;
  201. .flex_block{
  202. margin-bottom: 40px;
  203. display: flex;
  204. justify-content:space-between;
  205. .flex_input_main{
  206. position: relative;
  207. display: flex;
  208. flex: 1;
  209. align-items:center;
  210. background: rgba(255,255,255,0.7);
  211. border-radius: 62px;
  212. height: 62px;
  213. .icon_wrap{
  214. width: 35px;
  215. height: 35px;
  216. &.user{
  217. background: url('../../assets/images/sunVillage_info/login_icon_1.png') no-repeat;
  218. background-size: 100% 100%;
  219. margin-left: 30px;
  220. }
  221. &.password{
  222. background: url('../../assets/images/sunVillage_info/login_icon_2_code.png') no-repeat;
  223. height: 25px;
  224. background-size: 100% 100%;
  225. margin-left: 30px;
  226. }
  227. &.valid{
  228. background: url('../../assets/images/sunVillage_info/login_icon_3.png') no-repeat;
  229. background-size: 100% 100%;
  230. margin-left: 30px;
  231. }
  232. }
  233. .input_wrap{
  234. flex: 1;
  235. margin-left: 16px;
  236. padding-right: 30px;
  237. .ipt{
  238. width: 100%;
  239. height: 48px;
  240. background:transparent;
  241. font-size: 30px;
  242. color: #3f3d56;
  243. }
  244. }
  245. .showHidden{
  246. width: 32px;
  247. height: 32px;
  248. background: url('../../assets/images/sunVillage_info/login_icon_4.png') no-repeat;
  249. background-size: 100% 100%;
  250. position: absolute;
  251. right: 38px;
  252. cursor: pointer;
  253. &.ico_hide{
  254. background: url('../../assets/images/sunVillage_info/login_icon_5.png') no-repeat;
  255. background-size: 100% 100%;
  256. }
  257. }
  258. &.valid{
  259. flex:0 0 380px;
  260. }
  261. }
  262. .valid_main{
  263. width: 165px;
  264. height: 62px;
  265. border-radius: 30px;
  266. img{
  267. width: 100%;
  268. height: 100%;
  269. border-radius: 30px;
  270. }
  271. }
  272. }
  273. }
  274. .login_btn{
  275. padding-top: 80px;
  276. .btn{
  277. width: 315px;
  278. height: 80px;
  279. margin:0 auto;
  280. font-size: 32px;
  281. color: #fff;
  282. text-align: center;
  283. border: none;
  284. }
  285. }
  286. }
  287. </style>