login.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  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="$imageURL+ '/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'],
  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. const res = await this.$myRequest({
  303. url: '/api/api_gateway?method=user.login.login_user',
  304. data: {
  305. username: this.formdata.username,
  306. password: this.formdata.passwold,
  307. },
  308. });
  309. let session_key = res.session_key;
  310. uni.setStorage({
  311. key: 'session_key',
  312. data: session_key,
  313. success: () => {
  314. uni.switchTab({
  315. url: '../index/index',
  316. });
  317. },
  318. });
  319. },
  320. passwoldddata() {
  321. this.formdata.passwold = this.formdata.passwold.replace(
  322. /[\u4E00-\u9FA5]/g,
  323. ''
  324. );
  325. },
  326. rempass(val) {
  327. this.passvalue = val.value;
  328. if (val.value) {
  329. uni.setStorage({
  330. key: 'user_pass',
  331. data: this.formdata.passwold,
  332. success: function () {
  333. console.log('success');
  334. },
  335. });
  336. }
  337. },
  338. blur(val) {
  339. uni.setStorage({
  340. key: 'user_name',
  341. data: val,
  342. success: function () {
  343. console.log('success');
  344. },
  345. });
  346. },
  347. logoTime() {
  348. this.setTF = true;
  349. },
  350. set() {
  351. this.setbgtf = true;
  352. },
  353. sethttp() {
  354. uni.setStorage({
  355. key: 'http',
  356. data: this.value,
  357. success: () => {
  358. // console.log(this.value);
  359. this.setbgtf = false;
  360. uni.showToast({
  361. title: '修改成功',
  362. icon: 'none',
  363. });
  364. this.getEquipList();
  365. uni.removeStorage({
  366. key: 'session_key',
  367. });
  368. },
  369. });
  370. },
  371. arrow() {
  372. this.arrowtf = !this.arrowtf;
  373. },
  374. denglu() {
  375. if (this.passvalue) {
  376. uni.setStorage({
  377. key: 'user_pass',
  378. data: this.formdata.passwold,
  379. success: function () {
  380. console.log('success');
  381. },
  382. });
  383. } else {
  384. uni.removeStorage({
  385. key: 'user_pass',
  386. success: function () {
  387. console.log('success');
  388. },
  389. });
  390. }
  391. },
  392. },
  393. };
  394. </script>
  395. <style lang="scss">
  396. .bg-img {
  397. height: 100vh;
  398. background-image: url(../../static/images/login/bg.png);
  399. background-size: 100% 100%;
  400. padding-top: 500rpx;
  401. box-sizing: border-box;
  402. }
  403. .apptitle {
  404. font-size: 52rpx;
  405. color: #fff;
  406. width: 80%;
  407. margin: 0 auto 40rpx;
  408. }
  409. .logo {
  410. width: 100%;
  411. height: 340rpx;
  412. text-align: center;
  413. display: flex;
  414. align-items: center;
  415. padding-top: 240rpx;
  416. image {
  417. width: 280rpx;
  418. margin: 0 auto;
  419. height: 120rpx;
  420. }
  421. }
  422. .set {
  423. position: absolute;
  424. right: 50rpx;
  425. top: 150rpx;
  426. }
  427. .bg {
  428. width: 100%;
  429. position: fixed;
  430. bottom: 0;
  431. left: 0;
  432. z-index: -1;
  433. image {
  434. width: 100%;
  435. }
  436. }
  437. ::v-deep .u-input__right-icon {
  438. line-height: 35px !important;
  439. }
  440. .uni-form-item {
  441. width: 100%;
  442. .username {
  443. width: 80%;
  444. margin: 0 auto;
  445. display: flex;
  446. margin-bottom: 40rpx;
  447. padding-bottom: 10rpx;
  448. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  449. .u-icon__icon {
  450. margin-top: 17rpx;
  451. }
  452. .uni-input {
  453. width: 100%;
  454. color: #fff;
  455. }
  456. ::v-deep .uni-input-input {
  457. color: #fff;
  458. }
  459. }
  460. .passwold {
  461. width: 80%;
  462. margin: 0 auto;
  463. display: flex;
  464. margin-bottom: 40rpx;
  465. padding-bottom: 10rpx;
  466. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  467. .u-icon__icon {
  468. margin-top: 17rpx;
  469. }
  470. ::v-deep .uni-input-input {
  471. color: #fff;
  472. }
  473. .uni-input {
  474. width: 100%;
  475. color: #fff;
  476. }
  477. ::v-deep .uicon-eye {
  478. color: #fff !important;
  479. }
  480. }
  481. .aboutpass {
  482. width: 80%;
  483. margin: 0 auto;
  484. display: flex;
  485. justify-content: flex-end;
  486. p {
  487. color: #fff;
  488. font-size: 28rpx;
  489. }
  490. ::v-deep .uicon-checkbox-mark {
  491. border-color: #ff0000;
  492. // color: #f00 !important;
  493. }
  494. ::v-deep .u-checkbox__label {
  495. font-size: 28rpx;
  496. color: #fff;
  497. margin-right: 0;
  498. }
  499. }
  500. .uni-btn-v {
  501. width: 80%;
  502. margin: 112rpx auto 0;
  503. position: relative;
  504. z-index: 100;
  505. button {
  506. width: 100%;
  507. height: 90rpx;
  508. line-height: 90rpx;
  509. color: #ffffff;
  510. font-size: 36rpx;
  511. background-image: linear-gradient(
  512. to bottom,
  513. rgba(249, 249, 249, 0.6),
  514. rgba(249, 249, 249, 0.1)
  515. );
  516. color: #5dc18b;
  517. }
  518. }
  519. }
  520. .setbg {
  521. width: 100%;
  522. height: 100vh;
  523. position: absolute;
  524. top: 0;
  525. z-index: 99999;
  526. .mengban {
  527. width: 100%;
  528. height: 100vh;
  529. position: absolute;
  530. top: 0;
  531. background-color: rgba($color: #000000, $alpha: 0.5);
  532. }
  533. .set_http {
  534. position: absolute;
  535. width: 90%;
  536. left: 5%;
  537. top: 30%;
  538. .set_http_top {
  539. display: flex;
  540. justify-content: space-around;
  541. background-color: #5dc18b;
  542. height: 60px;
  543. line-height: 60px;
  544. color: #ffffff;
  545. border-top-right-radius: 20px;
  546. border-top-left-radius: 20px;
  547. font-size: 32rpx;
  548. }
  549. .set_http_bot {
  550. height: 150px;
  551. background-color: #ffffff;
  552. border-bottom-right-radius: 20px;
  553. border-bottom-left-radius: 20px;
  554. padding: 30px;
  555. .set_http_bot_input {
  556. margin-top: 20rpx;
  557. border: 2rpx solid #bdb6a6;
  558. border-radius: 20rpx;
  559. padding: 10rpx 40rpx 0 20rpx;
  560. font-size: 32rpx;
  561. height: 30px;
  562. display: flex;
  563. justify-content: space-between;
  564. input {
  565. width: 90%;
  566. }
  567. }
  568. }
  569. .scroll-Y {
  570. border: 2rpx solid #d0d0d0;
  571. border-radius: 20rpx;
  572. .scroll-view-item {
  573. padding-left: 20rpx;
  574. height: 70rpx;
  575. font-size: 28rpx;
  576. line-height: 70rpx;
  577. border-bottom: 2rpx solid #d0d0d0;
  578. }
  579. }
  580. }
  581. }
  582. .upgradeBox {
  583. padding: 15rpx;
  584. }
  585. </style>