loginIndex.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <view class="border-box">
  3. <view class="content x-c">
  4. <!-- <image class="backImg" @tap="goBack()" src="../../static/images/icon_close.png"></image> -->
  5. <view class="pageTop x-c">
  6. <view class="loginBox">
  7. <view class="logo">
  8. <image src="/static/logo_icon2.png"></image>
  9. </view>
  10. <view class="head-title">御君方门店系统</view>
  11. <view class="login-item">
  12. <view class="input-account" :class="{'input-active': accountActive }">
  13. <input v-model="account" placeholder="账号" type="text" @focus="changeText('accountActive',true)" @blur="changeText('accountActive',false)"/>
  14. </view>
  15. </view>
  16. <view class="login-item">
  17. <view class="input-pwd" :class="{'input-active': pwdActive }">
  18. <input v-model="password" placeholder="密码" ref="input" type="text" :password="isClose" @focus="changeText('pwdActive',true)" @blur="changeText('pwdActive',false)"/>
  19. <view class="close-pwd" @click="closePwd">
  20. <image :src="isClose?'/static/image/device/eye_close_icon36.png':'/static/image/device/eye_open_icon36.png'"></image>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="login-item flexCenter">
  25. <view class="input-code" :class="{ 'input-active': codeActive }">
  26. <input v-model="code" placeholder="验证码" type="text" @focus="changeText('codeActive',true)" @blur="changeText('codeActive',false)"/>
  27. </view>
  28. <view class="input-yzcode">
  29. <image :src="codeImg" @click="getCode"></image>
  30. </view>
  31. </view>
  32. <view class="checkbox">
  33. <!-- <view class="checkbox-icon" @tap="handleAgree">
  34. <image src="../../static/image/login/radio_default.png" v-show="!agree"></image>
  35. <image src="../../static/image/login/radio_choose.png" v-show="agree"></image>
  36. </view>
  37. <view>记住密码</view> -->
  38. <checkbox-group @tap="handlePwd">
  39. <label>
  40. <checkbox borderColor="#E0E3EE" iconColor="#8F6726" v-model="agree" :checked="agree" />
  41. 记住密码
  42. </label>
  43. </checkbox-group>
  44. </view>
  45. <view class="btns">
  46. <view class="login-btn" @click="login">登录</view>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- <view class="pageBottom" v-if="isApp && isAgreePrivacy">
  51. <view class="tips y-f"> — 快捷登录 — </view>
  52. <view class="menu x-ac">
  53. <view v-if="wxIsInstalled" @tap="loginWeixin" ><image src="/static/image/login/weixin.png"></image></view>
  54. <view v-if="isIos" @tap="quickAppleLogin" ><image src="/static/image/login/apple.png"></image></view>
  55. <view><image src="/static/image/login/qq.png"></image></view>
  56. <view><image src="/static/image/login/weibo.png"></image></view>
  57. </view>
  58. </view> -->
  59. <!-- <view class="checkbox">
  60. <view class="checkbox-icon" @tap="handleAgree">
  61. <image src="../../static/image/login/radio_default.png" v-show="!agree"></image>
  62. <image src="../../static/image/login/radio_choose.png" v-show="agree"></image>
  63. </view>
  64. <view>我已阅读并同意<text @tap="goToWeb(0)">《用户协议》</text><text @tap="goToWeb(1)">《隐私政策》</text> 并使用本机号码登录</view>
  65. </view> -->
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import { login, loginByWeChat, getUserInfo, loginByApple, setPhone, getCode } from '@/api/user';
  71. export default {
  72. data() {
  73. return {
  74. isClose:true,
  75. userName: '测试企业',
  76. account: '测试企业',
  77. password: 'admin1122..',
  78. registrationID: '',
  79. unionid: '',
  80. userPhone: '',
  81. loginType: 0,
  82. isApp: false,
  83. agree: false,
  84. isAgreePrivacy: false,
  85. isIos: false,
  86. from: '',
  87. source: '',
  88. appleKey: '',
  89. wxIsInstalled: false,
  90. code: '',
  91. codeImg: '',
  92. uuid: '',
  93. // 激活状态变量
  94. accountActive: false,
  95. pwdActive: false,
  96. codeActive: false
  97. };
  98. },
  99. onLoad(option) {
  100. var token=uni.getStorageSync('AppToken');
  101. if(token){
  102. var user=JSON.parse(uni.getStorageSync('userInfo'));
  103. this.account=user.userName
  104. this.password=uni.getStorageSync('password');
  105. }
  106. },
  107. onShow() {
  108. this.getCode();
  109. },
  110. onUnload() {
  111. uni.$off('getRegistrationID');
  112. },
  113. mounted() {
  114. },
  115. methods: {
  116. getCode(){
  117. getCode().then(res => {
  118. console.log('code')
  119. uni.hideLoading();
  120. if(res.code==200){
  121. // console.log('code',res)
  122. this.codeImg='data:image/png;base64,'+res.img
  123. this.uuid=res.uuid
  124. }
  125. else{
  126. uni.showToast({title: res.msg,icon: 'none'});
  127. }
  128. },
  129. (rej) => {
  130. uni.hideLoading();
  131. console.log('qxj rej:' + JSON.stringify(rej));
  132. }
  133. );
  134. },
  135. initUniverify() {
  136. const callback = (res) => {
  137. // 获取一键登录弹框协议勾选状态
  138. univerifyManager.getCheckBoxState({
  139. success(res) {
  140. if (res.state) {
  141. // 关闭一键登录弹框
  142. univerifyManager.close();
  143. }
  144. }
  145. });
  146. };
  147. // 订阅自定义按钮点击事件
  148. univerifyManager.onButtonsClick(callback);
  149. // 取消订阅自定义按钮点击事件
  150. univerifyManager.offButtonsClick(callback);
  151. },
  152. changeText(val,value){
  153. this[val]=value
  154. },
  155. closePwd(){
  156. this.isClose=!this.isClose
  157. },
  158. handlePwd(){
  159. this.agree=!this.agree
  160. },
  161. login() {
  162. if (this.$isEmpty(this.account)) {
  163. uni.showToast({
  164. title: '请输入帐号',
  165. icon: 'none'
  166. });
  167. return;
  168. }
  169. if (this.$isEmpty(this.password)) {
  170. uni.showToast({
  171. title: '请输入密码',
  172. icon: 'none'
  173. });
  174. return;
  175. }
  176. if (this.$isEmpty(this.code)) {
  177. uni.showToast({
  178. title: '请输入验证码',
  179. icon: 'none'
  180. });
  181. return;
  182. }
  183. var data = {
  184. account: this.account,
  185. password: this.password,
  186. uuid: this.uuid,
  187. code: this.code
  188. };
  189. var that = this;
  190. uni.showLoading({
  191. title: '处理中...'
  192. });
  193. login(data).then(
  194. (res) => {
  195. uni.hideLoading();
  196. if (res.code == 200) {
  197. uni.setStorageSync('AppToken', res.data.token);
  198. uni.setStorageSync('userInfo', JSON.stringify(res.data.user));
  199. if (this.agree) {
  200. uni.setStorageSync('password', data.password);
  201. } else {
  202. uni.setStorageSync('password', null);
  203. }
  204. uni.redirectTo({
  205. url: '/pages/index/index'
  206. });
  207. } else {
  208. uni.showToast({ title: res.msg, icon: 'none' });
  209. this.code = '';
  210. this.getCode();
  211. }
  212. },
  213. (rej) => {
  214. uni.hideLoading();
  215. console.log('qxj rej:' + JSON.stringify(rej));
  216. }
  217. );
  218. },
  219. goToRegister() {
  220. this.$navTo('./register');
  221. },
  222. goToFindPass() {
  223. this.$navTo('./findpass');
  224. }
  225. }
  226. };
  227. </script>
  228. <style scoped lang="scss">
  229. page {
  230. background-color: #ffffff;
  231. }
  232. .border-box {
  233. width: 100vw;
  234. height: 100vh;
  235. background-image:url(/static/image/device/ipad_yjf_boder.png);
  236. background-repeat: no-repeat;
  237. position: relative;
  238. background-size: 100% 100%;
  239. box-sizing: border-box;
  240. padding: 10px;
  241. }
  242. .content {
  243. display: flex;
  244. width: 100%;
  245. height: 100%;
  246. background-image: url(/static/image/device/ipad_yjf_bg.png);
  247. background-repeat: no-repeat;
  248. background-size: 100% 100%;
  249. position: relative;
  250. }
  251. .backImg {
  252. position: absolute;
  253. left: 30px;
  254. top: 40px;
  255. height: 30px;
  256. width: 30px;
  257. }
  258. .pageTop {
  259. flex: 1;
  260. display: flex;
  261. flex-direction: column;
  262. width: 100%;
  263. }
  264. .content .head {
  265. text-align: center;
  266. width: 100%;
  267. height: 100px;
  268. // background:url(/static/image/login/top_bg.png) no-repeat 0 center;
  269. background-size: cover;
  270. box-sizing: border-box;
  271. font-size: 36px;
  272. font-weight: bold;
  273. color: #666;
  274. }
  275. .content .head image {
  276. width: 150px;
  277. height: 150px;
  278. border-radius: 10px;
  279. box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.2);
  280. }
  281. .title {
  282. color: #141414;
  283. margin: 50upx 0upx 30upx 0px;
  284. font-size: 38px;
  285. font-weight: 500;
  286. }
  287. .desc {
  288. color: #686866;
  289. padding: 0 0 30px 0px;
  290. font-size: 28px;
  291. }
  292. .logo {
  293. width: 110px;
  294. height: 110px;
  295. background: #8f6726;
  296. border-radius: 150%;
  297. display: flex;
  298. align-items: center;
  299. justify-content: center;
  300. position: absolute;
  301. z-index: 10;
  302. top: -60px;
  303. left: 50%;
  304. transform: translateX(-50%);
  305. image {
  306. width: 74px;
  307. height: 74px;
  308. }
  309. }
  310. .head-title {
  311. font-family: Source Han Serif CN, Source Han Serif CN;
  312. font-weight: bold;
  313. font-size: 36px;
  314. color: #222222;
  315. text-align: center;
  316. font-style: normal;
  317. margin-bottom: 30px;
  318. }
  319. .flexCenter {
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. }
  324. .loginBox {
  325. padding: 67px 44px 44px;
  326. // width: calc(60%);
  327. background: #fdfdfd;
  328. z-index: 10;
  329. position: relative;
  330. border-radius: 24px;
  331. .login-item {}
  332. .login-item p {
  333. text-align: left;
  334. }
  335. .line {
  336. height: 0.5px;
  337. background-color: #efefef;
  338. margin-top: 10px;
  339. }
  340. input {
  341. margin-left: 80px;
  342. height: 52px;
  343. font-family: PingFang SC, PingFang SC;
  344. font-weight: 400;
  345. font-size: 18px;
  346. color: #a8aaac;
  347. text-align: left;
  348. line-height: 52px;
  349. }
  350. .input-account {
  351. margin-top: 10px;
  352. margin-bottom: 0px;
  353. border-radius: 12px;
  354. border: 1px solid #e0e3ee;
  355. height: 52px;
  356. width: 100%;
  357. background: url(/static/image/device/user_icon36.png) no-repeat 0 center;
  358. background-size: 27px 27px;
  359. background-position: 27px;
  360. }
  361. .input-pwd {
  362. margin-top: 20px;
  363. // margin-bottom: 20px;
  364. border-radius: 12px;
  365. border: 1px solid #e0e3ee;
  366. height: 52px;
  367. width: 100%;
  368. background: url(/static/image/device/password_icon36.png) no-repeat 0 center;
  369. background-size: 27px 27px;
  370. background-position: 27px;
  371. display: flex;
  372. align-items: center;
  373. justify-content: space-between;
  374. .close-pwd{
  375. margin-right: 40px;
  376. display: flex;
  377. align-items: center;
  378. justify-content: center;
  379. // margin-top: 10px;
  380. image{
  381. width: 27px;
  382. height: 27px;
  383. }
  384. }
  385. }
  386. .input-code {
  387. margin-top: 20px;
  388. margin-right: 20px;
  389. margin-bottom: 20px;
  390. border-radius: 12px;
  391. border: 1px solid #e0e3ee;
  392. height: 52px;
  393. width: 100%;
  394. background: url(/static/image/device/code_icon36.png) no-repeat 0 center;
  395. background-size: 27px 27px;
  396. background-position: 27px;
  397. }
  398. .input-yzcode {
  399. margin-top: 20px;
  400. margin-bottom: 20px;
  401. width: 200px;
  402. height: 52px;
  403. image {
  404. width: 100%;
  405. height: 100%;
  406. }
  407. }
  408. .reg-box {
  409. padding-bottom: 20px;
  410. margin: 0 10px;
  411. .reg-btn {
  412. font-size: 16px;
  413. color: #ff5c03;
  414. }
  415. }
  416. }
  417. /* 激活状态样式(核心) */
  418. .input-active {
  419. border:1px solid #8F6726 !important; /* 激活时边框色(示例:蓝色) */
  420. }
  421. .input-active input {
  422. caret-color: #8F6726; /* 激活时光标色(与边框色一致) */
  423. }
  424. .btns {
  425. margin-top: 30rpx;
  426. }
  427. .login-btn {
  428. display: flex;
  429. align-items: center;
  430. justify-content: center;
  431. width: 100%;
  432. height: 65px;
  433. background: #8f6726;
  434. border-radius: 12px;
  435. font-size: 24px;
  436. font-family: PingFang SC;
  437. font-weight: 500;
  438. color: rgba(255, 255, 255, 1);
  439. }
  440. .pageBottom {
  441. height: 220px;
  442. width: 75%;
  443. display: flex;
  444. flex-direction: column;
  445. position: absolute;
  446. bottom: 100px;
  447. }
  448. .tips {
  449. color: #999;
  450. font-size: 32px;
  451. }
  452. .menu {
  453. margin-top: 30px;
  454. image {
  455. width: 96px;
  456. height: 96px;
  457. }
  458. }
  459. .checkbox {
  460. // margin: 20px;
  461. margin-top: 20px;
  462. display: flex;
  463. // flex-direction: row;
  464. align-items: center;
  465. // justify-content: flex-start;
  466. font-family: PingFang SC, PingFang SC;
  467. font-weight: 400;
  468. font-size: 18px;
  469. color: #999999;
  470. // line-height: 38px;
  471. text-align: left;
  472. .uni-label-pointer{
  473. display: flex;
  474. // flex-direction: row;
  475. align-items: center;
  476. }
  477. text {
  478. color: #8f6726;
  479. }
  480. &-icon {
  481. flex-shrink: 0;
  482. margin-right: 15px;
  483. image {
  484. height: 24px;
  485. width: 24px;
  486. }
  487. }
  488. }
  489. // 响应式适配 - 针对不同屏幕尺寸调整
  490. // 小屏手机
  491. @media (max-width: 412px) {
  492. .login-panel {
  493. padding: 80px 30px 40px;
  494. .head-title {
  495. font-size: 40px;
  496. margin-bottom: 40px;
  497. }
  498. }
  499. $spacing: 20px;
  500. $input-height: 80px;
  501. .loginBox {
  502. padding: 90px 60px 60px;
  503. width: calc(80%);
  504. }
  505. }
  506. </style>