network.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. <template>
  2. <view>
  3. <!-- 切换和搜索 -->
  4. <view class="top-bar">
  5. <view class="tab-nav ddflex">
  6. <view :class="'tab-nav-item '+(tabIndex==1?'tab-nav-item-active':'')" @click="changTab(1)">人脉圈</view>
  7. <view :class="'tab-nav-item '+(tabIndex==2?'tab-nav-item-active':'')" @click="changTab(2)">名片夹</view>
  8. </view>
  9. <!-- 搜索 -->
  10. <view class="search">
  11. <view class="search-bar ddflex">
  12. <image src="../../static/images/ssico.png" class="ssico"></image>
  13. <input v-model="search" placeholder="搜索" confirm-type="search" @confirm="searchFn()" placeholder-class="placeholder" class="ipt fflex" />
  14. <!-- <view class="clear">取消</view> -->
  15. </view>
  16. </view>
  17. <!-- 分类 -->
  18. <view class="rec-association-2 ddflex" v-if="tabIndex==2">
  19. <view class="ddflex fflex">
  20. <view class="rec-association-nav-2 fflex">
  21. <scroll-view scroll-x="true" class="rec-association-scroll-2 ddflex">
  22. <view :class="'rec-association-scroll-item-2 tover '+(groupId == null?'rec-association-scroll-item-2-active':'')" @click="getCon(null,-1)">全部</view>
  23. <view :class="'rec-association-scroll-item-2 tover '+(groupId == item.id?'rec-association-scroll-item-2-active':'')" @click="getCon(item,index)" v-for="item,index in cardGroup" :key="index">{{item.groupName}}</view>
  24. </scroll-view>
  25. <view class="rec-association-nav-m-2"></view>
  26. </view>
  27. </view>
  28. <view class="dflex add" @click="jumpUrl('/card/groupManage/groupManage')">
  29. <image style="width: 32rpx;height: 32rpx;margin-right: 10rpx;margin-top: 16rpx;" src="../static/images/addFile.png"></image>
  30. <text>管理</text>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 隐藏 -->
  35. <view class="top-bar" style="position: relative;visibility: hidden;">
  36. <view class="tab-nav ddflex">
  37. <view :class="'tab-nav-item '+(tabIndex==1?'tab-nav-item-active':'')" @click="changTab(1)">人脉圈</view>
  38. <view :class="'tab-nav-item '+(tabIndex==2?'tab-nav-item-active':'')" @click="changTab(2)">名片夹</view>
  39. </view>
  40. <!-- 搜索 -->
  41. <view class="search">
  42. <view class="search-bar ddflex">
  43. <image src="../../static/images/ssico.png" class="ssico"></image>
  44. <input v-model="search" placeholder="搜索" confirm-type="search" @confirm="searchFn()" placeholder-class="placeholder" class="ipt fflex" />
  45. <!-- <view class="clear">取消</view> -->
  46. </view>
  47. </view>
  48. <!-- 分类 -->
  49. <view class="rec-association-2 ddflex" v-if="tabIndex==2">
  50. <view class="ddflex fflex">
  51. <view class="rec-association-nav-2 fflex">
  52. <scroll-view scroll-x="true" class="rec-association-scroll-2 ddflex">
  53. <view :class="'rec-association-scroll-item-2 tover '+(groupId == null?'rec-association-scroll-item-2-active':'')" @click="getCon(null,-1)">全部</view>
  54. <view :class="'rec-association-scroll-item-2 tover '+(groupId == item.id?'rec-association-scroll-item-2-active':'')" @click="getCon(item,index)" v-for="item,index in cardGroup" :key="index">{{item.groupName}}</view>
  55. </scroll-view>
  56. <view class="rec-association-nav-m-2"></view>
  57. </view>
  58. </view>
  59. <view class="dflex add" @click="jumpUrl('/card/groupManage/groupManage')">
  60. <image style="width: 32rpx;height: 32rpx;margin-right: 10rpx;margin-top: 16rpx;" src="../static/images/addFile.png"></image>
  61. <text>管理</text>
  62. </view>
  63. </view>
  64. </view>
  65. <!-- 数据 -->
  66. <view v-if="pageList.length>0">
  67. <view class="ddflex card-item" v-for="item,index in pageList" :key="index" @click="jumpUrl('/card/index/index?cardId='+item.id)">
  68. <image class="header" :src="item.avatar"></image>
  69. <view class="fflex">
  70. <view class="name">{{item.realName}}<text style="margin-left: 15rpx;" v-if="item.job">/ {{item.job}}</text></view>
  71. <view class="company tover">{{item.companyName}}</view>
  72. <view class="label tover" v-if="item.industryName">{{item.industryName}}</view>
  73. </view>
  74. <view class="ddflex" v-if="userInfo.id!=item.userId">
  75. <view v-if="item.beFollow>0&&item.follow<=0" class="card-btn btn1" @click.stop="userBehavior(item,index)">我的粉丝</view>
  76. <view v-else-if="item.beFollow<=0&&item.follow>0" class="card-btn btn2" @click.stop="userBehavior(item,index)">我已关注</view>
  77. <view v-else-if="item.beFollow>0&&item.follow>0" class="card-btn btn2" @click.stop="userBehavior(item,index)">互关</view>
  78. <view v-else class="card-btn btn3" @click.stop="userBehavior(item,index)">+关注</view>
  79. <view class="more" @click.stop="showOptionFn(index)" v-if="tabIndex==2">
  80. <view class="ddflex dian">
  81. <view v-for="it in 3"></view>
  82. </view>
  83. <view class="more-content-position" v-if="index==showOptionIndex">
  84. <view class="more-content">
  85. <view class="more-content-item ddflex" @click.stop="removeGroup(item)">
  86. <image style="width: 38rpx;height: 38rpx;margin-right: 10rpx;" src="../static/images/remove.png"></image>
  87. <text>移出名片</text>
  88. </view>
  89. <view class="more-content-item ddflex" @click.stop="jumpUrl('/card/groupManage/groupManage?cardId='+item.id)">
  90. <image style="width: 38rpx;height: 38rpx;margin-right: 10rpx;" src="../static/images/change.png"></image>
  91. <text>移动分组</text>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="nodata" v-else>
  100. <image :src="picUrlss + 'empty_dd.png'"></image>
  101. <text>暂无名片信息~</text>
  102. </view>
  103. <!-- 创建名片 -->
  104. <view style="height: 150rpx;"></view>
  105. <view class="ddflex option" style="justify-content: center;">
  106. <block v-if="tabIndex==1">
  107. <view class="option-btn ddflex" @click="jumpUrl(userCard?'/card/index/index':'/card/create/create')">
  108. <image style="width: 38rpx;height: 36rpx;margin-right: 10rpx;" src="../static/images/edit1.png"></image>
  109. <text>{{userCard?'我的名片':'创建名片'}}</text>
  110. </view>
  111. <view class="option-btn ddflex" @click="jumpUrl('/card/myNetWork/myNetWork')">
  112. <image style="width: 44rpx;height: 36rpx;margin-right: 10rpx;" src="../static/images/rm.png"></image>
  113. <text>我的人脉</text>
  114. </view>
  115. </block>
  116. <block v-if="tabIndex==2">
  117. <view class="option-btn ddflex" @click="jumpUrl(userCard?'/card/index/index':'/card/create/create')">
  118. <text>{{userCard?'我的名片':'创建名片'}}</text>
  119. </view>
  120. </block>
  121. </view>
  122. <view class="ceng" v-if="showOption" catchtouchmove="true" @click="hideOptionFn()"></view>
  123. </view>
  124. </template>
  125. <script>
  126. const app = getApp();
  127. const req = require('../../utils/request.js');
  128. const api = require('../../utils/api.js');
  129. export default {
  130. data() {
  131. return {
  132. picUrlss: req.public.picUrls,
  133. isLoad: true,
  134. ishow: false,
  135. tabIndex:1,//1人脉 2名片夹
  136. showOption:false,//名片夹是否打开了操作
  137. showOptionIndex:null,//打开操作的下标
  138. form: {
  139. page: 1,
  140. limit: 10
  141. },
  142. search: '',
  143. pageList:[],
  144. cardGroup:[],//名片夹列表
  145. groupId:null,//选中的分组id
  146. userCard:null,//用户名片信息
  147. userInfo:{}
  148. };
  149. },
  150. onLoad(options) {
  151. this.getPageList();
  152. this.userInfo = req.getStorage('userInfo')
  153. },
  154. onShow() {
  155. this.getUserCard()
  156. this.getCardGroup()
  157. },
  158. onReachBottom() {
  159. this.form.page++;
  160. this.getPageList();
  161. },
  162. methods: {
  163. jumpUrl(url){
  164. uni.navigateTo({
  165. url:url
  166. })
  167. },
  168. changTab(type){
  169. if(type==this.tabIndex) return false
  170. this.tabIndex = type
  171. this.form.page = 1;
  172. this.isLoad = true;
  173. this.getPageList()
  174. },
  175. showOptionFn(index){
  176. if(this.showOptionIndex == index) return false
  177. this.showOptionIndex = index
  178. this.showOption=true
  179. },
  180. hideOptionFn(){
  181. this.showOptionIndex = null
  182. this.showOption=false
  183. },
  184. // 数据
  185. getPageList() {
  186. if (!this.isLoad) return false;
  187. this.isLoad = false;
  188. let form = this.form;
  189. if(this.search){
  190. form.search = this.search;
  191. }else{ delete form.search}
  192. // 人脉圈
  193. if(this.tabIndex==1){
  194. delete form.dataType
  195. delete form.visitingCardGroupId
  196. }
  197. // 名片夹
  198. if(this.tabIndex==2){
  199. form.dataType=1
  200. if(this.groupId){
  201. form.visitingCardGroupId=this.groupId
  202. }else{
  203. delete form.visitingCardGroupId
  204. }
  205. }
  206. req.getRequest('/api/v3/visiting/card/folder/list', form, res => {
  207. res = res?res.list:null
  208. if (res && res.length == 10) this.isLoad = true;
  209. if (this.form.page > 1) res = this.pageList.concat(res);
  210. if(res && res.length == 0 && this.form.page == 1) this.ishow = true;
  211. this.pageList = res;
  212. });
  213. },
  214. // 用户名片信息
  215. getUserCard(){
  216. req.getRequest('/api/v3/visiting/card/userInfo', {}, res => {
  217. this.userCard = res
  218. });
  219. },
  220. // 名片夹列表
  221. getCardGroup(){
  222. req.getRequest('/api/v3/visiting/card/group/list', {}, res => {
  223. this.cardGroup = res
  224. });
  225. },
  226. // 查询切换分组
  227. getCon(item,index){
  228. let id = item?item.id:null
  229. if(id==this.groupId) return false
  230. this.groupId = id
  231. this.form.page = 1;
  232. this.isLoad = true;
  233. this.getPageList()
  234. },
  235. // 移动分组
  236. changeGroup(cardId,groupId){
  237. let form = {
  238. visitingCardGroupId:groupId,
  239. visitingCardId:cardId,
  240. userId:req.getStorage('userInfo').id
  241. }
  242. req.postRequest('/api/v3/visiting/card/folder/saveOrUpdate',form,res=>{
  243. req.msg('已移动分组')
  244. })
  245. this.hideOptionFn()
  246. this.form.page = 1;
  247. this.isLoad = true;
  248. this.getPageList()
  249. },
  250. // 移出名片夹
  251. removeGroup(item){
  252. this.$showModal({
  253. title: '提示',
  254. content: '确定要移出名片吗?'
  255. })
  256. .then(res => {
  257. req.postRequest('/api/v3/visiting/card/folder/delete',{id:item.id},res=>{
  258. req.msg('移出成功')
  259. this.hideOptionFn()
  260. this.form.page = 1;
  261. this.isLoad = true;
  262. this.getPageList()
  263. })
  264. })
  265. .catch(err => {
  266. });
  267. },
  268. searchFn(){
  269. this.form.page = 1;
  270. this.isLoad = true;
  271. this.getPageList()
  272. },
  273. // 用户行为
  274. userBehavior(item,index){
  275. var dataP = {};
  276. dataP.type = 23 //、产品 2、活动 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 12、用户须知 13、素材 15、医院科室 16、海报 20、医生 21 新闻 23名片
  277. dataP.behavior = 1; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
  278. dataP.bindId = item.id;
  279. req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
  280. console.log(this.pageList[index].follow)
  281. if(this.pageList[index].follow>0){
  282. this.pageList[index].follow = 0
  283. req.msg('已取消关注')
  284. }
  285. else if(this.pageList[index].follow<=0){
  286. this.pageList[index].follow = 1
  287. req.msg('已关注')
  288. }
  289. console.log(this.pageList[index].follow)
  290. this.pageList = JSON.parse(JSON.stringify(this.pageList))
  291. });
  292. },
  293. }
  294. }
  295. </script>
  296. <style>
  297. @import './network.css';
  298. </style>