From 87f6bb4bcb2446b9c9065b58391ae400cd358b77 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 09 八月 2022 17:39:42 +0800
Subject: [PATCH] 智能咨询搜索界面

---
 pages/module_consult/consultsearch/consultsearch.js |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/pages/module_consult/consultsearch/consultsearch.js b/pages/module_consult/consultsearch/consultsearch.js
index 9e30741..4504269 100644
--- a/pages/module_consult/consultsearch/consultsearch.js
+++ b/pages/module_consult/consultsearch/consultsearch.js
@@ -1,4 +1,7 @@
 // pages/module_consult/consultsearch/consultsearch.js
+const consultservice = require("../../../service/consultservice")
+const app = getApp()
+
 Page({
   /**
    * 椤甸潰鐨勫垵濮嬫暟鎹�
@@ -17,7 +20,7 @@
    * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
    */
   onLoad: function (options) {
-
+    this.getHotTopic()
   },
 
   /**
@@ -25,6 +28,10 @@
    */
   onReady: function () {
 
+  },
+
+  onShow: function () {
+    this.getLocalHistory()
   },
 
   clearInput() {
@@ -45,20 +52,59 @@
    * 鎼滅储
    */
   search() {
-
+    if (this.data.value.length == 0) {
+      wx.navigateBack({
+        delta: 1,
+      })
+      return
+    }
+    var that = this
+    wx.navigateTo({
+      url: '/pages/module_consult/consultresult/consultresult',
+      success: (res) => {
+        // 閫氳繃 eventChannel 鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+        res.eventChannel.emit('acceptDataFromOpenerPage', {
+          keyword: that.data.value
+        })
+      },
+    })
+    
+    if (this.data.histroy.indexOf(this.data.value) == -1) {
+      this.data.histroy.unshift(this.data.value)
+      wx.setStorage({
+        data: JSON.stringify(this.data.histroy),
+        key: 'search_history',
+      })
+    }
   },
 
   /**
    * 鑾峰彇鏈湴缂撳瓨鎼滅储鍘嗗彶
    */
   getLocalHistory() {
-
+    var that = this
+    wx.getStorage({
+      key: 'search_history',
+      success: (res) => {
+        let h = JSON.parse(res.data)
+        that.setData({
+          histroy: h
+        })
+      },
+    })
   },
 
   /**
    * 鑾峰彇鐑棬鎼滅储鍐呭
    */
   getHotTopic() {
-
+    var that = this
+    consultservice.getTopicLaw(app.globalData.accessToken.userId, {
+      success (res) {
+        that.setData({
+          hotTopic: res
+        })
+      }
+    })
   },
 })
\ No newline at end of file

--
Gitblit v1.9.3