login.vue 15 KB

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