冲突解决

This commit is contained in:
”chenxuelian“
2023-01-06 20:49:54 +08:00
24 changed files with 752 additions and 794 deletions

View File

@@ -14,7 +14,7 @@
<view class="classify">
<u-grid :border="false" col="5">
<u-grid-item v-for="(listItem,listIndex) in classifyList" :key="listIndex" @click="toClassify(listItem.id)">
<u--image :src="listItem.icon" width="86rpx" height="86rpx" :lazy-load="true">
<u--image :src="imgUrl+listItem.icon" width="86rpx" height="86rpx" :lazy-load="true">
</u--image>
<!-- <u-icon size="86rpx" :name="listItem.icon"></u-icon> -->
<text class="grid-text">{{listItem.name}}</text>
@@ -23,7 +23,7 @@
</view>
<!-- 分类模块下的轮播图 -->
<view>
<u-swiper :list="swiperList" indicatorMode="line" radius="0" circular></u-swiper>
<u-swiper :list="swiperList" keyName="img" indicatorMode="line" radius="0" circular></u-swiper>
</view>
@@ -33,12 +33,15 @@
</view> -->
<!-- 选项卡: 上架时间和点赞量 -->
<view>
<u-tabs :list="tabList" lineColor="#15CA65" :is-scroll="false"
activeStyle="color:#15CA65;font-weight: bold;">
<u-tabs :list="tabList" lineColor="#15CA65" scrollable="false"
activeStyle="color:#15CA65;font-weight: bold;" :current="tabCurrent" @change="tabChange">
</u-tabs>
</view>
<!-- 产品 -->
<products ref="getProducts"></products>
<products ref="getProductsByTime"></products>
<view style="font-size: 24rpx;color: #A3A3A3;text-align: center;padding: 26rpx 0;"
v-show="reachBottomLength===0">
没有更多数据了</view>
</view>
</view>
</template>
@@ -46,51 +49,12 @@
import {
serverHost
} from '@/service/request.js'
import loginVue from '../my/login/login.vue'
export default {
data() {
return {
classifyList: [
// {
// src: '/static/classify/sy_icon_hp.png',
// title: '烘培宝典'
// },
// {
// src: '/static/classify/sy_icon_ls.png',
// title: '零食铺子'
// },
// {
// src: '/static/classify/sy_icon_yp.png',
// title: '饮品大全'
// },
// {
// src: '/static/classify/sy_icon_tw.png',
// title: '调味菜单'
// },
// {
// src: '/static/classify/sy_icon_rs.png',
// title: '肉食荟萃'
// },
// {
// src: '/static/classify/sy_icon_np.png',
// title: '乳品手册'
// },
// {
// src: '/static/classify/sy_icon_gs.png',
// title: '果蔬地图'
// },
// {
// src: '/static/classify/sy_icon_sj.png',
// title: '食界新贵'
// },
// {
// src: '/static/classify/sy_icon_hz.png',
// title: '欢喜盒子'
// },
// {
// src: '/static/classify/sy_icon_cy.png',
// title: '创意工具'
// },
],
classifyList: [],
tabCurrent: 0,
tabList: [{
name: '上架时间'
},
@@ -98,63 +62,61 @@
name: '点赞量'
},
],
// swiperList: [
// 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
// 'https://cdn.uviewui.com/uview/swiper/swiper3.png'
// ],
imgUrl: '',
swiperList: [],
reachBottomLength: '',
productList: [],
pageNum: 1,
sortType: ''
}
},
onPullDownRefresh() {
// this.$refs.getProducts.query.pageNum = 1
// this.$refs.getProducts.productList = []
this.$refs.getProducts.getProducts()
//关闭下拉刷新
uni.stopPullDownRefresh()
onReachBottom() {
this.pageNum += 1
if (this.reachBottomLength !== 0) {
this.getNewProducts()
}
},
onLoad() {
this.getCategories()
this.getBanner()
this.getImgUrl()
// this.$refs.getProducts.getProducts()
this.getToken()
this.imgUrl = uni.getStorageSync('img_url')
},
methods: {
//获取一级分类
getCategories() {
this.$apiServe.getCategories().then(res => {
// console.log(res.data.data)
this.classifyList = res.data.data
}).finally(_ => {})
//点击上架时间和点赞量切换页面
tabChange(data) {
this.tabCurrent = data.index
uni.$emit("getCurrent", data.index);
if (data.index == 0) {
this.sortType = 1
} else if (data.index == 1) {
this.$refs.getProductsByTime.getProducts()
this.sortType = 2
}
},
//获取首页轮播图
getBanner() {
this.$apiServe.getBanner().then(res => {
// console.log(res.data.data);
let banner = res.data.data
for (const item of banner) {
this.swiperList = item.img
// console.log(item);
//下拉刷新获取新数据
getNewProducts() {
this.$apiServe.getProducts({
sortType: this.sortType,
pageSize: 4,
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.swiperList = res.data.data
}).finally(_ => {})
},
//点击一级分类
// click(listIndex) {
// this.$refs.uToast.success(`点击了第${listIndex}个`)
// },
//点击搜索框跳转到搜索页面
toSearch() {
uni.navigateTo({
url: '../../packageSearch/search/search'
if (tags.length === 0) {
this.reachBottomLength = tags.length
}
this.$refs.getProductsByTime.productList.push(...res.data.data)
})
},
getphonenumber(e) {
const {
code
} = e.detail;
console.log("手机code : ", code);
//获取token
getToken() {
var that = this
uni.login({
"provider": "weixin",
"onlyAuthorize": true, // 微信登录仅请求授权认证
@@ -162,13 +124,13 @@
const {
code
} = event
console.log("登录code", code);
//客户端成功获取授权临时票据code,向业务服务器发起登录请求。
// 调用登录接口 拿到token 传手机code,更新手机号码
that.$apiServe.login({
code: code
}).then(res => {
var data = res.data.data
// console.log('登录code换取的信息', data);
uni.setStorageSync('token', data.token);
})
},
fail: function(err) {
// 登录授权失败
@@ -176,6 +138,40 @@
}
})
},
//获取手机code
getphonenumber(e) {
let that = this
// const {
// code
// } = e.detail;
// console.log("手机code : ", code);
},
//获取子组件的getProducts方法返回数据的length用于当length为0时取消发送请求
// getChild(e) {
// this.reachBottomLength = e
// },
//获取一级分类
getCategories() {
this.$apiServe.getCategories().then(res => {
this.classifyList = res.data.data
}).finally(_ => {})
},
//获取首页轮播图
getBanner() {
this.$apiServe.getBanner().then(res => {
let banner = res.data.data
for (const item of banner) {
item.img = this.imgUrl + item.img
}
this.swiperList = res.data.data
}).finally(_ => {})
},
//点击搜索框跳转到搜索页面
toSearch() {
uni.navigateTo({
url: '../../packageSearch/search/search'
})
},
//点击一级分类跳转到分类页
toClassify(id) {
uni.navigateTo({
@@ -184,7 +180,6 @@
},
getImgUrl() {
this.$apiServe.getImgUrl().then(res => {
console.log(res)
try {
uni.setStorageSync('img_url', res.data.data.img_url);
} catch (e) {