dengjie commit : 首页产品列表下拉刷新分页展示产品
This commit is contained in:
@@ -41,28 +41,41 @@
|
|||||||
imgUrl: '',
|
imgUrl: '',
|
||||||
tagsArray: [],
|
tagsArray: [],
|
||||||
productList: [],
|
productList: [],
|
||||||
|
pageNum: 1, // 当前页
|
||||||
|
pageSize: 4, // 每页条数
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getProducts()
|
this.getProducts()
|
||||||
this.imgUrl = uni.getStorageSync('img_url')
|
this.imgUrl = uni.getStorageSync('img_url')
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
//获取产品列表
|
//获取产品列表
|
||||||
getProducts() {
|
getProducts() {
|
||||||
// console.log("子组件的获取产品列表方法====");
|
this.$apiServe.getProducts({
|
||||||
this.$apiServe.getProducts().then(res => {
|
pageSize: this.pageSize,
|
||||||
// console.log(res.data.data)
|
pageNum: this.pageNum
|
||||||
|
}).then(res => {
|
||||||
|
|
||||||
let tags = res.data.data
|
let tags = res.data.data
|
||||||
for (const item of tags) {
|
for (const item of tags) {
|
||||||
let tag = item.tags
|
let tag = item.tags
|
||||||
this.tagsArray = tag.split(',')
|
this.tagsArray = tag.split(',')
|
||||||
item.tags = this.tagsArray[0]
|
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) {
|
toDetailPage(item) {
|
||||||
|
|||||||
@@ -64,7 +64,6 @@
|
|||||||
getCertifiedCjDetail() {
|
getCertifiedCjDetail() {
|
||||||
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
|
this.$apiServe.getCertifiedCjDetail(this.id).then(res => {
|
||||||
console.log('认证厂家详情页', res)
|
console.log('认证厂家详情页', res)
|
||||||
|
|
||||||
// this.detailList = res.data.data
|
// this.detailList = res.data.data
|
||||||
}).finally(_ => {})
|
}).finally(_ => {})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,19 +61,18 @@
|
|||||||
swiperList: [],
|
swiperList: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onPullDownRefresh() {
|
onReachBottom() {
|
||||||
// this.$refs.getProducts.query.pageNum = 1
|
// console.log('pageNum===', this.$refs.getProducts);
|
||||||
// this.$refs.getProducts.productList = []
|
this.$refs.getProducts.pageNum += 1
|
||||||
|
|
||||||
this.$refs.getProducts.getProducts()
|
this.$refs.getProducts.getProducts()
|
||||||
|
|
||||||
//关闭下拉刷新
|
//关闭下拉刷新
|
||||||
uni.stopPullDownRefresh()
|
// uni.stopPullDownRefresh()
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.getCategories()
|
this.getCategories()
|
||||||
this.getBanner()
|
this.getBanner()
|
||||||
this.getImgUrl()
|
this.getImgUrl()
|
||||||
// this.$refs.getProducts.getProducts()
|
|
||||||
this.imgUrl = uni.getStorageSync('img_url')
|
this.imgUrl = uni.getStorageSync('img_url')
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {loginSys} from '@/service/request.js'
|
import {
|
||||||
|
loginSys
|
||||||
|
} from '@/service/request.js'
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@@ -32,11 +34,9 @@
|
|||||||
|
|
||||||
|
|
||||||
// 调用登录接口 拿到token 传手机code,更新手机号码
|
// 调用登录接口 拿到token 传手机code,更新手机号码
|
||||||
loginSys(code).then(res=>{
|
loginSys(code).then(res => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
|
//登录完成后使用手机code换取手机号,调用/user/getMobileByMnp接口
|
||||||
//接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
|
//接口详细链接 https://docs.apipost.cn/preview/468be606f65cae75/3f2f988ddf82dd8e
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
const serverHost = 'https://pupil.hchyun.com/api' // https://api-ugo-web.itheima.net'
|
const serverHost = 'https://pupil.hchyun.com/api' // https://api-ugo-web.itheima.net'
|
||||||
function isOutTime(res) {
|
function isOutTime(res) {
|
||||||
if (res.data.message === '请先登录') {
|
if (res.data.message === '请先登录') {
|
||||||
@@ -190,10 +189,10 @@ const apiService = {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取产品列表
|
// 获取产品列表
|
||||||
getProducts() {
|
getProducts(data) {
|
||||||
const url = `/home/product?sortType=1&pageSize=4&pageNum=1`
|
const url = `/home/product?sortType=1`
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve(service.get(url))
|
resolve(service.get(url, data))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 获取产品详情
|
// 获取产品详情
|
||||||
@@ -291,7 +290,9 @@ const apiService = {
|
|||||||
decrypt(data) {
|
decrypt(data) {
|
||||||
const url = `/api`
|
const url = `/api`
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
resolve(service.post(url, { data }))
|
resolve(service.post(url, {
|
||||||
|
data
|
||||||
|
}))
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 国密sm4加密
|
// 国密sm4加密
|
||||||
|
|||||||
Reference in New Issue
Block a user