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.

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