qx
qx
2025-03-13 a4a0046f5cbd0b165f7597c2a0bcb6811681dc0c
qx
1个文件已修改
1个文件已添加
74 ■■■■■ 已修改文件
src/views/123+.vue 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/tijian/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/123+.vue
New file
@@ -0,0 +1,73 @@
<template>
  <div>
    <h2>DeepSeek 聊天</h2>
    <textarea v-model="inputMessage" placeholder="请输入消息"></textarea>
    <button @click="sendMessage">发送</button>
    <p>回复: {{ reply }}</p>
    <p v-if="error" style="color: red">{{ error }}</p>
  </div>
</template>
<script>
export default {
  name: 'Chat',
  data() {
    return {
      inputMessage: '',
      reply: '',
      error: ''
    };
  },
  methods: {
    async sendMessage() {
      if (!this.inputMessage.trim()) {
        this.error = '消息不能为空';
        return;
      }
      this.error = '';
      this.reply = '';
      try {
        const response = await fetch('http://localhost:11434/api/chat', {
          method: 'POST',
          headers: {
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            model: 'ltkj-jy-ai',
            messages: [
              {
                role: 'system',
                content: this.inputMessage
              }
            ],
            stream: false
          })
        });
        if (!response.ok) {
          throw new Error('网络响应错误');
        }
        const data = await response.json();
        // 从返回数据中提取 message.content 作为回复
        this.reply = data.message?.content || '收到回复,但格式可能不正确';
      } catch (err) {
        this.error = '请求出错: ' + err.message;
        console.error('Fetch 错误:', err);
      }
    }
  }
};
</script>
<style scoped>
textarea {
  width: 300px;
  height: 100px;
  margin-bottom: 10px;
}
button {
  padding: 5px 10px;
}
</style>
src/views/system/tijian/index.vue
@@ -3261,6 +3261,7 @@
            discount: item.discount,
            parentProId: item.parentProId,
            cusIdCard: item.cusId,
            yhj: item.nowPrice
          })); // 创建新的对象,包含 discount 和 id
        gaibianzhekou(newArray).then((res) => {
          this.loadingSubmit = false;