cardList.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  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 '+(dateIndex!=-1?'f-active':'')" @click="changeFilterType(1)">
  13. {{dateIndex!=-1?dateList[dateIndex].label:'智能筛选'}}
  14. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  15. </view>
  16. <view :class="'filter-item fflex ddflex '+(areaIndex!=-1?'f-active':'')" @click="changeFilterType(1)">
  17. 地区
  18. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  19. </view>
  20. <view :class="'filter-item fflex ddflex '+(stateIndex!=-1?'f-active':'')" @click="changeFilterType(2)">
  21. {{stateIndex!=-1?stateList[stateIndex].label:'筛选'}}
  22. <image class="filter-item-icon" :style="filterType==2&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="ceng" v-if="isShowPop" @click="hidePop()"></view>
  27. <view class="hx-pop" :style="'top:calc(' +popBottom+' + '+(isShowPop?190:0)+'rpx' ">
  28. <view class="pop-con" v-if="filterType==1">
  29. <view class="pop-list ddflex">
  30. <view :class="'li' + (dateIndex == index ? ' active' : '')" v-for="(item, index) in dateList" :key="index" @click="switchType(index)">{{ item.label }}</view>
  31. </view>
  32. <view class="pop-time ddflex">
  33. <picker mode="date" class="date-ipt" @change="changeStartTime">
  34. <view :class="startTime ? '' : 'placeholder'">{{ startTime ? startTime : '选择日期' }}</view>
  35. </picker>
  36. <text>至</text>
  37. <picker mode="date" class="date-ipt" @change="changeEndTime">
  38. <view :class="endTime ? '' : 'placeholder'">{{ endTime ? endTime : '选择日期' }}</view>
  39. </picker>
  40. </view>
  41. </view>
  42. <view class="pop-con" v-if="filterType==2">
  43. <view class="pop-list ddflex">
  44. <view :class="'li' + (stateIndex == index ? ' active' : '')" v-for="(item, index) in stateList" :key="index" @click="switchType(index)">{{ item.label }}</view>
  45. </view>
  46. </view>
  47. <view class="pop-btn ddflex">
  48. <view @click="reset">重置</view>
  49. <view class="fflex" @click="confirm">确定</view>
  50. </view>
  51. </view>
  52. <view style="height: 190rpx;"></view>
  53. <!-- 订单列表 -->
  54. <view style="position: relative;overflow: hidden;" v-if="dataList.length>0">
  55. <view class="register-box" v-for="item,index in dataList" :key="index" @click="jumpUrl('/card/cardDetail/cardDetail?id='+item.id)">
  56. <view class="register-title ddflex fflex">
  57. <image class="register-title-icon" :src="item.avatar?item.avatar:'/static/images/userimg.png'"></image>
  58. <view class="flex" style="min-width: 0;">
  59. <view class="ddflex">
  60. <view class="card-name fflex tover">{{item.realName?item.realName:''}}</view>
  61. <image style="width: 64rpx;height: 64rpx;margin-left: 10rpx;" src="/card/static/images/wxChat.png"></image>
  62. </view>
  63. <view class="ddflex" style="margin-top: 4rpx;">
  64. <view class="card-tag">{{ item.jobName }}</view>
  65. <view class="card-tag">入司{{item.inDate?getAge(item.inDate):1}}年</view>
  66. </view>
  67. <view class="card-area ddflex">
  68. <image src="/card/static/images/area.png"></image>
  69. <view class="flex tover">{{item.address}}</view>
  70. <view style="color: #A1A1A1;margin-left: 10rpx;">距离{{item.distance>1000?((item.distance/1000).toFixed(2)+'km'):(item.distance+'m')}}</view>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="ddflex" style="margin-top: 41rpx;">
  75. <view class="flex">
  76. <view class="card-data">{{item.cntCust?item.cntCust:0}}</view>
  77. <view class="card-label">服务客户</view>
  78. </view>
  79. <view class="card-line"></view>
  80. <view class="flex">
  81. <view class="card-data">{{item.cntCntr?item.cntCntr:0}}</view>
  82. <view class="card-label">保单件数</view>
  83. </view>
  84. <view class="card-line"></view>
  85. <view class="flex">
  86. <view class="card-data">{{item.thumbs?item.thumbs:0}}</view>
  87. <view class="card-label">用户评价</view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. <view v-else class="nodata">
  93. <image src="../../card/static/images/empty.png" mode="widthFix"></image>
  94. <view>暂无数据</view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. const app = getApp();
  100. const req = require("../../utils/request.js");
  101. const util = require('../../utils/util.js');
  102. const QQMapWX = require("../../utils/qqmap.js");
  103. export default {
  104. components: {},
  105. props: {},
  106. data() {
  107. return {
  108. statusBarHeight:0,
  109. filterType:null,
  110. popBottom: '-100%',
  111. isShowPop: false,
  112. dateIndex: -1,
  113. // 时间类型 1、今日 2、昨日 3、近7日 4、近30天 5、本月 6、本季度 7、本年度
  114. dateList: [
  115. {
  116. label: '今日',
  117. value: 1
  118. },
  119. {
  120. label: '昨日',
  121. value: 2
  122. },
  123. {
  124. label: '近7日',
  125. value: 3
  126. },
  127. {
  128. label: '近30天',
  129. value: 4
  130. },
  131. {
  132. label: '本月',
  133. value: 5
  134. },
  135. {
  136. label: '本季度',
  137. value: 6
  138. },
  139. {
  140. label: '本年度',
  141. value: 7
  142. }
  143. ],
  144. startTime: '',
  145. endTime: '',
  146. stateIndex: -1,
  147. stateList:[{
  148. label: '开通成功',
  149. value: 7
  150. },
  151. {
  152. label: '待支付',
  153. value: 1
  154. },
  155. {
  156. label: '取消支付',
  157. value: 8
  158. }],
  159. page: 1,
  160. limit: 10,
  161. isLoad: true,
  162. searchVal: '',
  163. dataList: [],
  164. isReference:false,
  165. latitude: '23.027923',
  166. longitude: '113.753815',
  167. }
  168. },
  169. onLoad(options) {
  170. QQMapWX.initMap();
  171. req.getLocation(res => {
  172. const to = {
  173. latitude: res.latitude,
  174. longitude: res.longitude
  175. };
  176. this.latitude = res.latitude;
  177. this.longitude = res.longitude;
  178. this.getDataList()
  179. });
  180. },
  181. onShow() {
  182. if(this.isReference){
  183. this.isReference = false
  184. this.page=1;
  185. this.isLoad = true
  186. this.getDataList();
  187. }
  188. },
  189. onReachBottom() {
  190. this.page++;
  191. this.getDataList();
  192. },
  193. methods: {
  194. jumpUrl(url) {
  195. uni.navigateTo({
  196. url: url
  197. })
  198. },
  199. // 切换筛选类型
  200. changeFilterType(type){
  201. this.openPop()
  202. if(this.filterType==type) return false
  203. this.filterType = type
  204. },
  205. // 打开弹窗
  206. openPop(){
  207. this.isShowPop = true
  208. this.popBottom = '0%'
  209. },
  210. // 关闭弹窗
  211. hidePop() {
  212. this.isShowPop = false;
  213. this.popBottom = '-100%';
  214. },
  215. // 筛选
  216. switchType(index) {
  217. if(this.filterType==1){
  218. if (this.dateIndex == index) return false;
  219. this.dateIndex = index;
  220. this.startTime = '';
  221. this.endTime = '';
  222. }else{
  223. if (this.stateIndex == index) return false;
  224. this.stateIndex = index;
  225. }
  226. },
  227. changeStartTime(e) {
  228. const endTime = new Date(this.endTime);
  229. const startTime = new Date(e.detail.value);
  230. if (endTime.getTime() < startTime.getTime()) {
  231. req.msg('开始时间不能小于结束时间');
  232. return false;
  233. }
  234. this.startTime = e.detail.value;
  235. this.dateIndex = -1;
  236. if(!this.endTime){
  237. this.endTime = this.startTime
  238. }
  239. },
  240. changeEndTime(e) {
  241. const endTime = new Date(e.detail.value);
  242. const startTime = new Date(this.startTime);
  243. if (endTime.getTime() < startTime.getTime()) {
  244. req.msg('结束时间不能小于开始时间');
  245. return false;
  246. }
  247. this.endTime = e.detail.value;
  248. this.dateIndex = -1;
  249. if(!this.startTime){
  250. this.startTime = this.endTime
  251. }
  252. },
  253. confirm() {
  254. this.hidePop();
  255. this.isLoad = true;
  256. this.getDataList();
  257. },
  258. reset() {
  259. this.dateIndex = -1;
  260. this.stateIndex = -1;
  261. this.startTime = '';
  262. this.endTime = '';
  263. },
  264. // 分页查询
  265. getDataList() {
  266. if (!this.isLoad) return false;
  267. this.isLoad = false;
  268. let queryParams = {
  269. page: this.page,
  270. limit: this.limit,
  271. latitude: this.latitude,
  272. longitude: this.longitude,
  273. }
  274. if (this.searchVal) {
  275. queryParams.search = this.searchVal
  276. }
  277. // 时间筛选
  278. if (this.dateIndex != -1) {
  279. queryParams.dateType = this.dateList[this.dateIndex].value;
  280. }else if (this.dateIndex == -1) {
  281. } else {
  282. queryParams.dateType = 8
  283. queryParams.end = this.endTime?this.endTime:null;
  284. queryParams.start = this.startTime?this.startTime:null;
  285. }
  286. // 状态筛选
  287. if (this.stateIndex != -1) {
  288. queryParams.state = this.stateList[this.stateIndex].value;
  289. }
  290. req.getRequest('/api/visiting/card/cardInfoList', queryParams, data => {
  291. data = data.list
  292. if (data != null && data.length == this.limit) {
  293. this.isLoad = true;
  294. }
  295. if (this.page == 1) {
  296. this.dataList = [];
  297. }
  298. if (this.page > 0) {
  299. data = this.dataList.concat(data);
  300. }
  301. this.dataList = data;
  302. console.log('列表数据>>>', this.dataList);
  303. })
  304. },
  305. // 搜索
  306. searchFn() {
  307. this.page = 1;
  308. this.isLoad = true;
  309. this.getDataList();
  310. },
  311. formatTimeFn(data) {
  312. if (data) {
  313. return utils.formatTimeCommStr(data, 'Y-M-D')
  314. } else {
  315. return '';
  316. }
  317. },
  318. getAge(date) {
  319. return util.getAge(date)
  320. },
  321. },
  322. mounted() {
  323. const systemInfo = uni.getSystemInfoSync();
  324. // px转换到rpx的比例
  325. let pxToRpxScale = 750 / systemInfo.windowWidth;
  326. this.statusBarHeight = uni.getSystemInfoSync().windowTop*pxToRpxScale
  327. }
  328. }
  329. </script>
  330. <style>
  331. @import "./cardList.css";
  332. </style>