login.vue 10 KB

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