business.vue 16 KB

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