index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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: 'Hello',
  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. that.$storage.setJson('users',res.returnData);
  76. uni.switchTab({
  77. url: "/pages/index/index"
  78. });
  79. }
  80. else{
  81. uni.showToast({
  82. title: '登录失败请联系管理员',
  83. icon: 'none',
  84. duration: 500
  85. });
  86. }
  87. })
  88. },
  89. /**发布提交 */
  90. formSubmit(e) {
  91. var that = this;
  92. var yonghuming1= e.detail.value.yonghuming;
  93. var mima1= e.detail.value.mima;
  94. uni.request({
  95. url:'https://换成你自己的域名接口',
  96. header: {
  97. 'content-type': 'application/x-www-form-urlencoded'
  98. },
  99. method: 'POST',
  100. data: {
  101. yonghuming:yonghuming1,
  102. mima:mima1,
  103. },
  104. success: (res) => {
  105. if(res.data=="5"){
  106. wx.showToast({
  107. title: '用户名或密码错误',
  108. icon: 'none',
  109. duration: 500
  110. });
  111. }
  112. else{
  113. uni.navigateTo({
  114. url:"/pages/index1/index1",
  115. })
  116. }
  117. }
  118. })
  119. }
  120. }
  121. }
  122. </script>
  123. <style scoped>
  124. .content {
  125. background: #377EB4;
  126. width: 100vw;
  127. height: 100vh;
  128. background: url('../../static/bg.png') no-repeat;
  129. background-size: 100% 100%;
  130. }
  131. .avatorWrapper{
  132. height: 15vh;
  133. width: 100vw;
  134. display: flex;
  135. justify-content: center;
  136. align-items: flex-end;
  137. }
  138. .avator{
  139. width: 200upx;
  140. height: 200upx;
  141. overflow: hidden;
  142. }
  143. .avator .img{
  144. width: 100%
  145. }
  146. .name{
  147. /* padding: 0 90upx 50upx 90upx; */
  148. padding-left: 90upx;
  149. color: rgb(255, 255, 255);
  150. font-family: Noto Sans SC;
  151. font-size: 24px;
  152. font-weight: 700;
  153. }
  154. .form{
  155. padding: 0 100upx;
  156. margin-top: .625rem;
  157. }
  158. .inputWrapper{
  159. width: 100%;
  160. height: 80upx;
  161. background: rgba(0, 0, 0, 0);
  162. box-sizing: border-box;
  163. /* padding: 0 20px; */
  164. margin-top: 25px;
  165. border-bottom: 1px solid rgb(223, 223, 223);
  166. display: flex;
  167. align-items: center;
  168. }
  169. .log{
  170. width: .875rem;
  171. height: .875rem;
  172. background: url('../../static/login.png') no-repeat;
  173. background-size: 100% 100%;
  174. margin-right: .75rem;
  175. }
  176. .pass{
  177. width: .875rem;
  178. height: .875rem;
  179. background: url('../../static/mima.png') no-repeat;
  180. background-size: 100% 100%;
  181. margin-right: .75rem;
  182. }
  183. .inputWrapper .input{
  184. width: 100%;
  185. height: 100%;
  186. /* text-align: center; */
  187. color: rgb(223, 223, 223);
  188. font-family: Noto Sans SC;
  189. font-size: .8125rem;
  190. font-weight: 500;
  191. }
  192. .loginBtn{
  193. width: 16.8rem;
  194. /* padding: 0 23px 0 23px; */
  195. height: 2.5rem;
  196. 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%);
  197. border-radius: 2px;
  198. margin-top: 50px;
  199. display: flex;
  200. justify-content: center;
  201. align-items: center;
  202. color: rgb(223, 223, 223);
  203. font-family: Noto Sans SC;
  204. font-size: 15px;
  205. font-weight: 700;
  206. }
  207. .loginBtn .btnValue{
  208. color: white;
  209. }
  210. .forgotBtn{
  211. text-align: center;
  212. color: #EAF6F9;
  213. font-size: 15px;
  214. margin-top: 20px;
  215. }
  216. </style>