transaction.vue 12 KB

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