瀏覽代碼

下拉刷新

lilei 4 年之前
父節點
當前提交
f50fa02d6b
共有 3 個文件被更改,包括 38 次插入18 次删除
  1. 3 3
      pages.json
  2. 9 0
      pages/goods/goods.vue
  3. 26 15
      pages/goods/index.vue

+ 3 - 3
pages.json

@@ -19,8 +19,8 @@
 		{
 		{
 			"path": "pages/goods/index", // 商城
 			"path": "pages/goods/index", // 商城
 			"style": {
 			"style": {
-				"navigationBarTitleText": "乐色管家",
-				"enablePullDownRefresh": false
+				"navigationBarTitleText": "乐色商城",
+				"enablePullDownRefresh": true
 			}
 			}
 		},
 		},
 		{
 		{
@@ -150,7 +150,7 @@
             "style" :                                                                                    
             "style" :                                                                                    
             {
             {
                 "navigationBarTitleText": "商品",
                 "navigationBarTitleText": "商品",
-                "enablePullDownRefresh": false
+                "enablePullDownRefresh": true
             }
             }
             
             
         },
         },

+ 9 - 0
pages/goods/goods.vue

@@ -32,6 +32,15 @@
 			this.goldLimit = opts.goldLimit
 			this.goldLimit = opts.goldLimit
 			this.getGoods()
 			this.getGoods()
 		},
 		},
+		// 下拉刷新
+		onPullDownRefresh() {
+			console.log('refresh')
+			this.pageNo = 1
+			this.getGoods()
+			setTimeout(function () {
+				uni.stopPullDownRefresh()
+			}, 200)
+		},
 		methods: {
 		methods: {
 			// 查询商品
 			// 查询商品
 			getGoods(item,index){
 			getGoods(item,index){

+ 26 - 15
pages/goods/index.vue

@@ -38,23 +38,34 @@
 				goodsType:[], // 商品分类
 				goodsType:[], // 商品分类
 			}
 			}
 		},
 		},
-		onShow() {
-			this.getbannerList()
-			this.goodsList = []
-			getGoodsClass({}).then(res => {
-				console.log(res)
-				if(res.status == 200){
-					this.goodsType = res.data
-					this.goodsType.map((item,index) => {
-						this.getGoods(item,index)
-					})
-				}else{
-					this.goodsList = []
-					this.noDataText = '暂无商品'
-				}
-			})
+		onLoad() {
+			this.pageInit()
+		},
+		// 下拉刷新
+		onPullDownRefresh() {
+			console.log('refresh')
+			this.pageInit()
+			setTimeout(function () {
+				uni.stopPullDownRefresh()
+			}, 200)
 		},
 		},
 		methods: { 
 		methods: { 
+			pageInit(){
+				this.getbannerList()
+				this.goodsList = []
+				getGoodsClass({}).then(res => {
+					console.log(res)
+					if(res.status == 200){
+						this.goodsType = res.data
+						this.goodsType.map((item,index) => {
+							this.getGoods(item,index)
+						})
+					}else{
+						this.goodsList = []
+						this.noDataText = '暂无商品'
+					}
+				})
+			},
 			// 点击banner
 			// 点击banner
 			clickBanner(index){
 			clickBanner(index){
 				let row = this.imageTopList[index]
 				let row = this.imageTopList[index]