From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交

---
 wechat_staff/pages/kefu/select.js |   92 ++++++++++++++++++++++++++++++++++++---------
 1 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/wechat_staff/pages/kefu/select.js b/wechat_staff/pages/kefu/select.js
index 2daf226..a3d2b7b 100644
--- a/wechat_staff/pages/kefu/select.js
+++ b/wechat_staff/pages/kefu/select.js
@@ -1,12 +1,22 @@
-// pages/discover/discover.js
+import { getCustomerList, getCrmAuthUrl, batchAddLike } from '../../api/index'
+const { HYEventBus } = require('hy-event-store')
+const eventBus = new HYEventBus()
 Page({
 
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
   data: {
-    activeTabs: '0',
-    bottomLift: 0
+    bottomLift: 0,
+
+    keyWords: '',
+    dataList: [],
+    customer: {},
+    total: 0,
+    flag: 0,
+    page: 1,
+    pageSize: 10,
+
   },
 
   /**
@@ -17,26 +27,70 @@
     this.setData({
       bottomLift: app.bottomLift
     })
-  },  
-  tabsClick(e) {
-    const activeTabs = e.currentTarget.dataset.tab
-    this.setData({activeTabs})
-  },
+    this.getList()
+    
+  }, 
   handleSub() {
-    console.log('鐐瑰嚮楗夸簡');
-    wx.canvasToTempFilePath({
-      x: 100,
-      y: 200,
-      width: 50,
-      height: 50,
-      destWidth: 100,
-      destHeight: 100,
-      canvasId: 'myCanvas',
-      success(res) {
-        console.log(res.tempFilePath)
+    const { customer } = this.data
+    const enjoyList = wx.getStorageSync('enjoyList') || []
+    if(!customer.userId) return wx.showToast({
+      title: '璇峰厛閫夋嫨瑕佸叧鑱旂殑瀹㈡埛', icon: 'none'
+    })
+    batchAddLike({
+      articleIds: enjoyList.filter(i => i.checked).map(i => i.id).join(','),
+      customerId: customer.userId
+    })
+  },
+  tabsClick(e) {
+    const flag = e.currentTarget.dataset.tab
+    this.setData({flag})
+    this.setData({total: 0,dataList: [], page: 1})
+    this.getList()
+  },
+  itemCheck(e) {
+    const item = e.currentTarget.dataset.item
+    console.log('item', item);
+    this.setData({ customer: item })
+  },
+  reloadList() {
+    this.setData({total: 0,dataList: [], page: 1})
+    this.getList()
+  },
+  scrolltolower() {
+    console.log('瑙﹀簳浜嬩欢');
+    const { total, dataList, page } = this.data
+    if(total > dataList.length){
+      this.setData({ page: page + 1 })
+      this.getList()
+    }else{
+      wx.showToast({
+        title: '鏆傛棤鏇村鏁版嵁',
+        icon: 'none'
+      })
+    }
+  },
+  getList() {
+    const { flag, page, pageSize, keyWords } = this.data
+    getCustomerList({
+      flag, page, pageSize, keyWords
+    }).then(res => {
+      if(res.data){
+        this.setData({
+          total: res.data.total,
+          dataList: [...this.data.dataList, ...res.data.data]
+        })
       }
     })
   },
+  jumpClient() { 
+    getCrmAuthUrl({type:1}).then(res => {
+      console.log(res.data)
+      this.setData({ url: res.data })
+      wx.navigateTo({
+        url: '/pages/webView/index?link=' + res.data,
+      })
+    }) 
+  },
   onReady() {
 
   },

--
Gitblit v1.9.3