login.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="column" style="height: 100%;">
  3. <view class="content flex-1">
  4. <view class="login">
  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" placeholder="请输入帐号" type="text" ></input>
  15. </view>
  16. </view>
  17. <view class="login-item">
  18. <!-- <text>密码</text> -->
  19. <view class="input-pwd">
  20. <input v-model="password" placeholder="请输入密码" type="password" ></input>
  21. </view>
  22. </view>
  23. <view class="btns">
  24. <view class="login-btn" @click="login">登录</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="footer">
  30. <p>版权所有 @2024</p>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import { login } from '@/api/user.js'
  36. export default {
  37. data() {
  38. return {
  39. account:"",
  40. password:"",
  41. }
  42. },
  43. onLoad(option)
  44. {
  45. },
  46. onUnload() {
  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. width: 100%;
  113. .login{
  114. width: 100%;
  115. padding-bottom: 50rpx;
  116. .head{
  117. text-align: center;
  118. image{
  119. padding: 20rpx;
  120. width: 120rpx;
  121. height: 120rpx;
  122. border-radius: 10rpx;
  123. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  124. }
  125. .title{
  126. color: #141414;
  127. margin:50upx 0upx 30upx 0rpx;
  128. font-size: 38rpx;
  129. font-weight: 500;
  130. }
  131. .desc{
  132. color: #686866;
  133. padding:0 0 30rpx 0rpx;
  134. font-size: 28rpx;
  135. }
  136. }
  137. .login{
  138. width: 100%;
  139. padding: 30rpx 50rpx;
  140. .login-item{
  141. margin-bottom: 30rpx;
  142. text-align: left;
  143. .input-account{
  144. margin-top: 20rpx;
  145. margin-bottom: 20rpx;
  146. border-radius:40rpx;
  147. border:solid 1rpx #e4e4e4;
  148. height: 80rpx;
  149. width: 100%;
  150. background:url(../../static/account.png) no-repeat 0 center;
  151. background-size: 30rpx 30rpx;
  152. background-position: 30rpx;
  153. input{
  154. margin-left: 80rpx;
  155. height: 80rpx;
  156. line-height: 80rpx
  157. }
  158. }
  159. .input-pwd{
  160. margin-top: 20rpx;
  161. margin-bottom: 20rpx;
  162. border-radius:40rpx;
  163. border:solid 1rpx #e4e4e4;
  164. height: 80rpx;
  165. width: 100%;
  166. background:url(../../static/password.png) no-repeat 0 center;
  167. background-size: 30rpx 30rpx;
  168. background-position: 30rpx;
  169. input{
  170. margin-left: 80rpx;
  171. height: 80rpx;
  172. line-height: 80rpx
  173. }
  174. }
  175. }
  176. .btns{
  177. margin: 60rpx 0rpx;
  178. .login-btn {
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. width: 100%;
  183. height: 80rpx;
  184. background: linear-gradient(to right, #115296 0%, #115296 100%);
  185. background: -moz-linear-gradient(to right, #115296 0%, #115296 100%);
  186. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  187. border-radius: 40rpx;
  188. font-size: 30rpx;
  189. font-family: PingFang SC;
  190. font-weight: 500;
  191. color: rgba(255, 255, 255, 1);
  192. }
  193. }
  194. }
  195. }
  196. }
  197. .footer{
  198. color: #686866;
  199. width: 100%;
  200. position: fixed;
  201. text-align: center;
  202. bottom: 60upx;
  203. font-size: 28rpx;
  204. }
  205. </style>