index.vue 3.5 KB

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