This commit is contained in:
浅念
2025-12-13 17:30:18 +08:00
parent 5112803313
commit c60dda98a4
8 changed files with 356 additions and 182 deletions
-1
View File
@@ -11,7 +11,6 @@
v-else
class="chat-btn"
:class="item.status==1 ? 'chat-btn1' : item.status==2 ? 'chat-btn2' : item.status==3 ? 'chat-btn3' : 'chat-btn4'"
@click.stop="handleContact"
>
{{ item.status==1 ? '已发布' : item.status==2 ? '审核中' : item.status==3 ? '未通过' : '已过期' }}
</button>
+47 -8
View File
@@ -102,7 +102,9 @@ export default {
{ key: 'latest', label: '最新发布' },
{ key: 'near', label: '距离最近' }
],
currentTab: 'latest',
latitude:'',
longitude:'',
currentTab:'latest',
flist: [],
slist: [],
selfChecked: false,
@@ -122,6 +124,11 @@ export default {
},
onShow() {
this.loadCategoryList();
this.getFuzzy().then(res => {
this.latitude = res.latitude
this.longitude = res.longitude
console.log(res);
}).catch(err => console.error(err));
// this.syncTabbar()
// // 从详情页返回后,重新拉取当前分类数据
// if (this.categoriesLoaded) {
@@ -129,6 +136,29 @@ export default {
// }
},
methods: {
getFuzzy() {
return new Promise((resolve, reject) => {
wx.getSetting({
success: (st) => {
const ok = st.authSetting['scope.userFuzzyLocation'];
const run = () => wx.getFuzzyLocation({
type: 'wgs84',
success: resolve,
fail: reject
});
if (ok) return run();
wx.authorize({
scope: 'scope.userFuzzyLocation',
success: run,
fail: () => wx.openSetting({ success: () => reject(new Error('未授权')) })
});
},
fail: reject
});
});
},
goprivacy(){
uni.navigateTo({
url: '/pages/login/agreement',// 替换为你要跳转的页面路径
@@ -215,6 +245,7 @@ export default {
// 根据分类id加载分类下的内容
loadCategoryData(categoryId, isLoadMore = false) {
const collectUrl = this.currentTab=='latest' ? 'common/post/list' : 'common/post/nearby'
// 防止重复请求:如果是加载更多,需要检查所有加载状态
if (isLoadMore) {
if (this.loadingMore || this.loading || this.refreshing) {
@@ -236,15 +267,23 @@ export default {
this.hasMore = true;
this.slist = []; // 清空之前的数据
}
var that = this;
const params = {
current:this.page,
size:10,
status:1,
category_id:categoryId
};
// 添加排序参数(如果后端支持)
if(this.currentTab=='near'){
params.lng = this.longitude;
params.lat = this.latitude;
} else {
}
request({
url:'common/post/list',
url:collectUrl,
method:'GET',
data:{
category_id:categoryId,
current: this.page,
size: this.pageSize
}
data:params
}).then(res => {
this.loading = false;
this.loadingMore = false;
+20 -9
View File
@@ -20,9 +20,9 @@
<image v-if="danmuVisible" src="/static/image/dan1.png" mode=""></image>
<image v-else src="/static/image/danm.png" mode=""></image>
</view>
<view class="circle-btn">
<button open-type="share" class="circle-btn">
<image src="/static/image/shares.png" class="share" mode=""></image>
</view>
</button>
</view>
</view>
@@ -145,10 +145,11 @@ export default {
});
},
handleContact(item) {
uni.showToast({
title: '联系门店功能',
icon: 'none'
});
const phone = item.user.mobile
if (!phone) return uni.showToast({ title: '号码为空', icon: 'none' });
// 简单清洗:去空格/横杠
const num = String(phone).replace(/[^\d+]/g, '');
uni.makePhoneCall({ phoneNumber: num });
},
handleComment(item) {
uni.navigateTo({
@@ -160,6 +161,7 @@ export default {
var that = this;
const params = {
current:pageNo,
status:1,
size:10
};
const collectUrl = this.activeTab==0 ? 'common/post/list' : 'common/post/nearby'
@@ -226,7 +228,15 @@ export default {
});
});
}
}
},
// 分享给好友
onShareAppMessage() {
return {
title: '西门子样机福利平台',
path: '/pages/index/index?from=share',
imageUrl: "/static/image/share.jpg" // 封面图
}
},
}
</script>
@@ -267,12 +277,13 @@ export default {
height: 80rpx;
border-radius: 50%;
background: #fff;
padding: 4rpx;
display: flex;
align-items: center;
justify-content: center;
image{
width: 48rpx;
height: 48rpx;
width: 60rpx;
height: 60rpx;
}
.share{
width: 36rpx;
+8 -2
View File
@@ -11,14 +11,17 @@
<view class="msg-body">
<view class="msg-header">
<text class="msg-name">{{item.sender_user.nickname}}</text>
<!-- <text class="msg-time">{{item.created_at}}</text> -->
<text class="msg-time">{{item.created_at}}</text>
</view>
</view>
</view>
<view class="msg-text">
<text>{{ item.type==1?'点赞了': item.type==2?'收藏了':'评论了' }} </text>
<text>{{ formatContent(item.post && item.post.content) }}</text>
</view>
<view class="msg-text1">
<text>{{ item.comment.content }} </text>
</view>
</view>
</view>
</z-paging>
@@ -127,4 +130,7 @@
color: #666;
line-height: 38rpx;
}
.msg-text1{
color: #000;
}
</style>
+58 -55
View File
@@ -1,81 +1,83 @@
<template>
<view class="container">
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="回复我的"></uni-nav-bar>
<view class="reply-list">
<view class="reply-card" v-for="(reply, index) in replyList" :key="index">
<!-- 主回复 -->
<view class="reply-item">
<view class="reply-heard">
<image :src="reply.avatar" class="avatar"></image>
<z-paging ref="paging" :auto="false" v-model="contList" @query="queryList" empty-view-text="暂无数据!">
<template #top>
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="回复我的"></uni-nav-bar>
</template>
<view class="reply-list">
<view class="reply-card" v-for="(reply, index) in contList" :key="index">
<!-- 主回复 -->
<view class="reply-item">
<view class="reply-heard">
<image :src="reply.user.avatar_pull" class="avatar"></image>
<view class="reply-content">
<view class="username">{{ reply.user.nickname }}</view>
<view class="time">{{ reply.created_at}}</view>
</view>
</view>
<view class="reply-content">
<view class="username">{{ reply.username }}</view>
<view class="time">{{ reply.time }}</view>
<text class="reply-text">{{ reply.content }}</text>
</view>
</view>
<view class="reply-content">
<text class="reply-text">{{ reply.content }}</text>
</view>
</view>
<!-- 子回复 -->
<view class="sub-reply" v-for="(subReply, subIndex) in reply.subReplies" :key="subIndex">
<view class="reply-heard">
<image :src="subReply.avatar" class="avatar"></image>
<view class="reply-header">
<view class="username">{{ subReply.username }}</view>
<!-- 子回复 -->
<view class="sub-reply" v-for="(subReply, subIndex) in reply.child" :key="subIndex">
<view class="reply-heard">
<image :src="subReply.user.avatar_pull" class="avatar"></image>
<view class="reply-header">
<view class="username">{{ subReply.user.nickname }}</view>
</view>
</view>
<view class="reply-content">
<text class="reply-text">{{ subReply.content }}</text>
</view>
</view>
<view class="reply-content">
<text class="reply-text">{{ subReply.content }}</text>
</view>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
replyList: [
{
avatar: '/static/image/user.png',
username: '用户名用户名',
time: '2025年12月04日10:56:44',
content: '这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复',
subReplies: [
{
avatar: '/static/image/user.png',
username: '田户名田户名',
time: '2025年12月04日10:56:44',
content: '西门子全新款饮机品牌西门子全新款饮机品牌西门子全新...'
}
]
},
{
avatar: '/static/image/user.png',
username: '用户名用户名',
time: '2025年12月04日10:56:44',
content: '这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复这是回复',
subReplies: [
{
avatar: '/static/image/user.png',
username: '用户名用户名',
time: '2025年12月04日10:56:44',
content: '西门子全新款饮机品牌西门子全新款饮机品牌西门子全新...'
}
]
}
]
contList: []
}
},
onShow(){
this.$refs.paging.reload()
},
methods: {
leftClick() {
uni.reLaunch({
url: '/pages/index/mine',// 替换为你要跳转的页面路径
});
},
queryList(pageNo, pageSize) {
this.loading = true;
var that = this;
request({
url:'common/post/comment/list?scene=self',
method:'get',
data: {
current:pageNo,
size:10
}
}).then(res => {
if(res.data.code ==200){
var datas = res.data.data.records;
this.$refs.paging.complete(datas);
}else{
// this.$refs.paging.complete(null);
// that.listlength=0
}
uni.stopPullDownRefresh();
//
})
}
}
}
@@ -122,6 +124,7 @@
}
.reply-content {
margin-top: 20rpx;
flex: 1;
min-width: 0;
}
+71 -4
View File
@@ -40,9 +40,7 @@
<input class="uni-input" focus v-model="form.price" placeholder="请输入折扣价格" />
</view>
<view class="detils">
<view v-html="productcontents">
</view>
<rich-text :nodes="productcontents"></rich-text>
</view>
</view>
@@ -182,10 +180,35 @@ export default {
}
})
},
// 处理富文本HTML,让图片自适应
processRichText(html) {
if (!html) return ''
// 使用正则表达式给所有 img 标签添加样式
return html.replace(/<img([^>]*)>/gi, (match, attrs) => {
// 检查是否已有 style 属性
if (attrs.includes('style=')) {
// 如果已有 style,添加 max-width
return match.replace(/style=["']([^"']*)["']/i, (styleMatch, styleContent) => {
// 移除已有的 max-width 和 width
let newStyle = styleContent.replace(/max-width\s*:\s*[^;]+;?/gi, '').replace(/width\s*:\s*[^;]+;?/gi, '')
newStyle = newStyle.trim()
if (newStyle && !newStyle.endsWith(';')) {
newStyle += ';'
}
newStyle += 'max-width: 100%; height: auto;'
return `style="${newStyle}"`
})
} else {
// 如果没有 style,添加 style 属性
return `<img${attrs} style="max-width: 100%; height: auto;">`
}
})
},
selectCategory(item){
this.form.category = item.model || ''
this.form.sku_id = item.id || ''
this.productcontents = item.desc || ''
// 处理富文本,让图片自适应
this.productcontents = this.processRichText(item.desc || '')
console.log(this.productcontents)
this.showSelect1 = false
},
@@ -337,6 +360,42 @@ export default {
this.show = false
},
submitForm(){
// 必填校验
if(!this.form.category || !this.form.sku_id){
uni.showToast({
title: '请选择型号',
icon: 'none'
});
return
}
if(!this.form.content || !this.form.content.trim()){
uni.showToast({
title: '请输入文字内容',
icon: 'none'
});
return
}
if(!this.form.agename || !this.form.age){
uni.showToast({
title: '请选择样机新旧程度',
icon: 'none'
});
return
}
if(!this.form.price || !this.form.price.trim()){
uni.showToast({
title: '请输入折扣价格',
icon: 'none'
});
return
}
if(!this.form.media || this.form.media.length === 0){
uni.showToast({
title: '请至少上传一张图片',
icon: 'none'
});
return
}
if(!this.agree){
uni.showToast({
title: '请先同意发布协议!',
@@ -373,6 +432,14 @@ export default {
<style lang="scss">
.detils{
margin-top: 40rpx;
overflow: hidden;
word-wrap: break-word;
word-break: break-all;
}
// 确保富文本中的图片自适应
.rich-wrap{
width: 100%;
overflow: hidden;
}
.cent{
display: flex;
+64 -8
View File
@@ -2,7 +2,9 @@
<view class="detail-page">
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000"
backgroundColor="#fff" :statusBar="true" :title="detail.sku.product_name"></uni-nav-bar>
<button open-type="share" class="circle-btn">
<image src="/static/image/shares.png" class="share" mode=""></image>
</button>
<scroll-view scroll-y class="page-scroll">
<!-- 图集 -->
<view class="gallery">
@@ -49,7 +51,7 @@
<!-- 详情 -->
<view v-if="currentTab === 'detail'" class="detail-box">
<text class="detail-text" v-html="detail.sku.desc"></text>
<rich-text :nodes="processedDesc"></rich-text>
</view>
<!-- 评论 -->
@@ -62,7 +64,7 @@
<view v-else>
<view v-for="(item, index) in comments" :key="index" class="comment-item">
<view class="comment-heard">
<image class="comment-avatar" :src="item.user.avatar"></image>
<image class="comment-avatar" :src="item.user.avatar_pull"></image>
<view class="comment-header">
<view class="comment-header-left">
<view class="comment-name">{{item.user.nickname}}</view>
@@ -80,7 +82,7 @@
<view v-if="item.child && item.child.length" class="comment-reply-box">
<view v-for="(reply, rIndex) in item.child" :key="rIndex" class="reply-item">
<view class="reply-item-left">
<image class="reply-avatar" :src="reply.user.avatar"></image>
<image class="reply-avatar" :src="reply.user.avatar_pull"></image>
<text class="reply-name">{{reply.user.nickname}}:</text>
<uni-icons type="trash" @click="delComment(reply.id)" v-if="openid==reply.user.openid||openid==detail.user.openid" color="#999" size="20"></uni-icons>
</view>
@@ -152,6 +154,13 @@ export default {
currentIndex: 0
}
},
computed: {
// 处理富文本内容,让图片自适应
processedDesc() {
if (!this.detail.sku || !this.detail.sku.desc) return ''
return this.processRichText(this.detail.sku.desc)
}
},
onLoad(options) {
this.postid = options.id;
this.share = options.share
@@ -160,6 +169,30 @@ export default {
this.getCommentCount()
},
methods: {
// 处理富文本HTML,让图片自适应
processRichText(html) {
if (!html) return ''
// 使用正则表达式给所有 img 标签添加样式
return html.replace(/<img([^>]*)>/gi, (match, attrs) => {
// 检查是否已有 style 属性
if (attrs.includes('style=')) {
// 如果已有 style,添加 max-width
return match.replace(/style=["']([^"']*)["']/i, (styleMatch, styleContent) => {
// 移除已有的 max-width 和 width
let newStyle = styleContent.replace(/max-width\s*:\s*[^;]+;?/gi, '').replace(/width\s*:\s*[^;]+;?/gi, '')
newStyle = newStyle.trim()
if (newStyle && !newStyle.endsWith(';')) {
newStyle += ';'
}
newStyle += 'max-width: 100%; height: auto;'
return `style="${newStyle}"`
})
} else {
// 如果没有 style,添加 style 属性
return `<img${attrs} style="max-width: 100%; height: auto;">`
}
})
},
setCurrent(idx) {
this.currentIndex = idx
},
@@ -627,7 +660,7 @@ export default {
return {
title: this.article.content,
path: `/pages/square/detiles?share=share&id=${this.article.id}`,
imageUrl: "/static/image/share.jpg" // 封面图
imageUrl:this.article.media[0].url_pull // 封面图
}
},
// 分享到朋友圈
@@ -775,19 +808,23 @@ page,
background: #dcdcdc;
}
.detail-box {
margin-bottom: 80rpx;
background: #fff;
padding: 20rpx 24rpx 40rpx;
padding: 20rpx 24rpx 190rpx;
font-size: 26rpx;
color: #444;
line-height: 1.7;
overflow: hidden;
word-wrap: break-word;
word-break: break-all;
}
.icons20{
width: 36rpx;
height: 36rpx;
margin-right: 20rpx;
}
.comment-section {
padding: 20rpx 30rpx 140rpx;
.comment-section {
padding: 20rpx 30rpx 190rpx;
background: #fff;
}
@@ -979,4 +1016,23 @@ page,
align-items: center;
gap: 6rpx;
}
.circle-btn {
z-index: 11;
position: fixed;
right: 20rpx;
margin-top: 20rpx;
top: 180rpx;
border-radius: 50%;
width: 80rpx;
height: 80rpx;
background: #fff;
padding: 10rpx;
display: flex;
align-items: center;
justify-content: center;
.share{
width: 34rpx;
height: 34rpx;
}
}
</style>
+88 -95
View File
@@ -62,70 +62,57 @@ export default {
{ key: 'near', label: '距离最近' }
],
currentTab: 'latest',
slist:[
{
username:'用户名用户名',
time:'2025 年 12 月 4 日 10:56',
content:`西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子西门子全新嵌饮机品牌
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子`,
tag:['#散饮机','#9成新'],
location:'门店位置',
image:[
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'}
]
},{
username:'用户名用户名',
time:'2025 年 12 月 4 日 10:56',
content:`西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子西门子全新嵌饮机品牌
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子`,
tag:['#散饮机','#9成新'],
location:'门店位置',
image:[
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'}
]
},{
username:'用户名用户名',
time:'2025 年 12 月 4 日 10:56',
content:`西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子西门子全新嵌饮机品牌
西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子全新嵌饮机品牌西门子`,
tag:['#散饮机','#9成新'],
location:'门店位置',
image:[
{img_src:'/static/image/bx.jpg'},
{img_src:'/static/image/bx.jpg'}
]
}
],
slist:[],
loading: false,
refreshing: false,
loadingMore: false,
page: 1,
pageSize: 10,
hasMore: true,
defaultTags: ['样机机', '9成新']
latitude:'',
longitude:''
}
},
onShow() {
this.loadList()
this.getFuzzy().then(res => {
this.latitude = res.latitude
this.longitude = res.longitude
console.log(res);
}).catch(err => console.error(err));
// this.syncTabbar()
},
methods: {
syncTabbar() {
uni.setTabBarItem({ index: 0, text: this.$t('tabbar.home') })
uni.setTabBarItem({ index: 1, text: this.$t('tabbar.square') })
uni.setTabBarItem({ index: 2, text: this.$t('tabbar.publish') })
uni.setTabBarItem({ index: 3, text: this.$t('tabbar.mine') })
},
getFuzzy() {
return new Promise((resolve, reject) => {
wx.getSetting({
success: (st) => {
const ok = st.authSetting['scope.userFuzzyLocation'];
const run = () => wx.getFuzzyLocation({
type: 'wgs84',
success: resolve,
fail: reject
});
if (ok) return run();
wx.authorize({
scope: 'scope.userFuzzyLocation',
success: run,
fail: () => wx.openSetting({ success: () => reject(new Error('未授权')) })
});
},
fail: reject
});
});
},
handleContact(item) {
const phone = item.user.mobile
if (!phone) return uni.showToast({ title: '号码为空', icon: 'none' });
// 简单清洗:去空格/横杠
const num = String(phone).replace(/[^\d+]/g, '');
uni.makePhoneCall({ phoneNumber: num });
},
changeTab(key) {
if (this.currentTab === key) return
this.currentTab = key
@@ -135,50 +122,56 @@ export default {
this.loadList()
},
loadList(isLoadMore = false) {
if (isLoadMore) {
if (this.loadingMore || this.loading || this.refreshing || !this.hasMore) return
this.loadingMore = true
this.page += 1
} else {
if (this.loading || this.loadingMore) return
this.loading = true
this.page = 1
this.hasMore = true
this.slist = []
}
const sortKey = this.currentTab === 'near' ? 'distance' : 'latest'
request({
url: 'common/post/list',
method: 'GET',
data: {
current: this.page,
size: this.pageSize,
sort: sortKey
}
}).then(res => {
this.loading = false
this.loadingMore = false
this.refreshing = false
if (res.data.code === 200) {
const records = res.data.data.records || []
const total = res.data.data.total || 0
if (isLoadMore) {
this.slist = [...this.slist, ...records]
} else {
this.slist = records
}
this.hasMore = this.slist.length < total
}
}).catch(() => {
this.loading = false
this.loadingMore = false
this.refreshing = false
if (isLoadMore) {
this.page -= 1
}
})
if (isLoadMore) {
if (this.loadingMore || this.loading || this.refreshing || !this.hasMore) return
this.loadingMore = true
this.page += 1
} else {
if (this.loading || this.loadingMore) return
this.loading = true
this.page = 1
this.hasMore = true
this.slist = []
}
const collectUrl = this.currentTab=='latest' ? 'common/post/list' : 'common/post/nearby'
var that = this;
const params = {
current:this.page,
status:1,
size:10
};
// 添加排序参数(如果后端支持)
if(this.currentTab=='near'){
params.lng = this.longitude;
params.lat = this.latitude;
} else {
}
request({
url: collectUrl,
method: 'GET',
data: params
}).then(res => {
this.loading = false
this.loadingMore = false
this.refreshing = false
if (res.data.code === 200) {
const records = res.data.data.records || []
const total = res.data.data.total || 0
if (isLoadMore) {
this.slist = [...this.slist, ...records]
} else {
this.slist = records
}
this.hasMore = this.slist.length < total
}
}).catch(() => {
this.loading = false
this.loadingMore = false
this.refreshing = false
if (isLoadMore) {
this.page -= 1
}
})
},
onRefresh() {
if (this.loading || this.loadingMore) {