login.vue 12 KB

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