activity.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 :spring="indexStyle.spring" :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. indexStyle: {
  58. noticeBarBgColor: "#fff",
  59. noticeBarColor: "#FF3D00",
  60. backgroundClass: "background",
  61. spring: false,
  62. }
  63. }
  64. },
  65. components: {
  66. Tabbar
  67. },
  68. onShow() {
  69. if (this.$refs.tabbarMain) {
  70. this.$refs.tabbarMain.setcount(1);
  71. }
  72. },onLoad() {
  73. this.getBannerInfo("HDYM");
  74. this.spring()
  75. },
  76. onReachBottom() {
  77. if (this.current==1&&this.newsList.length < this.recordsTotal) {
  78. this.myLoadmore();
  79. }
  80. },
  81. methods: {
  82. spring() {
  83. this.springShow=false;
  84. try{
  85. if(this.carhelp.getConfig().spring2025){
  86. var spring2025=this.carhelp.getConfig().spring2025
  87. var sz=spring2025.split(',')
  88. if(sz&&sz.length==2){
  89. var time1=new Date(sz[0])
  90. var time2=new Date(sz[1])
  91. var time0=new Date()
  92. if(time0>time1&&time0<time2){
  93. this.springShow=true;
  94. }
  95. }
  96. }
  97. this.$forceUpdate()
  98. }catch(e){
  99. }
  100. if(!this.springShow){
  101. return
  102. }
  103. this.indexStyle.noticeBarBgColor = "#C00000"
  104. this.indexStyle.noticeBarColor = "#FFD695"
  105. this.indexStyle.backgroundClass = "background-spring"
  106. this.indexStyle.spring = true;
  107. },
  108. gotoArticleDetails(item){
  109. if(item.linkType=="2"){
  110. this.gotoUrl2(item.externalUrl)
  111. }else{
  112. this.gotoUrl('pages/article/articleDetails?id=' + item.id)
  113. }
  114. },
  115. change(index) {
  116. this.current = index;
  117. //this.newsType = this.tabList[index].type;
  118. if(this.newsList.length==0){
  119. this.getNewsList()
  120. }
  121. },
  122. getNewsList(bl) {
  123. uni.showLoading({
  124. title: "加载中",
  125. mask: true,
  126. })
  127. if (bl) {
  128. this.newsList = [];
  129. this.pageIndex = 1;
  130. }
  131. newsApi.newsInfoList({
  132. pageIndex: this.pageIndex,
  133. pageSize: 20,
  134. shortName: this.newsType
  135. }).then((res) => {
  136. uni.hideLoading()
  137. this.newsList = [
  138. ...this.newsList,
  139. ...res.data.data
  140. ];
  141. this.recordsTotal = res.data.recordsTotal
  142. }).catch(error => {
  143. uni.showToast({
  144. title: error,
  145. icon: "none"
  146. })
  147. })
  148. },
  149. myLoadmore() {
  150. this.pageIndex += 1;
  151. this.getNewsList()
  152. },
  153. getBannerInfo(code) {
  154. uni.showLoading({
  155. title: "加载中",
  156. mask: true,
  157. })
  158. newsApi.getBannerInfo(code).then((res) => {
  159. this.bannerList = res.data;
  160. uni.hideLoading()
  161. //document.getElementsByClassName("uni-swiper-wrapper")[0].parentNode.style="background-color: rgb(255, 255, 255); height: 120px;"
  162. }).catch(error => {
  163. uni.showToast({
  164. title: error,
  165. icon: "none"
  166. })
  167. })
  168. },
  169. clickBannerTopI(i) {
  170. var mod = this.bannerListTop[i];
  171. //this.showTop = false;
  172. this.clickBanner(0, true, mod)
  173. },
  174. clickBannerTop() {
  175. var mod = this.bannerListTop[this.showTopIndex];
  176. this.showTop = false;
  177. this.clickBanner(0, true, mod)
  178. },
  179. clickBanner(index, bl, modout) {
  180. var uurl = "";
  181. var mod = {}
  182. if (modout) {
  183. mod = modout;
  184. }else{
  185. mod =this.bannerList[index]
  186. }
  187. mod.clickUrl = mod.linkUrl
  188. if (mod.linkPicUrl && !bl) {
  189. this.showOss = true;
  190. this.showOssImg = mod.linkPicUrl;
  191. this.showOssIndex = index;
  192. } else if (mod.clickUrl == null) {
  193. } else if (mod.clickUrl.indexOf('http') == 0) {
  194. window.location = mod.clickUrl + uurl;
  195. } else if (mod.clickUrl.slice(-5) == 'login' && this.userId) {
  196. } else if (mod.clickUrl.indexOf('#/') == 0) {
  197. if (mod.clickUrl.indexOf("?") == -1) {
  198. mod.clickUrl += '?';
  199. }
  200. var url = mod.clickUrl.split("#")[1]
  201. //window.location = mod.clickUrl;
  202. uni.navigateTo({
  203. url: url + uurl
  204. })
  205. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  206. } else {
  207. uni.navigateTo({
  208. url: mod.clickUrl + uurl
  209. })
  210. }
  211. },
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .tag {
  217. width: 120px;
  218. top: -100rpx;
  219. left: 464rpx;
  220. position: relative;
  221. border-radius: 4px 4px 4px 0px;
  222. color: #fff;
  223. padding: 2px 6px;
  224. font-size: 20rpx;
  225. line-height: 20rpx;
  226. height: 1rpx;
  227. //background: linear-gradient(to right bottom, rgba(255, 255, 255, 0.4), transparent) var(--bg, #EA3447);
  228. background-blend-mode: soft-light;
  229. img{
  230. height: 74rpx;
  231. width: 240rpx;
  232. }
  233. }
  234. .background{
  235. padding-bottom: 30px;
  236. }
  237. .banner{
  238. margin: 24rpx;
  239. }
  240. .options-item{
  241. width: 100%;
  242. display: flex;
  243. justify-content: center;
  244. background: rgb(255, 255, 255);
  245. position: relative;
  246. position: fixed;
  247. left: 0;
  248. right: 0;
  249. top: 0;
  250. z-index: 991;
  251. }
  252. .news {
  253. background-color: #fff;
  254. margin: 0 16px ;
  255. border-radius: 8px;
  256. .news-content {
  257. display: flex;
  258. justify-content: space-between;
  259. margin-bottom: 24px;
  260. .content-text {
  261. width: 56.2%;
  262. height: 100%;
  263. line-height: 21px;
  264. color: #101010;
  265. text-align: left;
  266. font-size: 14px;
  267. }
  268. .content-title {
  269. width: 100%;
  270. overflow: hidden;
  271. text-overflow: ellipsis;
  272. display: -webkit-box;
  273. -webkit-box-orient: vertical;
  274. -webkit-line-clamp: 3;
  275. }
  276. .content-img {
  277. width: 40.57%;
  278. height: 100%;
  279. border-radius: 4px;
  280. overflow: hidden;
  281. img {
  282. width: 100%;
  283. height: 80%;
  284. }
  285. }
  286. .news-time {
  287. margin-top: 10%;
  288. color: #999999;
  289. width: 100px;
  290. height: 20px;
  291. font-size: 14px;
  292. }
  293. }
  294. }
  295. ::v-deep .springclass{
  296. .u-tabbar__content__item{
  297. .u-icon__img {
  298. width:56rpx !important;
  299. height:56rpx !important
  300. }
  301. }
  302. .u-tabbar__content__item:nth-child(2){
  303. .u-icon__img {
  304. width:72rpx !important;
  305. height:72rpx !important
  306. }
  307. }
  308. }
  309. </style>