loginOld.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. <template>
  2. <view class="bg-img">
  3. <!-- <view class="status_bar"></view> -->
  4. <view class="apptitle" @longpress="logoTime">
  5. {{ $isneutral ? '云飞智控' : '智控' }}
  6. </view>
  7. <view class="set" @click="set" v-if="setTF">
  8. <u-icon name="setting-fill" size="50" color="#fff"></u-icon>
  9. </view>
  10. <view class="formbox">
  11. <form @submit="formSubmit">
  12. <view class="uni-form-item uni-column">
  13. <view class="username">
  14. <u-icon
  15. name="account"
  16. size="36"
  17. style="margin-right: 30rpx; color: #fff"
  18. ></u-icon>
  19. <u-input
  20. class="uni-input"
  21. name="username"
  22. v-model="formdata.username"
  23. placeholder-class="icon iconfont icon-bianji1"
  24. placeholder="请输入用户名"
  25. placeholderStyle="color:#ffffff;"
  26. color="#FFFFFF"
  27. @blur="blur"
  28. />
  29. </view>
  30. <view class="passwold">
  31. <u-icon
  32. name="lock"
  33. size="36"
  34. style="margin-right: 30rpx; color: #fff"
  35. ></u-icon>
  36. <u-input
  37. v-model="formdata.passwold"
  38. type="password"
  39. :password-icon="true"
  40. :clearable="false"
  41. placeholder="请输入密码"
  42. @confirm="formSubmit"
  43. @input="passwoldddata"
  44. placeholderStyle="color:#fff;"
  45. suffixIconStyle="color:#fff;"
  46. color="#fff"
  47. class="uni-input"
  48. />
  49. </view>
  50. <view class="aboutpass">
  51. <u-checkbox-group>
  52. <u-checkbox
  53. v-model="checked"
  54. :label-disabled="false"
  55. size="28"
  56. @change="rempass"
  57. >记住密码</u-checkbox
  58. >
  59. </u-checkbox-group>
  60. </view>
  61. <view class="uni-btn-v">
  62. <button form-type="submit" @click="denglu">登 录</button>
  63. </view>
  64. <!--用户隐私协议-->
  65. <view class="agreement">
  66. <u-checkbox-group>
  67. <u-checkbox
  68. v-model="agree"
  69. shape="circle"
  70. size="28"
  71. active-color="#2979ff"
  72. :label-disabled="false"
  73. >我已阅读并同意
  74. </u-checkbox>
  75. </u-checkbox-group>
  76. <text class="agree-link" @click="goAgreement"
  77. >《用户隐私协议》</text
  78. >
  79. </view>
  80. </view>
  81. </form>
  82. </view>
  83. <!-- <view class="bg">
  84. <image :src="$imageURL+ '/bigdata_app'+'/image/login/850c9307f4ef2d7dc6db1049711ab55.jpg'" mode=""></image>
  85. </view> -->
  86. <view class="setbg" v-if="setbgtf">
  87. <view class="mengban" @click.stop="setbgtf = !setbgtf"></view>
  88. <view class="set_http">
  89. <view class="set_http_top">
  90. <u-icon name="close" size="40" @click="setbgtf = !setbgtf"></u-icon>
  91. <p>设置服务器地址</p>
  92. <u-icon name="checkbox-mark" size="40" @click="sethttp"></u-icon>
  93. </view>
  94. <view class="set_http_bot">
  95. <p>服务器访问地址</p>
  96. <view class="set_http_bot_input">
  97. <input
  98. type="text"
  99. v-model="value"
  100. placeholder="请在此处输入服务器地址(http://...)"
  101. />
  102. <u-icon
  103. :name="arrowtf ? 'arrow-up' : 'arrow-down'"
  104. @click="arrow"
  105. ></u-icon>
  106. </view>
  107. <scroll-view scroll-y="true" class="scroll-Y" v-if="arrowtf">
  108. <view
  109. :id="'demo' + index"
  110. class="scroll-view-item uni-bg-red"
  111. v-for="(item, index) in httparr"
  112. :key="index"
  113. @click="value = item"
  114. >{{ item }}</view
  115. >
  116. </scroll-view>
  117. </view>
  118. </view>
  119. </view>
  120. <u-modal
  121. title="升级中请勿随意操作"
  122. :show-confirm-button="false"
  123. v-model="showA"
  124. :content="contentA"
  125. >
  126. <view class="upgradeBox">
  127. <u-line-progress
  128. v-show="isShow"
  129. active-color="#19be6b"
  130. :striped="true"
  131. :percent="percentNum"
  132. :striped-active="true"
  133. ></u-line-progress>
  134. </view>
  135. </u-modal>
  136. </view>
  137. </template>
  138. <script>
  139. export default {
  140. data() {
  141. return {
  142. checked: false,
  143. formdata: {
  144. username: '',
  145. passwold: '',
  146. },
  147. setbgtf: false,
  148. setTF: false,
  149. value: 'https://web.hnyfwlw.com',
  150. httparr: ['https://web.hnyfwlw.com'],
  151. arrowtf: false,
  152. showA: false, //
  153. contentA: '',
  154. isShow: false, //进度条
  155. percentNum: 0, //在线下载进度
  156. passvalue: false,
  157. turnover: true,
  158. agree: false,
  159. };
  160. },
  161. onLoad() {},
  162. onShow() {
  163. uni.getStorage({
  164. key: 'user_pass',
  165. success: (res) => {
  166. if (res.data) {
  167. this.formdata.passwold = res.data;
  168. this.checked = true;
  169. } else {
  170. this.checked = false;
  171. }
  172. },
  173. });
  174. uni.getStorage({
  175. key: 'user_name',
  176. success: (res) => {
  177. this.formdata.username = res.data;
  178. },
  179. });
  180. uni.getStorage({
  181. key: 'http',
  182. success: (res) => {
  183. this.value = res.data;
  184. },
  185. });
  186. console.log(this.value);
  187. uni.getStorage({
  188. key: 'turnover',
  189. success: (res) => {
  190. console.log(res.data);
  191. this.turnover = res.data;
  192. },
  193. });
  194. this.getEquipList();
  195. },
  196. methods: {
  197. async getEquipList() {
  198. const res = await this.$myRequest({
  199. url: '/api/api_gateway?method=home.homes.app_version_record',
  200. data: {
  201. ret: 'first',
  202. },
  203. });
  204. console.log(res);
  205. this.appName = res[0].app_name;
  206. this.versions = Number(res[0].app_num.match(/\d+/g).join(''));
  207. var id = Number(plus.runtime.version.match(/\d+/g).join(''));
  208. console.log(this.versions, plus.runtime.version);
  209. if (this.percentNum > 0) {
  210. console.log('更新中');
  211. } else {
  212. console.log(this.turnover);
  213. if (this.turnover) {
  214. if (this.versions > id) {
  215. uni.showModal({
  216. title: '检测到有新版本,是否更新?',
  217. content: '建议更新,不更新可能会出现部分数据无法获取!',
  218. confirmText: '更新',
  219. cancelText: '不更新',
  220. success: (res) => {
  221. if (res.confirm) {
  222. console.log('用户点击确定');
  223. this.showA = true;
  224. this.isShow = true;
  225. this.upgrade();
  226. } else if (res.cancel) {
  227. // plus.runtime.quit();
  228. console.log('用户点击取消');
  229. uni.showModal({
  230. title: '是否每次进入提示更新?',
  231. content: '不再提示后可在<我的>-<关于我们>-<版本更新>中更新',
  232. confirmText: '提示',
  233. cancelText: '不再提示',
  234. success: (res) => {
  235. if (res.confirm) {
  236. console.log('用户点击确定');
  237. uni.setStorage({
  238. key: 'turnover',
  239. data: true,
  240. });
  241. } else if (res.cancel) {
  242. uni.setStorage({
  243. key: 'turnover',
  244. data: false,
  245. });
  246. }
  247. },
  248. });
  249. }
  250. },
  251. });
  252. } else {
  253. uni.getStorage({
  254. key: 'session_key',
  255. success: (res) => {
  256. console.log(res);
  257. if (res.data != '') {
  258. uni.switchTab({
  259. url: '../index/index',
  260. });
  261. }
  262. },
  263. });
  264. }
  265. } else {
  266. uni.getStorage({
  267. key: 'session_key',
  268. success: (res) => {
  269. console.log(res);
  270. if (res.data != '') {
  271. uni.switchTab({
  272. url: '../index/index',
  273. });
  274. }
  275. },
  276. });
  277. }
  278. }
  279. },
  280. upgrade() {
  281. console.log(this.appName);
  282. // var url = this.value + "/app_file/" + this.appName
  283. var appName = '';
  284. if (this.$isneutral) {
  285. appName = 'big_data'; //云飞
  286. } else {
  287. appName = 'big_data2'; //中性
  288. }
  289. var url = 'https://hnyfwlw.com/app/' + appName + '.apk';
  290. const downloadTask = uni.downloadFile({
  291. url: url, //仅为示例,并非真实的资源
  292. success: (res) => {
  293. console.log(res);
  294. if (res.statusCode === 200) {
  295. console.log('下载成功');
  296. console.log(
  297. '安装包下载成功,即将安装:' + JSON.stringify(res, null, 4)
  298. );
  299. plus.runtime.openFile(res.tempFilePath);
  300. this.showA = false;
  301. this.isShow = false;
  302. }
  303. },
  304. fail: (err) => {
  305. console.log(err);
  306. },
  307. complete: (com) => {
  308. console.log(com);
  309. },
  310. });
  311. downloadTask.onProgressUpdate((res) => {
  312. this.percentNum = res.progress;
  313. if (res.progress == 100) {
  314. console.log('下载完成了');
  315. }
  316. });
  317. },
  318. async formSubmit() {
  319. if (!this.agree) {
  320. uni.showToast({
  321. title: '请先阅读并同意用户隐私协议',
  322. icon: 'none',
  323. });
  324. return;
  325. }
  326. const res = await this.$myRequest({
  327. url: '/api/api_gateway?method=user.login.login_user',
  328. data: {
  329. username: this.formdata.username,
  330. password: this.formdata.passwold,
  331. },
  332. });
  333. let session_key = res.session_key;
  334. uni.setStorage({
  335. key: 'session_key',
  336. data: session_key,
  337. success: () => {
  338. // 登录前清除可能残留的权限缓存,再用新账号拉取
  339. this.$resetPermissionList()
  340. this.$fetchPermissionList()
  341. uni.switchTab({
  342. url: '../index/index',
  343. });
  344. },
  345. });
  346. },
  347. passwoldddata() {
  348. this.formdata.passwold = this.formdata.passwold.replace(
  349. /[\u4E00-\u9FA5]/g,
  350. ''
  351. );
  352. },
  353. rempass(val) {
  354. this.passvalue = val.value;
  355. if (val.value) {
  356. uni.setStorage({
  357. key: 'user_pass',
  358. data: this.formdata.passwold,
  359. success: function () {
  360. console.log('success');
  361. },
  362. });
  363. }
  364. },
  365. blur(val) {
  366. uni.setStorage({
  367. key: 'user_name',
  368. data: val,
  369. success: function () {
  370. console.log('success');
  371. },
  372. });
  373. },
  374. logoTime() {
  375. this.setTF = true;
  376. },
  377. set() {
  378. this.setbgtf = true;
  379. },
  380. sethttp() {
  381. uni.setStorage({
  382. key: 'http',
  383. data: this.value,
  384. success: () => {
  385. // console.log(this.value);
  386. this.setbgtf = false;
  387. uni.showToast({
  388. title: '修改成功',
  389. icon: 'none',
  390. });
  391. this.getEquipList();
  392. uni.removeStorage({
  393. key: 'session_key',
  394. });
  395. },
  396. });
  397. },
  398. arrow() {
  399. this.arrowtf = !this.arrowtf;
  400. },
  401. denglu() {
  402. if (this.passvalue) {
  403. uni.setStorage({
  404. key: 'user_pass',
  405. data: this.formdata.passwold,
  406. success: function () {
  407. console.log('success');
  408. },
  409. });
  410. } else {
  411. uni.removeStorage({
  412. key: 'user_pass',
  413. success: function () {
  414. console.log('success');
  415. },
  416. });
  417. }
  418. },
  419. goAgreement() {
  420. uni.navigateTo({
  421. url: './agreement',
  422. });
  423. },
  424. },
  425. };
  426. </script>
  427. <style lang="scss">
  428. .bg-img {
  429. height: 100vh;
  430. background-image: url(../../static/images/login/bg.png);
  431. background-size: 100% 100%;
  432. padding-top: 500rpx;
  433. box-sizing: border-box;
  434. }
  435. .apptitle {
  436. font-size: 52rpx;
  437. color: #fff;
  438. width: 80%;
  439. margin: 0 auto 40rpx;
  440. }
  441. .logo {
  442. width: 100%;
  443. height: 340rpx;
  444. text-align: center;
  445. display: flex;
  446. align-items: center;
  447. padding-top: 240rpx;
  448. image {
  449. width: 280rpx;
  450. margin: 0 auto;
  451. height: 120rpx;
  452. }
  453. }
  454. .set {
  455. position: absolute;
  456. right: 50rpx;
  457. top: 150rpx;
  458. }
  459. .bg {
  460. width: 100%;
  461. position: fixed;
  462. bottom: 0;
  463. left: 0;
  464. z-index: -1;
  465. image {
  466. width: 100%;
  467. }
  468. }
  469. ::v-deep .u-input__right-icon {
  470. line-height: 35px !important;
  471. }
  472. .uni-form-item {
  473. width: 100%;
  474. .username {
  475. width: 80%;
  476. margin: 0 auto;
  477. display: flex;
  478. margin-bottom: 40rpx;
  479. padding-bottom: 10rpx;
  480. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  481. .u-icon__icon {
  482. margin-top: 17rpx;
  483. }
  484. .uni-input {
  485. width: 100%;
  486. color: #fff;
  487. }
  488. ::v-deep .uni-input-input {
  489. color: #fff;
  490. }
  491. }
  492. .passwold {
  493. width: 80%;
  494. margin: 0 auto;
  495. display: flex;
  496. margin-bottom: 40rpx;
  497. padding-bottom: 10rpx;
  498. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  499. .u-icon__icon {
  500. margin-top: 17rpx;
  501. }
  502. ::v-deep .uni-input-input {
  503. color: #fff;
  504. }
  505. .uni-input {
  506. width: 100%;
  507. color: #fff;
  508. }
  509. ::v-deep .uicon-eye {
  510. color: #fff !important;
  511. }
  512. }
  513. .aboutpass {
  514. width: 80%;
  515. margin: 0 auto;
  516. display: flex;
  517. justify-content: flex-end;
  518. p {
  519. color: #fff;
  520. font-size: 28rpx;
  521. }
  522. ::v-deep .uicon-checkbox-mark {
  523. border-color: #ff0000;
  524. // color: #f00 !important;
  525. }
  526. ::v-deep .u-checkbox__label {
  527. font-size: 28rpx;
  528. color: #fff;
  529. margin-right: 0;
  530. }
  531. }
  532. .uni-btn-v {
  533. width: 80%;
  534. margin: 112rpx auto 0;
  535. position: relative;
  536. z-index: 100;
  537. button {
  538. width: 100%;
  539. height: 90rpx;
  540. line-height: 90rpx;
  541. color: #ffffff;
  542. font-size: 36rpx;
  543. background-image: linear-gradient(
  544. to bottom,
  545. rgba(249, 249, 249, 0.6),
  546. rgba(249, 249, 249, 0.1)
  547. );
  548. color: #5dc18b;
  549. }
  550. }
  551. }
  552. .setbg {
  553. width: 100%;
  554. height: 100vh;
  555. position: absolute;
  556. top: 0;
  557. z-index: 99999;
  558. .mengban {
  559. width: 100%;
  560. height: 100vh;
  561. position: absolute;
  562. top: 0;
  563. background-color: rgba($color: #000000, $alpha: 0.5);
  564. }
  565. .set_http {
  566. position: absolute;
  567. width: 90%;
  568. left: 5%;
  569. top: 30%;
  570. .set_http_top {
  571. display: flex;
  572. justify-content: space-around;
  573. background-color: #5dc18b;
  574. height: 60px;
  575. line-height: 60px;
  576. color: #ffffff;
  577. border-top-right-radius: 20px;
  578. border-top-left-radius: 20px;
  579. font-size: 32rpx;
  580. }
  581. .set_http_bot {
  582. height: 150px;
  583. background-color: #ffffff;
  584. border-bottom-right-radius: 20px;
  585. border-bottom-left-radius: 20px;
  586. padding: 30px;
  587. .set_http_bot_input {
  588. margin-top: 20rpx;
  589. border: 2rpx solid #bdb6a6;
  590. border-radius: 20rpx;
  591. padding: 10rpx 40rpx 0 20rpx;
  592. font-size: 32rpx;
  593. height: 30px;
  594. display: flex;
  595. justify-content: space-between;
  596. input {
  597. width: 90%;
  598. }
  599. }
  600. }
  601. .scroll-Y {
  602. border: 2rpx solid #d0d0d0;
  603. border-radius: 20rpx;
  604. .scroll-view-item {
  605. padding-left: 20rpx;
  606. height: 70rpx;
  607. font-size: 28rpx;
  608. line-height: 70rpx;
  609. border-bottom: 2rpx solid #d0d0d0;
  610. }
  611. }
  612. }
  613. }
  614. .upgradeBox {
  615. padding: 15rpx;
  616. }
  617. .agreement {
  618. width: 80%;
  619. margin: 40rpx auto 0;
  620. display: flex;
  621. align-items: center;
  622. justify-content: center;
  623. /deep/.u-checkbox__label {
  624. font-size: 24rpx;
  625. color: #fff;
  626. margin-right: 0;
  627. }
  628. /deep/.u-checkbox__icon-wrap {
  629. border-color: rgba(255, 255, 255, 0.8);
  630. }
  631. .agree-link {
  632. font-size: 24rpx;
  633. color: #fff;
  634. text-decoration: underline;
  635. }
  636. }
  637. </style>