myNetWork.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 :class="'tab-nav-item '+(tabIndex==3?'tab-nav-item-active':'')" @click="changTab(3)">粉丝</view>
  9. </view>
  10. <!-- 搜索 -->
  11. <view class="search">
  12. <view class="search-bar ddflex">
  13. <image src="../../static/images/ssico.png" class="ssico"></image>
  14. <input v-model="search" placeholder="搜索" confirm-type="search" @confirm="searchFn()" placeholder-class="placeholder" class="ipt fflex" />
  15. <!-- <view class="clear">取消</view> -->
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 隐藏 -->
  20. <view class="top-bar" style="position: relative;visibility: hidden;">
  21. <view class="tab-nav ddflex">
  22. <view :class="'tab-nav-item '+(tabIndex==1?'tab-nav-item-active':'')" @click="changTab(1)">人脉圈</view>
  23. <view :class="'tab-nav-item '+(tabIndex==2?'tab-nav-item-active':'')" @click="changTab(2)">名片夹</view>
  24. </view>
  25. <!-- 搜索 -->
  26. <view class="search">
  27. <view class="search-bar ddflex">
  28. <image src="../../static/images/ssico.png" class="ssico"></image>
  29. <input v-model="search" placeholder="搜索" confirm-type="search" @confirm="searchFn()" placeholder-class="placeholder" class="ipt fflex" />
  30. <!-- <view class="clear">取消</view> -->
  31. </view>
  32. </view>
  33. </view>
  34. <!-- 数据 -->
  35. <view v-if="pageList.length>0">
  36. <view class="ddflex card-item" v-for="item,index in pageList" :key="index" @click="jumpUrl('/card/index/index?cardId='+item.id)">
  37. <image class="header" :src="item.avatar"></image>
  38. <view class="fflex">
  39. <view class="name">{{item.realName}}<text style="margin-left: 15rpx;" v-if="item.job">/ {{item.job}}</text></view>
  40. <view class="company tover">{{item.companyName}}</view>
  41. <view class="label tover" v-if="item.industryName">{{item.industryName}}</view>
  42. </view>
  43. <view class="ddflex" v-if="userInfo.id!=item.userId">
  44. <view v-if="item.beFollow>0&&item.follow<=0" class="card-btn btn1" @click.stop="userBehavior(item,index)">我的粉丝</view>
  45. <view v-else-if="item.beFollow<=0&&item.follow>0" class="card-btn btn2" @click.stop="userBehavior(item,index)">我已关注</view>
  46. <view v-else-if="item.beFollow>0&&item.follow>0" class="card-btn btn2" @click.stop="userBehavior(item,index)">互关</view>
  47. <view v-else class="card-btn btn3" @click="userBehavior(item,index)">+关注</view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="nodata" v-else>
  52. <image :src="picUrlss + 'empty_dd.png'"></image>
  53. <text>暂无名片信息~</text>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. const app = getApp();
  59. const req = require('../../utils/request.js');
  60. const api = require('../../utils/api.js');
  61. export default {
  62. data() {
  63. return {
  64. picUrlss: req.public.picUrls,
  65. isLoad: true,
  66. ishow: false,
  67. tabIndex:1,//1好友 2关注 3粉丝
  68. form: {
  69. page: 1,
  70. limit: 10
  71. },
  72. search: '',
  73. pageList:[],
  74. userInfo:{}
  75. };
  76. },
  77. onLoad(options) {
  78. this.userInfo = req.getStorage('userInfo')
  79. this.getPageList();
  80. },
  81. onShow() {
  82. },
  83. onReachBottom() {
  84. this.form.page++;
  85. this.getPageList();
  86. },
  87. methods: {
  88. jumpUrl(url){
  89. uni.navigateTo({
  90. url:url
  91. })
  92. },
  93. changTab(type){
  94. if(type==this.tabIndex) return false
  95. this.tabIndex = type
  96. this.form.page = 1;
  97. this.isLoad = true;
  98. this.getPageList()
  99. },
  100. // 数据
  101. getPageList() {
  102. if (!this.isLoad) return false;
  103. this.isLoad = false;
  104. let form = this.form;
  105. if(this.search){
  106. form.search = this.search;
  107. }else{ delete form.search}
  108. // 人脉圈
  109. if(this.tabIndex==1){
  110. form.dataType = 3
  111. }else if(this.tabIndex==2){
  112. form.dataType = 4
  113. }else if(this.tabIndex==3){
  114. form.dataType = 5
  115. }
  116. req.getRequest('/api/v3/visiting/card/folder/list', form, res => {
  117. res = res?res.list:null
  118. if (res && res.length == 10) this.isLoad = true;
  119. if (this.form.page > 1) res = this.pageList.concat(res);
  120. if(res && res.length == 0 && this.form.page == 1) this.ishow = true;
  121. this.pageList = res;
  122. });
  123. },
  124. searchFn(){
  125. this.form.page = 1;
  126. this.isLoad = true;
  127. this.getPageList()
  128. },
  129. // 用户行为
  130. userBehavior(item,index){
  131. var dataP = {};
  132. dataP.type = 23 //、产品 2、活动 3、未知 4、内容 5、课程 6、老师 7、素材 8、题目 9、资料领取 10、招聘职位 12、用户须知 13、素材 15、医院科室 16、海报 20、医生 21 新闻 23名片
  133. dataP.behavior = 1; //1、关注 2、收藏 3、点赞 4、浏览 5、确认 6、分享
  134. dataP.bindId = item.id;
  135. req.postRequestLoding('/api/v3/behavior/save', dataP, data => {
  136. console.log(this.pageList[index].follow)
  137. if(this.pageList[index].follow>0){
  138. this.pageList[index].follow = 0
  139. req.msg('已取消关注')
  140. }
  141. else if(this.pageList[index].follow<=0){
  142. this.pageList[index].follow = 1
  143. req.msg('已关注')
  144. }
  145. console.log(this.pageList[index].follow)
  146. this.pageList = JSON.parse(JSON.stringify(this.pageList))
  147. });
  148. },
  149. }
  150. }
  151. </script>
  152. <style>
  153. @import './myNetWork.css';
  154. </style>