jiyi.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <view class="">
  3. <view class="box">
  4. <view class="nabBar" style="background-image: url('https://huli-app.wenlvti.net/app_static/minnanhun/image/jiyi_zxc.png'); background-size: cover">
  5. <u-navbar title="记忆" bgColor="rgba(255,255,255,0)" :placeholder="true" :leftIconSize="0" titleStyle="font-weight:bold;color:#7a5831"></u-navbar>
  6. </view>
  7. <view class="box_15">
  8. <u-swiper previousMargin="40" nextMargin="40" :autoplay="true" showTitle :height="150" :list="bannerlist" :circular="true" radius="5" bgColor="#ffffff"></u-swiper>
  9. </view>
  10. <view class="box_1">
  11. <view class="box_20">
  12. <view class="block_9">
  13. <button bindtap="onClick" class="button_1">
  14. <text lines="1" class="text_1">城市记忆</text>
  15. </button>
  16. <button bindtap="onClick" class="button_2" @click="cunShiBtn">
  17. <text lines="1" class="text_2">村史馆</text>
  18. </button>
  19. </view>
  20. <view class="block_10">
  21. <button bindtap="onClick" class="button_3">
  22. <text lines="1" class="text_3">区史馆</text>
  23. </button>
  24. <button bindtap="onClick" class="button_5">
  25. <text lines="1" class="text_4">校史馆</text>
  26. </button>
  27. <button bindtap="onClick" class="button_4">
  28. <text lines="1" class="text_5">医史馆</text>
  29. </button>
  30. </view>
  31. <view class="text-wrapper_4">
  32. <text lines="1" class="text_6">经典推荐</text>
  33. <!-- <text lines="1" class="text_7">查看更多》</text> -->
  34. </view>
  35. <!-- 瀑布流 -->
  36. <uv-waterfall v-model="list" :add-time="10" left-gap="10" right-gap="10" :column-gap="columnGap" @changeList="changeList">
  37. <!-- 第一列数据 -->
  38. <template v-slot:list1>
  39. <!-- 为了磨平部分平台的BUG,必须套一层view -->
  40. <view>
  41. <view @click="waterfallDetails(index)" v-for="(item, index) in list1" :key="item.id" class="waterfall-item">
  42. <view class="waterfall-item__image" :style="[imageStyle(item)]">
  43. <image :src="item.image" mode="widthFix" style="border-radius: 25rpx 60rpx 0rpx 30rpx" :style="{ width: item.width + 'px' }"></image>
  44. </view>
  45. <view class="like_box" @click="likeBtn(index)">
  46. <uni-icons v-if="list1[index].is_like > 0" type="heart-filled" color="red" size="20"></uni-icons>
  47. <uni-icons v-else type="heart-filled" color="#f8f8f8" size="20"></uni-icons>
  48. <text style="font-size: 28rpx">{{ list1[index].likes }}</text>
  49. </view>
  50. <view class="waterfall-item__ft">
  51. <view class="waterfall-item__ft__title">
  52. <text class="value">{{ item.title }}</text>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <!-- 第二列数据 -->
  59. <template v-slot:list2>
  60. <!-- 为了磨平部分平台的BUG,必须套一层view -->
  61. <view>
  62. <view @click="waterfallDetails2(index)" v-for="(item, index) in list2" :key="item.id" class="waterfall-item">
  63. <view class="waterfall-item__image" :style="[imageStyle(item)]">
  64. <image :src="item.image" mode="widthFix" style="border-radius: 25rpx 60rpx 0rpx 30rpx" :style="{ width: item.width + 'px' }"></image>
  65. </view>
  66. <view class="like_box" style="" @click="likeBtn2(index)">
  67. <uni-icons v-if="list2[index].is_like > 0" type="heart-filled" color="red" size="20"></uni-icons>
  68. <uni-icons v-else type="heart-filled" color="#f8f8f8" size="20"></uni-icons>
  69. <text style="font-size: 28rpx">{{ list2[index].likes }}</text>
  70. </view>
  71. <view class="waterfall-item__ft">
  72. <view class="waterfall-item__ft__title">
  73. <text class="value">{{ item.title }}</text>
  74. </view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. </uv-waterfall>
  80. </view>
  81. </view>
  82. </view>
  83. <mntabBar footerTab="1" :messageCount="0"></mntabBar>
  84. </view>
  85. </template>
  86. <script>
  87. import { mapState } from 'vuex';
  88. import { guid } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
  89. let that;
  90. export default {
  91. data() {
  92. return {
  93. main_body_id: '',
  94. bannerlist: [
  95. 'https://huli-app.wenlvti.net/app_static/minnanhun/image/sy_lbt2.png',
  96. 'https://huli-app.wenlvti.net/app_static/minnanhun/image/sy_lbt1.png',
  97. 'https://huli-app.wenlvti.net/app_static/minnanhun/image/sy_lbt3.jpg',
  98. 'https://huli-app.wenlvti.net/app_static/minnanhun/image/sy_lbt4.jpg',
  99. 'https://huli-app.wenlvti.net/app_static/minnanhun/image/sy_lbt5.png'
  100. ],
  101. list: [],
  102. list1: [], // 瀑布流第一列数据
  103. list2: [], // 瀑布流第二列数据
  104. columnGap: 10
  105. };
  106. },
  107. onLoad(option) {
  108. that = this;
  109. this.main_body_id = this.$db.get('main_body_id');
  110. this.getContentList();
  111. },
  112. computed: {
  113. imageStyle(item) {
  114. return (item) => {
  115. const v = uni.upx2px(750) - this.leftGap - this.rightGap - this.columnGap;
  116. const w = v / 2;
  117. const rate = w / item.w;
  118. const h = rate * item.h;
  119. return {
  120. width: w + 'px',
  121. height: h + 'px'
  122. };
  123. };
  124. }
  125. },
  126. methods: {
  127. imageClick(i) {
  128. console.log(i);
  129. },
  130. cunShiBtn() {
  131. uni.navigateTo({
  132. url: '/index_fenbao/cs_liebiao/cs_liebiao'
  133. });
  134. },
  135. // 瀑布流数据
  136. getContentList() {
  137. this.$api.getContentList({ main_body_id: 2, model_id: 8 }, function (res) {
  138. res.data.forEach((item) => {
  139. item.is_like = 0;
  140. });
  141. that.list = res.data;
  142. });
  143. },
  144. changeList(e) {
  145. // console.log(e, '瀑布流');
  146. this[e.name].push(e.value);
  147. },
  148. // 第一列详情
  149. waterfallDetails(i) {
  150. uni.navigateTo({
  151. url: '/jiyi_fenbao/recommendedDetails?id=' + this.list1[i].id
  152. });
  153. // console.log(this.list1[i].id, 888888888);
  154. },
  155. // 第二列详情
  156. waterfallDetails2(i) {
  157. // console.log(this.list2[i].id, 999999);
  158. uni.navigateTo({
  159. url: '/jiyi_fenbao/recommendedDetails?id=' + this.list2[i].id
  160. });
  161. },
  162. // 点赞
  163. likeBtn(i) {
  164. if (this.list1[i].is_like == 0) {
  165. this.$api.like(
  166. {
  167. main_body_id: this.main_body_id,
  168. content_id: this.list1[i].id
  169. },
  170. function (res) {
  171. that.list1[i].is_like = 1;
  172. that.list1[i].likes++;
  173. that.$common.successToShow('成功点赞');
  174. }
  175. );
  176. } else {
  177. that.$api.unLike(
  178. {
  179. main_body_id: that.main_body_id,
  180. content_ids: that.list1[i].id
  181. },
  182. function (res) {
  183. that.list1[i].is_like = 0;
  184. that.list1[i].likes--;
  185. that.$common.successToShow('取消点赞');
  186. }
  187. );
  188. }
  189. },
  190. // 点赞
  191. likeBtn2(i) {
  192. if (this.list2[i].is_like == 0) {
  193. this.$api.like(
  194. {
  195. main_body_id: this.main_body_id,
  196. content_id: this.list2[i].id
  197. },
  198. function (res) {
  199. that.list2[i].is_like = 1;
  200. that.list2[i].likes++;
  201. that.$common.successToShow('成功点赞');
  202. }
  203. );
  204. } else {
  205. that.$api.unLike(
  206. {
  207. main_body_id: that.main_body_id,
  208. content_ids: that.list2[i].id
  209. },
  210. function (res) {
  211. that.list2[i].is_like = 0;
  212. that.list2[i].likes--;
  213. that.$common.successToShow('取消点赞');
  214. }
  215. );
  216. }
  217. }
  218. }
  219. };
  220. </script>
  221. <style>
  222. .box {
  223. height: auto;
  224. width: 100%;
  225. /* background-image: url('https://huli-app.wenlvti.net/app_static/wuyuan/static/shouhu/wyj-feiyi3-001.png'); */
  226. /* background-size: 100% 100%; */
  227. background-attachment: fixed;
  228. border-radius: 16px 16px 0 0;
  229. position: relative;
  230. display: flex;
  231. flex-direction: column;
  232. }
  233. .waterfall-item {
  234. margin-bottom: 20rpx;
  235. }
  236. .waterfall-item__ft {
  237. position: relative;
  238. }
  239. .waterfall-item__ft__title {
  240. width: 100%;
  241. height: 65rpx;
  242. position: absolute;
  243. bottom: 0;
  244. left: 0;
  245. line-height: 65rpx;
  246. background-color: #ca5642;
  247. font-size: 30rpx;
  248. text-align: center;
  249. color: #ffffff;
  250. border-radius: 0 0 10rpx 10rpx;
  251. }
  252. .like_box {
  253. position: relative;
  254. top: -80rpx;
  255. left: 240rpx;
  256. display: flex;
  257. align-items: center;
  258. color: #ffffff;
  259. justify-content: space-evenly;
  260. height: 40rpx;
  261. width: 100rpx;
  262. border-radius: 30rpx;
  263. }
  264. .active {
  265. color: red;
  266. }
  267. .nabBar {
  268. height: 340rpx;
  269. }
  270. .u-swiper.data-v-6b019429 {
  271. background-color: rgba(0, 0, 0, 0) !important;
  272. }
  273. /deep/.column-value.data-v-ddfcbb1c {
  274. border-radius: 25rpx 60rpx 0rpx 30rpx !important;
  275. }
  276. .box_1 {
  277. position: relative;
  278. width: 750rpx;
  279. flex-direction: row;
  280. display: flex;
  281. }
  282. .title_pubu {
  283. width: 100%;
  284. height: 65rpx;
  285. line-height: 65rpx;
  286. background-color: #ca5642;
  287. font-size: 30rpx;
  288. display: flex;
  289. justify-content: space-around;
  290. color: #ffffff;
  291. position: absolute;
  292. bottom: 0;
  293. left: 0;
  294. }
  295. .box_20 {
  296. position: relative;
  297. width: 750rpx;
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .block_9 {
  302. width: 684rpx;
  303. height: 67rpx;
  304. flex-direction: row;
  305. display: flex;
  306. justify-content: space-between;
  307. margin: auto;
  308. }
  309. .button_1 {
  310. background-color: rgba(22, 69, 89, 1);
  311. border-radius: 33rpx;
  312. height: 67rpx;
  313. display: flex;
  314. flex-direction: column;
  315. width: 330rpx;
  316. position: relative;
  317. }
  318. .text_1 {
  319. color: rgba(255, 255, 255, 1);
  320. font-size: 28rpx;
  321. font-weight: 700;
  322. text-align: center;
  323. line-height: 60rpx;
  324. }
  325. .image_1 {
  326. position: absolute;
  327. left: 0rpx;
  328. top: 0rpx;
  329. width: 330rpx;
  330. height: 67rpx;
  331. }
  332. .button_2 {
  333. background-color: rgba(202, 86, 66, 1);
  334. border-radius: 33rpx;
  335. height: 67rpx;
  336. display: flex;
  337. flex-direction: column;
  338. width: 330rpx;
  339. position: relative;
  340. }
  341. .text_2 {
  342. color: rgba(255, 255, 255, 1);
  343. font-size: 28rpx;
  344. font-weight: 700;
  345. text-align: center;
  346. line-height: 60rpx;
  347. }
  348. .block_10 {
  349. width: 691rpx;
  350. height: 67rpx;
  351. flex-direction: row;
  352. display: flex;
  353. margin: 31rpx 0 0 32rpx;
  354. }
  355. .button_3 {
  356. background: #c3a07b;
  357. border-radius: 33rpx;
  358. height: 67rpx;
  359. display: flex;
  360. flex-direction: column;
  361. width: 212rpx;
  362. position: relative;
  363. }
  364. .button_5 {
  365. background: #5c987b;
  366. border-radius: 33rpx;
  367. height: 67rpx;
  368. display: flex;
  369. flex-direction: column;
  370. width: 212rpx;
  371. position: relative;
  372. }
  373. .text_3 {
  374. color: rgba(255, 255, 255, 1);
  375. font-size: 28rpx;
  376. font-weight: 700;
  377. text-align: center;
  378. line-height: 60rpx;
  379. }
  380. .text-wrapper_1 {
  381. background-color: rgba(197, 186, 165, 1);
  382. border-radius: 33rpx;
  383. height: 67rpx;
  384. margin-left: 24rpx;
  385. display: flex;
  386. flex-direction: column;
  387. width: 212rpx;
  388. }
  389. .text_4 {
  390. color: rgba(255, 255, 255, 1);
  391. font-size: 28rpx;
  392. font-weight: 700;
  393. text-align: center;
  394. line-height: 60rpx;
  395. }
  396. .button_4 {
  397. background-color: rgba(91, 84, 84, 1);
  398. border-radius: 33rpx;
  399. height: 67rpx;
  400. display: flex;
  401. flex-direction: column;
  402. width: 212rpx;
  403. position: relative;
  404. }
  405. .text_5 {
  406. color: rgba(255, 255, 255, 1);
  407. font-size: 28rpx;
  408. font-weight: 700;
  409. text-align: center;
  410. line-height: 60rpx;
  411. }
  412. .text-wrapper_4 {
  413. width: 668rpx;
  414. height: 34rpx;
  415. flex-direction: row;
  416. display: flex;
  417. justify-content: space-between;
  418. margin: 33rpx 0 25rpx 49rpx;
  419. }
  420. .text_6 {
  421. width: 144rpx;
  422. height: 34rpx;
  423. overflow-wrap: break-word;
  424. color: rgba(49, 37, 32, 1);
  425. font-size: 36rpx;
  426. font-family: Adobe Heiti Std R;
  427. font-weight: normal;
  428. text-align: left;
  429. white-space: nowrap;
  430. line-height: 36rpx;
  431. }
  432. .text_7 {
  433. width: 107rpx;
  434. height: 23rpx;
  435. overflow-wrap: break-word;
  436. color: rgba(102, 102, 102, 1);
  437. font-size: 24rpx;
  438. font-family: Adobe Heiti Std R;
  439. font-weight: normal;
  440. text-align: left;
  441. white-space: nowrap;
  442. line-height: 24rpx;
  443. margin-top: 5rpx;
  444. }
  445. .box_15 {
  446. margin-top: -160rpx;
  447. margin-left: 32rpx;
  448. margin-right: 32rpx;
  449. border-radius: 20rpx;
  450. padding: 20rpx;
  451. height: 360rpx;
  452. background-color: #ffe4b0;
  453. display: flex;
  454. margin-bottom: 35rpx;
  455. box-sizing: border-box;
  456. flex-direction: column;
  457. }
  458. </style>