cardList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  1. <template>
  2. <view>
  3. <view class="top-fixed">
  4. <view class="search-box ddflex">
  5. <view class="search-input ddflex fflex">
  6. <image src="/static/images/ssico.png"></image>
  7. <input @confirm="searchFn" confirm-type="search" @input="searchFn" v-model="searchVal" class="fflex"
  8. placeholder="请输入代理人姓名" />
  9. </view>
  10. </view>
  11. <view class="filter ddflex">
  12. <view :class="'filter-item fflex ddflex '+(filterType==2&&isShowPop?'f-active':'')" @click="changeFilterType(2)">
  13. <text style="max-width: 150rpx;" class="tover">{{stateIndex!=-1?stateList[stateIndex].label:'智能筛选'}}</text>
  14. <image class="filter-item-icon" :style="filterType==2&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  15. </view>
  16. <view class="fflex">
  17. <pickerAddress @change="regionChange">
  18. <view :class="'filter-item fflex ddflex '+(areaIndex!=-1?'f-active':'')" @click="changeFilterType(3)">
  19. <text style="max-width: 150rpx;" class="tover">{{regionText?regionText:'地区'}}</text>
  20. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  21. </view>
  22. </pickerAddress>
  23. <!-- <picker mode="region" v-model="regionIndex" @change="regionChange">
  24. <view :class="'filter-item fflex ddflex '+(areaIndex!=-1?'f-active':'')" @click="changeFilterType(3)">
  25. <text style="max-width: 150rpx;" class="tover">{{regionText?regionText:'地区'}}</text>
  26. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  27. </view>
  28. </picker> -->
  29. </view>
  30. <view :class="'filter-item fflex ddflex '+(filterType==1&&isShowPop?'f-active':'')" @click="changeFilterType(1)">
  31. 筛选
  32. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="ceng" v-if="isShowPop" @click="hidePop()"></view>
  37. <view class="hx-pop" :style="'top:calc(' +popBottom+' + '+(isShowPop?190:0)+'rpx' ">
  38. <view class="pop-con" v-if="filterType==1">
  39. <view class="pop-list">
  40. <view v-for="(item, index) in dateList" :key="index" style="margin-bottom: 30rpx;">
  41. <view>{{ item.title }}</view>
  42. <view class="ddflex">
  43. <view :class="'opt' + (it.isActive? ' opt-active' : '')" v-for="(it, idx) in item.option" :key="idx" @click="switchFilterType(index,idx)">
  44. <view>{{ it.label }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="pop-con" v-if="filterType==2">
  51. <view class="pop-list">
  52. <view :class="'li' + (stateIndex == index ? ' active' : '')" v-for="(item, index) in stateList" :key="index" @click="switchType(index)">
  53. {{ item.label }}
  54. </view>
  55. </view>
  56. </view>
  57. <view class="pop-btn ddflex" v-if="filterType!=2">
  58. <view @click="reset">重置</view>
  59. <view class="fflex" @click="confirm">确定</view>
  60. </view>
  61. </view>
  62. <view style="height: 190rpx;"></view>
  63. <!-- 订单列表 -->
  64. <view style="position: relative;overflow: hidden;" v-if="dataList.length>0">
  65. <view class="register-box" v-for="item,index in dataList" :key="index" @click="jumpUrl('/card/cardDetail/cardDetail?id='+item.id)">
  66. <view class="register-title ddflex fflex">
  67. <image class="register-title-icon" :src="item.avatar?item.avatar:'/static/images/userimg.png'" mode="aspectFill"></image>
  68. <view class="flex" style="min-width: 0;">
  69. <view class="ddflex" @click.stop="jumpSingleChatRoom(item)">
  70. <view class="card-name fflex tover">{{item.realName?item.realName:''}}</view>
  71. <image style="width: 64rpx;height: 64rpx;margin-left: 10rpx;" src="/card/static/images/wxChat.png"></image>
  72. </view>
  73. <view class="ddflex" style="margin-top: 4rpx;">
  74. <view class="card-tag">{{ item.jobName }}</view>
  75. <view class="card-tag">入司{{item.inDate?monthDayDiff(item.inDate):'1年'}}</view>
  76. </view>
  77. <view class="card-area ddflex">
  78. <image src="/card/static/images/area.png"></image>
  79. <view class="flex tover">{{item.address}}</view>
  80. <view style="color: #A1A1A1;margin-left: 10rpx;">距离{{item.distance>1000?((item.distance/1000).toFixed(2)+'km'):(item.distance+'m')}}</view>
  81. </view>
  82. </view>
  83. </view>
  84. <view class="ddflex" style="margin-top: 41rpx;">
  85. <view class="flex">
  86. <view class="card-data">{{item.cntCust?item.cntCust:0}}</view>
  87. <view class="card-label">服务客户</view>
  88. </view>
  89. <view class="card-line"></view>
  90. <view class="flex">
  91. <view class="card-data">{{item.cntCntr?item.cntCntr:0}}</view>
  92. <view class="card-label">保单件数</view>
  93. </view>
  94. <view class="card-line"></view>
  95. <view class="flex">
  96. <view class="card-data">{{item.thumbs?item.thumbs:0}}</view>
  97. <view class="card-label">用户点赞</view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view v-else class="nodata">
  103. <image src="../../card/static/images/empty.png" mode="widthFix"></image>
  104. <view>暂无数据</view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. const app = getApp();
  110. const req = require("../../utils/request.js");
  111. const util = require('../../utils/util.js');
  112. const QQMapWX = require("../../utils/qqmap.js");
  113. import pickerAddress from '../components/wangding-pickerAddress/wangding-pickerAddressSingle.vue';
  114. export default {
  115. components: {
  116. pickerAddress
  117. },
  118. props: {},
  119. data() {
  120. return {
  121. statusBarHeight:0,
  122. filterType:null,
  123. popBottom: '-100%',
  124. isShowPop: false,
  125. dateIndex: -1,
  126. // 时间类型 1、今日 2、昨日 3、近7日 4、近30天 5、本月 6、本季度 7、本年度
  127. dateList: [
  128. {
  129. title:'性别',
  130. key:'sex',
  131. option:[
  132. {
  133. label: '男',
  134. value: 1
  135. },{
  136. label: '女',
  137. value: 2
  138. },
  139. ]
  140. },{
  141. title:'入司时间',
  142. key:'inDate',
  143. option:[
  144. {
  145. label: '1~2年',
  146. value: 1
  147. },{
  148. label: '2~3年',
  149. value: 2
  150. },{
  151. label: '3~4年',
  152. value: 3
  153. },{
  154. label: '4年以上',
  155. value: 4
  156. }
  157. ]
  158. },{
  159. title:'职务',
  160. key:'job',
  161. option:[
  162. {
  163. label: '经理',
  164. value: 1
  165. },{
  166. label: '负责人',
  167. value: 2
  168. },{
  169. label: '业务员',
  170. value: 3
  171. }
  172. ]
  173. }
  174. ],
  175. startTime: '',
  176. endTime: '',
  177. regionText:'',
  178. regionCode:'',
  179. areaIndex:-1,
  180. stateIndex: 0,
  181. stateList:[{
  182. label: '智能推荐',
  183. value: null
  184. },{
  185. label: '评价分从高到低',
  186. value: 'avage'
  187. },
  188. {
  189. label: '浏览量从高到低',
  190. value: 'bCount',
  191. behavior:4
  192. },
  193. {
  194. label: '点赞量从高到低',
  195. value: 'bCount',
  196. behavior:3
  197. }],
  198. page: 1,
  199. limit: 10,
  200. isLoad: true,
  201. searchVal: '',
  202. dataList: [],
  203. isReference:false,
  204. latitude: '23.027923',
  205. longitude: '113.753815',
  206. }
  207. },
  208. onLoad(options) {
  209. QQMapWX.initMap();
  210. req.getLocation(async res => {
  211. const to = {
  212. latitude: res.latitude,
  213. longitude: res.longitude
  214. };
  215. this.latitude = res.latitude;
  216. this.longitude = res.longitude;
  217. await this.getDict()
  218. this.getDataList()
  219. });
  220. req.saveBehaviorNew('',4,4)
  221. },
  222. onShow() {
  223. if(this.isReference){
  224. this.isReference = false
  225. this.page=1;
  226. this.isLoad = true
  227. this.getDataList();
  228. }
  229. },
  230. onReachBottom() {
  231. // 只展示10条数据
  232. // this.page++;
  233. // this.getDataList();
  234. },
  235. methods: {
  236. jumpUrl(url) {
  237. uni.navigateTo({
  238. url: url
  239. })
  240. },
  241. jumpSingleChatRoom(item) {
  242. if (item) {
  243. req.jumpSingleChatRoom(item.userId, item.avatar, item.realName);
  244. req.saveBehaviorNew(item.id,1,14)
  245. }
  246. },
  247. getDict(){
  248. return new Promise((r,j)=>{
  249. req.getRequest('/api/other/dict/info',{dictType:'job'},res=>{
  250. this.dateList.map(item=>{
  251. if(item.key=='job'){
  252. item.option = []
  253. res.map(it=>{
  254. item.option.push({
  255. label:it.dictName,
  256. value:it.dictValue
  257. })
  258. })
  259. }
  260. })
  261. r(res)
  262. })
  263. })
  264. },
  265. // 切换筛选类型
  266. changeFilterType(type){
  267. // if(this.filterType==type) return false
  268. this.filterType = type
  269. if(type==3) {
  270. this.hidePop()
  271. return false
  272. }
  273. this.openPop()
  274. },
  275. // 打开弹窗
  276. openPop(){
  277. this.isShowPop = true
  278. this.popBottom = '0%'
  279. },
  280. // 关闭弹窗
  281. hidePop() {
  282. this.isShowPop = false;
  283. this.popBottom = '-100%';
  284. },
  285. // 筛选
  286. switchType(index) {
  287. if (this.stateIndex == index) return false;
  288. this.stateIndex = index;
  289. this.confirm()
  290. },
  291. switchFilterType(index,idx) {
  292. if(!this.dateList[index].option[idx].isActive){
  293. this.dateList[index].option.map(item=>{
  294. item.isActive = false
  295. })
  296. this.dateList[index].option[idx].isActive = true
  297. }else{
  298. this.dateList[index].option[idx].isActive = false
  299. }
  300. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  301. },
  302. regionChange(e){
  303. console.log(e)
  304. this.regionText = e.data.filter(item=>item&&item !="请选择").join('')
  305. this.regionCode = e.ids.length>0?e.ids.filter(item=>item&&item!='0')[e.ids.filter(item=>item&&item!='0').length-1]:''
  306. this.confirm()
  307. },
  308. confirm() {
  309. this.hidePop();
  310. this.isLoad = true;
  311. this.getDataList();
  312. },
  313. reset() {
  314. this.dateIndex = -1;
  315. this.stateIndex = 0;
  316. this.dateList.map(item=>{
  317. item.option.map(it=>{
  318. it.isActive = false
  319. })
  320. })
  321. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  322. this.regionText=''
  323. this.regionCode=''
  324. },
  325. // 分页查询
  326. getDataList() {
  327. if (!this.isLoad) return false;
  328. this.isLoad = false;
  329. let queryParams = {
  330. page: this.page,
  331. limit: this.limit,
  332. latitude: this.latitude,
  333. longitude: this.longitude,
  334. }
  335. if (this.searchVal) {
  336. queryParams.realName = this.searchVal
  337. }
  338. // 时间筛选
  339. if (this.dateIndex != -1) {
  340. queryParams.dateType = this.dateList[this.dateIndex].value;
  341. }else if (this.dateIndex == -1) {
  342. } else {
  343. queryParams.dateType = 8
  344. queryParams.end = this.endTime?this.endTime:null;
  345. queryParams.start = this.startTime?this.startTime:null;
  346. }
  347. // 状态筛选
  348. if (this.stateIndex != -1) {
  349. queryParams.orderFiled = this.stateList[this.stateIndex].value;
  350. if(this.stateList[this.stateIndex].behavior){
  351. queryParams.behavior = this.stateList[this.stateIndex].behavior;
  352. }
  353. }
  354. if(this.regionCode){
  355. queryParams.areaCode = this.regionCode
  356. }
  357. this.dateList.map(item=>{
  358. if(item.key=="sex"){
  359. let sl = item.option.filter(it=>{return it.isActive})
  360. if(sl.length>0){
  361. queryParams.gender = sl[0].value
  362. }
  363. }
  364. if(item.key=="job"){
  365. let jl = item.option.filter(it=>{return it.isActive})
  366. if(jl.length>0){
  367. queryParams.job = jl[0].value
  368. }
  369. }
  370. if(item.key=="inDate"){
  371. console.log('indate')
  372. let il = item.option.filter(it=>{return it.isActive})
  373. console.log(il)
  374. if(il.length>0){
  375. let d = il[0].value
  376. if(d==4){
  377. queryParams.endTime = this.getYear(d+1)
  378. }else{
  379. queryParams.startTime = this.getYear(d)
  380. queryParams.endTime = this.getYear(d+1)
  381. }
  382. }
  383. }
  384. if(item.key=="job"){
  385. // queryParams.gender = item.option.filter(it=>{return it.isActive})[0].value
  386. }
  387. })
  388. req.getRequest('/api/visiting/card/cardInfoList', queryParams, data => {
  389. data = data.list
  390. if (data != null && data.length == this.limit) {
  391. this.isLoad = true;
  392. }
  393. if (this.page == 1) {
  394. this.dataList = [];
  395. }
  396. if (this.page > 0) {
  397. data = this.dataList.concat(data);
  398. }
  399. this.dataList = data;
  400. console.log('列表数据>>>', this.dataList);
  401. })
  402. },
  403. getYear(index){
  404. let dateTime = new Date().getFullYear(); /* 获取现在的年份 */
  405. dateTime = new Date(new Date().setFullYear(dateTime-index))
  406. let y = dateTime.getFullYear()
  407. let m = dateTime.getMonth()+1<10?('0'+(dateTime.getMonth()+1)):dateTime.getMonth()+1
  408. let d = dateTime.getDate()<10?('0'+(dateTime.getDate())):dateTime.getDate()
  409. return y+'-'+m+'-'+d
  410. },
  411. // 搜索
  412. searchFn() {
  413. this.page = 1;
  414. this.isLoad = true;
  415. this.getDataList();
  416. },
  417. formatTimeFn(data) {
  418. if (data) {
  419. return utils.formatTimeCommStr(data, 'Y-M-D')
  420. } else {
  421. return '';
  422. }
  423. },
  424. monthDayDiff(date) {
  425. return util.monthDayDiff(date)
  426. },
  427. },
  428. mounted() {
  429. const systemInfo = uni.getSystemInfoSync();
  430. // px转换到rpx的比例
  431. let pxToRpxScale = 750 / systemInfo.windowWidth;
  432. this.statusBarHeight = uni.getSystemInfoSync().windowTop*pxToRpxScale
  433. }
  434. }
  435. </script>
  436. <style>
  437. @import "./cardList.css";
  438. </style>