login.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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. <a href="http://8.136.98.49:8002/safe_negotiate/">隐私政策</a>
  15. </view>
  16. <view class="tipinfo">
  17. 本应用尊重并保护所有用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照隐私政策的规定使用和披露您的个人信息。可阅读 <a href="http://8.136.98.49:8002/service_negotiate/">服务协议</a>和<a href="http://8.136.98.49:8002/safe_negotiate/">隐私政策</a>。
  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. agreeTip() {
  166. this.tipshow = false;
  167. uni.setStorage({
  168. key: "showTip",
  169. data: true,
  170. })
  171. },
  172. quitApp() {
  173. plus.runtime.quit();
  174. },
  175. checkboxChange(e) {
  176. this.isAgree = e.value;
  177. },
  178. async getEquipList() {
  179. const res = await this.$myRequest({
  180. url: '/api/api_gateway?method=home.homes.app_version_record',
  181. data: {
  182. ret: "first"
  183. }
  184. })
  185. console.log(res)
  186. this.appName = res[0].app_name
  187. this.versions = Number(res[0].app_num.match(/\d+/g).join(""))
  188. let id = Number(plus.runtime.version.match(/\d+/g).join(""))
  189. console.log(this.versions, plus.runtime.version)
  190. if (this.percentNum > 0) {
  191. console.log("更新中")
  192. } else {
  193. console.log(this.turnover)
  194. if (this.turnover) {
  195. if (this.versions > id) {
  196. uni.showModal({
  197. title: '检测到有新版本,是否更新?',
  198. content: '建议更新,不更新可能会出现部分数据无法获取!',
  199. confirmText: "更新",
  200. cancelText: "不更新",
  201. success: (res) => {
  202. if (res.confirm) {
  203. console.log('用户点击确定');
  204. this.showA = true
  205. this.isShow = true
  206. this.upgrade()
  207. } else if (res.cancel) {
  208. // plus.runtime.quit();
  209. console.log('用户点击取消');
  210. uni.showModal({
  211. title: '是否每次进入提示更新?',
  212. content: '不再提示后可在<我的>-<关于我们>-<版本更新>中更新',
  213. confirmText: "提示",
  214. cancelText: "不再提示",
  215. success: (res) => {
  216. if (res.confirm) {
  217. console.log('用户点击确定');
  218. uni.setStorage({
  219. key: "turnover",
  220. data: true,
  221. })
  222. } else if (res.cancel) {
  223. uni.setStorage({
  224. key: "turnover",
  225. data: false,
  226. })
  227. }
  228. }
  229. })
  230. }
  231. }
  232. })
  233. } else {
  234. uni.getStorage({
  235. key: 'session_key',
  236. success: (res) => {
  237. console.log(res)
  238. if (res.data != "") {
  239. uni.switchTab({
  240. url: "../index/index"
  241. })
  242. }
  243. },
  244. })
  245. }
  246. } else {
  247. uni.getStorage({
  248. key: 'session_key',
  249. success: (res) => {
  250. console.log(res)
  251. if (res.data != "") {
  252. uni.switchTab({
  253. url: "../index/index"
  254. })
  255. }
  256. },
  257. })
  258. }
  259. }
  260. },
  261. upgrade() {
  262. console.log(this.appName)
  263. // var url = this.value + "/app_file/" + this.appName
  264. var appName = ""
  265. if (this.$isneutral) {
  266. appName = "big_data" //云飞
  267. } else {
  268. appName = "big_data2" //中性
  269. }
  270. var url = "http://hnyfwlw.com/app/" + appName + ".apk"
  271. const downloadTask = uni.downloadFile({
  272. url: url, //仅为示例,并非真实的资源
  273. success: (res) => {
  274. console.log(res)
  275. if (res.statusCode === 200) {
  276. console.log('下载成功');
  277. console.log('安装包下载成功,即将安装:' + JSON.stringify(res, null, 4));
  278. plus.runtime.openFile(res.tempFilePath);
  279. this.showA = false
  280. this.isShow = false
  281. }
  282. },
  283. fail: (err) => {
  284. console.log(err)
  285. },
  286. complete: (com) => {
  287. console.log(com)
  288. }
  289. });
  290. downloadTask.onProgressUpdate((res) => {
  291. this.percentNum = res.progress
  292. if (res.progress == 100) {
  293. console.log('下载完成了')
  294. }
  295. });
  296. },
  297. async formSubmit() {
  298. if(!this.isAgree) {
  299. uni.showToast({
  300. title: "请先阅读并同意服务协议、隐私协议",
  301. icon: "error"
  302. })
  303. return
  304. }
  305. console.log(11111)
  306. const res = await this.$myRequest({
  307. url: '/api/api_gateway?method=user.login.login_user',
  308. data: {
  309. username: this.formdata.username,
  310. password: this.formdata.passwold
  311. }
  312. })
  313. console.log(res.session_key)
  314. let session_key = res.session_key
  315. uni.setStorage({
  316. key: 'session_key',
  317. data: session_key,
  318. success: () => {
  319. uni.switchTab({
  320. url: "../index/index"
  321. })
  322. }
  323. })
  324. },
  325. passwoldddata() {
  326. this.formdata.passwold = this.formdata.passwold.replace(/[\u4E00-\u9FA5]/g, '')
  327. },
  328. rempass(val) {
  329. debugger
  330. this.passvalue = val.value
  331. if (val.value) {
  332. uni.setStorage({
  333. key: 'user_pass',
  334. data: this.formdata.passwold,
  335. success: function() {
  336. console.log('success');
  337. }
  338. })
  339. }
  340. },
  341. blur(val) {
  342. uni.setStorage({
  343. key: 'user_name',
  344. data: val,
  345. success: function() {
  346. console.log('success');
  347. }
  348. })
  349. },
  350. logoTime() {
  351. this.setTF = true
  352. },
  353. set() {
  354. this.setbgtf = true
  355. },
  356. sethttp() {
  357. uni.setStorage({
  358. key: 'http',
  359. data: this.value,
  360. success: () => {
  361. // console.log(this.value);
  362. this.setbgtf = false
  363. uni.showToast({
  364. title: "修改成功",
  365. icon: "none"
  366. })
  367. this.getEquipList()
  368. uni.removeStorage({
  369. key: "session_key"
  370. })
  371. }
  372. });
  373. },
  374. arrow() {
  375. this.arrowtf = !this.arrowtf
  376. },
  377. denglu() {
  378. if (this.passvalue) {
  379. uni.setStorage({
  380. key: 'user_pass',
  381. data: this.formdata.passwold,
  382. success: function() {
  383. console.log('success');
  384. }
  385. })
  386. } else {
  387. uni.removeStorage({
  388. key: 'user_pass',
  389. success: function() {
  390. console.log('success');
  391. }
  392. })
  393. }
  394. }
  395. }
  396. }
  397. </script>
  398. <style lang="scss">
  399. page {
  400. background-image: url(../../static/images/login/bg.png);
  401. background-size: 100% 100%;
  402. padding-top: 700rpx;
  403. }
  404. .tipContent{
  405. padding: 40rpx 20rpx;
  406. .header{
  407. text-align: center;
  408. font-size: 30px;
  409. color: #3e3e3e;
  410. a{
  411. color: #3e3e3e;
  412. }
  413. }
  414. .tipinfo{
  415. line-height: 52rpx;
  416. margin-top: 20rpx;
  417. }
  418. .btnBox{
  419. display: flex;
  420. flex-direction: column;
  421. .u-btn{
  422. width: 100%;
  423. margin-top: 20rpx;
  424. }
  425. }
  426. }
  427. .apptitle {
  428. font-size: 52rpx;
  429. color: #fff;
  430. width: 80%;
  431. margin: 0 auto 40rpx;
  432. }
  433. .logo {
  434. width: 100%;
  435. height: 340rpx;
  436. text-align: center;
  437. display: flex;
  438. align-items: center;
  439. padding-top: 240rpx;
  440. image {
  441. width: 280rpx;
  442. margin: 0 auto;
  443. height: 120rpx;
  444. }
  445. }
  446. .set {
  447. position: absolute;
  448. right: 50rpx;
  449. top: 150rpx;
  450. }
  451. .bg {
  452. width: 100%;
  453. position: fixed;
  454. bottom: 0;
  455. left: 0;
  456. z-index: -1;
  457. image {
  458. width: 100%;
  459. }
  460. }
  461. /deep/.u-input__right-icon {
  462. line-height: 35px !important;
  463. }
  464. .uni-form-item {
  465. width: 100%;
  466. .username {
  467. width: 80%;
  468. margin: 0 auto;
  469. display: flex;
  470. margin-bottom: 40rpx;
  471. padding-bottom: 10rpx;
  472. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  473. .u-icon__icon {
  474. margin-top: 17rpx;
  475. }
  476. .uni-input {
  477. width: 100%;
  478. color: #fff;
  479. }
  480. /deep/.uni-input-input {
  481. color: #fff;
  482. }
  483. }
  484. .passwold {
  485. width: 80%;
  486. margin: 0 auto;
  487. display: flex;
  488. margin-bottom: 40rpx;
  489. padding-bottom: 10rpx;
  490. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  491. .u-icon__icon {
  492. margin-top: 17rpx;
  493. }
  494. /deep/.uni-input-input {
  495. color: #fff;
  496. }
  497. .uni-input {
  498. width: 100%;
  499. color: #fff;
  500. }
  501. /deep/.uicon-eye {
  502. color: #fff !important;
  503. }
  504. }
  505. .aboutpass {
  506. width: 80%;
  507. margin: 0 auto;
  508. display: flex;
  509. justify-content: flex-end;
  510. p {
  511. color: #fff;
  512. font-size: 28rpx;
  513. }
  514. /deep/.uicon-checkbox-mark {
  515. border-color: #FF0000;
  516. // color: #f00 !important;
  517. }
  518. /deep/.u-checkbox__label {
  519. font-size: 28rpx;
  520. color: #fff;
  521. margin-right: 0;
  522. }
  523. }
  524. .checkInfo{
  525. width: 80%;
  526. margin: 0 auto;
  527. display: flex;
  528. align-items: center;
  529. color: #fff;
  530. a{
  531. color: #2979ff;
  532. }
  533. }
  534. .uni-btn-v {
  535. width: 80%;
  536. margin: 112rpx auto 0;
  537. position: relative;
  538. z-index: 100;
  539. button {
  540. width: 100%;
  541. height: 90rpx;
  542. line-height: 90rpx;
  543. color: #FFFFFF;
  544. font-size: 36rpx;
  545. background-image: linear-gradient(to bottom, rgba(249, 249, 249, 0.6), rgba(249, 249, 249, 0.1));
  546. color: #5DC18B;
  547. }
  548. }
  549. }
  550. .setbg {
  551. width: 100%;
  552. height: 100vh;
  553. position: absolute;
  554. top: 0;
  555. z-index: 99999;
  556. .mengban {
  557. width: 100%;
  558. height: 100vh;
  559. position: absolute;
  560. top: 0;
  561. background-color: rgba($color: #000000, $alpha: 0.5);
  562. }
  563. .set_http {
  564. position: absolute;
  565. width: 90%;
  566. left: 5%;
  567. top: 30%;
  568. .set_http_top {
  569. display: flex;
  570. justify-content: space-around;
  571. background-color: #5DC18B;
  572. height: 60px;
  573. line-height: 60px;
  574. color: #FFFFFF;
  575. border-top-right-radius: 20px;
  576. border-top-left-radius: 20px;
  577. font-size: 32rpx;
  578. }
  579. .set_http_bot {
  580. height: 150px;
  581. background-color: #FFFFFF;
  582. border-bottom-right-radius: 20px;
  583. border-bottom-left-radius: 20px;
  584. padding: 30px;
  585. .set_http_bot_input {
  586. margin-top: 20rpx;
  587. border: 2rpx solid #bdb6a6;
  588. border-radius: 20rpx;
  589. padding: 10rpx 40rpx 0 20rpx;
  590. font-size: 32rpx;
  591. height: 30px;
  592. display: flex;
  593. justify-content: space-between;
  594. input {
  595. width: 90%;
  596. }
  597. }
  598. }
  599. .scroll-Y {
  600. border: 2rpx solid #d0d0d0;
  601. border-radius: 20rpx;
  602. .scroll-view-item {
  603. padding-left: 20rpx;
  604. height: 70rpx;
  605. font-size: 28rpx;
  606. line-height: 70rpx;
  607. border-bottom: 2rpx solid #d0d0d0;
  608. }
  609. }
  610. }
  611. }
  612. .upgradeBox {
  613. padding: 15rpx;
  614. }
  615. </style>