123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469 |
- <template>
- <view class="content">
- <view :style="statusBarHeight" class="status_bar">
- </view>
- <scroll-view scroll-x class="nav" style="margin-top: 20rpx;">
- <view class="flex text-center">
- <view class="cu-item flex-sub" :class="0==TabCur?'text-white':''" @tap="tabSelect" data-id="0">
- <text>货源找车</text>
- </view>
- <view class="cu-item flex-sub" :class="1==TabCur?'text-white':''" @tap="tabSelect" data-id="1">
- <text>
- 车队找粮</text>
- </view>
- </view>
- </scroll-view>
- <swiper :current="TabCur" class="swiper-box" duration="300" @change="tabSelect">
- <swiper-item class="tab-content" data-id="1">
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
- <block v-if="TabCur==0">
- <!-- <view class="cu-bar search">
- <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=2')">
- <text class="cuIcon-search"></text>
- <input type="text" placeholder="搜索" confirm-type="search"></input>
- </view>
- </view> -->
- <view class="guess-section">
- <view
- v-for="(item , index) in tranInfo" :key="index"
- class="guess-item guess-item-warp bg-white"
- @click="navToDetailPage(item.id)"
- >
- <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
- <text>{{item.startPlace }}</text>
- <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
- <text>{{item.endPlace }}</text>
- </view>
- <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
- <view>
- <text class='status' v-if="item.status == 30">可承运</text>
- <text class='status' v-if="item.status == 40">已结束</text>
- <view class='goods'><text>{{item.goodsName}}</text><text>{{numFilter(item.total - item.tranCount) }}吨</text></view>
- </view>
-
- <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
- <text v-if='item.inPrice' class="text-price">{{item.inPrice }}/吨</text>
- </view>
- <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
- <text></text>
- <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
- </view>
- </view>
- <view v-show="isLoadMore">
- <uni-load-more :status="loadStatus" ></uni-load-more>
- </view>
- </view>
- </block>
- </scroll-view>
- </swiper-item>
- <swiper-item class="tab-content" data-id="0">
- <scroll-view class="list-scroll-content" scroll-y @scrolltolower="onReachBottomTmp">
- <block v-if="TabCur==1">
- <!-- <view class="cu-bar search">
- <view class="search-form round" @click="naviageToPage('/pageA/product/search?TabCur=3')">
- <text class="cuIcon-search"></text>
- <input type="text" placeholder="搜索" confirm-type="search"></input>
- </view>
- </view> -->
- <view class="guess-section">
- <view
- v-for="(item, index) in carInfo" :key="index"
- class="guess-item guess-item-warp bg-white"
- @click="navToDetailPage(item.id)"
- >
- <view style='margin:5px 0;diaplay:inline-block;font-weight:900;' class="flex justify-between">
- <text>{{item.startPlace }}</text>
- <image class='carIcon' src='https://taohaoliang.oss-cn-beijing.aliyuncs.com/tmp/car.png'></image>
- <text>{{item.endPlace }}</text>
- </view>
- <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
- <view>
- <text class='status' v-if="item.status == 2">可委托</text>
- <text class='status' v-else>已承运</text>
- <view class='goods'><text>{{item.driver}}</text><text>{{item.carNo}}</text></view>
- </view>
-
- <text v-if='item.price' class="text-price">{{item.price }}/吨</text>
- </view>
- <view style='margin:5px 0;diaplay:inline-block;' class="flex justify-between">
- <text></text>
- <text class='gmtUpdate'>{{item.gmtUpdate}}</text>
- </view>
- </view>
- <view v-show="isLoadMore">
- <uni-load-more :status="loadStatus" ></uni-load-more>
- </view>
- </view>
- </block>
- </scroll-view>
- </swiper-item>
- </swiper>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex';
- export default {
- name: "tran",
- data() {
- return {
- tranInfo: [],
- carInfo:[],
- pages:1,//页数
- limit:10 ,//每次取条目数
- loadStatus:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
- isLoadMore:false ,//是否加载中
- TabCur:0,
- statusBarHeight:"height:"
- };
- },
- computed: {
- ...mapState(['hasLogin','userInfo'])
- },
- onShow() {
- uni.showTabBar()
- uni.hideKeyboard()
- this.loadData()
- var userInfo = uni.getStorageSync("userInfo")
- var that = this
- console.log("userInfo",userInfo)
- uni.removeTabBarBadge({
- index: 4
- })
- this.$api.doRequest('get', '/newNoticeTask/query/noticeTasks').then(res => {
- if (res.data.data) {
- let name = 'myTip';
- let value = res.data.data.total;
- that.$store.commit('$uStore', {
- name,
- value
- });
- if(value != 0&&value){
- uni.setTabBarBadge({
- index:4,
- text:value+""
- })
- }
- name = 'taskTip';
- value = res.data.data.total;
- that.$store.commit('$uStore', {
- name,
- value
- });
- // name = 'contractTip';
- // value = res.data.data.contractTip;
- // that.$store.commit('$uStore', {
- // name,
- // value
- // });
- }
- })
- },
- //下拉刷新
- onPullDownRefresh() {
- this.pages = 1
- this.isLoadMore = false
- this.loadStatus = 'loading'
- this.loadData()
- },
- onLoad() {
- var that = this
- uni.getSystemInfo({
- success: function(res) {
- console.log("statusBarHeight",res.statusBarHeight)
- that.statusBarHeight += res.statusBarHeight + "px"; //这就是状态栏的高度
- },
- });
- },
- onReachBottom(){ //上拉触底函数
- if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
- this.isLoadMore=true
- this.pages += 1
- if(this.TabCur == 0){
- this.getIndexTranData()
- }
- else{
- this.getIndexCarData()
- }
-
- }
- },
- methods: {
- numFilter (value) {
- if(!value){
- return 0
- }
- // 截取当前数据到小数点后两位
- let realVal = parseFloat(value).toFixed(2)
- return realVal
- },
- naviageToPage(page) {
- uni.navigateTo({
- url: page,
- fail() {
- uni.switchTab({
- url: page
- })
- }
- })
- },
- async loadData() {
- const that = this
- uni.showLoading({
- title: '正在加载',
- mask:true
- })
- if(this.TabCur == 0){
- that.$api.request('tran', 'getTranListInfo',{
- page: this.pages,
- limit:this.limit
- }, failres => {
- that.$api.msg(failres.errmsg)
- this.isLoadMore = false
- this.loadStatus = 'nomore'
- if(this.pages>1){this.pages=1}
- uni.hideLoading()
- uni.stopPullDownRefresh()
- }).then(res => {
- let data = res.data
- console.log(res)
- //销售信息
- if(res.data.tranInfo){
- console.log(res.data.tranInfo)
- that.tranInfo = res.data.tranInfo
-
- }
- uni.hideLoading()
- uni.stopPullDownRefresh()
- })
- }
- else{
- that.$api.request('tran', 'getCarListInfo',{
- page: this.pages,
- limit:this.limit
- }, failres => {
- that.$api.msg(failres.errmsg)
- this.isLoadMore = false
- this.loadStatus = 'nomore'
- if(this.pages>1){this.pages=1}
- uni.hideLoading()
- uni.stopPullDownRefresh()
- }).then(res => {
- let data = res.data
- //销售信息
- if(res.data.carInfo){
- that.carInfo = res.data.carInfo
- }
- uni.hideLoading()
- uni.stopPullDownRefresh()
- })
- }
- },
- tabSelect(e) {
- if(e.currentTarget.dataset.id){
- this.TabCur = e.currentTarget.dataset.id;
- }
- else{
- this.TabCur = e.target.current;
- }
- this.pages = 1
- console.log(this.TabCur)
- this.loadData()
- },
- //详情
- navToDetailPage(item) {
- let id = item;
- if(this.TabCur == 0){
- uni.navigateTo({
- url: `/pages/tran/tran_detail?id=${id}`
- })
- }
- else{
- uni.navigateTo({
- url: `/pages/tran/car_detail?id=${id}`
- })
- }
- },
- onReachBottomTmp(){ //上拉触底函数
- if(!this.isLoadMore){ //此处判断,上锁,防止重复请求
- this.isLoadMore=true
- this.pages += 1
- if(this.TabCur == 0){
- this.getIndexTranData()
- }
- else{
- this.getIndexCarData()
- }
-
- }
- },
- getIndexTranData(){
- const that = this
- var pages=that.pages
- var limit=that.limit
-
- uni.showLoading({
- title: '正在加载',
- mask:true
- })
- that.$api.request('tran', 'getTranListInfo', {
- page: pages,
- limit:limit
- },failres => {
- that.$api.msg(failres.errmsg)
- that.isLoadMore=false
- that.loadStatus = 'nomore'
- if(that.pages>1){that.pages-=1}
- uni.hideLoading()
- }).then(res => {
- let data = res.data
- //销售信息
- if(data.tranInfo.length > 0){
- that.tranInfo = that.tranInfo.concat(data.tranInfo)
- that.isLoadMore=false
- }
- else{
- if(that.pages>1){that.pages-=1}
- that.isLoadMore=true
- that.loadStatus = 'nomore'
- }
- uni.hideLoading()
- })
- },
- getIndexCarData(){
- const that = this
- var pages=that.pages
- var limit=that.limit
-
- uni.showLoading({
- title: '正在加载',
- mask:true
- })
- that.$api.request('tran', 'getCarListInfo', {
- page: pages,
- limit:limit
- },failres => {
- that.$api.msg(failres.errmsg)
- that.isLoadMore=false
- that.loadStatus = 'nomore'
- if(that.pages>1){that.pages-=1}
- uni.hideLoading()
- }).then(res => {
- let data = res.data
- //销售信息
- if(data.carInfo.length > 0){
- that.carInfo = that.carInfo.concat(data.carInfo)
- that.isLoadMore=false
- }
- else{
- if(that.pages>1){that.pages-=1}
- that.isLoadMore=true
- that.loadStatus = 'nomore'
- }
- uni.hideLoading()
- })
- }
-
- },
- }
- </script>
- <style lang="scss" scoped>
- .cu-tag.badge {
- right: 26rpx;
- }
- .text-white text{
- position: relative;
- z-index: 2;
- background: linear-gradient(45deg, #3DC146, #B2D612);
- padding: 5px 10px;
- border-radius: 38rpx;
- }
- .guess-item-warp{
- padding:15px;
- border-radius: 5px;
- color:#000;
- box-shadow: 0 2px 2px rgba(0,0,0,0.1);
- margin:5px 0;
- }
- .cu-bar .search-form {
- background-color: #ffff;
- }
- .status{
- font-weight:900;
- display:inline-block;
- margin-right:15px;
- }
- .gmtUpdate{
- color:rgba(0,0,0,0.5);
- }
- .goods{
- display:inline-block;
- background:#F5F5F5;
- font-size:12px;
- padding:5px 10px;
- color:#585858;
- border-radius: 3px;
- }
- .text-price{
- color:#E63113;
- }
- .goods text{
- display: inline-block;
- padding:0 5px;
- }
- .goods text:first-child{
- border-right:1px solid #737373;
- }
- .carIcon{
- width: 68px;
- height: 14px;
- position: relative;
- top: 4px;
- }
- .guess-section{
- background:transparent;
- }
- page,
- .content {
- background: $page-color-base;
- height: 100%;
- }
- /* .container{
- padding-bottom: 100upx;
- } */
- .cu-form-group input {
- text-align: right;
- }
- .cu-form-group textarea {
- text-align: right;
- }
- .place{
- font-size: 40rpx;
- line-height: 1;
- padding-right: 10upx;
- }
- .place-center{
- font-size: 28rpx;
- }
- .btn-size{
- font-size: 28rpx;
- }
- .place-bottom{
- margin-top: 20rpx;
- }
- .swiper-box {
- height: 85vh;
- }
- .list-scroll-content {
- height: 100%;
- }
- .uni-swiper-item {
- height: auto;
- }
- .status_bar {
- width: 100%;
- }
- </style>
|