From 437144f41c74505d362a5214a18cec3d01b3ce4b Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 10 十月 2022 17:51:30 +0800
Subject: [PATCH] 2022.10.10

---
 pages/m_consult/consultonline/consultonline.js |  168 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 121 insertions(+), 47 deletions(-)

diff --git a/pages/m_consult/consultonline/consultonline.js b/pages/m_consult/consultonline/consultonline.js
index 9d994c1..4ff59c9 100644
--- a/pages/m_consult/consultonline/consultonline.js
+++ b/pages/m_consult/consultonline/consultonline.js
@@ -1,8 +1,9 @@
 // pages/m_consult/consultonline/consultonline.js
+const b_search = require("../behaviors/b_search")
 const app = getApp()
 
 Page({
-
+  behaviors: [b_search],
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
    */
@@ -13,56 +14,23 @@
         time: '',
         userId: 'system',
         userName: '鏅鸿兘瀹㈡湇',
-        text: '鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓轰綘鏈嶅姟',
-      },
-      {
-        id: 'system',
-        time: '',
-        userId: 'system',
-        userName: '鏅鸿兘瀹㈡湇',
-        text: '鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓烘偍鏈嶅姟锛屾湰鏈堜俊鐢ㄨ嚜璇勭粨鏋滆緝 濂斤紝缁х画淇濇寔鍝�.鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓烘偍鏈嶅姟锛屾湰鏈堜俊鐢ㄨ嚜璇勭粨鏋滆緝 濂斤紝缁х画淇濇寔鍝�.鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓烘偍鏈嶅姟锛屾湰鏈堜俊鐢ㄨ嚜璇勭粨鏋滆緝 濂斤紝缁х画淇濇寔鍝�.鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓烘偍鏈嶅姟锛屾湰鏈堜俊鐢ㄨ嚜璇勭粨鏋滆緝 濂斤紝缁х画淇濇寔鍝�.鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓烘偍鏈嶅姟锛屾湰鏈堜俊鐢ㄨ嚜璇勭粨鏋滆緝 濂斤紝缁х画淇濇寔鍝�.',
-      },
-
+        type: 0,
+        text: '灏婃暚鐨勭敤鎴凤紝灏忕櫧绔瘹涓烘偍鏈嶅姟锛屾偍鏈変粈涔堥棶棰樺憿',
+      }
     ],
 
     focus: false,
     value: '',
-    placeholder: '璇疯緭鍏ュ叧閿瓧'
+    placeholder: '璇疯緭鍏ユ兂瑕佹彁闂殑鍐呭'
   },
 
   /**
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad(options) {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
-   */
-  onReady() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
-   */
-  onShow() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
-   */
-  onHide() {
-
-  },
-
-  /**
-   * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
-   */
-  onUnload() {
-
+    this.setData({
+      userId: app.globalData.accessToken.userId
+    })
   },
 
   clearInput() {
@@ -85,27 +53,133 @@
       time: '',
       userId: app.globalData.accessToken.userId,
       userName: app.globalData.userInfo.acountname,
+      type: 0,
       text: this.data.value,
     })
-    this.getAnswer(this.data.value)
+    console.log('-----------chat------------------');
+    console.log(record);
+    console.log(this.data.userId);
+    this.lastKeyword = this.data.value
     this.setData({
       record,
       value: ''
     })
+
+    this.getAnswer()
   },
 
-  getAnswer(q) {
+  getAnswer() {
+    this.search({
+      keyword: this.lastKeyword,
+      type: undefined
+    }, 1, 1)
+    // let record = this.data.record
+    // const r = {
+    //   id: 'system',
+    //   time: '',
+    //   userId: 'system',
+    //   userName: '鏅鸿兘瀹㈡湇',
+    //   type: 1,
+    //   text: {
+    //     tabList: [
+    //       {name: '闂瓟',tag: 0}, 
+    //       {name: '妗堜緥',tag: 0}, 
+    //       {name: '鏉$洰',tag: 0}, 
+    //       {name: '鏂囦欢',tag: 0}
+    //     ],
+    //     key1: {keyword: q, type: 1},
+    //     key2: {keyword: q, type: 2},
+    //     key3: {keyword: q, type: 3},
+    //     key4: {keyword: q, type: 4},
+    //     // pageList: p
+    //   },
+    // }
+    // this.data.record.push(r)
+    // let last = this.data.record.length - 1
+    // this.setData({
+    //   [`record[${last}]`]: r
+    // })
+    // this.setData({
+    //   record,
+    // })
+  },
+
+  loadComplete() {
+    const results = this.data.results
     let record = this.data.record
 
-    setTimeout(() => {
+    if (results.length == 0) {
       record.push({
         id: 'system',
         time: '',
         userId: 'system',
         userName: '鏅鸿兘瀹㈡湇',
-        text: '鐢ㄦ埛鎮ㄥソ锛屽緢楂樺叴涓轰綘鏈嶅姟',
+        type: 0,
+        text: '鎶辨瓑锛屾垜杩樹笉鐞嗚В鎮ㄧ殑鎰忔�濄�傝灏濊瘯閲嶆柊鍜ㄨ銆�'
       })
-      this.setData({record})
-    }, 1000);
+    } else {
+      record.push({
+        id: 'system',
+        time: '',
+        userId: 'system',
+        userName: '鏅鸿兘瀹㈡湇',
+        type: 0,
+        text: '灏忕櫧缁欐偍鎻愪緵鍙傝�冨涓嬶細'
+      })
+      const map = new Map()
+      results.sort((a, b) => {
+        return b.typeId - a.typeId
+      })
+      results.forEach(r => {
+        if (!map.has(r.typeName)) {
+          r.keyword = this.lastKeyword
+          map.set(r.typeName, [])
+          map.get(r.typeName).push(r)
+        }
+      });
+      const t = []
+      const p = []
+      for (let item of map) {
+        t.push({
+          name: item[0],
+          tag: 0
+        })
+        p.push(item[1])
+      }
+      record.push({
+        id: 'system',
+        time: '',
+        userId: 'system',
+        userName: '鏅鸿兘瀹㈡湇',
+        type: 1,
+        refresh: true,
+        text: {
+          tabList: t,
+          pageList: p
+        },
+      })
+    }
+    this.setData({
+      record,
+    })
+  },
+
+  gotoMore(e) {
+    const iList = e.currentTarget.dataset.index
+    const i1 = iList[0]
+    const i2 = iList[1]
+    const {keyword, typeId} = this.data.record[i1].text.pageList[i2][0]
+    console.log(keyword);
+    console.log(typeId);
+    wx.navigateTo({
+      url: '/pages/m_consult/consultresultmore/consultresultmore',
+      success: (res) => {
+        // 閫氳繃 eventChannel 鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+        res.eventChannel.emit('acceptDataFromOpenerPage', {
+          typeId: typeId,
+          keyword: keyword
+        })
+      },
+    })
   }
 })
\ No newline at end of file

--
Gitblit v1.9.3