FirstList.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <!-- 商城宣传页,列表页 -->
  2. <template>
  3. <view class="page-body" style="background: #f6f6f6;">
  4. <!-- <video src="https://jvod.300hu.com/vod/product/4c17d312-2039-4668-8460-fd71540fb465/f0db5965187f4178bb7ed745bbff143c.mp4?info=50793-1054733-h264-aac" controls="true"></video>
  5. <video src="http://192.168.3.158:80/static/firstIndex/f0db5965187f4178bb7ed745bbff143c.mp4"></video>
  6. <video control s src="https://zxpt.newfeifan.cn/admin-api/infra/file/23/get/03488f68d9c9269a3eac373ab5309d574ffdd67e6882ec8a2f86f9b4766c91e7.mp4"></video>-->
  7. <s-empty v-if="state.pagination.total === 0" icon="/static/data-empty.png" :text="t('common.no_data')" />
  8. <view v-if="state.pagination.total > 0 && type == 'activityCard'">
  9. <view class="article ss-r-10" v-for="item in state.pagination.list" @click="sheep.$router.go('/pages/public/richtext', {title:item.title});">
  10. <view class="title" >
  11. {{item.title}}
  12. </view>
  13. <view class="content">
  14. <view class="image " v-if="item.picUrl.trim()">
  15. <image :src="item.picUrl" mode="aspectFit" class="image-content"></image>
  16. </view>
  17. <view class="desc" >
  18. {{item.introduction}}
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view v-if="state.pagination.total > 0 && type == 'articleCard'">
  24. <view class="activity ss-r-10" v-for="item in state.pagination.list" :style="{ backgroundImage: `url(${item.picUrl})` }" @click="sheep.$router.go('/pages/public/richtext', {title:item.title});">
  25. <view class="activity-bottom">
  26. <text>{{item.title}}</text>
  27. <view class=""><image src="@/static/firstIndex/youjiantou.png" mode="aspectFit" /></view>
  28. </view>
  29. </view>
  30. </view>
  31. <uni-load-more v-if="state.pagination.total > 0" :status="state.loadStatus" :content-text="{ contentdown: '上拉加载更多'}" @tap="loadmore" />
  32. <s-tabbar path="/pages/index/FirstIndex" :tabbar="tabbar" />
  33. </view>
  34. </template>
  35. <script setup>
  36. import {
  37. computed,
  38. ref,
  39. reactive
  40. } from 'vue';
  41. import {
  42. onLoad,
  43. onShow,
  44. onReachBottom,
  45. onPullDownRefresh
  46. } from '@dcloudio/uni-app';
  47. import sheep from '@/sheep';
  48. import $share from '@/sheep/platform/share';
  49. import _ from 'lodash';
  50. import {
  51. isAndroid,
  52. getAndroidJiGuangId
  53. } from '@/sheep/hooks/useApp'
  54. import {
  55. showWalletModal,
  56. colseWalletModal
  57. } from '@/sheep/hooks/useModal';
  58. import { t } from '@/locale'
  59. import ArticleApi from '@/sheep/api/promotion/article';
  60. // 隐藏原生tabBar
  61. uni.hideTabBar();
  62. const appInfo = computed(() => sheep.$store('app').info);
  63. const {
  64. safeArea
  65. } = sheep.$platform.device;
  66. const pageHeight = computed(() => safeArea.height - 45);
  67. const props = defineProps({
  68. // 是否显示tabbar
  69. tabbar: {
  70. type: Boolean,
  71. default: true
  72. },
  73. // 是否显示tabbar
  74. categoryId: {
  75. type: Number,
  76. default: 0
  77. },
  78. type:{
  79. type:String,
  80. default:'articleCard'
  81. }
  82. });
  83. const tabbar = ref({
  84. "theme": "red",
  85. "style": {
  86. "bgType": "color",
  87. "bgColor": "#323b4e",
  88. "color": "#e6e6e5",
  89. "activeColor": "#1fa380"
  90. },
  91. "items": [{
  92. "text": t('common.home'),
  93. "url": "/pages/index/FirstIndex",
  94. "iconUrl": sheep.$url.static('/static/firstIndex/index.svg'),
  95. "activeIconUrl": sheep.$url.static('/static/firstIndex/index-active.svg')
  96. },
  97. {
  98. "text": t('common.activities'),
  99. "url": "/pages/index/FirstActivity",
  100. "iconUrl": sheep.$url.static('/static/firstIndex/activity.svg'),
  101. "activeIconUrl": sheep.$url.static('/static/firstIndex/activity-active.svg')
  102. },
  103. {
  104. "text": t('common.videos'),
  105. "url": "/pages/index/FirstVideo",
  106. "iconUrl": sheep.$url.static('/static/firstIndex/video.svg'),
  107. "activeIconUrl": sheep.$url.static('/static/firstIndex/video-active.svg')
  108. },
  109. {
  110. "text": t('common.mall'),
  111. "url": "/pages/index/index",
  112. "iconUrl": sheep.$url.static('/static/firstIndex/shop.svg'),
  113. "activeIconUrl": sheep.$url.static('/static/firstIndex/shop-active.svg')
  114. }
  115. ]
  116. });
  117. // 数据
  118. const state = reactive({
  119. categoryId: 0,
  120. pagination: {
  121. list: [],
  122. current_page: 1,
  123. total: 1,
  124. last_page: 1,
  125. },
  126. loadStatus: ''
  127. });
  128. async function getArticleList(page = 1, list_rows = 5) {
  129. state.loadStatus = 'loading';
  130. let { code, data } = await ArticleApi.getArticleByCategory({pageNo: page,pageSize: list_rows,categoryId: state.categoryId});
  131. if (code !== 0) {
  132. return;
  133. }
  134. let articleList = _.concat(state.pagination.list, data.list);
  135. state.pagination.list = articleList
  136. state.pagination.total = data.total;
  137. state.pagination.last_page = Math.ceil(data.total / 5)
  138. if (state.pagination.current_page < state.pagination.last_page) {
  139. state.loadStatus = 'more';
  140. } else {
  141. state.loadStatus = 'noMore';
  142. }
  143. }
  144. // 加载更多
  145. function loadMore() {
  146. if (state.loadStatus !== 'noMore') {
  147. state.pagination.current_page += 1
  148. getArticleList(state.pagination.current_page);
  149. }
  150. }
  151. onLoad(async (option) => {
  152. if(option && option.categoryId){
  153. state.categoryId = option.categoryId
  154. }else{
  155. state.categoryId = props.categoryId
  156. }
  157. await getArticleList();
  158. });
  159. // 上拉加载更多
  160. onReachBottom(() => {
  161. loadMore();
  162. });
  163. // 下拉刷新
  164. onPullDownRefresh(() => {
  165. state.pagination.list = []
  166. state.pagination.current_page = 1
  167. state.pagination.total = 1
  168. state.pagination.last_page = 1
  169. getArticleList();
  170. setTimeout(function() {
  171. uni.stopPullDownRefresh();
  172. }, 800);
  173. });
  174. </script>
  175. <style scoped>
  176. .page-body {
  177. width: 100%;
  178. position: relative;
  179. z-index: 1;
  180. flex: 1;
  181. padding-top:40rpx;
  182. box-sizing:border-box;
  183. .article {
  184. padding:16rpx;
  185. height: 230rpx;
  186. position: relative;
  187. width: 90%;
  188. margin: 0 auto;
  189. color:#000;
  190. margin-bottom: 40rpx;
  191. background-repeat: no-repeat;
  192. background-size: 100%;
  193. background-position: center;
  194. background-color: #fff;
  195. overflow: hidden;
  196. .title {
  197. font-size: 34rpx;
  198. /* font-weight: bold; */
  199. margin-bottom: 8px;
  200. }
  201. .content {
  202. display: flex;
  203. flex-direction: row;
  204. }
  205. .image {
  206. width: 300rpx;
  207. height: 169rpx;
  208. margin-right: 16rpx;
  209. background-color: #999;
  210. }
  211. .image-content {
  212. width: 100%;
  213. height: 100%;
  214. border-radius: 8rpx;
  215. }
  216. .desc {
  217. flex: 1;
  218. font-size: 32rpx;
  219. color: #333;
  220. line-height: 1.6;
  221. padding-top: 10rpx;
  222. overflow: hidden;
  223. display: -webkit-box;
  224. -webkit-box-orient: vertical;
  225. -webkit-line-clamp: 3;
  226. text-overflow: ellipsis;
  227. }
  228. }
  229. .activity {
  230. height: 300rpx;
  231. position: relative;
  232. width: 90%;
  233. margin: 0 auto;
  234. color:#fff;
  235. margin-bottom: 40rpx;
  236. background-repeat: no-repeat;
  237. background-size: 100%;
  238. background-position: center;
  239. background-color: #fff;
  240. overflow: hidden;
  241. .activity-bottom{
  242. position: absolute;
  243. bottom: 0;
  244. left: 0;
  245. width: 100%;
  246. height: 50rpx;
  247. background: rgba(0,0,0,0.5);
  248. padding:10rpx;
  249. box-sizing: border-box;
  250. display: flex;
  251. align-items: center;
  252. justify-content: space-between;
  253. text{
  254. white-space: nowrap;
  255. overflow: hidden;
  256. text-overflow: ellipsis;
  257. };
  258. image{
  259. width: 20rpx;
  260. height: 20rpx;
  261. }
  262. }
  263. }
  264. }
  265. </style>