login.vue 10 KB

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