plant.vue 13 KB

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