From ebc6e7ee67f13e7aa311e737dfcb4c5caed112ee Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期四, 15 八月 2024 18:23:57 +0800
Subject: [PATCH] ll

---
 wechat_staff/pages/kefu/select.js |  138 ++++++++++++++++++++++++++++++++++++----------
 1 files changed, 108 insertions(+), 30 deletions(-)

diff --git a/wechat_staff/pages/kefu/select.js b/wechat_staff/pages/kefu/select.js
index ece970c..9e287d9 100644
--- a/wechat_staff/pages/kefu/select.js
+++ b/wechat_staff/pages/kefu/select.js
@@ -1,4 +1,12 @@
-import { getCustomerList } from '../../api/index'
+import {
+  getCustomerList,
+  getCrmAuthUrl,
+  batchAddLike
+} from '../../api/index'
+const {
+  HYEventBus
+} = require('hy-event-store')
+const eventBus = new HYEventBus()
 Page({
 
   /**
@@ -9,6 +17,7 @@
 
     keyWords: '',
     dataList: [],
+    customer: {},
     total: 0,
     flag: 0,
     page: 1,
@@ -25,24 +34,86 @@
       bottomLift: app.bottomLift
     })
     this.getList()
-  },  
+
+  },
+  handleSub() {
+    const {
+      customer
+    } = this.data
+    const enjoyList = wx.getStorageSync('enjoyList') || []
+    if (!customer.platSourceId) return wx.showToast({
+      title: '璇峰厛閫夋嫨瑕佸叧鑱旂殑瀹㈡埛',
+      icon: 'none'
+    })
+    batchAddLike({
+      articleIds: enjoyList.filter(i => i.checked).map(i => i.id).join(','),
+      customerId: customer.customerId,
+      platId: customer.platSourceId,
+      platSource: customer.platSource
+    }).then(res => {
+      if (res.code == 200) {
+        setTimeout(() => {
+          wx.showToast({
+            title: '缁戝畾鎴愬姛',
+            icon: 'none'
+          })
+        }, 500)
+        this.setData({
+          customer: {},
+          total: 0,
+          dataList: [],
+          page: 1
+        })
+        this.getList()
+      }else{
+        return wx.showToast({
+          title: res.message,
+          icon: 'none'
+        })
+      }
+    })
+  },
   tabsClick(e) {
     const flag = e.currentTarget.dataset.tab
-    this.setData({flag})
-    this.setData({total: 0,dataList: [], page: 1})
+    this.setData({
+      flag
+    })
+    this.setData({
+      total: 0,
+      dataList: [],
+      page: 1,
+      customer: {}
+    })
     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.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 })
+    const {
+      total,
+      dataList,
+      page
+    } = this.data
+    if (total > dataList.length) {
+      this.setData({
+        page: page + 1
+      })
       this.getList()
-    }else{
+    } else {
       wx.showToast({
         title: '鏆傛棤鏇村鏁版嵁',
         icon: 'none'
@@ -50,11 +121,19 @@
     }
   },
   getList() {
-    const { flag, page, pageSize, keyWords } = this.data
+    const {
+      flag,
+      page,
+      pageSize,
+      keyWords
+    } = this.data
     getCustomerList({
-      flag, page, pageSize, keyWords
+      flag,
+      page,
+      pageSize,
+      keyWords
     }).then(res => {
-      if(res.data){
+      if (res.data) {
         this.setData({
           total: res.data.total,
           dataList: [...this.data.dataList, ...res.data.data]
@@ -63,24 +142,23 @@
     })
   },
   jumpClient() {
-    
-    wx.switchTab({
-      url: '/pages/client/index',
-    })
-  },
-  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)
-      }
+    getCrmAuthUrl({
+      type: 1
+    }).then(res => {
+      this.setData({
+        url: res.data
+      })
+      const url = res.data
+      wx.navigateTo({
+        url: '/pages/webView/index',
+        success: function (res1) {
+          // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹� 
+          console.log(url)
+          res1.eventChannel.emit('data', {
+            link: url
+          });
+        }
+      })
     })
   },
   onReady() {

--
Gitblit v1.9.3