real.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <div class="real-pages">
  3. <div>
  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: 1200px;
  102. margin: 0 auto;
  103. display: flex;
  104. gap: 0 20px;
  105. padding-bottom: 50px;
  106. .real-info {
  107. width: 715px;
  108. background: #ffffff;
  109. border-radius: 10px;
  110. padding: 20px;
  111. .title {
  112. font-size: 20px;
  113. color: #101828;
  114. }
  115. .time {
  116. font-size: 14px;
  117. color: #364153;
  118. margin: 10px 0 18px 0;
  119. }
  120. .real-html {
  121. width: 679px;
  122. :deep(img) {
  123. max-width: 100%;
  124. height: auto;
  125. }
  126. }
  127. .img {
  128. width: 679px;
  129. height: 351px;
  130. border-radius: 10px;
  131. }
  132. .head {
  133. font-weight: 600;
  134. font-size: 14px;
  135. color: #101828;
  136. margin: 10px 0 18px 0;
  137. }
  138. .info {
  139. font-size: 14px;
  140. color: #364153;
  141. margin-bottom: 15px;
  142. }
  143. }
  144. .real-shop {
  145. flex: 1;
  146. .head1 {
  147. font-weight: 600;
  148. font-size: 20px;
  149. color: #101828;
  150. }
  151. .head2 {
  152. font-size: 14px;
  153. color: #364153;
  154. margin-left: 10px;
  155. }
  156. //数据
  157. .data-bos {
  158. display: flex;
  159. gap: 17px;
  160. flex-wrap: wrap;
  161. margin-top: 10px;
  162. width: 100%;
  163. .data-list {
  164. width: 224px;
  165. background: #ffffff;
  166. border-radius: 10px;
  167. padding: 20px 20px 22px 20px;
  168. cursor: pointer;
  169. .data-img {
  170. width: 184px;
  171. height: 184px;
  172. border-radius: 10px;
  173. }
  174. .data-title {
  175. margin-top: 4px;
  176. font-size: 14px;
  177. color: #101828;
  178. height: 40px;
  179. }
  180. .money {
  181. margin-top: 4px;
  182. .money1 {
  183. font-size: 16px;
  184. color: #e7000b;
  185. }
  186. .money2 {
  187. font-size: 12px;
  188. color: #99a1af;
  189. text-decoration: line-through;
  190. padding-left: 6px;
  191. }
  192. }
  193. .data-cat {
  194. width: 86px;
  195. height: 26px;
  196. background: #e7000b;
  197. border-radius: 2px;
  198. font-size: 14px;
  199. color: #ffffff;
  200. line-height: 26px;
  201. text-align: center;
  202. margin-top: 16px;
  203. }
  204. }
  205. }
  206. }
  207. .related-bos {
  208. flex: 1;
  209. .related-box {
  210. width: 100%;
  211. background-color: #ffffff;
  212. border-radius: 10px;
  213. padding: 20px;
  214. .related-title {
  215. font-size: 16px;
  216. color: #666666;
  217. .related-huan {
  218. font-size: 14px;
  219. cursor: pointer;
  220. }
  221. }
  222. // 采购指南
  223. .procure-bos {
  224. width: 100%;
  225. display: flex;
  226. flex-direction: column;
  227. margin-top: 12px;
  228. gap: 12px 0px;
  229. .procure-list {
  230. width: 100%;
  231. height: 268px;
  232. background: #ffffff;
  233. cursor: pointer;
  234. border-radius: 10px;
  235. overflow: hidden;
  236. border: 1px solid #d0d5dd;
  237. img {
  238. width: 100%;
  239. height: 200px;
  240. border-bottom: 1px solid #d0d5dd;
  241. }
  242. .procure1 {
  243. padding: 12px 0 4px 20px;
  244. font-weight: 600;
  245. font-size: 14px;
  246. color: #101828;
  247. }
  248. .procure2 {
  249. padding-left: 20px;
  250. font-size: 12px;
  251. color: #364153;
  252. }
  253. }
  254. }
  255. }
  256. }
  257. }
  258. </style>