newsinfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. <template>
  2. <view>
  3. <view class="guess-section-wrap1">
  4. <view class='guess-section-wrap-content'>
  5. <view style='margin:19rpx;background:#fff;padding:15px;border-radius:5px;' class='flex justify-between' v-for='(item, index) in newsInfo' :key="index" @click="navToDetailPage(item.id)">
  6. <view style='margin-right:10px;'>
  7. <view style='font-size:16px;height:54px;' class="Regular">{{item.title}}</view>
  8. <view class="Regular" style='color:#B2B3BB;font-size:12px;'><text style='margin-right:5px;'>{{item.from}}</text>{{item.gmtUpdate}}</view>
  9. </view>
  10. <view><image style='width:100px;height:72px;border-radius:5px;' :src='item.titleImg'></image></view>
  11. </view>
  12. </view>
  13. <view v-show="isLoadMore">
  14. <uni-load-more :status="loadStatus" ></uni-load-more>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. import {
  21. mapState
  22. } from 'vuex';
  23. export default {
  24. name: "sale",
  25. data() {
  26. return {
  27. titleNViewBackground: '',
  28. swiperCurrent: 0,
  29. swiperLength: 0,
  30. carouselList: [],
  31. windowSpuList: [],
  32. categoryPickList: [],
  33. categoryButtomList: [],
  34. salesTop: [],
  35. saleInfo: [],
  36. portInfo: [],
  37. banner: undefined,
  38. isVip: false,
  39. pages: 1, //页数
  40. limit: 10, //每次取条目数
  41. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  42. isLoadMore: false, //是否加载中
  43. showTran:true,
  44. list: [],
  45. scrollTop: 0,
  46. cardCur: 0,
  47. dotStyle: false,
  48. newsInfo: [],
  49. categoryList:[],
  50. pages:1,//页数
  51. limit:10 ,//每次取条目数
  52. loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  53. TabCur: 0,
  54. category:0,
  55. current: 0,
  56. infoList1:[],
  57. time:""
  58. };
  59. },
  60. onReady() {
  61. },
  62. onShow() {
  63. uni.showTabBar()
  64. this.pages = 1
  65. this.isLoadMore = false
  66. this.loadStatus = 'more'
  67. this.loadData()
  68. },
  69. onLoad(options) {
  70. var that = this
  71. var infoList = [];
  72. // uni.request({
  73. // url: "https://hq.sinajs.cn/list=C0,C2109,C2111,C2201,C2203,C2205,C2207,A0,A2109,A2111,A2201,A2203,A2205,A2207",
  74. // // url: "https://hq.sinajs.cn/list=C2109",
  75. // header: {
  76. // 'content-type': 'application/x-www-form-urlencoded'
  77. // },
  78. // success: function(result) {
  79. // // resolve调用后,即可传递到调用方使用then或者async+await同步方式进行处理逻辑
  80. // var tmp = result.data.split('"')
  81. // for(var i = 1; i<tmp.length;i=i+2){
  82. // var list = tmp[i].split(",")
  83. // var data = {
  84. // goodsName:list[0],
  85. // newPrice:list[6],
  86. // openPrice:list[2]
  87. // }
  88. // if(data.goodsName){
  89. // infoList.push(data)
  90. // }
  91. // }
  92. // let name = 'infoList';
  93. // let value = infoList;
  94. // that.$store.commit('$uStore', {
  95. // name,
  96. // value
  97. // });
  98. // // console.log("infoList",infoList)
  99. // },
  100. // fail: function(e) {
  101. // console.log('error in...')
  102. // // reject调用后,即可传递到调用方使用catch或者async+await同步方式进行处理逻辑
  103. // reject(e)
  104. // },
  105. // })
  106. },
  107. onPageScroll(e) {
  108. this.scrollTop = e.scrollTop;
  109. },
  110. onReachBottom() { //上拉触底函数
  111. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  112. this.isLoadMore = true
  113. this.pages += 1
  114. this.getIndexSaleData()
  115. }
  116. },
  117. onPullDownRefresh() {
  118. this.pages = 1
  119. this.isLoadMore = false
  120. this.loadStatus = 'loading'
  121. this.loadData()
  122. setTimeout(function () {
  123. uni.stopPullDownRefresh();
  124. }, 1000);
  125. },
  126. computed: {
  127. ...mapState(['hasLogin', 'userInfo']),
  128. },
  129. methods: {
  130. DotStyle(e) {
  131. this.dotStyle = e.detail.value
  132. },
  133. cardSwiper(e) {
  134. this.cardCur = e.detail.current
  135. },
  136. hangqing() {
  137. uni.navigateTo({
  138. url: `/pageB/news/news`
  139. })
  140. },
  141. tabSelect(e) {
  142. this.TabCur = e.currentTarget.dataset.id;
  143. this.category = this.TabCur
  144. this.pages = 1
  145. this.loadData()
  146. },
  147. //回到顶部
  148. goTop(e) { // 一键回到顶部
  149. console.log(e)
  150. if (wx.pageScrollTo) {
  151. wx.pageScrollTo({
  152. scrollTop: 0
  153. })
  154. } else {
  155. wx.showModal({
  156. title: '提示',
  157. content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  158. })
  159. }
  160. },
  161. async loadData() {
  162. var that=this
  163. // 新闻内容
  164. that.$api.request('news', 'getNewsInfo',{
  165. category:2,
  166. page: this.pages,
  167. limit:this.limit
  168. }, failres => {
  169. that.$api.msg(failres.errmsg)
  170. this.isLoadMore = false
  171. this.loadStatus = 'nomore'
  172. if(this.pages>1){this.pages=1}
  173. uni.hideLoading()
  174. }).then(res => {
  175. let data = res.data
  176. for(var i=0;i<data.length;i++){
  177. if(data[i].title.length > 25){
  178. data[i].title = data[i].title.substring(0,25) + "..."
  179. }
  180. let _date = new Date(data[i].gmtUpdate)
  181. data[i].gmtUpdate = this.$u.timeFormat(_date.getTime(), 'mm-dd hh:MM');
  182. }
  183. that.newsInfo = data
  184. uni.hideLoading()
  185. })
  186. },
  187. //轮播图切换修改背景色
  188. swiperChange(e) {
  189. const index = e.detail.current;
  190. this.swiperCurrent = index;
  191. // this.titleNViewBackground = this.carouselList[index].color;
  192. },
  193. //详情
  194. navToDetailPage(item) {
  195. let id = item;
  196. uni.navigateTo({
  197. url: `/pageB/news/news_detail?id=${id}`
  198. })
  199. },
  200. naviageToPage(page) {
  201. uni.navigateTo({
  202. url: page,
  203. fail() {
  204. uni.switchTab({
  205. url: page
  206. })
  207. }
  208. })
  209. },
  210. getIndexSaleData() {
  211. const that = this
  212. var pages=that.pages
  213. var limit=that.limit
  214. uni.showLoading({
  215. title: '正在加载'
  216. })
  217. that.$api.request('news', 'getNewsInfo', {
  218. category:2,
  219. page: pages,
  220. limit:limit
  221. },failres => {
  222. that.$api.msg(failres.errmsg)
  223. that.isLoadMore=false
  224. that.loadStatus = 'nomore'
  225. if(that.pages>1){that.pages-=1}
  226. uni.hideLoading()
  227. }).then(res => {
  228. let data = res.data
  229. if(data.length > 0){
  230. for(var k =0;k<data.length;k++){
  231. if(data[k].title.length > 20){
  232. data[k].title = data[k].title.substring(0,20) + "..."
  233. }
  234. let _date = new Date(data[k].gmtUpdate)
  235. data[k].gmtUpdate = this.$u.timeFormat(_date.getTime(), 'mm-dd hh:MM');
  236. }
  237. that.newsInfo = that.newsInfo.concat(data)
  238. that.isLoadMore=false
  239. }
  240. else{
  241. if(that.pages>1){that.pages-=1}
  242. that.isLoadMore=true
  243. that.loadStatus = 'nomore'
  244. }
  245. uni.hideLoading()
  246. })
  247. }
  248. },
  249. // #ifndef MP
  250. // 标题栏input搜索框点击
  251. onNavigationBarSearchInputClicked: async function(e) {
  252. uni.navigateTo({
  253. url: '/pageA/product/search'
  254. })
  255. },
  256. //点击导航栏 buttons 时触发
  257. // onNavigationBarButtonTap(e) {
  258. // const index = e.index;
  259. // if (index === 0) {
  260. // this.$api.msg('点击了扫描');
  261. // } else if (index === 1) {
  262. // // #ifdef APP-PLUS
  263. // const pages = getCurrentPages();
  264. // const page = pages[pages.length - 1];
  265. // const currentWebview = page.$getAppWebview();
  266. // currentWebview.hideTitleNViewButtonRedDot({
  267. // index
  268. // });
  269. // // #endif
  270. // uni.navigateTo({
  271. // url: '/pages/notice/notice'
  272. // })
  273. // }
  274. // }
  275. // #endif
  276. }
  277. </script>
  278. <style>
  279. .price{
  280. color:#FD714F;
  281. }
  282. .container{
  283. margin: 10rpx 10rpx 10rpx 10rpx;
  284. }
  285. .cu-tag.badge {
  286. right: 26rpx;
  287. }
  288. .up,.down{
  289. width: 7.5px;
  290. height: 9px;
  291. position:relative;
  292. top:-2px;
  293. vertical-align: middle;
  294. margin-right: 2px;
  295. }
  296. .gird-left,.gird-right{
  297. }
  298. .cu-tag.radius[class*="line"]::after {
  299. border-radius: 66rpx;
  300. }
  301. .goTop{
  302. height: 32px;
  303. width: 32px;
  304. position: fixed;
  305. bottom: 200rpx;
  306. right: 30rpx;
  307. border-radius: 50%;
  308. }
  309. .goTop image{
  310. width:32px;
  311. height:32px;
  312. }
  313. .flex{
  314. display:flex;
  315. }
  316. .text-white{
  317. color:#fff;
  318. }
  319. .cu-card{
  320. border-bottom:1rpx solid #f8f8f8;
  321. text-align: center;
  322. }
  323. .factory{
  324. font-size:26rpx;
  325. font-weight:900;
  326. }
  327. .positive{
  328. color:#FD714F;
  329. font-size:26rpx;
  330. font-weight:900;
  331. }
  332. .negative{
  333. color:#22C572;
  334. font-size:26rpx;
  335. font-weight:900;
  336. }
  337. .wrap{
  338. font-size:20rpx;
  339. color: rgba(0,0,0,0.5);
  340. }
  341. .align-center{
  342. align-items: center;
  343. }
  344. .flex-direction-row{
  345. flex-direction:row;
  346. }
  347. .factoryItem{
  348. padding: 20rpx 0;
  349. }
  350. /* #ifdef MP */
  351. .mp-search-box {
  352. // position:relative;
  353. left: 0;
  354. top: 30upx;
  355. z-index: 9999;
  356. width: 100%;
  357. padding: 0 80upx;
  358. background: rgba(255, 170, 0, 0.6);
  359. .ser-input {
  360. flex: 1;
  361. height: 56upx;
  362. line-height: 56upx;
  363. text-align: center;
  364. font-size: 28upx;
  365. color: $font-color-base;
  366. border-radius: 10px;
  367. background: rgba(255, 255, 255, .6);
  368. }
  369. }
  370. .desc{
  371. width:73%;
  372. margin-right:2%;
  373. }
  374. .justify-between{
  375. justify-content: space-between;
  376. }
  377. page {
  378. .cate-section {
  379. position: relative;
  380. z-index: 5;
  381. border-radius: 16upx 16upx 0 0;
  382. margin-top: -20upx;
  383. }
  384. .carousel-section {
  385. padding: 0;
  386. .titleNview-placing {
  387. padding-top: 0;
  388. height: 0;
  389. }
  390. .carousel {
  391. .carousel-item {
  392. padding: 0;
  393. }
  394. }
  395. .swiper-dots {
  396. left: 50%;
  397. bottom: 5upx;
  398. transform: translateX(-50%);
  399. }
  400. }
  401. }
  402. /* #endif */
  403. .cuIcon-notification::before{
  404. color:#f37b1;
  405. }
  406. .cu-card.article>.cu-item .content>image {
  407. height: 3.4em;
  408. margin-right: 0rpx;
  409. margin-top: 24rpx;
  410. }
  411. .screen-swiper.price-swiper{
  412. height:70rpx;
  413. min-height: 70rpx;
  414. background: #fff;
  415. margin-bottom: 10px;
  416. }
  417. .swiper-item{
  418. border-radius: 5%;
  419. }
  420. .guess-section {
  421. margin-bottom: 120rpx;
  422. margin-top:20rpx;
  423. }
  424. .guess-section .price{
  425. color:#FD714F;
  426. font-size: 34rpx;
  427. font-weight:600;
  428. }
  429. page {
  430. background: #f5f5f5;
  431. }
  432. .m-t {
  433. margin-top: 16upx;
  434. }
  435. /* 销售信息 */
  436. .introduce-section {
  437. background: #fff;
  438. padding: 20upx 30upx;
  439. padding-bottom: 100upx;
  440. .guess-item {
  441. padding-bottom: 20upx;
  442. border-bottom: 1px solid #ccc;
  443. }
  444. .title {
  445. font-size: 28upx;
  446. color: $font-color-dark;
  447. font-weight:bold;
  448. height: 50upx;
  449. line-height: 50upx;
  450. flex:2.5;
  451. }
  452. .title-tip {
  453. flex:1;
  454. }
  455. .price-box {
  456. display: flex;
  457. align-items: baseline;
  458. height: 70upx;
  459. padding: 10upx 0;
  460. font-size: 26upx;
  461. color: $uni-color-primary;
  462. }
  463. .price {
  464. font-size: $font-lg + 2upx;
  465. }
  466. .m-price {
  467. margin: 0 12upx;
  468. color: $font-color-light;
  469. text-decoration: line-through;
  470. }
  471. .coupon-tip {
  472. align-items: center;
  473. padding: 4upx 10upx;
  474. background: $uni-color-primary;
  475. font-size: $font-sm;
  476. color: #fff;
  477. border-radius: 6upx;
  478. line-height: 1;
  479. transform: translateY(-4upx);
  480. }
  481. .bot-row {
  482. display: flex;
  483. align-items: center;
  484. height: 50upx;
  485. font-size: $font-sm;
  486. color: $font-color-light;
  487. view {
  488. flex: 1;
  489. }
  490. }
  491. }
  492. </style>