login.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view>
  3. <view class="bg">
  4. <image
  5. :src="$imageURL + '/bigdata_app/log/bg.png'"
  6. mode=""
  7. class="bgimg"
  8. ></image>
  9. </view>
  10. <!-- <view class="status_bar"></view> -->
  11. <view class="apptitle"> 云飞智控 </view>
  12. <view class="set" @click="set" v-if="setTF">
  13. <u-icon name="setting-fill" size="50" color="#fff"></u-icon>
  14. </view>
  15. <view class="formbox">
  16. <form @submit="formSubmit">
  17. <view class="uni-form-item uni-column">
  18. <view class="username">
  19. <u-icon
  20. name="account"
  21. size="36"
  22. style="margin-right: 30rpx; color: #fff"
  23. ></u-icon>
  24. <u-input
  25. class="uni-input"
  26. name="username"
  27. v-model="formdata.username"
  28. placeholder-class="icon iconfont icon-bianji1"
  29. placeholder="请输入用户名"
  30. placeholderStyle="color:#ffffff;"
  31. color="#FFFFFF"
  32. @blur="blur"
  33. />
  34. </view>
  35. <view class="passwold">
  36. <u-icon
  37. name="lock"
  38. size="36"
  39. style="margin-right: 30rpx; color: #fff"
  40. ></u-icon>
  41. <u-input
  42. v-model="formdata.passwold"
  43. type="password"
  44. :password-icon="true"
  45. :clearable="false"
  46. placeholder="请输入密码"
  47. @confirm="formSubmit"
  48. @input="passwoldddata"
  49. placeholderStyle="color:#fff;"
  50. suffixIconStyle="color:#fff;"
  51. color="#fff"
  52. class="uni-input"
  53. />
  54. </view>
  55. <view class="aboutpass">
  56. <u-checkbox-group>
  57. <u-checkbox
  58. v-model="checked"
  59. :label-disabled="false"
  60. size="28"
  61. @change="rempass"
  62. >记住密码
  63. </u-checkbox>
  64. </u-checkbox-group>
  65. </view>
  66. <view class="uni-btn-v">
  67. <button form-type="submit" @click="denglu">登 录</button>
  68. </view>
  69. </view>
  70. </form>
  71. </view>
  72. <u-modal
  73. title="升级中请勿随意操作"
  74. :show-confirm-button="false"
  75. v-model="showA"
  76. :content="contentA"
  77. >
  78. <view class="upgradeBox">
  79. <u-line-progress
  80. v-show="isShow"
  81. active-color="#19be6b"
  82. :striped="true"
  83. :percent="percentNum"
  84. :striped-active="true"
  85. ></u-line-progress>
  86. </view>
  87. </u-modal>
  88. </view>
  89. </template>
  90. <script>
  91. export default {
  92. data() {
  93. return {
  94. checked: false,
  95. formdata: {
  96. username: '',
  97. passwold: '',
  98. },
  99. setbgtf: false,
  100. setTF: false,
  101. value: 'http://8.136.98.49:8002',
  102. httparr: ['http://8.136.98.49:8002', 'http://dev.hnyfwlw.com'],
  103. arrowtf: false,
  104. showA: false, //
  105. contentA: '',
  106. isShow: false, //进度条
  107. percentNum: 0, //在线下载进度
  108. passvalue: false,
  109. };
  110. },
  111. onLoad() {
  112. uni.getStorage({
  113. key: 'user_pass',
  114. success: (res) => {
  115. if (res.data) {
  116. this.formdata.passwold = res.data;
  117. this.checked = true;
  118. } else {
  119. this.checked = false;
  120. }
  121. },
  122. });
  123. uni.getStorage({
  124. key: 'user_name',
  125. success: (res) => {
  126. this.formdata.username = res.data;
  127. },
  128. });
  129. uni.getStorage({
  130. key: 'http',
  131. success: (res) => {
  132. this.value = res.data;
  133. },
  134. });
  135. this.getEquipList();
  136. },
  137. onShow() {},
  138. methods: {
  139. async getEquipList() {
  140. const res = await this.$myRequest({
  141. url: '/api/api_gateway?method=home.homes.app_version_record',
  142. data: {
  143. ret: 'first',
  144. },
  145. });
  146. console.log(res);
  147. this.appName = res[0].app_name;
  148. // uni.getStorage({
  149. // key: 'session_key',
  150. // success: (res) => {
  151. // console.log(res)
  152. // if (res.data != "") {
  153. // uni.switchTab({
  154. // url: "../index/index"
  155. // })
  156. // }
  157. // },
  158. // })
  159. // }
  160. },
  161. async formSubmit() {
  162. const res = await this.$myRequest({
  163. url: '/api/api_gateway?method=user.login.login_user',
  164. data: {
  165. username: this.formdata.username,
  166. password: this.formdata.passwold,
  167. },
  168. });
  169. console.log(res.session_key);
  170. let session_key = res.session_key;
  171. uni.setStorage({
  172. key: 'session_key',
  173. data: session_key,
  174. success: () => {
  175. // 登录前清除可能残留的权限缓存,再用新账号拉取
  176. this.$resetPermissionList();
  177. this.$fetchPermissionList();
  178. uni.switchTab({
  179. url: '../index/index',
  180. });
  181. },
  182. });
  183. },
  184. passwoldddata() {
  185. this.formdata.passwold = this.formdata.passwold.replace(
  186. /[\u4E00-\u9FA5]/g,
  187. '',
  188. );
  189. },
  190. rempass(val) {
  191. this.passvalue = val.value;
  192. if (val.value) {
  193. uni.setStorage({
  194. key: 'user_pass',
  195. data: this.formdata.passwold,
  196. success: function () {
  197. console.log('success');
  198. },
  199. });
  200. }
  201. },
  202. blur(val) {
  203. uni.setStorage({
  204. key: 'user_name',
  205. data: val,
  206. success: function () {
  207. console.log('success');
  208. },
  209. });
  210. },
  211. logoTime() {
  212. this.setTF = true;
  213. },
  214. set() {
  215. this.setbgtf = true;
  216. },
  217. sethttp() {
  218. uni.setStorage({
  219. key: 'http',
  220. data: this.value,
  221. success: () => {
  222. // console.log(this.value);
  223. this.setbgtf = false;
  224. uni.showToast({
  225. title: '修改成功',
  226. icon: 'none',
  227. });
  228. this.getEquipList();
  229. },
  230. });
  231. },
  232. arrow() {
  233. this.arrowtf = !this.arrowtf;
  234. },
  235. denglu() {
  236. if (this.passvalue) {
  237. uni.setStorage({
  238. key: 'user_pass',
  239. data: this.formdata.passwold,
  240. success: function () {
  241. console.log('success');
  242. },
  243. });
  244. } else {
  245. uni.removeStorage({
  246. key: 'user_pass',
  247. success: function () {
  248. console.log('success');
  249. },
  250. });
  251. }
  252. },
  253. },
  254. };
  255. </script>
  256. <style lang="scss">
  257. .bg {
  258. width: 100%;
  259. height: 100vh;
  260. position: absolute;
  261. top: 0;
  262. left: 0;
  263. .bgimg {
  264. width: 100%;
  265. height: 100%;
  266. }
  267. }
  268. .apptitle {
  269. font-size: 52rpx;
  270. color: #fff;
  271. width: 80%;
  272. margin: 600rpx auto 40rpx;
  273. }
  274. .logo {
  275. width: 100%;
  276. height: 340rpx;
  277. text-align: center;
  278. display: flex;
  279. align-items: center;
  280. padding-top: 240rpx;
  281. image {
  282. width: 280rpx;
  283. margin: 0 auto;
  284. height: 120rpx;
  285. }
  286. }
  287. .set {
  288. position: absolute;
  289. right: 50rpx;
  290. top: 150rpx;
  291. }
  292. .bg {
  293. width: 100%;
  294. position: fixed;
  295. bottom: 0;
  296. left: 0;
  297. z-index: -1;
  298. image {
  299. width: 100%;
  300. }
  301. }
  302. /deep/.u-input__right-icon {
  303. line-height: 35px !important;
  304. }
  305. .uni-form-item {
  306. width: 100%;
  307. .username {
  308. width: 80%;
  309. margin: 0 auto;
  310. display: flex;
  311. margin-bottom: 40rpx;
  312. padding-bottom: 10rpx;
  313. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  314. .u-icon__icon {
  315. margin-top: 17rpx;
  316. }
  317. .uni-input {
  318. width: 100%;
  319. color: #fff;
  320. }
  321. .u-input__input {
  322. color: #fff !important;
  323. }
  324. }
  325. .passwold {
  326. width: 80%;
  327. margin: 0 auto;
  328. display: flex;
  329. margin-bottom: 40rpx;
  330. padding-bottom: 10rpx;
  331. border-bottom: 2rpx solid rgba(249, 249, 249, 0.4);
  332. .u-icon__icon {
  333. margin-top: 17rpx;
  334. }
  335. /deep/.u-input__input {
  336. color: #fff;
  337. }
  338. .uni-input {
  339. width: 100%;
  340. color: #fff;
  341. }
  342. /deep/.uicon-eye {
  343. color: #fff !important;
  344. }
  345. }
  346. .aboutpass {
  347. width: 80%;
  348. margin: 0 auto;
  349. display: flex;
  350. justify-content: flex-end;
  351. p {
  352. color: #fff;
  353. font-size: 28rpx;
  354. }
  355. /deep/.uicon-checkbox-mark {
  356. border-color: #ff0000;
  357. // color: #f00 !important;
  358. }
  359. /deep/.u-checkbox__label {
  360. font-size: 28rpx;
  361. color: #fff;
  362. margin-right: 0;
  363. }
  364. }
  365. .uni-btn-v {
  366. width: 80%;
  367. margin: 112rpx auto 0;
  368. position: relative;
  369. z-index: 100;
  370. button {
  371. width: 100%;
  372. height: 90rpx;
  373. line-height: 90rpx;
  374. color: #ffffff;
  375. font-size: 36rpx;
  376. background-image: linear-gradient(
  377. to bottom,
  378. rgba(249, 249, 249, 0.6),
  379. rgba(249, 249, 249, 0.1)
  380. );
  381. color: #5dc18b;
  382. }
  383. }
  384. }
  385. .setbg {
  386. width: 100%;
  387. height: 100vh;
  388. position: absolute;
  389. top: 0;
  390. z-index: 99999;
  391. .mengban {
  392. width: 100%;
  393. height: 100vh;
  394. position: absolute;
  395. top: 0;
  396. background-color: rgba($color: #000000, $alpha: 0.5);
  397. }
  398. .set_http {
  399. position: absolute;
  400. width: 90%;
  401. left: 5%;
  402. top: 30%;
  403. .set_http_top {
  404. display: flex;
  405. justify-content: space-around;
  406. background-color: #5dc18b;
  407. height: 60px;
  408. line-height: 60px;
  409. color: #ffffff;
  410. border-top-right-radius: 20px;
  411. border-top-left-radius: 20px;
  412. font-size: 32rpx;
  413. }
  414. .set_http_bot {
  415. height: 150px;
  416. background-color: #ffffff;
  417. border-bottom-right-radius: 20px;
  418. border-bottom-left-radius: 20px;
  419. padding: 30px;
  420. .set_http_bot_input {
  421. margin-top: 20rpx;
  422. border: 2rpx solid #bdb6a6;
  423. border-radius: 20rpx;
  424. padding: 10rpx 40rpx 0 20rpx;
  425. font-size: 32rpx;
  426. height: 30px;
  427. display: flex;
  428. justify-content: space-between;
  429. input {
  430. width: 90%;
  431. }
  432. }
  433. }
  434. .scroll-Y {
  435. border: 2rpx solid #d0d0d0;
  436. border-radius: 20rpx;
  437. .scroll-view-item {
  438. padding-left: 20rpx;
  439. height: 70rpx;
  440. font-size: 28rpx;
  441. line-height: 70rpx;
  442. border-bottom: 2rpx solid #d0d0d0;
  443. }
  444. }
  445. }
  446. }
  447. .upgradeBox {
  448. padding: 15rpx;
  449. }
  450. </style>