contacts.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. <template>
  2. <div class="mainBox">
  3. <div class="hallBox">
  4. <div class="hallLeft">
  5. <!--添加好友 start------------------------------------------>
  6. <contactsTitle :name="tableTitleName" @addUser="addUser" @closeAddUser="closeAddUser" />
  7. <!--添加好友 end------------------------------------------>
  8. <!--搜索 start------------------------------------------>
  9. <div class="searchBox">
  10. <el-input
  11. placeholder="请输入用户账号"
  12. prefix-icon="el-icon-search"
  13. v-model="searchUserName"
  14. @keyup.enter.native="searchFriend"
  15. v-if="pagestatus == 4"
  16. >
  17. </el-input>
  18. <el-input
  19. placeholder="请输入好友账号"
  20. prefix-icon="el-icon-search"
  21. v-model="searchUserListName"
  22. @keyup.enter.native="searchOrdFriend"
  23. v-if="pagestatus==1||pagestatus==2||pagestatus==3"
  24. >
  25. </el-input>
  26. </div>
  27. <!--搜索 end------------------------------------------>
  28. <div class="newFriendBox">新的朋友</div>
  29. <div class="newFriendImgBox" v-if="pagestatus==4">
  30. <div class="newFriendImg">
  31. <img src="@/assets/chat/newcontacts.png">
  32. </div>
  33. <div class="newFriendText" @click="searchFriend">
  34. 搜索:{{searchUserName}}
  35. </div>
  36. <div class="searchFriendBox" v-if="searchWindowStatus==true">
  37. <div class="searchFriendItem">
  38. <div class="searchFriendAvatar">
  39. <img :src="searchFriendList.avatar" v-if="searchFriendList.avatar!=''">
  40. <img src="@/assets/chat/user/admin.png" v-else>
  41. </div>
  42. <div class="searchFriendInfo">
  43. <div class="searchFriendName">
  44. <div class="searchFriendNameText" v-if="searchFriendList.remark!=null&&searchFriendList.remark!=''">{{searchFriendList.remark}}</div>
  45. <div class="searchFriendNameText" v-else>{{searchFriendList.user_name}}</div>
  46. <!--性别-->
  47. <!-- <div class="gender"><img src="@/assets/chat/girl.png"></div> -->
  48. <!--更多-->
  49. <!-- <img src="@/assets/chat/fi_more.png"> -->
  50. </div>
  51. <div class="searchFriendPhone">账号:{{searchFriendList.user_name}}</div>
  52. </div>
  53. </div>
  54. <!-- <div v-if="searchFriendList.isfriend==0||searchFriendList.isfriend==null"></div>
  55. <div class="searchFriendLineBox" v-else @click="openEditWindow">
  56. <div class="searchFriendLineTitle">备注</div>
  57. <div class="searchFriendLineContent">
  58. <div class="searchFriendLineContentItem">
  59. <div>{{searchFriendList.remark}}</div>
  60. <div><i class="el-icon-edit"></i></div>
  61. </div>
  62. </div>
  63. </div> -->
  64. <!-- <div class="searchFriendLineBox">
  65. <div class="searchFriendLineTitle">共同群聊</div>
  66. <div class="searchFriendLineContent">0个</div>
  67. </div>
  68. <div class="searchFriendLineBox">
  69. <div class="searchFriendLineTitle">添加方式</div>
  70. <div class="searchFriendLineContent">通过账号添加</div>
  71. </div> -->
  72. <div class="searchFriendButton">
  73. <el-button type="primary" v-if="searchFriendList.showBtn==false&&searchFriendList.id!=this.$store.state.user.userid" @click="openAddWindow(searchFriendList.id)">添加到通讯录</el-button>
  74. <el-button type="danger" v-else-if="searchFriendList.showBtn==true" @click="deleteFriend(searchFriendList)">删除好友</el-button>
  75. <el-button type="primary" disabled v-else>添加到通讯录</el-button>
  76. </div>
  77. <!-- <div class="searchFriendButton">
  78. <div class="searchFriendButtonItem">
  79. <img src="@/assets/chat/sendmessage.png">
  80. <div>发消息</div>
  81. </div>
  82. </div> -->
  83. </div>
  84. </div>
  85. <div :class="['newFriendImgBox', pagestatus === 2 ? 'newFriendIActive' : '']" @click="tabPage(2)" v-else>
  86. <div class="newFriendImg">
  87. <img src="@/assets/chat/newcontacts.png">
  88. </div>
  89. <div class="newFriendText" v-if="pagestatus==4">
  90. 搜索:{{searchUserName}}
  91. </div>
  92. <div class="newFriendText" v-else>
  93. 新的朋友
  94. <span v-if="userApplyList.length>0">{{userApplyList.length}}</span>
  95. </div>
  96. </div>
  97. <!--用户列表 start------------------------------------------>
  98. <div class="userListBox" v-if="pagestatus==1||pagestatus==2||pagestatus==3">
  99. <!-- <div class="userListTitle">A</div> -->
  100. <div class="userItem" @click="changeUserItem(item.friend_id)" v-for="(item,index) in userFriendList" :key="index" :class="['userItem', { active: item.status == 1 }]">
  101. <div class="userAvatar">
  102. <img :src="item.avatar" v-if="item.avatar!=''">
  103. <img src="@/assets/chat/user/admin.png" v-else>
  104. </div>
  105. <div class="userInfo">
  106. <div class="userName">
  107. <div class="userNameText" v-if="item.remark!=null">{{item.user_name}}<span v-if="item.remark!=''">({{item.remark}})</span></div>
  108. <div class="userNameText" v-else>{{item.user_name}}</div>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. <!--用户列表 end------------------------------------------>
  114. </div>
  115. <div class="hallRight" v-if="pagestatus==1||pagestatus==4">
  116. <div class="ifHallRigthNoMessage">恒星管理平台</div>
  117. </div>
  118. <div class="hallRight" v-if="pagestatus==2">
  119. <div class="UserNameBox">
  120. <div class="userName">新的朋友</div>
  121. </div>
  122. <div class="rightNewFriendBox" v-for="(item,index) in userApplyList" :key="index">
  123. <div class="rightNewFriendItem">
  124. <div class="rightNewFriendAvatar">
  125. <img :src="item.avatar" v-if="item.avatar!=''">
  126. <img src="@/assets/chat/user/admin.png" v-else>
  127. </div>
  128. <div class="rightNewFriendInfo">
  129. <div class="rightNewFriendName">{{item.remark}}</div>
  130. <div class="rightNewFriendPhone">{{item.user_name}}</div>
  131. </div>
  132. </div>
  133. <div class="rightNewFriendStatus">
  134. <div class="rightNewFriendStatus2">
  135. <el-button type="primary" @click="openWindow(item)">接受</el-button>
  136. </div>
  137. </div>
  138. </div>
  139. <!-- <div class="rightNewFriendBox">
  140. <div class="rightNewFriendItem">
  141. <div class="rightNewFriendAvatar">
  142. <img src="@/assets/chat/user/user.png">
  143. </div>
  144. <div class="rightNewFriendInfo">
  145. <div class="rightNewFriendName">我是某某某</div>
  146. <div class="rightNewFriendPhone">15210211200</div>
  147. </div>
  148. </div>
  149. <div class="rightNewFriendStatus">
  150. <div class="rightNewFriendStatus1">已接受</div>
  151. </div>
  152. </div>
  153. <div class="rightNewFriendBox">
  154. <div class="rightNewFriendItem">
  155. <div class="rightNewFriendAvatar">
  156. <img src="@/assets/chat/user/user.png">
  157. </div>
  158. <div class="rightNewFriendInfo">
  159. <div class="rightNewFriendName">我是某某某</div>
  160. <div class="rightNewFriendPhone">15210211200</div>
  161. </div>
  162. </div>
  163. <div class="rightNewFriendStatus">
  164. <div class="rightNewFriendStatus2">
  165. <el-button type="primary" @click="friendWindowStatus=true">接受</el-button>
  166. </div>
  167. </div>
  168. </div> -->
  169. </div>
  170. <div class="hallRight" v-if="pagestatus==3">
  171. <div class="userInfoMainBox">
  172. <div class="userInfoMainItem">
  173. <div class="userInfoMainAvatar">
  174. <img :src="friendInfo.avatar" v-if="friendInfo.avatar!=''">
  175. <img src="@/assets/chat/user/admin.png" v-else>
  176. </div>
  177. <div class="userInfoMainInfo">
  178. <div class="userInfoMainName">
  179. <div class="userInfoMainNameText">{{friendInfo.user_name}}</div>
  180. </div>
  181. <div class="userInfoMainPhone">账号:{{friendInfo.user_name}}</div>
  182. </div>
  183. </div>
  184. <div class="userInfoMainLineBox">
  185. <div class="userInfoMainLineTitle">备注</div>
  186. <div class="userInfoMainLineContent">
  187. <div class="userInfoMainLineContentItem" @click="openEditWindow">
  188. <div v-if="friendInfo.remark!=null&&friendInfo.remark!=''">{{friendInfo.remark}}</div>
  189. <div v-else>暂无备注</div>
  190. <div><i class="el-icon-edit"></i></div>
  191. </div>
  192. </div>
  193. </div>
  194. <!-- <div class="userInfoMainLineBox">
  195. <div class="userInfoMainLineTitle">共同群聊</div>
  196. <div class="userInfoMainLineContent">0个</div>
  197. </div>
  198. <div class="userInfoMainLineBox">
  199. <div class="userInfoMainLineTitle">添加方式</div>
  200. <div class="userInfoMainLineContent">通过账号添加</div>
  201. </div> -->
  202. <div class="userInfoMainButton">
  203. <!-- <div class="userInfoMainButtonItem">
  204. <img src="@/assets/chat/sendmessage.png">
  205. <div>删除好友</div>
  206. </div> -->
  207. <el-button type="primary" icon="el-icon-s-promotion" @click="sendMessage(friendInfo)">发送消息</el-button>
  208. <el-button type="danger" icon="el-icon-delete" @click="deleteFriend(friendInfo.friend_id)">删除好友</el-button>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. <!--发送好友申请弹出框 start------------------------------------------------------------>
  214. <el-dialog :visible.sync="addFriendWindowStatus" title="朋友申请" :close-on-click-modal="false" width="420px">
  215. <div>
  216. <div>
  217. <el-form :model="form" ref="form" autocomplete="off" label-position="left">
  218. <div class="formDiv">
  219. <el-form-item label="验证消息:" :label-width="formLabelWidth" class="custom-align-right">
  220. <el-input v-model="addform.remark" autocomplete="off" placeholder="我是.."></el-input>
  221. </el-form-item>
  222. </div>
  223. </el-form>
  224. </div>
  225. <div class="footerButtonBox">
  226. <el-button type="info" @click="addFriendWindowStatus=false">取消</el-button>
  227. <el-button type="primary" @click="addMyFriend">确定</el-button>
  228. </div>
  229. </div>
  230. </el-dialog>
  231. <!--发送好友申请弹出框 end------------------------------------------------------------>
  232. <!--请求验证弹出框 start------------------------------------------------------------>
  233. <el-dialog :visible.sync="friendWindowStatus" title="通过朋友验证" :close-on-click-modal="false" width="420px">
  234. <div>
  235. <div class="friendWindowText">
  236. <!--此处修改备注是没用的,修改备注需要friendId,但是此时你们还不是好友,改不了备注-->
  237. <!-- <el-form :model="form" ref="form" autocomplete="off" label-position="left">
  238. <div class="formDiv">
  239. <el-form-item label="备注名" :label-width="formLabelWidth" class="custom-align-right">
  240. <el-input v-model="form.remark" autocomplete="off" placeholder="请输入备注名.."></el-input>
  241. </el-form-item>
  242. </div>
  243. </el-form> -->
  244. 确定要添加<span>{{friendInfo.user_name}}</span>为好友吗?
  245. </div>
  246. <div class="footerButtonBox">
  247. <el-button type="info" @click="friendWindowStatus=false">取消</el-button>
  248. <el-button type="primary" @click="addFriend">确定</el-button>
  249. </div>
  250. </div>
  251. </el-dialog>
  252. <!--请求验证弹出框 end------------------------------------------------------------>
  253. <!--修改备注弹出框 start------------------------------------------------------------>
  254. <el-dialog :visible.sync="editWindowStatus" title="修改备注" :close-on-click-modal="false" width="420px">
  255. <div>
  256. <div>
  257. <el-form :model="form" ref="form" autocomplete="off" label-position="left">
  258. <div class="formDiv">
  259. <el-form-item label="备注名" :label-width="formLabelWidth" class="custom-align-right">
  260. <el-input v-model="remark" autocomplete="off" placeholder="请输入备注名.."></el-input>
  261. </el-form-item>
  262. </div>
  263. </el-form>
  264. </div>
  265. <div class="footerButtonBox">
  266. <el-button type="info" @click="editWindowStatus=false">取消</el-button>
  267. <el-button type="primary" @click="editFriend">确定</el-button>
  268. </div>
  269. </div>
  270. </el-dialog>
  271. <!--修改备注弹出框 end------------------------------------------------------------>
  272. </div>
  273. </template>
  274. <script>
  275. //引入公用样式
  276. import '@/styles/global.less';
  277. //引入baseUrl
  278. import URL from '@/utils/baseUrl';
  279. //引入组件
  280. import contactsTitle from './components/contactsTitle.vue';
  281. import { status } from 'nprogress';
  282. import openWindow from '@/utils/open-window';
  283. export default {
  284. components: {
  285. contactsTitle
  286. },
  287. data() {
  288. return {
  289. //1.全局配置 start------------------------------------------------------------>
  290. tableTitleName:'通讯录',
  291. pagestatus:1,//1=没有选择任何联系人 2=申请列表 3=好友详情 4=搜索结果
  292. formLabelWidth:"100px",//表单label宽度
  293. searchUserName:"",//搜索新添加用户
  294. searchUserListName:"",//搜索好友列表
  295. friendId:"",//要添加的好友id
  296. friendWindowStatus:false,//通过朋友申请弹出框
  297. searchWindowStatus:false,//搜索窗口左侧弹出框
  298. searchUserWindowStatus:false,//搜索好友列表弹出框
  299. editWindowStatus:false,//修改备注弹出框
  300. addFriendWindowStatus:false,//发送好友申请弹出框
  301. editFriendId:"",//要编辑的好友
  302. getFriendApplyListStatus:null,//获取好友申请列表状态
  303. //1.全局配置 end------------------------------------------------------------>
  304. //2.好友列表 start------------------------------------------------------------>
  305. userFriendList:[],//好友列表
  306. userApplyList:[],//好友申请列表
  307. searchFriendList:"",//搜索好友列表
  308. //2.好友列表 end------------------------------------------------------------>
  309. //3.通过好友申请 start------------------------------------------------------------>
  310. form:{
  311. //好友的用户id
  312. id:"",
  313. //好友id
  314. friend_id:"",
  315. //好友申请
  316. remark:"",
  317. //状态
  318. status:2,
  319. //申请id
  320. apply_id:""
  321. },
  322. //3.通过好友申请 end------------------------------------------------------------>
  323. //4.编辑好友 start------------------------------------------------------------>
  324. friendInfo:{},//好友信息
  325. remark:"",//修改的用户备注
  326. //4.编辑好友 end------------------------------------------------------------>
  327. //5.发送好友申请 start------------------------------------------------------------>
  328. addform:{
  329. //好友id
  330. friend_id:"",
  331. //好友申请
  332. remark:"",
  333. },
  334. //5.发送好友申请 end------------------------------------------------------------>
  335. };
  336. },
  337. methods: {
  338. //0.全局操作 start------------------------------------------------------------>
  339. //0.1切换页面状态
  340. tabPage(status){
  341. this.pagestatus = status;
  342. if(status==2){
  343. //如果是2 好友列表状态还原
  344. for(let item of this.userFriendList){
  345. item.status = 0;
  346. }
  347. }
  348. this.getFriendApplyList();
  349. },
  350. //0.全局操作 end------------------------------------------------------------>
  351. //1.好友列表 start------------------------------------------------------------>
  352. addUser(){
  353. this.pagestatus = 4;
  354. },
  355. closeAddUser(){
  356. this.pagestatus = 2;
  357. this.searchWindowStatus = false;
  358. },
  359. //1.1获取联系人列表
  360. getUserFriendList(){
  361. //获取用户身份id
  362. //const userId = this.$store.state.user.userid;
  363. this.$store.dispatch('chat/getFriendsList',{}).then(res=> {
  364. let data = res.data;
  365. for(let item of data){
  366. item.status = 0; //默认未选中
  367. }
  368. this.userFriendList = data;
  369. }).catch(() => {
  370. this.$message.error('获取好友列表失败!')
  371. })
  372. },
  373. //1.2选择联系人
  374. changeUserItem(id){
  375. for(let item of this.userFriendList){
  376. if(item.friend_id == id){
  377. item.status = 1;
  378. }else{
  379. item.status = 0;
  380. }
  381. }
  382. //切换页面到用户列表
  383. this.pagestatus = 3;
  384. //把要编辑的好友的id存起来
  385. this.editFriendId = id;
  386. // console.log(id)
  387. // console.log(this.userFriendList)
  388. //获取好友身份信息详情
  389. this.$store.dispatch('chat/getFriendInfo',{friend_id:this.editFriendId}).then(res=> {
  390. console.log(res);
  391. //保存好友信息
  392. this.friendInfo = res.data;
  393. }).catch(() => {
  394. this.$message.error('获得好友身份详情失败!')
  395. })
  396. },
  397. //1.3搜索联系人
  398. searchFriend(){
  399. //搜索联系人
  400. this.$store.dispatch('chat/searchFriend',{keyword:this.searchUserName}).then(res=> {
  401. //获取到好友
  402. this.searchWindowStatus = false;
  403. console.log(res);
  404. if(res.code==200){
  405. if(res.data.length>0){
  406. this.searchWindowStatus = true;
  407. this.searchFriendList = res.data[0];
  408. //搜出来以后查询两人是否为好友
  409. this.searchIsFriend(this.searchFriendList)
  410. }else{
  411. this.$message.error('没有找到该联系人!')
  412. }
  413. }else{
  414. this.$message.error('搜索关键字不能为空!')
  415. }
  416. })
  417. },
  418. //1.3搜索好友列表中的好友
  419. searchOrdFriend(){
  420. if(this.searchUserListName==""){
  421. this.$message.error('搜索关键字不能为空!')
  422. return;
  423. }else{
  424. let isFriend = false;
  425. for(let item of this.userFriendList){
  426. if(item.user_name == this.searchUserListName){
  427. isFriend = true;
  428. this.searchFriendList = item;
  429. }
  430. }
  431. if(isFriend){
  432. this.changeUserItem(this.searchFriendList.friend_id)
  433. //console.log(this.searchFriendList);
  434. }else{
  435. this.$message.error('没有找到该联系人!')
  436. }
  437. }
  438. },
  439. //1.好友列表 end------------------------------------------------------------>
  440. //2.获得好友申请列表 start------------------------------------------------------------>
  441. //2.1 好友申请列表
  442. getFriendApplyList(){
  443. console.log("获取好友申请列表");
  444. const userId = this.$store.state.user.userid;
  445. this.$store.dispatch('chat/getFriendsApplyList',{user_id:userId}).then(res=> {
  446. this.userApplyList = res.data;
  447. }).catch(() => {
  448. this.$message.error('获取好友申请列表失败!')
  449. })
  450. },
  451. //2.2 接受好友申请
  452. addFriend(){
  453. //通过用户申请
  454. console.log(this.form);
  455. this.$store.dispatch('chat/applyFriend',this.form).then(res=> {
  456. if(res.code==200){
  457. this.$message.success('成功添加好友!')
  458. this.friendWindowStatus = false;
  459. //重新加载用户列表
  460. this.getUserFriendList();
  461. //清空右侧
  462. this.friendInfo = {};
  463. //this.pagestatus = 1;
  464. this.getFriendApplyListStatus();
  465. }
  466. })
  467. },
  468. //2.3 删除好友
  469. deleteFriend(id){
  470. console.log(id);
  471. if(id){
  472. this.editFriendId = String(id);
  473. }
  474. console.log(id)
  475. this.$confirm('此操作将永久删除该联系人, 是否继续?', '提示', {
  476. confirmButtonText: '确定',
  477. cancelButtonText: '取消',
  478. type: 'warning'
  479. }).then(() => {
  480. console.log(this.editFriendId);
  481. this.$store.dispatch('chat/delFriend',{friend_id:this.editFriendId}).then(res=> {
  482. this.$message.success('删除成功!')
  483. //关闭用户详情显示
  484. this.pagestatus = 1;
  485. //重新装在用户列表
  486. this.getUserFriendList();
  487. })
  488. }).catch(() => {
  489. this.$message({
  490. type: 'warning',
  491. message: '已取消删除'
  492. });
  493. });
  494. },
  495. //2.4 编辑好友
  496. editFriend(){
  497. let data = {
  498. friend_id:this.editFriendId,
  499. remark:this.remark
  500. }
  501. //this.editFriendId
  502. this.$store.dispatch('chat/updateFriend',data).then(res=> {
  503. if(res.code==200){
  504. this.$message.success('修改备注名成功!')
  505. this.pagestatus = 1;
  506. this.editWindowStatus = false;
  507. this.getUserFriendList();
  508. this.remark = "";
  509. }else{
  510. this.$message.error(res.message)
  511. }
  512. }).catch(() => {
  513. this.$message.error('修改备注名失败!')
  514. })
  515. },
  516. //2.5 发送好友申请
  517. addMyFriend(){
  518. console.log(this.addform);
  519. this.$store.dispatch('chat/addFriend',this.addform).then(res=> {
  520. this.$message.success("已成功发送好友申请!")
  521. this.addFriendWindowStatus = false;
  522. this.searchWindowStatus = false;
  523. this.addform.remark = "";
  524. })
  525. },
  526. //2.6 查询是否是好友
  527. searchIsFriend(item){
  528. let data = {
  529. friend_id:item.isfriend
  530. }
  531. console.log(data);
  532. this.$store.dispatch('chat/isFriend',data).then(res=>{
  533. console.log(res);
  534. if(res.code==0&&res.message=="不是好友"){
  535. this.searchFriendList.showBtn = false;
  536. }else{
  537. this.searchFriendList.showBtn = true;
  538. }
  539. this.$forceUpdate();
  540. })
  541. },
  542. //2.7 定时查询好友申请状态
  543. setTimeFriendApplyList(){
  544. console.log("定时查询好友申请状态");
  545. let that = this;
  546. this.getFriendApplyListStatus = setInterval(()=>{
  547. that.getFriendApplyList();
  548. },5000)
  549. },
  550. //2.获得好友申请列表 end------------------------------------------------------------>
  551. //3.操作弹出框 start------------------------------------------------------------>
  552. //用户菜单操作
  553. openWindow(item){
  554. this.form.id = item.id;
  555. this.form.friend_id = item.friend_id;
  556. this.friendInfo = item;
  557. //打开弹出框
  558. this.friendWindowStatus = true;
  559. },
  560. openEditWindow(id){
  561. //打开修改备注弹出框
  562. this.editWindowStatus = true;
  563. },
  564. openAddWindow(id){
  565. console.log(id);
  566. this.addform.friend_id = String(id);
  567. this.addFriendWindowStatus = true;
  568. },
  569. //发送消息
  570. sendMessage(friendInfo){
  571. console.log(friendInfo);
  572. //带着friend_id跳转到hall页面
  573. this.$router.push({
  574. path:'/hall',
  575. query:{friend_id:friendInfo.friend_id}
  576. });
  577. },
  578. //3.操作弹出框 end------------------------------------------------------------>
  579. },
  580. mounted() {
  581. //1.获取联系人列表
  582. this.getUserFriendList();
  583. //2.获取好友申请列表
  584. this.getFriendApplyList();
  585. //3.定时查询好友申请状态
  586. this.setTimeFriendApplyList();
  587. //打印当前用户id
  588. console.log("当前的用户id为:" + this.$store.state.user.userid);
  589. },
  590. beforeDestroy() {
  591. clearInterval(this.getFriendApplyListStatus);
  592. }
  593. };
  594. </script>
  595. <style scoped lang="less">
  596. .hallBox {
  597. display: flex;
  598. margin: 30px;
  599. //左侧
  600. .hallLeft {
  601. width: 420px;
  602. background: #fff;
  603. border-radius: 20px;
  604. margin-right: 20px;
  605. .newFriendBox {
  606. padding: 10px 25px 0 25px;
  607. font-size: 18px;
  608. color: #999;
  609. }
  610. .newFriendImgBox {
  611. margin: 10px 0 10px 0;
  612. padding: 20px 0 20px 25px;
  613. display: flex;
  614. align-items: center;
  615. justify-content: flex-start;
  616. cursor: pointer;
  617. border-bottom: 1px solid #E9EDF7;
  618. position: relative;
  619. box-sizing: border-box;
  620. border-right: 4px solid #fff;
  621. .newFriendImg {
  622. width: 58px;
  623. height: 58px;
  624. border-radius: 8px;
  625. background: #5570F1;
  626. display: flex;
  627. align-items: center;
  628. justify-content: center;
  629. margin-right: 20px;
  630. }
  631. .newFriendText {
  632. color: #333;
  633. font-size: 18px;
  634. display: flex;
  635. align-items: center;
  636. justify-content: space-between;
  637. flex: 1;
  638. span {
  639. background: #5570F1;
  640. color: #fff;
  641. line-height: 24px;
  642. font-size: 12px;
  643. width: 24px;
  644. height: 24px;
  645. text-align: center;
  646. border-radius: 50%;
  647. display: block;
  648. margin-right: 20px;
  649. }
  650. }
  651. }
  652. .newFriendIActive {
  653. border-right: 4px solid #5570F1 !important;
  654. background: #F5F7FD
  655. }
  656. .searchFriendBox {
  657. position: absolute;
  658. width: 280px;
  659. border-radius: 8px;
  660. top: 0;
  661. right: -300px;
  662. background: #fff;
  663. box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
  664. border-radius: 8px;
  665. z-index: 100;
  666. box-sizing: border-box;
  667. padding: 30px 0;
  668. .searchFriendItem {
  669. display: flex;
  670. align-items: center;
  671. justify-content: flex-start;
  672. border-bottom: 1px solid #E9EDF7;
  673. padding: 0 20px 30px 20px;
  674. .searchFriendAvatar {
  675. img {
  676. width: 66px;
  677. height: 66px;
  678. border-radius: 50%;
  679. }
  680. margin-right: 15px;
  681. }
  682. .searchFriendInfo {
  683. flex: 1;
  684. .searchFriendName {
  685. display: flex;
  686. align-items: center;
  687. .gender {
  688. img {
  689. width: 12px;
  690. height: 12px;
  691. }
  692. }
  693. img {
  694. width: 18px;
  695. height: 18px;
  696. cursor: pointer;
  697. }
  698. .searchFriendNameText {
  699. font-size: 18px;
  700. width: 120px;
  701. height: 28px;
  702. line-height: 28px;
  703. white-space: nowrap;
  704. overflow: hidden;
  705. text-overflow: ellipsis;
  706. }
  707. }
  708. .searchFriendPhone {
  709. font-size: 14px;
  710. color: #999;
  711. margin-top: 10px;
  712. }
  713. }
  714. }
  715. .searchFriendLineBox {
  716. display: flex;
  717. align-items: center;
  718. justify-content: flex-start;
  719. padding: 20px;
  720. border-bottom: 1px solid #E9EDF7;
  721. .searchFriendLineTitle{
  722. font-size: 16px;
  723. color: #999999;
  724. width: 90px;
  725. }
  726. .searchFriendLineContent{
  727. font-size: 16px;
  728. color: #333;
  729. flex: 1;
  730. .searchFriendLineContentItem{
  731. display: flex;
  732. align-items: center;
  733. justify-content: space-between;
  734. }
  735. }
  736. }
  737. .searchFriendButton {
  738. padding:40px 0 10px 0;
  739. text-align: center;
  740. .searchFriendButtonItem {
  741. font-size: 14px;
  742. color: #5570F1;
  743. img {
  744. width: 30px;
  745. height: 30px;
  746. margin-bottom: 5px;
  747. }
  748. }
  749. }
  750. }
  751. .userListTitle {
  752. padding: 15px 25px;
  753. font-size: 18px;
  754. color: #999;
  755. }
  756. .searchBox {
  757. padding-left: 25px;
  758. padding-right: 25px;
  759. padding-bottom: 20px;
  760. }
  761. .userListBox {
  762. padding: 15px 0;
  763. overflow-y: auto;
  764. height: 380px;
  765. .active {
  766. background: #F5F7FD;
  767. box-sizing: border-box;
  768. border-right: 4px solid #5570F1 !important;
  769. }
  770. .userItem {
  771. padding: 0 21px 0 25px;
  772. display: flex;
  773. align-items: center;
  774. justify-content: space-between;
  775. height: 90px;
  776. box-sizing: border-box;
  777. border-right: 4px solid #fff;
  778. cursor: pointer;
  779. .userAvatar {
  780. img {
  781. width: 58px;
  782. height: 58px;
  783. border-radius: 50%;
  784. }
  785. }
  786. .userInfo {
  787. flex: 1;
  788. box-sizing: border-box;
  789. padding-left: 15px;
  790. .userName {
  791. display: flex;
  792. align-items: center;
  793. justify-content: space-between;
  794. .userNameText {
  795. font-size: 18px;
  796. font-weight: bold;
  797. width: 240px;
  798. white-space: nowrap;
  799. overflow: hidden;
  800. text-overflow: ellipsis;
  801. color: #333;
  802. }
  803. .userMessageNum {
  804. font-size: 12px;
  805. color: #333;
  806. width: 24px;
  807. height: 24px;
  808. line-height: 24px;
  809. text-align: center;
  810. border-radius: 50%;
  811. background: #FFCC91;
  812. font-weight: bold;
  813. }
  814. }
  815. .userMessage {
  816. display: flex;
  817. align-items: center;
  818. justify-content: space-between;
  819. .userMessageText {
  820. display: block;
  821. width: 240px;
  822. white-space: nowrap;
  823. overflow: hidden;
  824. text-overflow: ellipsis;
  825. font-size: 14px;
  826. color: #999999;
  827. }
  828. .userMessageTime {
  829. font-size: 14px;
  830. color: #999999;
  831. }
  832. }
  833. }
  834. }
  835. }
  836. }
  837. //右侧
  838. .hallRight {
  839. flex: 1;
  840. background: #fff;
  841. border-radius: 20px;
  842. position: relative;
  843. height: 740px;
  844. .rightNewFriendBox {
  845. height: 126px;
  846. border-bottom: 1px solid #E9EDF7;
  847. display: flex;
  848. align-items: center;
  849. justify-content: space-between;
  850. box-sizing: border-box;
  851. padding: 30px 40px;
  852. .rightNewFriendItem {
  853. display: flex;
  854. align-items: center;
  855. .rightNewFriendAvatar {
  856. margin-right: 15px;
  857. img {
  858. width: 66px;
  859. height: 66px;
  860. border-radius: 50%;
  861. }
  862. }
  863. .rightNewFriendInfo {
  864. .rightNewFriendName {
  865. font-size: 18px;
  866. margin-bottom: 7px;
  867. }
  868. .rightNewFriendPhone {
  869. font-size: 18px;
  870. color: #999;
  871. }
  872. }
  873. }
  874. .rightNewFriendStatus {
  875. .rightNewFriendStatus1 {
  876. font-size: 16px;
  877. color: #999;
  878. width: 69px;
  879. text-align: center;
  880. }
  881. }
  882. }
  883. .userInfoMainBox {
  884. padding: 40px;
  885. max-width: 900px;
  886. margin: 100px auto 0 auto;
  887. .userInfoMainItem {
  888. display: flex;
  889. align-items: center;
  890. justify-content: flex-start;
  891. border-bottom: 1px solid #E9EDF7;
  892. padding: 0 20px 30px 20px;
  893. .userInfoMainAvatar {
  894. img {
  895. width: 66px;
  896. height: 66px;
  897. border-radius: 50%;
  898. }
  899. margin-right: 15px;
  900. }
  901. .userInfoMainInfo {
  902. flex: 1;
  903. .userInfoMainName {
  904. display: flex;
  905. align-items: center;
  906. justify-content: space-between;
  907. img {
  908. width: 18px;
  909. height: 18px;
  910. cursor: pointer;
  911. }
  912. .userInfoMainNameText {
  913. font-size: 18px;
  914. width: 240px;
  915. height: 28px;
  916. line-height: 28px;
  917. white-space: nowrap;
  918. overflow: hidden;
  919. text-overflow: ellipsis;
  920. }
  921. }
  922. .userInfoMainPhone {
  923. font-size: 14px;
  924. color: #999;
  925. margin-top: 10px;
  926. }
  927. }
  928. }
  929. .userInfoMainLineBox {
  930. display: flex;
  931. align-items: center;
  932. justify-content: flex-start;
  933. padding: 20px;
  934. border-bottom: 1px solid #E9EDF7;
  935. .userInfoMainLineTitle{
  936. font-size: 16px;
  937. color: #999999;
  938. width: 90px;
  939. }
  940. .userInfoMainLineContent{
  941. font-size: 16px;
  942. color: #333;
  943. flex: 1;
  944. .userInfoMainLineContentItem{
  945. display: flex;
  946. align-items: center;
  947. justify-content: space-between;
  948. cursor: pointer;
  949. }
  950. }
  951. }
  952. .userInfoMainButton {
  953. padding:40px 0 10px 0;
  954. text-align: center;
  955. .userInfoMainButtonItem {
  956. font-size: 14px;
  957. color: #5570F1;
  958. img {
  959. width: 30px;
  960. height: 30px;
  961. margin-bottom: 5px;
  962. }
  963. }
  964. }
  965. }
  966. .ifHallRigthNoMessage {
  967. color: #CCCCCC;
  968. font-size: 32px;
  969. font-weight: bold;
  970. text-align: center;
  971. height: 740px;
  972. line-height: 740px;
  973. }
  974. .userName {
  975. font-size: 20px;
  976. color: #333;
  977. font-weight: bold;
  978. }
  979. .ifNotice {
  980. padding-bottom: 60px !important;
  981. }
  982. .UserNameBox {
  983. display: flex;
  984. align-items: center;
  985. justify-content: space-between;
  986. padding: 40px 30px 30px 30px;
  987. border-bottom: 1px solid #E7E7E7;
  988. position: relative;
  989. .moreIcon {
  990. cursor: pointer;
  991. }
  992. .groupNotice {
  993. position: absolute;
  994. height: 40px;
  995. line-height: 40px;
  996. font-size: 16px;
  997. background:url('../../assets/chat/notice.png') no-repeat 10px center #F6F8FE;
  998. left: 30px;
  999. box-sizing: border-box;
  1000. padding-left: 40px;
  1001. bottom: 10px;
  1002. color: #999999;
  1003. border-radius: 10px;
  1004. padding-right: 10px;
  1005. width: 400px;
  1006. white-space: nowrap;
  1007. overflow: hidden;
  1008. text-overflow: ellipsis;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. //弹出框底部按钮
  1014. .footerButtonBox {
  1015. padding-top: 40px;
  1016. text-align: center;
  1017. }
  1018. .friendWindowText {
  1019. font-size: 16px;
  1020. color: #333;
  1021. span {
  1022. color: #5570F1;
  1023. font-weight: bold;
  1024. }
  1025. }
  1026. //表单微调 start------------------------------------------------------------>*/
  1027. ::v-deep .custom-form-item > .el-form-item__label {
  1028. line-height: 140px !important;
  1029. }
  1030. ::v-deep .custom-textarea .el-textarea__inner {
  1031. resize: none; /* 禁止用拖拽调整大小 */
  1032. }
  1033. ::v-deep .custom-align-right .el-form-item__label {
  1034. text-align: right; /* 设置标签文字右对齐 */
  1035. }
  1036. ::v-deep .el-select-group__title {
  1037. color: #909399;
  1038. }
  1039. ::v-deep .el-select {
  1040. width: 100% !important;
  1041. }
  1042. ::v-deep .el-tabs__active-bar{
  1043. height: 1px !important;
  1044. }
  1045. ::v-deep .el-tabs__nav-wrap::after {
  1046. height:1px !important;
  1047. }
  1048. ::v-deep .el-tabs__header {
  1049. margin-bottom: 0 !important;
  1050. }
  1051. </style>