business.vue 16 KB

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