login.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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="'https://s3.hnyfwlw.com/webstaticimg/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. debugger
  268. this.passvalue = val.value
  269. if (val.value) {
  270. uni.setStorage({
  271. key: 'user_pass',
  272. data: this.formdata.passwold,
  273. success: function() {
  274. console.log('success');
  275. }
  276. })
  277. }
  278. },
  279. blur(val) {
  280. uni.setStorage({
  281. key: 'user_name',
  282. data: val,
  283. success: function() {
  284. console.log('success');
  285. }
  286. })
  287. },
  288. logoTime() {
  289. this.setTF = true
  290. },
  291. set() {
  292. this.setbgtf = true
  293. },
  294. sethttp() {
  295. uni.setStorage({
  296. key: 'http',
  297. data: this.value,
  298. success: () => {
  299. // console.log(this.value);
  300. this.setbgtf = false
  301. uni.showToast({
  302. title: "修改成功",
  303. icon: "none"
  304. })
  305. this.getEquipList()
  306. uni.removeStorage({
  307. key: "session_key"
  308. })
  309. }
  310. });
  311. },
  312. arrow() {
  313. this.arrowtf = !this.arrowtf
  314. },
  315. denglu() {
  316. if (this.passvalue) {
  317. uni.setStorage({
  318. key: 'user_pass',
  319. data: this.formdata.passwold,
  320. success: function() {
  321. console.log('success');
  322. }
  323. })
  324. } else {
  325. uni.removeStorage({
  326. key: 'user_pass',
  327. success: function() {
  328. console.log('success');
  329. }
  330. })
  331. }
  332. }
  333. }
  334. }
  335. </script>
  336. <style lang="scss">
  337. page{
  338. background-image: url(../../static/images/login/bg.png);
  339. background-size: 100% 100%;
  340. padding-top: 700rpx;
  341. }
  342. .apptitle{
  343. font-size: 52rpx;
  344. color: #fff;
  345. width: 80%;
  346. margin: 0 auto 40rpx;
  347. }
  348. .logo {
  349. width: 100%;
  350. height: 340rpx;
  351. text-align: center;
  352. display: flex;
  353. align-items: center;
  354. padding-top: 240rpx;
  355. image {
  356. width: 280rpx;
  357. margin: 0 auto;
  358. height: 120rpx;
  359. }
  360. }
  361. .set {
  362. position: absolute;
  363. right: 50rpx;
  364. top: 150rpx;
  365. }
  366. .bg {
  367. width: 100%;
  368. position: fixed;
  369. bottom: 0;
  370. left: 0;
  371. z-index: -1;
  372. image {
  373. width: 100%;
  374. }
  375. }
  376. ::v-deep .u-input__right-icon {
  377. line-height: 35px !important;
  378. }
  379. .uni-form-item {
  380. width: 100%;
  381. .username {
  382. width: 80%;
  383. margin: 0 auto;
  384. display: flex;
  385. margin-bottom: 40rpx;
  386. padding-bottom: 10rpx;
  387. border-bottom: 2rpx solid rgba(249,249,249,0.4);
  388. .u-icon__icon {
  389. margin-top: 17rpx;
  390. }
  391. .uni-input {
  392. width: 100%;
  393. color: #fff;
  394. }
  395. ::v-deep .uni-input-input{
  396. color: #fff;
  397. }
  398. }
  399. .passwold {
  400. width: 80%;
  401. margin: 0 auto;
  402. display: flex;
  403. margin-bottom: 40rpx;
  404. padding-bottom: 10rpx;
  405. border-bottom: 2rpx solid rgba(249,249,249,0.4);
  406. .u-icon__icon {
  407. margin-top: 17rpx;
  408. }
  409. ::v-deep .uni-input-input{
  410. color: #fff;
  411. }
  412. .uni-input {
  413. width: 100%;
  414. color: #fff;
  415. }
  416. ::v-deep .uicon-eye{
  417. color: #fff !important;
  418. }
  419. }
  420. .aboutpass {
  421. width: 80%;
  422. margin: 0 auto;
  423. display: flex;
  424. justify-content: flex-end;
  425. p {
  426. color: #fff;
  427. font-size: 28rpx;
  428. }
  429. ::v-deep .uicon-checkbox-mark{
  430. border-color: #FF0000;
  431. // color: #f00 !important;
  432. }
  433. ::v-deep .u-checkbox__label {
  434. font-size: 28rpx;
  435. color: #fff;
  436. margin-right: 0;
  437. }
  438. }
  439. .uni-btn-v {
  440. width: 80%;
  441. margin: 112rpx auto 0;
  442. position: relative;
  443. z-index: 100;
  444. button {
  445. width: 100%;
  446. height: 90rpx;
  447. line-height: 90rpx;
  448. color: #FFFFFF;
  449. font-size: 36rpx;
  450. background-image: linear-gradient(to bottom, rgba(249,249,249,0.6), rgba(249, 249, 249, 0.1));
  451. color: #5DC18B;
  452. }
  453. }
  454. }
  455. .setbg {
  456. width: 100%;
  457. height: 100vh;
  458. position: absolute;
  459. top: 0;
  460. z-index: 99999;
  461. .mengban {
  462. width: 100%;
  463. height: 100vh;
  464. position: absolute;
  465. top: 0;
  466. background-color: rgba($color: #000000, $alpha: 0.5);
  467. }
  468. .set_http {
  469. position: absolute;
  470. width: 90%;
  471. left: 5%;
  472. top: 30%;
  473. .set_http_top {
  474. display: flex;
  475. justify-content: space-around;
  476. background-color: #5DC18B;
  477. height: 60px;
  478. line-height: 60px;
  479. color: #FFFFFF;
  480. border-top-right-radius: 20px;
  481. border-top-left-radius: 20px;
  482. font-size: 32rpx;
  483. }
  484. .set_http_bot {
  485. height: 150px;
  486. background-color: #FFFFFF;
  487. border-bottom-right-radius: 20px;
  488. border-bottom-left-radius: 20px;
  489. padding: 30px;
  490. .set_http_bot_input {
  491. margin-top: 20rpx;
  492. border: 2rpx solid #bdb6a6;
  493. border-radius: 20rpx;
  494. padding: 10rpx 40rpx 0 20rpx;
  495. font-size: 32rpx;
  496. height: 30px;
  497. display: flex;
  498. justify-content: space-between;
  499. input {
  500. width: 90%;
  501. }
  502. }
  503. }
  504. .scroll-Y {
  505. border: 2rpx solid #d0d0d0;
  506. border-radius: 20rpx;
  507. .scroll-view-item {
  508. padding-left: 20rpx;
  509. height: 70rpx;
  510. font-size: 28rpx;
  511. line-height: 70rpx;
  512. border-bottom: 2rpx solid #d0d0d0;
  513. }
  514. }
  515. }
  516. }
  517. .upgradeBox {
  518. padding: 15rpx;
  519. }
  520. </style>