portprice.vue 13 KB

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