正在显示
3 个修改的文件
包含
30 行增加
和
15 行删除
@@ -12,7 +12,7 @@ Page({ | @@ -12,7 +12,7 @@ Page({ | ||
12 | comlist:"", | 12 | comlist:"", |
13 | com_id:"", | 13 | com_id:"", |
14 | choosed_index:0, | 14 | choosed_index:0, |
15 | - datas: ["", "", "", "", ""] | 15 | + chatlist: [] |
16 | }, | 16 | }, |
17 | 17 | ||
18 | /** | 18 | /** |
@@ -68,9 +68,15 @@ Page({ | @@ -68,9 +68,15 @@ Page({ | ||
68 | 68 | ||
69 | sendMsg: function() { | 69 | sendMsg: function() { |
70 | var that = this; | 70 | var that = this; |
71 | + if (this.data.inputValue == "" || this.data.inputValue.replace(/(^\s*)|(\s*$)/g, "")==""){ | ||
72 | + wx.showToast({ | ||
73 | + title: '请输入内容', | ||
74 | + }) | ||
75 | + return | ||
76 | + } | ||
71 | var Authorization = app.globalData.Authorization; | 77 | var Authorization = app.globalData.Authorization; |
72 | wx.request({ | 78 | wx.request({ |
73 | - url: baseUrl + 'callbot/v1/chats', | 79 | + url: baseUrl + 'chatbot/v1/chats', |
74 | data: { | 80 | data: { |
75 | text: that.data.inputValue | 81 | text: that.data.inputValue |
76 | }, | 82 | }, |
@@ -81,8 +87,11 @@ Page({ | @@ -81,8 +87,11 @@ Page({ | ||
81 | }, | 87 | }, |
82 | success: function(res) { | 88 | success: function(res) { |
83 | if (res && res.data) { | 89 | if (res && res.data) { |
84 | - console.log("res", res) | ||
85 | - | 90 | + console.log("res", res) |
91 | + that.setData({ | ||
92 | + inputValue:"" | ||
93 | + }) | ||
94 | + that.getChatinfo() | ||
86 | } | 95 | } |
87 | } | 96 | } |
88 | }) | 97 | }) |
@@ -147,7 +156,7 @@ Page({ | @@ -147,7 +156,7 @@ Page({ | ||
147 | var that = this; | 156 | var that = this; |
148 | var Authorization = app.globalData.Authorization; | 157 | var Authorization = app.globalData.Authorization; |
149 | wx.request({ | 158 | wx.request({ |
150 | - url: baseUrl + 'callbot/v1/chats', | 159 | + url: baseUrl + 'chatbot/v1/chats', |
151 | data: {}, | 160 | data: {}, |
152 | method: "GET", | 161 | method: "GET", |
153 | header: { | 162 | header: { |
@@ -157,7 +166,9 @@ Page({ | @@ -157,7 +166,9 @@ Page({ | ||
157 | success: function (res) { | 166 | success: function (res) { |
158 | if (res && res.data) { | 167 | if (res && res.data) { |
159 | console.log("res", res) | 168 | console.log("res", res) |
160 | - | 169 | + that.setData({ |
170 | + chatlist: res.data.items.reverse() | ||
171 | + }) | ||
161 | } | 172 | } |
162 | } | 173 | } |
163 | }) | 174 | }) |
1 | <!--pages/main/smartchat/chat.wxml--> | 1 | <!--pages/main/smartchat/chat.wxml--> |
2 | <view hidden='{{showModal}}'> | 2 | <view hidden='{{showModal}}'> |
3 | <scroll-view style='background:#fff;margin-bottom:150rpx'> | 3 | <scroll-view style='background:#fff;margin-bottom:150rpx'> |
4 | - <view wx:for="{{datas}}"> | ||
5 | - <view style='margin:50rpx 60rpx 0 36rpx;display:flex;flex-direction:row'> | ||
6 | - <image style='width:136rpx;height:92rpx' src="/images/icon_robot.png"></image> | 4 | + <view wx:for="{{chatlist}}" wx:for-item="item" style='display:flex;flex-direction:column'> |
5 | + <view style='margin:50rpx 60rpx 0 36rpx;display:flex;flex-direction:row' wx:if="{{item.type=='0'}}"> | ||
6 | + <image style='width:102rpx;height:92rpx' src="/images/icon_robot.png"></image> | ||
7 | <view class='receive_bg'> | 7 | <view class='receive_bg'> |
8 | - <text class='text_receive_wrap'>您要计算工资薪金的还是劳务报酬的个您要计算工资薪金的还是劳务报酬的</text> | 8 | + <text class='text_receive_wrap'>{{item.text}}</text> |
9 | </view> | 9 | </view> |
10 | - | ||
11 | </view> | 10 | </view> |
12 | - <view style='margin:50rpx 36rpx 0 60rpx;display:flex;flex-direction:row'> | 11 | + <view style='margin:50rpx 36rpx 0 60rpx;display:flex;justify-content:flex-end;' wx:if="{{item.type=='1'}}"> |
13 | <view class='send_bg'> | 12 | <view class='send_bg'> |
14 | - <text class='text_send_wrap'>您要计算工资薪金的还是劳务报酬的个您要计算工资薪金的还是劳务报酬的</text> | 13 | + <text class='text_send_wrap'>{{item.text}}</text> |
15 | </view> | 14 | </view> |
16 | - <view style='width:136rpx;height:92rpx'> | 15 | + <view style='width:92rpx;height:92rpx;'> |
17 | <open-data type="userAvatarUrl"></open-data> | 16 | <open-data type="userAvatarUrl"></open-data> |
18 | </view> | 17 | </view> |
19 | </view> | 18 | </view> |
20 | </view> | 19 | </view> |
21 | </scroll-view> | 20 | </scroll-view> |
22 | <view class='bottom_wrap'> | 21 | <view class='bottom_wrap'> |
23 | - <input class='input_wrap' placeholder-class='input_placeholder_wrap' confirm-type="send" bindinput="bindKeyInput" placeholder='请输入您要咨询的问题'></input> | 22 | + <input class='input_wrap' placeholder-class='input_placeholder_wrap' confirm-type="send" bindinput="bindKeyInput" placeholder='请输入您要咨询的问题' value='{{inputValue}}'></input> |
24 | <view class='btn_send_wrap' bindtap='sendMsg'>发送</view> | 23 | <view class='btn_send_wrap' bindtap='sendMsg'>发送</view> |
25 | </view> | 24 | </view> |
26 | </view> | 25 | </view> |
@@ -118,6 +118,8 @@ | @@ -118,6 +118,8 @@ | ||
118 | padding: 0 20rpx; | 118 | padding: 0 20rpx; |
119 | border: 1px solid #e7e7e7; | 119 | border: 1px solid #e7e7e7; |
120 | border-radius: 4px; | 120 | border-radius: 4px; |
121 | + font-size: 16px; | ||
122 | + color: #333; | ||
121 | } | 123 | } |
122 | 124 | ||
123 | .receive_bg { | 125 | .receive_bg { |
@@ -132,6 +134,7 @@ | @@ -132,6 +134,7 @@ | ||
132 | font-size: 14px; | 134 | font-size: 14px; |
133 | color: #4a4a4a; | 135 | color: #4a4a4a; |
134 | letter-spacing: 0; | 136 | letter-spacing: 0; |
137 | + word-break:break-all; | ||
135 | } | 138 | } |
136 | 139 | ||
137 | .send_bg { | 140 | .send_bg { |
@@ -139,6 +142,7 @@ | @@ -139,6 +142,7 @@ | ||
139 | border-radius: 8px; | 142 | border-radius: 8px; |
140 | padding: 24rpx 28rpx; | 143 | padding: 24rpx 28rpx; |
141 | margin-right: 28rpx; | 144 | margin-right: 28rpx; |
145 | + max-width: 500rpx; | ||
142 | } | 146 | } |
143 | 147 | ||
144 | .text_send_wrap { | 148 | .text_send_wrap { |
@@ -146,6 +150,7 @@ | @@ -146,6 +150,7 @@ | ||
146 | font-size: 14px; | 150 | font-size: 14px; |
147 | color: #4a4a4a; | 151 | color: #4a4a4a; |
148 | letter-spacing: 0; | 152 | letter-spacing: 0; |
153 | + word-break:break-all; | ||
149 | } | 154 | } |
150 | 155 | ||
151 | .input_placeholder_wrap { | 156 | .input_placeholder_wrap { |
请
注册
或
登录
后发表评论