cardList.vue 13 KB

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