index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="chatAIPage">
  3. <div class="header">
  4. <div class="icon"><van-icon name="flower-o" size="25" /></div>
  5. <div class="titleTip">欢迎进入随身邦chatBl,智能助理为您提供以下服务</div>
  6. </div>
  7. <div class="content">
  8. <div
  9. class="tabItem"
  10. v-for="item in tabData"
  11. :style="{ background: item.backColor }"
  12. @click="openAiPage(item)">
  13. <div class="tabName">{{ item.tabName }}</div>
  14. <div class="message">{{ item.message }}</div>
  15. <div class="icon">
  16. <van-icon :name="item.icon" size="45" />
  17. </div>
  18. </div>
  19. </div>
  20. <div class="footer">
  21. <div class="tip">对话发起</div>
  22. <div class="chatBox">
  23. <van-field
  24. v-model="chatBoxMessage"
  25. rows="3"
  26. type="textarea"
  27. :border="true"
  28. placeholder="【随身邦chatBl】将与您对话,请输入…." />
  29. <van-icon name="guide-o" class="sendIcon" size="40" />
  30. </div>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import { getAiToken } from '@/api/chatAI.js';
  36. export default {
  37. name: 'chatAIPage',
  38. data() {
  39. return {
  40. tabData: [
  41. {
  42. tabName: '指标查询',
  43. message: '帮助您用自然语言查询指标、支持多条件组合查询',
  44. icon: 'bar-chart-o',
  45. backColor: '#665bb9',
  46. datasetId: '250514091022957',
  47. },
  48. {
  49. tabName: '门店圈选',
  50. message: '帮助您使用自然语言进行筛选,支持多条件组合筛选',
  51. icon: 'list-switching',
  52. backColor: '#68a3e7',
  53. datasetId: '250514091601918',
  54. },
  55. ],
  56. chatBoxMessage: '',
  57. AIToken: '',
  58. };
  59. },
  60. created() {
  61. this.getAiTokenFun();
  62. },
  63. methods: {
  64. getAiTokenFun() {
  65. this.toastLoading(0, '上传中...', true);
  66. getAiToken()
  67. .then((res) => {
  68. this.toastLoading().clear();
  69. if (res.code == 200) {
  70. this.AIToken = res.msg;
  71. } else {
  72. this.$toast(res.msg);
  73. }
  74. })
  75. .catch((error) => {
  76. this.toastLoading().clear();
  77. this.$toast(error.msg);
  78. });
  79. },
  80. openAiPage(item) {
  81. let href =
  82. 'http://bi.dgtis.com/cboard/h5/index.html?token=' +
  83. this.AIToken +
  84. '#/chatbi?datasetId=' +
  85. item.datasetId;
  86. window.location.href = href;
  87. },
  88. },
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. .chatAIPage {
  93. width: 100%;
  94. height: 100%;
  95. overflow: hidden;
  96. padding: 15px;
  97. display: flex;
  98. flex-direction: column;
  99. .header {
  100. width: 100%;
  101. display: flex;
  102. align-items: center;
  103. padding-bottom: 10px;
  104. .icon {
  105. color: #666;
  106. }
  107. .titleTip {
  108. font-size: 14px;
  109. color: #666;
  110. }
  111. }
  112. .content {
  113. flex: 1;
  114. overflow-y: auto;
  115. padding: 10px 0;
  116. .tabItem {
  117. width: 48%;
  118. height: 180px;
  119. float: left;
  120. margin-right: 4%;
  121. margin-bottom: 20px;
  122. display: flex;
  123. flex-direction: column;
  124. justify-content: space-between;
  125. padding: 10px;
  126. color: #fff;
  127. border-radius: 15px;
  128. &:nth-child(even) {
  129. margin-right: 0;
  130. }
  131. .tabName {
  132. font-size: 16px;
  133. margin-bottom: 10px;
  134. }
  135. .message {
  136. flex: 1;
  137. font-size: 14px;
  138. margin-bottom: 15px;
  139. overflow: hidden;
  140. text-overflow: ellipsis;
  141. display: -webkit-box;
  142. -webkit-box-orient: vertical;
  143. -webkit-line-clamp: 3;
  144. }
  145. .icon {
  146. text-align: center;
  147. margin-bottom: 15px;
  148. }
  149. }
  150. }
  151. .footer {
  152. .tip {
  153. font-size: 16px;
  154. padding: 10px;
  155. }
  156. .chatBox {
  157. position: relative;
  158. .van-cell {
  159. padding-bottom: 30px;
  160. }
  161. .sendIcon {
  162. position: absolute;
  163. right: 3px;
  164. bottom: 0px;
  165. color: #999;
  166. }
  167. }
  168. }
  169. }
  170. </style>