appIndex.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <template>
  2. <view class="page" :style="{'min-height':h+'px'}">
  3. <view class="box">
  4. <view class="text">您好!欢迎使用<br>游嵊泗商家服务平台</view>
  5. <view class="login">
  6. <view class="item">
  7. <u--input
  8. placeholder="用户名"
  9. prefixIcon="account-fill"
  10. prefixIconStyle="font-size: 22px;color: #909399"
  11. labelColor="#ffffff"
  12. v-model="dataFrom.username"
  13. ></u--input>
  14. </view>
  15. <view class="item">
  16. <u--input
  17. placeholder="密码"
  18. prefixIcon="lock-fill"
  19. prefixIconStyle="font-size: 22px;color: #909399"
  20. labelColor="#ffffff"
  21. type="password"
  22. v-model="dataFrom.password"
  23. ></u--input>
  24. </view>
  25. <!-- <view class="item" @click="typeShow=true">
  26. <u--input
  27. placeholder="类型"
  28. prefixIcon="coupon-fill"
  29. suffixIcon="arrow-down"
  30. prefixIconStyle="font-size: 22px;color: #909399"
  31. suffixIconStyle="font-size: 22px;color: #909399"
  32. readonly
  33. v-model="userType"
  34. ></u--input>
  35. </view> -->
  36. <button @click="login">登录</button>
  37. <u-picker :show="typeShow" :columns="columns" @close="typeShow=false" @cancel="typeShow=false" @confirm="confirm"></u-picker>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. typeShow:false,
  47. userType:'',
  48. columns:[['酒店民宿','商家']],
  49. typeCfg:{'酒店民宿':'1','商家':'2'},
  50. dataFrom:{
  51. username:'',
  52. password:'',
  53. usertype:'1',
  54. captcha:'666',
  55. uuid: "",
  56. grant_type: "password",
  57. }
  58. }
  59. },
  60. onLoad() {
  61. uni.clearStorageSync();
  62. },
  63. methods: {
  64. confirm(e){
  65. this.userType = e.value[0];
  66. this.typeShow = false;
  67. },
  68. login(){
  69. // this.dataFrom.usertype = this.typeCfg[this.userType]||'';
  70. if(!this.dataFrom.username) return this.$showToast('请输入用户名');
  71. if(!this.dataFrom.password) return this.$showToast('请输入密码');
  72. // if(!this.dataFrom.usertype) return this.$showToast('请选择类型');
  73. uni.setStorageSync('authorization','Basic cmVucmVuaW86cmVucmVuaW8=');
  74. let that = this;
  75. this.$api.post("/auth/oauth/token", {
  76. ...this.dataFrom,
  77. username: this.dataFrom.username + "&&" + `${this.dataFrom.usertype}`,
  78. },false,true).then(res=>{
  79. if(res.data.code==0){
  80. uni.setStorageSync('authorization',res.data.token_type+' '+res.data.access_token);
  81. uni.setStorageSync('access_token',res.data.access_token);
  82. that.$api.get('/sys/user/info').then(resu=>{
  83. if(resu.data.code===0){
  84. that.$showToast('登录成功');
  85. uni.setStorageSync('userInfo',resu.data.data);
  86. setTimeout(()=>{
  87. uni.reLaunch({
  88. url:'/pages/login/select?userInfo='+encodeURIComponent(JSON.stringify(resu.data.data))
  89. })
  90. },1500)
  91. }else that.$showToast(resu.data.msg)
  92. })
  93. }else that.$showToast(res.data.msg)
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="less">
  100. .page{
  101. background: url(https://i.ringzle.com/file/20240109/472b6b7b9ea44652b85e73c796876378.png) no-repeat;
  102. background-size: 100% 100%;
  103. display: flex;
  104. align-items: center;
  105. justify-content: center;
  106. .box{
  107. width: calc(100% - 180rpx);
  108. display: flex;
  109. flex-direction: column;
  110. align-items: center;
  111. image{
  112. width: 480rpx;
  113. height: 520rpx;
  114. }
  115. .text{
  116. text-align: center;
  117. font-size: 56rpx;
  118. font-family: PingFang SC, PingFang SC;
  119. font-weight: 800;
  120. color: #FFFFFF;
  121. line-height: 96rpx;
  122. }
  123. .login{
  124. margin-top: 80rpx;
  125. width: 100%;
  126. .item{
  127. margin-bottom: 40rpx;
  128. ::v-deep input{
  129. color: #FFFFFF !important;
  130. }
  131. }
  132. button{
  133. width: 100%;
  134. height: 100%;
  135. background: #FFFFFF;
  136. border-radius: 48rpx 48rpx 48rpx 48rpx;
  137. line-height: 96rpx;
  138. text-align: center;
  139. font-size: 34rpx;
  140. font-family: PingFang SC, PingFang SC;
  141. font-weight: 400;
  142. color: #145EE6;
  143. }
  144. }
  145. }
  146. }
  147. </style>