login.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  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. <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,this.formdata)
  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. page{
  337. background-image: url(../../static/images/login/bg.png);
  338. background-size: 100% 100%;
  339. padding-top: 700rpx;
  340. }
  341. .apptitle{
  342. font-size: 52rpx;
  343. color: #fff;
  344. width: 80%;
  345. margin: 0 auto 40rpx;
  346. }
  347. .logo {
  348. width: 100%;
  349. height: 340rpx;
  350. text-align: center;
  351. display: flex;
  352. align-items: center;
  353. padding-top: 240rpx;
  354. image {
  355. width: 280rpx;
  356. margin: 0 auto;
  357. height: 120rpx;
  358. }
  359. }
  360. .set {
  361. position: absolute;
  362. right: 50rpx;
  363. top: 150rpx;
  364. }
  365. .bg {
  366. width: 100%;
  367. position: fixed;
  368. bottom: 0;
  369. left: 0;
  370. z-index: -1;
  371. image {
  372. width: 100%;
  373. }
  374. }
  375. /deep/.u-input__right-icon {
  376. line-height: 35px !important;
  377. }
  378. .uni-form-item {
  379. width: 100%;
  380. .username {
  381. width: 80%;
  382. margin: 0 auto;
  383. display: flex;
  384. margin-bottom: 40rpx;
  385. padding-bottom: 10rpx;
  386. border-bottom: 2rpx solid rgba(249,249,249,0.4);
  387. .u-icon__icon {
  388. margin-top: 17rpx;
  389. }
  390. .uni-input {
  391. width: 100%;
  392. color: #fff;
  393. }
  394. /deep/.uni-input-input{
  395. color: #fff;
  396. }
  397. }
  398. .passwold {
  399. width: 80%;
  400. margin: 0 auto;
  401. display: flex;
  402. margin-bottom: 40rpx;
  403. padding-bottom: 10rpx;
  404. border-bottom: 2rpx solid rgba(249,249,249,0.4);
  405. .u-icon__icon {
  406. margin-top: 17rpx;
  407. }
  408. /deep/.uni-input-input{
  409. color: #fff;
  410. }
  411. .uni-input {
  412. width: 100%;
  413. color: #fff;
  414. }
  415. /deep/.uicon-eye{
  416. color: #fff !important;
  417. }
  418. }
  419. .aboutpass {
  420. width: 80%;
  421. margin: 0 auto;
  422. display: flex;
  423. justify-content: flex-end;
  424. p {
  425. color: #fff;
  426. font-size: 28rpx;
  427. }
  428. /deep/.uicon-checkbox-mark{
  429. border-color: #FF0000;
  430. // color: #f00 !important;
  431. }
  432. /deep/.u-checkbox__label {
  433. font-size: 28rpx;
  434. color: #fff;
  435. margin-right: 0;
  436. }
  437. }
  438. .uni-btn-v {
  439. width: 80%;
  440. margin: 112rpx auto 0;
  441. position: relative;
  442. z-index: 100;
  443. button {
  444. width: 100%;
  445. height: 90rpx;
  446. line-height: 90rpx;
  447. color: #FFFFFF;
  448. font-size: 36rpx;
  449. background-image: linear-gradient(to bottom, rgba(249,249,249,0.6), rgba(249, 249, 249, 0.1));
  450. color: #5DC18B;
  451. }
  452. }
  453. }
  454. .setbg {
  455. width: 100%;
  456. height: 100vh;
  457. position: absolute;
  458. top: 0;
  459. z-index: 99999;
  460. .mengban {
  461. width: 100%;
  462. height: 100vh;
  463. position: absolute;
  464. top: 0;
  465. background-color: rgba($color: #000000, $alpha: 0.5);
  466. }
  467. .set_http {
  468. position: absolute;
  469. width: 90%;
  470. left: 5%;
  471. top: 30%;
  472. .set_http_top {
  473. display: flex;
  474. justify-content: space-around;
  475. background-color: #5DC18B;
  476. height: 60px;
  477. line-height: 60px;
  478. color: #FFFFFF;
  479. border-top-right-radius: 20px;
  480. border-top-left-radius: 20px;
  481. font-size: 32rpx;
  482. }
  483. .set_http_bot {
  484. height: 150px;
  485. background-color: #FFFFFF;
  486. border-bottom-right-radius: 20px;
  487. border-bottom-left-radius: 20px;
  488. padding: 30px;
  489. .set_http_bot_input {
  490. margin-top: 20rpx;
  491. border: 2rpx solid #bdb6a6;
  492. border-radius: 20rpx;
  493. padding: 10rpx 40rpx 0 20rpx;
  494. font-size: 32rpx;
  495. height: 30px;
  496. display: flex;
  497. justify-content: space-between;
  498. input {
  499. width: 90%;
  500. }
  501. }
  502. }
  503. .scroll-Y {
  504. border: 2rpx solid #d0d0d0;
  505. border-radius: 20rpx;
  506. .scroll-view-item {
  507. padding-left: 20rpx;
  508. height: 70rpx;
  509. font-size: 28rpx;
  510. line-height: 70rpx;
  511. border-bottom: 2rpx solid #d0d0d0;
  512. }
  513. }
  514. }
  515. }
  516. .upgradeBox {
  517. padding: 15rpx;
  518. }
  519. </style>