login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. mounted() {
  48. },
  49. onShow() {
  50. // let loginPage = '';
  51. // // #ifdef MP-WEIXIN
  52. // loginPage = '/pages/auth/wxlogin';
  53. // // #endif
  54. // loginPage = '/pages/auth/login';
  55. // uni.reLaunch({
  56. // url:loginPage,
  57. // success: () => {
  58. // uni.hideLoading();
  59. // },
  60. // fail: () => {
  61. // uni.hideLoading();
  62. // }
  63. // })
  64. },
  65. methods: {
  66. login(){
  67. if (this.utils.isEmpty(this.account)) {
  68. uni.showToast({
  69. title: "请输入帐号",
  70. icon: 'none',
  71. });
  72. return
  73. }
  74. if (this.utils.isEmpty(this.password)) {
  75. uni.showToast({
  76. title: "请输入密码",
  77. icon: 'none',
  78. });
  79. return
  80. }
  81. var data = {
  82. account:this.account,
  83. password: this.password,
  84. };
  85. var that=this;
  86. uni.showLoading({
  87. title:"处理中..."
  88. })
  89. login(data).then(
  90. res => {
  91. uni.hideLoading()
  92. if(res.code==200){
  93. uni.setStorageSync('AppToken',res.data.token);
  94. uni.setStorageSync('companyUserId',res.data.user.userId);
  95. uni.setStorageSync('companyUserInfo',JSON.stringify(res.data.user));
  96. uni.$emit('initSocket');
  97. uni.reLaunch({
  98. // url: '../user/index',
  99. url: "/pages/index/index",
  100. animationType: 'pop-in',
  101. animationDuration: 100
  102. })
  103. }
  104. else{
  105. uni.showToast({
  106. title: res.msg,
  107. icon: 'none'
  108. })
  109. }
  110. },
  111. rej => {}
  112. );
  113. }
  114. },
  115. }
  116. </script>
  117. <style lang="scss" scoped>
  118. page{
  119. background-color: #ffffff;
  120. }
  121. .content{
  122. background-color: #ffffff;
  123. display: flex;
  124. flex-direction: column;
  125. align-items: center;
  126. justify-content: center;
  127. // height: calc(100vh);
  128. overflow-y: auto;
  129. width: 100%;
  130. .login{
  131. width: 100%;
  132. padding-bottom: 50rpx;
  133. .head{
  134. text-align: center;
  135. image{
  136. padding: 20rpx;
  137. width: 120rpx;
  138. height: 120rpx;
  139. border-radius: 10rpx;
  140. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  141. }
  142. .title{
  143. color: #141414;
  144. margin:50upx 0upx 30upx 0rpx;
  145. font-size: 38rpx;
  146. font-weight: 500;
  147. }
  148. .desc{
  149. color: #686866;
  150. padding:0 0 30rpx 0rpx;
  151. font-size: 28rpx;
  152. }
  153. }
  154. .login{
  155. width: 100%;
  156. padding: 30rpx 50rpx;
  157. .login-item{
  158. margin-bottom: 30rpx;
  159. text-align: left;
  160. .input-account{
  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/account.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. .input-pwd{
  177. margin-top: 20rpx;
  178. margin-bottom: 20rpx;
  179. border-radius:40rpx;
  180. border:solid 1rpx #e4e4e4;
  181. height: 80rpx;
  182. width: 100%;
  183. background:url(../../static/password.png) no-repeat 0 center;
  184. background-size: 30rpx 30rpx;
  185. background-position: 30rpx;
  186. input{
  187. margin-left: 80rpx;
  188. height: 80rpx;
  189. line-height: 80rpx
  190. }
  191. }
  192. }
  193. .btns{
  194. margin: 60rpx 0rpx;
  195. .login-btn {
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. width: 100%;
  200. height: 80rpx;
  201. // background: linear-gradient(to bottom, #cfe3ff, #cabbfd);
  202. background: #5c82ff;
  203. box-shadow: 0px 7rpx 6rpx 0px rgba(0, 0, 0, 0.2);
  204. border-radius: 40rpx;
  205. font-size: 30rpx;
  206. font-family: PingFang SC;
  207. font-weight: 500;
  208. color: rgba(255, 255, 255, 1.0);
  209. }
  210. }
  211. }
  212. }
  213. }
  214. .footer{
  215. color: #686866;
  216. width: 100%;
  217. position: sticky;
  218. text-align: center;
  219. bottom: 60upx;
  220. z-index: 1;
  221. font-size: 28rpx;
  222. }
  223. </style>