From 56bf10b47feb44aeecebc33ff87bc4dc2775d7ab Mon Sep 17 00:00:00 2001
From: clay <209192278@qq.com>
Date: Thu, 29 Dec 2022 09:48:45 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E5=BD=93=E8=8E=B7=E5=8F=96=E9=A6=96?=
=?UTF-8?q?=E9=A1=B5=E4=BA=A7=E5=93=81=E5=88=97=E8=A1=A8=E6=97=B6=EF=BC=8C?=
=?UTF-8?q?=E8=BF=94=E5=9B=9E=E6=95=B0=E6=8D=AElength=E4=B8=BA0=E6=97=B6?=
=?UTF-8?q?=E5=8F=96=E6=B6=88=E5=8F=91=E9=80=81=E8=AF=B7=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
components/products/products.vue | 5 +----
pages/index/index.vue | 15 +++++++++------
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/components/products/products.vue b/components/products/products.vue
index 372e49f..7f60bef 100644
--- a/components/products/products.vue
+++ b/components/products/products.vue
@@ -65,11 +65,8 @@
this.tagsArray = tag.split(',')
item.tags = this.tagsArray[0]
}
+ this.$emit("getChild", tags.length);
- // if (res.data.data.length == 0) {
- // requestTask.abort()
- // }
- console.log(res);
// 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
this.productList = [...this.productList, ...res.data.data]
diff --git a/pages/index/index.vue b/pages/index/index.vue
index cf9b3f6..e6ce84b 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -38,7 +38,7 @@
-
+
@@ -59,15 +59,14 @@
],
imgUrl: '',
swiperList: [],
+ reachBottomLength: ''
}
},
onReachBottom() {
- // console.log('pageNum===', this.$refs.getProducts);
this.$refs.getProducts.pageNum += 1
- this.$refs.getProducts.getProducts()
-
- //关闭下拉刷新
- // uni.stopPullDownRefresh()
+ if (this.reachBottomLength !== 0) {
+ this.$refs.getProducts.getProducts()
+ }
},
onLoad() {
this.getCategories()
@@ -77,6 +76,10 @@
},
methods: {
+ //获取子组件的getProducts方法返回数据的length,用于当length为0时取消发送请求
+ getChild(e) {
+ this.reachBottomLength = e
+ },
//获取一级分类
getCategories() {
this.$apiServe.getCategories().then(res => {
From 27787d3300cf4acdf761bbf76b74e72cc53bf7e2 Mon Sep 17 00:00:00 2001
From: clay <209192278@qq.com>
Date: Wed, 4 Jan 2023 16:46:46 +0800
Subject: [PATCH 2/2] 1
---
components/news/news.vue | 7 +------
pages/index/index.vue | 24 ++++++++++++++++++++----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/components/news/news.vue b/components/news/news.vue
index 804dea6..05645e5 100644
--- a/components/news/news.vue
+++ b/components/news/news.vue
@@ -36,14 +36,9 @@
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
- //获取行业新闻
- // {
- // pageSize: 2,
- // pageNum: 1
- // }
getNews() {
this.$apiServe.getNews().then(res => {
- // console.log('行业新闻', res.data.data)
+ console.log('行业新闻', res.data.data)
for (const item of res.data.data) {
item.pub_time_str = dateFormat(item.pub_time_str)
}
diff --git a/pages/index/index.vue b/pages/index/index.vue
index e6ce84b..497fcb1 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -39,6 +39,9 @@
+
+ 没有更多数据了
@@ -79,6 +82,7 @@
//获取子组件的getProducts方法返回数据的length,用于当length为0时取消发送请求
getChild(e) {
this.reachBottomLength = e
+
},
//获取一级分类
getCategories() {
@@ -103,10 +107,18 @@
})
},
getphonenumber(e) {
+ let that = this
+ console.log(e);
+ //必须要公司注册,且微信认证过的小程序,才能获取到手机号的接口权限
+ if (e.detail.errMsg == "getPhoneNumber:fail ") {
+ console.log('用户拒绝提供手机号');
+ } else {
+ console.log('用户同意提供手机号');
+ }
const {
- code
+ phoneCode
} = e.detail;
- console.log("手机code : ", code);
+ console.log("手机code : ", phoneCode);
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
@@ -118,7 +130,12 @@
console.log("登录code", code);
//客户端成功获取授权临时票据(code),向业务服务器发起登录请求。
// 调用登录接口 拿到token 传手机code,更新手机号码
-
+ let fromData = {
+ code: code
+ }
+ that.$apiServe.login(fromData).then(res => {
+ console.log(res);
+ })
},
fail: function(err) {
// 登录授权失败
@@ -134,7 +151,6 @@
},
getImgUrl() {
this.$apiServe.getImgUrl().then(res => {
- // console.log(res)
try {
uni.setStorageSync('img_url', res.data.data.img_url);
} catch (e) {