You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

339 lines
6.8 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="main">
  3. <view class="top" :style="{ height: iSMT + 'px' }"></view>
  4. <!-- 头部导航 -->
  5. <view class="header">
  6. <view class="back-icon">
  7. <image @click="onBack" src="/static/customer-service-platform/cs-platform-back.png"
  8. class="header-icon-image"></image>
  9. </view>
  10. <view class="title">{{ headerTitle }}</view>
  11. <view class="notification-icon">
  12. <image src="/static/customer-service-platform/message.png" class="header-icon-image"></image>
  13. </view>
  14. </view>
  15. <scroll-view scroll-y class="content-container">
  16. <view class="content-header">
  17. <view class="content-header-area">
  18. <view class="logo">
  19. <image mode="aspectFit" src="/static/customer-service-platform/ellipse-dc-img.png"></image>
  20. </view>
  21. <view class="greeting">
  22. <text class="greet-title">我能为你做点什么</text>
  23. <text class="greet-sub">DeepChart随时为您提供服务</text>
  24. </view>
  25. </view>
  26. </view>
  27. <!-- 卡片部分 -->
  28. <view class="card">
  29. <!-- 问题头部-->
  30. <view class="question-header">
  31. <view class="question-row">
  32. <image class="question-avatar" src="/static/customer-service-platform/robot-head.png"
  33. mode="aspectFill"></image>
  34. <view class="question-title">{{ questionTitle }}</view>
  35. </view>
  36. </view>
  37. <!-- 卡片内容区-->
  38. <view class="card-body">
  39. <image class="card-logo" src="/static/customer-service-platform/ellipse-dc-img.png"
  40. mode="aspectFit"></image>
  41. <view class="card-text">
  42. <text class="card-paragraph">
  43. {{answerContent}}
  44. </text>
  45. </view>
  46. </view>
  47. </view>
  48. <view class="login-row" v-if="showLoginRegister">
  49. <button class="login-btn" @click="toLogin">登录</button>
  50. <button class="register-btn" @click="toRegistration">注册</button>
  51. </view>
  52. </scroll-view>
  53. </view>
  54. </template>
  55. <script>
  56. import { useUserStore } from "../../stores/modules/userInfo.js"
  57. import {
  58. getAnswerApi
  59. } from "../../api/customerServicePlatform/customerServicePlatform";
  60. export default {
  61. data() {
  62. return {
  63. headerTitle: '智能客服中台',
  64. iSMT: 0,
  65. questionTitle: '',
  66. answerContent: '正在思考...',
  67. showLoginRegister:false,
  68. token:''
  69. };
  70. },
  71. mounted() {
  72. this.iSMT = uni.getSystemInfoSync().statusBarHeight || 0;
  73. this.getAnswerContent()
  74. const memberStore = useUserStore()
  75. this.token = memberStore.userInfo?.token
  76. },
  77. onLoad(options) {
  78. if (options.question) {
  79. this.questionTitle = decodeURIComponent(options.question);
  80. if (this.questionTitle.includes("如何注册")) {
  81. this.showLoginRegister = true
  82. } else {
  83. this.showLoginRegister = false
  84. }
  85. }
  86. },
  87. methods: {
  88. async getAnswerContent() {
  89. let conversationId = '';
  90. try {
  91. const cache = uni.getStorageSync('conversationId');
  92. if (cache) conversationId = cache;
  93. } catch (e) {
  94. conversationId = '';
  95. }
  96. const res = await getAnswerApi({
  97. question: this.questionTitle,
  98. conversationId: conversationId,
  99. token:this.token
  100. })
  101. console.log(res)
  102. if (res.code == 200) {
  103. uni.setStorageSync('conversationId', res.data.conversationId);
  104. const answer = res.data.answer
  105. this.answerContent = '';
  106. for (let i = 0; i < answer.length; i++) {
  107. this.answerContent += answer[i];
  108. await this.sleepTime(150);
  109. }
  110. } else {
  111. this.answerContent = '获取回答失败,请重试';
  112. }
  113. },
  114. async sleepTime() {
  115. const ms = Math.floor(Math.random() * (300 - 30 + 1)) + 30;
  116. return new Promise(resolve => setTimeout(resolve, ms));
  117. },
  118. toRegistration() {
  119. uni.redirectTo({
  120. url: "/pages/start/Registration/Registration",
  121. });
  122. },
  123. toLogin() {
  124. uni.redirectTo({
  125. url: "/pages/start/login/login",
  126. });
  127. },
  128. onBack() {
  129. if (typeof uni !== 'undefined') uni.navigateBack();
  130. }
  131. }
  132. };
  133. </script>
  134. <style scoped>
  135. .main {
  136. display: flex;
  137. flex-direction: column;
  138. height: 100vh;
  139. background-color: #ffffff;
  140. }
  141. .header {
  142. display: flex;
  143. justify-content: space-between;
  144. align-items: center;
  145. padding: 20rpx 30rpx;
  146. background-color: #ffffff;
  147. }
  148. .title {
  149. color: #000000;
  150. text-align: center;
  151. font-size: 32rpx;
  152. font-weight: 400;
  153. }
  154. .back-icon,
  155. .notification-icon {
  156. width: 40rpx;
  157. display: flex;
  158. align-items: center;
  159. justify-content: center;
  160. }
  161. .header-icon-image {
  162. width: 40rpx;
  163. height: 40rpx;
  164. object-fit: contain;
  165. }
  166. .content-container {
  167. padding: 20rpx;
  168. width: 100%;
  169. box-sizing: border-box;
  170. overflow-x: hidden;
  171. }
  172. .content-header {
  173. display: flex;
  174. align-items: center;
  175. justify-content: center;
  176. gap: 24rpx;
  177. padding: 0 60rpx;
  178. width: 100%;
  179. box-sizing: border-box;
  180. height: 188rpx;
  181. }
  182. .content-header-area {
  183. display: flex;
  184. gap: 20rpx;
  185. }
  186. .logo {
  187. width: 120rpx;
  188. height: 120rpx;
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. flex: 0 0 112rpx;
  193. }
  194. .greeting {
  195. display: flex;
  196. flex-direction: column;
  197. justify-content: center;
  198. flex: 1 1 auto;
  199. }
  200. .greet-title {
  201. color: #000;
  202. font-size: 40rpx;
  203. font-style: normal;
  204. font-weight: 500;
  205. line-height: normal;
  206. margin: 0;
  207. overflow: hidden;
  208. text-overflow: ellipsis;
  209. white-space: nowrap;
  210. }
  211. .greet-sub {
  212. color: #838383;
  213. font-size: 28rpx;
  214. font-style: normal;
  215. font-weight: 400;
  216. line-height: normal;
  217. margin-top: 12rpx;
  218. overflow: hidden;
  219. text-overflow: ellipsis;
  220. white-space: nowrap;
  221. }
  222. .card {
  223. width: 90%;
  224. margin: 0 auto 20rpx;
  225. padding: 28rpx;
  226. box-sizing: border-box;
  227. border-radius: 16rpx;
  228. border: 4rpx solid #FF7C99;
  229. background: #fff;
  230. }
  231. /* 问题头部 */
  232. .question-header {
  233. width: 100%;
  234. margin-bottom: 48rpx;
  235. }
  236. .question-row {
  237. display: flex;
  238. align-items: center;
  239. }
  240. .question-avatar {
  241. width: 52rpx;
  242. height: 52rpx;
  243. border-radius: 999rpx;
  244. margin-right: 20rpx;
  245. flex-shrink: 0;
  246. }
  247. .question-title {
  248. color: #000000;
  249. font-size: 34rpx;
  250. }
  251. /* 卡片内部布局 */
  252. .card-body {
  253. display: flex;
  254. gap: 20rpx;
  255. align-items: flex-start;
  256. }
  257. .card-logo {
  258. width: 52rpx;
  259. height: 52rpx;
  260. flex: 0 0 52rpx;
  261. border-radius: 8rpx;
  262. }
  263. .card-text {
  264. flex: 1 1 auto;
  265. }
  266. .card-paragraph {
  267. display: block;
  268. color: #000000;
  269. font-size: 28rpx;
  270. margin-bottom: 14rpx;
  271. font-style: normal;
  272. font-weight: 500;
  273. }
  274. .login-row {
  275. display: flex;
  276. justify-content: center;
  277. align-items: center;
  278. width: 100%;
  279. margin-top: 100rpx;
  280. }
  281. .login-btn {
  282. width: 260rpx;
  283. height: 100rpx;
  284. border-radius: 50rpx;
  285. background: #F3F3F3;
  286. color: #000000;
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. font-size: 28rpx;
  291. margin-right: 20rpx;
  292. }
  293. .register-btn {
  294. width: 260rpx;
  295. height: 100rpx;
  296. border-radius: 60rpx;
  297. background: #000;
  298. color: #ffffff;
  299. display: flex;
  300. justify-content: center;
  301. align-items: center;
  302. font-size: 28rpx;
  303. }
  304. </style>