real.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="real-pages">
  3. <div class="flex-1">
  4. <div class="real-info">
  5. <div class="title">{{ dataInfo.announcementTitle }}</div>
  6. <div class="time">{{ dataInfo.createTime }}</div>
  7. <div class="real-html" v-html="dataInfo.announcementContent"></div>
  8. </div>
  9. </div>
  10. <el-affix :offset="0" target=".real-pages">
  11. <div class="related-bos">
  12. <div class="related-box">
  13. <div class="flex-row-between related-title">
  14. <div>产品推荐</div>
  15. <div class="flex-row-start related-huan" @click="getList">
  16. <el-icon><Sort /></el-icon>
  17. <div style="margin-left: 4px">换一换</div>
  18. </div>
  19. </div>
  20. <div class="procure-bos">
  21. <div v-for="(item, index) in dataList" :key="index" class="procure-list" @click="onPath('/plan_info?id=' + item.id)">
  22. <img :src="item.coverImage" alt="" />
  23. <div class="procure1">{{ item.title }}</div>
  24. <div class="procure2">{{ item.releaseTime }}</div>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. </el-affix>
  30. <!--
  31. <div class="real-shop">
  32. <div class="shop-head flex-row-start">
  33. <div class="head1">为您推荐</div>
  34. <div class="head2">热门流行商品推荐</div>
  35. </div>
  36. <div class="data-bos">
  37. <div v-for="(item, index) in 9" :key="index" class="data-list">
  38. <img class="data-img" src="@/assets/images/login-background.jpg" alt="" />
  39. <div class="data-title">格力KFR-72LW/定频冷暖空调柜机3P</div>
  40. <div class="money">
  41. <span class="money1">¥1,299</span>
  42. <span class="money2">¥1,899</span>
  43. </div>
  44. </div>
  45. </div>
  46. </div> -->
  47. </div>
  48. </template>
  49. <script setup lang="ts">
  50. import { onPath } from '@/utils/siteConfig';
  51. import { getYouYzXunInfo } from '@/api/plan/index';
  52. import { getProcurementProgramList } from '@/api/plan/index';
  53. const id = ref<any>(null);
  54. const dataInfo = ref<any>({});
  55. const route = useRoute();
  56. const dataList = ref<any>([]);
  57. onMounted(() => {
  58. id.value = route.query.id;
  59. getInfo();
  60. getList();
  61. });
  62. const getInfo = () => {
  63. getYouYzXunInfo(id.value).then((res) => {
  64. if (res.code == 200) {
  65. dataInfo.value = res.data;
  66. }
  67. });
  68. };
  69. // 封装获取列表的逻辑
  70. const getList = () => {
  71. getProcurementProgramList({
  72. pageSize: 10,
  73. pageNum: 1
  74. }).then((res) => {
  75. if (res.code == 200) {
  76. if (res.rows && res.rows.length > 0) {
  77. if (res.rows.length <= 2) {
  78. dataList.value = res.rows;
  79. } else {
  80. dataList.value = getRandomElements(res.rows, 3);
  81. }
  82. }
  83. }
  84. });
  85. };
  86. function getRandomElements(arr: any, count: any) {
  87. if (count > arr.length) {
  88. throw new Error('要取的数量不能超过数组长度');
  89. }
  90. const copy = [...arr];
  91. const result = [];
  92. for (let i = 0; i < count; i++) {
  93. const randomIndex = Math.floor(Math.random() * copy.length);
  94. result.push(copy.splice(randomIndex, 1)[0]);
  95. }
  96. return result;
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .real-pages {
  101. width: 100%;
  102. min-width: 1200px;
  103. max-width: 1500px;
  104. margin: 0 auto;
  105. display: flex;
  106. gap: 0 20px;
  107. padding-bottom: 50px;
  108. .real-info {
  109. width: 100%;
  110. background: #ffffff;
  111. border-radius: 10px;
  112. padding: 20px;
  113. .title {
  114. font-size: 20px;
  115. color: #101828;
  116. }
  117. .time {
  118. font-size: 14px;
  119. color: #364153;
  120. margin: 10px 0 18px 0;
  121. }
  122. .real-html {
  123. width: 679px;
  124. :deep(img) {
  125. max-width: 100%;
  126. height: auto;
  127. }
  128. }
  129. .img {
  130. width: 679px;
  131. height: 351px;
  132. border-radius: 10px;
  133. }
  134. .head {
  135. font-weight: 600;
  136. font-size: 14px;
  137. color: #101828;
  138. margin: 10px 0 18px 0;
  139. }
  140. .info {
  141. font-size: 14px;
  142. color: #364153;
  143. margin-bottom: 15px;
  144. }
  145. }
  146. .real-shop {
  147. flex: 1;
  148. .head1 {
  149. font-weight: 600;
  150. font-size: 20px;
  151. color: #101828;
  152. }
  153. .head2 {
  154. font-size: 14px;
  155. color: #364153;
  156. margin-left: 10px;
  157. }
  158. //数据
  159. .data-bos {
  160. display: flex;
  161. gap: 17px;
  162. flex-wrap: wrap;
  163. margin-top: 10px;
  164. width: 100%;
  165. .data-list {
  166. width: 224px;
  167. background: #ffffff;
  168. border-radius: 10px;
  169. padding: 20px 20px 22px 20px;
  170. cursor: pointer;
  171. .data-img {
  172. width: 184px;
  173. height: 184px;
  174. border-radius: 10px;
  175. }
  176. .data-title {
  177. margin-top: 4px;
  178. font-size: 14px;
  179. color: #101828;
  180. height: 40px;
  181. }
  182. .money {
  183. margin-top: 4px;
  184. .money1 {
  185. font-size: 16px;
  186. color: #e7000b;
  187. }
  188. .money2 {
  189. font-size: 12px;
  190. color: #99a1af;
  191. text-decoration: line-through;
  192. padding-left: 6px;
  193. }
  194. }
  195. .data-cat {
  196. width: 86px;
  197. height: 26px;
  198. background: #e7000b;
  199. border-radius: 2px;
  200. font-size: 14px;
  201. color: #ffffff;
  202. line-height: 26px;
  203. text-align: center;
  204. margin-top: 16px;
  205. }
  206. }
  207. }
  208. }
  209. .related-bos {
  210. flex: 1;
  211. .related-box {
  212. width: 100%;
  213. background-color: #ffffff;
  214. border-radius: 10px;
  215. padding: 20px;
  216. .related-title {
  217. font-size: 16px;
  218. color: #666666;
  219. .related-huan {
  220. font-size: 14px;
  221. cursor: pointer;
  222. }
  223. }
  224. // 采购指南
  225. .procure-bos {
  226. width: 100%;
  227. display: flex;
  228. flex-direction: column;
  229. margin-top: 12px;
  230. gap: 12px 0px;
  231. .procure-list {
  232. width: 100%;
  233. height: 268px;
  234. background: #ffffff;
  235. cursor: pointer;
  236. border-radius: 10px;
  237. overflow: hidden;
  238. border: 1px solid #d0d5dd;
  239. img {
  240. width: 100%;
  241. height: 200px;
  242. border-bottom: 1px solid #d0d5dd;
  243. }
  244. .procure1 {
  245. padding: 12px 0 4px 20px;
  246. font-weight: 600;
  247. font-size: 14px;
  248. color: #101828;
  249. }
  250. .procure2 {
  251. padding-left: 20px;
  252. font-size: 12px;
  253. color: #364153;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. }
  260. </style>