index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <view class="content padding30">
  3. <view class="bg_color_fff padding20 border_radius_20" @click="to_service_search">
  4. <u-search placeholder="输入你想知道的事" v-model="keyword"
  5. @search="toAi({msgContent:keyword})"
  6. @custom="toAi({msgContent:keyword})"
  7. :showAction="false" borderColor="#ffffff"></u-search>
  8. </view>
  9. <swiper class="swiper_list bg_color_fff border_radius_20 mt20" circular :indicator-dots="true" :autoplay="true" indicator-active-color="#ffffff">
  10. <swiper-item v-for="(item, index) in swiperList" :key="index" class="swiper_item border_radius_20"
  11. @click="toWebView(item)"
  12. >
  13. <image :src="HTTP_ADMIN_URL+item.dictValue" mode="" class="swiper_img border_radius_20"></image>
  14. </swiper-item>
  15. </swiper>
  16. <!-- 财智工具箱 -->
  17. <view class="mt20 bg_color_fff border_radius_20">
  18. <view class="bold font_size30 padding20">财智工具箱</view>
  19. <view class="grid-container padding20">
  20. <view class="border_radius_20"
  21. @click="toAi({agentId:item.agentId})"
  22. v-for="(item, index) in agentList" :key="index">
  23. <image :src="HTTP_ADMIN_URL+item.imageUrl" class="item-img"></image>
  24. <view class="item-content">
  25. <view class="font_size30 bold title text-ellipsis">{{item.agentName}}</view>
  26. <view class="font_size20 gray mt10 desc text-ellipsis">{{item.agentDesc}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 常见问题 -->
  32. <view class="mt20 bg_color_fff border_radius_20">
  33. <view class="bold font_size30 padding20">常见问题</view>
  34. <view class="padding20 flex-center-between border-bottom"
  35. @click="toAi({agentId:item.cssClass*1,msgContent:item.dictValue})"
  36. v-for="(item, index) in adSearchList" :key="index">
  37. <text class="flex_1 mr20">#{{item.dictValue}}</text>
  38. <image src="/static/img/arrow-right.png" mode="widthFix" class="menu_img"></image>
  39. </view>
  40. </view>
  41. </view>
  42. </template>
  43. <script setup>
  44. import { ref } from "vue";
  45. import { adList, getAgentList, getAdSearch } from "@/api/home.js";
  46. import { HTTP_ADMIN_URL } from "@/config/app.js";
  47. import { onLoad, onShareAppMessage} from '@dcloudio/uni-app'
  48. onShareAppMessage((res) => {
  49. return appStore.onShareAppMessageObj
  50. })
  51. import { useAppStore } from "@/stores/app";
  52. const appStore = useAppStore();
  53. const keyword = ref('');
  54. const swiperList = ref([]);
  55. const agentList = ref([]);
  56. const adSearchList = ref([]);
  57. onLoad(()=>{
  58. console.log('index onLoad');
  59. adListFn();
  60. agentListFn();
  61. getAdSearchFn();
  62. });
  63. function toWebView({targetPath,dictCode}){
  64. if(targetPath){
  65. uni.navigateTo({
  66. url: '/pages/webView/webView?url='+encodeURIComponent(url)
  67. });
  68. }else{
  69. uni.navigateTo({
  70. url: '/pages/policy/ad_detail?dictCode='+dictCode
  71. });
  72. }
  73. }
  74. function toAi({agentId='', msgContent=''}){
  75. if(agentId) appStore.UPDATE_agentId(agentId);
  76. if(msgContent)appStore.UPDATE_msgContent(msgContent);
  77. uni.switchTab({
  78. url: '/pages/ai/ai'
  79. });
  80. }
  81. //获取轮播图
  82. function adListFn(){
  83. adList().then(res=>{
  84. if(res.code == 200){
  85. swiperList.value = res.data || [];
  86. }
  87. })
  88. }
  89. //获取智能体列表
  90. function agentListFn(){
  91. getAgentList().then(res=>{
  92. if(res.code == 200){
  93. agentList.value = res.rows || [];
  94. }
  95. })
  96. }
  97. // 搜索常用问题
  98. function getAdSearchFn(){
  99. getAdSearch().then(res=>{
  100. if(res.code == 200){
  101. adSearchList.value = res.data || [];
  102. }
  103. })
  104. }
  105. </script>
  106. <style scoped lang="scss">
  107. .content{
  108. /* 轮播 */
  109. .swiper_list{
  110. height: 350rpx;
  111. overflow: visible;
  112. .swiper_item{
  113. height: fit-content !important;
  114. .swiper_img{
  115. width: 100%;
  116. height: 350rpx;
  117. }
  118. }
  119. }
  120. .grid-container{
  121. .item-img{
  122. width: 100%;
  123. height: 200rpx;
  124. object-fit: cover;
  125. object-position: center;
  126. border-radius: 20rpx 20rpx 0 0;
  127. }
  128. .title, .desc {
  129. display: -webkit-box; /* 将对象作为弹性伸缩盒子模型显示 ,适用于webkit内核浏览器 */
  130. -webkit-box-orient: vertical; /* 设置或检索伸缩盒对象的子元素的排列方式 为垂直排列 */
  131. -webkit-line-clamp: 1; /* 显示的行数,这里设置为2行 */
  132. overflow: hidden; /* 隐藏超出的内容 */
  133. }
  134. }
  135. .menu_img{
  136. width: 50rpx;
  137. height: 50rpx;
  138. }
  139. }
  140. </style>