From 87f6bb4bcb2446b9c9065b58391ae400cd358b77 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 09 八月 2022 17:39:42 +0800
Subject: [PATCH] 智能咨询搜索界面
---
app.json | 4
pages/module_consult/consultresult/consultresult.js | 28 +++++++
pages/module_consult/consultsearch/consultsearch.wxml | 11 +-
pages/module_consult/consulthome/consulthome.wxml | 6
pages/module_consult/consulthome/consulthome.js | 59 ++++++--------
service/baserequest.js | 6 +
service/consultservice.js | 28 +++++++
pages/module_consult/consultresult/consultresult.json | 3
pages/module_consult/consultsearch/consultsearch.js | 54 ++++++++++++-
pages/module_consult/consultresult/consultresult.wxml | 2
pages/module_consult/consultresult/consultresult.wxss | 1
11 files changed, 153 insertions(+), 49 deletions(-)
diff --git a/app.json b/app.json
index b4d7859..171199a 100644
--- a/app.json
+++ b/app.json
@@ -1,5 +1,4 @@
{
- "entryPagePath": "pages/module_consult/consultsearch/consultsearch",
"pages": [
"pages/login/login",
"pages/home/home",
@@ -18,7 +17,8 @@
"pages/test/test",
"pages/promisesign/promisesign",
"pages/module_consult/consulthome/consulthome",
- "pages/module_consult/consultsearch/consultsearch"
+ "pages/module_consult/consultsearch/consultsearch",
+ "pages/module_consult/consultresult/consultresult"
],
"window": {
"backgroundTextStyle": "light",
diff --git a/pages/module_consult/consulthome/consulthome.js b/pages/module_consult/consulthome/consulthome.js
index 1601e1a..aec7504 100644
--- a/pages/module_consult/consulthome/consulthome.js
+++ b/pages/module_consult/consulthome/consulthome.js
@@ -54,38 +54,31 @@
},
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
- */
- onHide: function () {
-
- },
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
- */
- onUnload: function () {
-
- },
-
- /**
- * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
- */
- onShareAppMessage: function () {
-
+ goto (e) {
+ var url = ""
+ var index = e.currentTarget.dataset.index
+ switch (index) {
+ case "0":
+ url = ""
+ break;
+ case "1":
+ url = "/pages/module_consult/consultsearch/consultsearch"
+ break;
+ case "2":
+ url = ""
+ break;
+ }
+ if (url != "") {
+ wx.navigateTo({
+ url: url
+ })
+ } else {
+ wx.showToast({
+ title: '鍔熻兘鏁鏈熷緟',
+ duration: 1000,
+ icon: 'none',
+ mask: true,
+ })
+ }
}
})
\ No newline at end of file
diff --git a/pages/module_consult/consulthome/consulthome.wxml b/pages/module_consult/consulthome/consulthome.wxml
index 9d0ed1b..d83186b 100644
--- a/pages/module_consult/consulthome/consulthome.wxml
+++ b/pages/module_consult/consulthome/consulthome.wxml
@@ -8,21 +8,21 @@
</view>
<view class="page__bd">
<view class="flex-h">
- <view class="card">
+ <view class="card" bindtap="goto" data-index="0">
<image src="/res/icons/con_pro_bg.png" class="card-bg" mode="scaleToFill"/>
<view class="card-title">甯歌闂</view>
<view class="card-abstract">甯歌浼佷笟鐜繚闂</view>
<image src="/res/icons/con_pro.png" mode="aspectFit" class="icon"></image>
</view>
<view class="divider"></view>
- <view class="card middle">
+ <view class="card middle" bindtap="goto" data-index="1">
<image src="/res/icons/con_lib_bg.png" class="card-bg" mode="scaleToFill"/>
<view class="card-title">鐜繚鐭ヨ瘑搴�</view>
<view class="card-abstract">鐜繚娉曞緥娉曡</view>
<image src="/res/icons/con_lib.png" mode="aspectFit" class="icon"></image>
</view>
<view class="divider"></view>
- <view class="card">
+ <view class="card" bindtap="goto" data-index="2">
<image src="/res/icons/con_qa_bg.png" class="card-bg" mode="scaleToFill"/>
<view class="card-title">鏅鸿兘鍜ㄨ</view>
<view class="card-abstract">鐜繚涓撳 鍦ㄧ嚎鍜ㄨ</view>
diff --git a/pages/module_consult/consultresult/consultresult.js b/pages/module_consult/consultresult/consultresult.js
new file mode 100644
index 0000000..971e185
--- /dev/null
+++ b/pages/module_consult/consultresult/consultresult.js
@@ -0,0 +1,28 @@
+// pages/module_consult/consultresult/consultresult.js
+const consultservice = require("../../../service/consultservice")
+const app = getApp()
+
+Page({
+
+ /**
+ * 椤甸潰鐨勫垵濮嬫暟鎹�
+ */
+ data: {
+ keyword: ''
+ },
+
+ /**
+ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
+ */
+ onLoad: function (options) {
+ var that = this
+ this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) {
+ console.log(data);
+ that.data.keyword = data.keyword
+ })
+ },
+
+ search () {
+ consultservice.search(app)
+ }
+})
\ No newline at end of file
diff --git a/pages/module_consult/consultresult/consultresult.json b/pages/module_consult/consultresult/consultresult.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/pages/module_consult/consultresult/consultresult.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/pages/module_consult/consultresult/consultresult.wxml b/pages/module_consult/consultresult/consultresult.wxml
new file mode 100644
index 0000000..923854d
--- /dev/null
+++ b/pages/module_consult/consultresult/consultresult.wxml
@@ -0,0 +1,2 @@
+<!--pages/module_consult/consultresult/consultresult.wxml-->
+<text>pages/module_consult/consultresult/consultresult.wxml</text>
diff --git a/pages/module_consult/consultresult/consultresult.wxss b/pages/module_consult/consultresult/consultresult.wxss
new file mode 100644
index 0000000..acfde28
--- /dev/null
+++ b/pages/module_consult/consultresult/consultresult.wxss
@@ -0,0 +1 @@
+/* pages/module_consult/consultresult/consultresult.wxss */
\ No newline at end of file
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
diff --git a/pages/module_consult/consultsearch/consultsearch.wxml b/pages/module_consult/consultsearch/consultsearch.wxml
index a41718c..69eadf8 100644
--- a/pages/module_consult/consultsearch/consultsearch.wxml
+++ b/pages/module_consult/consultsearch/consultsearch.wxml
@@ -1,24 +1,23 @@
<!--pages/module_consult/consultsearch/consultsearch.wxml-->
<view class="page">
<view class="page__hd">
- <view class="search-bar" bindtap="search">
+ <view class="search-bar">
<mp-icon icon="search" size="15" color="black"></mp-icon>
- <text>{{searchTips}}</text>
<input type="text" class="search-bar__input" placeholder="{{placeholder}}" value="{{value}}" focus="{{focus}}" bindinput="inputChange" />
<text class="weui-icon-clear" hover-class="weui-active" wx:if="{{value.length > 0}}" bindtap="clearInput"></text>
</view>
- <view class="btn" bindtap="search">鎼滅储</view>
+ <view class="btn" bindtap="search">{{value.length > 0 ? '鎼滅储' : '鍙栨秷'}}</view>
</view>
<view class="page__bd">
<view wx:if="{{histroy.length > 0}}">
<view>鍘嗗彶璁板綍</view>
- <text wx:for="{{history}}"></text>
+ <text wx:for="{{history}}" wx:key="index">{{item}}</text>
</view>
<view>澶у閮藉湪鎼�</view>
- <view wx:for="{{hotTopic}}">
+ <view wx:for="{{hotTopic}}" wx:key="index">
<text>{{index + 1}}</text>
- <text>{{item}}</text>
+ <text>{{item.name}}</text>
<image src=""></image>
</view>
</view>
diff --git a/service/baserequest.js b/service/baserequest.js
index 21ed36a..073c4f9 100644
--- a/service/baserequest.js
+++ b/service/baserequest.js
@@ -51,11 +51,15 @@
// }
}
fun1.fail = function (error) {
+ console.log("--------------璇锋眰閿欒----------------" + fun.url);
+ console.log(error);
wx.showToast({
title: '缃戠粶杩炴帴澶辫触',
icon: 'none'
})
- fun.fail(error)
+ if (fun.fail) {
+ fun.fail(error)
+ }
}
fun1.complete = fun.complete
wx.request(fun1)
diff --git a/service/consultservice.js b/service/consultservice.js
new file mode 100644
index 0000000..7a75163
--- /dev/null
+++ b/service/consultservice.js
@@ -0,0 +1,28 @@
+const $f = require('./baserequest')
+
+module.exports = {
+ //鏍规嵁鍏抽敭瀛楁悳绱㈡硶寰嬫硶瑙�
+ searchLaw: function (userId, keyword, fun) {
+ let cb = {
+ url: `/consultation/search/law`,
+ params: {
+ userId: userId,
+ keyword: keyword
+ },
+ }
+ Object.assign(cb, fun)
+ $f.get(cb)
+ },
+
+ //鑾峰彇鐑棬
+ getTopicLaw: function (userId, fun) {
+ let cb = {
+ url: `/consultation/topic/law`,
+ params: {
+ userId: userId,
+ },
+ }
+ Object.assign(cb, fun)
+ $f.get(cb)
+ },
+}
\ No newline at end of file
--
Gitblit v1.9.3