login.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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="imgPath+'/app/image/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="请输入密码" password type="text"></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-tips">重庆云联融智提供技术支持</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. computed: {
  44. imgPath() {
  45. // 处理空值,返回默认路径或空字符串
  46. // if (!this.$store.state.imgpath) {
  47. // return '' // 本地默认图
  48. // }
  49. return this.$store.state.imgpath
  50. }
  51. },
  52. onLoad(option) {
  53. },
  54. mounted() {
  55. },
  56. onShow() {
  57. // let loginPage = '';
  58. // // #ifdef MP-WEIXIN
  59. // loginPage = '/pages/auth/wxlogin';
  60. // // #endif
  61. // loginPage = '/pages/auth/login';
  62. // uni.reLaunch({
  63. // url:loginPage,
  64. // success: () => {
  65. // uni.hideLoading();
  66. // },
  67. // fail: () => {
  68. // uni.hideLoading();
  69. // }
  70. // })
  71. console.log(this.$store.state.imgpath+'/app/images/card_icon.png')
  72. },
  73. methods: {
  74. login(){
  75. if (this.utils.isEmpty(this.account)) {
  76. uni.showToast({
  77. title: "请输入帐号",
  78. icon: 'none',
  79. });
  80. return
  81. }
  82. if (this.utils.isEmpty(this.password)) {
  83. uni.showToast({
  84. title: "请输入密码",
  85. icon: 'none',
  86. });
  87. return
  88. }
  89. var data = {
  90. account:this.account,
  91. password: this.password,
  92. };
  93. var that=this;
  94. uni.showLoading({
  95. title:"处理中..."
  96. })
  97. login(data).then(
  98. res => {
  99. uni.hideLoading()
  100. if(res.code==200){
  101. uni.setStorageSync('AppToken',res.data.token);
  102. uni.setStorageSync('companyUserId',res.data.user.userId);
  103. uni.setStorageSync('companyUserInfo',JSON.stringify(res.data.user));
  104. uni.$emit('initSocket');
  105. uni.reLaunch({
  106. // url: '../user/index',
  107. url: "/pages/index/index",
  108. animationType: 'pop-in',
  109. animationDuration: 100
  110. })
  111. }
  112. else{
  113. uni.showToast({
  114. title: res.msg,
  115. icon: 'none'
  116. })
  117. }
  118. },
  119. rej => {}
  120. );
  121. }
  122. },
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. page{
  127. background-color: #ffffff;
  128. }
  129. .footer-tips {
  130. margin-top: 14rpx;
  131. text-align: center;
  132. font-family: PingFang SC,PingFang SC;
  133. font-weight: 500;
  134. font-size: 12px;
  135. color: #bbb;
  136. }
  137. .content{
  138. background-color: #ffffff;
  139. display: flex;
  140. flex-direction: column;
  141. align-items: center;
  142. justify-content: center;
  143. // height: calc(100vh);
  144. overflow-y: auto;
  145. width: 100%;
  146. .login{
  147. width: 100%;
  148. padding-bottom: 50rpx;
  149. .head{
  150. text-align: center;
  151. image{
  152. padding: 20rpx;
  153. width: 120rpx;
  154. height: 120rpx;
  155. border-radius: 10rpx;
  156. box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  157. }
  158. .title{
  159. color: #141414;
  160. margin:50upx 0upx 30upx 0rpx;
  161. font-size: 38rpx;
  162. font-weight: 500;
  163. }
  164. .desc{
  165. color: #686866;
  166. padding:0 0 30rpx 0rpx;
  167. font-size: 28rpx;
  168. }
  169. }
  170. .login{
  171. width: 100%;
  172. padding: 30rpx 50rpx;
  173. .login-item{
  174. margin-bottom: 30rpx;
  175. text-align: left;
  176. .input-account{
  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/account.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. .input-pwd{
  193. margin-top: 20rpx;
  194. margin-bottom: 20rpx;
  195. border-radius:40rpx;
  196. border:solid 1rpx #e4e4e4;
  197. height: 80rpx;
  198. width: 100%;
  199. background:url(../../static/password.png) no-repeat 0 center;
  200. background-size: 30rpx 30rpx;
  201. background-position: 30rpx;
  202. input{
  203. margin-left: 80rpx;
  204. height: 80rpx;
  205. line-height: 80rpx
  206. }
  207. }
  208. }
  209. .btns{
  210. margin: 60rpx 0rpx;
  211. .login-btn {
  212. display: flex;
  213. align-items: center;
  214. justify-content: center;
  215. width: 100%;
  216. height: 80rpx;
  217. // background: linear-gradient(to bottom, #cfe3ff, #cabbfd);
  218. background: #5c82ff;
  219. box-shadow: 0px 7rpx 6rpx 0px rgba(0, 0, 0, 0.2);
  220. border-radius: 40rpx;
  221. font-size: 30rpx;
  222. font-family: PingFang SC;
  223. font-weight: 500;
  224. color: rgba(255, 255, 255, 1.0);
  225. }
  226. }
  227. }
  228. }
  229. }
  230. .footer{
  231. color: #686866;
  232. width: 100%;
  233. position: sticky;
  234. text-align: center;
  235. bottom: 60upx;
  236. z-index: 1;
  237. font-size: 28rpx;
  238. }
  239. </style>