cardList.vue 12 KB

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