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.

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