clientManage.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view>
  3. <view class="tab ddflex">
  4. <view class="tab-item fflex" :class="tabIndex==1?'tab-item-active':''" @click="tabChange(1)">我的客户</view>
  5. <view class="tab-item fflex" :class="tabIndex==2?'tab-item-active':''" @click="tabChange(2)">客户动态</view>
  6. </view>
  7. <view class="top-fixed" v-if="tabIndex==1">
  8. <view class="search-box ddflex">
  9. <view class="search-input ddflex fflex">
  10. <image src="/static/images/ssico.png"></image>
  11. <input @confirm="searchFn" confirm-type="search" @input="searchFn" v-model="searchVal" class="fflex"
  12. placeholder="请输入客户昵称或真实姓名" />
  13. </view>
  14. <!-- <view style="margin: 0rpx 0rpx 0 20rpx;color: #2A82FD;text-align: right;font-size: 26rpx;" @click="jumpUrl('/mine/allDynamic/allDynamic')">客户动态></view> -->
  15. </view>
  16. <view class="filter ddflex">
  17. <view :class="'filter-item fflex ddflex '+(filterType==2&&isShowPop?'f-active':'')" @click="changeFilterType(2)">
  18. <text style="max-width: 150rpx;" class="tover">{{stateIndex!=-1?stateList[stateIndex].label:'智能筛选'}}</text>
  19. <image class="filter-item-icon" :style="filterType==2&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  20. </view>
  21. <view :class="'filter-item fflex ddflex '+(filterType==1&&isShowPop?'f-active':'')" @click="changeFilterType(1)">
  22. 筛选
  23. <image class="filter-item-icon" :style="filterType==1&&isShowPop?'transform: rotate(180deg);':''" src="../static/images/down.png"></image>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="ceng" :style="'top:calc(' +popBottom+' + '+(isShowPop?270:0)+'rpx' " v-if="isShowPop" @click="hidePop()"></view>
  28. <view class="hx-pop" :style="'top:calc(' +popBottom+' + '+(isShowPop?270:0)+'rpx' ">
  29. <view class="pop-con" v-if="filterType==1">
  30. <view class="pop-list">
  31. <view v-for="(item, index) in dateList" :key="index" style="margin-bottom: 30rpx;">
  32. <view>{{ item.title }}</view>
  33. <view class="ddflex">
  34. <view :class="'opt' + (it.isActive? ' opt-active' : '')" v-for="(it, idx) in item.option" :key="idx" @click="switchFilterType(index,idx)">
  35. <view>{{ it.label }}</view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="pop-con" v-if="filterType==2">
  42. <view class="pop-list">
  43. <view :class="'li' + (stateIndex == index ? ' active' : '')" v-for="(item, index) in stateList" :key="index" @click="switchType(index)">
  44. {{ item.label }}
  45. </view>
  46. </view>
  47. </view>
  48. <view class="pop-btn ddflex" v-if="filterType!=2">
  49. <view @click="reset">重置</view>
  50. <view class="fflex" @click="confirm">确定</view>
  51. </view>
  52. </view>
  53. <view style="height: 290rpx;" v-if="tabIndex==1"></view>
  54. <view style="height: 120rpx;" v-if="tabIndex==2"></view>
  55. <!-- 订单列表 -->
  56. <block v-if="tabIndex==1">
  57. <view style="position: relative;overflow: hidden;" v-if="dataList.length>0">
  58. <view class="register-box" v-for="item,index in dataList" :key="index" @click="jumpUrl('/mine/clientDetail/clientDetail?id='+item.id)">
  59. <view class="register-title dflex fflex">
  60. <image class="register-title-icon" :src="item.avatar?item.avatar:'/static/images/userimg.png'"></image>
  61. <view class="flex" style="min-width: 0;">
  62. <view class="ddflex">
  63. <view class="card-name fflex tover">{{item.nickName?item.nickName:''}}</view>
  64. <view v-if="item.mobile">
  65. <image style="width: 140rpx;height: 64rpx;margin-left: 20rpx;" src="/mine/static/images/lx.png" @click.stop="goPhone(item.mobile)"></image>
  66. </view>
  67. </view>
  68. <view class="card-name" style="line-height: 48rpx;margin-bottom: 10rpx;" v-if="item.realName">({{item.realName}})</view>
  69. <view class="ddflex" style="margin-top: 4rpx;">
  70. <block v-if="item.customTypeName&&item.customTypeName.length>0">
  71. <view class="card-tag" v-for="it,idx in item.customTypeName" :key="idx+'s'">{{it}}</view>
  72. </block>
  73. <block v-if="item.labelName&&item.labelName.length>0">
  74. <view class="card-tag card-tag-t" v-for="it,idx in item.labelName" :key="idx+'l'">{{it}}</view>
  75. </block>
  76. </view>
  77. <view class="ddflex" style="font-size: 24rpx;color: #999;font-weight: 400;margin: 20rpx 0;">
  78. <text>保单</text><text style="color: #000000;">{{item.warrantyCount?item.warrantyCount:0}}</text>
  79. <view class="card-line" style="height: 23rpx;margin: 0 10rpx;"></view>
  80. <text>共计保费</text><text style="color: #FF5700;">{{item.warrantyMoney?item.warrantyMoney:0}}元</text>
  81. </view>
  82. </view>
  83. </view>
  84. <!-- <view class="ddflex" style="margin-top: 41rpx;font-size: 24rpx;padding: 0 30rpx;">
  85. <view class="ddflex fflex">
  86. <view style="color: #999;margin-right: 16rpx;">服务策略</view>
  87. <view style="color: #333333;">刺激消费频率</view>
  88. </view>
  89. <view v-if="item.mobile">
  90. <image style="width: 140rpx;height: 64rpx;margin-left: 20rpx;" src="/mine/static/images/lx.png" @click.stop="goPhone(item.mobile)"></image>
  91. </view>
  92. </view> -->
  93. </view>
  94. </view>
  95. <view v-else class="nodata">
  96. <image src="../../card/static/images/empty.png" mode="widthFix"></image>
  97. <view>暂无数据</view>
  98. </view>
  99. </block>
  100. <block v-if="tabIndex==2">
  101. <view class="log">
  102. <view v-if="logsList && logsList.length > 0" v-for="(it, index) in logsList" :key="index" @click="jumpUrl('/mine/clientDetail/clientDetail?id='+it.uid)">
  103. <view class="time-year" v-if="todayYear!=it.year && index==0 || (index!=0 && (it.year!=logsList[index-1].year))">{{ it.year }}年</view>
  104. <view class="dflex">
  105. <view class="time-sort">
  106. <block v-if="index==0 || (index!=0 && (it.day!=logsList[index-1].day||it.month!=logsList[index-1].month||it.year!=logsList[index-1].year))">
  107. <text v-if="todayYear==it.year&&todayMonth==it.month&&todayDay==it.day">今日</text>
  108. <block v-else>
  109. <text>{{it.day}}</text>{{ it.month }}月
  110. </block>
  111. </block>
  112. </view>
  113. <view class="li fflex">
  114. <image src="/mine/static/images/jcico.png" class="jcico"></image>
  115. <view class="ddflex" style="width: 100%;margin-bottom: 20rpx;">
  116. <image style="width: 80rpx;height: 80rpx;border-radius: 100%;margin-right: 20rpx;" :src="it.avatar?it.avatar:'/static/images/userimg.png'"></image>
  117. <view class="fflex">
  118. <view style="font-size: 28rpx;font-weight: bold;" class="ddflex">
  119. <view class="tover " style="max-width: 250rpx;">{{it.nickName}}</view>
  120. <view v-if="it.realName">({{it.realName}})</view>
  121. </view>
  122. <view class="time">{{ it.time }}</view>
  123. </view>
  124. </view>
  125. <!-- <view class="des" v-if="it.brief">{{ it.brief }}</view> -->
  126. <rich-text class="des" :nodes="it.content"></rich-text>
  127. </view>
  128. </view>
  129. </view>
  130. <view v-if="!logsList || logsList.length == 0" class="nodata">
  131. <image src="/mine/static/images/empty.png" mode="aspectFill"></image>
  132. <view>暂无记录~</view>
  133. </view>
  134. </view>
  135. </block>
  136. </view>
  137. </template>
  138. <script>
  139. const app = getApp();
  140. const req = require("../../utils/request.js");
  141. const util = require('../../utils/util.js');
  142. export default {
  143. components: {},
  144. props: {},
  145. data() {
  146. return {
  147. tabIndex:1,
  148. filterType:null,
  149. popBottom: '-100%',
  150. isShowPop: false,
  151. dateIndex: -1,
  152. // 时间类型 1、今日 2、昨日 3、近7日 4、近30天 5、本月 6、本季度 7、本年度
  153. dateList: [
  154. {
  155. title:'性别',
  156. key:'sex',
  157. option:[
  158. {
  159. label: '男',
  160. value: 1
  161. },{
  162. label: '女',
  163. value: 2
  164. },
  165. ]
  166. },{
  167. title:'客户类型',
  168. key:'custom_type',
  169. option:[]
  170. },{
  171. title:'客户标签',
  172. key:'custom_label',
  173. option:[
  174. {
  175. label: '经理',
  176. value: 1
  177. },{
  178. label: '负责人',
  179. value: 2
  180. },{
  181. label: '业务员',
  182. value: 3
  183. }
  184. ]
  185. }
  186. ],
  187. stateIndex: 0,
  188. stateList:[{
  189. label: '智能推荐',
  190. value: null
  191. },{
  192. label: '保费从高到低',
  193. value: 'warranty_money',
  194. behavior:'desc'
  195. },
  196. {
  197. label: '保费从低到高',
  198. value: 'warranty_money',
  199. behavior:'asc'
  200. },
  201. {
  202. label: '保单从高到低',
  203. value: 'warranty_count',
  204. behavior:'desc'
  205. },{
  206. label: '保单从低到高',
  207. value: 'warranty_count',
  208. behavior:'asc'
  209. }],
  210. page: 1,
  211. limit: 10,
  212. isLoad: true,
  213. searchVal: '',
  214. dataList: [],
  215. isReference:false,
  216. // 动态
  217. form: {
  218. page: 1,
  219. limit: 10
  220. },
  221. isLoadDynamic: true,
  222. logsList:[],
  223. todayYear:'',
  224. todayMonth:'',
  225. todayDay:''
  226. }
  227. },
  228. async onLoad(options) {
  229. this.todayYear = new Date().getFullYear()
  230. this.todayMonth = new Date().getMonth() + 1
  231. this.todayDay = new Date().getDate()
  232. await this.getDict()
  233. await this.getDictCustomType()
  234. this.getDataList()
  235. },
  236. onShow() {
  237. if(this.isReference){
  238. this.isReference = false
  239. this.page=1;
  240. this.isLoad = true
  241. this.getDataList();
  242. }
  243. },
  244. onReachBottom() {
  245. if(this.tabIndex==1){
  246. this.page++;
  247. this.getDataList();
  248. }
  249. if(this.tabIndex==2){
  250. this.form.page++;
  251. this.getPageList(false);
  252. }
  253. },
  254. methods: {
  255. jumpUrl(url) {
  256. uni.navigateTo({
  257. url: url
  258. })
  259. this.hidePop()
  260. },
  261. // 客户标签字典
  262. getDict(){
  263. return new Promise((r,j)=>{
  264. req.getRequest('/api/other/dict/info',{dictType:'custom_label'},res=>{
  265. this.dateList.map(item=>{
  266. if(item.key=='custom_label'){
  267. item.option = []
  268. res.map(it=>{
  269. item.option.push({
  270. label:it.dictName,
  271. value:it.dictValue
  272. })
  273. })
  274. }
  275. })
  276. r(res)
  277. })
  278. })
  279. },
  280. // 客户类型字典
  281. getDictCustomType(){
  282. return new Promise((r,j)=>{
  283. req.getRequest('/api/other/dict/info',{dictType:'custom_type'},res=>{
  284. this.dateList.map(item=>{
  285. if(item.key=='custom_type'){
  286. item.option = []
  287. res.map(it=>{
  288. item.option.push({
  289. label:it.dictName,
  290. value:it.dictValue
  291. })
  292. })
  293. }
  294. })
  295. r(res)
  296. })
  297. })
  298. },
  299. // 切换筛选类型
  300. changeFilterType(type){
  301. // if(this.filterType==type) return false
  302. this.filterType = type
  303. if(type==3) {
  304. this.hidePop()
  305. return false
  306. }
  307. this.openPop()
  308. },
  309. // 打开弹窗
  310. openPop(){
  311. this.isShowPop = true
  312. this.popBottom = '0%'
  313. },
  314. // 关闭弹窗
  315. hidePop() {
  316. this.isShowPop = false;
  317. this.popBottom = '-100%';
  318. },
  319. // 筛选
  320. switchType(index) {
  321. if (this.stateIndex == index) return false;
  322. this.stateIndex = index;
  323. this.confirm()
  324. },
  325. switchFilterType(index,idx) {
  326. // 可多选
  327. if(this.dateList[index].key=='custom_label' || this.dateList[index].key=='custom_type'){
  328. if(!this.dateList[index].option[idx].isActive){
  329. this.dateList[index].option[idx].isActive = true
  330. }else{
  331. this.dateList[index].option[idx].isActive = false
  332. }
  333. }else{
  334. if(!this.dateList[index].option[idx].isActive){
  335. this.dateList[index].option.map(item=>{
  336. item.isActive = false
  337. })
  338. this.dateList[index].option[idx].isActive = true
  339. }else{
  340. this.dateList[index].option[idx].isActive = false
  341. }
  342. }
  343. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  344. },
  345. confirm() {
  346. this.hidePop();
  347. this.isLoad = true;
  348. this.page=1;
  349. this.isLoad = true
  350. this.getDataList();
  351. },
  352. reset() {
  353. this.dateIndex = -1;
  354. this.stateIndex = 0;
  355. this.dateList.map(item=>{
  356. item.option.map(it=>{
  357. it.isActive = false
  358. })
  359. })
  360. this.dateList = JSON.parse(JSON.stringify(this.dateList))
  361. },
  362. // 分页查询
  363. getDataList() {
  364. if (!this.isLoad) return false;
  365. this.isLoad = false;
  366. let queryParams = {
  367. page: this.page,
  368. limit: this.limit,
  369. latitude: this.latitude,
  370. longitude: this.longitude,
  371. }
  372. if (this.searchVal) {
  373. queryParams.nickName = this.searchVal
  374. }
  375. // 状态筛选
  376. if (this.stateIndex != -1) {
  377. queryParams.orderField = this.stateList[this.stateIndex].value;
  378. if(this.stateList[this.stateIndex].behavior){
  379. queryParams.order = this.stateList[this.stateIndex].behavior;
  380. }
  381. }
  382. this.dateList.map(item=>{
  383. if(item.key=="sex"){
  384. let sl = item.option.filter(it=>{return it.isActive})
  385. if(sl.length>0){
  386. queryParams.gender = sl[0].value
  387. }
  388. }
  389. if(item.key=="custom_label"){
  390. let jl = item.option.filter(it=>{return it.isActive})
  391. if(jl.length>0){
  392. // queryParams.label = jl[0].value
  393. queryParams.label = jl.map(item => {return item.value}).join(',')
  394. }
  395. }
  396. if(item.key=="custom_type"){
  397. let tl = item.option.filter(it=>{return it.isActive})
  398. if(tl.length>0){
  399. queryParams.type = tl.map(item => {return item.value}).join(',')
  400. }
  401. }
  402. })
  403. req.getRequest('/api/user/getUserBySaleNo', queryParams, data => {
  404. data = data.list
  405. if (data != null && data.length == this.limit) {
  406. this.isLoad = true;
  407. }
  408. if (this.page == 1) {
  409. this.dataList = [];
  410. }
  411. if (this.page > 0) {
  412. data = this.dataList.concat(data);
  413. }
  414. this.dataList = data;
  415. console.log('列表数据>>>', this.dataList);
  416. })
  417. },
  418. // 搜索
  419. searchFn() {
  420. this.page = 1;
  421. this.isLoad = true;
  422. this.page=1;
  423. this.getDataList();
  424. },
  425. // 拨打电话
  426. goPhone(phone) {
  427. if(!phone) return false
  428. uni.makePhoneCall({
  429. phoneNumber: phone,
  430. success(res){
  431. }
  432. }); // 传参带入号码即可
  433. },
  434. tabChange(index){
  435. if(this.tabIndex==index) return false
  436. this.tabIndex = index
  437. this.hidePop()
  438. if(this.tabIndex==2){
  439. this.form.page = 1
  440. this.isLoadDynamic = true;
  441. this.logsList = []
  442. this.getPageList(true)
  443. }else{
  444. this.page = 1;
  445. this.isLoad = true;
  446. this.page=1;
  447. this.dataList = [];
  448. this.getDataList();
  449. }
  450. },
  451. getPageList(isShow) {
  452. if (!this.isLoadDynamic) return false;
  453. this.isLoadDynamic = false;
  454. let form = this.form;
  455. uni.showLoading();
  456. req.getRequest(
  457. '/api/user/getUsersTrends',
  458. form,
  459. res => {
  460. res = res?res.list:[]
  461. if(res&&res.length>0){
  462. res.map(item=>{
  463. let t = this.getDate(item.createDate)
  464. item.year = t.year
  465. item.month = t.month
  466. item.day = t.day
  467. item.time = (t.hour<10?('0'+t.hour):t.hour)+':'+(t.minute<10?('0'+t.minute):t.minute)
  468. })
  469. }
  470. this.isShow = true;
  471. if (res && res.length == 10) {
  472. this.isLoadDynamic = true;
  473. }
  474. if (this.form.page > 1) {
  475. res = this.logsList.concat(res);
  476. }else{
  477. this.goTop()
  478. }
  479. this.logsList = res;
  480. uni.hideLoading();
  481. },
  482. isShow
  483. );
  484. },
  485. getDate(dateStr){
  486. if(!dateStr) return false
  487. let date = new Date(dateStr)
  488. const year = date.getFullYear();
  489. const month = date.getMonth() + 1;
  490. const day = date.getDate();
  491. const hour = date.getHours();
  492. const minute = date.getMinutes();
  493. const second = date.getSeconds();
  494. return {
  495. year:year,
  496. month:month,
  497. day:day,
  498. hour:hour,
  499. minute:minute,
  500. second:second,
  501. }
  502. },
  503. goTop(e) {
  504. // 一键回到顶部
  505. if (uni.pageScrollTo) {
  506. uni.pageScrollTo({
  507. scrollTop: 0,
  508. duration:100
  509. });
  510. }
  511. }
  512. },
  513. mounted() {
  514. }
  515. }
  516. </script>
  517. <style>
  518. @import "./clientManage.css";
  519. </style>