business.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632
  1. <template>
  2. <view>
  3. <view>
  4. <picker @change="locationChange" :value="location" :range="locationType">
  5. <view class="picker">
  6. {{location>-1?locationType[location]:'请选择'}}
  7. </view>
  8. </picker>
  9. </view>
  10. <view class='tag tag-bule radius line-pink'>采购</view>
  11. <view class='tag tag-bule radius line-pink'>销售</view>
  12. <view class="cu-bar search bg-white">
  13. <view class="search-form round" @click="naviageToPage('/pageA/product/lookup?TabCur=')">
  14. <text style='color: #ccc;' class="cuIcon-search"></text>
  15. <input type="text" placeholder="请输入货名或标题" confirm-type="search"></input>
  16. </view>
  17. </view>
  18. <view class='tag tag-bule radius line-pink' @click="sousuo">玉米</view>
  19. <view class='tag tag-bule radius line-pink' @click="sousuo">大豆</view>
  20. <view class='tag tag-bule radius line-pink' @click="sousuo">小麦</view>
  21. <view class='tag tag-bule radius line-pink' @click="sousuo">水稻</view>
  22. <view class='tag tag-bule radius line-pink' @click="sousuo">高粱</view>
  23. <view class="introduce-section">
  24. <view v-for="(item, index) in buyInfo" :key="index" class="guess-item" @click="navToDetailPage(item)">
  25. <view class="price-box">
  26. <view class="title">{{item.title}}</view>
  27. <template v-if='item.isFutures==0'>
  28. <view v-if="item.price !== 0" class="title-tip">
  29. <text class="price-tip">¥</text>
  30. <text class="price">{{item.price}}</text>
  31. <text class="price-tip">元/吨</text>
  32. </view>
  33. <view v-else class="title-tip">
  34. <text>市场价</text>
  35. </view>
  36. </template>
  37. <view class="title-tip" v-if='item.isFutures==1'>
  38. <text style='color:#828282;margin-bottom:10rpx;display:inline-block;'
  39. class="price-tip">今日基差</text>&nbsp;
  40. <view>
  41. <text class="price-tip">¥</text>
  42. <text class="price">{{item.basis}}</text>
  43. <text class="price-tip">元/吨</text>
  44. </view>
  45. </view>
  46. </view>
  47. <view class='tag tag-bule radius line-pink' v-if='item.isFutures==0'>现货</view>
  48. <view class='tag tag-bule radius line-pink' v-if='item.isFutures==1'>期货</view>
  49. <view class='tag tag-green radius line-green'>{{item.goodsName}}</view>
  50. <view class='tag tag-yellow radius line-yellow'>易粮易运</view>
  51. </view>
  52. <view v-show="isLoadMore">
  53. <uni-load-more :status="loadStatus"></uni-load-more>
  54. </view>
  55. </view>
  56. <u-back-top :scroll-top="scrollTop" tips="顶部" :custom-style="{backgroundColor: '#a0cfff',color: '#2979ff'}"
  57. :iconStyle="{color: '#2979ff',fontSize: '34rpx'}" mode="square" icon="arrow-up"></u-back-top>
  58. <drag-button :isDock="true" :existTabBar="true" :isIcon="true" text="发布" location="20" @btnClick="fabu" />
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. name: "business",
  64. data() {
  65. return {
  66. PageCur: "buy",
  67. buyInfo: [],
  68. pages: 1, //页数
  69. limit: 10, //每次取条目数
  70. loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
  71. isLoadMore: false, //是否加载中
  72. showTran: true,
  73. scrollTop: 0,
  74. categoryList: [{
  75. title: '我要买粮',
  76. id: '0'
  77. }, {
  78. title: '我要卖粮',
  79. id: '1'
  80. }],
  81. TabCur: 0,
  82. current: 1,
  83. location: 0,
  84. locationType: ['黑龙江省', '河南省', '山东省', '安徽省', '吉林省', '河北省', '江苏省', '内蒙古自治区', '四川省', '湖南省', '湖北省', '辽宁省',
  85. '江西省', '云南省', '新疆维吾尔自治区', '山西省', '广西壮族自治区', '陕西省', '广东省', '甘肃省', '重庆市', '贵州省', '浙江省', '福建省',
  86. '宁夏回族自治区', '天津市', '海南省', '青海省', '西藏自治区', '上海市', '北京市'
  87. ]
  88. }
  89. },
  90. onShow() {
  91. uni.showTabBar()
  92. },
  93. onLoad(options) {
  94. console.log("buy onload")
  95. // #ifdef H5
  96. this.headerTop = document.getElementsByTagName('uni-page-head')[0].offsetHeight + 'px';
  97. // #endif
  98. this.cateId = options.tid ? options.tid : 0;
  99. this.keywords = options.keywords ? options.keywords : ''
  100. this.loadData();
  101. },
  102. onPageScroll(e) {
  103. this.scrollTop = e.scrollTop;
  104. },
  105. //下拉刷新
  106. onPullDownRefresh() {
  107. this.pages = 1
  108. this.isLoadMore = false
  109. this.loadStatus = 'loading'
  110. this.loadData()
  111. },
  112. onReachBottom() { //上拉触底函数
  113. if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
  114. this.isLoadMore = true
  115. this.pages += 1
  116. this.getIndexBuyData()
  117. }
  118. },
  119. methods: {
  120. naviageToPage(page) {
  121. page = page + this.TabCur
  122. uni.navigateTo({
  123. url: page,
  124. fail() {
  125. uni.switchTab({
  126. url: page
  127. })
  128. }
  129. })
  130. },
  131. locationChange(e) {
  132. this.location = e.detail.value
  133. },
  134. tabSelect(e) {
  135. this.TabCur = e.currentTarget.dataset.id;
  136. this.category = this.TabCur
  137. this.pages = 1
  138. this.loadData()
  139. },
  140. fabu() {
  141. uni.navigateTo({
  142. url: `/pageB/trust/trust`
  143. })
  144. },
  145. //加载商品 ,带下拉刷新和上滑加载
  146. async loadData(type = 'add', loading) {
  147. const that = this
  148. uni.showLoading({
  149. title: '正在加载',
  150. mask: true
  151. })
  152. var param1 = ''
  153. var param2 = ''
  154. if (that.TabCur == 0) {
  155. param1 = 'integral'
  156. param2 = 'getIndexData'
  157. } else {
  158. param1 = 'buy'
  159. param2 = 'getBuyListInfo'
  160. }
  161. console.log(param1, param2)
  162. that.$api.request(param1, param2, {
  163. page: 1,
  164. limit: 10
  165. }, failres => {
  166. that.$api.msg(failres.errmsg)
  167. that.isLoadMore = false
  168. that.loadStatus = 'nomore'
  169. if (that.pages > 1) {
  170. that.pages -= 1
  171. }
  172. uni.hideLoading()
  173. }).then(res => {
  174. let data = null
  175. if (that.TabCur == 0) {
  176. data = res.data.saleInfo
  177. } else {
  178. data = res.data
  179. }
  180. uni.stopPullDownRefresh()
  181. //采购信息
  182. if (data.length > 0) {
  183. that.buyInfo = data
  184. that.isLoadMore = false
  185. } else {
  186. if (that.pages > 1) {
  187. that.pages -= 1
  188. }
  189. that.isLoadMore = true
  190. that.loadStatus = 'nomore'
  191. }
  192. uni.hideLoading()
  193. })
  194. },
  195. //详情
  196. navToDetailPage(item) {
  197. let id = item.id;
  198. if (item.price === 0) {
  199. this.contactUs();
  200. } else {
  201. if (this.TabCur == 0) {
  202. uni.navigateTo({
  203. url: `/pageA/product/detail?id=${id}`
  204. })
  205. } else {
  206. uni.navigateTo({
  207. url: `/pageA/product/detail_buy?id=${id}`
  208. })
  209. }
  210. }
  211. },
  212. contactUs() {
  213. const that = this
  214. uni.makePhoneCall({
  215. // 手机号
  216. phoneNumber: '15145408888',
  217. // 成功回调
  218. success: (res) => {
  219. console.log('调用成功!')
  220. },
  221. // 失败回调
  222. fail: (res) => {
  223. console.log('调用失败!')
  224. }
  225. });
  226. },
  227. getIndexBuyData() {
  228. const that = this
  229. var pages = that.pages
  230. var limit = that.limit
  231. uni.showLoading({
  232. title: '正在加载',
  233. mask: true
  234. })
  235. that.$api.request('buy', 'getBuyListInfo', {
  236. page: pages,
  237. limit: limit
  238. }, failres => {
  239. that.$api.msg(failres.errmsg)
  240. that.isLoadMore = false
  241. that.loadStatus = 'nomore'
  242. if (that.pages > 1) {
  243. that.pages -= 1
  244. }
  245. uni.hideLoading()
  246. }).then(res => {
  247. let data = res.data
  248. //采购信息
  249. if (data.length > 0) {
  250. that.buyInfo = that.buyInfo.concat(data)
  251. that.isLoadMore = false
  252. } else {
  253. if (that.pages > 1) {
  254. that.pages -= 1
  255. }
  256. that.isLoadMore = true
  257. that.loadStatus = 'nomore'
  258. }
  259. uni.hideLoading()
  260. })
  261. }
  262. }
  263. }
  264. </script>
  265. <style>
  266. page,
  267. .content {
  268. // background: $page-color-base;
  269. }
  270. .cu-tag.badge {
  271. right: 26rpx;
  272. }
  273. .cu-item {
  274. height: 80rpx;
  275. display: inline-block;
  276. line-height: 80rpx;
  277. }
  278. .search-form {
  279. background: #fff;
  280. box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  281. }
  282. .title-tip {
  283. color: #E63113;
  284. text-align: right;
  285. }
  286. .tag-bule {
  287. background: #CDE7FB;
  288. color: #0B4572;
  289. }
  290. .tag-green {
  291. background: #C6F7BC;
  292. color: #065112;
  293. }
  294. .tag-yellow {
  295. background: #FBF4B1;
  296. color: #5C4409;
  297. }
  298. .tag {
  299. padding: 5px;
  300. display: inline-flex;
  301. font-size: 22rpx;
  302. margin: 3px;
  303. }
  304. .text-white {
  305. color: #fff;
  306. }
  307. .text-white text {
  308. position: relative;
  309. z-index: 2;
  310. background: linear-gradient(45deg, #3DC146, #B2D612);
  311. padding: 5px 10px;
  312. border-radius: 38rpx;
  313. }
  314. .guess-section {
  315. padding-bottom: 100upx;
  316. display: flex;
  317. flex-wrap: wrap;
  318. padding: 0 30upx;
  319. background: #fff;
  320. .guess-item {
  321. display: flex;
  322. flex-direction: column;
  323. width: 98%;
  324. border-bottom: 1px solid #ccc;
  325. }
  326. .image-wrapper {
  327. width: 100%;
  328. height: 330upx;
  329. border-radius: 3px;
  330. overflow: hidden;
  331. image {
  332. width: 100%;
  333. height: 100%;
  334. opacity: 1;
  335. }
  336. }
  337. .title {
  338. font-size: $font-lg;
  339. color: #121212;
  340. }
  341. .price-orther {
  342. font-size: $font-sm;
  343. color: $font-color-base;
  344. }
  345. .price {
  346. font-size: 64rpx;
  347. color: #39b54a;
  348. line-height: 1;
  349. padding-right: 10upx;
  350. }
  351. .goods1 {
  352. font-size: $font-sm;
  353. color: $font-color-base;
  354. }
  355. .goods2 {
  356. font-size: $font-sm;
  357. color: $font-color-base;
  358. padding-left: 10%;
  359. }
  360. .goods3 {
  361. font-size: $font-sm;
  362. color: $font-color-base;
  363. padding-left: 10%;
  364. }
  365. .goods4 {
  366. font-size: $font-sm;
  367. color: #ff5500;
  368. }
  369. .goods5 {
  370. font-size: $font-sm;
  371. color: $font-color-base;
  372. }
  373. .view-item {
  374. width: 100%;
  375. // line-height: 40upx;
  376. padding-top: 10upx;
  377. }
  378. .confirm-btn {
  379. margin-left: 20%;
  380. }
  381. .date-time {
  382. margin-left: 30%;
  383. }
  384. .padding-xs-tmp {
  385. padding: 15upx 10upx 10upx 10upx;
  386. }
  387. }
  388. .navbar {
  389. position: fixed;
  390. left: 0;
  391. top: var(--window-top);
  392. display: flex;
  393. width: 100%;
  394. height: 80upx;
  395. background: #fff;
  396. box-shadow: 0 2upx 10upx rgba(0, 0, 0, .06);
  397. z-index: 10;
  398. .nav-item {
  399. flex: 1;
  400. display: flex;
  401. justify-content: center;
  402. align-items: center;
  403. height: 100%;
  404. font-size: 30upx;
  405. color: $font-color-dark;
  406. position: relative;
  407. &.current {
  408. color: $base-color;
  409. &:after {
  410. content: '';
  411. position: absolute;
  412. left: 50%;
  413. bottom: 0;
  414. transform: translateX(-50%);
  415. width: 120upx;
  416. height: 0;
  417. border-bottom: 4upx solid $base-color;
  418. }
  419. }
  420. }
  421. .p-box {
  422. display: flex;
  423. flex-direction: column;
  424. .yticon {
  425. display: flex;
  426. align-items: center;
  427. justify-content: center;
  428. width: 30upx;
  429. height: 14upx;
  430. line-height: 1;
  431. margin-left: 4upx;
  432. font-size: 26upx;
  433. color: #888;
  434. &.active {
  435. color: $base-color;
  436. }
  437. }
  438. .xia {
  439. transform: scaleY(-1);
  440. }
  441. }
  442. .cate-item {
  443. display: flex;
  444. justify-content: center;
  445. align-items: center;
  446. height: 100%;
  447. width: 80upx;
  448. position: relative;
  449. font-size: 44upx;
  450. &:after {
  451. content: '';
  452. position: absolute;
  453. left: 0;
  454. top: 50%;
  455. transform: translateY(-50%);
  456. border-left: 1px solid #ddd;
  457. width: 0;
  458. height: 36upx;
  459. }
  460. }
  461. }
  462. /* 分类 */
  463. .cate-mask {
  464. position: fixed;
  465. left: 0;
  466. top: var(--window-top);
  467. bottom: 0;
  468. width: 100%;
  469. background: rgba(0, 0, 0, 0);
  470. z-index: 95;
  471. transition: .3s;
  472. .cate-content {
  473. width: 630upx;
  474. height: 100%;
  475. background: #fff;
  476. float: right;
  477. transform: translateX(100%);
  478. transition: .3s;
  479. }
  480. &.none {
  481. display: none;
  482. }
  483. &.show {
  484. background: rgba(0, 0, 0, .4);
  485. .cate-content {
  486. transform: translateX(0);
  487. }
  488. }
  489. }
  490. .cate-list {
  491. display: flex;
  492. flex-direction: column;
  493. height: 100%;
  494. .cate-item {
  495. display: flex;
  496. align-items: center;
  497. height: 90upx;
  498. padding-left: 30upx;
  499. font-size: 28upx;
  500. color: #555;
  501. position: relative;
  502. }
  503. .two {
  504. height: 64upx;
  505. color: #303133;
  506. font-size: 30upx;
  507. background: #f8f8f8;
  508. }
  509. .active {
  510. color: $base-color;
  511. }
  512. }
  513. /* 销售信息 */
  514. .introduce-section {
  515. background: #fff;
  516. padding: 20upx 30upx;
  517. padding-bottom: 100upx;
  518. .guess-item {
  519. padding-bottom: 20upx;
  520. border-bottom: 1px solid #ccc;
  521. }
  522. .title {
  523. font-size: 28upx;
  524. color: $font-color-dark;
  525. font-weight: bold;
  526. height: 50upx;
  527. line-height: 50upx;
  528. flex: 2.5;
  529. }
  530. .title-tip {
  531. flex: 1;
  532. }
  533. .price-box {
  534. display: flex;
  535. align-items: baseline;
  536. height: 70upx;
  537. padding: 10upx 0;
  538. font-size: 26upx;
  539. color: $uni-color-primary;
  540. }
  541. .price {
  542. font-size: $font-lg + 2upx;
  543. }
  544. .m-price {
  545. margin: 0 12upx;
  546. color: $font-color-light;
  547. text-decoration: line-through;
  548. }
  549. .coupon-tip {
  550. align-items: center;
  551. padding: 4upx 10upx;
  552. background: $uni-color-primary;
  553. font-size: $font-sm;
  554. color: #fff;
  555. border-radius: 6upx;
  556. line-height: 1;
  557. transform: translateY(-4upx);
  558. }
  559. .bot-row {
  560. display: flex;
  561. align-items: center;
  562. height: 50upx;
  563. font-size: $font-sm;
  564. color: $font-color-light;
  565. view {
  566. flex: 1;
  567. }
  568. }
  569. }
  570. </style>