login.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view>
  3. <view class="content">
  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.$emit('initSocket');
  81. uni.reLaunch({
  82. url: '../user/index',
  83. animationType: 'pop-in',
  84. animationDuration: 100
  85. })
  86. }
  87. else{
  88. uni.showToast({
  89. title: res.msg,
  90. icon: 'none'
  91. })
  92. }
  93. },
  94. rej => {}
  95. );
  96. }
  97. },
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. page{
  102. background-color: #ffffff;
  103. }
  104. .content{
  105. background-color: #ffffff;
  106. display: flex;
  107. flex-direction: column;
  108. align-items: center;
  109. justify-content: center;
  110. height: calc(100vh);
  111. width: 100%;
  112. .login{
  113. width: 100%;
  114. padding-bottom: 50rpx;
  115. .head{
  116. text-align: center;
  117. image{
  118. padding: 20rpx;
  119. width: 120rpx;
  120. height: 120rpx;
  121. border-radius: 10rpx;
  122. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  123. }
  124. .title{
  125. color: #141414;
  126. margin:50upx 0upx 30upx 0rpx;
  127. font-size: 38rpx;
  128. font-weight: 500;
  129. }
  130. .desc{
  131. color: #686866;
  132. padding:0 0 30rpx 0rpx;
  133. font-size: 28rpx;
  134. }
  135. }
  136. .login{
  137. width: 100%;
  138. padding: 30rpx 50rpx;
  139. .login-item{
  140. margin-bottom: 30rpx;
  141. text-align: left;
  142. .input-account{
  143. margin-top: 20rpx;
  144. margin-bottom: 20rpx;
  145. border-radius:40rpx;
  146. border:solid 1rpx #e4e4e4;
  147. height: 80rpx;
  148. width: 100%;
  149. background:url(../../static/account.png) no-repeat 0 center;
  150. background-size: 30rpx 30rpx;
  151. background-position: 30rpx;
  152. input{
  153. margin-left: 80rpx;
  154. height: 80rpx;
  155. line-height: 80rpx
  156. }
  157. }
  158. .input-pwd{
  159. margin-top: 20rpx;
  160. margin-bottom: 20rpx;
  161. border-radius:40rpx;
  162. border:solid 1rpx #e4e4e4;
  163. height: 80rpx;
  164. width: 100%;
  165. background:url(../../static/password.png) no-repeat 0 center;
  166. background-size: 30rpx 30rpx;
  167. background-position: 30rpx;
  168. input{
  169. margin-left: 80rpx;
  170. height: 80rpx;
  171. line-height: 80rpx
  172. }
  173. }
  174. }
  175. .btns{
  176. margin: 60rpx 0rpx;
  177. .login-btn {
  178. display: flex;
  179. align-items: center;
  180. justify-content: center;
  181. width: 100%;
  182. height: 80rpx;
  183. background: linear-gradient(to right, #115296 0%, #115296 100%);
  184. background: -moz-linear-gradient(to right, #115296 0%, #115296 100%);
  185. box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
  186. border-radius: 40rpx;
  187. font-size: 30rpx;
  188. font-family: PingFang SC;
  189. font-weight: 500;
  190. color: rgba(255, 255, 255, 1);
  191. }
  192. }
  193. }
  194. }
  195. }
  196. .footer{
  197. color: #686866;
  198. width: 100%;
  199. position: fixed;
  200. text-align: center;
  201. bottom: 60upx;
  202. font-size: 28rpx;
  203. }
  204. </style>