login.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view class="column" style="height: 100vh;">
  3. <view class="content flex-1" >
  4. <view class="login pt14">
  5. <view class="head">
  6. <image src="/static/logo.png" ></image>
  7. <p class="title">销售管理端</p>
  8. <p class="desc">客户沟通更智能</p>
  9. </view>
  10. <view class="login">
  11. <view class="login-item">
  12. <!-- <text>帐号</text> -->
  13. <view class="input-account">
  14. <input v-model="account"
  15. placeholder="请输入帐号" type="text" ></input>
  16. </view>
  17. </view>
  18. <view class="login-item">
  19. <!-- <text>密码</text> -->
  20. <view class="input-pwd">
  21. <input v-model="password"
  22. placeholder="请输入密码" type="password" ></input>
  23. </view>
  24. </view>
  25. <view class="btns">
  26. <view class="login-btn" @click="login">登录</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- <view class="footer" >
  32. <p>版权所有 @2024</p>
  33. </view> -->
  34. </view>
  35. </template>
  36. <script>
  37. import { login } from '@/api/user.js'
  38. export default {
  39. data() {
  40. return {
  41. account:"",
  42. password:"",
  43. }
  44. },
  45. onLoad(option)
  46. {
  47. },
  48. mounted() {
  49. },
  50. methods: {
  51. login(){
  52. if (this.utils.isEmpty(this.account)) {
  53. uni.showToast({
  54. title: "请输入帐号",
  55. icon: 'none',
  56. });
  57. return
  58. }
  59. if (this.utils.isEmpty(this.password)) {
  60. uni.showToast({
  61. title: "请输入密码",
  62. icon: 'none',
  63. });
  64. return
  65. }
  66. var data = {
  67. account:this.account,
  68. password: this.password,
  69. };
  70. var that=this;
  71. uni.showLoading({
  72. title:"处理中..."
  73. })
  74. login(data).then(
  75. res => {
  76. uni.hideLoading()
  77. if(res.code==200){
  78. uni.setStorageSync('AppToken',res.data.token);
  79. uni.setStorageSync('companyUserId',res.data.user.userId);
  80. uni.setStorageSync('companyUserInfo',JSON.stringify(res.data.user));
  81. uni.$emit('initSocket');
  82. uni.reLaunch({
  83. url: '../user/index',
  84. animationType: 'pop-in',
  85. animationDuration: 100
  86. })
  87. }
  88. else{
  89. uni.showToast({
  90. title: res.msg,
  91. icon: 'none'
  92. })
  93. }
  94. },
  95. rej => {}
  96. );
  97. }
  98. },
  99. }
  100. </script>
  101. <style lang="scss" scoped>
  102. page{
  103. background-color: #ffffff;
  104. }
  105. .content{
  106. background-color: #ffffff;
  107. display: flex;
  108. flex-direction: column;
  109. align-items: center;
  110. justify-content: center;
  111. // height: calc(100vh);
  112. overflow-y: auto;
  113. width: 100%;
  114. .login{
  115. width: 100%;
  116. padding-bottom: 50rpx;
  117. .head{
  118. text-align: center;
  119. image{
  120. padding: 20rpx;
  121. width: 120rpx;
  122. height: 120rpx;
  123. border-radius: 10rpx;
  124. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  125. }
  126. .title{
  127. color: #141414;
  128. margin:50upx 0upx 30upx 0rpx;
  129. font-size: 38rpx;
  130. font-weight: 500;
  131. }
  132. .desc{
  133. color: #686866;
  134. padding:0 0 30rpx 0rpx;
  135. font-size: 28rpx;
  136. }
  137. }
  138. .login{
  139. width: 100%;
  140. padding: 30rpx 50rpx;
  141. .login-item{
  142. margin-bottom: 30rpx;
  143. text-align: left;
  144. .input-account{
  145. margin-top: 20rpx;
  146. margin-bottom: 20rpx;
  147. border-radius:40rpx;
  148. border:solid 1rpx #e4e4e4;
  149. height: 80rpx;
  150. width: 100%;
  151. background:url(../../static/account.png) no-repeat 0 center;
  152. background-size: 30rpx 30rpx;
  153. background-position: 30rpx;
  154. input{
  155. margin-left: 80rpx;
  156. height: 80rpx;
  157. line-height: 80rpx
  158. }
  159. }
  160. .input-pwd{
  161. margin-top: 20rpx;
  162. margin-bottom: 20rpx;
  163. border-radius:40rpx;
  164. border:solid 1rpx #e4e4e4;
  165. height: 80rpx;
  166. width: 100%;
  167. background:url(../../static/password.png) no-repeat 0 center;
  168. background-size: 30rpx 30rpx;
  169. background-position: 30rpx;
  170. input{
  171. margin-left: 80rpx;
  172. height: 80rpx;
  173. line-height: 80rpx
  174. }
  175. }
  176. }
  177. .btns{
  178. margin: 60rpx 0rpx;
  179. .login-btn {
  180. display: flex;
  181. align-items: center;
  182. justify-content: center;
  183. width: 100%;
  184. height: 80rpx;
  185. background: linear-gradient(to right, #115296 0%, #115296 100%);
  186. background: -moz-linear-gradient(to right, #115296 0%, #115296 100%);
  187. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  188. border-radius: 40rpx;
  189. font-size: 30rpx;
  190. font-family: PingFang SC;
  191. font-weight: 500;
  192. color: rgba(255, 255, 255, 1);
  193. }
  194. }
  195. }
  196. }
  197. }
  198. .footer{
  199. color: #686866;
  200. width: 100%;
  201. position: sticky;
  202. text-align: center;
  203. bottom: 60upx;
  204. z-index: 1;
  205. font-size: 28rpx;
  206. }
  207. </style>