cardList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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. this.page++;
  232. this.getDataList();
  233. },
  234. methods: {
  235. jumpUrl(url) {
  236. uni.navigateTo({
  237. url: url
  238. })
  239. },
  240. jumpSingleChatRoom(item) {
  241. if (item) {
  242. req.jumpSingleChatRoom(item.userId, item.avatar, item.realName);
  243. req.saveBehaviorNew(item.id,1,14)
  244. }
  245. },
  246. getDict(){
  247. return new Promise((r,j)=>{
  248. req.getRequest('/api/other/dict/info',{dictType:'job'},res=>{
  249. this.dateList.map(item=>{
  250. if(item.key=='job'){
  251. item.option = []
  252. res.map(it=>{
  253. item.option.push({
  254. label:it.dictName,
  255. value:it.dictValue
  256. })
  257. })
  258. }
  259. })
  260. r(res)
  261. })
  262. })
  263. },
  264. // 切换筛选类型
  265. changeFilterType(type){
  266. // if(this.filterType==type) return false
  267. this.filterType = type
  268. if(type==3) {
  269. this.hidePop()
  270. return false
  271. }
  272. this.openPop()
  273. },
  274. // 打开弹窗
  275. openPop(){
  276. this.isShowPop = true
  277. this.popBottom = '0%'
  278. },
  279. // 关闭弹窗
  280. hidePop() {
  281. this.isShowPop = false;
  282. this.popBottom = '-100%';
  283. },
  284. // 筛选
  285. switchType(index) {
  286. if (this.stateIndex == index) return false;
  287. this.stateIndex = index;
  288. this.confirm()
  289. },
  290. switchFilterType(index,idx) {
  291. if(!this.dateList[index].option[idx].isActive){
  292. this.dateList[index].option.map(item=>{
  293. item.isActive = false
  294. })
  295. this.dateList[index].option[idx].isActive = true
  296. }else{
  297. this.dateList[index].option[idx].isActive = false
  298. }
  299. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  300. },
  301. regionChange(e){
  302. console.log(e)
  303. this.regionText = e.data.filter(item=>item&&item !="请选择").join('')
  304. this.regionCode = e.ids.length>0?e.ids.filter(item=>item&&item!='0')[e.ids.filter(item=>item&&item!='0').length-1]:''
  305. this.confirm()
  306. },
  307. confirm() {
  308. this.hidePop();
  309. this.isLoad = true;
  310. this.getDataList();
  311. },
  312. reset() {
  313. this.dateIndex = -1;
  314. this.stateIndex = 0;
  315. this.dateList.map(item=>{
  316. item.option.map(it=>{
  317. it.isActive = false
  318. })
  319. })
  320. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  321. this.regionText=''
  322. this.regionCode=''
  323. },
  324. // 分页查询
  325. getDataList() {
  326. if (!this.isLoad) return false;
  327. this.isLoad = false;
  328. let queryParams = {
  329. page: this.page,
  330. limit: this.limit,
  331. latitude: this.latitude,
  332. longitude: this.longitude,
  333. }
  334. if (this.searchVal) {
  335. queryParams.realName = this.searchVal
  336. }
  337. // 时间筛选
  338. if (this.dateIndex != -1) {
  339. queryParams.dateType = this.dateList[this.dateIndex].value;
  340. }else if (this.dateIndex == -1) {
  341. } else {
  342. queryParams.dateType = 8
  343. queryParams.end = this.endTime?this.endTime:null;
  344. queryParams.start = this.startTime?this.startTime:null;
  345. }
  346. // 状态筛选
  347. if (this.stateIndex != -1) {
  348. queryParams.orderFiled = this.stateList[this.stateIndex].value;
  349. if(this.stateList[this.stateIndex].behavior){
  350. queryParams.behavior = this.stateList[this.stateIndex].behavior;
  351. }
  352. }
  353. if(this.regionCode){
  354. queryParams.areaCode = this.regionCode
  355. }
  356. this.dateList.map(item=>{
  357. if(item.key=="sex"){
  358. let sl = item.option.filter(it=>{return it.isActive})
  359. if(sl.length>0){
  360. queryParams.gender = sl[0].value
  361. }
  362. }
  363. if(item.key=="job"){
  364. let jl = item.option.filter(it=>{return it.isActive})
  365. if(jl.length>0){
  366. queryParams.job = jl[0].value
  367. }
  368. }
  369. if(item.key=="inDate"){
  370. console.log('indate')
  371. let il = item.option.filter(it=>{return it.isActive})
  372. console.log(il)
  373. if(il.length>0){
  374. let d = il[0].value
  375. if(d==4){
  376. queryParams.endTime = this.getYear(d+1)
  377. }else{
  378. queryParams.startTime = this.getYear(d)
  379. queryParams.endTime = this.getYear(d+1)
  380. }
  381. }
  382. }
  383. if(item.key=="job"){
  384. // queryParams.gender = item.option.filter(it=>{return it.isActive})[0].value
  385. }
  386. })
  387. req.getRequest('/api/visiting/card/cardInfoList', queryParams, data => {
  388. data = data.list
  389. if (data != null && data.length == this.limit) {
  390. this.isLoad = true;
  391. }
  392. if (this.page == 1) {
  393. this.dataList = [];
  394. }
  395. if (this.page > 0) {
  396. data = this.dataList.concat(data);
  397. }
  398. this.dataList = data;
  399. console.log('列表数据>>>', this.dataList);
  400. })
  401. },
  402. getYear(index){
  403. let dateTime = new Date().getFullYear(); /* 获取现在的年份 */
  404. dateTime = new Date(new Date().setFullYear(dateTime-index))
  405. let y = dateTime.getFullYear()
  406. let m = dateTime.getMonth()+1<10?('0'+(dateTime.getMonth()+1)):dateTime.getMonth()+1
  407. let d = dateTime.getDate()<10?('0'+(dateTime.getDate())):dateTime.getDate()
  408. return y+'-'+m+'-'+d
  409. },
  410. // 搜索
  411. searchFn() {
  412. this.page = 1;
  413. this.isLoad = true;
  414. this.getDataList();
  415. },
  416. formatTimeFn(data) {
  417. if (data) {
  418. return utils.formatTimeCommStr(data, 'Y-M-D')
  419. } else {
  420. return '';
  421. }
  422. },
  423. monthDayDiff(date) {
  424. return util.monthDayDiff(date)
  425. },
  426. },
  427. mounted() {
  428. const systemInfo = uni.getSystemInfoSync();
  429. // px转换到rpx的比例
  430. let pxToRpxScale = 750 / systemInfo.windowWidth;
  431. this.statusBarHeight = uni.getSystemInfoSync().windowTop*pxToRpxScale
  432. }
  433. }
  434. </script>
  435. <style>
  436. @import "./cardList.css";
  437. </style>