Browse Source

首页轮播添加判断

wangchao 3 years ago
parent
commit
6ec9e3b20f
1 changed files with 69 additions and 46 deletions
  1. 69 46
      pages/sale/information.vue

+ 69 - 46
pages/sale/information.vue

@@ -11,8 +11,8 @@
 		<!-- 头部轮播 -->
 		<view class="carousel-section">
 			<swiper class="screen-swiper header-swiper" ::class="dotStyle?'square-dot':'round-dot'"
-				:indicator-dots="true" :circular="true" :autoplay="true" interval="5000"
-				@change="swiperChange" indicator-color="#8799a3" indicator-active-color="#0081ff">
+				:indicator-dots="true" :circular="true" :autoplay="true" interval="5000" @change="swiperChange"
+				indicator-color="#8799a3" indicator-active-color="#0081ff">
 				<swiper-item class="swiper-item" v-for="(item,index) in carouselList" :key="index"
 					:class="cardCur==index?'text-white':''" @click="naviageToPage(item.url)">
 					<image :src="item.imgUrl"></image>
@@ -31,8 +31,8 @@
 				<view class='title'>工厂价格</view>
 				<view style='color:#B2B3BB;' @click='more("/pages/sale/plant")'>更多</view>
 			</view>
-			<swiper class="screen-swiper header-swiper" :autoplay="true" interval="3000" duration="500" :circular="true" :acceleration="true"
-				style="min-height: 380px;">
+			<swiper class="screen-swiper header-swiper" :autoplay="true" interval="3000" duration="500" :circular="true"
+				:acceleration="true" style="min-height: 380px;">
 				<swiper-item class="" v-for="(item1,index) in factoryPriceData.list" :key="index">
 					<view class='guess-section-wrap-item clearfix' v-for='(item,index1) in item1' :key="index1">
 						<view class='factory'>{{item.factory}}</view>
@@ -58,9 +58,10 @@
 				<view style='color:#B2B3BB;' @click='more("/pages/sale/portprice")'>更多</view>
 			</view>
 			<!-- <uni-notice-bar scrollable="true" single="true" background-color="white" :portList="portList" ></uni-notice-bar> -->
-				<swiper class="screen-swiper header-swiper-port" :autoplay="true" interval="0" duration="60000" :circular="true" :acceleration="true">
-					<swiper-item class="" v-for="(item1,index) in portPriceData.list" :key="index">
-						<view class='guess-section-wrap-item clearfix' v-for='(item,index1) in item1' :key="index1">
+			<swiper class="screen-swiper header-swiper-port" :autoplay="true" interval="0" duration="60000"
+				:circular="true" :acceleration="true">
+				<swiper-item class="" v-for="(item1,index) in portPriceData.list" :key="index">
+					<view class='guess-section-wrap-item clearfix' v-for='(item,index1) in item1' :key="index1">
 						<view class='factory'>{{item.port}}</view>
 						<view class='wrap'>{{item.goodsName}}</view>
 						<view class='price'>
@@ -84,10 +85,10 @@
 											src='../../static/img/homepage/unitweight@3x.png'></image>
 										>={{item.bulkDensity}}
 									</view>
-									</view>
+							</view>
 						</view>
-					</swiper-item>
-				</swiper>
+				</swiper-item>
+			</swiper>
 		</view>
 		<view class="guess-section-wrap1">
 			<view style='padding:15px;' class='flex justify-between'>
@@ -163,7 +164,7 @@
 				infoList1: [],
 				statusBarHeight: "height:",
 				factoryPriceData: {},
-				portPriceData:{}
+				portPriceData: {}
 			};
 		},
 		onReady() {},
@@ -256,7 +257,9 @@
 			this.loadData()
 			var userInfo = uni.getStorageSync("userInfo")
 			var that = this
