login.vue 15 KB

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