login.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="login">
  3. <img src="../../common/assets/image/logobig.png" alt="" class="logobig" />
  4. <img src="./topimg.png" alt="" class="topimg" />
  5. <div class="wellogin">
  6. <div class="loginBox">
  7. <div class="logTit">
  8. <span class="titletxt">欢迎登录</span>
  9. </div>
  10. <div class="inputBox">
  11. <img src="../../common/assets/image/comicon.png" alt="" />
  12. <input
  13. type="text"
  14. placeholder="请输入账号"
  15. v-model="loginForm.userName"
  16. />
  17. </div>
  18. <div class="inputBox">
  19. <img src="../../common/assets/image/pswicon.svg" alt="" />
  20. <input
  21. type="password"
  22. placeholder="请输入密码"
  23. v-model="loginForm.password"
  24. />
  25. </div>
  26. <div class="inputBox">
  27. <img src="../../common/assets/image/yzmicon.svg" alt="" />
  28. <input
  29. type="text"
  30. placeholder="验证码"
  31. class="yanzhengma"
  32. v-model="loginForm.code"
  33. />
  34. <img
  35. :src="loginForm.captchaImage"
  36. @click="captchaImageRefresh(loginForm)"
  37. class="yanzhengImg"
  38. />
  39. </div>
  40. <div style="margin-top: 80rpx">
  41. <van-button
  42. type="default"
  43. class="loginbtn"
  44. size="large"
  45. color="rgba(138, 5, 84, 1)"
  46. @click="login"
  47. >登 录</van-button
  48. >
  49. </div>
  50. </div>
  51. </div>
  52. <div class="bottomTips">
  53. <label class="radio">
  54. <radio value="r1" checked="true" color="#8a0554" />
  55. 已阅读并同意<span style="color: #8a0554"
  56. >《服务协议条款及隐私政策》</span
  57. >
  58. </label>
  59. </div>
  60. <van-dialog id="van-toast" />
  61. </div>
  62. </template>
  63. <script>
  64. import Dialog from "../../wxcomponents/weapp/dist/dialog/dialog.js";
  65. import { login } from "@/js_sdk/http.js";
  66. import w_md5 from "@/js_sdk/zww-md5/w_md5.js";
  67. export default {
  68. data() {
  69. return {
  70. loginForm: {
  71. userName: "",
  72. password: "",
  73. code: "",
  74. type: "USER",
  75. captchaId: "",
  76. captchaImage: "",
  77. rememberMe: true,
  78. },
  79. };
  80. },
  81. onLoad(e) {
  82. console.log(e);
  83. // login()
  84. this.captchaImageRefresh(this.loginForm);
  85. this.loginForm.type = e.type ? e.type : "USER";
  86. },
  87. methods: {
  88. async wxlogin() {
  89. let _this = this;
  90. wx.login({
  91. success: async function (res) {
  92. let data = await login({ openCode: res.code });
  93. console.log(data);
  94. _this.$auth.setUser(data.data.token);
  95. _this.$auth.setUserInfo(data.data);
  96. uni.switchTab({
  97. url: "/pages/index/index",
  98. });
  99. },
  100. });
  101. },
  102. goqy() {
  103. uni.navigateTo({
  104. url: "/pages/gocompnay/index",
  105. });
  106. },
  107. gozhfw() {
  108. wx.navigateToMiniProgram({
  109. appId: "wx9919d022c184462b",
  110. success(res) {
  111. // 打开成功
  112. },
  113. fail(e) {
  114. console.log(e);
  115. },
  116. });
  117. },
  118. captchaImageRefresh: function (_form) {
  119. _form.captchaId = this.$common.uuid(8);
  120. _form.captchaImage =
  121. this.$constant.BASE_URI +
  122. "/captcha/captchaImage?type=math&captchaId=" +
  123. _form.captchaId +
  124. "&s=" +
  125. Math.random();
  126. },
  127. forgetPsw() {
  128. wx.showModal({
  129. title: "提示!",
  130. content: "管理端修改密码需要拨打客服电话15061150110咨询,是否拨打?",
  131. success: function (res) {
  132. if (res.confirm) {
  133. uni.makePhoneCall({
  134. phoneNumber: "15061150110", //电话号码
  135. success: function (e) {},
  136. fail: function (e) {},
  137. });
  138. }
  139. },
  140. });
  141. },
  142. login() {
  143. const _this = this;
  144. if (!this.loginForm.userName || !this.loginForm.password) {
  145. uni.showModal({
  146. title: "提示",
  147. content: "请输入账号和密码",
  148. icon: "error",
  149. showCancel: false,
  150. });
  151. return;
  152. }
  153. let loginForm = {
  154. ...this.loginForm,
  155. password: w_md5.hex_md5_32(this.loginForm.password),
  156. };
  157. login(loginForm).then((res) => {
  158. if (res.errmsg == "成功") {
  159. uni.showToast({
  160. title: "登录成功",
  161. icon: "none",
  162. mask: true,
  163. duration: 2000,
  164. });
  165. this.$auth.setUser(res.data.token);
  166. this.$auth.setUserInfo({
  167. ...res.data,
  168. userType: this.loginForm.type,
  169. });
  170. uni.switchTab({
  171. url: "/pages/index/index",
  172. });
  173. } else {
  174. this.captchaImageRefresh(this.loginForm);
  175. }
  176. });
  177. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  178. },
  179. onShareAppMessage: function () {},
  180. },
  181. };
  182. </script>
  183. <style lang="scss">
  184. .login {
  185. background: white;
  186. height: 100%;
  187. overflow: hidden;
  188. .wellogin {
  189. width: 750rpx;
  190. height: 1060;
  191. background: #ffffff;
  192. border-radius: 40rpx 40rpx 0rpx 0rpx;
  193. position: absolute;
  194. padding-top: 68rpx;
  195. top: 330rpx;
  196. }
  197. .topimg {
  198. /* margin: auto; */
  199. display: block;
  200. margin: auto;
  201. position: absolute;
  202. left: calc(50% - 300rpx);
  203. /* width: 240rpx; */
  204. width: 600rpx;
  205. }
  206. .logTit {
  207. width: 70vw;
  208. margin-bottom: 62rpx;
  209. z-index: 1;
  210. color: rgba(51, 51, 51, 1);
  211. font-size: 4vw;
  212. p {
  213. color: rgba(102, 102, 102, 1);
  214. font-size: 4vw;
  215. margin-top: 0.5vw;
  216. }
  217. .titletxt {
  218. font-size: 48rpx;
  219. font-family: Taipei Sans TC Beta-Bold, Taipei Sans TC Beta;
  220. font-weight: bold;
  221. color: #333333;
  222. }
  223. .titletxt2 {
  224. font-size: 32rpx;
  225. font-family: PingFang SC-Regular, PingFang SC;
  226. font-weight: 400;
  227. color: #666666;
  228. }
  229. }
  230. .logobig {
  231. width: 100vw;
  232. height: 100vh;
  233. position: absolute;
  234. left: 0;
  235. z-index: 0;
  236. }
  237. .loginBox {
  238. width: 80vw;
  239. margin: auto;
  240. }
  241. .inputBox {
  242. position: relative;
  243. display: flex;
  244. align-items: center;
  245. width: 100%;
  246. img {
  247. position: absolute;
  248. width: 50rpx;
  249. height: 70rpx;
  250. margin-right: 16rpx;
  251. margin-left: 32rpx;
  252. // padding-top: 40px;
  253. }
  254. .yanzhengImg {
  255. right: 0;
  256. width: 21vw;
  257. height: 15vw;
  258. margin: 0;
  259. padding: 0;
  260. }
  261. .yanzhengImgBox {
  262. height: 50px;
  263. display: flex;
  264. align-items: center;
  265. }
  266. input {
  267. background: #f3f5f9;
  268. width: 100%;
  269. height: 100rpx;
  270. padding: 5rpx 0 5rpx 85rpx;
  271. background-color: rgba(255, 255, 255, 1);
  272. border: 1rpx solid rgba(29, 24, 188, 0.05);
  273. margin: 16rpx 0;
  274. font-size: 4vw;
  275. background: #f3f5f9;
  276. }
  277. input::-webkit-input-placeholder {
  278. color: rgba(153, 153, 153, 1);
  279. }
  280. .yanzhengma {
  281. width: 60%;
  282. }
  283. }
  284. .pswBox {
  285. width: 100%;
  286. display: flex;
  287. justify-content: flex-end;
  288. margin: 20px 0;
  289. color: rgba(29, 24, 188, 1);
  290. }
  291. .van-button {
  292. margin-top: 15rpx;
  293. border-radius: 60px;
  294. }
  295. .loginbtn {
  296. margin-top: 50rpx;
  297. }
  298. .bottomTips {
  299. width: 100vw;
  300. position: fixed;
  301. bottom: 15px;
  302. text-align: center;
  303. color: #999999;
  304. font-size: 2vw;
  305. }
  306. @media screen and (max-height: 454px) {
  307. .bottomTips {
  308. display: none;
  309. }
  310. }
  311. }
  312. </style>