fix: 修复myAttention页面样式问题,优化文本截断效果
This commit is contained in:
parent
60281f17ce
commit
efbe517a92
@ -186,24 +186,15 @@
|
||||
uni.stopPullDownRefresh()
|
||||
},
|
||||
onShow() {
|
||||
this.userInfo = uni.getStorageSync('userInfo')
|
||||
if (this.userInfo == null || this.userInfo.userType == '09') {
|
||||
this.showJoinImg = true
|
||||
} else {
|
||||
this.showJoinImg = false
|
||||
const newUserInfo = uni.getStorageSync('userInfo')
|
||||
// 只在用户信息发生变化时更新状态
|
||||
if (JSON.stringify(newUserInfo) !== JSON.stringify(this.userInfo)) {
|
||||
this.userInfo = newUserInfo
|
||||
this.showJoinImg = !this.userInfo || this.userInfo.userType === '09'
|
||||
|
||||
// 只在用户状态变化时重新加载数据
|
||||
this.resetAndLoadData()
|
||||
}
|
||||
// 重置分页参数
|
||||
this.pageNum = 1
|
||||
this.finished = false
|
||||
this.featurePageList = []
|
||||
this.getActivityList() // 获取活动列表
|
||||
},
|
||||
// onPullDownRefresh(){
|
||||
// this.getFeaturePageListFun() // 专辑页列表
|
||||
// },
|
||||
onPullDownRefresh() {
|
||||
// 禁用页面下拉刷新效果
|
||||
uni.stopPullDownRefresh()
|
||||
},
|
||||
methods: {
|
||||
loginSuccess() {
|
||||
@ -216,6 +207,102 @@
|
||||
this.showJoinImg = false
|
||||
}
|
||||
},
|
||||
// 重置并加载数据
|
||||
resetAndLoadData() {
|
||||
this.pageNum = 1
|
||||
this.finished = false
|
||||
this.featurePageList = []
|
||||
this.getActivityList()
|
||||
},
|
||||
// 获取活动列表
|
||||
async getActivityList() {
|
||||
if (this.loading || this.finished) return
|
||||
|
||||
try {
|
||||
this.loading = true
|
||||
const res = await getActivities({
|
||||
pageNum: this.pageNum,
|
||||
pageSize: this.pageSize
|
||||
})
|
||||
|
||||
if (res.code === 200) {
|
||||
const { rows, total } = res
|
||||
|
||||
// 处理数据,计算剩余天数和状态
|
||||
const processedRows = this.processActivityData(rows)
|
||||
|
||||
// 更新列表数据
|
||||
if (this.pageNum === 1) {
|
||||
this.featurePageList = processedRows
|
||||
} else {
|
||||
this.featurePageList = [...this.featurePageList, ...processedRows]
|
||||
}
|
||||
|
||||
this.total = total
|
||||
this.finished = this.featurePageList.length >= total
|
||||
this.pageNum++
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取活动列表失败:', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
// 处理活动数据
|
||||
processActivityData(rows) {
|
||||
return rows
|
||||
.map(it => {
|
||||
// 计算剩余天数
|
||||
const targetDate = new Date(it.endDate)
|
||||
const currentDate = new Date()
|
||||
const timeDiff = targetDate.getTime() - currentDate.getTime()
|
||||
const remainingDays = Math.ceil(timeDiff / (1000 * 3600 * 24))
|
||||
|
||||
// 设置活动状态
|
||||
let activityState = 'recruiting'
|
||||
if (it.activityStatus === 2) {
|
||||
activityState = 'in_progress'
|
||||
} else if (it.activityStatus === 3) {
|
||||
activityState = 'completed'
|
||||
}
|
||||
|
||||
return {
|
||||
...it,
|
||||
remainingDays,
|
||||
activityState,
|
||||
remainingBeerCount: it.remainingBeerCount || 0,
|
||||
barAwardStatus: it.barAwardStatus || 0
|
||||
}
|
||||
})
|
||||
.filter(item => {
|
||||
if (item.activityState === 'recruiting') {
|
||||
return item.remainingDays >= 0
|
||||
}
|
||||
return true
|
||||
})
|
||||
},
|
||||
// 修改页面加载更多方法
|
||||
async changePage() {
|
||||
if (!this.finished) {
|
||||
await this.getActivityList()
|
||||
}
|
||||
},
|
||||
handleActivityClick(item) {
|
||||
console.log('handleActivityClick called', item)
|
||||
uni.navigateTo({
|
||||
url: "/pagesActivity/activityDetail?id=" + item.id
|
||||
})
|
||||
},
|
||||
handlePopupChange(e) {
|
||||
if (e && e.detail) {
|
||||
this.currentAdIndex = e.detail.current;
|
||||
}
|
||||
},
|
||||
handleAdSwiperChange(e) {
|
||||
if (e && e.detail) {
|
||||
this.currentAdIndex = e.detail.current;
|
||||
}
|
||||
},
|
||||
toAddAiad() {
|
||||
uni.navigateTo({
|
||||
url: '/pagesMy/addAiad'
|
||||
@ -335,90 +422,6 @@
|
||||
// 实现搜索逻辑
|
||||
console.log('搜索关键词:', this.keyword);
|
||||
},
|
||||
// 获取活动列表
|
||||
async getActivityList() {
|
||||
if (this.loading || this.finished) return
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await getActivities({
|
||||
pageNum: this.pageNum,
|
||||
pageSize: this.pageSize
|
||||
})
|
||||
if (res.code === 200) {
|
||||
const { rows, total } = res
|
||||
|
||||
// 处理数据,计算剩余天数和状态
|
||||
const processedRows = rows.map(it => {
|
||||
// 计算剩余天数
|
||||
const targetDate = new Date(it.endDate);
|
||||
const currentDate = new Date();
|
||||
const timeDiff = targetDate.getTime() - currentDate.getTime();
|
||||
const remainingDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
||||
|
||||
// 设置活动状态
|
||||
let activityState = 'recruiting';
|
||||
if (it.activityStatus === 2) {
|
||||
activityState = 'in_progress';
|
||||
} else if (it.activityStatus === 3) {
|
||||
activityState = 'completed';
|
||||
}
|
||||
|
||||
return {
|
||||
...it,
|
||||
remainingDays,
|
||||
activityState,
|
||||
remainingBeerCount: it.remainingBeerCount || 0,
|
||||
barAwardStatus: it.barAwardStatus || 0
|
||||
};
|
||||
});
|
||||
|
||||
// 过滤掉招募剩余天数为负数的活动
|
||||
const filteredRows = processedRows.filter(item => {
|
||||
if (item.activityState === 'recruiting') {
|
||||
return item.remainingDays >= 0
|
||||
}
|
||||
return true
|
||||
});
|
||||
|
||||
if (this.pageNum === 1) {
|
||||
this.featurePageList = filteredRows;
|
||||
} else {
|
||||
this.featurePageList = [...this.featurePageList, ...filteredRows];
|
||||
}
|
||||
this.total = total;
|
||||
this.finished = this.featurePageList.length >= total;
|
||||
this.pageNum++;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取活动列表失败:', error)
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
// 修改页面加载更多方法
|
||||
async changePage() {
|
||||
if (!this.finished) {
|
||||
await this.getActivityList()
|
||||
}
|
||||
},
|
||||
// 处理活动项点击
|
||||
handleActivityClick(item) {
|
||||
console.log('handleActivityClick called', item)
|
||||
uni.navigateTo({
|
||||
url: "/pagesActivity/activityDetail?id=" + item.id
|
||||
})
|
||||
},
|
||||
handlePopupChange(e) {
|
||||
if (e && e.detail) {
|
||||
this.currentAdIndex = e.detail.current;
|
||||
}
|
||||
},
|
||||
handleAdSwiperChange(e) {
|
||||
if (e && e.detail) {
|
||||
this.currentAdIndex = e.detail.current;
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -434,6 +437,20 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Roboto, "Segoe UI", "Microsoft YaHei", sans-serif;
|
||||
|
||||
.join-box {
|
||||
width: 100%;
|
||||
height: 562rpx;
|
||||
background: #f5f5f5;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
|
||||
.img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.search-box {
|
||||
@ -477,13 +494,22 @@
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 200rpx;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
|
||||
scroll-view {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.activity-list {
|
||||
padding: 0 24rpx;
|
||||
padding: 0 32rpx;
|
||||
opacity: 1;
|
||||
transition: opacity 0.3s ease;
|
||||
|
||||
&.loading {
|
||||
opacity: 0.6;
|
||||
}
|
||||
}
|
||||
|
||||
.more-btn-box {
|
||||
@ -646,7 +672,15 @@
|
||||
|
||||
.bg-white {
|
||||
background: #FFFFFF;
|
||||
// box-shadow: 0rpx 1rpx 3rpx 0rpx rgba(0, 0, 0, 0.1);
|
||||
border-radius: 30rpx 30rpx 12rpx 12rpx;
|
||||
padding-top: 8rpx;
|
||||
position: relative;
|
||||
transform: translateY(-20rpx);
|
||||
z-index: 1;
|
||||
|
||||
.search-box {
|
||||
margin: 24rpx 32rpx;
|
||||
}
|
||||
}
|
||||
|
||||
.activity-item {
|
||||
@ -811,4 +845,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 添加过渡效果
|
||||
.fade-enter-active, .fade-leave-active {
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.fade-enter, .fade-leave-to {
|
||||
opacity: 0;
|
||||
}
|
||||
</style>
|
@ -24,7 +24,7 @@
|
||||
<text class="text-lg">暂无法查看信息</text>
|
||||
<text class="sub-text">您还没有登录,请登录后查看信息</text>
|
||||
<button class="login-btn" @click="toLogin">
|
||||
<image src="@/static/send-2.svg" class="btn-icon"></image>
|
||||
<image src="/static/send-2.svg" class="btn-icon"></image>
|
||||
登录/认证
|
||||
</button>
|
||||
</block>
|
||||
@ -32,7 +32,7 @@
|
||||
<text class="text-lg">您的门店还未完成认证</text>
|
||||
<text class="sub-text">请点击认证门店信息</text>
|
||||
<button class="login-btn" @click="toLogin">
|
||||
<image src="@/static/send-2.svg" class="btn-icon"></image>
|
||||
<image src="/static/send-2.svg" class="btn-icon"></image>
|
||||
去认证
|
||||
</button>
|
||||
</block>
|
||||
@ -142,7 +142,7 @@
|
||||
<view class="coin-item" v-for="(it, index) in myExchangeOrder" :key="index" @click="toOrderInfo(it)">
|
||||
<view class="flex justify-between" style="margin-bottom: 16rpx;">
|
||||
<text style="color: #5E5F60;font-weight: 600;font-size: 28rpx;">
|
||||
<image src="@/static/beerCoin.png" style="width: 24rpx;height: 24rpx;margin-right: 16rpx;"></image>
|
||||
<image src="/static/beerCoin.png" style="width: 24rpx;height: 24rpx;margin-right: 16rpx;"></image>
|
||||
啤酒币兑换</text>
|
||||
<text style="color: #5E5F60;font-weight: 600;font-size: 24rpx;margin-top: 8rpx;">已完成</text>
|
||||
</view>
|
||||
@ -900,6 +900,12 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 44rpx;
|
||||
|
||||
.btn-icon {
|
||||
width: 36rpx;
|
||||
height: 36rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -403,7 +403,7 @@
|
||||
height: 277rpx;
|
||||
|
||||
.cover {
|
||||
width: 120rpx;
|
||||
width: 150rpx;
|
||||
height: 213rpx;
|
||||
border-radius: 16rpx;
|
||||
margin-right: 24rpx;
|
||||
|
@ -41,6 +41,7 @@
|
||||
<script>
|
||||
import { base_url } from '@/api/config.js';
|
||||
import { addFeedback } from '@/api/user.js';
|
||||
import { getToken } from '@/utils/auth.js';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@ -67,11 +68,18 @@ export default {
|
||||
addFeedback(data).then(res => {
|
||||
uni.showToast({
|
||||
title: '提交成功',
|
||||
icon: 'none'
|
||||
icon: 'success'
|
||||
});
|
||||
setTimeout(() => {
|
||||
uni.navigateBack();
|
||||
}, 500);
|
||||
uni.switchTab({
|
||||
url: '/pages/index/my'
|
||||
});
|
||||
}, 1000);
|
||||
}).catch(err => {
|
||||
uni.showToast({
|
||||
title: '提交失败',
|
||||
icon: 'none'
|
||||
});
|
||||
});
|
||||
},
|
||||
handleUpload() {
|
||||
@ -81,26 +89,7 @@ export default {
|
||||
uni.authorize({
|
||||
scope: 'scope.camera',
|
||||
success: () => {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success: (res) => {
|
||||
uni.uploadFile({
|
||||
url: base_url + '/bar/common/upload',
|
||||
filePath: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
formData: { type: 'image' },
|
||||
success: (uploadFileRes) => {
|
||||
this.form.reviewImg = JSON.parse(uploadFileRes.data).url;
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.chooseAndUploadImage();
|
||||
},
|
||||
fail: () => {
|
||||
uni.showToast({
|
||||
@ -125,21 +114,87 @@ export default {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.chooseAndUploadImage();
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 选择并上传图片
|
||||
chooseAndUploadImage() {
|
||||
uni.chooseImage({
|
||||
count: 1,
|
||||
success: (res) => {
|
||||
uni.showLoading({
|
||||
title: '上传中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
const token = getToken();
|
||||
console.log('当前token:', token);
|
||||
|
||||
uni.uploadFile({
|
||||
url: base_url + '/bar/common/upload',
|
||||
url: base_url + '/api/bar/common/upload',
|
||||
filePath: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
formData: { type: 'image' },
|
||||
header: {
|
||||
'Authorization': token,
|
||||
'Content-Type': 'multipart/form-data'
|
||||
},
|
||||
formData: {
|
||||
type: 'image'
|
||||
},
|
||||
success: (uploadFileRes) => {
|
||||
this.form.reviewImg = JSON.parse(uploadFileRes.data).url;
|
||||
console.log('上传响应原始数据:', uploadFileRes);
|
||||
|
||||
try {
|
||||
// 检查状态码
|
||||
if (uploadFileRes.statusCode !== 200) {
|
||||
throw new Error(`服务器响应错误: ${uploadFileRes.statusCode}`);
|
||||
}
|
||||
|
||||
let result;
|
||||
try {
|
||||
result = JSON.parse(uploadFileRes.data);
|
||||
} catch (parseError) {
|
||||
console.error('解析响应数据失败,原始数据:', uploadFileRes.data);
|
||||
throw new Error('服务器响应格式错误');
|
||||
}
|
||||
|
||||
console.log('解析后的响应数据:', result);
|
||||
|
||||
if (result.code === 200) {
|
||||
const imageUrl = result.data || result.url;
|
||||
if (!imageUrl) {
|
||||
throw new Error('未获取到图片地址');
|
||||
}
|
||||
this.form.reviewImg = imageUrl;
|
||||
uni.showToast({
|
||||
title: '上传成功',
|
||||
icon: 'success'
|
||||
});
|
||||
} else {
|
||||
throw new Error(result.msg || '上传失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理上传响应错误:', error);
|
||||
uni.showToast({
|
||||
title: error.message || '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('上传请求失败:', err);
|
||||
uni.showToast({
|
||||
title: '上传失败',
|
||||
icon: 'none'
|
||||
});
|
||||
},
|
||||
complete: () => {
|
||||
uni.hideLoading();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 7.8 KiB |
Loading…
x
Reference in New Issue
Block a user