基于coze+微信小程序的ai对话
界面介绍:
代码:(替换你的coze的配置)
<template><view class="container"><!-- 高斯模糊背景 --><view class="animated-bg"><view class="gradient-blob"></view><view class="gradient-blob two"></view><view class="gradient-blob three"></view><view class="gradient-blob four"></view><view class="overlay"></view></view><!-- 返回按钮 --><view class="back-button" @tap="goBack"><text class="back-icon">←</text><text class="back-text">返回</text></view><!-- 头部区域 --><view class="header"><text class="logo-text">AI Assistant</text><text class="subtitle">智能学习英语,探索无限可能</text></view><!-- 搜索区域 --><view class="search-section" :class="{ 'search-focused': isFocused }"><view class="search-box"><text class="search-icon">🔍</text><input class="search-input" type="text" v-model="searchQuery"placeholder="探索任何英语问题..."@focus="handleFocus"@blur="handleBlur"@confirm="handleSearch"/><view v-if="searchQuery" @tap="clearSearch" class="clear-btn"><text class="clear-icon">✕</text></view></view></view><!-- 内容区域 --><scroll-view class="content-section" scroll-y :class="{ 'has-result': searchResult }"><!-- 默认状态 --><view class="welcome-section" v-if="!searchResult && !loading"><view class="feature-cards"><view class="feature-card"><text class="card-icon">💡</text><text class="card-title">智能问答</text></view><view class="feature-card"><text class="card-icon">🎯</text><text class="card-title">精准解析</text></view><view class="feature-card"><text class="card-icon">🚀</text><text class="card-title">即时响应</text></view></view><view class="quick-starts"><text class="section-title">快速开始</text><view class="suggestion-chips"><text class="chip" @tap="useExample('讲解英语的发展历程')">英语简史</text><text class="chip" @tap="useExample('如何有效的学习英语?')">英语学习方法</text><text class="chip" @tap="useExample('如何提高学习效率?')">提高英语学习效率</text></view></view></view><!-- 加载状态 --><view class="loading-state" v-if="loading"><view class="pulse-loader"><view class="pulse"></view><view class="pulse"></view><view class="pulse"></view></view><text class="loading-text">AI 思考中...</text></view><!-- 结果展示 --><view class="result-wrapper" v-if="searchResult"><view class="result-card"><view class="result-header"><text class="ai-badge">AI</text><text class="timestamp">{{new Date().toLocaleTimeString()}}</text></view><text class="result-text">{{searchResult}}</text></view><!-- 跟进问题 --><view class="follow-up-section" v-if="followUpQuestions.length"><text class="section-title">延伸思考</text><view class="follow-up-list"><view class="follow-up-item" v-for="(question, index) in followUpQuestions" :key="index"@tap="useExample(question)"><text class="follow-up-icon">❯</text><text class="follow-up-text">{{question}}</text></view></view></view></view></scroll-view></view>
</template><script>export default {data() {return {searchQuery: '',searchResult: '',followUpQuestions: [],loading: false,isFocused: false,// Coze API 配置cozeConfig: {apiUrl: 'https://api.coze.cn/open_api/v2/chat',token: '', // 替换为您的访问令牌botId: '', // 替换为您的机器人IDuserId: '' // 用户ID,可以根据需要修改}}},methods: {// 返回上一页goBack() {uni.navigateBack({delta: 1 // 返回的页面层数,1 表示返回上一页});},handleFocus() {this.isFocused = true},handleBlur() {this.isFocused = false},clearSearch() {this.searchQuery = ''this.searchResult = ''},useExample(text) {this.searchQuery = textthis.handleSearch()},async handleSearch() {if (!this.searchQuery.trim()) {uni.showToast({title: '请输入搜索内容',icon: 'none'});return;}this.loading = true;this.followUpQuestions = [];try {const response = await uni.request({url: this.cozeConfig.apiUrl,method: 'POST',header: {'Authorization': `Bearer ${this.cozeConfig.token}`,'Content-Type': 'application/json','Accept': '*/*','Host': 'api.coze.cn','Connection': 'keep-alive'},data: {conversation_id: Date.now().toString(),bot_id: this.cozeConfig.botId,user: this.cozeConfig.userId,query: this.searchQuery,stream: false}});// 解析响应const responseData = response[1].data; // 第二个元素才是实际数据if (responseData.code === 0) {const messages = responseData.messages || [];// 只获取类型为 answer 的第一条消息作为核心回答const answer = messages.find(msg => msg.type === 'answer');if (answer) {// 移除可能的 verbose 信息和系统提示let cleanAnswer = answer.content.replace(/\{.*?\}/g, '') // 移除 JSON 格式的内容.replace(/\[.*?\]/g, '') // 移除方括号内的内容.trim();this.searchResult = cleanAnswer;}// 获取跟进问题const followUps = messages.filter(msg => msg.type === 'follow_up');if (followUps.length > 0) {this.followUpQuestions = followUps.map(q => q.content);}} else {throw new Error('API 请求失败');}} catch (error) {console.error('API Error:', error);uni.showToast({title: '搜索失败,请重试',icon: 'none'});} finally {this.loading = false;}}}}
</script><style>.container {min-height: 100vh;position: relative;overflow: hidden;background: #f8f9fa;}.animated-bg {position: fixed;width: 100%;height: 100%;top: 0;left: 0;overflow: hidden;z-index: 0;background: linear-gradient(125deg, #00fff3, #ff00e6);animation: gradientBG 15s ease infinite;}.gradient-blob {position: absolute;width: 1000rpx;height: 1000rpx;background: linear-gradient(45deg,rgba(255, 49, 97, 0.5),rgba(255, 97, 162, 0.5));border-radius: 50%;filter: blur(80px);animation: blob-movement 20s infinite linear,color-shift 10s infinite alternate;opacity: 0.7;top: -300rpx;left: -300rpx;}.gradient-blob.two {background: linear-gradient(45deg,rgba(67, 206, 162, 0.5),rgba(24, 90, 157, 0.5));animation: blob-movement-2 25s infinite linear,color-shift-2 12s infinite alternate;animation-delay: -3s;top: 60%;left: 60%;}.gradient-blob.three {background: linear-gradient(45deg,rgba(255, 197, 84, 0.5),rgba(255, 159, 0, 0.5));animation: blob-movement-3 30s infinite linear,color-shift-3 8s infinite alternate;animation-delay: -5s;top: 40%;left: 30%;}.gradient-blob.four {background: linear-gradient(45deg,rgba(147, 88, 255, 0.5),rgba(19, 123, 255, 0.5));animation: blob-movement-4 28s infinite linear,color-shift-4 15s infinite alternate;animation-delay: -7s;top: 20%;left: 70%;}.overlay {position: absolute;top: 0;left: 0;right: 0;bottom: 0;background: rgba(255, 255, 255, 0.2);backdrop-filter: blur(20px);}@keyframes gradientBG {0% {background-position: 0% 50%;}50% {background-position: 100% 50%;}100% {background-position: 0% 50%;}}@keyframes blob-movement {0% {transform: translate(0, 0) scale(1) rotate(0deg);}33% {transform: translate(300rpx, 200rpx) scale(1.2) rotate(120deg);}66% {transform: translate(-200rpx, 400rpx) scale(0.8) rotate(240deg);}100% {transform: translate(0, 0) scale(1) rotate(360deg);}}@keyframes blob-movement-2 {0% {transform: translate(0, 0) scale(1.1) rotate(0deg);}33% {transform: translate(-250rpx, -300rpx) scale(0.9) rotate(120deg);}66% {transform: translate(300rpx, -200rpx) scale(1.2) rotate(240deg);}100% {transform: translate(0, 0) scale(1.1) rotate(360deg);}}@keyframes blob-movement-3 {0% {transform: translate(0, 0) scale(0.9) rotate(0deg);}33% {transform: translate(400rpx, -100rpx) scale(1.1) rotate(120deg);}66% {transform: translate(-300rpx, 200rpx) scale(0.8) rotate(240deg);}100% {transform: translate(0, 0) scale(0.9) rotate(360deg);}}@keyframes blob-movement-4 {0% {transform: translate(0, 0) scale(1) rotate(0deg);}33% {transform: translate(-200rpx, 300rpx) scale(1.1) rotate(120deg);}66% {transform: translate(250rpx, -250rpx) scale(0.9) rotate(240deg);}100% {transform: translate(0, 0) scale(1) rotate(360deg);}}@keyframes color-shift {0% {background: linear-gradient(45deg, rgba(255, 49, 97, 0.5), rgba(255, 97, 162, 0.5));}100% {background: linear-gradient(45deg, rgba(255, 182, 193, 0.5), rgba(255, 20, 147, 0.5));}}@keyframes color-shift-2 {0% {background: linear-gradient(45deg, rgba(67, 206, 162, 0.5), rgba(24, 90, 157, 0.5));}100% {background: linear-gradient(45deg, rgba(0, 255, 255, 0.5), rgba(0, 128, 128, 0.5));}}@keyframes color-shift-3 {0% {background: linear-gradient(45deg, rgba(255, 197, 84, 0.5), rgba(255, 159, 0, 0.5));}100% {background: linear-gradient(45deg, rgba(255, 215, 0, 0.5), rgba(255, 140, 0, 0.5));}}@keyframes color-shift-4 {0% {background: linear-gradient(45deg, rgba(147, 88, 255, 0.5), rgba(19, 123, 255, 0.5));}100% {background: linear-gradient(45deg, rgba(138, 43, 226, 0.5), rgba(65, 105, 225, 0.5));}}/* 头部样式 */.header {padding: 60rpx 40rpx;text-align: center;z-index: 1;position: relative;}.logo-text {font-size: 48rpx;color: #1a1a1a;font-weight: 600;letter-spacing: 2rpx;text-shadow: 0 2px 4px rgba(255, 255, 255, 0.2);}.subtitle {font-size: 28rpx;color: rgba(0, 0, 0, 0.7);margin-top: 16rpx;display: block;}/* 搜索框样式 */.search-section {padding: 20rpx 40rpx;position: relative;z-index: 2;}.search-box {background: rgba(255, 255, 255, 0.2);backdrop-filter: blur(20px);border-radius: 20rpx;padding: 24rpx 32rpx;display: flex;align-items: center;border: 1px solid rgba(255, 255, 255, 0.3);transition: all 0.3s ease;}.search-box:hover {background: rgba(255,255,255,0.15);}.search-input {flex: 1;margin: 0 20rpx;font-size: 32rpx;color: #1a1a1a;height: 48rpx;line-height: 48rpx;}.search-icon, .clear-icon {font-size: 32rpx;color: rgba(255,255,255,0.6);}/* 功能卡片 */.feature-cards {display: flex;justify-content: space-around;padding: 40rpx;gap: 20rpx;}.feature-card {background: rgba(255, 255, 255, 0.2);backdrop-filter: blur(10px);border-radius: 16rpx;padding: 30rpx;text-align: center;flex: 1;border: 1px solid rgba(255, 255, 255, 0.3);transition: all 0.3s ease;}.feature-card:active {transform: scale(0.98);background: rgba(255,255,255,0.15);}.card-icon {font-size: 48rpx;margin-bottom: 16rpx;display: block;}.card-title {color: #fff;font-size: 28rpx;}/* 建议词条 */.quick-starts {padding: 40rpx;}.section-title {color: rgba(0, 0, 0, 0.7);font-size: 28rpx;margin-bottom: 20rpx;display: block;}.suggestion-chips {display: flex;flex-wrap: wrap;gap: 16rpx;}.chip {background: rgba(255,255,255,0.1);padding: 16rpx 32rpx;border-radius: 100rpx;color: #fff;font-size: 28rpx;transition: all 0.3s ease;}.chip:active {background: rgba(255,255,255,0.2);transform: scale(0.98);}/* 加载动画 */.loading-state {padding: 60rpx;text-align: center;}.pulse-loader {display: flex;justify-content: center;gap: 12rpx;}.pulse {width: 16rpx;height: 16rpx;background: #fff;border-radius: 50%;animation: pulse 1.5s infinite ease-in-out;}.pulse:nth-child(2) { animation-delay: 0.2s; }.pulse:nth-child(3) { animation-delay: 0.4s; }@keyframes pulse {0%, 100% { transform: scale(0.5); opacity: 0.2; }50% { transform: scale(1); opacity: 1; }}.loading-text {color: rgba(255,255,255,0.7);font-size: 28rpx;margin-top: 20rpx;display: block;}/* 结果卡片 */.result-wrapper {padding: 40rpx;}.result-card {background: rgba(255, 255, 255, 0.2);backdrop-filter: blur(15px);border-radius: 20rpx;padding: 30rpx;border: 1px solid rgba(255, 255, 255, 0.3);animation: slideUp 0.3s ease;}.result-header {display: flex;justify-content: space-between;align-items: center;margin-bottom: 20rpx;}.ai-badge {background: linear-gradient(135deg, #7C3AED, #3B82F6);color: #fff;padding: 6rpx 16rpx;border-radius: 8rpx;font-size: 24rpx;}.timestamp {color: rgba(255,255,255,0.5);font-size: 24rpx;}.result-text {color: #1a1a1a;font-size: 30rpx;line-height: 1.6;}/* 跟进问题 */.follow-up-section {margin-top: 40rpx;}.follow-up-list {display: flex;flex-direction: column;gap: 16rpx;}.follow-up-item {background: rgba(255, 255, 255, 0.15);padding: 24rpx;border-radius: 16rpx;display: flex;align-items: center;transition: all 0.3s ease;backdrop-filter: blur(10px);}.follow-up-item:active {background: rgba(255,255,255,0.15);transform: translateX(10rpx);}.follow-up-icon {color: rgba(255,255,255,0.5);margin-right: 16rpx;font-size: 24rpx;}.follow-up-text {color: #1a1a1a;font-size: 28rpx;}@keyframes slideUp {from { opacity: 0;transform: translateY(20rpx);}to {opacity: 1;transform: translateY(0);}}.search-input::placeholder {color: rgba(0, 0, 0, 0.4);}.back-button {position: fixed;top: 40rpx;left: 20rpx;display: flex;align-items: center;padding: 10rpx 20rpx;background: rgba(255, 255, 255, 0.8);border-radius: 50rpx;backdrop-filter: blur(10px);z-index: 999;box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);}.back-icon {font-size: 36rpx;margin-right: 10rpx;color: #333;}.back-text {font-size: 28rpx;color: #333;}
</style>
相关文章:

基于coze+微信小程序的ai对话
界面介绍: 代码:(替换你的coze的配置) <template><view class"container"><!-- 高斯模糊背景 --><view class"animated-bg"><view class"gradient-blob"></view…...

[Linux]项目自动化构建工具-make/Makefile
项目自动化构建工具-make/Makefile make与Makefile单文件Makefile多文件Makefile 缓冲区 首先理清多文件之间的关系: 这里为什么没有包含test.h头文件?因为在当前工作目录下,因此不需要包含test.h,如果把test.h移到上一级目录&…...

Dashboard-frps
通过浏览器查看 frp的状态以及代理统计信息展示。 注:Dashboard 尚未针对大量的 proxy 数据展示做优化,如果出现 Dashboard 访问较慢的情况,请不要启用此功能。 需要在 frps.ini中指定 dashboard服务使用的端口,即可开启此功能&…...

android 新增native binder service 方式(三)
书接上回,继续第三种方式,是手动生成 service binder 的方法,项目结构 1,编译aidl aidl 文件保持不变,如何生成Bn和Bp 文件呢。 aidl -I ./libserviceaidl/aidl -h ./ -o ./ --langcpp libserviceaidl/aidl/com/test/IService.a…...

(IDE接入DeepSeek)简单了解DeepSeek接入辅助开发与本地部署建议
重点:IDE接入DeepSeek是否收费 收费! 本文章主要是为了给小白避雷,目前很多文章告诉大家怎么接入DeepSeek,但是并未告知大家是否收费。如果是想白嫖的,就可以不用去接入了。 一、引言 最近爆火的AI人工智能工具DeepSe…...

seasms v9 注入漏洞 + order by注入+information_schema解决方法
目录 一、当注入时,information_schema被禁用的解决方法 1.通过sys库可以获取到表名和库名 2.通过无列名注入join获取列名 二、seasms v9 注入漏洞 三、order by注入 一、当注入时,information_schema被禁用的解决方法 information_schema数据库是My…...

【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
👉 点击关注不迷路 👉 点击关注不迷路 👉 点击关注不迷路 文章大纲 10分钟快速部署Elasticsearch单节点环境1. 系统环境要求1.1 硬件配置推荐1.2 软件依赖 2. Docker部署方案2.1 部署流程2.2 参数说明2.3 性能优化建议 3. 手动部署方案3.1 安…...
如何使用useEffect模拟组件的生命周期?
什么是 useEffect? useEffect 是 React 提供的一个 Hook,用于处理副作用(side effects)。它允许你在函数组件中执行一些操作,这些操作通常会影响组件的渲染,比如数据获取、订阅、DOM 操作等。通过 useEffe…...

【DeepSeek】私有化本地部署图文(Win+Mac)
目录 一、DeepSeek本地部署【Windows】 1、安装Ollama 2、配置环境变量 3、下载模型 4、使用示例 a、直接访问 b、chatbox网页访问 二、DeepSeek本地部署【Mac】 1、安装Ollama 2、配置环境变量 3、下载模型 4、使用示例 5、删除已下载的模型 三、DeepSeek其他 …...

Python 入门教程(2)搭建环境 | 2.3、VSCode配置Python开发环境
文章目录 一、VSCode配置Python开发环境1、软件安装2、安装Python插件3、配置Python环境4、包管理5、调试程序 前言 Visual Studio Code(简称VSCode)以其强大的功能和灵活的扩展性,成为了许多开发者的首选。本文将详细介绍如何在VSCode中配置…...
Wireshark详解
Wireshark使用详解 1.Wireshark 简介2.下载与安装1. 下载地址2. 安装步骤(以 Windows 为例) 3. 界面与核心功能1. 主界面布局2. 常用菜单功能 4. 过滤功能详解1. 过滤类型2. 常用过滤命令 5. 过滤命令与网络结构对应6. 使用注意事项7. 案例分析 TCP 三次…...
《从零开始掌握Python:一份全面的学习指南》
一、为什么选择Python? Python以其简洁优雅的语法和强大的生态系统成为全球最受欢迎的编程语言之一。无论是开发网站、分析数据、构建人工智能模型,还是自动化办公,Python都能轻松胜任。 学习门槛低:代码如英文般直观,例如 print("Hello, World!")。 应用领域广…...

布署elfk-准备工作
建议申请5台机器部署elfk: filebeat(每台app)--> logstash(2台keepalived)--> elasticsearch(3台)--> kibana(部署es上)采集输出 处理转发 分布式存储 展示 ELK中文社区: 搜索客,搜索人自己的社区 官方…...

LlamaFactory-webui:训练大语言模型的入门级教程
LlamaFactory是一个开源框架,支持多种流行的语言模型,及多种微调技术,同时,以友好的交互式界面,简化了大语言模型的学习。 本章内容,从如何拉取,我已经搭建好的Llamafactory镜像开始࿰…...
达梦数据库授权给某个用户查询其他指定用户下所有表的权限
方法1: 新版本有一个数据库参数 GRANT_SCHEMA,表示是否开启授予和回收模式权限功能。0:否;1:是 此参数为静态参数,默认是0,将改参数修改为1后,重启数据库生效。 将参数修改为1 S…...

uniapp 微信小程序打包之后vendor.js 主包体积太大,解决办法,“subPackages“:true设置不生效
现在是打包的时候,vendor.js 的内容全部打到了主包里面, 说一下我的方法: 1. 通过发行 小程序打包 这样打包的体积是最小的,打包之后打开微信开发工具,然后再上传 2.manifest.json,在“mp-weixin”里添加代码 "…...

Docker数据卷容器实战
数据卷容器 数据共享 上面讲述的是主机和容器之间共享数据,那么如何实现容器和容器之间的共享数据呢?那就是创建 创建数据卷容器。 命名的容器挂载数据卷,其他容器通过挂载这个(父容器)实现数据共享,挂载…...
【Eureka 缓存机制】
今天简单介绍一下Eureka server 的缓存机制吧✌️✌️✌️ 一、先来个小剧场:服务发现的"拖延症" 想象你是个外卖小哥(客户端),每次接单都要打电话问调度中心(Eureka Server):“现在…...
docker-compose方式启动Kafka Sasl加密认证(无zk)
首先参考文档,思考过程可以进行参考https://juejin.cn/post/7294556533932884020#heading-3 用的镜像是Bitnami,对SASL配置进行了简化,需要按照特定格式去配置jass验证 完整配置如下 镜像版本参考:https://hub.docker.com/r/bitn…...

[ComfyUI]官方已支持Skyreels混元图生视频,速度更快,效果更好(附工作流)
一、介绍 昨天有提到官方已经支持了Skyreels,皆大欢喜,效果更好一些,还有GGUF量化版本,进一步降低了大家的显存消耗。 今天就来分享一下官方流怎么搭建,我体验下来感觉更稳了一些,生成速度也更快…...
Vim 调用外部命令学习笔记
Vim 外部命令集成完全指南 文章目录 Vim 外部命令集成完全指南核心概念理解命令语法解析语法对比 常用外部命令详解文本排序与去重文本筛选与搜索高级 grep 搜索技巧文本替换与编辑字符处理高级文本处理编程语言处理其他实用命令 范围操作示例指定行范围处理复合命令示例 实用技…...
Spring Boot 实现流式响应(兼容 2.7.x)
在实际开发中,我们可能会遇到一些流式数据处理的场景,比如接收来自上游接口的 Server-Sent Events(SSE) 或 流式 JSON 内容,并将其原样中转给前端页面或客户端。这种情况下,传统的 RestTemplate 缓存机制会…...

3.3.1_1 检错编码(奇偶校验码)
从这节课开始,我们会探讨数据链路层的差错控制功能,差错控制功能的主要目标是要发现并且解决一个帧内部的位错误,我们需要使用特殊的编码技术去发现帧内部的位错误,当我们发现位错误之后,通常来说有两种解决方案。第一…...

论文浅尝 | 基于判别指令微调生成式大语言模型的知识图谱补全方法(ISWC2024)
笔记整理:刘治强,浙江大学硕士生,研究方向为知识图谱表示学习,大语言模型 论文链接:http://arxiv.org/abs/2407.16127 发表会议:ISWC 2024 1. 动机 传统的知识图谱补全(KGC)模型通过…...
C# SqlSugar:依赖注入与仓储模式实践
C# SqlSugar:依赖注入与仓储模式实践 在 C# 的应用开发中,数据库操作是必不可少的环节。为了让数据访问层更加简洁、高效且易于维护,许多开发者会选择成熟的 ORM(对象关系映射)框架,SqlSugar 就是其中备受…...
Java多线程实现之Thread类深度解析
Java多线程实现之Thread类深度解析 一、多线程基础概念1.1 什么是线程1.2 多线程的优势1.3 Java多线程模型 二、Thread类的基本结构与构造函数2.1 Thread类的继承关系2.2 构造函数 三、创建和启动线程3.1 继承Thread类创建线程3.2 实现Runnable接口创建线程 四、Thread类的核心…...
BLEU评分:机器翻译质量评估的黄金标准
BLEU评分:机器翻译质量评估的黄金标准 1. 引言 在自然语言处理(NLP)领域,衡量一个机器翻译模型的性能至关重要。BLEU (Bilingual Evaluation Understudy) 作为一种自动化评估指标,自2002年由IBM的Kishore Papineni等人提出以来,…...
关于uniapp展示PDF的解决方案
在 UniApp 的 H5 环境中使用 pdf-vue3 组件可以实现完整的 PDF 预览功能。以下是详细实现步骤和注意事项: 一、安装依赖 安装 pdf-vue3 和 PDF.js 核心库: npm install pdf-vue3 pdfjs-dist二、基本使用示例 <template><view class"con…...

Ubuntu Cursor升级成v1.0
0. 当前版本低 使用当前 Cursor v0.50时 GitHub Copilot Chat 打不开,快捷键也不好用,当看到 Cursor 升级后,还是蛮高兴的 1. 下载 Cursor 下载地址:https://www.cursor.com/cn/downloads 点击下载 Linux (x64) ,…...
vue3 daterange正则踩坑
<el-form-item label"空置时间" prop"vacantTime"> <el-date-picker v-model"form.vacantTime" type"daterange" start-placeholder"开始日期" end-placeholder"结束日期" clearable :editable"fal…...