wangchao 3 years ago
parent
commit
aa0f724cf5
1 changed files with 26 additions and 20 deletions
  1. 26 20
      pages/user/report.vue

+ 26 - 20
pages/user/report.vue

@@ -214,7 +214,7 @@
 				</maoScroll>
 			</view> -->
 			<view class="content7">
-				<view ref='scroll' class='scroll'>
+				<view ref='scroll' class='scroll' :style="{'top':'-'+scrollTop+'px'}">
 					<view class="row1" v-for="(item,index) in ztList">
 						<view class="zt">
 							<view class="point"></view>在途
@@ -243,7 +243,8 @@
 		},
 		data() {
 			return {
-				carInterval: '',
+				scrollTop: 0,
+				carInterval: null,
 				inventoryCost: '',
 				inventoryValue: '',
 				contractSelect: '0',
@@ -371,10 +372,10 @@
 			}
 		},
 		onLoad: function(option) {
-			// uni.showLoading({
-			// 	title: "数据加载中...",
-			// 	mask: true
-			// })
+			uni.showLoading({
+				title: "数据加载中...",
+				mask: true
+			})
 			if (this.nowDate == '2022年全年') {
 				this.seachMoth = '2022'
 			}
@@ -383,6 +384,10 @@
 		destroyed() {
 			clearInterval(this.carInterval)
 		},
+		onUnload() {
+			debugger
+			clearInterval(this.carInterval)
+		},
 		methods: {
 			goToPage(index) {
 				console.log(index)
@@ -761,33 +766,34 @@
 				})
 			},
 			scroll() {
-				let _scroll = 0
 				let that = this
 				let _outHeight = ''
 				let _inHeight = ''
 				let obj = uni.createSelectorQuery().select('.content7')
-				obj.boundingClientRect(function(data) { // data - 各种参数
+				obj.boundingClientRect(function(data) {
 					console.log(data)
 					_outHeight = data.height
 				}).exec()
 				setTimeout(function() {
 					let obj1 = uni.createSelectorQuery().select('.scroll')
-					obj1.boundingClientRect(function(data) { // data - 各种参数
+					obj1.boundingClientRect(function(data) {
 						console.log(data)
 						_inHeight = data.height
 					}).exec()
-					that.carInterval = setInterval(function() {
-						_scroll++
-						console.log(_scroll)
-						if (_scroll < _inHeight - _outHeight) {
-							that.$refs.scroll.$el.style.top = '-' + _scroll + 'px'
+					that.carInterval = setInterval(() => {
+						console.log('···················')
+						console.log("_scroll", that.scrollTop)
+						console.log('_inHeight', _inHeight)
+						console.log('_outHeight', _outHeight)
+						if (that.scrollTop < _inHeight - _outHeight) {
+							that.scrollTop++
+							// console.log(that.$refs)
+							// that.$refs.scroll.$el.style.top = '-' + _scroll + 'px'
 						} else {
-							_scroll = 0
+							that.scrollTop = 0
 						}
-					}, 50)
-
-				}, 0)
-
+					}, 100)
+				}, 10)
 			},
 			confirm(e) {
 				console.log(e)
@@ -1028,7 +1034,7 @@
 	.content7 {
 		position: relative;
 		overflow: hidden;
-		height: 400rpx;
+		height: 520rpx;
 		margin-top: 20rpx;
 
 		.scroll {