login.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <template>
  2. <view style="height: 100vh;">
  3. <view class="status_bar"></view>
  4. <view class="logo" @longpress="logoTime">
  5. <image src="../../static/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" />
  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">登 录</button>
  29. </view>
  30. </view>
  31. </form>
  32. <view class="bg">
  33. <image src="../../static/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. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. checked: false,
  62. formdata: {
  63. username: '',
  64. passwold: ''
  65. },
  66. setbgtf:false,
  67. setTF:false,
  68. value:"http://8.136.98.49:8002",
  69. httparr:["http://8.136.98.49:8002","http://182.92.193.64:8002"],
  70. arrowtf:false
  71. }
  72. },
  73. onLoad() {
  74. uni.getStorage({
  75. key: 'user_pass',
  76. success: (res) => {
  77. if(res.data){
  78. this.formdata.passwold = res.data
  79. this.checked =true
  80. }else{
  81. this.checked =false
  82. }
  83. }
  84. })
  85. uni.getStorage({
  86. key: 'user_name',
  87. success: (res) => {
  88. this.formdata.username = res.data
  89. }
  90. })
  91. uni.getStorage({
  92. key: 'http',
  93. success: (res) => {
  94. this.value = res.data
  95. }
  96. })
  97. },
  98. onShow(){
  99. uni.getStorage({
  100. key: 'session_key',
  101. success: (res) => {
  102. console.log(res)
  103. if(res.data!=""){
  104. uni.switchTab({
  105. url: "../index/index"
  106. })
  107. }
  108. }
  109. })
  110. },
  111. methods: {
  112. async formSubmit() {
  113. const res = await this.$myRequest({
  114. url: '/api/api_gateway?method=user.login.login_user',
  115. data: {
  116. username: this.formdata.username,
  117. password: this.formdata.passwold
  118. }
  119. })
  120. let session_key = res.session_key
  121. uni.setStorage({
  122. key: 'session_key',
  123. data: session_key,
  124. success: () => {
  125. uni.switchTab({
  126. url: "../index/index"
  127. })
  128. }
  129. })
  130. },
  131. passwoldddata() {
  132. this.formdata.passwold = this.formdata.passwold.replace(/[\u4E00-\u9FA5]/g, '')
  133. },
  134. rempass(val) {
  135. if(val.value){
  136. uni.setStorage({
  137. key: 'user_pass',
  138. data: this.formdata.passwold,
  139. success: function() {
  140. console.log('success');
  141. }
  142. })
  143. }else{
  144. uni.removeStorage({
  145. key: 'user_pass',
  146. success: function() {
  147. console.log('success');
  148. }
  149. })
  150. }
  151. },
  152. blur(val){
  153. uni.setStorage({
  154. key: 'user_name',
  155. data: val,
  156. success: function() {
  157. console.log('success');
  158. }
  159. })
  160. },
  161. logoTime(){
  162. this.setTF = true
  163. },
  164. set(){
  165. this.setbgtf = true
  166. },
  167. sethttp(){
  168. uni.setStorage({
  169. key: 'http',
  170. data: this.value,
  171. success: function () {
  172. console.log('success');
  173. }
  174. });
  175. this.setbgtf = false
  176. },
  177. arrow(){
  178. this.arrowtf = !this.arrowtf
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss">
  184. .logo {
  185. width: 100%;
  186. height: 340rpx;
  187. text-align: center;
  188. display: flex;
  189. align-items: center;
  190. padding-top: 240rpx;
  191. image {
  192. width: 280rpx;
  193. margin: 0 auto;
  194. height: 120rpx;
  195. }
  196. }
  197. .set{
  198. position: absolute;
  199. right: 50rpx;
  200. top: 100rpx;
  201. }
  202. .bg {
  203. width: 100%;
  204. position: fixed;
  205. bottom: 0;
  206. z-index: -1;
  207. image {
  208. width: 100%;
  209. }
  210. }
  211. /deep/.u-input__right-icon {
  212. line-height: 35px !important;
  213. }
  214. .uni-form-item {
  215. width: 100%;
  216. .username {
  217. width: 80%;
  218. margin: 0 auto;
  219. display: flex;
  220. margin-bottom: 40rpx;
  221. padding-bottom: 10rpx;
  222. border-bottom: 2rpx solid #C3C3C3;
  223. }
  224. .passwold {
  225. width: 80%;
  226. margin: 0 auto;
  227. display: flex;
  228. margin-bottom: 40rpx;
  229. padding-bottom: 10rpx;
  230. border-bottom: 2rpx solid #C3C3C3;
  231. }
  232. .aboutpass {
  233. width: 80%;
  234. margin: 0 auto;
  235. display: flex;
  236. justify-content: flex-end;
  237. p {
  238. color: #C0C0C0;
  239. font-size: 28rpx;
  240. }
  241. /deep/.u-checkbox__label {
  242. font-size: 28rpx;
  243. color: #C0C0C0;
  244. margin-right: 0;
  245. }
  246. }
  247. .uni-btn-v {
  248. width: 80%;
  249. margin: 112rpx auto 0;
  250. position: relative;
  251. z-index: 100;
  252. button {
  253. width: 100%;
  254. height: 72rpx;
  255. line-height: 75rpx;
  256. background-color: #5DC18B;
  257. color: #FFFFFF;
  258. border-radius: 36rpx;
  259. font-size: 28rpx;
  260. }
  261. }
  262. }
  263. .setbg{
  264. width: 100%;
  265. height: 100vh;
  266. position: absolute;
  267. top: 0;
  268. z-index: 99999;
  269. .mengban{
  270. width: 100%;
  271. height: 100vh;
  272. position: absolute;
  273. top: 0;
  274. background-color: rgba($color: #000000, $alpha: 0.5);
  275. }
  276. .set_http{
  277. position: absolute;
  278. width: 90%;
  279. left: 5%;
  280. top:30%;
  281. .set_http_top{
  282. display: flex;
  283. justify-content: space-around;
  284. background-color: #5DC18B;
  285. height: 60px;
  286. line-height: 60px;
  287. color: #FFFFFF;
  288. border-top-right-radius: 20px;
  289. border-top-left-radius: 20px;
  290. font-size: 32rpx;
  291. }
  292. .set_http_bot{
  293. height: 150px;
  294. background-color: #FFFFFF;
  295. border-bottom-right-radius: 20px;
  296. border-bottom-left-radius: 20px;
  297. padding: 30px;
  298. .set_http_bot_input{
  299. margin-top: 20rpx;
  300. border: 2rpx solid #bdb6a6;
  301. border-radius: 20rpx;
  302. padding: 10rpx 40rpx 0 20rpx;
  303. font-size: 32rpx;
  304. height: 30px;
  305. display: flex;
  306. justify-content: space-between;
  307. input{
  308. width: 90%;
  309. }
  310. }
  311. }
  312. .scroll-Y{
  313. border: 2rpx solid #d0d0d0;
  314. border-radius: 20rpx;
  315. .scroll-view-item{
  316. padding-left: 20rpx;
  317. height: 50rpx;
  318. font-size: 28rpx;
  319. line-height: 50rpx;
  320. }
  321. }
  322. }
  323. }
  324. </style>