index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view class="content">
  3. <!-- <img src="../../static/bei.png" alt="" class="tubei"> -->
  4. <form>
  5. <view class="avatorWrapper">
  6. </view>
  7. <view class="name">中小型机场手持终端</view>
  8. <view class="form">
  9. <view class="inputWrapper">
  10. <view class="log"></view>
  11. <input class="input" name="username" type="text" v-model="username" placeholder-style="font-size:.8125rem;color:rgb(223, 223, 223);display:flex;justify-content: start;" placeholder="请输入登录账号"/>
  12. </view>
  13. <view class="inputWrapper">
  14. <view class="pass"></view>
  15. <input class="input" name="password" type="password" v-model="password" placeholder-style="font-size:.8125rem;color:rgb(223, 223, 223);display:flex;justify-content: start;" placeholder="请输入密码"/>
  16. </view>
  17. </view>
  18. <button form-type="submit" class="loginBtn" @tap="login">登录</button>
  19. </form>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. title: '',
  27. username:"",
  28. password:"",
  29. }
  30. },
  31. created() {
  32. this.getToken()
  33. },
  34. onLoad() {
  35. },
  36. methods: {
  37. async getToken(){
  38. let that = this;
  39. let data = {
  40. "appid": "appdjmmaf0kerwpf",
  41. "appSecret": "appu7zpllz1folzsljm498dcpi0lsog1"
  42. }
  43. await that.$http.httpPost('/foxlibc/getToken',data).then(res => {
  44. if(res.code == "0"){
  45. that.$storage.setJson('apps',res.returnData);
  46. }
  47. })
  48. },
  49. async login () {
  50. const apps = this.$storage.getJson("apps")
  51. let that = this;
  52. let passWordMD5 = this.$md5(that.password)
  53. let data = {
  54. "app_token": apps.app_token,
  55. "username": that.username,
  56. "password": passWordMD5
  57. }
  58. if(data.username==""||data.password==""){
  59. uni.showToast({
  60. title: '请输入正确账号密码',
  61. icon: 'none',
  62. duration: 500
  63. });
  64. return;
  65. }
  66. await that.$http.httpPost('/foxlibc/sign-in',data).then(res => {
  67. if(res.code=="-1"){
  68. uni.showToast({
  69. title: '用户名或密码错误',
  70. icon: 'none',
  71. duration: 500
  72. });
  73. }
  74. else if(res.code=="0"){
  75. res.returnData["user_name"] =res.returnData["user_name"]?res.returnData["user_name"]:that.username
  76. that.$storage.setJson('users',res.returnData);
  77. this.getAuth(res.returnData.user_id);
  78. }
  79. else{
  80. uni.showToast({
  81. title: '登录失败请联系管理员',
  82. icon: 'none',
  83. duration: 5000
  84. });
  85. }
  86. })
  87. },
  88. async getAuth(user_id){
  89. let data = {"serviceId":2,"dataContent":[{"user_id":user_id}],"page":1,"pageSize":999,"event":"0"}
  90. await this.$http.httpPost('/openApi/query',data).then(res => {
  91. if(res.code=="0"){
  92. let isAPP = res.returnData.filter(function(item){
  93. return item.auth_ident==="APP_auth"
  94. })
  95. if(isAPP.length>0){
  96. this.$storage.setJson("authList",res.returnData)
  97. uni.switchTab({
  98. url: "/pages/index/index"
  99. });
  100. }
  101. else{
  102. this.$storage.remove('users');
  103. uni.showToast({
  104. title: '该账户没有APP登录权限',
  105. icon: 'none',
  106. duration: 5000
  107. });
  108. }
  109. }
  110. })
  111. }
  112. }
  113. }
  114. </script>
  115. <style scoped>
  116. .content {
  117. background: #377EB4;
  118. width: 100vw;
  119. height: 100vh;
  120. background: url('../../static/bg.png') no-repeat;
  121. background-size: 100% 100%;
  122. }
  123. .avatorWrapper{
  124. height: 15vh;
  125. width: 100vw;
  126. display: flex;
  127. justify-content: center;
  128. align-items: flex-end;
  129. }
  130. .avator{
  131. width: 200upx;
  132. height: 200upx;
  133. overflow: hidden;
  134. }
  135. .avator .img{
  136. width: 100%
  137. }
  138. .name{
  139. /* padding: 0 90upx 50upx 90upx; */
  140. padding-left: 90upx;
  141. color: rgb(255, 255, 255);
  142. font-family: Noto Sans SC;
  143. font-size: 24px;
  144. font-weight: 700;
  145. }
  146. .form{
  147. padding: 0 100upx;
  148. margin-top: .625rem;
  149. }
  150. .inputWrapper{
  151. width: 100%;
  152. height: 80upx;
  153. background: rgba(0, 0, 0, 0);
  154. box-sizing: border-box;
  155. /* padding: 0 20px; */
  156. margin-top: 25px;
  157. border-bottom: 1px solid rgb(223, 223, 223);
  158. display: flex;
  159. align-items: center;
  160. }
  161. .log{
  162. width: .875rem;
  163. height: .875rem;
  164. background: url('../../static/login.png') no-repeat;
  165. background-size: 100% 100%;
  166. margin-right: .75rem;
  167. }
  168. .pass{
  169. width: .875rem;
  170. height: .875rem;
  171. background: url('../../static/mima.png') no-repeat;
  172. background-size: 100% 100%;
  173. margin-right: .75rem;
  174. }
  175. .inputWrapper .input{
  176. width: 100%;
  177. height: 100%;
  178. /* text-align: center; */
  179. color: rgb(223, 223, 223);
  180. font-family: Noto Sans SC;
  181. font-size: .8125rem;
  182. font-weight: 500;
  183. }
  184. .loginBtn{
  185. width: 16.8rem;
  186. /* padding: 0 23px 0 23px; */
  187. height: 2.5rem;
  188. background: linear-gradient(179.11deg, rgba(51,161,165,1.00) 11.422%,rgba(59,111,142,1.00) 118.849%,rgba(59,111,142,1.00) 118.849%,rgba(59,111,142,1.00) 118.849%);
  189. border-radius: 2px;
  190. margin-top: 50px;
  191. display: flex;
  192. justify-content: center;
  193. align-items: center;
  194. color: rgb(223, 223, 223);
  195. font-family: Noto Sans SC;
  196. font-size: 15px;
  197. font-weight: 700;
  198. }
  199. .loginBtn .btnValue{
  200. color: white;
  201. }
  202. .forgotBtn{
  203. text-align: center;
  204. color: #EAF6F9;
  205. font-size: 15px;
  206. margin-top: 20px;
  207. }
  208. </style>