login.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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" placeholder="请输入帐号/手机号" type="text"/>
  15. </view>
  16. </view>
  17. <view class="login-item">
  18. <!-- <text>密码</text> -->
  19. <view class="input-pwd">
  20. <input v-model="password" placeholder="请输入密码" password type="text"/>
  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-tips">重庆云联融智提供技术支持</view> -->
  30. </view>
  31. </template>
  32. <script>
  33. import { login } from './api/manageCompany.js'
  34. import IMSDK from "openim-uniapp-polyfill";
  35. import { callingModule, meetingModule } from "@/pages_im/util/imCommon";
  36. export default {
  37. data() {
  38. return {
  39. account:"",
  40. password:"",
  41. }
  42. },
  43. computed: {
  44. imgPath() {
  45. return this.$store.getters.imgpath
  46. },
  47. appid() {
  48. return this.$store.getters.appid
  49. },
  50. },
  51. onLoad(option) {
  52. },
  53. mounted() {
  54. },
  55. onShow() {
  56. // let loginPage = '';
  57. // // #ifdef MP-WEIXIN
  58. // loginPage = '/pages/auth/wxlogin';
  59. // // #endif
  60. // loginPage = '/pages/auth/login';
  61. // uni.reLaunch({
  62. // url:loginPage,
  63. // success: () => {
  64. // uni.hideLoading();
  65. // },
  66. // fail: () => {
  67. // uni.hideLoading();
  68. // }
  69. // });
  70. console.log(this.$store.getters.imgpath+'/app/images/card_icon.png')
  71. },
  72. methods: {
  73. login(){
  74. if (!this.account || this.account.trim() === '') {
  75. uni.showToast({
  76. title: "请输入帐号",
  77. icon: 'none',
  78. });
  79. return;
  80. }
  81. if (!this.password || this.password.trim() === '') {
  82. uni.showToast({
  83. title: "请输入密码",
  84. icon: 'none',
  85. });
  86. return;
  87. }
  88. var data = {
  89. account:this.account,
  90. password: this.password,
  91. appid:this.appid
  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.showToast({icon:'success',title: "登录成功"});
  102. uni.setStorageSync('ManageToken',res.data.token);
  103. uni.setStorageSync('companyUserId',res.data.user.userId);
  104. uni.setStorageSync('companyUserInfo',JSON.stringify(res.data.user));
  105. uni.setStorageSync('CompanyUserToken',res.companyUserToken);
  106. uni.setStorageSync('companyUser',JSON.stringify(res.data.user));
  107. let CompanyUserToken=uni.getStorageSync("CompanyUserToken");
  108. if(!CompanyUserToken){
  109. IMSDK.asyncApi(IMSDK.IMMethods.Logout, IMSDK.uuid()).then(() => {
  110. callingModule?.endCall();
  111. meetingModule?.endCall();
  112. uni.removeStorage({ key: 'IMToken' });
  113. uni.removeStorage({ key: 'IMUserID' });
  114. uni.removeStorage({key: "IMHasLogin" });
  115. setTimeout(()=>{
  116. uni.$emit('refreshIM');
  117. },500);
  118. }).catch((err) => console.log(err)).finally(() => {
  119. uni.$emit('refreshIMMenu');
  120. });
  121. }
  122. uni.$emit('initSocket');
  123. uni.redirectTo({
  124. // url: '../user/index',
  125. url: "/pages_manage/index",
  126. animationType: 'pop-in',
  127. animationDuration: 100
  128. })
  129. }
  130. else{
  131. uni.showToast({
  132. title: res.msg,
  133. icon: 'none'
  134. })
  135. }
  136. },
  137. rej => {}
  138. );
  139. }
  140. },
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. page{
  145. background-color: #ffffff;
  146. }
  147. .footer-tips {
  148. margin-top: 14rpx;
  149. text-align: center;
  150. font-family: PingFang SC,PingFang SC;
  151. font-weight: 500;
  152. font-size: 12px;
  153. color: #bbb;
  154. }
  155. .content{
  156. background-color: #ffffff;
  157. display: flex;
  158. flex-direction: column;
  159. align-items: center;
  160. justify-content: center;
  161. // height: calc(100vh);
  162. overflow-y: auto;
  163. width: 100%;
  164. .login{
  165. width: 100%;
  166. padding-bottom: 50rpx;
  167. .head{
  168. text-align: center;
  169. image{
  170. margin: 20rpx;
  171. margin-top: 20px;
  172. width: 120rpx;
  173. height: 120rpx;
  174. border-radius: 10rpx;
  175. //box-shadow:0px 0px 20rpx rgba(0,0,0,0.2);
  176. }
  177. .title{
  178. color: #141414;
  179. margin:50upx 0upx 30upx 0rpx;
  180. font-size: 38rpx;
  181. font-weight: 500;
  182. }
  183. .desc{
  184. color: #686866;
  185. padding:0 0 30rpx 0rpx;
  186. font-size: 28rpx;
  187. }
  188. }
  189. .login{
  190. width: 100%;
  191. padding: 30rpx 50rpx;
  192. .login-item{
  193. margin-bottom: 30rpx;
  194. text-align: left;
  195. .input-account{
  196. margin-top: 20rpx;
  197. margin-bottom: 20rpx;
  198. border-radius:40rpx;
  199. border:solid 1rpx #e4e4e4;
  200. height: 80rpx;
  201. width: 100%;
  202. background:url('@/static/account.png') no-repeat 0 center;
  203. background-size: 30rpx 30rpx;
  204. background-position: 30rpx;
  205. input{
  206. margin-left: 80rpx;
  207. height: 80rpx;
  208. line-height: 80rpx
  209. }
  210. }
  211. .input-pwd{
  212. margin-top: 20rpx;
  213. margin-bottom: 20rpx;
  214. border-radius:40rpx;
  215. border:solid 1rpx #e4e4e4;
  216. height: 80rpx;
  217. width: 100%;
  218. background:url('@/static/password.png') no-repeat 0 center;
  219. background-size: 30rpx 30rpx;
  220. background-position: 30rpx;
  221. input{
  222. margin-left: 80rpx;
  223. height: 80rpx;
  224. line-height: 80rpx
  225. }
  226. }
  227. }
  228. .btns{
  229. margin: 60rpx 0rpx;
  230. .login-btn {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. width: 100%;
  235. height: 80rpx;
  236. // background: linear-gradient(to bottom, #cfe3ff, #cabbfd);
  237. background: #5c82ff;
  238. box-shadow: 0px 7rpx 6rpx 0px rgba(0, 0, 0, 0.2);
  239. border-radius: 40rpx;
  240. font-size: 30rpx;
  241. font-family: PingFang SC;
  242. font-weight: 500;
  243. color: rgba(255, 255, 255, 1.0);
  244. }
  245. }
  246. }
  247. }
  248. }
  249. .footer{
  250. color: #686866;
  251. width: 100%;
  252. position: sticky;
  253. text-align: center;
  254. bottom: 60upx;
  255. z-index: 1;
  256. font-size: 28rpx;
  257. }
  258. </style>