link chat and camera

This commit is contained in:
Fam Zheng 2025-03-01 12:48:34 +00:00
parent f2c461935a
commit 5557efe0a5
6 changed files with 74 additions and 28 deletions

View File

@ -35,6 +35,11 @@ Component({
});
return;
}
this.setData({
visible_content: [],
next_index: 0,
next_offset: 0,
});
setTimeout(() => {
this.update_interval = setInterval(() => {
this.update_visible_content();
@ -49,12 +54,12 @@ Component({
}
},
update_visible_content() {
console.log('update_visible_content', this.data.next_index, this.properties.content.length);
if (this.data.next_index >= this.properties.content.length) {
clearInterval(this.update_interval);
return;
}
var next_entry = this.properties.content[this.data.next_index];
console.log('next_entry', next_entry);
if (next_entry.type != 'text') {
// just add the next entry to the visible content
this.setData({

View File

@ -4,7 +4,7 @@
</view>
<view class="content {{ is_prompt ? 'prompt' : '' }}">
<view wx:for="{{ visible_content }}" wx:key="index">
<view wx:if="{{ item.type == 'text'}}" class="text {{ item.classes }}">
<view wx:if="{{ item.type == 'text'}}" class="text {{ item.classes }}" data-index="{{ index }}" bindtap="handle_onclick">
<text wx:if="{{ item.mark == 'tick' }}" class="green">✓</text><text class="{{ item.classes }}">{{ item.content }}</text>
</view>
<view wx:if="{{ item.type == 'scanguidecss' }}" class="media">

View File

@ -89,4 +89,9 @@ view.text.margin-bottom-10 {
view.text.bold {
font-weight: bold;
}
view.text.link {
color: #ef4823;
text-decoration: underline;
}

View File

@ -85,6 +85,9 @@ Page({
},
onLoad(options) {
this.setData({
ai_chat_mode: options.ai_chat_mode,
});
var new_session_id = Date.now();
getApp().globalData.session_id = new_session_id;
if (options.env == 'dev') {
@ -280,9 +283,17 @@ Page({
show_result_page(serial_code) {
this.busy = true;
wx.redirectTo({
url: '/pages/productinfo/productinfo?serial_code=' + serial_code,
});
if (this.data.ai_chat_mode) {
// YYYY-MM-DD HH:MM:SS
var time = new Date().toISOString().replace('T', ' ').replace('Z', '');
wx.redirectTo({
url: '/pages/chat/chat?serial_code=' + serial_code + '&time=' + time,
});
} else {
wx.redirectTo({
url: '/pages/productinfo/productinfo?serial_code=' + serial_code,
});
}
},
show_verifyfailed() {

View File

@ -41,10 +41,15 @@ Page({
* Lifecycle function--Called when page load
*/
onLoad(options) {
this.show_welcome_response();
this.show_verify_result();
this.show_product_details();
this.show_promotions();
this.setData({
serial_code: options.serial_code,
time: options.time,
});
if (options.serial_code) {
this.show_verify_result(true);
} else {
this.show_welcome_response();
}
},
/**
@ -98,7 +103,7 @@ Page({
goto_camera() {
wx.navigateTo({
url: '/pages/camera/camera',
url: '/pages/camera/camera?ai_chat_mode=1',
})
},
@ -120,7 +125,7 @@ Page({
})
},
show_verify_tech() {
this.setData({
this.set_content({
prompt: [
{
type: 'text',
@ -161,7 +166,7 @@ Page({
type: 'suggestion',
title: '重看验证结果',
onclick: () => {
this.show_verify_result();
this.show_verify_result(false);
}
},
{
@ -181,7 +186,9 @@ Page({
]
})
},
show_verify_result() {
show_verify_result(is_first_time) {
var serial_code = this.data.serial_code || "";
var time = this.data.time || "2025-01-01 14:30";
var resp = [
{
type: 'text',
@ -203,12 +210,17 @@ Page({
},
{
type: 'text',
content: '验证编码: xxxxx',
classes: 'margin-bottom-10',
content: '验证编码: ' + serial_code,
classes: 'margin-bottom-10 link',
onclick: () => {
wx.navigateTo({
url: '/pages/productinfo/productinfo?serial_code=' + serial_code,
});
}
},
{
type: 'text',
content: '验证时间: 2025-02-24 14:30'
content: '验证时间: ' + time,
},
{
type: 'splitline',
@ -240,16 +252,18 @@ Page({
}
},
]
this.setData({
prompt: [{
type: 'text',
content: '查看验证结果'
}],
var prompt = is_first_time ? [] : [{
type: 'text',
content: '查看验证结果'
}];
this.set_content({
prompt: prompt,
response: resp,
})
},
show_welcome_response() {
this.setData({
this.set_content({
prompt: [],
response: this.data.welcome_response,
})
},
@ -295,7 +309,7 @@ Page({
type: 'suggestion',
title: '重看验证结果',
onclick: () => {
this.show_verify_result();
this.show_verify_result(false);
}
},
{
@ -313,7 +327,7 @@ Page({
}
}
]
this.setData({
this.set_content({
prompt: [{
type: 'text',
content: '这个产品怎么样'
@ -357,7 +371,7 @@ Page({
type: 'suggestion',
title: '重看验证结果',
onclick: () => {
this.show_verify_result();
this.show_verify_result(false);
}
},
{
@ -375,7 +389,7 @@ Page({
}
}
]
this.setData({
this.set_content({
prompt: [{
type: 'text',
content: '有什么福利活动吗?'
@ -383,4 +397,15 @@ Page({
response: resp,
})
},
set_content({prompt, response}) {
this.setData({
prompt: prompt,
response: response,
})
this.selectComponent('#response').restart_content_output();
var x = this.selectComponent('#prompt');
if (x) {
x.restart_content_output();
}
}
})

View File

@ -1,7 +1,7 @@
<view class="container">
<view class="chatlog {{ show_modal.length > 0 ? 'hidden' : '' }}">
<contentstream wx:if="{{ prompt.length > 0 }}" content="{{ prompt }}" is_prompt="1"></contentstream>
<contentstream content="{{ response }}"></contentstream>
<contentstream id="prompt" wx:if="{{ prompt.length > 0 }}" content="{{ prompt }}" is_prompt="1"></contentstream>
<contentstream id="response" content="{{ response }}"></contentstream>
</view>
<view class="bottom">
<view class="quick-actions">