This commit is contained in:
浅念
2026-01-13 15:10:33 +08:00
parent f768835f15
commit 56f09c263f
19 changed files with 3253 additions and 910 deletions
+16
View File
@@ -0,0 +1,16 @@
{
"i18n-ally.localesPaths": [
"common/locales",
"uni_modules/uni-table/i18n",
"uni_modules/uni-calendar/components/uni-calendar/i18n",
"uni_modules/uni-countdown/components/uni-countdown/i18n",
"uni_modules/uni-datetime-picker/components/uni-datetime-picker/i18n",
"uni_modules/uni-fav/components/uni-fav/i18n",
"uni_modules/uni-goods-nav/components/uni-goods-nav/i18n",
"uni_modules/uni-load-more/components/uni-load-more/i18n",
"uni_modules/uni-popup/components/uni-popup/i18n",
"uni_modules/uni-pagination/components/uni-pagination/i18n",
"uni_modules/uni-search-bar/components/uni-search-bar/i18n",
"uni_modules/z-paging/components/z-paging/i18n"
]
}
+5 -5
View File
@@ -1,7 +1,7 @@
// const baseUrl = "https://api.collect.hs.hnzhwlkj.club/"; //这里放置url域名32044
// const baseUrl = "https://api.collect.xyh.muzili.top/"; //这里放置url域名32044
const baseUrl = "https://usedcar.dev.hnxinyouhe.com/"; //这里放置url域名32044
// const baseUrl = "https://114.215.24.240:8106/api/v1/"; //这里放置url域名32044
const baseUrl = "https://userdcar-server.hnxinyouhe.com/"; //这里放置url域名32044
// const baseUrl = "https://usedcar.dev.hnxinyouhe.com/"; //这里放置url域名32044
// const baseUrl = "http://219.157.255.213:36010/"; //这里放置url域名32044
export function request(options){//封装的requset
let { url,data,method } = options;
data = data || {},
@@ -13,7 +13,7 @@ export function request(options){//封装的requset
uni.request({//这里是uniapp网络请求的api
url: baseUrl + url, //仅为示例,并非真实接口地址。
data,
header:{'content-type': 'application/x-www-form-urlencoded','Fdesk-Auth-Token':uni.getStorageSync('token'),'Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
header:{'Fdesk-Auth-Token':uni.getStorageSync('token'),'Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
method:method||"GET",//默认请求方式是get
success: (res) => {
resolve(res)
@@ -31,7 +31,7 @@ export function requestx(options){//封装的requset
uni.request({//这里是uniapp网络请求的api
url: baseUrl + url, //仅为示例,并非真实接口地址。
data,
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('openid')},
header:{'Authorization': 'Bearer ' + uni.getStorageSync('openid')},
method:method||"GET",//默认请求方式是get
success: (res) => {
resolve(res)
+350
View File
@@ -0,0 +1,350 @@
<template>
<view class="car-cards" @click="handleCardTap">
<view class="car-card">
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
<view class="info">
<view class="row row1">
<text class="name u-line-1">{{ item.product_name }}</text>
</view>
<view class="row row2">
<view class="kv">
<text class="k">车源地</text>
<text class="v u-line-1">{{ item.source_place }}</text>
</view>
<view class="kv">
<text class="k">车身颜色</text>
<text class="v u-line-1">{{ item.body_color }}</text>
</view>
</view>
<view class="row row3">
<view class="kv">
<text class="k">上牌时间</text>
<text class="v">{{ formatPlateTime(item.plate_time) }}</text>
</view>
<view class="kv">
<text class="k">里程</text>
<text class="v">{{ item.mileage }}</text>
</view>
</view>
</view>
</view>
<!-- 操作区:保存 + 分享(方案A:卡片右下角悬浮) -->
<view class="card-actions">
<view class="actions-lift">
<text class="">创建时间:</text>
<text class="">{{ item.created_at }}</text>
</view>
<view class="right-btn">
<view class="action-btn" @tap.stop="handleToggleSave">
<u-icon name="download" size="18" />
</view>
<view class="action-btn" @tap.stop="handleShare">
<u-icon name="share" size="18" />
</view>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
name: 'CarCard',
props: {
item: {
type: Object,
required: true
},
index: {
type: Number,
default: -1
}
},
methods: {
formatPlateTime(dateStr) {
return String(dateStr || '').slice(0, 7) // "2026-01"
},
pdfchanges() {
this.$emit('pdfchange')
},
handleCardTap() {
// 直接处理跳转,避免事件传递问题
if (this.item && this.item.id) {
const id = this.item.id
uni.navigateTo({
url: `/pages/index/detils?id=${id}`
})
} else {
console.error('CarCard: item or item.id is missing', this.item)
}
},
// H5 下载:用 a 标签触发
downloadByAnchor(url, filename) {
try {
const a = document.createElement('a')
a.href = url
a.download = filename || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (e) {
// 兜底:直接打开
if (typeof window !== 'undefined') window.open(url, '_blank')
}
},
downloadpdf(item) {
request({
url: 'common/usedcar/pdf',
method: 'get',
data: { id: item.id }
}).then(res => {
if (res.data.code == 200) {
this.downloadByAnchor(res.data.data.pdf_url, res.data.data.file_name)
}
})
},
handleToggleSave() {
const item = this.item
if (item.pdf_src && item.pdf_src != '') {
this.downloadpdf(item)
} else {
// 让父组件统一弹出输入框(避免列表里每个卡片都渲染一个 popup)
this.$emit('request-price', { item, index: this.index })
}
},
buildShareLink(id) {
// 统一生成"详情页路径"
const path = `pages/index/detils?id=${id}&appid=${uni.getStorageSync('fsappid')}`
// #ifdef H5
try {
const origin = window.location.origin
// uni-app H5 默认 hash 路由
return `${origin}/${path}`
} catch (e) {
return path
}
// #endif
return path
},
isFeishuEnv() {
// 飞书/ Lark 客户端内置浏览器 UA 通常包含 Feishu / Lark
try {
const ua = (navigator.userAgent || '').toLowerCase()
return ua.includes('feishu') || ua.includes('lark')
} catch (e) {
return false
}
},
feishuShare(payload) {
// 在飞书内优先使用 tt.share
try {
if (!this.isFeishuEnv()) return false
if (!window || !window.tt || !window.h5sdk) return false
// ready 后再调用
window.h5sdk.ready(() => {
// 优先使用 shareWebContent(文档推荐的 Web App 分享能力),不支持则降级到 share
if (typeof window.tt.shareWebContent === 'function') {
window.tt.shareWebContent({
title: payload.title,
content: payload.desc,
url: payload.link,
imageUrl: payload.imageUrl,
success: () => {
uni.showToast({ title: '已唤起飞书分享', icon: 'none' })
},
fail: (err) => {
console.error('feishu shareWebContent fail:', err)
uni.showToast({ title: '分享失败,可复制链接', icon: 'none' })
}
})
} else if (typeof window.tt.share === 'function') {
window.tt.share({
title: payload.title,
desc: payload.desc,
link: payload.link,
imageUrl: payload.imageUrl,
success: () => {
uni.showToast({ title: '已唤起飞书分享', icon: 'none' })
},
fail: (err) => {
console.error('feishu share fail:', err)
uni.showToast({ title: '分享失败,可复制链接', icon: 'none' })
}
})
} else {
throw new Error('Feishu share api not available')
}
})
return true
} catch (e) {
return false
}
},
handleShare() {
const item = this.item
const title = item.product_name || '车辆详情'
const link = this.buildShareLink(item.id)
const imageUrl = (item.images_pull && item.images_pull[0]) ? item.images_pull[0] : ''
// #ifdef MP-WEIXIN
// 小程序:打开系统分享面板(需要页面 onShareAppMessage 支持)
uni.showShareMenu({ withShareTicket: true })
uni.showToast({ title: '请使用右上角分享', icon: 'none' })
// #endif
// #ifdef H5
// 1) 飞书内:优先走飞书分享
const ok = this.feishuShare({
title,
desc: title,
link,
imageUrl
})
if (ok) return
// H5:优先走 Web Share API
if (typeof navigator !== 'undefined' && navigator.share) {
navigator.share({ title, text: title, url: link }).catch(() => {})
return
}
// #endif
// 兜底:弹出操作并复制链接
uni.showActionSheet({
itemList: ['复制链接', '复制标题'],
success: (res) => {
if (res.tapIndex === 0) {
uni.setClipboardData({ data: link })
} else {
uni.setClipboardData({ data: title })
}
}
})
}
}
}
</script>
<style lang="scss" scoped>
.car-cards {
padding-bottom: 6rpx; // 预留右下角按钮空间,避免遮挡信息
border-radius: 18rpx;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
margin-bottom: 18rpx;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.car-card {
position: relative;
display: flex;
align-items: stretch;
padding: 18rpx;
}
/* 方案A:卡片右下角悬浮操作区 */
.card-actions {
padding: 18rpx;
display: flex;
align-items: center;
justify-content: space-between;
gap: 14rpx;
border-top: 1px solid #e1e1e1;
}
.actions-lift {
font-size: 12px;
}
.right-btn {
display: flex;
gap: 14rpx;
}
.action-btn {
width: 50rpx;
height: 50rpx;
border-radius: 999rpx;
background: rgba(255, 255, 255, 0.92);
box-shadow: 0 8rpx 18rpx rgba(0, 0, 0, 0.12);
display: flex;
align-items: center;
justify-content: center;
}
.action-btn:active {
transform: scale(0.96);
}
.thumb {
width: 190rpx;
height: 140rpx;
border-radius: 14rpx;
background: #eef2f7;
flex-shrink: 0;
}
.info {
flex: 1;
margin-left: 18rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.row {
display: flex;
align-items: center;
}
.row1 {
justify-content: space-between;
margin-bottom: 10rpx;
}
.name {
font-size: 30rpx;
font-weight: 700;
color: #111827;
max-width: 420rpx;
}
.tag {
font-size: 22rpx;
padding: 6rpx 12rpx;
border-radius: 999rpx;
background: rgba(255, 151, 47, 0.14);
color: #b45309;
flex-shrink: 0;
}
.row2,
.row3 {
justify-content: space-between;
gap: 16rpx;
}
.kv {
flex: 1;
min-width: 0;
display: flex;
align-items: baseline;
}
.k {
font-size: 22rpx;
color: #6b7280;
margin-right: 10rpx;
flex-shrink: 0;
}
.v {
font-size: 24rpx;
color: #374151;
font-weight: 600;
min-width: 0;
}
</style>
+1
View File
@@ -18,5 +18,6 @@
<body>
<div id="app"><!--app-html--></div>
<script type="module" src="/main.js"></script>
</body>
</html>
+18
View File
@@ -68,6 +68,24 @@
"navigationStyle":"custom"// 去掉微信小程序顶部导航
}
},
{
"path" : "pages/index/changinfo",
"style" :
{
"navigationBarTitleText": "个人信息",
"enablePullDownRefresh": false,
"navigationStyle":"custom"// 去掉微信小程序顶部导航
}
},
{
"path" : "pages/index/myPublish",
"style" :
{
"navigationBarTitleText": "我的发布",
"enablePullDownRefresh": false,
"navigationStyle":"custom"// 去掉微信小程序顶部导航
}
},
{
"path" : "pages/login/feishu-callback",
"style" :
+270
View File
@@ -0,0 +1,270 @@
<template>
<view>
<uni-nav-bar leftText=" " :fixed="true" :border="false" leftIcon="back" @clickLeft="leftClick" color="#000000" backgroundColor="#fff" :statusBar="true" title="个人信息"></uni-nav-bar>
<view class="content">
<view class="topimg">
<uni-file-picker fileMediatype="image" limit="1" :list-styles="imageStyles" :del-icon="false" disable-preview @select="select" @delete="delfn('picture')">
<image class="user" :src="userinfo.avatar_url"mode=""></image>
</uni-file-picker>
<view>点击更换头像</view>
</view>
<view class="cell1">
<view class="item">手机号</view>
<view class="right">
<input placeholder="请输入手机号" type="number" v-model="userinfo.mobile"></input>
</view>
</view>
<u-divider text=""></u-divider>
<view class="cell1">
<view class="item">邮箱</view>
<view class="right">
<input placeholder="请输入邮箱" type="text" v-model="userinfo.position"></input>
</view>
</view>
<u-divider text=""></u-divider>
<view class="cell1">
<view class="item">二维码</view>
<view class="right">
<u-radio-group v-model="userinfo.socialize">
<u-radio name="微信" class="m-r-10">微信</u-radio>
<u-radio name="WhatsApp">WhatsApp</u-radio>
</u-radio-group>
</view>
</view>
<view class="cell">
<view class="item">上传二维码</view>
<view class="right">
<uni-file-picker style="margin: 10px 0px;" fileMediatype="image" limit="1" :list-styles="imageStyles" :del-icon="false" disable-preview @select="selectewm" >
<image class="user" :src="userinfo.socialize_pic_url==null?'/static/image/mine/erwm.png':userinfo.socialize_pic_url " mode=""></image>
</uni-file-picker>
</view>
</view>
</view>
<view class="foot">
<button class="btn" @click="bcFn">保存</button>
</view>
</view>
</template>
<script>
import { nextTick } from "vue"
import { request,showToast } from '@/api/apiT.js'
export default {
data() {
return {
imageStyles: {
border: true,
},
userinfo:{},
}
},
onLoad() {
this.getinfo()
},
methods: {
getinfo(){
var that= this;
request({
url:'user/getInfo',
method:'get',
}).then(res => {
if(res.data.data.position=='null'){
res.data.data.position=''
}
that.userinfo = res.data.data;
this.actives = res.data.data.country_id
this.country_name = res.data.data.country_name
that.select1()
})
},
uploadfn(imgUrl,scene){
uni.showLoading({
title: '上传中'
});
uni.uploadFile({
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
filePath: imgUrl,
name: 'file',
header:{'Fdesk-Auth-Token': uni.getStorageSync('token'),'Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
success: (uploadFileRes) => {
const res = JSON.parse(uploadFileRes.data || '{}')
uni.hideLoading();
uni.showToast({
title:res.message,
icon:'none'
})
if(res && res.data && res.data.file_name){
that.userinfo[name1] = path.data.image_url
that.userinfo[name] = path.data.path
}
},
fail: (err) => reject(err)
});
},
select(e){
const tempFilePaths = e.tempFilePaths;
const imgUrl=tempFilePaths[0]
this.uploadfn(imgUrl,'avatar')
},
leftClick(){
uni.navigateBack({})
},
bcFn(){
request({
url:'user/save',
method:'POST',
data:{
avatar:this.userinfo.avatar,
avatar_url:this.userinfo.avatar_url,
sex:this.userinfo.sex,
name:this.userinfo.name,
mobile:this.userinfo.mobile,
position:this.userinfo.position,
country_id:this.userinfo.country_id,
sign:this.userinfo.sign,
socialize:this.userinfo.socialize,
socialize_pic:this.userinfo.socialize_pic,
socialize_pic_url:this.userinfo.socialize_pic_url,
}
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
if(res.data.code ==0){
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/mine',// 替换为你要跳转的页面路径
});
}, 1000);
}
})
}
}
}
</script>
<style lang="scss">
.uni-file-picker {
margin-left: 33.3%;
}
.m-r-10{
margin-right: 10px;
}
.uniui-right{
position: absolute;
top: 2px;
}
.u-divider{
margin: 0px 0px !important;
}
.arrowright{
margin-right: -15px;
}
.content{
background: #FFFFFF;
padding-bottom: 100px;
.topimg{
text-align: center;
position: relative;
padding: 20px 0px;
color: #999999;
}
.user{
width: 200rpx;
height: 200rpx;
}
.xj{
width: 60rpx;
height: 52rpx;
position: absolute;
right: 46%;
top: 33%;
}
}
.cell1{
display: flex;
justify-content:space-between;
padding: 18px 20px;
align-items: center;
font-weight: 500;
.item{
width: 90px;
}
}
.cell{
padding: 18px 20px;
font-weight: 500;
.item{
width: 90px;
}
}
.right{
text-align: right;
}
.select{
display: flex;
position: relative;
margin-right: 10px;
}
.foot{
position: fixed;
bottom: 0px;
width: 100%;
height: 160rpx;
background: #FFFFFF;
}
.btn{
background: #3F435B;
color: white;
border-radius: 50px;
width: 84%;
margin: 20px 8%;
}
.addimg{
width: 35px;
height: 35px;
border-radius: 50%;
}
//
.actives{
background-color: #dfdfdf;
}
.text{
display: flex;
align-items: center;
justify-content: space-between;
line-height: 30px;
padding: 10px 15px 0px;
.qd{
color: #3471FF;
}
}
.popup-content {
padding: 20px;
background-color: #fff;
}
.option-list {
max-height: 400rpx;
margin-top: 20rpx;
}
.option-item {
padding: 20rpx;
border-bottom: 1rpx solid #eee;
}
.option-item:last-child {
border-bottom: none;
}
.no-data {
text-align: center;
padding: 20rpx;
color: #999;
}
</style>
+72 -11
View File
@@ -9,11 +9,11 @@
<text class="name">{{ detail.product_name }}</text>
</view>
<view class="kv">
<view class="kv-item" @click="copyIfHas('车辆识别码', detail.vin)">
<!-- <view class="kv-item" @click="copyIfHas('车辆识别码', detail.vin)">
<text class="k">车辆识别码</text>
<text class="v ellipsis">{{ detail.vin }}</text>
<text class="copy" v-if="detail.vin">复制</text>
</view>
</view> -->
<view class="kv-item">
<text class="k">车价(¥)</text>
@@ -25,10 +25,10 @@
<text class="v">{{ detail.source_place}}</text>
</view>
<view class="kv-item">
<!-- <view class="kv-item">
<text class="k">上牌地</text>
<text class="v">{{ detail.plate_place }}</text>
</view>
</view> -->
<view class="kv-item">
<text class="k">上牌时间</text>
@@ -44,10 +44,13 @@
<text class="k">里程</text>
<text class="v">{{ detail.mileage }}</text>
</view>
<view class="kv-item">
<text class="k">马力</text>
<text class="v">{{ detail.power }}</text>
</view>
<view class="kv-item">
<text class="k">车身颜色</text>
<text class="v">{{ detail.color }}</text>
<text class="v">{{ detail.body_color }}</text>
</view>
<view class="kv-item">
@@ -56,6 +59,15 @@
</view>
</view>
</view>
<!-- 车况介绍 -->
<view class="card">
<view class="section-title">车况介绍</view>
<text class="desc" v-if="detail.condition_desc!=''">{{ detail.condition_desc }}</text>
<view class="noneview" v-else>
<img src="/static/image/none.png" alt="">
</view>
</view>
<view class="hero">
<view class="section-title">产品图</view>
<!-- 有图:九宫格/多行平铺;无图:占位 -->
@@ -70,11 +82,17 @@
/>
</view>
</view>
<!-- 车况介绍 -->
<view class="card">
<view class="section-title">车况介绍</view>
<text class="desc">{{ detail.condition_desc }}</text>
<view class="hero">
<view class="section-title">附件</view>
<view v-if="detail.attachment_pull.length>0">
<view v-for="(file, i) in detail.attachment_pull" :key="i" class="fujian" @click="reviewFile(file)">
<p>{{file.name}}</p>
<view>查看</view>
</view>
</view>
<view class="noneview" v-else>
<img src="/static/image/none.png" alt="">
</view>
</view>
</view>
</view>
@@ -86,6 +104,7 @@
data() {
return {
id: '',
appid: '',
detail: {},
currentImageIndex: 0
}
@@ -111,6 +130,20 @@
onLoad(options) {
// 1) 支持通过 id 打开:/pages/index/detils?id=123
this.id = options?.id || ''
// 2) 分享链接里会带 appid,用于未登录时拉起飞书免登
const appid = options?.appid || uni.getStorageSync('fsappid') || ''
if (appid) uni.setStorageSync('fsappid', appid)
// 3) 如果未登录:先去登录页,登录成功后再回到当前详情页
const token = uni.getStorageSync('token')
if (!token) {
const redirect = `/pages/index/detils?id=${this.id}${appid ? `&appid=${encodeURIComponent(appid)}` : ''}`
uni.setStorageSync('post_login_redirect', redirect)
// 使用 reLaunch,避免用户打开分享链接后历史栈混乱
uni.reLaunch({
url: `/pages/login/index?appid=${encodeURIComponent(appid)}&redirect=${encodeURIComponent(redirect)}`
})
return
}
this.getshows()
},
methods: {
@@ -146,6 +179,23 @@
current: this.images[this.currentImageIndex],
urls: this.images
})
},
downloadByAnchor(url, filename) {
try {
const a = document.createElement('a')
a.href = url
a.download = filename || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (e) {
// 兜底:直接打开
if (typeof window !== 'undefined') window.open(url, '_blank')
}
},
reviewFile(file){
this.downloadByAnchor(file.src, file.name)
}
}
}
@@ -329,4 +379,15 @@
color: #ff972f;
font-size: 24rpx;
}
.fujian{
display: flex;
align-items: center;
justify-content: space-between;
border: 1px solid #ebebeb;
padding: 8px 10px;
border-radius: 4px;
}
.noneview{
text-align: center;
}
</style>
+374
View File
@@ -0,0 +1,374 @@
<template>
<view class="page">
<!-- 列表 -->
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无数据!">
<!-- <uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="首页"></uni-nav-bar> -->
<!-- 顶部:标题 + 搜索(不想要搜索可直接删除这一块) -->
<view class="page-head">
<view class="head-search">
<u-search
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@change="onKeywordChange"
@search="onSearch"
@clear="onSearch"
/>
</view>
</view>
<view class="list-wrap">
<CarCard
v-for="item in list"
:key="item.id"
:item="item"
@pdfchange="onSearch"
@request-price="onRequestPrice"
/>
</view>
</z-paging>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog
mode="input"
title="请输入价格"
:value="priceDialogValue"
placeholder="请输入车辆价格"
@confirm="dialogInputConfirm"
/>
</uni-popup>
<!-- <uni-popup ref="inputDialog" type="dialog">
<view class="popup-dialog">
<view class="popup-title">请输入价格</view>
<view class="popup-input-wrap">
<input
class="popup-input"
type="number"
v-model="priceDialogValue"
placeholder="请输入车辆价格"
/>
</view>
<view class="popup-btns">
<view class="popup-btn cancel" @click="close">取消</view>
<view class="popup-btn confirm" @click="dialogInputConfirm">确定</view>
</view>
</view>
</uni-popup> -->
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
import CarCard from '@/components/CarCard/CarCard.vue'
export default {
components: {
CarCard
},
data() {
return {
priceDialogItem: null,
priceDialogIndex: -1,
priceDialogValue: '',
keyword: '',
page: 1,
pageSize: 10,
loading: false,
finished: false,
list: []
}
},
onLoad() {
this.initFeishuShare()
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
// #ifdef H5
try {
const u = new URL(window.location.href)
const r = u.searchParams.get('r')
if (r) {
const target = decodeURIComponent(r)
// 清理地址栏的 r,避免反复跳转
u.searchParams.delete('r')
window.history.replaceState({}, '', u.toString())
// 让首页加载完再跳
setTimeout(() => {
uni.navigateTo({ url: target })
}, 50)
}
} catch (e) {}
// #endif
},
methods: {
isFeishuEnv() {
// 飞书/ Lark 客户端内置浏览器 UA 通常包含 Feishu / Lark
try {
const ua = (navigator.userAgent || '').toLowerCase()
return ua.includes('feishu') || ua.includes('lark')
} catch (e) {
return false
}
},
loadFeishuJSSDK() {
// 动态加载飞书 H5 JS-SDK(避免你还要改 public/index.html)
return new Promise((resolve, reject) => {
try {
// 已加载
if (typeof window !== 'undefined' && window.h5sdk && window.tt) return resolve(true)
// H5 才有 document
if (typeof document === 'undefined') return reject(new Error('not in h5 environment'))
// 已插入但未 ready
const existed = document.querySelector('script[data-feishu-h5sdk="1"]')
if (existed) {
existed.addEventListener('load', () => resolve(true))
existed.addEventListener('error', () => reject(new Error('feishu sdk load error')))
return
}
const s = document.createElement('script')
s.async = true
s.src = 'https://lf-scm-cn.feishucdn.com/lark/op/h5-js-sdk-1.5.44.js'
s.onload = () => resolve(true)
s.onerror = () => reject(new Error('feishu sdk load error'))
document.head.appendChild(s)
} catch (e) {
reject(e)
}
})
},
getFeishuSignUrl() {
// 飞书签名通常要求“去掉 hash 的完整 URL”
try {
return window.location.href.split('#')[0]
} catch (e) {
return ''
}
},
initFeishuShare() {
try {
// 确保在飞书环境
// if (!this.isFeishuEnv()) return
// 动态加载 SDK
this.loadFeishuJSSDK()
// 这里需要后端提供签名接口:返回 { appId, timestamp, nonceStr, signature }
// 你可以按你后端习惯改成:request({ url: 'xxx', ... })
// const signUrl = encodeURIComponent(this.getFeishuSignUrl())
const signUrl = this.getFeishuSignUrl()
request({
url:'common/auth/feishu/signature',
method:'get',
data: {url:signUrl,app_id:uni.getStorageSync('fsappid')}
}).then(res => {
var cfg = res.data.data;
window.h5sdk.config({
appId: cfg.appId || uni.getStorageSync('fsappid'),
timestamp: cfg.timestamp,
nonceStr: cfg.nonceStr,
signature: cfg.signature,
jsApiList: ['shareWebContent','share']
})
window.h5sdk.ready(() => {
this._feishuReady = true
})
window.h5sdk.error((err) => {
this._feishuReady = false
console.error('Feishu JSSDK error:', err)
})
})
} catch (e) {
// 不要阻塞页面,失败就走 H5 的兜底分享
console.error('initFeishuShare failed:', e)
}
},
close() {
this.$refs.inputDialog.close()
},
onRequestPrice(payload) {
// payload: { item, index }
this.priceDialogItem = payload && payload.item ? payload.item : null
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
this.priceDialogValue = ''
this.$nextTick(() => {
this.$refs.inputDialog && this.$refs.inputDialog.open()
})
},
// H5 下载:用 a 标签触发
downloadByAnchor(url, filename) {
try {
const a = document.createElement('a')
a.href = url
a.download = filename || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (e) {
// 兜底:直接打开
if (typeof window !== 'undefined') window.open(url, '_blank')
}
},
downloadpdf(item) {
request({
url: 'common/usedcar/pdf',
method: 'get',
data: { id: item.id }
}).then(res => {
if (res.data.code == 200) {
this.downloadByAnchor(res.data.data.pdf_url, res.data.data.file_name)
}
})
},
dialogInputConfirm(val) {
const item = this.priceDialogItem
const index = this.priceDialogIndex
const price = String(val || '').trim()
if (!item) return
if (!price) {
uni.showToast({ title: '请输入价格', icon: 'none' })
return
}
if (isNaN(price) || Number(price) <= 0) {
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
return
}
request({
url: 'common/usedcar/produce/pdf',
method: 'get',
data: { id: item.id, price }
}).then(res => {
if (res.data.code == 200) {
// 通知刷新列表(你原来就是靠这个事件刷新)
this.onSearch()
this.downloadpdf(item)
} else {
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
}
})
},
onKeywordChange(val) {
// val 是输入值(uView 通常会传)
this.keyword = val
// 防抖:300ms 内持续输入只触发一次
if (this._kwTimer) clearTimeout(this._kwTimer)
this._kwTimer = setTimeout(() => {
this.onSearch()
}, 300)
},
onSearch() {
this.queryList(this.page,this.pageSize)
},
queryList(pageNo, pageSize, from) {
this.loading = true;
var that = this;
const params = {
current:pageNo,
status:1,
size:10
};
params.keyword = this.keyword;
request({
url:'common/usedcar/list',
method:'get',
data: params
}).then(res => {
if(res.data.code ==200){
var datas = res.data.data.records;
this.$refs.paging.complete(datas);
}else{
}
uni.stopPullDownRefresh();
//
})
}
}
}
</script>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #f4f6f8;
}
.page-head {
position: fixed;
width: 100%;
bottom: 50px;
z-index: 99;
// padding: 28rpx 24rpx 18rpx;
// background: linear-gradient(180deg, rgba(255, 151, 47, 0.22) 0%, rgba(255, 151, 47, 0.06) 55%, #f4f6f8 100%);
}
.head-search {
background: rgba(255, 255, 255, 1);
border-radius: 9px 9px 0px 0px;
padding: 20rpx 10px;
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
}
.list-wrap {
padding: 18rpx 24rpx 40rpx;
}
.loadmore {
padding: 18rpx 0 6rpx;
}
.popup-dialog {
width: 620rpx;
background: #fff;
border-radius: 24rpx;
overflow: hidden;
}
.popup-title {
text-align: center;
font-size: 32rpx;
// font-weight: 600;
color: #656565;
padding: 32rpx 20rpx 20rpx;
}
.popup-input-wrap {
padding: 0 40rpx 30rpx;
}
.popup-input {
height: 88rpx;
border-radius: 12rpx;
border: 1px solid #dfdfdf;
padding: 0 24rpx;
font-size: 30rpx;
color: #333;
}
.popup-btns {
display: flex;
border-top: 1rpx solid #eee;
}
.popup-btn {
flex: 1;
height: 96rpx;
line-height: 96rpx;
text-align: center;
font-size: 32rpx;
}
.popup-btn.cancel {
color: #666;
border-right: 1rpx solid #eee;
}
.popup-btn.confirm {
color: #007aff; /* uni 主色 */
font-weight: 500;
}
</style>
+189 -135
View File
@@ -20,52 +20,40 @@
</view>
</view>
<view class="list-wrap">
<view
v-for="(item, idx) in list"
:key="item.id "
class="car-card"
@tap="goDetail(item)"
>
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
<view class="info">
<view class="row row1">
<text class="name u-line-1">{{ item.product_name }}</text>
</view>
<view class="row row2">
<view class="kv">
<text class="k">车源地</text>
<text class="v u-line-1">{{ item.source_place }}</text>
</view>
<view class="kv">
<text class="k">车身颜色</text>
<text class="v u-line-1">{{ item.body_color }}</text>
</view>
</view>
<view class="row row3">
<view class="kv">
<text class="k">上牌时间</text>
<text class="v">{{ ym(item.plate_time) }}</text>
</view>
<view class="kv">
<text class="k">里程</text>
<text class="v">{{ item.mileage }}</text>
</view>
</view>
</view>
</view>
<CarCard
v-for="item in list"
:key="item.id"
:item="item"
@pdfchange="onSearch"
@request-price="onRequestPrice"
/>
</view>
</z-paging>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog
mode="input"
title="请输入价格"
:value="priceDialogValue"
placeholder="请输入车辆价格"
@confirm="dialogInputConfirm"
/>
</uni-popup>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
import CarCard from '@/components/CarCard/CarCard.vue'
export default {
components: {
CarCard
},
data() {
return {
priceDialogItem: null,
priceDialogIndex: -1,
priceDialogValue: '',
keyword: '',
page: 1,
pageSize: 10,
@@ -75,11 +63,173 @@
}
},
onLoad() {
this.initFeishuShare()
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
// #ifdef H5
try {
const u = new URL(window.location.href)
const r = u.searchParams.get('r')
if (r) {
const target = decodeURIComponent(r)
// 清理地址栏的 r,避免反复跳转
u.searchParams.delete('r')
window.history.replaceState({}, '', u.toString())
// 让首页加载完再跳
setTimeout(() => {
uni.navigateTo({ url: target })
}, 50)
}
} catch (e) {}
// #endif
},
methods: {
ym(dateStr) {
return String(dateStr || '').slice(0, 7) // "2026-01"
isFeishuEnv() {
// 飞书/ Lark 客户端内置浏览器 UA 通常包含 Feishu / Lark
try {
const ua = (navigator.userAgent || '').toLowerCase()
return ua.includes('feishu') || ua.includes('lark')
} catch (e) {
return false
}
},
loadFeishuJSSDK() {
// 动态加载飞书 H5 JS-SDK(避免你还要改 public/index.html)
return new Promise((resolve, reject) => {
try {
// 已加载
if (typeof window !== 'undefined' && window.h5sdk && window.tt) return resolve(true)
// H5 才有 document
if (typeof document === 'undefined') return reject(new Error('not in h5 environment'))
// 已插入但未 ready
const existed = document.querySelector('script[data-feishu-h5sdk="1"]')
if (existed) {
existed.addEventListener('load', () => resolve(true))
existed.addEventListener('error', () => reject(new Error('feishu sdk load error')))
return
}
const s = document.createElement('script')
s.async = true
s.src = 'https://lf-scm-cn.feishucdn.com/lark/op/h5-js-sdk-1.5.44.js'
s.onload = () => resolve(true)
s.onerror = () => reject(new Error('feishu sdk load error'))
document.head.appendChild(s)
} catch (e) {
reject(e)
}
})
},
getFeishuSignUrl() {
// 飞书签名通常要求“去掉 hash 的完整 URL”
try {
return window.location.href.split('#')[0]
} catch (e) {
return ''
}
},
initFeishuShare() {
try {
// 确保在飞书环境
// if (!this.isFeishuEnv()) return
// 动态加载 SDK
this.loadFeishuJSSDK()
// 这里需要后端提供签名接口:返回 { appId, timestamp, nonceStr, signature }
// 你可以按你后端习惯改成:request({ url: 'xxx', ... })
// const signUrl = encodeURIComponent(this.getFeishuSignUrl())
const signUrl = this.getFeishuSignUrl()
request({
url:'common/auth/feishu/signature',
method:'get',
data: {url:signUrl,app_id:uni.getStorageSync('fsappid')}
}).then(res => {
var cfg = res.data.data;
window.h5sdk.config({
appId: cfg.appId || uni.getStorageSync('fsappid'),
timestamp: cfg.timestamp,
nonceStr: cfg.nonceStr,
signature: cfg.signature,
jsApiList: ['shareWebContent','share']
})
window.h5sdk.ready(() => {
this._feishuReady = true
})
window.h5sdk.error((err) => {
this._feishuReady = false
console.error('Feishu JSSDK error:', err)
})
})
} catch (e) {
// 不要阻塞页面,失败就走 H5 的兜底分享
console.error('initFeishuShare failed:', e)
}
},
onRequestPrice(payload) {
// payload: { item, index }
this.priceDialogItem = payload && payload.item ? payload.item : null
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
this.priceDialogValue = ''
this.$nextTick(() => {
this.$refs.inputDialog && this.$refs.inputDialog.open()
})
},
// H5 下载:用 a 标签触发
downloadByAnchor(url, filename) {
try {
const a = document.createElement('a')
a.href = url
a.download = filename || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (e) {
// 兜底:直接打开
if (typeof window !== 'undefined') window.open(url, '_blank')
}
},
downloadpdf(item) {
request({
url: 'common/usedcar/pdf',
method: 'get',
data: { id: item.id }
}).then(res => {
if (res.data.code == 200) {
this.downloadByAnchor(res.data.data.pdf_url, res.data.data.file_name)
}
})
},
dialogInputConfirm(val) {
const item = this.priceDialogItem
const index = this.priceDialogIndex
const price = String(val || '').trim()
if (!item) return
if (!price) {
uni.showToast({ title: '请输入价格', icon: 'none' })
return
}
if (isNaN(price) || Number(price) <= 0) {
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
return
}
request({
url: 'common/usedcar/produce/pdf',
method: 'get',
data: { id: item.id, price }
}).then(res => {
if (res.data.code == 200) {
// 通知刷新列表(你原来就是靠这个事件刷新)
this.onSearch()
this.downloadpdf(item)
} else {
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
}
})
},
onKeywordChange(val) {
// val 是输入值(uView 通常会传)
@@ -116,23 +266,6 @@
uni.stopPullDownRefresh();
//
})
},
goDetail(item) {
// 你后续详情页如果要接 id,这里按后端字段改一下即可
const id = item.id
uni.navigateTo({
url: `/pages/index/detils?id=${id}`
})
},
formatMileage(v) {
if (v === '-' || v === undefined || v === null || String(v).trim() === '') return '-'
const n = Number(v)
if (isNaN(n)) return String(v)
// < 10000:直接显示;>= 10000:转万
if (n >= 10000) {
return `${(n / 10000).toFixed(1)}万 km`
}
return `${Math.round(n)} km`
}
}
}
@@ -155,7 +288,7 @@
.head-search {
background: rgba(255, 255, 255, 1);
border-radius: 18rpx;
border-radius: 9px 9px 0px 0px;
padding: 20rpx 10px;
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
}
@@ -164,85 +297,6 @@
padding: 18rpx 24rpx 40rpx;
}
.car-card {
display: flex;
align-items: stretch;
padding: 18rpx;
border-radius: 18rpx;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
margin-bottom: 18rpx;
}
.thumb {
width: 190rpx;
height: 140rpx;
border-radius: 14rpx;
background: #eef2f7;
flex-shrink: 0;
}
.info {
flex: 1;
margin-left: 18rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.row {
display: flex;
align-items: center;
}
.row1 {
justify-content: space-between;
margin-bottom: 10rpx;
}
.name {
font-size: 30rpx;
font-weight: 700;
color: #111827;
max-width: 420rpx;
}
.tag {
font-size: 22rpx;
padding: 6rpx 12rpx;
border-radius: 999rpx;
background: rgba(255, 151, 47, 0.14);
color: #b45309;
flex-shrink: 0;
}
.row2,
.row3 {
justify-content: space-between;
gap: 16rpx;
}
.kv {
flex: 1;
min-width: 0;
display: flex;
align-items: baseline;
}
.k {
font-size: 22rpx;
color: #6b7280;
margin-right: 10rpx;
flex-shrink: 0;
}
.v {
font-size: 24rpx;
color: #374151;
font-weight: 600;
min-width: 0;
}
.loadmore {
padding: 18rpx 0 6rpx;
}
+179
View File
@@ -0,0 +1,179 @@
<template>
<view class="page">
<!-- 用户信息卡片 -->
<view class="user-card" @click="goToChanginfo">
<view class="user-info">
<image
class="avatar"
:src="userInfo.avatar_url || '/static/image/car.png'"
mode="aspectFill"
/>
<view class="user-details">
<text class="nickname">{{ userInfo.name || '未设置昵称' }}</text>
<text class="phone">{{ userInfo.mobile || '未绑定手机号' }}</text>
</view>
</view>
</view>
<!-- 功能入口 -->
<view class="menu-section">
<view class="menu-item" @tap="goToMyPublish">
<view class="menu-icon">
<u-icon name="list" size="24" color="#3F435B"></u-icon>
</view>
<text class="menu-text">我的发布</text>
<view class="menu-arrow">
<u-icon name="arrow-right" size="18" color="#999"></u-icon>
</view>
</view>
</view>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
export default {
data() {
return {
userInfo: {
avatar_url: '',
name: '',
mobile: ''
}
}
},
onLoad() {
this.getUserInfo()
},
onShow() {
// 页面显示时刷新用户信息
this.getUserInfo()
},
methods: {
// 获取用户信息
getUserInfo() {
request({
url: 'user/getInfo',
method: 'get'
}).then(res => {
if (res.data.code == 0 || res.data.code == 200) {
this.userInfo = {
avatar_url: res.data.data.avatar_url || '',
name: res.data.data.name || '',
mobile: res.data.data.mobile || ''
}
}
}).catch(() => {
// 获取失败时使用默认值
})
},
// 跳转到我的发布列表
goToMyPublish() {
uni.navigateTo({
url: '/pages/index/myPublish'
})
},
// 跳转到个人信息
goToChanginfo() {
uni.navigateTo({
url: '/pages/index/changinfo'
})
},
}
}
</script>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #f4f6f8;
padding: 20rpx;
}
.user-card {
background: rgba(255, 255, 255, 0.95);
border-radius: 18rpx;
padding: 40rpx 30rpx;
margin-bottom: 20rpx;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
}
.user-info {
display: flex;
align-items: center;
}
.avatar {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
background: #eef2f7;
margin-right: 30rpx;
}
.user-details {
flex: 1;
display: flex;
flex-direction: column;
gap: 12rpx;
}
.nickname {
font-size: 32rpx;
font-weight: 700;
color: #111827;
}
.phone {
font-size: 26rpx;
color: #6b7280;
}
.menu-section {
background: rgba(255, 255, 255, 0.95);
border-radius: 18rpx;
overflow: hidden;
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
}
.menu-item {
display: flex;
align-items: center;
padding: 30rpx;
border-bottom: 1px solid #f0f0f0;
transition: background-color 0.2s;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item:active {
background-color: #f9fafb;
}
.menu-icon {
width: 48rpx;
height: 48rpx;
display: flex;
align-items: center;
justify-content: center;
margin-right: 24rpx;
background: #f3f4f6;
border-radius: 12rpx;
}
.menu-text {
flex: 1;
font-size: 30rpx;
color: #111827;
font-weight: 500;
}
.menu-arrow {
display: flex;
align-items: center;
justify-content: center;
}
</style>
+180 -278
View File
@@ -1,88 +1,62 @@
<template>
<view class="page">
<uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="我的"></uni-nav-bar>
<!-- 顶部:标题 + 搜索(不想要搜索可直接删除这一块) -->
<view class="page-head">
<view class="head-search">
<u-search
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@search="onSearch"
@clear="onSearch"
/>
</view>
</view>
<!-- 列表 -->
<view class="list-wrap">
<uni-swipe-action-item
:threshold="0"
:right-options="options1"
@click="bindClick"
>
<view
v-for="(item, idx) in list"
:key="item.id || item.car_id || item.product_id || idx"
class="car-card"
@tap="goDetail(item)"
>
<image class="thumb" src="/static/image/car.png" mode="aspectFill" />
<view class="info">
<view class="row row1">
<text class="name u-line-1">{{ item.name }}</text>
</view>
<view class="row row2">
<view class="kv">
<text class="k">车源地</text>
<text class="v u-line-1">{{ item.source }}</text>
</view>
<view class="kv">
<text class="k">车身颜色</text>
<text class="v u-line-1">{{ item.color }}</text>
</view>
</view>
<view class="row row3">
<view class="kv">
<text class="k">上牌时间</text>
<text class="v">{{ item.plate_time }}</text>
</view>
<view class="kv">
<text class="k">里程</text>
<text class="v">{{ item.mileage }}</text>
</view>
</view>
</view>
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无数据!">
<!-- <uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="首页"></uni-nav-bar> -->
<!-- 顶部:标题 + 搜索(不想要搜索可直接删除这一块) -->
<view class="page-head">
<view class="head-search">
<u-search
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@change="onKeywordChange"
@search="onSearch"
@clear="onSearch"
/>
</view>
</uni-swipe-action-item>
<!-- 空状态 -->
<u-empty v-if="!loading && list.length === 0" text="暂无数据" mode="data" />
<!-- 底部加载状态 -->
<view v-if="list.length > 0" class="loadmore">
<u-loadmore :status="loadStatus" />
</view>
</view>
<view class="list-wrap">
<uni-swipe-action-item
v-for="item in list"
:key="item.id"
:right-options="options1"
@click="swipeClick($event, item)"
>
<CarCard
:item="item"
@pdfchange="onSearch"
@request-price="onRequestPrice"
/>
</uni-swipe-action-item>
</view>
</z-paging>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog
mode="input"
title="请输入价格"
:value="priceDialogValue"
placeholder="请输入车辆价格"
@confirm="dialogInputConfirm"
/>
</uni-popup>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
/**
* 首页列表接口(你如果后端接口不是这个路径,改这里即可)
* 兼容分页:page/per_page(或 page/page_size)
*/
const LIST_API = 'car/list'
import CarCard from '@/components/CarCard/CarCard.vue'
export default {
components: {
CarCard
},
data() {
return {
priceDialogItem: null,
priceDialogIndex: -1,
priceDialogValue: '',
options1: [{
text: '编辑',
style: {
@@ -101,140 +75,142 @@
pageSize: 10,
loading: false,
finished: false,
list: [
{
name:'奥迪Q3 2013款 35 TFSI 舒适型',
source:'北京',
color:'黑色',
plate_time:'2013-07',
mileage:'11万公里'
}
]
}
},
computed: {
loadStatus() {
if (this.loading && this.page === 1) return 'loading'
if (this.loading) return 'loading'
if (this.finished) return 'nomore'
return 'loadmore'
list: []
}
},
onLoad() {
this.fetchList(true)
},
onPullDownRefresh() {
this.fetchList(true).finally(() => {
uni.stopPullDownRefresh()
})
},
onReachBottom() {
if (!this.loading && !this.finished) {
this.fetchList(false)
}
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
// #ifdef H5
try {
const u = new URL(window.location.href)
const r = u.searchParams.get('r')
if (r) {
const target = decodeURIComponent(r)
// 清理地址栏的 r,避免反复跳转
u.searchParams.delete('r')
window.history.replaceState({}, '', u.toString())
// 让首页加载完再跳
setTimeout(() => {
uni.navigateTo({ url: target })
}, 50)
}
} catch (e) {}
// #endif
},
methods: {
onSearch() {
this.fetchList(true)
},
async fetchList(reset = false) {
if (this.loading) return
this.loading = true
try {
if (reset) {
this.page = 1
this.finished = false
}
const res = await request({
url: LIST_API,
method: 'GET',
data: {
page: this.page,
per_page: this.pageSize,
keyword: this.keyword || ''
}
})
const payload = (res && res.data) ? res.data : {}
const data = payload.data || payload || {}
// 兼容不同后端结构:list / data / items / rows / records
let rows =
data.list ||
data.data ||
data.items ||
data.rows ||
data.records ||
[]
if (!Array.isArray(rows)) {
rows = []
}
if (reset) this.list = []
this.list = this.list.concat(rows)
// 兼容 total / last_page / has_more 等字段
const hasMore =
(data.has_more === true) ||
(data.next_page_url ? true : false) ||
(false)
if (rows.length < this.pageSize && !hasMore) {
this.finished = true
} else {
this.page += 1
}
} catch (e) {
console.error('[home fetchList] error:', e)
uni.showToast({ title: e?.message || '加载失败', icon: 'none' })
} finally {
this.loading = false
}
},
goDetail(item) {
// 你后续详情页如果要接 id,这里按后端字段改一下即可
const id = item.id || item.car_id || item.product_id || ''
uni.navigateTo({
url: `/pages/index/detils?id=${encodeURIComponent(id)}`
onRequestPrice(payload) {
// payload: { item, index }
this.priceDialogItem = payload && payload.item ? payload.item : null
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
this.priceDialogValue = ''
this.$nextTick(() => {
this.$refs.inputDialog && this.$refs.inputDialog.open()
})
},
formatPlate(v) {
if (!v || v === '-') return '-'
// 允许:时间戳 / yyyy-mm-dd / yyyy/mm/dd / yyyyMMdd
let d
if (typeof v === 'number' || /^\d+$/.test(String(v))) {
const n = Number(v)
// 秒/毫秒都兼容
d = new Date(n < 1e12 ? n * 1000 : n)
} else {
const s = String(v)
const s2 = s.replace(/\//g, '-').trim()
if (/^\d{8}$/.test(s2)) {
const y = s2.slice(0, 4)
const m = s2.slice(4, 6)
const dd = s2.slice(6, 8)
d = new Date(`${y}-${m}-${dd}T00:00:00`)
dialogInputConfirm(val) {
const item = this.priceDialogItem
const index = this.priceDialogIndex
const price = String(val || '').trim()
if (!item) return
if (!price) {
uni.showToast({ title: '请输入价格', icon: 'none' })
return
}
if (isNaN(price) || Number(price) <= 0) {
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
return
}
request({
url: 'common/usedcar/produce/pdf',
method: 'get',
data: { id: item.id, price }
}).then(res => {
if (res.data.code == 200) {
// 通知刷新列表(你原来就是靠这个事件刷新)
this.onSearch()
// 直接调用对应卡片实例的下载方法(如果 ref 数组存在的话)
const cards = this.$refs.carCard
const card = Array.isArray(cards) ? cards[index] : cards
if (card && typeof card.downloadpdf === 'function') {
card.downloadpdf(item)
}
} else {
d = new Date(s2)
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
}
}
if (isNaN(d.getTime())) return String(v)
const y = d.getFullYear()
const m = String(d.getMonth() + 1).padStart(2, '0')
return `${y}-${m}`
})
},
formatMileage(v) {
if (v === '-' || v === undefined || v === null || String(v).trim() === '') return '-'
const n = Number(v)
if (isNaN(n)) return String(v)
// < 10000:直接显示;>= 10000:转万
if (n >= 10000) {
return `${(n / 10000).toFixed(1)}万 km`
onKeywordChange(val) {
// val 是输入值(uView 通常会传)
this.keyword = val
// 防抖:300ms 内持续输入只触发一次
if (this._kwTimer) clearTimeout(this._kwTimer)
this._kwTimer = setTimeout(() => {
this.onSearch()
}, 300)
},
onSearch() {
this.queryList(this.page,this.pageSize)
},
queryList(pageNo, pageSize, from) {
this.loading = true;
var that = this;
const params = {
current:pageNo,
status:1,
size:10
};
params.keyword = this.keyword;
params.scene = 'self';
request({
url:'common/usedcar/list',
method:'get',
data: params
}).then(res => {
if(res.data.code ==200){
var datas = res.data.data.records;
this.$refs.paging.complete(datas);
}else{
}
uni.stopPullDownRefresh();
//
})
},
swipeClick(e,item){
let {
content
} = e;
if (content.text === '删除') {
uni.showModal({
title: '提示',
content: '是否删除',
success: res => {
if (res.confirm) {
request({
url:'common/usedcar/destroy',
method:'post',
data: {id:item.id}
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
this.queryList()
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
const id = item.id
uni.navigateTo({
url: `/pages/index/publishedit?id=${id}`
})
}
return `${Math.round(n)} km`
}
}
}
@@ -247,13 +223,18 @@
}
.page-head {
// position: fixed;
// width: 100%;
position: fixed;
width: 100%;
bottom: 50px;
z-index: 99;
// padding: 28rpx 24rpx 18rpx;
// background: linear-gradient(180deg, rgba(255, 151, 47, 0.22) 0%, rgba(255, 151, 47, 0.06) 55%, #f4f6f8 100%);
}
.head-search {
background: rgba(255, 255, 255, 0.9);
// border-radius: 18rpx;
padding: 6rpx;
background: rgba(255, 255, 255, 1);
border-radius: 18rpx;
padding: 20rpx 10px;
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
}
@@ -261,85 +242,6 @@
padding: 18rpx 24rpx 40rpx;
}
.car-card {
display: flex;
align-items: stretch;
padding: 18rpx;
border-radius: 18rpx;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
// margin-bottom: 18rpx;
}
.thumb {
width: 190rpx;
height: 140rpx;
border-radius: 14rpx;
background: #eef2f7;
flex-shrink: 0;
}
.info {
flex: 1;
margin-left: 18rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.row {
display: flex;
align-items: center;
}
.row1 {
justify-content: space-between;
margin-bottom: 10rpx;
}
.name {
font-size: 30rpx;
font-weight: 700;
color: #111827;
max-width: 420rpx;
}
.tag {
font-size: 22rpx;
padding: 6rpx 12rpx;
border-radius: 999rpx;
background: rgba(255, 151, 47, 0.14);
color: #b45309;
flex-shrink: 0;
}
.row2,
.row3 {
justify-content: space-between;
gap: 16rpx;
}
.kv {
flex: 1;
min-width: 0;
display: flex;
align-items: baseline;
}
.k {
font-size: 22rpx;
color: #6b7280;
margin-right: 10rpx;
flex-shrink: 0;
}
.v {
font-size: 24rpx;
color: #374151;
font-weight: 600;
min-width: 0;
}
.loadmore {
padding: 18rpx 0 6rpx;
}
+206 -145
View File
@@ -1,72 +1,62 @@
<template>
<view class="page">
<!-- 列表 -->
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无数据!">
<!-- <uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="我的"></uni-nav-bar> -->
<!-- <uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="首页"></uni-nav-bar> -->
<!-- 顶部:标题 + 搜索(不想要搜索可直接删除这一块) -->
<view class="page-head">
<view class="head-search">
<u-search
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@search="onSearch"
@clear="onSearch"
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@change="onKeywordChange"
@search="onSearch"
@clear="onSearch"
/>
</view>
</view>
<view class="list-wrap">
<uni-swipe-action-item
v-for="(item, idx) in list"
:key="item.id "
v-for="item in list"
:key="item.id"
:right-options="options1"
@click="swipeClick($event, item)"
>
<view class="car-card" @click="goDetail(item)">
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
<view class="info">
<view class="row row1">
<text class="name u-line-1">{{ item.product_name }}</text>
</view>
<view class="row row2">
<view class="kv">
<text class="k">车源地</text>
<text class="v u-line-1">{{ item.source_place }}</text>
</view>
<view class="kv">
<text class="k">车身颜色</text>
<text class="v u-line-1">{{ item.body_color }}</text>
</view>
</view>
<view class="row row3">
<view class="kv">
<text class="k">上牌时间</text>
<text class="v">{{ ym(item.plate_time) }}</text>
</view>
<view class="kv">
<text class="k">里程</text>
<text class="v">{{ item.mileage }}</text>
</view>
</view>
</view>
</view>
<CarCard
:item="item"
@pdfchange="onSearch"
@request-price="onRequestPrice"
/>
</uni-swipe-action-item>
</view>
</z-paging>
<uni-popup ref="inputDialog" type="dialog">
<uni-popup-dialog
mode="input"
title="请输入价格"
:value="priceDialogValue"
placeholder="请输入车辆价格"
@confirm="dialogInputConfirm"
/>
</uni-popup>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
import CarCard from '@/components/CarCard/CarCard.vue'
export default {
components: {
CarCard
},
data() {
return {
priceDialogItem: null,
priceDialogIndex: -1,
priceDialogValue: '',
options1: [{
text: '编辑',
style: {
@@ -89,11 +79,182 @@
}
},
onLoad() {
this.initFeishuShare()
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
// #ifdef H5
try {
const u = new URL(window.location.href)
const r = u.searchParams.get('r')
if (r) {
const target = decodeURIComponent(r)
// 清理地址栏的 r,避免反复跳转
u.searchParams.delete('r')
window.history.replaceState({}, '', u.toString())
// 让首页加载完再跳
setTimeout(() => {
uni.navigateTo({ url: target })
}, 50)
}
} catch (e) {}
// #endif
},
methods: {
ym(dateStr) {
return String(dateStr || '').slice(0, 7) // "2026-01"
isFeishuEnv() {
// 飞书/ Lark 客户端内置浏览器 UA 通常包含 Feishu / Lark
try {
const ua = (navigator.userAgent || '').toLowerCase()
return ua.includes('feishu') || ua.includes('lark')
} catch (e) {
return false
}
},
loadFeishuJSSDK() {
// 动态加载飞书 H5 JS-SDK(避免你还要改 public/index.html)
return new Promise((resolve, reject) => {
try {
// 已加载
if (typeof window !== 'undefined' && window.h5sdk && window.tt) return resolve(true)
// H5 才有 document
if (typeof document === 'undefined') return reject(new Error('not in h5 environment'))
// 已插入但未 ready
const existed = document.querySelector('script[data-feishu-h5sdk="1"]')
if (existed) {
existed.addEventListener('load', () => resolve(true))
existed.addEventListener('error', () => reject(new Error('feishu sdk load error')))
return
}
const s = document.createElement('script')
s.async = true
s.src = 'https://lf-scm-cn.feishucdn.com/lark/op/h5-js-sdk-1.5.44.js'
s.onload = () => resolve(true)
s.onerror = () => reject(new Error('feishu sdk load error'))
document.head.appendChild(s)
} catch (e) {
reject(e)
}
})
},
getFeishuSignUrl() {
// 飞书签名通常要求“去掉 hash 的完整 URL”
try {
return window.location.href.split('#')[0]
} catch (e) {
return ''
}
},
initFeishuShare() {
try {
// 确保在飞书环境
// if (!this.isFeishuEnv()) return
// 动态加载 SDK
this.loadFeishuJSSDK()
// 这里需要后端提供签名接口:返回 { appId, timestamp, nonceStr, signature }
// 你可以按你后端习惯改成:request({ url: 'xxx', ... })
// const signUrl = encodeURIComponent(this.getFeishuSignUrl())
const signUrl = this.getFeishuSignUrl()
request({
url:'common/auth/feishu/signature',
method:'get',
data: {url:signUrl,app_id:uni.getStorageSync('fsappid')}
}).then(res => {
var cfg = res.data.data;
window.h5sdk.config({
appId: cfg.appId || uni.getStorageSync('fsappid'),
timestamp: cfg.timestamp,
nonceStr: cfg.nonceStr,
signature: cfg.signature,
jsApiList: ['shareWebContent','share']
})
window.h5sdk.ready(() => {
this._feishuReady = true
})
window.h5sdk.error((err) => {
this._feishuReady = false
console.error('Feishu JSSDK error:', err)
})
})
} catch (e) {
// 不要阻塞页面,失败就走 H5 的兜底分享
console.error('initFeishuShare failed:', e)
}
},
onRequestPrice(payload) {
// payload: { item, index }
this.priceDialogItem = payload && payload.item ? payload.item : null
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
this.priceDialogValue = ''
this.$nextTick(() => {
this.$refs.inputDialog && this.$refs.inputDialog.open()
})
},
// H5 下载:用 a 标签触发
downloadByAnchor(url, filename) {
try {
const a = document.createElement('a')
a.href = url
a.download = filename || ''
a.target = '_blank'
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
} catch (e) {
// 兜底:直接打开
if (typeof window !== 'undefined') window.open(url, '_blank')
}
},
downloadpdf(item) {
request({
url: 'common/usedcar/pdf',
method: 'get',
data: { id: item.id }
}).then(res => {
if (res.data.code == 200) {
this.downloadByAnchor(res.data.data.pdf_url, res.data.data.file_name)
}
})
},
dialogInputConfirm(val) {
const item = this.priceDialogItem
const index = this.priceDialogIndex
const price = String(val || '').trim()
if (!item) return
if (!price) {
uni.showToast({ title: '请输入价格', icon: 'none' })
return
}
if (isNaN(price) || Number(price) <= 0) {
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
return
}
request({
url: 'common/usedcar/produce/pdf',
method: 'get',
data: { id: item.id, price }
}).then(res => {
if (res.data.code == 200) {
// 通知刷新列表(你原来就是靠这个事件刷新)
this.onSearch()
this.downloadpdf(item)
} else {
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
}
})
},
onKeywordChange(val) {
// val 是输入值(uView 通常会传)
this.keyword = val
// 防抖:300ms 内持续输入只触发一次
if (this._kwTimer) clearTimeout(this._kwTimer)
this._kwTimer = setTimeout(() => {
this.onSearch()
}, 300)
},
onSearch() {
this.queryList(this.page,this.pageSize)
@@ -106,8 +267,8 @@
status:1,
size:10
};
params.scene = 'self';
params.keyword = this.keyword;
params.scene = 'self';
request({
url:'common/usedcar/list',
method:'get',
@@ -122,23 +283,6 @@
//
})
},
goDetail(item) {
// 你后续详情页如果要接 id,这里按后端字段改一下即可
const id = item.id || item.car_id || item.product_id || ''
uni.navigateTo({
url: `/pages/index/detils?id=${id}`
})
},
formatMileage(v) {
if (v === '-' || v === undefined || v === null || String(v).trim() === '') return '-'
const n = Number(v)
if (isNaN(n)) return String(v)
// < 10000:直接显示;>= 10000:转万
if (n >= 10000) {
return `${(n / 10000).toFixed(1)}万 km`
}
return `${Math.round(n)} km`
},
swipeClick(e,item){
let {
content
@@ -196,95 +340,12 @@
border-radius: 18rpx;
padding: 20rpx 10px;
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
}
.list-wrap {
padding: 18rpx 24rpx 40rpx;
}
.car-card {
display: flex;
align-items: stretch;
padding: 18rpx;
border-radius: 18rpx;
background: rgba(255, 255, 255, 0.95);
box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.06);
// margin-bottom: 18rpx;
}
.uni-swipe{
margin-bottom: 18rpx;
}
.thumb {
width: 190rpx;
height: 140rpx;
border-radius: 14rpx;
background: #eef2f7;
flex-shrink: 0;
}
.info {
flex: 1;
margin-left: 18rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.row {
display: flex;
align-items: center;
}
.row1 {
justify-content: space-between;
margin-bottom: 10rpx;
}
.name {
font-size: 30rpx;
font-weight: 700;
color: #111827;
max-width: 420rpx;
}
.tag {
font-size: 22rpx;
padding: 6rpx 12rpx;
border-radius: 999rpx;
background: rgba(255, 151, 47, 0.14);
color: #b45309;
flex-shrink: 0;
}
.row2,
.row3 {
justify-content: space-between;
gap: 16rpx;
}
.kv {
flex: 1;
min-width: 0;
display: flex;
align-items: baseline;
}
.k {
font-size: 22rpx;
color: #6b7280;
margin-right: 10rpx;
flex-shrink: 0;
}
.v {
font-size: 24rpx;
color: #374151;
font-weight: 600;
min-width: 0;
}
.loadmore {
padding: 18rpx 0 6rpx;
}
+184
View File
@@ -0,0 +1,184 @@
<template>
<view class="page">
<!-- 列表 -->
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无发布信息!">
<uni-nav-bar
leftText=" "
leftIcon="back"
@clickLeft="goBack"
:fixed="true"
:border="false"
color="#000000"
backgroundColor="#fff"
:statusBar="true"
title="我的发布"
></uni-nav-bar>
<!-- 顶部:搜索 -->
<view class="page-head">
<view class="head-search">
<u-search
v-model="keyword"
placeholder="请输入关键词"
:show-action="false"
shape="round"
@change="onKeywordChange"
@search="onSearch"
@clear="onSearch"
/>
</view>
</view>
<view class="list-wrap">
<uni-swipe-action-item
v-for="item in list"
:key="item.id"
:right-options="options1"
@click="swipeClick($event, item)"
>
<CarCard
:item="item"
/>
</uni-swipe-action-item>
</view>
</z-paging>
</view>
</template>
<script>
import { request } from '@/api/apiT.js'
import CarCard from '@/components/CarCard/CarCard.vue'
export default {
components: {
CarCard
},
data() {
return {
options1: [{
text: '编辑',
style: {
backgroundColor: '#007aff'
}
},
{
text: '删除',
style: {
backgroundColor: '#F56C6C'
}
}],
keyword: '',
page: 1,
pageSize: 10,
loading: false,
finished: false,
list: []
}
},
onLoad() {
},
methods: {
onKeywordChange(val) {
// val 是输入值(uView 通常会传)
this.keyword = val
// 防抖:300ms 内持续输入只触发一次
if (this._kwTimer) clearTimeout(this._kwTimer)
this._kwTimer = setTimeout(() => {
this.onSearch()
}, 300)
},
onSearch() {
this.queryList(this.page, this.pageSize)
},
queryList(pageNo, pageSize, from) {
this.loading = true;
var that = this;
const params = {
current: pageNo,
status: 1,
size: 10,
scene: 'self' // 只获取自己的发布
};
params.keyword = this.keyword;
request({
url: 'common/usedcar/list',
method: 'get',
data: params
}).then(res => {
if (res.data.code == 200) {
var datas = res.data.data.records;
this.$refs.paging.complete(datas);
} else {
}
uni.stopPullDownRefresh();
})
},
goBack() {
uni.navigateBack()
},
swipeClick(e, item) {
let {
content
} = e;
if (content.text === '删除') {
uni.showModal({
title: '提示',
content: '是否删除',
success: res => {
if (res.confirm) {
request({
url: 'common/usedcar/destroy',
method: 'post',
data: { id: item.id }
}).then(res => {
uni.showToast({
title: res.data.message,
icon: 'none'
});
this.queryList()
})
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
} else {
const id = item.id
uni.navigateTo({
url: `/pages/index/publishedit?id=${id}`
})
}
}
}
}
</script>
<style lang="scss" scoped>
.page {
min-height: 100vh;
background: #f4f6f8;
}
.page-head {
position: fixed;
width: 100%;
bottom: 0px;
z-index: 99;
}
.head-search {
background: rgba(255, 255, 255, 1);
border-radius: 18rpx;
padding: 20rpx 10px;
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
}
.list-wrap {
padding: 18rpx 24rpx 40rpx;
}
.loadmore {
padding: 18rpx 0 6rpx;
}
</style>
+438 -17
View File
@@ -4,16 +4,26 @@
<view class="content">
<view class="cell">
<view>产品名称 <text class="red">*</text></view>
<view class="right">
<input placeholder="请输入产品名称" v-model="carinfo.product_name" />
<view class="right right-bind">
<input class="inp" placeholder="请输入车辆的品牌 系列查找车型" v-model="carinfo.product_name" />
<view class="bind-btn" @tap.stop="onBindByName">绑定</view>
</view>
</view>
<view class="cell">
<!-- 绑定结果提示(已绑定时显示) -->
<view v-if="bindState.boundProduct" class="bind-tip">
<text class="bind-tip-text">已绑定:{{ bindState.boundProduct.name || bindState.boundProduct.product_name || bindState.boundProduct.title || '-' }}</text>
<text class="bind-tip-clear" @tap.stop="clearBind">清除</text>
</view>
<view v-else class="bind-tip">
<text>例:比亚迪海狮07DM</text>
</view>
<!-- <view class="cell">
<view>车辆识别码</view>
<view class="right">
<input placeholder="请输入车架号/VIN码" v-model="carinfo.vin" />
</view>
</view>
</view> -->
<view class="cell">
<view>车价(¥)</view>
<view class="right">
@@ -26,12 +36,12 @@
<input placeholder="请输入车源地" v-model="carinfo.source_place" />
</view>
</view>
<view class="cell">
<!-- <view class="cell">
<view>上牌地</view>
<view class="right">
<input placeholder="请输入上牌地" v-model="carinfo.plate_place" />
</view>
</view>
</view> -->
<view class="cell">
<view>上牌时间</view>
<view class="right">
@@ -59,6 +69,12 @@
<input placeholder="请输入排量" v-model="carinfo.displacement" />
</view>
</view>
<view class="cell">
<view>马力</view>
<view class="right">
<input placeholder="请输入马力" v-model="carinfo.power" />
</view>
</view>
<view class="cell">
<view>里程</view>
<view class="right">
@@ -87,11 +103,65 @@
<textarea auto-height v-model="carinfo.condition_desc" placeholder="请输入车况介绍"/>
</view>
</view>
<view class="cont">
<view class="conts">附件</view>
<view class="media-upload-wrapper">
<uni-file-picker ref="mediaPicker1" limit="20" fileMediatype="all" @select="selectMedia1" @delete="delfn1" >
<view class="upload-icon-wrapper">
<image src="/static/image/photo.png" mode="" class="addimg"></image>
</view>
</uni-file-picker>
</view>
</view>
</view>
<view class="zw">
<button class="btn" @click="draftadd">提交</button>
</view>
</view>
<!-- 绑定产品弹框 -->
<view v-if="bindState.showDialog" class="bind-mask" @tap="closeBindDialog">
<view class="bind-dialog" @tap.stop>
<view class="bind-dialog-head">
<text class="bind-dialog-title">选择要绑定的产品</text>
<text class="bind-dialog-close" @tap="closeBindDialog">×</text>
</view>
<!-- 弹框内搜索(仅过滤接口返回列表) -->
<view class="bind-search" v-if="bindState.list && bindState.list.length">
<input class="bind-search-input" v-model="bindState.keyword" placeholder="搜索产品名称" placeholder-class="bind-search-placeholder" />
<text v-if="bindState.keyword" class="bind-search-clear" @tap.stop="bindState.keyword = ''">清除</text>
</view>
<scroll-view scroll-y class="bind-dialog-body">
<view v-if="bindState.loading" class="bind-loading">加载中…</view>
<view v-else-if="!bindState.list.length" class="bind-empty">未找到匹配的产品</view>
<view v-else-if="!filteredBindList.length" class="bind-empty">未找到匹配结果</view>
<view v-else>
<view
class="bind-item"
:class="{ active: bindState.selectedId === getBindItemId(it, idx) }"
v-for="(it, idx) in filteredBindList"
:key="getBindItemId(it, idx)"
@tap="selectBind(it, idx)"
>
<view class="bind-item-main">
<text class="bind-item-title">{{ it.name || it.product_name || it.title || ('产品 ' + (idx + 1)) }}</text>
<text class="bind-item-sub">{{ formatBindSub(it) }}</text>
</view>
<view class="bind-item-check">
<view class="check-dot" v-if="bindState.selectedId === getBindItemId(it, idx)"></view>
</view>
</view>
</view>
</scroll-view>
<view class="bind-dialog-foot">
<view class="btn btn-ghost" @tap="closeBindDialog">取消</view>
<view class="btn btn-primary" :class="{ disabled: !bindState.selectedId }" @tap="confirmBind">确认绑定</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { request,showToast } from '@/api/apiT.js'
@@ -99,6 +169,14 @@
data() {
return {
maxMedia:20,
bindState:{
showDialog:false,
loading:false,
list:[],
selectedId:'',
boundProduct:null,
keyword:''
},
carinfo:{
product_name:'',
vin:'',
@@ -107,30 +185,170 @@
plate_place:'',
plate_time:'',
displacement:'',
power:'',
body_color:'',
images:[],
condition_desc:'',
mileage:''
mileage:'',
attachment:[],
crawl_title:'',
crawl_brand:'',
crawl_series:'',
crawl_year:'',
crawl_msrp:'',
crawl_car_id:''
}
}
},
onLoad() {
},
computed: {
// 弹框内搜索过滤(仅前端过滤接口返回结果,不重复请求)
filteredBindList() {
const list = Array.isArray(this.bindState.list) ? this.bindState.list : []
const kw = String(this.bindState.keyword || '').trim().toLowerCase()
if (!kw) return list
return list.filter((it, idx) => {
const id = String(it.id || it.product_id || it.code || idx).toLowerCase()
const name = String(it.name || it.product_name || it.title || '').toLowerCase()
const sub = String(this.formatBindSub(it) || '').toLowerCase()
return id.includes(kw) || name.includes(kw) || sub.includes(kw)
})
}
},
methods: {
onBorrowTimeChange(e) {
this.carinfo.plate_time = e
},
uploadfn(imgUrl){
// 绑定:根据输入的“产品名称”拉取候选产品
onBindByName() {
const name = String(this.carinfo.product_name || '').trim()
if (!name) {
return uni.showToast({ title: '请先输入产品名称', icon: 'none' })
}
// 打开弹框 + loading
this.bindState.showDialog = true
this.bindState.loading = true
this.bindState.list = []
this.bindState.selectedId = ''
this.bindState.keyword = ''
/**
* TODO:把这里的接口地址换成你真实的“按名称搜索产品”接口
* - 传参:name(产品名称)
* - 返回:数组(可能多个匹配)
*/
request({
url: 'common/usedcar/crawl', // <== 这里改成你的真实接口
method: 'get',
data: { keyword:name }
}).then(res => {
if(res.data.code ==200){
this.bindState.list = res.data.data.model
}else{
uni.showToast({ title: res.data.message, icon: 'none' })
}
}).catch(() => {
uni.showToast({ title: '拉取产品失败,请稍后重试', icon: 'none' })
}).finally(() => {
this.bindState.loading = false
})
},
closeBindDialog() {
this.bindState.showDialog = false
this.bindState.keyword = ''
},
getBindItemId(it, idx) {
return String(it.id || it.product_id || it.requisition_item_id || it.code || idx)
},
selectBind(it, idx) {
this.bindState.selectedId = this.getBindItemId(it, idx)
this.bindState._selected = it
},
formatBindSub(it) {
// 按你接口字段自行补充展示:编码/规格/分类/库存等
const parts = []
if (it.sku || it.code) parts.push('编码:' + (it.sku || it.code))
if (it.category_name) parts.push('分类:' + it.category_name)
if (it.price) parts.push('价格:' + it.price)
return parts.join(' · ')
},
confirmBind() {
if (!this.bindState.selectedId || !this.bindState._selected) return
const it = this.bindState._selected
// 写入“已绑定”状态(你后续提交表单时可直接带上 bound_product_id)
this.bindState.boundProduct = it
this.carinfo.crawl_title = it.title
this.carinfo.crawl_brand = it.brand_name
this.carinfo.crawl_series = it.series_name
this.carinfo.crawl_year = it.year
this.carinfo.crawl_msrp = it.msrp
this.carinfo.crawl_car_id = it.car_id
console.log(it)
this.closeBindDialog()
uni.showToast({ title: '绑定成功', icon: 'none' })
},
clearBind() {
this.carinfo.crawl_title = ''
this.carinfo.crawl_brand = ''
this.carinfo.crawl_series = ''
this.carinfo.crawl_year = ''
this.carinfo.crawl_msrp = ''
this.carinfo.crawl_car_id = ''
this.bindState.boundProduct = null
uni.showToast({ title: '已清除绑定', icon: 'none' })
},
uploadfn(imgUrl,scene){
uni.showLoading({
title: '上传中'
});
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://usedcar.dev.hnxinyouhe.com/upload/image?scene=usedcarimg',
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
filePath: imgUrl,
name: 'image',
name: 'file',
header:{'Fdesk-Auth-Token': uni.getStorageSync('token'),'Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
success: (uploadFileRes) => {
const res = JSON.parse(uploadFileRes.data || '{}')
if(res && res.data && res.data.href){
resolve(res.data.href)
uni.hideLoading();
uni.showToast({
title:res.message,
icon:'none'
})
if(res && res.data && res.data.file_name){
resolve(res.data.file_name)
}else{
reject('上传失败')
}
},
fail: (err) => reject(err)
});
})
},
uploadfndile(imgUrl,scene){
uni.showLoading({
title: '上传中'
});
return new Promise((resolve, reject) => {
uni.uploadFile({
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
filePath: imgUrl,
name: 'file',
header:{'Fdesk-Auth-Token': uni.getStorageSync('token'),'Fdesk-Login-Type': 'feishu','Fdesk-System-Code':'fdesk'},
success: (uploadFileRes) => {
const res = JSON.parse(uploadFileRes.data || '{}')
uni.hideLoading();
uni.showToast({
title:res.message,
icon:'none'
})
if(res && res.data && res.data.file_name){
resolve(res.data)
}else{
reject('上传失败')
}
@@ -146,7 +364,7 @@
if(paths.length === 0){
return
}
Promise.all(paths.map(p => this.uploadfn(p))).then(urls => {
Promise.all(paths.map(p => this.uploadfn(p,'usedcarimg'))).then(urls => {
urls.forEach(url => {
this.carinfo.images.push(url)
})
@@ -160,6 +378,30 @@
delfn(e){
this.carinfo.images.splice(e.index, 1)
},
selectMedia1(e){
const allowCount = this.maxMedia - this.carinfo.attachment.length
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
const paths = tempFilePaths.slice(0, allowCount)
if(paths.length === 0){
return
}
Promise.all(paths.map(p => this.uploadfndile(p,'usedcarfile'))).then(urls => {
urls.forEach(url => {
const obj={}
obj.name =url.original_name
obj.src =url.file_name
this.carinfo.attachment.push(obj)
})
}).catch(() => {
uni.showToast({
title:'图片上传失败,请重试',
icon:'none'
})
})
},
delfn1(e){
this.carinfo.attachment.splice(e.index, 1)
},
draftadd(){
const payload = {
...this.carinfo,
@@ -180,7 +422,7 @@
});
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index',// 替换为你要跳转的页面路径
url: '/pages/index/index',// 替换为你要跳 转的页面路径
});
}, 1000);
})
@@ -198,7 +440,7 @@
color: red;
}
.content{
margin: 20px 12px;
// margin: 20px 12px;
background: #FFFFFF;
border-radius: 10px;
}
@@ -223,7 +465,7 @@
position: relative;
display: flex;
justify-content:space-between;
padding: 18px 20px;
padding: 14px 10px;
/* border-bottom: 1px solid #C3C3C3; */
align-items: center;
font-weight: 500;
@@ -318,4 +560,183 @@
width: 215rpx;
height: 215rpx;
}
/* 产品名称 + 绑定按钮 */
.right-bind{
flex-direction: row;
align-items: center;
display: flex;
width: 74%;
}
.right-bind .inp{
flex: 1;
font-size: 28rpx;
}
.bind-btn{
margin-left: 16rpx;
padding: 0 18rpx;
height: 56rpx;
line-height: 56rpx;
border-radius: 12rpx;
background: #2E6CF6;
color: #fff;
font-size: 26rpx;
}
.bind-tip{
// margin: 0 24rpx 16rpx;
padding: 12rpx 18rpx;
// border-radius: 12rpx;
background: #F3F6FF;
display: flex;
align-items: center;
justify-content: space-between;
}
.bind-tip-text{
color: #2B3A55;
font-size: 24rpx;
}
.bind-tip-clear{
color: #2E6CF6;
font-size: 24rpx;
}
/* 弹框搜索 */
.bind-search{
margin: 5px 24rpx 16rpx;
padding: 12rpx 18rpx;
border-radius: 12rpx;
background: #F3F6FF;
display: flex;
align-items: center;
justify-content: space-between;
}
.bind-search-input{
flex: 1;
font-size: 26rpx;
color: #333;
}
.bind-search-placeholder{
color: #9AA6BF;
}
.bind-search-clear{
margin-left: 16rpx;
font-size: 24rpx;
color: #2E6CF6;
}
/* 绑定弹框 */
.bind-mask{
position: fixed;
left: 0; right: 0; top: 0; bottom: 0;
background: rgba(0,0,0,0.45);
z-index: 999;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
}
.bind-dialog{
width: 100%;
max-width: 680rpx;
background: #fff;
border-radius: 20rpx;
overflow: hidden;
}
.bind-dialog-head{
height: 96rpx;
padding: 0 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
border-bottom: 1px solid #f0f0f0;
}
.bind-dialog-title{
font-size: 30rpx;
font-weight: 600;
color: #111;
}
.bind-dialog-close{
font-size: 40rpx;
color: #999;
line-height: 1;
}
.bind-dialog-body{
max-height: 720rpx;
padding: 12rpx 0;
}
.bind-loading,.bind-empty{
padding: 40rpx 24rpx;
color: #888;
text-align: center;
font-size: 26rpx;
}
.bind-item{
padding: 18rpx 24rpx;
display: flex;
align-items: center;
justify-content: space-between;
}
.bind-item.active{
background: #F3F6FF;
}
.bind-item-main{
flex: 1;
padding-right: 16rpx;
}
.bind-item-title{
font-size: 28rpx;
font-weight: 600;
color: #222;
display: block;
}
.bind-item-sub{
margin-top: 6rpx;
font-size: 24rpx;
color: #777;
display: block;
}
.bind-item-check{
width: 44rpx;
height: 44rpx;
border-radius: 50%;
border: 2rpx solid #2E6CF6;
display: flex;
align-items: center;
justify-content: center;
}
.check-dot{
width: 22rpx;
height: 22rpx;
border-radius: 50%;
background: #2E6CF6;
}
.bind-dialog-foot{
padding: 16rpx 24rpx 22rpx;
display: flex;
gap: 16rpx;
border-top: 1px solid #f0f0f0;
}
.btn{
flex: 1;
height: 76rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
font-size: 28rpx;
}
.btn-ghost{
background: #F5F6F8;
color: #333;
}
.btn-primary{
background: #2E6CF6;
color: #fff;
}
.btn-primary.disabled{
opacity: .45;
}
</style>
File diff suppressed because it is too large Load Diff
+18 -4
View File
@@ -44,6 +44,15 @@
this.startDots()
// #ifdef H5
this._code = options.code || ''
// 支持从回调参数里带 redirect(有些场景会拼到回调地址上)
const redirect = options.redirect || options.r || ''
if (redirect) {
try {
uni.setStorageSync('post_login_redirect', decodeURIComponent(redirect))
} catch (e) {
uni.setStorageSync('post_login_redirect', redirect)
}
}
// #endif
if (!this._code) {
@@ -94,19 +103,24 @@
uni.setStorageSync('token', token)
this.title = '登录成功'
this.desc = '正在进入首页'
this.desc = '正在进入页面'
this.goHomeSmooth()
this.goRedirectSmooth()
} catch (err) {
console.error('[feishu callback] error:', err)
this.fail(err?.message || '登录失败')
}
},
goHomeSmooth() {
getRedirectTarget() {
return uni.getStorageSync('post_login_redirect') || '/pages/index/index'
},
goRedirectSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({ url: '/pages/index/index' })
const target = this.getRedirectTarget()
uni.removeStorageSync('post_login_redirect')
uni.reLaunch({ url: target })
}, wait)
},
retry() {
+20 -6
View File
@@ -37,6 +37,16 @@
onLoad(options) {
this.fsappid = options.appid || '';
uni.setStorageSync('fsappid', this.fsappid);
// 保存登录成功后的回跳地址(支持 redirect/r)
const redirect = options.redirect || options.r || ''
if (redirect) {
// options 里可能已被 decode,也可能没有,保险起见 try 一下
try {
uni.setStorageSync('post_login_redirect', decodeURIComponent(redirect))
} catch (e) {
uni.setStorageSync('post_login_redirect', redirect)
}
}
this._startedAt = Date.now()
this.startDots()
this.silentAuth()
@@ -65,8 +75,8 @@
const token = uni.getStorageSync('token')
if (token) {
this.title = '已登录'
this.desc = '正在进入首页'
return this.goHomeSmooth()
this.desc = '正在进入页面'
return this.goRedirectSmooth()
}
// 2) 获取飞书授权跳转地址(静默授权/免登)
@@ -98,13 +108,17 @@
uni.showToast({ title: err?.message || '登录失败', icon: 'none' })
}
},
goHomeSmooth() {
getRedirectTarget() {
return uni.getStorageSync('post_login_redirect') || '/pages/index/index'
},
goRedirectSmooth() {
const elapsed = Date.now() - this._startedAt
const wait = Math.max(0, this.minStayMs - elapsed)
setTimeout(() => {
uni.reLaunch({
url: '/pages/index/index'
})
const target = this.getRedirectTarget()
// 用完即清,避免后续误跳
uni.removeStorageSync('post_login_redirect')
uni.reLaunch({ url: target })
}, wait)
},
sleep(ms) {
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B