login.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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: true,
  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. uni.getStorage({
  122. key: 'showTip',
  123. success: (res) => {
  124. if (res.data) {
  125. this.tipshow = !res.data;
  126. } else {
  127. this.tipshow = true;
  128. }
  129. }
  130. })
  131. uni.getStorage({
  132. key: 'user_pass',
  133. success: (res) => {
  134. if (res.data) {
  135. this.formdata.passwold = res.data
  136. this.checked = true
  137. } else {
  138. this.checked = false
  139. }
  140. }
  141. })
  142. uni.getStorage({
  143. key: 'user_name',
  144. success: (res) => {
  145. this.formdata.username = res.data
  146. }
  147. })
  148. uni.getStorage({
  149. key: 'http',
  150. success: (res) => {
  151. this.value = res.data
  152. }
  153. })
  154. console.log(this.value)
  155. uni.getStorage({
  156. key: 'turnover',
  157. success: (res) => {
  158. console.log(res.data)
  159. this.turnover = res.data
  160. }
  161. })
  162. this.getEquipList()
  163. },
  164. methods: {
  165. openExternalLink(url) {
  166. plus.runtime.openURL(url);
  167. },
  168. agreeTip() {
  169. this.tipshow = false;
  170. uni.setStorage({
  171. key: "showTip",
  172. data: true,
  173. })
  174. },
  175. quitApp() {
  176. plus.runtime.quit();
  177. },
  178. checkboxChange(e) {
  179. this.isAgree = e.value;
  180. },
  181. async getEquipList() {
  182. const res = await this.$myRequest({
  183. url: '/api/api_gateway?method=home.homes.app_version_record',
  184. data: {
  185. ret: "first"
  186. }
  187. })
  188. console.log(res)
  189. this.appName = res[0].app_name
  190. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  191. let id = Number(plus.runtime.version.match(/\d+/g).join(""))
  192. console.log(this.versions, plus.runtime.version)
  193. if (this.percentNum > 0) {
  194. console.log("更新中")
  195. } else {
  196. console.log(this.turnover)
  197. if (this.turnover) {
  198. if (this.versions > id) {
  199. uni.showModal({
  200. title: '检测到有新版本,是否更新?',
  201. content: '建议更新,不更新可能会出现部分数据无法获取!',
  202. confirmText: "更新",
  203. cancelText: "不更新",
  204. success: (res) => {
  205. if (res.confirm) {
  206. console.log('用户点击确定');
  207. this.showA = true
  208. this.isShow = true
  209. this.upgrade()
  210. } else if (res.cancel) {
  211. // plus.runtime.quit();
  212. console.log('用户点击取消');
  213. uni.showModal({
  214. title: '是否每次进入提示更新?',
  215. content: '不再提示后可在<我的>-<关于我们>-<版本更新>中更新',
  216. confirmText: "提示",
  217. cancelText: "不再提示",
  218. success: (res) => {
  219. if (res.confirm) {
  220. console.log('用户点击确定');
  221. uni.setStorage({
  222. key: "turnover",
  223. data: true,
  224. })
  225. } else if (res.cancel) {
  226. uni.setStorage({
  227. key: "turnover",
  228. data: false,
  229. })
  230. }
  231. }
  232. })
  233. }
  234. }
  235. })
  236. } else {
  237. uni.getStorage({
  238. key: 'session_key',
  239. success: (res) => {
  240. console.log(res)
  241. if (res.data != "") {
  242. uni.switchTab({
  243. url: "../index/index"
  244. })
  245. }
  246. },
  247. })
  248. }
  249. } else {
  250. uni.getStorage({
  251. key: 'session_key',
  252. success: (res) => {
  253. console.log(res)
  254. if (res.data != "") {
  255. uni.switchTab({
  256. url: "../index/index"
  257. })
  258. }
  259. },
  260. })
  261. }
  262. }
  263. },
  264. upgrade() {
  265. console.log(this.appName)
  266. // var url = this.value + "/app_file/" + this.appName
  267. var appName = ""
  268. if (this.$isneutral) {
  269. appName = "big_data" //云飞
  270. } else {
  271. appName = "big_data2" //中性
  272. }
  273. var url = "http://hnyfwlw.com/app/" + appName + ".apk"
  274. const downloadTask = uni.downloadFile({
  275. url: url, //仅为示例,并非真实的资源
  276. success: (res) => {
  277. console.log(res)
  278. if (res.statusCode === 200) {
  279. console.log('下载成功');
  280. console.log('安装包下载成功,即将安装:' + JSON.stringify(res, null, 4));
  281. plus.runtime.openFile(res.tempFilePath);
  282. this.showA = false
  283. this.isShow = false
  284. }
  285. },
  286. fail: (err) => {
  287. console.log(err)
  288. },
  289. complete: (com) => {
  290. console.log(com)
  291. }
  292. });
  293. downloadTask.onProgressUpdate((res) => {
  294. this.percentNum = res.progress
  295. if (res.progress == 100) {
  296. console.log('下载完成了')
  297. }
  298. });
  299. },
  300. async formSubmit() {
  301. if(!this.isAgree) {
  302. uni.showToast({
  303. title: "请先阅读并同意服务协议、隐私协议",
  304. icon: "error"
  305. })
  306. return
  307. }
  308. console.log(11111)
  309. const res = await this.$myRequest({
  310. url: '/api/api_gateway?method=user.login.login_user',
  311. data: {
  312. username: this.formdata.username,
  313. password: this.formdata.passwold
  314. }
  315. })
  316. console.log(res.session_key)
  317. let session_key = res.session_key
  318. uni.setStorage({
  319. key: 'session_key',
  320. data: session_key,
  321. success: () => {
  322. uni.switchTab({
  323. url: "../index/index"
  324. })
  325. }
  326. })
  327. },
  328. passwoldddata() {
  329. this.formdata.passwold = this.formdata.passwold.replace(/[\u4E00-\u9FA5]/g, '')
  330. },
  331. rempass(val) {
  332. debugger
  333. this.passvalue = val.value
  334. if (val.value) {
  335. uni.setStorage({
  336. key: 'user_pass',
  337. data: this.formdata.passwold,
  338. success: function() {
  339. console.log('success');
  340. }
  341. })
  342. }
  343. },
  344. blur(val) {
  345. uni.setStorage({
  346. key: 'user_name',
  347. data: val,
  348. success: function() {
  349. console.log('success');
  350. }
  351. })
  352. },
  353. logoTime() {
  354. this.setTF = true
  355. },
  356. set() {
  357. this.setbgtf = true
  358. },
  359. sethttp() {
  360. uni.setStorage({
  361. key: 'http',
  362. data: this.value,
  363. success: () => {
  364. // console.log(this.value);
  365. this.setbgtf = false
  366. uni.showToast({
  367. title: "修改成功",
  368. icon: "none"
  369. })
  370. this.getEquipList()
  371. uni.removeStorage({
  372. key: "session_key"
  373. })
  374. }
  375. });
  376. },
  377. arrow() {
  378. this.arrowtf = !this.arrowtf
  379. },
  380. denglu() {
  381. if (this.passvalue) {
  382. uni.setStorage({
  383. key: 'user_pass',
  384. data: this.formdata.passwold,
  385. success: function() {
  386. console.log('success');
  387. }
  388. })
  389. } else {
  390. uni.removeStorage({
  391. key: 'user_pass',
  392. success: function() {
  393. console.log('success');
  394. }
  395. })
  396. }
  397. }
  398. }
  399. }
  400. </script>
  401. <style lang="scss">
  402. page {
  403. background-image: url(../../static/images/login/bg.png);
  404. background-size: 100% 100%;
  405. padding-top: 700rpx;
  406. }
  407. .tipContent{
  408. padding: 40rpx 20rpx;
  409. .header{
  410. text-align: center;
  411. font-size: 30px;
  412. color: #3e3e3e;
  413. a{
  414. color: #3e3e3e;
  415. }
  416. }
  417. .tipinfo{
  418. line-height: 52rpx;
  419. margin-top: 20rpx;
  420. .tipTextBtn{
  421. display: inline-block;
  422. color: #2979ff;
  423. text-decoration: underline; /* 添加下划线 */
  424. }
  425. }
  426. .btnBox{
  427. display: flex;
  428. flex-direction: column;
  429. .u-btn{
  430. width: 100%;
  431. margin-top: 20rpx;
  432. }
  433. }
  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. /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. /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. /deep/.uni-input-input {
  503. color: #fff;
  504. }
  505. .uni-input {
  506. width: 100%;
  507. color: #fff;
  508. }
  509. /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. /deep/.uicon-checkbox-mark {
  523. border-color: #FF0000;
  524. // color: #f00 !important;
  525. }
  526. /deep/.u-checkbox__label {
  527. font-size: 28rpx;
  528. color: #fff;
  529. margin-right: 0;
  530. }
  531. }
  532. .checkInfo{
  533. width: 80%;
  534. margin: 0 auto;
  535. display: flex;
  536. align-items: center;
  537. color: #fff;
  538. a{
  539. color: #2979ff;
  540. }
  541. }
  542. .uni-btn-v {
  543. width: 80%;
  544. margin: 112rpx auto 0;
  545. position: relative;
  546. z-index: 100;
  547. button {
  548. width: 100%;
  549. height: 90rpx;
  550. line-height: 90rpx;
  551. color: #FFFFFF;
  552. font-size: 36rpx;
  553. background-image: linear-gradient(to bottom, rgba(249, 249, 249, 0.6), rgba(249, 249, 249, 0.1));
  554. color: #5DC18B;
  555. }
  556. }
  557. }
  558. .setbg {
  559. width: 100%;
  560. height: 100vh;
  561. position: absolute;
  562. top: 0;
  563. z-index: 99999;
  564. .mengban {
  565. width: 100%;
  566. height: 100vh;
  567. position: absolute;
  568. top: 0;
  569. background-color: rgba($color: #000000, $alpha: 0.5);
  570. }
  571. .set_http {
  572. position: absolute;
  573. width: 90%;
  574. left: 5%;
  575. top: 30%;
  576. .set_http_top {
  577. display: flex;
  578. justify-content: space-around;
  579. background-color: #5DC18B;
  580. height: 60px;
  581. line-height: 60px;
  582. color: #FFFFFF;
  583. border-top-right-radius: 20px;
  584. border-top-left-radius: 20px;
  585. font-size: 32rpx;
  586. }
  587. .set_http_bot {
  588. height: 150px;
  589. background-color: #FFFFFF;
  590. border-bottom-right-radius: 20px;
  591. border-bottom-left-radius: 20px;
  592. padding: 30px;
  593. .set_http_bot_input {
  594. margin-top: 20rpx;
  595. border: 2rpx solid #bdb6a6;
  596. border-radius: 20rpx;
  597. padding: 10rpx 40rpx 0 20rpx;
  598. font-size: 32rpx;
  599. height: 30px;
  600. display: flex;
  601. justify-content: space-between;
  602. input {
  603. width: 90%;
  604. }
  605. }
  606. }
  607. .scroll-Y {
  608. border: 2rpx solid #d0d0d0;
  609. border-radius: 20rpx;
  610. .scroll-view-item {
  611. padding-left: 20rpx;
  612. height: 70rpx;
  613. font-size: 28rpx;
  614. line-height: 70rpx;
  615. border-bottom: 2rpx solid #d0d0d0;
  616. }
  617. }
  618. }
  619. }
  620. .upgradeBox {
  621. padding: 15rpx;
  622. }
  623. </style>