Merge pull request 'DJ' (#39) from DJ into dev

Reviewed-on: http://git.hchyun.com/feashow/pupil/pulls/39
This commit is contained in:
odjbin
2023-01-04 08:47:47 +00:00
3 changed files with 31 additions and 20 deletions

View File

@@ -36,14 +36,9 @@
this.imgUrl = uni.getStorageSync('img_url') this.imgUrl = uni.getStorageSync('img_url')
}, },
methods: { methods: {
//获取行业新闻
// {
// pageSize: 2,
// pageNum: 1
// }
getNews() { getNews() {
this.$apiServe.getNews().then(res => { this.$apiServe.getNews().then(res => {
// console.log('行业新闻', res.data.data) console.log('行业新闻', res.data.data)
for (const item of res.data.data) { for (const item of res.data.data) {
item.pub_time_str = dateFormat(item.pub_time_str) item.pub_time_str = dateFormat(item.pub_time_str)
} }

View File

@@ -65,11 +65,8 @@
this.tagsArray = tag.split(',') this.tagsArray = tag.split(',')
item.tags = this.tagsArray[0] 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] this.productList = [...this.productList, ...res.data.data]

View File

@@ -38,7 +38,10 @@
</u-tabs> </u-tabs>
</view> </view>
<!-- 产品 --> <!-- 产品 -->
<products ref="getProducts"></products> <products ref="getProducts" @getChild="getChild()"></products>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-if="reachBottomLength==0">
没有更多数据了</view>
</view> </view>
</view> </view>
</template> </template>
@@ -59,15 +62,14 @@
], ],
imgUrl: '', imgUrl: '',
swiperList: [], swiperList: [],
reachBottomLength: ''
} }
}, },
onReachBottom() { onReachBottom() {
// console.log('pageNum===', this.$refs.getProducts);
this.$refs.getProducts.pageNum += 1 this.$refs.getProducts.pageNum += 1
this.$refs.getProducts.getProducts() if (this.reachBottomLength !== 0) {
this.$refs.getProducts.getProducts()
//关闭下拉刷新 }
// uni.stopPullDownRefresh()
}, },
onLoad() { onLoad() {
this.getCategories() this.getCategories()
@@ -77,6 +79,11 @@
}, },
methods: { methods: {
//获取子组件的getProducts方法返回数据的length用于当length为0时取消发送请求
getChild(e) {
this.reachBottomLength = e
},
//获取一级分类 //获取一级分类
getCategories() { getCategories() {
this.$apiServe.getCategories().then(res => { this.$apiServe.getCategories().then(res => {
@@ -100,10 +107,18 @@
}) })
}, },
getphonenumber(e) { getphonenumber(e) {
let that = this
console.log(e);
//必须要公司注册,且微信认证过的小程序,才能获取到手机号的接口权限
if (e.detail.errMsg == "getPhoneNumber:fail ") {
console.log('用户拒绝提供手机号');
} else {
console.log('用户同意提供手机号');
}
const { const {
code phoneCode
} = e.detail; } = e.detail;
console.log("手机code : ", code); console.log("手机code : ", phoneCode);
uni.login({ uni.login({
"provider": "weixin", "provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证 "onlyAuthorize": true, // 微信登录仅请求授权认证
@@ -115,7 +130,12 @@
console.log("登录code", code); console.log("登录code", code);
//客户端成功获取授权临时票据code,向业务服务器发起登录请求。 //客户端成功获取授权临时票据code,向业务服务器发起登录请求。
// 调用登录接口 拿到token 传手机code,更新手机号码 // 调用登录接口 拿到token 传手机code,更新手机号码
let fromData = {
code: code
}
that.$apiServe.login(fromData).then(res => {
console.log(res);
})
}, },
fail: function(err) { fail: function(err) {
// 登录授权失败 // 登录授权失败
@@ -131,7 +151,6 @@
}, },
getImgUrl() { getImgUrl() {
this.$apiServe.getImgUrl().then(res => { this.$apiServe.getImgUrl().then(res => {
// console.log(res)
try { try {
uni.setStorageSync('img_url', res.data.data.img_url); uni.setStorageSync('img_url', res.data.data.img_url);
} catch (e) { } catch (e) {