Merge pull request 'dengjie commit : 首页产品列表下拉刷新分页展示产品' (#38) from DJ into dev
Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/38
This commit is contained in:
@@ -41,28 +41,41 @@
|
||||
imgUrl: '',
|
||||
tagsArray: [],
|
||||
productList: [],
|
||||
pageNum: 1, // 当前页
|
||||
pageSize: 4, // 每页条数
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getProducts()
|
||||
this.imgUrl = uni.getStorageSync('img_url')
|
||||
|
||||
},
|
||||
|
||||
methods: {
|
||||
//获取产品列表
|
||||
getProducts() {
|
||||
// console.log("子组件的获取产品列表方法====");
|
||||
this.$apiServe.getProducts().then(res => {
|
||||
// console.log(res.data.data)
|
||||
this.$apiServe.getProducts({
|
||||
pageSize: this.pageSize,
|
||||
pageNum: this.pageNum
|
||||
}).then(res => {
|
||||
|
||||
let tags = res.data.data
|
||||
for (const item of tags) {
|
||||
let tag = item.tags
|
||||
this.tagsArray = tag.split(',')
|
||||
item.tags = this.tagsArray[0]
|
||||
}
|
||||
this.productList = res.data.data
|
||||
|
||||
}).finally(_ => {})
|
||||
// if (res.data.data.length == 0) {
|
||||
// requestTask.abort()
|
||||
// }
|
||||
console.log(res);
|
||||
// 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
|
||||
this.productList = [...this.productList, ...res.data.data]
|
||||
|
||||
}).finally(_ => {
|
||||
|
||||
})
|
||||
},
|
||||
//点击图片跳转到详情页
|
||||
toDetailPage(item) {
|
||||
|
||||
@@ -64,7 +64,6 @@
|
||||
getCertifiedCjDetail() {
|
||||
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
|
||||
console.log('认证厂家详情页', res)
|
||||
|
||||
// this.detailList = res.data.data
|
||||
}).finally(_ => {})
|
||||
},
|
||||
|
||||
@@ -61,19 +61,18 @@
|
||||
swiperList: [],
|
||||
}
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
// this.$refs.getProducts.query.pageNum = 1
|
||||
// this.$refs.getProducts.productList = []
|
||||
|
||||
onReachBottom() {
|
||||
// console.log('pageNum===', this.$refs.getProducts);
|
||||
this.$refs.getProducts.pageNum += 1
|
||||
this.$refs.getProducts.getProducts()
|
||||
|
||||
//关闭下拉刷新
|
||||
uni.stopPullDownRefresh()
|
||||
// uni.stopPullDownRefresh()
|
||||
},
|
||||
onLoad() {
|
||||
this.getCategories()
|
||||
this.getBanner()
|
||||
this.getImgUrl()
|
||||
// this.$refs.getProducts.getProducts()
|
||||
this.imgUrl = uni.getStorageSync('img_url')
|
||||
},
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {loginSys} from '@/service/request.js'
|
||||
import {
|
||||
loginSys
|
||||
} from '@/service/request.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@@ -35,8 +37,6 @@
|
||||
loginSys(code).then(res => {
|
||||
console.log(res);
|
||||
|
||||
|
||||
|
||||
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
|
||||
//接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
const serverHost = 'https://pupil.hchyun.com/api' // https://api-ugo-web.itheima.net'
|
||||
function isOutTime(res) {
|
||||
if (res.data.message === '请先登录') {
|
||||
@@ -190,10 +189,10 @@ const apiService = {
|
||||
})
|
||||
},
|
||||
// 获取产品列表
|
||||
getProducts() {
|
||||
const url = `/home/product?sortType=1&pageSize=4&pageNum=1`
|
||||
getProducts(data) {
|
||||
const url = `/home/product?sortType=1`
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(service.get(url))
|
||||
resolve(service.get(url, data))
|
||||
})
|
||||
},
|
||||
// 获取产品详情
|
||||
@@ -291,7 +290,9 @@ const apiService = {
|
||||
decrypt(data) {
|
||||
const url = `/api`
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(service.post(url, { data }))
|
||||
resolve(service.post(url, {
|
||||
data
|
||||
}))
|
||||
})
|
||||
},
|
||||
// 国密sm4加密
|
||||
|
||||
Reference in New Issue
Block a user