login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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://182.92.193.64:8002"],
  75. arrowtf: false,
  76. showA: false, //
  77. contentA: '',
  78. isShow: false, //进度条
  79. percentNum: 0, //在线下载进度
  80. passvalue: false,
  81. turnover: false
  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, id)
  133. if (this.percentNum > 0) {
  134. console.log("更新中")
  135. } else {
  136. if (this.turnover) {
  137. if (this.versions > id) {
  138. uni.showModal({
  139. title: '检测到有新版本,是否更新?',
  140. content: '建议更新,不更新可能会出现部分数据无法获取!',
  141. confirmText: "更新",
  142. cancelText: "不更新",
  143. success: (res) => {
  144. if (res.confirm) {
  145. console.log('用户点击确定');
  146. this.showA = true
  147. this.isShow = true
  148. this.upgrade()
  149. } else if (res.cancel) {
  150. // plus.runtime.quit();
  151. console.log('用户点击取消');
  152. uni.showModal({
  153. title: '是否每次进入提示更新?',
  154. content: '不再提示后可在<我的>-<关于我们>-<版本更新>中更新',
  155. confirmText: "提示",
  156. cancelText: "不再提示",
  157. success: (res) => {
  158. if (res.confirm) {
  159. console.log('用户点击确定');
  160. uni.setStorage({
  161. key: "turnover",
  162. data: true,
  163. })
  164. } else if (res.cancel) {
  165. uni.setStorage({
  166. key: "turnover",
  167. data: false,
  168. })
  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. }
  190. },
  191. upgrade() {
  192. console.log(this.appName)
  193. // var url = this.value + "/app_file/" + this.appName
  194. var url = "http://hnyfwlw.com/app/big_data.apk"
  195. const downloadTask = uni.downloadFile({
  196. url: url, //仅为示例,并非真实的资源
  197. success: (res) => {
  198. console.log(res)
  199. if (res.statusCode === 200) {
  200. console.log('下载成功');
  201. console.log('安装包下载成功,即将安装:' + JSON.stringify(res, null, 4));
  202. plus.runtime.openFile(res.tempFilePath);
  203. this.showA = false
  204. this.isShow = false
  205. }
  206. },
  207. fail: (err) => {
  208. console.log(err)
  209. },
  210. complete: (com) => {
  211. console.log(com)
  212. }
  213. });
  214. downloadTask.onProgressUpdate((res) => {
  215. this.percentNum = res.progress
  216. if (res.progress == 100) {
  217. console.log('下载完成了')
  218. }
  219. });
  220. },
  221. async formSubmit() {
  222. const res = await this.$myRequest({
  223. url: '/api/api_gateway?method=user.login.login_user',
  224. data: {
  225. username: this.formdata.username,
  226. password: this.formdata.passwold
  227. }
  228. })
  229. console.log(res.session_key)
  230. let session_key = res.session_key
  231. uni.setStorage({
  232. key: 'session_key',
  233. data: session_key,
  234. success: () => {
  235. uni.switchTab({
  236. url: "../index/index"
  237. })
  238. }
  239. })
  240. },
  241. passwoldddata() {
  242. this.formdata.passwold = this.formdata.passwold.replace(/[\u4E00-\u9FA5]/g, '')
  243. },
  244. rempass(val) {
  245. this.passvalue = val.value
  246. if (val.value) {
  247. uni.setStorage({
  248. key: 'user_pass',
  249. data: this.formdata.passwold,
  250. success: function() {
  251. console.log('success');
  252. }
  253. })
  254. }
  255. },
  256. blur(val) {
  257. uni.setStorage({
  258. key: 'user_name',
  259. data: val,
  260. success: function() {
  261. console.log('success');
  262. }
  263. })
  264. },
  265. logoTime() {
  266. this.setTF = true
  267. },
  268. set() {
  269. this.setbgtf = true
  270. },
  271. sethttp() {
  272. uni.setStorage({
  273. key: 'http',
  274. data: this.value,
  275. success: () => {
  276. // console.log(this.value);
  277. this.setbgtf = false
  278. uni.showToast({
  279. title: "修改成功",
  280. icon: "none"
  281. })
  282. this.getEquipList()
  283. uni.removeStorage({
  284. key: "session_key"
  285. })
  286. }
  287. });
  288. },
  289. arrow() {
  290. this.arrowtf = !this.arrowtf
  291. },
  292. denglu() {
  293. if (this.passvalue) {
  294. uni.setStorage({
  295. key: 'user_pass',
  296. data: this.formdata.passwold,
  297. success: function() {
  298. console.log('success');
  299. }
  300. })
  301. } else {
  302. uni.removeStorage({
  303. key: 'user_pass',
  304. success: function() {
  305. console.log('success');
  306. }
  307. })
  308. }
  309. }
  310. }
  311. }
  312. </script>
  313. <style lang="scss">
  314. .logo {
  315. width: 100%;
  316. height: 340rpx;
  317. text-align: center;
  318. display: flex;
  319. align-items: center;
  320. padding-top: 240rpx;
  321. image {
  322. width: 280rpx;
  323. margin: 0 auto;
  324. height: 120rpx;
  325. }
  326. }
  327. .set {
  328. position: absolute;
  329. right: 50rpx;
  330. top: 100rpx;
  331. }
  332. .bg {
  333. width: 100%;
  334. position: fixed;
  335. bottom: 0;
  336. left: 0;
  337. z-index: -1;
  338. image {
  339. width: 100%;
  340. }
  341. }
  342. /deep/.u-input__right-icon {
  343. line-height: 35px !important;
  344. }
  345. .uni-form-item {
  346. width: 100%;
  347. .username {
  348. width: 80%;
  349. margin: 0 auto;
  350. display: flex;
  351. margin-bottom: 40rpx;
  352. padding-bottom: 10rpx;
  353. border-bottom: 2rpx solid #C3C3C3;
  354. .u-icon__icon {
  355. margin-top: 17rpx;
  356. }
  357. .uni-input {
  358. width: 100%;
  359. }
  360. }
  361. .passwold {
  362. width: 80%;
  363. margin: 0 auto;
  364. display: flex;
  365. margin-bottom: 40rpx;
  366. padding-bottom: 10rpx;
  367. border-bottom: 2rpx solid #C3C3C3;
  368. .u-icon__icon {
  369. margin-top: 17rpx;
  370. }
  371. .uni-input {
  372. width: 100%;
  373. }
  374. }
  375. .aboutpass {
  376. width: 80%;
  377. margin: 0 auto;
  378. display: flex;
  379. justify-content: flex-end;
  380. p {
  381. color: #C0C0C0;
  382. font-size: 28rpx;
  383. }
  384. /deep/.u-checkbox__label {
  385. font-size: 28rpx;
  386. color: #C0C0C0;
  387. margin-right: 0;
  388. }
  389. }
  390. .uni-btn-v {
  391. width: 80%;
  392. margin: 112rpx auto 0;
  393. position: relative;
  394. z-index: 100;
  395. button {
  396. width: 100%;
  397. height: 72rpx;
  398. line-height: 75rpx;
  399. background-color: #5DC18B;
  400. color: #FFFFFF;
  401. border-radius: 36rpx;
  402. font-size: 28rpx;
  403. }
  404. }
  405. }
  406. .setbg {
  407. width: 100%;
  408. height: 100vh;
  409. position: absolute;
  410. top: 0;
  411. z-index: 99999;
  412. .mengban {
  413. width: 100%;
  414. height: 100vh;
  415. position: absolute;
  416. top: 0;
  417. background-color: rgba($color: #000000, $alpha: 0.5);
  418. }
  419. .set_http {
  420. position: absolute;
  421. width: 90%;
  422. left: 5%;
  423. top: 30%;
  424. .set_http_top {
  425. display: flex;
  426. justify-content: space-around;
  427. background-color: #5DC18B;
  428. height: 60px;
  429. line-height: 60px;
  430. color: #FFFFFF;
  431. border-top-right-radius: 20px;
  432. border-top-left-radius: 20px;
  433. font-size: 32rpx;
  434. }
  435. .set_http_bot {
  436. height: 150px;
  437. background-color: #FFFFFF;
  438. border-bottom-right-radius: 20px;
  439. border-bottom-left-radius: 20px;
  440. padding: 30px;
  441. .set_http_bot_input {
  442. margin-top: 20rpx;
  443. border: 2rpx solid #bdb6a6;
  444. border-radius: 20rpx;
  445. padding: 10rpx 40rpx 0 20rpx;
  446. font-size: 32rpx;
  447. height: 30px;
  448. display: flex;
  449. justify-content: space-between;
  450. input {
  451. width: 90%;
  452. }
  453. }
  454. }
  455. .scroll-Y {
  456. border: 2rpx solid #d0d0d0;
  457. border-radius: 20rpx;
  458. .scroll-view-item {
  459. padding-left: 20rpx;
  460. height: 70rpx;
  461. font-size: 28rpx;
  462. line-height: 70rpx;
  463. border-bottom: 2rpx solid #d0d0d0;
  464. }
  465. }
  466. }
  467. }
  468. .upgradeBox {
  469. padding: 15rpx;
  470. }
  471. </style>