plant.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  1. <template>
  2. <view>
  3. <view class="guess-section">
  4. <view class="cu-card article no-card" style='width: 100%;'>
  5. <view class="top-tap Regular" style="display:flex;">
  6. <view class="top-tap-item">工厂</view>
  7. <view class="top-tap-item">价格</view>
  8. <view class="top-tap-item">较昨日</view>
  9. </view>
  10. </view>
  11. <view class="guess-list">
  12. <view class="guess-list-item" v-for="(item, index) in newsInfo" :key="index">
  13. <view class="guess-item-item">
  14. <view class='factory Medium'>{{item.factory}}</view>
  15. <view class='wrap Regular'>{{item.city}} {{item.factoryType}}</view>
  16. </view>
  17. <view class='price NumberBold guess-item-item'>{{item.price}}</view>
  18. <view class='positive NumberBold guess-item-item' v-if='item.comparePrice>0'>
  19. <image class='up' src='../../static/img/homepage/shangsheng.png'>{{item.comparePrice}}
  20. </image>
  21. </view>
  22. <view class='negative NumberBold guess-item-item' v-if='item.comparePrice<0'>
  23. <image class='down' src='../../static/img/homepage/xiajiang.png'>{{-item.comparePrice}}
  24. </image>
  25. </view>
  26. <view class="guess-item-item Regular" v-if='item.comparePrice==0'>-</view>
  27. </view>
  28. </view>
  29. <view v-show="isLoadMore">
  30. <uni-load-more :status="loadStatus"></uni-load-more>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. mapState
  38. } from 'vuex';
  39. export default {
  40. name: "sale",
  41. data() {
  42. return {
  43. titleNViewBackground: '',
  44. swiperCurrent: 0,
  45. swiperLength: 0,
  46. carouselList: [],
  47. windowSpuList: [],
  48. categoryPickList: [],
  49. categoryButtomList: [],
  50. salesTop: [],
  51. saleInfo: [],
  52. portInfo: [],
  53. banner: undefined,
  54. isVip: false,
  55. pages: 1, //页数
  56. limit: 10, //每次取条目数
  57. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  58. isLoadMore: false, //是否加载中
  59. showTran: true,
  60. list: [],
  61. scrollTop: 0,
  62. cardCur: 0,
  63. dotStyle: false,
  64. newsInfo: [],
  65. categoryList: [],
  66. pages: 1, //页数
  67. limit: 10, //每次取条目数
  68. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  69. TabCur: 0,
  70. category: 0,
  71. current: 0,
  72. infoList1: []
  73. };
  74. },
  75. onReady() {},
  76. onShow() {
  77. uni.showTabBar()
  78. this.pages = 1
  79. this.isLoadMore = false
  80. this.loadStatus = 'more'
  81. this.loadData()
  82. },
  83. onLoad(options) {
  84. var that = this
  85. var infoList = [];
  86. uni.request({
  87. url: "https://hq.sinajs.cn/list=C0,C2109,C2111,C2201,C2203,C2205,C2207,A0,A2109,A2111,A2201,A2203,A2205,A2207",
  88. // url: "https://hq.sinajs.cn/list=C2109",
  89. header: {
  90. 'content-type': 'application/x-www-form-urlencoded'
  91. },
  92. success: function(result) {
  93. // resolve调用后,即可传递到调用方使用then或者async+await同步方式进行处理逻辑
  94. var tmp = result.data.split('"')
  95. for (var i = 1; i < tmp.length; i = i + 2) {
  96. var list = tmp[i].split(",")
  97. var data = {
  98. goodsName: list[0],
  99. newPrice: list[6],
  100. openPrice: list[2]
  101. }
  102. if (data.goodsName) {
  103. infoList.push(data)
  104. }
  105. }
  106. let name = 'infoList';
  107. let value = infoList;
  108. that.$store.commit('$uStore', {
  109. name,
  110. value
  111. });
  112. // console.log("infoList",infoList)
  113. },
  114. fail: function(e) {
  115. console.log('error in...')
  116. // reject调用后,即可传递到调用方使用catch或者async+await同步方式进行处理逻辑
  117. reject(e)
  118. },
  119. })
  120. },
  121. onPageScroll(e) {
  122. this.scrollTop = e.scrollTop;
  123. },
  124. onReachBottom() { //上拉触底函数
  125. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  126. this.isLoadMore = true
  127. this.pages += 1
  128. this.getIndexSaleData()
  129. }
  130. },
  131. onPullDownRefresh() {
  132. this.pages = 1
  133. this.isLoadMore = false
  134. this.loadStatus = 'loading'
  135. this.loadData()
  136. setTimeout(function() {
  137. uni.stopPullDownRefresh();
  138. }, 1000);
  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. var _gp = ''
  178. var _mt = ''
  179. if (this.TabCur == 0) {
  180. _gp = 'news'
  181. _mt = 'getFactoryPriceInfo'
  182. } else if (this.TabCur == 1) {
  183. _gp = 'news'
  184. _mt = 'getPortPriceInfo'
  185. } else if (this.TabCur == 2) {
  186. _gp = 'news'
  187. _mt = 'getNewsInfo'
  188. }
  189. // 新闻内容
  190. that.$api.request(_gp, _mt, {
  191. category: this.category,
  192. page: this.pages,
  193. limit: this.limit
  194. }, failres => {
  195. that.$api.msg(failres.errmsg)
  196. this.isLoadMore = false
  197. this.loadStatus = 'nomore'
  198. if (this.pages > 1) {
  199. this.pages = 1
  200. }
  201. uni.hideLoading()
  202. }).then(res => {
  203. let data = res.data
  204. that.newsInfo = data
  205. uni.hideLoading()
  206. })
  207. },
  208. }
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .container {
  213. margin: 10rpx 10rpx 10rpx 10rpx;
  214. }
  215. .cu-tag.badge {
  216. right: 26rpx;
  217. }
  218. .up,
  219. .down {
  220. width: 7.5px;
  221. height: 9px;
  222. position: relative;
  223. vertical-align: middle;
  224. margin-right: 2px;
  225. }
  226. .gird-left,
  227. .gird-right {}
  228. .cu-tag.radius[class*="line"]::after {
  229. border-radius: 66rpx;
  230. }
  231. .goTop {
  232. height: 32px;
  233. width: 32px;
  234. position: fixed;
  235. bottom: 200rpx;
  236. right: 30rpx;
  237. border-radius: 50%;
  238. }
  239. .goTop image {
  240. width: 32px;
  241. height: 32px;
  242. }
  243. .flex {
  244. display: flex;
  245. }
  246. .text-white {
  247. color: #fff;
  248. }
  249. .cu-card {
  250. border-bottom: 1rpx solid #f8f8f8;
  251. text-align: center;
  252. }
  253. .factory {
  254. font-size: 28rpx;
  255. }
  256. .positive {
  257. color: #FD714F;
  258. font-size: 28rpx;
  259. }
  260. .negative {
  261. color: #22C572;
  262. font-size: 28rpx;
  263. font-weight: 900;
  264. }
  265. .wrap {
  266. font-size: 24rpx;
  267. color: #B2B3BB;
  268. }
  269. .align-center {
  270. align-items: center;
  271. }
  272. .flex-direction-row {
  273. flex-direction: row;
  274. }
  275. .factoryItem {
  276. padding: 20rpx 0;
  277. }
  278. /* #ifdef MP */
  279. .mp-search-box {
  280. // position:relative;
  281. left: 0;
  282. top: 30upx;
  283. z-index: 9999;
  284. width: 100%;
  285. padding: 0 80upx;
  286. background: rgba(255, 170, 0, 0.6);
  287. .ser-input {
  288. flex: 1;
  289. height: 56upx;
  290. line-height: 56upx;
  291. text-align: center;
  292. font-size: 28upx;
  293. color: $font-color-base;
  294. border-radius: 10px;
  295. background: rgba(255, 255, 255, .6);
  296. }
  297. }
  298. .desc {
  299. width: 73%;
  300. margin-right: 2%;
  301. }
  302. .justify-between {
  303. justify-content: space-between;
  304. }
  305. page {
  306. .cate-section {
  307. position: relative;
  308. z-index: 5;
  309. border-radius: 16upx 16upx 0 0;
  310. margin-top: -20upx;
  311. }
  312. .carousel-section {
  313. padding: 0;
  314. .titleNview-placing {
  315. padding-top: 0;
  316. height: 0;
  317. }
  318. .carousel {
  319. .carousel-item {
  320. padding: 0;
  321. }
  322. }
  323. .swiper-dots {
  324. left: 50%;
  325. bottom: 5upx;
  326. transform: translateX(-50%);
  327. }
  328. }
  329. }
  330. /* #endif */
  331. .cuIcon-notification::before {
  332. color: #f37b1;
  333. }
  334. .cu-card.article>.cu-item .content>image {
  335. height: 3.4em;
  336. margin-right: 0rpx;
  337. margin-top: 24rpx;
  338. }
  339. .screen-swiper.price-swiper {
  340. height: 70rpx;
  341. min-height: 70rpx;
  342. background: #fff;
  343. margin-bottom: 10px;
  344. }
  345. .swiper-item {
  346. border-radius: 5%;
  347. }
  348. .guess-section {
  349. padding: 0;
  350. margin-top: 20rpx;
  351. }
  352. .guess-section .guess-item {
  353. width: 100%;
  354. background: green;
  355. border-bottom: 1px solid #EEEEEE;
  356. }
  357. .guess-section .price {
  358. font-size: 34rpx;
  359. color: #FD714F;
  360. }
  361. page {
  362. background: #f5f5f5;
  363. }
  364. .m-t {
  365. margin-top: 16upx;
  366. }
  367. /* 销售信息 */
  368. .introduce-section {
  369. background: #fff;
  370. padding: 20upx 30upx;
  371. padding-bottom: 100upx;
  372. .guess-item {
  373. padding-bottom: 20upx;
  374. border-bottom: 1px solid #ccc;
  375. }
  376. .title {
  377. font-size: 28upx;
  378. color: $font-color-dark;
  379. font-weight: bold;
  380. height: 50upx;
  381. line-height: 50upx;
  382. flex: 2.5;
  383. }
  384. .title-tip {
  385. flex: 1;
  386. }
  387. .price-box {
  388. display: flex;
  389. align-items: baseline;
  390. height: 70upx;
  391. padding: 10upx 0;
  392. font-size: 26upx;
  393. color: $uni-color-primary;
  394. }
  395. .price {
  396. font-size: $font-lg + 2upx;
  397. }
  398. .m-price {
  399. margin: 0 12upx;
  400. color: $font-color-light;
  401. text-decoration: line-through;
  402. }
  403. .coupon-tip {
  404. align-items: center;
  405. padding: 4upx 10upx;
  406. background: $uni-color-primary;
  407. font-size: $font-sm;
  408. color: #fff;
  409. border-radius: 6upx;
  410. line-height: 1;
  411. transform: translateY(-4upx);
  412. }
  413. .bot-row {
  414. display: flex;
  415. align-items: center;
  416. height: 50upx;
  417. font-size: $font-sm;
  418. color: $font-color-light;
  419. view {
  420. flex: 1;
  421. }
  422. }
  423. }
  424. .top-tap {
  425. display: flex;
  426. font-size: 27rpx;
  427. padding: 20rpx 48rpx;
  428. justify-content: space-between;
  429. .top-tap-item {
  430. color: #B2B3BB;
  431. }
  432. .top-tap-item:nth-of-type(1) {
  433. flex: 3;
  434. display: flex;
  435. justify-content: flex-start;
  436. }
  437. .top-tap-item:nth-of-type(2) {
  438. flex: 3;
  439. display: flex;
  440. justify-content: center;
  441. }
  442. .top-tap-item:nth-of-type(3) {
  443. flex: 1;
  444. display: flex;
  445. justify-content: flex-end;
  446. }
  447. }
  448. .guess-list {
  449. width: 100%;
  450. .guess-list-item {
  451. padding: 20rpx 47rpx;
  452. display: flex;
  453. width: 100%;
  454. border-bottom: 1px solid #EEEEEE;
  455. .guess-item-item:nth-of-type(1) {
  456. flex: 3;
  457. display: flex;
  458. justify-content: flex-start;
  459. flex-direction: column;
  460. }
  461. ;
  462. .guess-item-item:nth-of-type(2) {
  463. flex: 3;
  464. display: flex;
  465. justify-content: center;
  466. align-items: center;
  467. }
  468. .guess-item-item:nth-of-type(3) {
  469. flex: 1;
  470. display: flex;
  471. justify-content: flex-end;
  472. align-items: center;
  473. }
  474. }
  475. }
  476. </style>