Explorar o código

Signed-off-by: liuboyan <632697560@qq.com>
下拉刷新

liuboyan %!s(int64=4) %!d(string=hai) anos
pai
achega
5a7cdc8c37

+ 2 - 2
config/api.js

@@ -1,5 +1,5 @@
-// const WX_API_BASE = 'https://www.qianjiadi.com/'
-const WX_API_BASE = 'http://ch.jihengcc.cn:17080/'
+const WX_API_BASE = 'https://www.qianjiadi.com/'
+// const WX_API_BASE = 'http://ch.jihengcc.cn:17080/'
 // const WX_API_BASE = 'https://test.jihengcc.cn/'
    // const WX_API_BASE = 'https://www.qianjiadi.com/'
 

+ 28 - 14
pages.json

@@ -5,7 +5,8 @@
 	"pages": [{
 			"path": "pages/index/index",
 			"style": {
-				"navigationBarTitleText": "首页"
+				"navigationBarTitleText": "首页",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "pages/index/login",
@@ -16,19 +17,22 @@
 		{
 			"path": "pages/shop/index",
 			"style": {
-				"navigationBarTitleText": "商城"
+				"navigationBarTitleText": "商城",
+				"enablePullDownRefresh":true
 			}
 		},
 		{
 			"path": "pages/cart/cart",
 			"style": {
-				"navigationBarTitleText": "购物车"
+				"navigationBarTitleText": "购物车",
+				"enablePullDownRefresh":true
 			}
 		},
 		{
 			"path": "pages/user/index",
 			"style": {
-				"navigationBarTitleText": "个人"
+				"navigationBarTitleText": "个人",
+				"enablePullDownRefresh":true
 			}
 		}
 	],
@@ -42,7 +46,8 @@
 		}, {
 			"path": "goodList",
 			"style": {
-				"navigationBarTitleText": "商品列表"
+				"navigationBarTitleText": "商品列表",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "shopDetails",
@@ -62,12 +67,14 @@
 		}, {
 			"path": "evaluateList",
 			"style": {
-				"navigationBarTitleText": "评价列表"
+				"navigationBarTitleText": "评价列表",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "videoList",
 			"style": {
-				"navigationBarTitleText": "直播大厅"
+				"navigationBarTitleText": "直播大厅",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "liveDetail",
@@ -95,12 +102,14 @@
 		"pages": [{
 			"path": "plantList",
 			"style": {
-				"navigationBarTitleText": "我的种植"
+				"navigationBarTitleText": "我的种植",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "entrustList",
 			"style": {
-				"navigationBarTitleText": "委托列表"
+				"navigationBarTitleText": "委托列表",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "entrustForm",
@@ -110,7 +119,8 @@
 		}, {
 			"path": "addressList",
 			"style": {
-				"navigationBarTitleText": "我的地址"
+				"navigationBarTitleText": "我的地址",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "addressForm",
@@ -120,18 +130,21 @@
 		}, {
 			"path": "couponList",
 			"style": {
-				"navigationBarTitleText": "我的优惠券"
+				"navigationBarTitleText": "我的优惠券",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "integralList",
 			"style": {
-				"navigationBarTitleText": "我的积分"
+				"navigationBarTitleText": "我的积分",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "orderList",
 			"style": {
 				"navigationBarTitleText": "订单中心",
-				"backgroundColor": "#f7f7f7"
+				"backgroundColor": "#f7f7f7",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "orderDetail",
@@ -151,7 +164,8 @@
 		}, {
 			"path": "messageList",
 			"style": {
-				"navigationBarTitleText": "留言列表"
+				"navigationBarTitleText": "留言列表",
+				"enablePullDownRefresh":true
 			}
 		}, {
 			"path": "messageForm",

+ 8 - 1
pages/cart/cart.vue

@@ -72,6 +72,10 @@
 			this.cartsList = []
 			this.getCartData()
 		},
+		onPullDownRefresh() {
+			this.cartsList = []
+			this.getCartData('refresh')
+		},
 		methods: {
 			//  跳转商铺页
 			goToShop(item) {
@@ -86,8 +90,11 @@
 				});
 			},
 			//  获取购物车列表
-			getCartData() {
+			getCartData(type) {
 				NET.request(API.getCartList, {}, 'GET').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					res.data.merchants && res.data.merchants.forEach(item => {
 						item.allCheck = false
 						item.products.forEach(site => {

+ 8 - 16
pages/index/index.vue

@@ -63,9 +63,7 @@
 		<view class="index-title" style="margin-bottom: 4px;">
 			<view class="title-text">猜你喜欢</view>
 		</view>
-		
-		<scroll-view class="content-box" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
-		 @refresherrefresh="onRefresh" @refresherrestore="onRestore">
+		<scroll-view class="content-box" scroll-y="true">
 			<view class="goods-row" v-for="(item,index) in goodsList" :key="index" @click="goToGoodDetails(item)">
 				<image class="goods-img" :src="item.imgPath"></image>
 				<view class="goods-info">
@@ -94,7 +92,6 @@
 				shortVideo: null,
 				advertList: [],
 				discountList: [],
-				triggered: false,
 				goodsList: [],
 			}
 		},
@@ -104,12 +101,16 @@
 					url: '/pages/index/login'
 				});
 			}
+			// this.getBaseInfo()
+			// this.getPreferGoodsList()
 		},
 		onShow() {
 			this.getBaseInfo()
-			setTimeout(() => {
-				this.triggered = true;
-			}, 1000)
+			this.getPreferGoodsList()
+		},
+		onPullDownRefresh() {
+			this.getPreferGoodsList()
+			this.getBaseInfo()
 		},
 		methods: {
 			//  查询数据
@@ -147,18 +148,9 @@
 					})
 				})
 			},
-			//  下拉刷新
-			onRefresh() {
-				this.getPreferGoodsList()
-			},
-			//  刷新终止
-			onRestore() {
-				this.triggered = 'restore'
-			},
 			//  获取猜你喜欢商品列表
 			getPreferGoodsList() {
 				NET.request(API.getPreferGoods, {}, 'GET').then(res => {
-					this.triggered = false;
 					this.goodsList = res.data
 				}).catch(error => {
 					this.$refs.uTips.show({

+ 28 - 29
pages/shop/index.vue

@@ -15,7 +15,7 @@
 				<view class="sort-right-col" :class="sortSecondCode == item.cateCode ? 'sort-right-col-active' : ''" v-for="(item,index) in sortSecondList"
 				 :key="index" @click="checkSecondSort(item)">{{item.cateValue}}</view>
 			</scroll-view>
-			<k-scroll-view @onPullDown="handlePullDown" @onPullUp="handleLoadMore" class="goods-box">
+			<scroll-view class="goods-box" scroll-y="true" @scrolltolower="handleLoadMore()">
 				<view class="goods-row" v-for="(item, index) in goodsList" :key="index" @click="goToGoodDetails(item)">
 					<image class="goods-img" :src="item.imgPath"></image>
 					<view class="goods-info">
@@ -33,7 +33,7 @@
 						</view>
 					</view>
 				</view>
-			</k-scroll-view>
+			</scroll-view>
 		</view>
 		<u-modal v-model="modalShow" content="是否将该商品添加至购物车" @confirm="submitAddCart()" :async-close="true"
 		 :show-cancel-button="true"></u-modal>
@@ -64,25 +64,36 @@
 			}
 		},
 		onShow() {
-			this.sortFirstList = []
-			NET.request(API.getSortList, {}, 'POST').then(res => {
-				this.sortFirstList = res.data
-				if (res.data.length) {
-					this.checkFirstSort(res.data[0])
-				} else {
+			this.getBaseData()
+		},
+		onPullDownRefresh() {
+			this.getBaseData()
+			uni.stopPullDownRefresh();
+		},
+		methods: {
+			//  获取全部数据
+			getBaseData() {
+				this.pageIndex = 1
+				this.sortFirstList = []
+				this.sortSecondList = []
+				this.goodsList = []
+				NET.request(API.getSortList, {}, 'POST').then(res => {
+					this.sortFirstList = res.data
+					if (res.data.length) {
+						this.checkFirstSort(res.data[0])
+					} else {
+						this.$refs.uTips.show({
+							title: '获取商品分类失败',
+							type: 'warning',
+						})
+					}
+				}).catch(error => {
 					this.$refs.uTips.show({
 						title: '获取商品分类失败',
 						type: 'warning',
 					})
-				}
-			}).catch(error => {
-				this.$refs.uTips.show({
-					title: '获取商品分类失败',
-					type: 'warning',
 				})
-			})
-		},
-		methods: {
+			},
 			//  切换一级分类
 			checkFirstSort(item) {
 				this.sortFirstCode = item.cateCode
@@ -108,26 +119,15 @@
 				this.pageIndex = 1
 				this.getGoodsList()
 			},
-			//  下拉刷新
-			handlePullDown(stopLoad) {
-				this.pageIndex = 1
-				this.goodsList = []
-				this.getGoodsList(stopLoad)
-				stopLoad ? stopLoad() : '';
-			},
 			//  懒加载
 			handleLoadMore(stopLoad) {
 				if (!this.isOver) {
 					this.pageIndex++
 					this.getGoodsList()
-				} else {
-					stopLoad ? stopLoad({
-						isEnd: true
-					}) : '';
 				}
 			},
 			//  获取商品
-			getGoodsList(stopLoad) {
+			getGoodsList() {
 				NET.request(API.getGoodsBySort, {
 					name: this.goodName,
 					oneId: this.sortFirstCode,
@@ -275,7 +275,6 @@
 				height: calc(100% - 44px) !important;
 				padding: 6px 0 0px 0;
 				box-sizing: border-box;
-				overflow-y: auto;
 				float: left;
 
 				.goods-row {

+ 15 - 8
pages/user/index.vue

@@ -96,16 +96,23 @@
 			this.userData = uni.getStorageSync("userData")
 		},
 		onShow() {
-			NET.request(API.getMainInfo + this.userData.userId, {}, 'GET').then(res => {
-				this.mainInfo = res.data
-			}).catch(error => {
-				this.$refs.uTips.show({
-					title: '获取个人信息失败',
-					type: 'warning',
-				})
-			})
+			this.getBaseData()
+		},
+		onPullDownRefresh() {
+			this.getBaseData()
 		},
 		methods: {
+			//  获取全部数据
+			getBaseData() {
+				NET.request(API.getMainInfo + this.userData.userId, {}, 'GET').then(res => {
+					this.mainInfo = res.data
+				}).catch(error => {
+					this.$refs.uTips.show({
+						title: '获取个人信息失败',
+						type: 'warning',
+					})
+				})
+			},
 			//  我的种植
 			entrustClick() {
 				uni.navigateTo({

+ 9 - 1
pagesGood/evaluateList.vue

@@ -43,6 +43,11 @@
 			this.goodId = options.goodId
 		},
 		onShow() {
+			this.getMessageList('refresh')
+		},
+		onPullDownRefresh() {
+			this.pageIndex = 1
+			this.assessList = []
 			this.getMessageList()
 		},
 		methods: {
@@ -54,8 +59,11 @@
 				}
 			},
 			//  获取全部留言
-			getMessageList() {
+			getMessageList(type) {
 				NET.request(API.getAssessList + this.goodId + '/' + this.pageIndex + '/10', {}, 'GET').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this.isOver = res.data.list.length != 10
 					this.assessList = this.assessList.concat(res.data.list)
 				}).catch(error => {

+ 14 - 15
pagesGood/goodList.vue

@@ -4,7 +4,9 @@
 			<uni-search-bar ref="searchBar" radius="5" placeholder="搜索" :defaultText="goodName" clearButton="auto" cancelButton="none"
 			 bgColor="#ffffff" @confirm="search" class="search-bar" />
 		</view>
-		<k-scroll-view @onPullDown="handlePullDown" @onPullUp="handleLoadMore" class="goods-box">
+		<scroll-view class="message-list-box" scroll-y="true" @scrolltolower="handleLoadMore()">
+		</scroll-view>
+		<scroll-view class="goods-box" scroll-y="true" @scrolltolower="handleLoadMore()">
 			<view class="goods-row" v-for="(item, index) in goodsList" :key="index" @click="goToGoodDetails(item)">
 				<image class="goods-img" :src="item.imgPath"></image>
 				<view class="goods-info">
@@ -26,7 +28,7 @@
 					</view>
 				</view>
 			</view>
-		</k-scroll-view>
+		</scroll-view>
 		<u-modal v-model="modalShow" content="是否将该商品添加至购物车" @confirm="submitAddCart()" :async-close="true"
 		 :show-cancel-button="true"></u-modal>
 		<u-top-tips ref="uTips"></u-top-tips>
@@ -63,6 +65,11 @@
 				this.$refs.searchBar.searchVal = this.goodName
 			}
 		},
+		onPullDownRefresh() {
+			this.goodsList = []
+			this.pageIndex = 1
+			this.getGoodsList('refresh')
+		},
 		methods: {
 			//  搜索商品
 			search(data) {
@@ -71,32 +78,24 @@
 				this.pageIndex = 1
 				this.getGoodsList()
 			},
-			//  下拉刷新
-			handlePullDown(stopLoad) {
-				this.pageIndex = 1
-				this.goodsList = []
-				this.getGoodsList(stopLoad)
-				stopLoad ? stopLoad() : '';
-			},
 			//  懒加载
-			handleLoadMore(stopLoad) {
+			handleLoadMore() {
 				if (!this.isOver) {
 					this.pageIndex++
 					this.getGoodsList()
-				} else {
-					stopLoad ? stopLoad({
-						isEnd: true
-					}) : '';
 				}
 			},
 			//  获取商品
-			getGoodsList(stopLoad) {
+			getGoodsList(type) {
 				NET.request(API.getGoodsByType, {
 					name: this.goodName,
 					productType: this.goodType,
 					pageIndex: this.pageIndex,
 					pageSize: 10,
 				}, 'POST').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this.isOver = res.data.list.length != 10
 					this.goodsList = this.goodsList.concat(res.data.list)
 				}).catch(error => {

+ 12 - 15
pagesGood/videoList.vue

@@ -4,7 +4,7 @@
 			<uni-search-bar ref="searchBar" radius="5" placeholder="搜索" clearButton="auto" cancelButton="none" bgColor="#F8F8F8"
 			 @confirm="search" class="search-bar" />
 		</view>
-		<k-scroll-view @onPullDown="handlePullDown" @onPullUp="handleLoadMore" class="video-box">
+		<scroll-view class="video-box" scroll-y="true" @scrolltolower="handleLoadMore()">
 			<view class="video-col" v-for="(item, index) in videoList" :key="index" @click="goToVideoDetail(item)">
 				<image class="video-img" :src="videoType == 1 ? item.imgUrl : item.coverUrl"></image>
 				<view class="video-title">{{videoType == 1 ? item.liveName : item.videoName}}</view>
@@ -14,7 +14,7 @@
 					<view class="video-mask-text">未开播</view>
 				</view>
 			</view>
-		</k-scroll-view>
+		</scroll-view>
 		<u-top-tips ref="uTips"></u-top-tips>
 	</view>
 </template>
@@ -41,6 +41,11 @@
 			}
 			this.getVideoList()
 		},
+		onPullDownRefresh() {
+			this.pageIndex = 1
+			this.videoList = []
+			this.getVideoList('refresh')
+		},
 		methods: {
 			//  搜索直播
 			search(data) {
@@ -49,30 +54,22 @@
 				this.pageIndex = 1
 				this.getVideoList()
 			},
-			//  下拉刷新
-			handlePullDown(stopLoad) {
-				this.pageIndex = 1
-				this.videoList = []
-				this.getVideoList(stopLoad)
-				stopLoad ? stopLoad() : '';
-			},
 			//  懒加载
-			handleLoadMore(stopLoad) {
+			handleLoadMore() {
 				if (!this.isOver) {
 					this.pageIndex++
 					this.getVideoList()
-				} else {
-					stopLoad ? stopLoad({
-						isEnd: true
-					}) : '';
 				}
 			},
 			//  获取直播列表
-			getVideoList(stopLoad) {
+			getVideoList(type) {
 				NET.request((this.videoType == 1 ? API.getLiveTelecastList : API.getShortVideo) + '/' + this.pageIndex + '/10', {
 					liveName: this.videoName,
 					videoName: this.videoName,
 				}, 'GET').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this.isOver = res.data.list.length != 10
 					this.videoList = this.videoList.concat(res.data.list)
 				}).catch(res => {

+ 7 - 1
pagesMain/addressList.vue

@@ -49,10 +49,16 @@
 		onShow() {
 			this.getAddress()
 		},
+		onPullDownRefresh() {
+			this.getAddress('refresh')
+		},
 		methods: {
 			//  查询地址
-			getAddress() {
+			getAddress(type) {
 				NET.request(API.getAddressList, {}, 'POST').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this.addressList = res.data
 				}).catch(error => {
 					this.$refs.uTips.show({

+ 9 - 1
pagesMain/couponList.vue

@@ -89,6 +89,11 @@
 		onLoad() {
 			this.getList()
 		},
+		onPullDownRefresh() {
+			this['pageIndex' + (this.tabIndex + 1)] = 1
+			this['couponList' + (this.tabIndex + 1)] = []
+			this.getList('refresh')
+		},
 		methods: {
 			//  切换tab
 			changeTabs(index) {
@@ -107,13 +112,16 @@
 				}
 			},
 			//  获取列表数据
-			getList() {
+			getList(refresh) {
 				this.loadingData = true
 				NET.request(API.getCouponList, {
 					isUse: this.tabIndex == 0 ? null : (this.tabIndex == 1 ? 0 : 1),
 					pageIndex: this['pageIndex' + (this.tabIndex + 1)],
 					pageSize: 10,
 				}, 'POST').then(res => {
+					if (refresh == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					if (res.isSuccess) {
 						if (res.data.list.length) {
 							this.loadingData = false

+ 10 - 1
pagesMain/entrustList.vue

@@ -46,9 +46,15 @@
 			}
 		},
 		onShow() {
+			this.pageIndex = 1
 			this.entrustList = []
 			this.getEntrustList()
 		},
+		onPullDownRefresh() {
+			this.pageIndex = 1
+			this.entrustList = []
+			this.getEntrustList('refresh')
+		},
 		methods: {
 			//  懒加载
 			handleLoadMore() {
@@ -58,12 +64,15 @@
 				}
 			},
 			//  获取委托
-			getEntrustList() {
+			getEntrustList(refresh) {
 				NET.request(API.getEvaluateList, {
 					productId: this.productData.productId,
 					pageIndex: this.pageIndex,
 					pageSize: 10,
 				}, 'POST').then(res => {
+					if (refresh == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					if (res.isSuccess) {
 						if (res.data.list.length) {
 							this.isOver = res.data.list.length != 10

+ 12 - 1
pagesMain/integralList.vue

@@ -75,6 +75,14 @@
 			this.getIntegraList(1)
 			this.getIntegraList(2)
 		},
+		onPullDownRefresh() {
+			this.pageIndex1 = 1
+			this.integralList1 = []
+			this.pageIndex2 = 1
+			this.integralList2 = []
+			this.getIntegraList(1, 'refresh')
+			this.getIntegraList(2, 'refresh')
+		},
 		methods: {
 			//  切换tab
 			changeTabs(index) {
@@ -95,12 +103,15 @@
 				}
 			},
 			//  获取全部商品
-			getIntegraList(type) {
+			getIntegraList(type, refresh) {
 				NET.request(API.getIntegralList, {
 					behavior: type,
 					pageIndex: this['pageIndex' + type],
 					pageSize: 10,
 				}, 'POST').then(res => {
+					if (refresh == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this['isOver' + type] = res.data.integralList.length != 10
 					this['integralList' + type] = this['integralList' + type].concat(res.data.integralList)
 				}).catch(res => {

+ 9 - 1
pagesMain/messageList.vue

@@ -42,6 +42,11 @@
 			this.messageList = []
 			this.getMessageList()
 		},
+		onPullDownRefresh() {
+			this.pageIndex = 1
+			this.messageList = []
+			this.getMessageList('refresh')
+		},
 		methods: {
 			//  懒加载
 			handleLoadMore() {
@@ -51,11 +56,14 @@
 				}
 			},
 			//  获取全部留言
-			getMessageList() {
+			getMessageList(type) {
 				NET.request(API.getMessageList + this.pageIndex + '/10', {
 					flag: 1,
 					orderId: this.orderId
 				}, 'GET').then(res => {
+					if (type == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this.isOver = res.data.list.length != 10
 					this.messageList = this.messageList.concat(res.data.list)
 				}).catch(error => {

+ 10 - 1
pagesMain/orderList.vue

@@ -67,6 +67,12 @@
 			this.getOrderList(options.type)
 		},
 		onReady(options) {},
+		onPullDownRefresh() {
+			this['isOver' + (this.tabIndex + 1)] = false
+			this['pageIndex' + (this.tabIndex + 1)] = 1
+			this['orderList' + (this.tabIndex + 1)] = []
+			this.getOrderList(this.tabIndex + 1, 'refresh')
+		},
 		methods: {
 			//  切换tab
 			changeTabs(index) {
@@ -88,10 +94,13 @@
 				}
 			},
 			//  获取全部商品
-			getOrderList(type) {
+			getOrderList(type, refresh) {
 				NET.request(API.getOrderList + this['pageIndex' + type] + '/10', {
 					flag: type,
 				}, 'GET').then(res => {
+					if (refresh == 'refresh') {
+						uni.stopPullDownRefresh();
+					}
 					this['isOver' + type] = res.data.list.length != 10
 					this['orderList' + type] = this['orderList' + type].concat(res.data.list)
 				}).catch(error => {