修改
This commit is contained in:
Vendored
+16
@@ -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
@@ -1,7 +1,7 @@
|
|||||||
// const baseUrl = "https://api.collect.hs.hnzhwlkj.club/"; //这里放置url域名32044
|
// const baseUrl = "https://api.collect.hs.hnzhwlkj.club/"; //这里放置url域名32044
|
||||||
// const baseUrl = "https://api.collect.xyh.muzili.top/"; //这里放置url域名32044
|
const baseUrl = "https://userdcar-server.hnxinyouhe.com/"; //这里放置url域名32044
|
||||||
const baseUrl = "https://usedcar.dev.hnxinyouhe.com/"; //这里放置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 = "http://219.157.255.213:36010/"; //这里放置url域名32044
|
||||||
export function request(options){//封装的requset
|
export function request(options){//封装的requset
|
||||||
let { url,data,method } = options;
|
let { url,data,method } = options;
|
||||||
data = data || {},
|
data = data || {},
|
||||||
@@ -13,7 +13,7 @@ export function request(options){//封装的requset
|
|||||||
uni.request({//这里是uniapp网络请求的api
|
uni.request({//这里是uniapp网络请求的api
|
||||||
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
||||||
data,
|
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
|
method:method||"GET",//默认请求方式是get
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res)
|
resolve(res)
|
||||||
@@ -31,7 +31,7 @@ export function requestx(options){//封装的requset
|
|||||||
uni.request({//这里是uniapp网络请求的api
|
uni.request({//这里是uniapp网络请求的api
|
||||||
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
url: baseUrl + url, //仅为示例,并非真实接口地址。
|
||||||
data,
|
data,
|
||||||
header:{'content-type': 'application/x-www-form-urlencoded','Authorization': 'Bearer ' + uni.getStorageSync('openid')},
|
header:{'Authorization': 'Bearer ' + uni.getStorageSync('openid')},
|
||||||
method:method||"GET",//默认请求方式是get
|
method:method||"GET",//默认请求方式是get
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
resolve(res)
|
resolve(res)
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
@@ -18,5 +18,6 @@
|
|||||||
<body>
|
<body>
|
||||||
<div id="app"><!--app-html--></div>
|
<div id="app"><!--app-html--></div>
|
||||||
<script type="module" src="/main.js"></script>
|
<script type="module" src="/main.js"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
+18
@@ -68,6 +68,24 @@
|
|||||||
"navigationStyle":"custom"// 去掉微信小程序顶部导航
|
"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",
|
"path" : "pages/login/feishu-callback",
|
||||||
"style" :
|
"style" :
|
||||||
|
|||||||
@@ -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
@@ -9,11 +9,11 @@
|
|||||||
<text class="name">{{ detail.product_name }}</text>
|
<text class="name">{{ detail.product_name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="kv">
|
<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="k">车辆识别码</text>
|
||||||
<text class="v ellipsis">{{ detail.vin }}</text>
|
<text class="v ellipsis">{{ detail.vin }}</text>
|
||||||
<text class="copy" v-if="detail.vin">复制</text>
|
<text class="copy" v-if="detail.vin">复制</text>
|
||||||
</view>
|
</view> -->
|
||||||
|
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
<text class="k">车价(¥)</text>
|
<text class="k">车价(¥)</text>
|
||||||
@@ -25,10 +25,10 @@
|
|||||||
<text class="v">{{ detail.source_place}}</text>
|
<text class="v">{{ detail.source_place}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="kv-item">
|
<!-- <view class="kv-item">
|
||||||
<text class="k">上牌地</text>
|
<text class="k">上牌地</text>
|
||||||
<text class="v">{{ detail.plate_place }}</text>
|
<text class="v">{{ detail.plate_place }}</text>
|
||||||
</view>
|
</view> -->
|
||||||
|
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
<text class="k">上牌时间</text>
|
<text class="k">上牌时间</text>
|
||||||
@@ -44,10 +44,13 @@
|
|||||||
<text class="k">里程</text>
|
<text class="k">里程</text>
|
||||||
<text class="v">{{ detail.mileage }}</text>
|
<text class="v">{{ detail.mileage }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="kv-item">
|
||||||
|
<text class="k">马力</text>
|
||||||
|
<text class="v">{{ detail.power }}</text>
|
||||||
|
</view>
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
<text class="k">车身颜色</text>
|
<text class="k">车身颜色</text>
|
||||||
<text class="v">{{ detail.color }}</text>
|
<text class="v">{{ detail.body_color }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
@@ -56,6 +59,15 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</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="hero">
|
||||||
<view class="section-title">产品图</view>
|
<view class="section-title">产品图</view>
|
||||||
<!-- 有图:九宫格/多行平铺;无图:占位 -->
|
<!-- 有图:九宫格/多行平铺;无图:占位 -->
|
||||||
@@ -70,11 +82,17 @@
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="hero">
|
||||||
<!-- 车况介绍 -->
|
<view class="section-title">附件</view>
|
||||||
<view class="card">
|
<view v-if="detail.attachment_pull.length>0">
|
||||||
<view class="section-title">车况介绍</view>
|
<view v-for="(file, i) in detail.attachment_pull" :key="i" class="fujian" @click="reviewFile(file)">
|
||||||
<text class="desc">{{ detail.condition_desc }}</text>
|
<p>{{file.name}}</p>
|
||||||
|
<view>查看</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="noneview" v-else>
|
||||||
|
<img src="/static/image/none.png" alt="">
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -86,6 +104,7 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
id: '',
|
id: '',
|
||||||
|
appid: '',
|
||||||
detail: {},
|
detail: {},
|
||||||
currentImageIndex: 0
|
currentImageIndex: 0
|
||||||
}
|
}
|
||||||
@@ -111,6 +130,20 @@
|
|||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
// 1) 支持通过 id 打开:/pages/index/detils?id=123
|
// 1) 支持通过 id 打开:/pages/index/detils?id=123
|
||||||
this.id = options?.id || ''
|
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()
|
this.getshows()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -146,6 +179,23 @@
|
|||||||
current: this.images[this.currentImageIndex],
|
current: this.images[this.currentImageIndex],
|
||||||
urls: this.images
|
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;
|
color: #ff972f;
|
||||||
font-size: 24rpx;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -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>
|
||||||
+188
-134
@@ -20,52 +20,40 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="list-wrap">
|
<view class="list-wrap">
|
||||||
<view
|
<CarCard
|
||||||
v-for="(item, idx) in list"
|
v-for="item in list"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
class="car-card"
|
:item="item"
|
||||||
@tap="goDetail(item)"
|
@pdfchange="onSearch"
|
||||||
>
|
@request-price="onRequestPrice"
|
||||||
<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>
|
|
||||||
</view>
|
</view>
|
||||||
</z-paging>
|
</z-paging>
|
||||||
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
|
<uni-popup-dialog
|
||||||
|
mode="input"
|
||||||
|
title="请输入价格"
|
||||||
|
:value="priceDialogValue"
|
||||||
|
placeholder="请输入车辆价格"
|
||||||
|
@confirm="dialogInputConfirm"
|
||||||
|
/>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request } from '@/api/apiT.js'
|
import { request } from '@/api/apiT.js'
|
||||||
|
import CarCard from '@/components/CarCard/CarCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CarCard
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
priceDialogItem: null,
|
||||||
|
priceDialogIndex: -1,
|
||||||
|
priceDialogValue: '',
|
||||||
keyword: '',
|
keyword: '',
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -75,11 +63,173 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
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: {
|
methods: {
|
||||||
ym(dateStr) {
|
isFeishuEnv() {
|
||||||
return String(dateStr || '').slice(0, 7) // "2026-01"
|
// 飞书/ 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) {
|
onKeywordChange(val) {
|
||||||
// val 是输入值(uView 通常会传)
|
// val 是输入值(uView 通常会传)
|
||||||
@@ -116,23 +266,6 @@
|
|||||||
uni.stopPullDownRefresh();
|
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 {
|
.head-search {
|
||||||
background: rgba(255, 255, 255, 1);
|
background: rgba(255, 255, 255, 1);
|
||||||
border-radius: 18rpx;
|
border-radius: 9px 9px 0px 0px;
|
||||||
padding: 20rpx 10px;
|
padding: 20rpx 10px;
|
||||||
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
@@ -164,85 +297,6 @@
|
|||||||
padding: 18rpx 24rpx 40rpx;
|
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 {
|
.loadmore {
|
||||||
padding: 18rpx 0 6rpx;
|
padding: 18rpx 0 6rpx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
+161
-259
@@ -1,6 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
<uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="我的"></uni-nav-bar>
|
<!-- 列表 -->
|
||||||
|
<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="page-head">
|
||||||
<view class="head-search">
|
<view class="head-search">
|
||||||
@@ -9,80 +11,52 @@
|
|||||||
placeholder="请输入关键词"
|
placeholder="请输入关键词"
|
||||||
:show-action="false"
|
:show-action="false"
|
||||||
shape="round"
|
shape="round"
|
||||||
|
@change="onKeywordChange"
|
||||||
@search="onSearch"
|
@search="onSearch"
|
||||||
@clear="onSearch"
|
@clear="onSearch"
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 列表 -->
|
|
||||||
<view class="list-wrap">
|
<view class="list-wrap">
|
||||||
<uni-swipe-action-item
|
<uni-swipe-action-item
|
||||||
:threshold="0"
|
v-for="item in list"
|
||||||
|
:key="item.id"
|
||||||
:right-options="options1"
|
:right-options="options1"
|
||||||
@click="bindClick"
|
@click="swipeClick($event, item)"
|
||||||
>
|
>
|
||||||
<view
|
<CarCard
|
||||||
v-for="(item, idx) in list"
|
:item="item"
|
||||||
:key="item.id || item.car_id || item.product_id || idx"
|
@pdfchange="onSearch"
|
||||||
class="car-card"
|
@request-price="onRequestPrice"
|
||||||
@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>
|
|
||||||
</view>
|
|
||||||
</uni-swipe-action-item>
|
</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>
|
||||||
|
</z-paging>
|
||||||
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
|
<uni-popup-dialog
|
||||||
|
mode="input"
|
||||||
|
title="请输入价格"
|
||||||
|
:value="priceDialogValue"
|
||||||
|
placeholder="请输入车辆价格"
|
||||||
|
@confirm="dialogInputConfirm"
|
||||||
|
/>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request } from '@/api/apiT.js'
|
import { request } from '@/api/apiT.js'
|
||||||
|
import CarCard from '@/components/CarCard/CarCard.vue'
|
||||||
/**
|
|
||||||
* 首页列表接口(你如果后端接口不是这个路径,改这里即可)
|
|
||||||
* 兼容分页:page/per_page(或 page/page_size)
|
|
||||||
*/
|
|
||||||
const LIST_API = 'car/list'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CarCard
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
priceDialogItem: null,
|
||||||
|
priceDialogIndex: -1,
|
||||||
|
priceDialogValue: '',
|
||||||
options1: [{
|
options1: [{
|
||||||
text: '编辑',
|
text: '编辑',
|
||||||
style: {
|
style: {
|
||||||
@@ -101,141 +75,143 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
loading: false,
|
loading: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
list: [
|
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'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.fetchList(true)
|
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
|
||||||
},
|
// #ifdef H5
|
||||||
onPullDownRefresh() {
|
try {
|
||||||
this.fetchList(true).finally(() => {
|
const u = new URL(window.location.href)
|
||||||
uni.stopPullDownRefresh()
|
const r = u.searchParams.get('r')
|
||||||
})
|
if (r) {
|
||||||
},
|
const target = decodeURIComponent(r)
|
||||||
onReachBottom() {
|
// 清理地址栏的 r,避免反复跳转
|
||||||
if (!this.loading && !this.finished) {
|
u.searchParams.delete('r')
|
||||||
this.fetchList(false)
|
window.history.replaceState({}, '', u.toString())
|
||||||
|
// 让首页加载完再跳
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateTo({ url: target })
|
||||||
|
}, 50)
|
||||||
}
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
// #endif
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
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()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
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 {
|
||||||
|
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() {
|
onSearch() {
|
||||||
this.fetchList(true)
|
this.queryList(this.page,this.pageSize)
|
||||||
},
|
},
|
||||||
async fetchList(reset = false) {
|
queryList(pageNo, pageSize, from) {
|
||||||
if (this.loading) return
|
this.loading = true;
|
||||||
this.loading = true
|
var that = this;
|
||||||
try {
|
const params = {
|
||||||
if (reset) {
|
current:pageNo,
|
||||||
this.page = 1
|
status:1,
|
||||||
this.finished = false
|
size:10
|
||||||
}
|
};
|
||||||
|
params.keyword = this.keyword;
|
||||||
const res = await request({
|
params.scene = 'self';
|
||||||
url: LIST_API,
|
request({
|
||||||
method: 'GET',
|
url:'common/usedcar/list',
|
||||||
data: {
|
method:'get',
|
||||||
page: this.page,
|
data: params
|
||||||
per_page: this.pageSize,
|
}).then(res => {
|
||||||
keyword: this.keyword || ''
|
if(res.data.code ==200){
|
||||||
}
|
var datas = res.data.data.records;
|
||||||
})
|
this.$refs.paging.complete(datas);
|
||||||
|
|
||||||
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{
|
}else{
|
||||||
this.page += 1
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.error('[home fetchList] error:', e)
|
|
||||||
uni.showToast({ title: e?.message || '加载失败', icon: 'none' })
|
|
||||||
} finally {
|
|
||||||
this.loading = false
|
|
||||||
}
|
}
|
||||||
|
uni.stopPullDownRefresh();
|
||||||
|
//
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
swipeClick(e,item){
|
||||||
goDetail(item) {
|
let {
|
||||||
// 你后续详情页如果要接 id,这里按后端字段改一下即可
|
content
|
||||||
const id = item.id || item.car_id || item.product_id || ''
|
} = 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({
|
uni.navigateTo({
|
||||||
url: `/pages/index/detils?id=${encodeURIComponent(id)}`
|
url: `/pages/index/publishedit?id=${id}`
|
||||||
})
|
})
|
||||||
},
|
|
||||||
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`)
|
|
||||||
} else {
|
|
||||||
d = new Date(s2)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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`
|
|
||||||
}
|
|
||||||
return `${Math.round(n)} km`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -247,13 +223,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.page-head {
|
.page-head {
|
||||||
// position: fixed;
|
position: fixed;
|
||||||
// width: 100%;
|
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 {
|
.head-search {
|
||||||
background: rgba(255, 255, 255, 0.9);
|
background: rgba(255, 255, 255, 1);
|
||||||
// border-radius: 18rpx;
|
border-radius: 18rpx;
|
||||||
padding: 6rpx;
|
padding: 20rpx 10px;
|
||||||
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,85 +242,6 @@
|
|||||||
padding: 18rpx 24rpx 40rpx;
|
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 {
|
.loadmore {
|
||||||
padding: 18rpx 0 6rpx;
|
padding: 18rpx 0 6rpx;
|
||||||
}
|
}
|
||||||
|
|||||||
+199
-138
@@ -1,10 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<view class="page">
|
<view class="page">
|
||||||
|
|
||||||
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<z-paging ref="paging" v-model="list" @query="queryList" empty-view-text="暂无数据!">
|
<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="page-head">
|
||||||
<view class="head-search">
|
<view class="head-search">
|
||||||
@@ -13,6 +11,7 @@
|
|||||||
placeholder="请输入关键词"
|
placeholder="请输入关键词"
|
||||||
:show-action="false"
|
:show-action="false"
|
||||||
shape="round"
|
shape="round"
|
||||||
|
@change="onKeywordChange"
|
||||||
@search="onSearch"
|
@search="onSearch"
|
||||||
@clear="onSearch"
|
@clear="onSearch"
|
||||||
/>
|
/>
|
||||||
@@ -20,53 +19,44 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="list-wrap">
|
<view class="list-wrap">
|
||||||
<uni-swipe-action-item
|
<uni-swipe-action-item
|
||||||
v-for="(item, idx) in list"
|
v-for="item in list"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:right-options="options1"
|
:right-options="options1"
|
||||||
@click="swipeClick($event, item)"
|
@click="swipeClick($event, item)"
|
||||||
>
|
>
|
||||||
<view class="car-card" @click="goDetail(item)">
|
<CarCard
|
||||||
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
|
:item="item"
|
||||||
<view class="info">
|
@pdfchange="onSearch"
|
||||||
<view class="row row1">
|
@request-price="onRequestPrice"
|
||||||
<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>
|
|
||||||
</uni-swipe-action-item>
|
</uni-swipe-action-item>
|
||||||
</view>
|
</view>
|
||||||
</z-paging>
|
</z-paging>
|
||||||
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
|
<uni-popup-dialog
|
||||||
|
mode="input"
|
||||||
|
title="请输入价格"
|
||||||
|
:value="priceDialogValue"
|
||||||
|
placeholder="请输入车辆价格"
|
||||||
|
@confirm="dialogInputConfirm"
|
||||||
|
/>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request } from '@/api/apiT.js'
|
import { request } from '@/api/apiT.js'
|
||||||
|
import CarCard from '@/components/CarCard/CarCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
CarCard
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
priceDialogItem: null,
|
||||||
|
priceDialogIndex: -1,
|
||||||
|
priceDialogValue: '',
|
||||||
options1: [{
|
options1: [{
|
||||||
text: '编辑',
|
text: '编辑',
|
||||||
style: {
|
style: {
|
||||||
@@ -89,11 +79,182 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
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: {
|
methods: {
|
||||||
ym(dateStr) {
|
isFeishuEnv() {
|
||||||
return String(dateStr || '').slice(0, 7) // "2026-01"
|
// 飞书/ 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() {
|
onSearch() {
|
||||||
this.queryList(this.page,this.pageSize)
|
this.queryList(this.page,this.pageSize)
|
||||||
@@ -106,8 +267,8 @@
|
|||||||
status:1,
|
status:1,
|
||||||
size:10
|
size:10
|
||||||
};
|
};
|
||||||
params.scene = 'self';
|
|
||||||
params.keyword = this.keyword;
|
params.keyword = this.keyword;
|
||||||
|
params.scene = 'self';
|
||||||
request({
|
request({
|
||||||
url:'common/usedcar/list',
|
url:'common/usedcar/list',
|
||||||
method:'get',
|
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){
|
swipeClick(e,item){
|
||||||
let {
|
let {
|
||||||
content
|
content
|
||||||
@@ -196,95 +340,12 @@
|
|||||||
border-radius: 18rpx;
|
border-radius: 18rpx;
|
||||||
padding: 20rpx 10px;
|
padding: 20rpx 10px;
|
||||||
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
box-shadow: 0 10rpx 28rpx rgba(0, 0, 0, 0.06);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.list-wrap {
|
.list-wrap {
|
||||||
padding: 18rpx 24rpx 40rpx;
|
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 {
|
.loadmore {
|
||||||
padding: 18rpx 0 6rpx;
|
padding: 18rpx 0 6rpx;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
+436
-15
@@ -4,16 +4,26 @@
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>产品名称 <text class="red">*</text></view>
|
<view>产品名称 <text class="red">*</text></view>
|
||||||
<view class="right">
|
<view class="right right-bind">
|
||||||
<input placeholder="请输入产品名称" v-model="carinfo.product_name" />
|
<input class="inp" placeholder="请输入车辆的品牌 系列查找车型" v-model="carinfo.product_name" />
|
||||||
|
<view class="bind-btn" @tap.stop="onBindByName">绑定</view>
|
||||||
</view>
|
</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>车辆识别码</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入车架号/VIN码" v-model="carinfo.vin" />
|
<input placeholder="请输入车架号/VIN码" v-model="carinfo.vin" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>车价(¥)</view>
|
<view>车价(¥)</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
@@ -26,12 +36,12 @@
|
|||||||
<input placeholder="请输入车源地" v-model="carinfo.source_place" />
|
<input placeholder="请输入车源地" v-model="carinfo.source_place" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell">
|
<!-- <view class="cell">
|
||||||
<view>上牌地</view>
|
<view>上牌地</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入上牌地" v-model="carinfo.plate_place" />
|
<input placeholder="请输入上牌地" v-model="carinfo.plate_place" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view> -->
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>上牌时间</view>
|
<view>上牌时间</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
@@ -59,6 +69,12 @@
|
|||||||
<input placeholder="请输入排量" v-model="carinfo.displacement" />
|
<input placeholder="请输入排量" v-model="carinfo.displacement" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="cell">
|
||||||
|
<view>马力</view>
|
||||||
|
<view class="right">
|
||||||
|
<input placeholder="请输入马力" v-model="carinfo.power" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>里程</view>
|
<view>里程</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
@@ -87,10 +103,64 @@
|
|||||||
<textarea auto-height v-model="carinfo.condition_desc" placeholder="请输入车况介绍"/>
|
<textarea auto-height v-model="carinfo.condition_desc" placeholder="请输入车况介绍"/>
|
||||||
</view>
|
</view>
|
||||||
</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>
|
||||||
<view class="zw">
|
<view class="zw">
|
||||||
<button class="btn" @click="draftadd">提交</button>
|
<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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@@ -99,6 +169,14 @@
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
maxMedia:20,
|
maxMedia:20,
|
||||||
|
bindState:{
|
||||||
|
showDialog:false,
|
||||||
|
loading:false,
|
||||||
|
list:[],
|
||||||
|
selectedId:'',
|
||||||
|
boundProduct:null,
|
||||||
|
keyword:''
|
||||||
|
},
|
||||||
carinfo:{
|
carinfo:{
|
||||||
product_name:'',
|
product_name:'',
|
||||||
vin:'',
|
vin:'',
|
||||||
@@ -107,30 +185,170 @@
|
|||||||
plate_place:'',
|
plate_place:'',
|
||||||
plate_time:'',
|
plate_time:'',
|
||||||
displacement:'',
|
displacement:'',
|
||||||
|
power:'',
|
||||||
body_color:'',
|
body_color:'',
|
||||||
images:[],
|
images:[],
|
||||||
condition_desc:'',
|
condition_desc:'',
|
||||||
mileage:''
|
mileage:'',
|
||||||
|
attachment:[],
|
||||||
|
crawl_title:'',
|
||||||
|
crawl_brand:'',
|
||||||
|
crawl_series:'',
|
||||||
|
crawl_year:'',
|
||||||
|
crawl_msrp:'',
|
||||||
|
crawl_car_id:''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
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: {
|
methods: {
|
||||||
onBorrowTimeChange(e) {
|
onBorrowTimeChange(e) {
|
||||||
this.carinfo.plate_time = 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) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: 'https://usedcar.dev.hnxinyouhe.com/upload/image?scene=usedcarimg',
|
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
|
||||||
filePath: imgUrl,
|
filePath: imgUrl,
|
||||||
name: 'image',
|
name: 'file',
|
||||||
header:{'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'},
|
||||||
success: (uploadFileRes) => {
|
success: (uploadFileRes) => {
|
||||||
const res = JSON.parse(uploadFileRes.data || '{}')
|
const res = JSON.parse(uploadFileRes.data || '{}')
|
||||||
if(res && res.data && res.data.href){
|
uni.hideLoading();
|
||||||
resolve(res.data.href)
|
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{
|
}else{
|
||||||
reject('上传失败')
|
reject('上传失败')
|
||||||
}
|
}
|
||||||
@@ -146,7 +364,7 @@
|
|||||||
if(paths.length === 0){
|
if(paths.length === 0){
|
||||||
return
|
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 => {
|
urls.forEach(url => {
|
||||||
this.carinfo.images.push(url)
|
this.carinfo.images.push(url)
|
||||||
})
|
})
|
||||||
@@ -160,6 +378,30 @@
|
|||||||
delfn(e){
|
delfn(e){
|
||||||
this.carinfo.images.splice(e.index, 1)
|
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(){
|
draftadd(){
|
||||||
const payload = {
|
const payload = {
|
||||||
...this.carinfo,
|
...this.carinfo,
|
||||||
@@ -198,7 +440,7 @@
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
.content{
|
.content{
|
||||||
margin: 20px 12px;
|
// margin: 20px 12px;
|
||||||
background: #FFFFFF;
|
background: #FFFFFF;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
}
|
}
|
||||||
@@ -223,7 +465,7 @@
|
|||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content:space-between;
|
justify-content:space-between;
|
||||||
padding: 18px 20px;
|
padding: 14px 10px;
|
||||||
/* border-bottom: 1px solid #C3C3C3; */
|
/* border-bottom: 1px solid #C3C3C3; */
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
@@ -318,4 +560,183 @@
|
|||||||
width: 215rpx;
|
width: 215rpx;
|
||||||
height: 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>
|
</style>
|
||||||
|
|||||||
+567
-143
@@ -2,36 +2,54 @@
|
|||||||
<view>
|
<view>
|
||||||
<!-- <uni-nav-bar leftText=" " @clickLeft="leftClick" leftIcon="back" :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="车辆编辑"></uni-nav-bar> -->
|
<!-- <uni-nav-bar leftText=" " @clickLeft="leftClick" leftIcon="back" :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="车辆编辑"></uni-nav-bar> -->
|
||||||
<view class="content">
|
<view class="content">
|
||||||
|
<!-- 产品名称 + 绑定 -->
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>产品名称 <text class="red">*</text></view>
|
<view>产品名称 <text class="red">*</text></view>
|
||||||
<view class="right">
|
<view class="right right-bind">
|
||||||
<input placeholder="请输入产品名称" v-model="carinfo.product_name" />
|
<input class="inp" placeholder="请输入产品名称" v-model="carinfo.product_name" />
|
||||||
|
<view class="bind-btn" @tap.stop="onBindByName">绑定</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 已绑定提示 -->
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<!-- (保持原字段:VIN/上牌地 如你不需要可继续注释) -->
|
||||||
|
<!--
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>车辆识别码</view>
|
<view>车辆识别码</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入车架号/VIN码" v-model="carinfo.vin" />
|
<input placeholder="请输入车架号/VIN码" v-model="carinfo.vin" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
-->
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>车价(¥)</view>
|
<view>车价(¥)</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入车价" v-model="carinfo.price" />
|
<input placeholder="请输入车价" v-model="carinfo.price" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>车源地</view>
|
<view>车源地</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入车源地" v-model="carinfo.source_place" />
|
<input placeholder="请输入车源地" v-model="carinfo.source_place" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!--
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>上牌地</view>
|
<view>上牌地</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入上牌地" v-model="carinfo.plate_place" />
|
<input placeholder="请输入上牌地" v-model="carinfo.plate_place" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
-->
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>上牌时间</view>
|
<view>上牌时间</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
@@ -53,24 +71,35 @@
|
|||||||
</uni-datetime-picker>
|
</uni-datetime-picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>排量</view>
|
<view>排量</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入排量" v-model="carinfo.displacement" />
|
<input placeholder="请输入排量" v-model="carinfo.displacement" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="cell">
|
||||||
|
<view>马力</view>
|
||||||
|
<view class="right">
|
||||||
|
<input placeholder="请输入马力" v-model="carinfo.power" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>里程</view>
|
<view>里程</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入里程" v-model="carinfo.mileage" />
|
<input placeholder="请输入里程" v-model="carinfo.mileage" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>车身颜色</view>
|
<view>车身颜色</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入车身颜色" v-model="carinfo.body_color" />
|
<input placeholder="请输入车身颜色" v-model="carinfo.body_color" />
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="cont">
|
<view class="cont">
|
||||||
<view class="conts">产品图</view>
|
<view class="conts">产品图</view>
|
||||||
<view class="media-upload-wrapper">
|
<view class="media-upload-wrapper">
|
||||||
@@ -90,28 +119,115 @@
|
|||||||
</uni-file-picker>
|
</uni-file-picker>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="cont">
|
<view class="cont">
|
||||||
<view class="conts">车况介绍</view>
|
<view class="conts">车况介绍</view>
|
||||||
<view class="">
|
<view>
|
||||||
<textarea auto-height v-model="carinfo.condition_desc" placeholder="请输入车况介绍"/>
|
<textarea auto-height v-model="carinfo.condition_desc" placeholder="请输入车况介绍"/>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 附件(与 publish 添加页一致:attachment 为数组对象 {name,src},后端存 JSON 字符串) -->
|
||||||
|
<view class="cont">
|
||||||
|
<view class="conts">附件</view>
|
||||||
|
<view class="media-upload-wrapper">
|
||||||
|
<uni-file-picker
|
||||||
|
ref="filePicker"
|
||||||
|
v-model="fileListAttach"
|
||||||
|
:limit="maxMedia"
|
||||||
|
file-mediatype="all"
|
||||||
|
mode="grid"
|
||||||
|
:auto-upload="false"
|
||||||
|
@select="selectMedia1"
|
||||||
|
@delete="delfn1"
|
||||||
|
>
|
||||||
|
<view class="upload-icon-wrapper">
|
||||||
|
<image src="/static/image/photo.png" mode="" class="addimg"></image>
|
||||||
</view>
|
</view>
|
||||||
|
</uni-file-picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="zw">
|
<view class="zw">
|
||||||
<button class="btn" @click="draftadd">提交</button>
|
<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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { request, showToast } from '@/api/apiT.js'
|
import { request, showToast } from '@/api/apiT.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
maxMedia: 20,
|
maxMedia: 20,
|
||||||
// uni-file-picker 回显/展示用(url/name/extname)
|
|
||||||
|
// 图片回显列表(uni-file-picker v-model)
|
||||||
fileList: [],
|
fileList: [],
|
||||||
|
// 附件回显列表(uni-file-picker v-model)
|
||||||
|
fileListAttach: [],
|
||||||
|
|
||||||
id: '',
|
id: '',
|
||||||
_uploading: false,
|
_uploading: false,
|
||||||
|
_uploadingFiles: false,
|
||||||
|
|
||||||
|
// 绑定弹框状态
|
||||||
|
bindState: {
|
||||||
|
showDialog: false,
|
||||||
|
loading: false,
|
||||||
|
list: [],
|
||||||
|
selectedId: '',
|
||||||
|
selectedItem: null,
|
||||||
|
boundProduct: null,
|
||||||
|
keyword: ''
|
||||||
|
},
|
||||||
|
|
||||||
carinfo: {
|
carinfo: {
|
||||||
id: '',
|
id: '',
|
||||||
product_name: '',
|
product_name: '',
|
||||||
@@ -121,73 +237,179 @@
|
|||||||
plate_place: '',
|
plate_place: '',
|
||||||
plate_time: '',
|
plate_time: '',
|
||||||
displacement: '',
|
displacement: '',
|
||||||
|
power: '',
|
||||||
body_color: '',
|
body_color: '',
|
||||||
// 提交给后端用:相对路径数组(最终 join(','))
|
// 提交给后端:相对路径数组(最终 join(','))
|
||||||
images: [],
|
images: [],
|
||||||
condition_desc: '',
|
condition_desc: '',
|
||||||
mileage:''
|
mileage: '',
|
||||||
|
// 附件:对象数组(最终 JSON.stringify)
|
||||||
|
attachment: [],
|
||||||
|
// 抓取绑定字段(与 publish 添加页一致)
|
||||||
|
crawl_title: '',
|
||||||
|
crawl_brand: '',
|
||||||
|
crawl_series: '',
|
||||||
|
crawl_year: '',
|
||||||
|
crawl_msrp: '',
|
||||||
|
crawl_car_id: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.id = options?.id || ''
|
this.id = options?.id || ''
|
||||||
this.getshows()
|
this.getshows()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
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: {
|
methods: {
|
||||||
leftClick() {
|
leftClick() {
|
||||||
uni.navigateBack()
|
uni.navigateBack()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onBorrowTimeChange(e) {
|
||||||
|
this.carinfo.plate_time = e
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== 数据回显 ==========
|
||||||
getshows() {
|
getshows() {
|
||||||
let that = this;
|
|
||||||
request({
|
request({
|
||||||
url: 'common/usedcar/show',
|
url: 'common/usedcar/show',
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
data:{
|
data: { id: this.id }
|
||||||
id:that.id
|
|
||||||
}
|
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.code == 200) {
|
if (res.data.code !== 200) return
|
||||||
const d = res.data.data || {}
|
const d = res.data.data || {}
|
||||||
// 1) images:后端返回的是逗号字符串,这里转成数组(用于编辑提交)
|
|
||||||
const keys = String(d.images || '')
|
// images: string => array
|
||||||
|
const imageKeys = String(d.images || '')
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(s => String(s || '').trim())
|
.map(s => String(s || '').trim())
|
||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
|
|
||||||
// 2) 表单字段
|
|
||||||
|
// attachment:后端是 JSON 字符串:[{name,src}],并且会给 attachment_pull 用于回显
|
||||||
|
let attachArr = []
|
||||||
|
try {
|
||||||
|
if (Array.isArray(d.attachment_pull) && d.attachment_pull.length) {
|
||||||
|
// 注意:attachment_pull 的 src 多数是带签名的绝对 URL,只用于展示
|
||||||
|
attachArr = d.attachment_pull.map(a => ({
|
||||||
|
name: a.name || a.original_name || '未命名',
|
||||||
|
src: a.src || a.file_path || a.file_name || ''
|
||||||
|
}))
|
||||||
|
} else if (d.attachment) {
|
||||||
|
const parsed = typeof d.attachment === 'string' ? JSON.parse(d.attachment) : d.attachment
|
||||||
|
attachArr = Array.isArray(parsed) ? parsed : []
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
attachArr = []
|
||||||
|
}
|
||||||
|
|
||||||
|
// 绑定信息:详情接口会返回 crawl_* 字段(示例数据里就是 crawl_*)
|
||||||
|
const bound = (d.crawl_car_id || d.crawl_title || d.crawl_brand || d.crawl_series)
|
||||||
|
? {
|
||||||
|
car_id: d.crawl_car_id,
|
||||||
|
title: d.crawl_title,
|
||||||
|
brand_name: d.crawl_brand,
|
||||||
|
series_name: d.crawl_series,
|
||||||
|
year: d.crawl_year,
|
||||||
|
msrp: d.crawl_msrp
|
||||||
|
}
|
||||||
|
: null
|
||||||
|
|
||||||
this.carinfo = {
|
this.carinfo = {
|
||||||
...this.carinfo,
|
...this.carinfo,
|
||||||
...d,
|
...d,
|
||||||
images: keys
|
images: imageKeys,
|
||||||
|
attachment: attachArr.map(a => ({
|
||||||
|
name: a.name || a.original_name || '未命名',
|
||||||
|
src: a.src || a.file_path || a.file_name || ''
|
||||||
|
})),
|
||||||
|
power: d.power ?? this.carinfo.power,
|
||||||
|
// crawl_* 会被 ...d 自动覆盖,这里只兜底
|
||||||
|
crawl_car_id: d.crawl_car_id ?? this.carinfo.crawl_car_id
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3) 图片回显:优先用 images_pull(签名URL用于显示)
|
// 图片回显:优先 images_pull(签名URL)否则用 keys
|
||||||
const pulls = Array.isArray(d.images_pull) && d.images_pull.length
|
const pulls = Array.isArray(d.images_pull) && d.images_pull.length ? d.images_pull : imageKeys
|
||||||
? d.images_pull
|
|
||||||
: keys
|
|
||||||
this.fileList = pulls.map((u, idx) => {
|
this.fileList = pulls.map((u, idx) => {
|
||||||
const raw = String(u || '')
|
const raw = String(u || '')
|
||||||
const filename = raw.split('?')[0].split('/').pop() || `img_${idx + 1}`
|
const filename = raw.split('?')[0].split('/').pop() || `img_${idx + 1}`
|
||||||
const ext = filename.includes('.') ? filename.split('.').pop() : ''
|
const ext = filename.includes('.') ? filename.split('.').pop() : ''
|
||||||
return { url: raw, name: filename, extname: ext }
|
return { url: raw, name: filename, extname: ext }
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
// 附件回显:优先用 attachment_pull(带签名 URL),否则用 attachment 里的 src
|
||||||
|
const pullsFiles = (Array.isArray(d.attachment_pull) && d.attachment_pull.length)
|
||||||
|
? d.attachment_pull
|
||||||
|
: (this.carinfo.attachment || [])
|
||||||
|
|
||||||
|
this.fileListAttach = (pullsFiles || []).map((u, idx) => {
|
||||||
|
const raw = typeof u === 'string'
|
||||||
|
? String(u)
|
||||||
|
: String(u?.src || '')
|
||||||
|
const filename = (typeof u === 'object' && u)
|
||||||
|
? String(u.name || u.original_name || '').trim() || (raw.split('?')[0].split('/').pop() || `file_${idx + 1}`)
|
||||||
|
: (raw.split('?')[0].split('/').pop() || `file_${idx + 1}`)
|
||||||
|
const ext = filename.includes('.') ? filename.split('.').pop() : ''
|
||||||
|
return { url: raw, name: filename, extname: ext }
|
||||||
|
})
|
||||||
|
|
||||||
|
// 已绑定提示:用 crawl_* 拼一个 boundProduct
|
||||||
|
this.bindState.boundProduct = bound
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onBorrowTimeChange(e) {
|
|
||||||
this.carinfo.plate_time = e
|
// ========== 上传(与 publish 添加页一致) ==========
|
||||||
},
|
// 返回后端 data 对象:{ file_name, original_name, ... }
|
||||||
uploadfn(imgUrl){
|
uploadFileByScene(filePath, scene) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
uni.uploadFile({
|
uni.uploadFile({
|
||||||
url: 'https://usedcar.dev.hnxinyouhe.com/upload/image?scene=usedcarimg',
|
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
|
||||||
|
filePath,
|
||||||
|
name: 'file',
|
||||||
|
header: {
|
||||||
|
'Fdesk-Auth-Token': uni.getStorageSync('token'),
|
||||||
|
'Fdesk-Login-Type': 'feishu',
|
||||||
|
'Fdesk-System-Code': 'fdesk'
|
||||||
|
},
|
||||||
|
success: (uploadFileRes) => {
|
||||||
|
const r = JSON.parse(uploadFileRes.data || '{}')
|
||||||
|
if (r && r.data && r.data.file_name) {
|
||||||
|
resolve(r.data)
|
||||||
|
} else {
|
||||||
|
reject('上传失败')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: (err) => reject(err)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
uploadfn(imgUrl,scene){
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uni.uploadFile({
|
||||||
|
url: 'https://userdcar-server.hnxinyouhe.com/upload?scene='+scene,
|
||||||
filePath: imgUrl,
|
filePath: imgUrl,
|
||||||
name: 'image',
|
name: 'file',
|
||||||
header:{'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'},
|
||||||
success: (uploadFileRes) => {
|
success: (uploadFileRes) => {
|
||||||
const res = JSON.parse(uploadFileRes.data || '{}')
|
const res = JSON.parse(uploadFileRes.data || '{}')
|
||||||
if(res && res.data && res.data.href){
|
if(res && res.data && res.data.file_name){
|
||||||
resolve(res.data.href)
|
resolve(res.data.file_name)
|
||||||
}else{
|
}else{
|
||||||
reject('上传失败')
|
reject('上传失败')
|
||||||
}
|
}
|
||||||
@@ -196,13 +418,19 @@
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
uploadImage(path) {
|
||||||
|
return this.uploadfn(path, 'usedcarimg')
|
||||||
|
},
|
||||||
|
|
||||||
|
uploadAttachment(path) {
|
||||||
|
return this.uploadFileByScene(path, 'usedcarfile')
|
||||||
|
},
|
||||||
|
|
||||||
|
// 图片选择
|
||||||
selectMedia(e) {
|
selectMedia(e) {
|
||||||
const allowCount = this.maxMedia - (this.carinfo.images?.length || 0)
|
const allowCount = this.maxMedia - (this.carinfo.images?.length || 0)
|
||||||
if (allowCount <= 0) {
|
if (allowCount <= 0) {
|
||||||
uni.showToast({
|
uni.showToast({ title: `最多只能上传${this.maxMedia}张图片`, icon: 'none' })
|
||||||
title:`最多只能上传${this.maxMedia}张图片`,
|
|
||||||
icon:'none'
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,47 +444,160 @@
|
|||||||
if (this._uploading) return
|
if (this._uploading) return
|
||||||
this._uploading = true
|
this._uploading = true
|
||||||
|
|
||||||
// 先占位,保证 delete 的 index 与 images 数组对得上
|
// 占位,保持索引一致
|
||||||
const startAt = this.carinfo.images.length
|
const startAt = this.carinfo.images.length
|
||||||
for(let i=0;i<paths.length;i++){
|
for (let i = 0; i < paths.length; i++) this.carinfo.images.push('__PENDING__')
|
||||||
this.carinfo.images.push('__PENDING__')
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.all(paths.map(p => this.uploadfn(p)))
|
Promise.all(paths.map(p => this.uploadImage(p)))
|
||||||
.then(keys => {
|
.then(keys => {
|
||||||
keys.forEach((key, i) => {
|
keys.forEach((key, i) => this.$set(this.carinfo.images, startAt + i, String(key)))
|
||||||
// 替换占位
|
|
||||||
this.$set(this.carinfo.images, startAt + i, String(key))
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
// 失败:移除占位,同时把 fileList 对应项删掉(避免页面“假回显”)
|
|
||||||
this.carinfo.images.splice(startAt, paths.length)
|
this.carinfo.images.splice(startAt, paths.length)
|
||||||
if (Array.isArray(this.fileList) && this.fileList.length >= startAt + paths.length) {
|
if (Array.isArray(this.fileList) && this.fileList.length >= startAt + paths.length) {
|
||||||
this.fileList.splice(startAt, paths.length)
|
this.fileList.splice(startAt, paths.length)
|
||||||
}
|
}
|
||||||
uni.showToast({
|
uni.showToast({ title: '图片上传失败,请重试', icon: 'none' })
|
||||||
title:'图片上传失败,请重试',
|
|
||||||
icon:'none'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.finally(() => {
|
|
||||||
this._uploading = false
|
|
||||||
})
|
})
|
||||||
|
.finally(() => { this._uploading = false })
|
||||||
},
|
},
|
||||||
|
|
||||||
delfn(e) {
|
delfn(e) {
|
||||||
// fileList 会由 uni-file-picker 自己维护;这里同步删除提交用的 images
|
|
||||||
this.carinfo.images.splice(e.index, 1)
|
this.carinfo.images.splice(e.index, 1)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 附件选择(与 publish 添加页一致:attachment push {name,src})
|
||||||
|
selectMedia1(e) {
|
||||||
|
const allowCount = this.maxMedia - (this.carinfo.attachment?.length || 0)
|
||||||
|
if (allowCount <= 0) {
|
||||||
|
uni.showToast({ title: `最多只能上传${this.maxMedia}个附件`, icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const tempFiles = e.tempFiles || []
|
||||||
|
const tempFilePaths = (tempFiles.length
|
||||||
|
? tempFiles.map(f => f.path || f.url).filter(Boolean)
|
||||||
|
: (e.tempFilePaths || [])
|
||||||
|
)
|
||||||
|
const paths = tempFilePaths.slice(0, allowCount)
|
||||||
|
if (paths.length === 0) return
|
||||||
|
if (this._uploadingFiles) return
|
||||||
|
this._uploadingFiles = true
|
||||||
|
|
||||||
|
Promise.all(paths.map(p => this.uploadAttachment(p)))
|
||||||
|
.then(list => {
|
||||||
|
list.forEach(info => {
|
||||||
|
// uploadAttachment 返回 {original_name,file_name}
|
||||||
|
this.carinfo.attachment.push({
|
||||||
|
name: info.original_name || '未命名',
|
||||||
|
src: info.file_name || ''
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
uni.showToast({ title: '附件上传失败,请重试', icon: 'none' })
|
||||||
|
})
|
||||||
|
.finally(() => { this._uploadingFiles = false })
|
||||||
|
},
|
||||||
|
|
||||||
|
delfn1(e) {
|
||||||
|
this.carinfo.attachment.splice(e.index, 1)
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== 绑定产品 ==========
|
||||||
|
onBindByName() {
|
||||||
|
const name = String(this.carinfo.product_name || '').trim()
|
||||||
|
if (!name) {
|
||||||
|
uni.showToast({ title: '请先输入产品名称', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.bindState.loading = true
|
||||||
|
this.bindState.showDialog = true
|
||||||
|
this.bindState.list = []
|
||||||
|
this.bindState.selectedId = ''
|
||||||
|
this.bindState.selectedItem = null
|
||||||
|
this.bindState.keyword = ''
|
||||||
|
|
||||||
|
// 与 publish 添加页一致:按名称调用抓取接口,返回可能多个车型
|
||||||
|
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.code || idx)
|
||||||
|
},
|
||||||
|
|
||||||
|
formatBindSub(it) {
|
||||||
|
// 你可以按接口字段改:编码/规格/分类/库存等
|
||||||
|
const parts = []
|
||||||
|
if (it.code) parts.push(`编码:${it.code}`)
|
||||||
|
if (it.sku) parts.push(`SKU:${it.sku}`)
|
||||||
|
if (it.category_name) parts.push(`分类:${it.category_name}`)
|
||||||
|
if (it.stock != null) parts.push(`库存:${it.stock}`)
|
||||||
|
return parts.join(' ')
|
||||||
|
},
|
||||||
|
|
||||||
|
selectBind(it, idx) {
|
||||||
|
const id = this.getBindItemId(it, idx)
|
||||||
|
this.bindState.selectedId = id
|
||||||
|
this.bindState.selectedItem = it
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmBind() {
|
||||||
|
if (!this.bindState.selectedId || !this.bindState.selectedItem) return
|
||||||
|
const it = this.bindState.selectedItem
|
||||||
|
// 与 publish 添加页一致:写入 crawl_* 字段
|
||||||
|
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 || ''
|
||||||
|
|
||||||
|
this.bindState.boundProduct = it
|
||||||
|
this.closeBindDialog()
|
||||||
|
uni.showToast({ title: '绑定成功', icon: 'none' })
|
||||||
|
},
|
||||||
|
|
||||||
|
clearBind() {
|
||||||
|
this.bindState.boundProduct = null
|
||||||
|
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 = ''
|
||||||
|
},
|
||||||
|
|
||||||
|
// ========== 提交 ==========
|
||||||
draftadd() {
|
draftadd() {
|
||||||
const payload = {
|
const payload = {
|
||||||
...this.carinfo,
|
...this.carinfo,
|
||||||
// images 数组 => "url1,url2,url3"
|
|
||||||
images: (this.carinfo.images || [])
|
images: (this.carinfo.images || [])
|
||||||
.map(s => String(s || '').trim())
|
.map(s => String(s || '').trim())
|
||||||
.filter(s => !!s && s !== '__PENDING__')
|
.filter(s => !!s && s !== '__PENDING__')
|
||||||
.join(',')
|
.join(',')
|
||||||
}
|
}
|
||||||
|
|
||||||
request({
|
request({
|
||||||
url: 'common/usedcar/update',
|
url: 'common/usedcar/update',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@@ -269,21 +610,24 @@
|
|||||||
plate_place: payload.plate_place,
|
plate_place: payload.plate_place,
|
||||||
plate_time: payload.plate_time,
|
plate_time: payload.plate_time,
|
||||||
displacement: payload.displacement,
|
displacement: payload.displacement,
|
||||||
|
power: payload.power,
|
||||||
body_color: payload.body_color,
|
body_color: payload.body_color,
|
||||||
images: payload.images,
|
images: payload.images,
|
||||||
condition_desc: payload.condition_desc,
|
condition_desc: payload.condition_desc,
|
||||||
mileage:payload.mileage
|
mileage: payload.mileage,
|
||||||
|
attachment: payload.attachment,
|
||||||
|
crawl_title: payload.crawl_title,
|
||||||
|
crawl_brand: payload.crawl_brand,
|
||||||
|
crawl_series: payload.crawl_series,
|
||||||
|
crawl_year: payload.crawl_year,
|
||||||
|
crawl_msrp: payload.crawl_msrp,
|
||||||
|
crawl_car_id: payload.crawl_car_id
|
||||||
}
|
}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
uni.showToast({
|
uni.showToast({ title: res.data.message, icon: 'none' })
|
||||||
title: res.data.message,
|
|
||||||
icon: 'none'
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({
|
uni.reLaunch({ url: '/pages/index/mine' })
|
||||||
url: '/pages/index/mine',// 替换为你要跳转的页面路径
|
}, 1000)
|
||||||
});
|
|
||||||
}, 1000);
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,41 +635,19 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
.uniui-right{
|
.uniui-right{ position:absolute; top:2px; }
|
||||||
position: absolute;
|
.red{ color:red; }
|
||||||
top: 2px;
|
.content{ margin:20px 12px; background:#FFFFFF; border-radius:10px; }
|
||||||
}
|
.zw{ height:120px; }
|
||||||
.red{
|
.cont{ position:relative; padding:18px 20px; align-items:center; font-weight:500; }
|
||||||
color: red;
|
.conts{ margin-bottom:20rpx; }
|
||||||
}
|
.media-upload-wrapper{ display:flex; flex-wrap:wrap; gap:16rpx; }
|
||||||
.content{
|
|
||||||
margin: 20px 12px;
|
|
||||||
background: #FFFFFF;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
.zw{
|
|
||||||
height: 120px;
|
|
||||||
}
|
|
||||||
.cont{
|
|
||||||
position: relative;
|
|
||||||
padding: 18px 20px;
|
|
||||||
align-items: center;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.conts{
|
|
||||||
margin-bottom: 20rpx;
|
|
||||||
}
|
|
||||||
.media-upload-wrapper{
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
gap: 16rpx;
|
|
||||||
}
|
|
||||||
.cell{
|
.cell{
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 18px 20px;
|
padding: 18px 20px;
|
||||||
/* border-bottom: 1px solid #C3C3C3; */
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
@@ -346,77 +668,179 @@
|
|||||||
pointer-events:none;
|
pointer-events:none;
|
||||||
border-color:#C3C3C3;
|
border-color:#C3C3C3;
|
||||||
}
|
}
|
||||||
.cell1{
|
.right{ text-align:right; }
|
||||||
display: flex;
|
|
||||||
justify-content:space-between;
|
|
||||||
padding: 18px 20px;
|
|
||||||
align-items: center;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
.right{
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
.select{
|
|
||||||
display: flex;
|
|
||||||
position: relative;
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
.foot{
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0px;
|
|
||||||
width: 100%;
|
|
||||||
height: 120px;
|
|
||||||
background: #FFFFFF;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
.btn{
|
.btn{
|
||||||
background-color:#3F435B;
|
background-color:#3F435B;
|
||||||
color:white;
|
color:white;
|
||||||
border-radius:50px;
|
border-radius:50px;
|
||||||
width:92%;
|
width:92%;
|
||||||
margin-bottom: 40px;
|
|
||||||
margin:15px 4%;
|
margin:15px 4%;
|
||||||
}
|
}
|
||||||
|
.addimg{ width:215rpx; height:215rpx; }
|
||||||
|
|
||||||
.actives{
|
/* 产品名称 + 绑定按钮 */
|
||||||
background-color: #dfdfdf;
|
.right-bind{
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
display: flex;
|
||||||
|
width: 70%;
|
||||||
}
|
}
|
||||||
.text{
|
.right-bind .inp{ flex:1; }
|
||||||
|
.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;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
line-height: 30px;
|
|
||||||
padding: 10px 15px 0px;
|
|
||||||
.qd{
|
|
||||||
color: #3471FF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.popup-content {
|
|
||||||
padding: 20px;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
}
|
||||||
|
.bind-tip-text{ color:#2B3A55; font-size:24rpx; }
|
||||||
|
.bind-tip-clear{ color:#2E6CF6; font-size:24rpx; }
|
||||||
|
|
||||||
.option-list {
|
/* 弹框搜索 */
|
||||||
max-height: 400rpx;
|
.bind-search{
|
||||||
margin-top: 20rpx;
|
margin: 5px 24rpx 16rpx;
|
||||||
|
padding: 12rpx 18rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: #F3F6FF;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
.bind-search-input{
|
||||||
.option-item {
|
flex: 1;
|
||||||
padding: 20rpx;
|
font-size: 26rpx;
|
||||||
border-bottom: 1rpx solid #eee;
|
color: #333;
|
||||||
}
|
}
|
||||||
|
.bind-search-placeholder{
|
||||||
.option-item:last-child {
|
color: #9AA6BF;
|
||||||
border-bottom: none;
|
|
||||||
}
|
}
|
||||||
|
.bind-search-clear{
|
||||||
.no-data {
|
margin-left: 16rpx;
|
||||||
text-align: center;
|
font-size: 24rpx;
|
||||||
padding: 20rpx;
|
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;
|
color: #999;
|
||||||
|
line-height: 1;
|
||||||
}
|
}
|
||||||
.addimg{
|
.bind-dialog-body{
|
||||||
width: 215rpx;
|
max-height: 720rpx;
|
||||||
height: 215rpx;
|
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>
|
</style>
|
||||||
|
|||||||
@@ -44,6 +44,15 @@
|
|||||||
this.startDots()
|
this.startDots()
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
this._code = options.code || ''
|
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
|
// #endif
|
||||||
|
|
||||||
if (!this._code) {
|
if (!this._code) {
|
||||||
@@ -94,19 +103,24 @@
|
|||||||
uni.setStorageSync('token', token)
|
uni.setStorageSync('token', token)
|
||||||
|
|
||||||
this.title = '登录成功'
|
this.title = '登录成功'
|
||||||
this.desc = '正在进入首页'
|
this.desc = '正在进入页面'
|
||||||
|
|
||||||
this.goHomeSmooth()
|
this.goRedirectSmooth()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('[feishu callback] error:', err)
|
console.error('[feishu callback] error:', err)
|
||||||
this.fail(err?.message || '登录失败')
|
this.fail(err?.message || '登录失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
goHomeSmooth() {
|
getRedirectTarget() {
|
||||||
|
return uni.getStorageSync('post_login_redirect') || '/pages/index/index'
|
||||||
|
},
|
||||||
|
goRedirectSmooth() {
|
||||||
const elapsed = Date.now() - this._startedAt
|
const elapsed = Date.now() - this._startedAt
|
||||||
const wait = Math.max(0, this.minStayMs - elapsed)
|
const wait = Math.max(0, this.minStayMs - elapsed)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({ url: '/pages/index/index' })
|
const target = this.getRedirectTarget()
|
||||||
|
uni.removeStorageSync('post_login_redirect')
|
||||||
|
uni.reLaunch({ url: target })
|
||||||
}, wait)
|
}, wait)
|
||||||
},
|
},
|
||||||
retry() {
|
retry() {
|
||||||
|
|||||||
+20
-6
@@ -37,6 +37,16 @@
|
|||||||
onLoad(options) {
|
onLoad(options) {
|
||||||
this.fsappid = options.appid || '';
|
this.fsappid = options.appid || '';
|
||||||
uni.setStorageSync('fsappid', this.fsappid);
|
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._startedAt = Date.now()
|
||||||
this.startDots()
|
this.startDots()
|
||||||
this.silentAuth()
|
this.silentAuth()
|
||||||
@@ -65,8 +75,8 @@
|
|||||||
const token = uni.getStorageSync('token')
|
const token = uni.getStorageSync('token')
|
||||||
if (token) {
|
if (token) {
|
||||||
this.title = '已登录'
|
this.title = '已登录'
|
||||||
this.desc = '正在进入首页'
|
this.desc = '正在进入页面'
|
||||||
return this.goHomeSmooth()
|
return this.goRedirectSmooth()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2) 获取飞书授权跳转地址(静默授权/免登)
|
// 2) 获取飞书授权跳转地址(静默授权/免登)
|
||||||
@@ -98,13 +108,17 @@
|
|||||||
uni.showToast({ title: err?.message || '登录失败', icon: 'none' })
|
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 elapsed = Date.now() - this._startedAt
|
||||||
const wait = Math.max(0, this.minStayMs - elapsed)
|
const wait = Math.max(0, this.minStayMs - elapsed)
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.reLaunch({
|
const target = this.getRedirectTarget()
|
||||||
url: '/pages/index/index'
|
// 用完即清,避免后续误跳
|
||||||
})
|
uni.removeStorageSync('post_login_redirect')
|
||||||
|
uni.reLaunch({ url: target })
|
||||||
}, wait)
|
}, wait)
|
||||||
},
|
},
|
||||||
sleep(ms) {
|
sleep(ms) {
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 640 B |
Reference in New Issue
Block a user