Files
h5-meike/pages/ticket/scenic.vue
T
xuchaoandClaude Opus 4.8 7dee45aeed fix: 补贴价飘带文字居中 + 价格与元留间距
实测底图(image_bj_text.png)右侧约 18% 是蓝色箭头、左侧橙色才是文字槽。
旧代码 content-box 把飘带拉宽、箭头右移,文字左贴留下右侧空档=太靠左。
改法:盒子改 border-box 精确等于底图宽,右侧 padding 让出箭头区,
文字在橙色槽内 justify-content 居中;拆成 标签/¥/价格/元 四段控制间距,
价格与"元"间留 8rpx(375 屏约 4px),去掉导致数字上偏的 margin-bottom。
实测:文字居中、左留白与右留白均衡、元与价格有明显间距、不压蓝色箭头。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 16:07:57 +08:00

291 lines
6.5 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view>
<view class='nr_item' v-for="(item,index) in lookList" :key="index" @click="toDetail(item.id)">
<image class="nr_img" :src="item.mainPic||'https://aliyunoss.hn12301.net/sd/all_moren.png'"></image>
<view class="nr_item_r">
<text class="n_text">{{item.name||''}}</text>
<view class="nr_tags">
<text :class="index1==0?'t_text1':index1==1?'t_text':index1==2?'t_text2':'t_text3'"
v-for="(item1,index1) in ['节日福利/春游秋游','余额券','满减券']" :key="index1">{{item1}}</text>
</view>
<view class="r_text">{{item.subTypeId}}</view>
<view class="nr_origin">原售价<text
class="nr_origin_num">{{(item.price/100).toFixed(0)}}</text>元</view>
<view class="p_text"><text class="p_label">会员补贴价</text><text class="p_symbol">¥</text><text
class="p_num">{{(item.unitPrice/100).toFixed(0)}}</text><text class="p_unit">元</text></view>
</view>
</view>
<!-- xuchao: 订单悬浮按钮 -->
<gmy-float-touch :mainImg="mainImg" @menuClick="floatTouchClick"></gmy-float-touch>
</view>
</template>
<script>
// xuchao: 门票列表页(启动页/入口页)
import auth from '@/common/auth.js'
import gmyFloatTouch from "@/components/gmy-float-touch/gmy-float-touch.vue"
var that = ''
export default {
components: { gmyFloatTouch },
data() {
return {
mainImg: "../../static/logo4.png",
pageAll: 2,
isLoad: true,
lookList: [],
obj: {
"name": "",
"typeId": "",
"cityId": "",
"pageSize": 10,
"pageNum": 1,
"todayAvailable": false
}
}
},
onLoad() {
that = this
// xuchao: 未登录则(正式)跳登录页 / (开发)静默假登录
if (!auth.requireLogin('/pages/ticket/scenic')) return
this.queryTicketsPageMethod()
},
onReachBottom() {
this.queryTicketsPageMethod()
},
methods: {
queryTicketsPageMethod() {
if (this.obj.pageNum <= this.pageAll && this.isLoad) {
this.isLoad = false
this.$u.api.queryTicketsPage(this.obj).then(res => {
this.isLoad = true
this.obj.pageNum = this.obj.pageNum * 1 + 1
this.pageAll = Math.ceil(res.data.total / 10)
this.lookList = this.lookList.concat(res.data.list)
})
}
},
toDetail(e) {
uni.navigateTo({
url: 'scenicdetail?id=' + e
})
},
// xuchao: 悬浮按钮 —— 跳门票订单列表
floatTouchClick(e) {
if (e == 4) {
uni.navigateTo({
url: '/pages/ticket/orderlist'
})
}
}
}
}
</script>
<style>
page {
background: #FFEFD5;
}
</style>
<style scoped lang="less">
.nr_item {
// xuchao: 左右边距用百分比,随屏幕宽度等比变化;宽度自适应(去掉固定 702rpx)
width: auto;
box-sizing: border-box;
margin: 24rpx 3.2% 0;
display: flex;
background: #fff;
padding: 12rpx;
.nr_img {
width: 268rpx;
height: 268rpx;
flex: none;
}
.nr_item_r {
// xuchao: 右侧信息列改为弹性填充,配合卡片宽度自适应
flex: 1;
min-width: 0;
margin-left: 20rpx;
display: flex;
gap: 8rpx;
flex-direction: column;
position: relative;
.nr_tags {
display: flex;
gap: 12rpx;
flex-wrap: wrap;
}
.p_text {
position: absolute;
bottom: 0rpx;
right: 0rpx;
// xuchao: border-box 让盒子精确等于底图宽度;右侧 padding 让出蓝色箭头区,文字在橙色槽内居中
width: 250rpx;
height: 50rpx;
box-sizing: border-box;
background: url('https://aliyunoss.hn12301.net/xgh/image_bj_text.png');
background-size: 100% 100%;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
padding-left: 14rpx;
padding-right: 51rpx;
border-radius: 4rpx;
}
.p_label {
font-size: 16rpx;
}
.p_symbol {
font-size: 18rpx;
margin: 0 2rpx 0 6rpx;
}
.p_num {
font-size: 32rpx;
font-style: italic;
font-weight: bold;
}
.p_unit {
font-size: 16rpx;
// xuchao: 价格与"元"之间留出明显间距(8rpx ≈ 375 屏 4px)
margin-left: 8rpx;
}
.nr_origin {
position: absolute;
bottom: 60rpx;
right: 0rpx;
width: 100%;
text-align: right;
color: #4F4F4F;
font-size: 12rpx;
}
.nr_origin_num {
font-size: 28rpx;
text-decoration: line-through;
font-weight: bold;
}
.r_text {
width: 100%;
overflow: hidden !important;
text-overflow: ellipsis !important;
display: -webkit-box !important;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
font-size: 20rpx;
}
.n_text {
color: #008F90;
font-weight: bolder;
overflow: hidden !important;
text-overflow: ellipsis !important;
display: -webkit-box !important;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
font-size: 32rpx;
}
.t_text {
background-color: #FDEEC3;
font-size: 18rpx;
padding: 5rpx 10rpx;
color: #D57817;
border-radius: 4rpx;
}
.t_text1 {
background-color: #FDF4ED;
font-size: 18rpx;
padding: 5rpx 10rpx;
color: #AF4744;
border-radius: 4rpx;
}
.t_text2 {
background-color: #cbebfb;
font-size: 18rpx;
padding: 5rpx 10rpx;
color: #6ba0b3;
border-radius: 4rpx;
}
.t_text3 {
background-color: #F0F1F5;
font-size: 18rpx;
padding: 5rpx 10rpx;
color: #525357;
border-radius: 4rpx;
}
}
}
// 以下为旧版遗留、当前模板未使用的样式(.item / .r_text1 / .n_text1),按约定仅提示不删
.item {
width: 702rpx;
padding: 12rpx;
border-radius: 8rpx;
background-color: #fff;
position: relative;
margin-top: 24rpx;
display: flex;
margin-left: 24rpx;
.item_name {
width: 434rpx;
line-height: normal;
color: #000;
font-size: 28rpx;
font-weight: bold;
overflow: hidden !important;
text-overflow: ellipsis !important;
display: -webkit-box !important;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
.tag {
font-size: 20rpx;
color: #fff;
padding: 6rpx 5rpx;
background: linear-gradient(180deg, #FF9E49 0%, #ED3B1A 100%);
border-radius: 4rpx;
margin-top: 12rpx;
margin-right: 12rpx;
}
.tag1 {
font-size: 20rpx;
color: #999999;
padding: 5rpx;
border: 2rpx #999999 solid;
border-radius: 4rpx;
margin-top: 12rpx;
margin-right: 12rpx;
}
.hot_tag {
height: 36rpx;
color: #fff;
font-size: 20rpx;
position: absolute;
top: 12rpx;
left: 12rpx;
background: rgba(0, 0, 0, 0.5);
padding: 0rpx 8rpx;
border-radius: 8rpx 0rpx 8rpx 0rpx;
line-height: 36rpx;
}
}
</style>