基于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量化版本,进一步降低了大家的显存消耗。 今天就来分享一下官方流怎么搭建,我体验下来感觉更稳了一些,生成速度也更快…...
利用最小二乘法找圆心和半径
#include <iostream> #include <vector> #include <cmath> #include <Eigen/Dense> // 需安装Eigen库用于矩阵运算 // 定义点结构 struct Point { double x, y; Point(double x_, double y_) : x(x_), y(y_) {} }; // 最小二乘法求圆心和半径 …...
多云管理“拦路虎”:深入解析网络互联、身份同步与成本可视化的技术复杂度
一、引言:多云环境的技术复杂性本质 企业采用多云策略已从技术选型升维至生存刚需。当业务系统分散部署在多个云平台时,基础设施的技术债呈现指数级积累。网络连接、身份认证、成本管理这三大核心挑战相互嵌套:跨云网络构建数据…...
React Native 开发环境搭建(全平台详解)
React Native 开发环境搭建(全平台详解) 在开始使用 React Native 开发移动应用之前,正确设置开发环境是至关重要的一步。本文将为你提供一份全面的指南,涵盖 macOS 和 Windows 平台的配置步骤,如何在 Android 和 iOS…...
Cesium1.95中高性能加载1500个点
一、基本方式: 图标使用.png比.svg性能要好 <template><div id"cesiumContainer"></div><div class"toolbar"><button id"resetButton">重新生成点</button><span id"countDisplay&qu…...
循环冗余码校验CRC码 算法步骤+详细实例计算
通信过程:(白话解释) 我们将原始待发送的消息称为 M M M,依据发送接收消息双方约定的生成多项式 G ( x ) G(x) G(x)(意思就是 G ( x ) G(x) G(x) 是已知的)࿰…...
visual studio 2022更改主题为深色
visual studio 2022更改主题为深色 点击visual studio 上方的 工具-> 选项 在选项窗口中,选择 环境 -> 常规 ,将其中的颜色主题改成深色 点击确定,更改完成...
从零实现STL哈希容器:unordered_map/unordered_set封装详解
本篇文章是对C学习的STL哈希容器自主实现部分的学习分享 希望也能为你带来些帮助~ 那咱们废话不多说,直接开始吧! 一、源码结构分析 1. SGISTL30实现剖析 // hash_set核心结构 template <class Value, class HashFcn, ...> class hash_set {ty…...
FFmpeg:Windows系统小白安装及其使用
一、安装 1.访问官网 Download FFmpeg 2.点击版本目录 3.选择版本点击安装 注意这里选择的是【release buids】,注意左上角标题 例如我安装在目录 F:\FFmpeg 4.解压 5.添加环境变量 把你解压后的bin目录(即exe所在文件夹)加入系统变量…...
uniapp 小程序 学习(一)
利用Hbuilder 创建项目 运行到内置浏览器看效果 下载微信小程序 安装到Hbuilder 下载地址 :开发者工具默认安装 设置服务端口号 在Hbuilder中设置微信小程序 配置 找到运行设置,将微信开发者工具放入到Hbuilder中, 打开后出现 如下 bug 解…...
提升移动端网页调试效率:WebDebugX 与常见工具组合实践
在日常移动端开发中,网页调试始终是一个高频但又极具挑战的环节。尤其在面对 iOS 与 Android 的混合技术栈、各种设备差异化行为时,开发者迫切需要一套高效、可靠且跨平台的调试方案。过去,我们或多或少使用过 Chrome DevTools、Remote Debug…...
