activity.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <view style="background-color: #fff;">
  3. <ujp-navbar title="优惠活动" :is-back="false" v-if="false" ></ujp-navbar>
  4. <view>
  5. <view class="options-item">
  6. <u-tabs :list="tabList" :current="current" @change="change" :show-bar="false" active-color="#00B962 " inactive-color="#c4c0c0"></u-tabs>
  7. </view>
  8. <uni-view data-v-fd8981f8="" class="u-navbar-placeholder" style="width: 100%; height: 88rpx;"></uni-view>
  9. </view>
  10. <view class="background" v-show="current==0">
  11. <view class="banner" v-for="(item,i) in bannerList"
  12. :key="i">
  13. <u-image width="100%" @click="clickBanner(i)"
  14. mode="scaleToFill" height="250" border-radius ="12"
  15. :src="item.picUrl"></u-image>
  16. <view class="tag"
  17. v-if="item.isMain">
  18. <img src="@/assets/img/buy/tip.png">
  19. </view>
  20. </view>
  21. <u-divider bg-color="#F2F4F4" >已经到底了</u-divider>
  22. </view>
  23. <view class="news" v-show="current==1">
  24. <view class="news-content" v-for="(item,index) in newsList" :key="item.id"
  25. @click="gotoArticleDetails(item)"
  26. >
  27. <view class="content-text">
  28. <view class="content-title oldTextjp2" oldstyle="font-size: 18px;">{{item.title}}</view>
  29. <view class="news-time">{{item.createTime ? item.createTime.slice(5,16) : ''}}</view>
  30. </view>
  31. <view class="content-img">
  32. <img v-if="item.pic " :src="item.pic" alt="">
  33. <img v-else src="@/assets/static/img/image_default.png" alt="">
  34. </view>
  35. </view>
  36. <u-divider v-if="newsList.length!=0&&newsList.length ==recordsTotal">已经到底了</u-divider>
  37. </view>
  38. <Tabbar :current="1" ref="tabbarMain" ></Tabbar>
  39. </view>
  40. </template>
  41. <script>
  42. import Tabbar from '@/components/Tabbar.vue';
  43. import * as newsApi from '@/apis/news.js'
  44. export default {
  45. data() {
  46. return {
  47. tabList: [
  48. {name: '优惠活动',type: 'YHHD'},
  49. {name: '通知公告',type: 'TZGG'},
  50. ],
  51. current: 0,
  52. newsList: [],
  53. pageIndex: 1,
  54. newsType: 'TZGG',
  55. recordsTotal: 0,
  56. bannerList: [],
  57. }
  58. },
  59. components: {
  60. Tabbar
  61. },
  62. onShow() {
  63. if (this.$refs.tabbarMain) {
  64. this.$refs.tabbarMain.setcount(1);
  65. }
  66. },onLoad() {
  67. this.getBannerInfo("HDYM");
  68. },
  69. onReachBottom() {
  70. if (this.current==1&&this.newsList.length < this.recordsTotal) {
  71. this.myLoadmore();
  72. }
  73. },
  74. methods: {
  75. gotoArticleDetails(item){
  76. if(item.linkType=="2"){
  77. this.gotoUrl2(item.externalUrl)
  78. }else{
  79. this.gotoUrl('pages/article/articleDetails?id=' + item.id)
  80. }
  81. },
  82. change(index) {
  83. this.current = index;
  84. //this.newsType = this.tabList[index].type;
  85. if(this.newsList.length==0){
  86. this.getNewsList()
  87. }
  88. },
  89. getNewsList(bl) {
  90. uni.showLoading({
  91. title: "加载中",
  92. mask: true,
  93. })
  94. if (bl) {
  95. this.newsList = [];
  96. this.pageIndex = 1;
  97. }
  98. newsApi.newsInfoList({
  99. pageIndex: this.pageIndex,
  100. pageSize: 20,
  101. shortName: this.newsType
  102. }).then((res) => {
  103. uni.hideLoading()
  104. this.newsList = [
  105. ...this.newsList,
  106. ...res.data.data
  107. ];
  108. this.recordsTotal = res.data.recordsTotal
  109. }).catch(error => {
  110. uni.showToast({
  111. title: error,
  112. icon: "none"
  113. })
  114. })
  115. },
  116. myLoadmore() {
  117. this.pageIndex += 1;
  118. this.getNewsList()
  119. },
  120. getBannerInfo(code) {
  121. uni.showLoading({
  122. title: "加载中",
  123. mask: true,
  124. })
  125. newsApi.getBannerInfo(code).then((res) => {
  126. this.bannerList = res.data;
  127. uni.hideLoading()
  128. //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
  129. }).catch(error => {
  130. uni.showToast({
  131. title: error,
  132. icon: "none"
  133. })
  134. })
  135. },
  136. clickBannerTopI(i) {
  137. var mod = this.bannerListTop[i];
  138. //this.showTop = false;
  139. this.clickBanner(0, true, mod)
  140. },
  141. clickBannerTop() {
  142. var mod = this.bannerListTop[this.showTopIndex];
  143. this.showTop = false;
  144. this.clickBanner(0, true, mod)
  145. },
  146. clickBanner(index, bl, modout) {
  147. var uurl = "";
  148. var mod = this.bannerList[index]
  149. if (modout) {
  150. mod = modout;
  151. }
  152. mod.clickUrl = mod.linkUrl
  153. if (mod.linkPicUrl && !bl) {
  154. this.showOss = true;
  155. this.showOssImg = mod.linkPicUrl;
  156. this.showOssIndex = index;
  157. } else if (mod.clickUrl == null) {
  158. } else if (mod.clickUrl.indexOf('http') == 0) {
  159. window.location = mod.clickUrl + uurl;
  160. } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
  161. } else if (mod.clickUrl.indexOf('#/') == 0) {
  162. if (mod.clickUrl.indexOf("?") == -1) {
  163. mod.clickUrl += '?';
  164. }
  165. var url = mod.clickUrl.split("#")[1]
  166. //window.location = mod.clickUrl;
  167. uni.navigateTo({
  168. url: url + uurl
  169. })
  170. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  171. } else {
  172. uni.navigateTo({
  173. url: mod.clickUrl + uurl
  174. })
  175. }
  176. },
  177. }
  178. }
  179. </script>
  180. <style lang="scss" scoped>
  181. .tag {
  182. width: 120px;
  183. top: -100rpx;
  184. left: 464rpx;
  185. position: relative;
  186. border-radius: 4px 4px 4px 0px;
  187. color: #fff;
  188. padding: 2px 6px;
  189. font-size: 20rpx;
  190. line-height: 20rpx;
  191. height: 1rpx;
  192. //background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.4), transparent) var(--bg, #EA3447);
  193. background-blend-mode: soft-light;
  194. img{
  195. height: 74rpx;
  196. width: 240rpx;
  197. }
  198. }
  199. .background{
  200. padding-bottom: 30px;
  201. }
  202. .banner{
  203. margin: 24rpx;
  204. }
  205. .options-item{
  206. width: 100%;
  207. display: flex;
  208. justify-content: center;
  209. background: rgb(255, 255, 255);
  210. position: relative;
  211. position: fixed;
  212. left: 0;
  213. right: 0;
  214. top: 0;
  215. z-index: 991;
  216. }
  217. .news {
  218. background-color: #fff;
  219. margin: 0 16px ;
  220. border-radius: 8px;
  221. .news-content {
  222. display: flex;
  223. justify-content: space-between;
  224. margin-bottom: 24px;
  225. .content-text {
  226. width: 56.2%;
  227. height: 100%;
  228. line-height: 21px;
  229. color: #101010;
  230. text-align: left;
  231. font-size: 14px;
  232. }
  233. .content-title {
  234. width: 100%;
  235. overflow: hidden;
  236. text-overflow: ellipsis;
  237. display: -webkit-box;
  238. -webkit-box-orient: vertical;
  239. -webkit-line-clamp: 3;
  240. }
  241. .content-img {
  242. width: 40.57%;
  243. height: 100%;
  244. border-radius: 4px;
  245. overflow: hidden;
  246. img {
  247. width: 100%;
  248. height: 80%;
  249. }
  250. }
  251. .news-time {
  252. margin-top: 10%;
  253. color: #999999;
  254. width: 100px;
  255. height: 20px;
  256. font-size: 14px;
  257. }
  258. }
  259. }
  260. </style>