-			this.$api.doRequest('get', '/salePlanInfo/getTips', {phone:userInfo.phone}).then(res => {
+			this.$api.doRequest('get', '/salePlanInfo/getTips', {
+				phone: userInfo.phone
+			}).then(res => {
 				if (res.data.data) {
 					let name = 'myTip';
 					let value = res.data.data.myTip;
@@ -264,10 +267,10 @@
 						name,
 						value
 					});
-					if(value != 0){
+					if (value != 0) {
 						uni.setTabBarBadge({
-							index:3,
-							text:value+""
+							index: 3,
+							text: value + ""
 						})
 					}
 					name = 'taskTip';
@@ -308,45 +311,64 @@
 			...mapState(['hasLogin', 'userInfo'])
 		},
 		methods: {
-			makeportScrollData(valList) {
+			// makeportScrollData(valList) {
+			// 	console.log(valList)
+			// 	let _rowCount = valList.length;
+			// 	let _pageSize = 2
+			// 	let _newArray = []
+			// 	if (_rowCount == null || _rowCount == "") {
+			// 		this.portPriceData.totalPage = 0;
+			// 	} else {
+			// 		if (_pageSize != 0 && _rowCount % _pageSize == 0) {
+			// 			this.portPriceData.totalPage = parseInt(_rowCount / _pageSize)
+			// 		}
+			// 		if (_pageSize != 0 && _rowCount % _pageSize != 0) {
+			// 			this.portPriceData.totalPage = parseInt(_rowCount / _pageSize) + 1;
+			// 		}
+			// 	}
+			// 	for (let i = 0; i < valList.length; i += 2) {
+			// 		_newArray.push(valList.slice(i, i + 2))
+			// 	}
+			// 	this.portPriceData.list = _newArray
+			// },
+			makeScrollData(valList, size) {
 				console.log(valList)
 				let _rowCount = valList.length;
-				let _pageSize = 2
+				let _pageSize = size
 				let _newArray = []
 				if (_rowCount == null || _rowCount == "") {
-					this.portPriceData.totalPage = 0;
+					if (size == 8) {
+
+						this.factoryPriceData.totalPage = 0;
+					} else {
+						this.portPriceData.totalPage = 0;
+					}
 				} else {
 					if (_pageSize != 0 && _rowCount % _pageSize == 0) {
-						this.portPriceData.totalPage = parseInt(_rowCount / _pageSize)
+						if (size == 8) {
+							this.factoryPriceData.totalPage = parseInt(_rowCount / _pageSize)
+						} else {
+							this.portPriceData.totalPage = parseInt(_rowCount / _pageSize)
+						}
 					}
 					if (_pageSize != 0 && _rowCount % _pageSize != 0) {
-						this.portPriceData.totalPage = parseInt(_rowCount / _pageSize) + 1;
+						if (size == 8) {
+
+							this.factoryPriceData.totalPage = parseInt(_rowCount / _pageSize) + 1;
+						} else {
+							this.portPriceData.totalPage = parseInt(_rowCount / _pageSize) + 1;
+						}
 					}
 				}
-				for (let i = 0; i < valList.length; i += 2) {
-					_newArray.push(valList.slice(i, i + 2))
+				for (let i = 0; i < valList.length; i += size) {
+					_newArray.push(valList.slice(i, i + size))
 				}
-				this.portPriceData.list = _newArray
-			},
-			makeScrollData(valList) {
-				console.log(valList)
-				let _rowCount = valList.length;
-				let _pageSize = 8
-				let _newArray = []
-				if (_rowCount == null || _rowCount == "") {
-					this.factoryPriceData.totalPage = 0;
+				if (size == 8) {
+					this.factoryPriceData.list = _newArray
 				} else {
-					if (_pageSize != 0 && _rowCount % _pageSize == 0) {
-						this.factoryPriceData.totalPage = parseInt(_rowCount / _pageSize)
-					}
-					if (_pageSize != 0 && _rowCount % _pageSize != 0) {
-						this.factoryPriceData.totalPage = parseInt(_rowCount / _pageSize) + 1;
-					}
+					this.portPriceData.list = _newArray
 				}
-				for (let i = 0; i < valList.length; i += 8) {
-					_newArray.push(valList.slice(i, i + 8))
-				}
-				this.factoryPriceData.list = _newArray
+
 			},
 			more(url) {
 				console.log(url)
@@ -419,7 +441,7 @@
 				}).then(res => {
 					let data = res.data
 					that.plantList = data
-					that.makeScrollData(that.plantList)
+					that.makeScrollData(that.plantList, 8)
 					uni.hideLoading()
 				})
 				// 港口价格
@@ -438,7 +460,7 @@
 				}).then(res => {
 					let data = res.data
 					that.portList = data
-					that.makeportScrollData(that.portList)
+					that.makeScrollData(that.portList, 2)
 					uni.hideLoading()
 				})
 				// 新闻内容
@@ -586,8 +608,8 @@
 				uni.showLoading({
 					title: '正在加载',
 				})
-				var pages=that.pages
-				var limit=that.limit
+				var pages = that.pages
+				var limit = that.limit
 				that.$api.request('news', 'getNewsInfo', {
 					category: 2,
 					page: 1,
@@ -1130,7 +1152,8 @@
 		padding-right: 40rpx;
 		margin-bottom: 26rpx;
 	}
-	.header-swiper-port{
+
+	.header-swiper-port {
 		height: 120px;
 		min-height: 120px;
 	}