login.vue 12 KB

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