调整 添加贸易条款
This commit is contained in:
@@ -1,7 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
|
|
||||||
<view class="car-cards" @click="handleCardTap">
|
<view class="car-cards" >
|
||||||
<view class="car-card">
|
<view class="heard">
|
||||||
|
<view class="" @click="handleCardTap">
|
||||||
|
编号:{{item.code?item.code:'~'}}
|
||||||
|
</view>
|
||||||
|
<view v-if="ismy">
|
||||||
|
<u-icon @click="detilsfn(item)" name="edit-pen-fill" size="25" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="car-card" @click="handleCardTap">
|
||||||
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
|
<image class="thumb" :src="item.images_pull[0]" mode="aspectFill" />
|
||||||
<view class="info">
|
<view class="info">
|
||||||
<view class="row row1">
|
<view class="row row1">
|
||||||
@@ -26,14 +34,14 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="kv">
|
<view class="kv">
|
||||||
<text class="k">里程</text>
|
<text class="k">里程</text>
|
||||||
<text class="v">{{ item.mileage }}</text>
|
<text class="v">{{ item.mileage }} <text v-if="item.mileage">Km</text> </text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 操作区:保存 + 分享(方案A:卡片右下角悬浮) -->
|
<!-- 操作区:保存 + 分享(方案A:卡片右下角悬浮) -->
|
||||||
<view class="card-actions">
|
<view class="card-actions">
|
||||||
<view class="actions-lift">
|
<view class="actions-lift" @click="handleCardTap">
|
||||||
<text class="">创建时间:</text>
|
<text class="">创建时间:</text>
|
||||||
<text class="">{{ item.created_at }}</text>
|
<text class="">{{ item.created_at }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -59,12 +67,22 @@
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
|
ismy:{
|
||||||
|
default: false,
|
||||||
|
type: Boolean
|
||||||
|
},
|
||||||
index: {
|
index: {
|
||||||
type: Number,
|
type: Number,
|
||||||
default: -1
|
default: -1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
detilsfn(item){
|
||||||
|
const id = item.id
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/index/publishedit?id=${id}`
|
||||||
|
})
|
||||||
|
},
|
||||||
formatPlateTime(dateStr) {
|
formatPlateTime(dateStr) {
|
||||||
return String(dateStr || '').slice(0, 7) // "2026-01"
|
return String(dateStr || '').slice(0, 7) // "2026-01"
|
||||||
},
|
},
|
||||||
@@ -110,12 +128,12 @@
|
|||||||
},
|
},
|
||||||
handleToggleSave() {
|
handleToggleSave() {
|
||||||
const item = this.item
|
const item = this.item
|
||||||
if (item.pdf_src && item.pdf_src != '') {
|
// if (item.pdf_src && item.pdf_src != '') {
|
||||||
this.downloadpdf(item)
|
// this.downloadpdf(item)
|
||||||
} else {
|
// } else {
|
||||||
// 让父组件统一弹出输入框(避免列表里每个卡片都渲染一个 popup)
|
// 让父组件统一弹出输入框(避免列表里每个卡片都渲染一个 popup)
|
||||||
this.$emit('request-price', { item, index: this.index })
|
this.$emit('request-price', { item, index: this.index })
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
buildShareLink(id) {
|
buildShareLink(id) {
|
||||||
// 统一生成"详情页路径"
|
// 统一生成"详情页路径"
|
||||||
@@ -230,6 +248,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.heard{
|
||||||
|
padding: 5px 10px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
.car-cards {
|
.car-cards {
|
||||||
padding-bottom: 6rpx; // 预留右下角按钮空间,避免遮挡信息
|
padding-bottom: 6rpx; // 预留右下角按钮空间,避免遮挡信息
|
||||||
border-radius: 18rpx;
|
border-radius: 18rpx;
|
||||||
|
|||||||
@@ -4,14 +4,14 @@
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="topimg">
|
<view class="topimg">
|
||||||
<uni-file-picker fileMediatype="image" limit="1" :list-styles="imageStyles" :del-icon="false" disable-preview @select="select" @delete="delfn('picture')">
|
<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>
|
<image class="user" :src="userinfo.avatar"mode=""></image>
|
||||||
</uni-file-picker>
|
</uni-file-picker>
|
||||||
<view>点击更换头像</view>
|
<view>点击更换头像</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell1">
|
<view class="cell1">
|
||||||
<view class="item">手机号</view>
|
<view class="item">手机号</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入手机号" type="number" v-model="userinfo.mobile"></input>
|
<input placeholder="请输入手机号" type="number" v-model="userinfo.email"></input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<u-divider text=""></u-divider>
|
<u-divider text=""></u-divider>
|
||||||
@@ -65,16 +65,10 @@
|
|||||||
getinfo(){
|
getinfo(){
|
||||||
var that= this;
|
var that= this;
|
||||||
request({
|
request({
|
||||||
url:'user/getInfo',
|
url:'common/user/info',
|
||||||
method:'get',
|
method:'get',
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if(res.data.data.position=='null'){
|
|
||||||
res.data.data.position=''
|
|
||||||
}
|
|
||||||
that.userinfo = res.data.data;
|
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){
|
uploadfn(imgUrl,scene){
|
||||||
|
|||||||
+330
-3
@@ -5,6 +5,14 @@
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<!-- 基础信息卡片 -->
|
<!-- 基础信息卡片 -->
|
||||||
<view class="card">
|
<view class="card">
|
||||||
|
<view class="heard">
|
||||||
|
<view class="">
|
||||||
|
编号:{{detail.code?detail.code:'~'}}
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<u-icon @click="openPriceDialog()" name="download" size="25" />
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
<view class="title-row">
|
<view class="title-row">
|
||||||
<text class="name">{{ detail.product_name }}</text>
|
<text class="name">{{ detail.product_name }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -42,7 +50,7 @@
|
|||||||
|
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
<text class="k">里程</text>
|
<text class="k">里程</text>
|
||||||
<text class="v">{{ detail.mileage }}</text>
|
<text class="v">{{ detail.mileage }}<text v-if="detail.mileage">Km</text></text>
|
||||||
</view>
|
</view>
|
||||||
<view class="kv-item">
|
<view class="kv-item">
|
||||||
<text class="k">马力</text>
|
<text class="k">马力</text>
|
||||||
@@ -95,6 +103,62 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
|
<view class="price-dialog">
|
||||||
|
<view class="pd-title">设置价格</view>
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">贸易条款</view>
|
||||||
|
<view class="pd-price-line">
|
||||||
|
<uni-data-select
|
||||||
|
v-model="priceForm.trade_term"
|
||||||
|
class="tradeTerm"
|
||||||
|
:localdata="tradeTermOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">价格</view>
|
||||||
|
<view class="pd-price-line">
|
||||||
|
<view class="pd-input-suffix-wrap">
|
||||||
|
<input
|
||||||
|
class="pd-input pd-input-price pd-input-with-suffix"
|
||||||
|
v-model="priceForm.price"
|
||||||
|
type="number"
|
||||||
|
inputmode="decimal"
|
||||||
|
placeholder="请输入数字"
|
||||||
|
@input="onPriceInput"
|
||||||
|
/>
|
||||||
|
<!-- 币种下拉:放在输入框内部右侧(无边框) -->
|
||||||
|
<view class="pd-currency-suffix">
|
||||||
|
<uni-data-select
|
||||||
|
v-model="priceForm.currency"
|
||||||
|
:localdata="currencyOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 语言单选 -->
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">语言</view>
|
||||||
|
<radio-group class="pd-radio-group" @change="onLangChange">
|
||||||
|
<label class="pd-radio" v-for="l in langOptions" :key="l.value">
|
||||||
|
<radio :value="l.value" :checked="priceForm.lang === l.value" />
|
||||||
|
<text class="pd-radio-text">{{ l.text }}</text>
|
||||||
|
</label>
|
||||||
|
</radio-group>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="pd-actions">
|
||||||
|
<view class="pd-btn pd-cancel" @tap="closePriceDialog">取消</view>
|
||||||
|
<view class="pd-btn pd-confirm" @tap="confirmPriceDialog">确认</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -106,7 +170,34 @@
|
|||||||
id: '',
|
id: '',
|
||||||
appid: '',
|
appid: '',
|
||||||
detail: {},
|
detail: {},
|
||||||
currentImageIndex: 0
|
currentImageIndex: 0,
|
||||||
|
priceForm: {
|
||||||
|
price: "", // 只存数字字符串
|
||||||
|
currency: "USD", // USD | RUB | AED | EUR
|
||||||
|
lang: "en" // en | ru | es | ar
|
||||||
|
},
|
||||||
|
currencyOptions: [
|
||||||
|
{ value: "USD", text: "美元" },
|
||||||
|
{ value: "CNY", text: "人民币" },
|
||||||
|
{ value: "RUB", text: "卢布" },
|
||||||
|
{ value: "AED", text: "迪拉姆" },
|
||||||
|
{ value: "EUR", text: "欧元" }
|
||||||
|
],
|
||||||
|
langOptions: [
|
||||||
|
{ text: "英语", value: "en" },
|
||||||
|
{ text: "俄语", value: "ru" },
|
||||||
|
{ text: "西班牙语", value: "es" },
|
||||||
|
{ text: "阿拉伯语", value: "ar" }
|
||||||
|
],
|
||||||
|
tradeTermOptions: [
|
||||||
|
{ value: "FOB", text: "FOB" },
|
||||||
|
{ value: "CIF", text: "CIF" },
|
||||||
|
{ value: "EXW", text: "EXW" },
|
||||||
|
{ value: "DDP", text: "DDP" },
|
||||||
|
{ value: "CIP", text: "CIP" },
|
||||||
|
{ value: "FCA", text: "FCA" },
|
||||||
|
{ value: "CFR", text: "CFR" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -195,13 +286,131 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
reviewFile(file){
|
reviewFile(file){
|
||||||
this.downloadByAnchor(file.src, file.name)
|
this.downloadByAnchor(file.src_pull, file.name)
|
||||||
|
},
|
||||||
|
// 打开弹框时调用:可传默认值(可选)
|
||||||
|
openPriceDialog() {
|
||||||
|
this.priceForm = {
|
||||||
|
trade_term:'',
|
||||||
|
price: "",
|
||||||
|
currency: "USD",
|
||||||
|
lang: "en"
|
||||||
|
}
|
||||||
|
this.$refs.inputDialog.open()
|
||||||
|
},
|
||||||
|
|
||||||
|
closePriceDialog() {
|
||||||
|
this.$refs.inputDialog.close()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 只允许数字 + 可选1个小数点(你要“纯整数”也行,我后面给你一行改法)
|
||||||
|
onPriceInput(e) {
|
||||||
|
let v = (e.detail && e.detail.value) ? String(e.detail.value) : String(this.priceForm.price || "")
|
||||||
|
|
||||||
|
// 过滤掉非数字和点
|
||||||
|
v = v.replace(/[^\d.]/g, "")
|
||||||
|
|
||||||
|
// 只保留第一个小数点
|
||||||
|
const parts = v.split(".")
|
||||||
|
if (parts.length > 2) {
|
||||||
|
v = parts[0] + "." + parts.slice(1).join("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉开头多余 0(保留 0.xxx)
|
||||||
|
v = v.replace(/^0+(\d)/, "$1")
|
||||||
|
if (v.startsWith(".")) v = "0" + v
|
||||||
|
|
||||||
|
this.priceForm.price = v
|
||||||
|
},
|
||||||
|
|
||||||
|
onCurrencyPickerChange(e) {
|
||||||
|
const idx = Number(e.detail.value || 0)
|
||||||
|
this.currencyIndex = idx
|
||||||
|
this.priceForm.currency = this.currencyOptions[idx]?.value || "USD"
|
||||||
|
},
|
||||||
|
|
||||||
|
onLangChange(e) {
|
||||||
|
this.priceForm.lang = e.detail.value
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmPriceDialog() {
|
||||||
|
// 校验
|
||||||
|
if (!this.priceForm.trade_term) {
|
||||||
|
return uni.showToast({ title: "请选择贸易条款", icon: "none" })
|
||||||
|
}
|
||||||
|
if (!this.priceForm.price) {
|
||||||
|
return uni.showToast({ title: "请输入价格", icon: "none" })
|
||||||
|
}
|
||||||
|
const payload = {
|
||||||
|
trade_term:this.priceForm.trade_term,
|
||||||
|
price: this.priceForm.price, // 数字字符串
|
||||||
|
currency: this.priceForm.currency, // USD/RUB/AED/EUR
|
||||||
|
lang: this.priceForm.lang // en/ru/es/ar
|
||||||
|
}
|
||||||
|
console.log(payload)
|
||||||
|
this.closePriceDialog()
|
||||||
|
this.dialogInputConfirm(payload)
|
||||||
|
},
|
||||||
|
dialogInputConfirm(val) {
|
||||||
|
if (!val.price) {
|
||||||
|
uni.showToast({ title: '请输入价格', icon: 'none' })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
request({
|
||||||
|
url: 'common/usedcar/produce/pdf',
|
||||||
|
method: 'get',
|
||||||
|
data: { id: this.id, price:val.price,currency:val.currency,lang:val.lang,trade_term:val.trade_term }
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.code == 200) {
|
||||||
|
this.downloadpdf(this.id)
|
||||||
|
} else {
|
||||||
|
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 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 }
|
||||||
|
}).then(res => {
|
||||||
|
if (res.data.code == 200) {
|
||||||
|
this.downloadByAnchor(res.data.data.pdf_url, res.data.data.file_name)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
.tradeTerm{
|
||||||
|
border: 1px solid #eae9e9;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
.heard{
|
||||||
|
padding: 5px 0px;
|
||||||
|
color: #666;
|
||||||
|
font-size: 12px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
.page {
|
.page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #f6f7fb;
|
background: #f6f7fb;
|
||||||
@@ -390,4 +599,122 @@
|
|||||||
.noneview{
|
.noneview{
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.price-dialog{
|
||||||
|
width: 640rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-title{
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row-col{
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-label{
|
||||||
|
width: 120rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input{
|
||||||
|
flex:1;
|
||||||
|
height: 66rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 0 18rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
.pd-input-suffix-wrap{
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-with-suffix{
|
||||||
|
padding-right: 180rpx; /* 给右侧币种留空间 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-currency-suffix{
|
||||||
|
position: absolute;
|
||||||
|
right: 14rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 140rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
::v-deep .uni-select{
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
.pd-radio-group{
|
||||||
|
display:flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx 22rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio-text{
|
||||||
|
margin-left: 10rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-actions{
|
||||||
|
display:flex;
|
||||||
|
gap: 18rpx;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-btn{
|
||||||
|
flex:1;
|
||||||
|
height: 84rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-cancel{
|
||||||
|
background:#f5f5f5;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-confirm{
|
||||||
|
background:#3F435B; /* 你喜欢绿色风格 */
|
||||||
|
color:#fff;
|
||||||
|
font-weight:600;
|
||||||
|
}
|
||||||
|
.pd-price-line{
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-price{
|
||||||
|
flex: 1;
|
||||||
|
min-width: 240rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+270
-11
@@ -29,7 +29,7 @@
|
|||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</z-paging>
|
</z-paging>
|
||||||
<uni-popup ref="inputDialog" type="dialog">
|
<!-- <uni-popup ref="inputDialog" type="dialog">
|
||||||
<uni-popup-dialog
|
<uni-popup-dialog
|
||||||
mode="input"
|
mode="input"
|
||||||
title="请输入价格"
|
title="请输入价格"
|
||||||
@@ -37,6 +37,63 @@
|
|||||||
placeholder="请输入车辆价格"
|
placeholder="请输入车辆价格"
|
||||||
@confirm="dialogInputConfirm"
|
@confirm="dialogInputConfirm"
|
||||||
/>
|
/>
|
||||||
|
</uni-popup> -->
|
||||||
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
|
<view class="price-dialog">
|
||||||
|
<view class="pd-title">设置价格</view>
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">贸易条款</view>
|
||||||
|
<view class="pd-price-line">
|
||||||
|
<uni-data-select
|
||||||
|
v-model="priceForm.trade_term"
|
||||||
|
class="tradeTerm"
|
||||||
|
:localdata="tradeTermOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">价格</view>
|
||||||
|
<view class="pd-price-line">
|
||||||
|
<view class="pd-input-suffix-wrap">
|
||||||
|
<input
|
||||||
|
class="pd-input pd-input-price pd-input-with-suffix"
|
||||||
|
v-model="priceForm.price"
|
||||||
|
type="number"
|
||||||
|
inputmode="decimal"
|
||||||
|
placeholder="请输入数字"
|
||||||
|
@input="onPriceInput"
|
||||||
|
/>
|
||||||
|
<!-- 币种下拉:放在输入框内部右侧(无边框) -->
|
||||||
|
<view class="pd-currency-suffix">
|
||||||
|
<uni-data-select
|
||||||
|
class="pd-currency-select-suffix"
|
||||||
|
v-model="priceForm.currency"
|
||||||
|
:localdata="currencyOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 语言单选 -->
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">语言</view>
|
||||||
|
<radio-group class="pd-radio-group" @change="onLangChange">
|
||||||
|
<label class="pd-radio" v-for="l in langOptions" :key="l.value">
|
||||||
|
<radio :value="l.value" :checked="priceForm.lang === l.value" />
|
||||||
|
<text class="pd-radio-text">{{ l.text }}</text>
|
||||||
|
</label>
|
||||||
|
</radio-group>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="pd-actions">
|
||||||
|
<view class="pd-btn pd-cancel" @tap="closePriceDialog">取消</view>
|
||||||
|
<view class="pd-btn pd-confirm" @tap="confirmPriceDialog">确认</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -44,7 +101,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { request } from '@/api/apiT.js'
|
import { request } from '@/api/apiT.js'
|
||||||
import CarCard from '@/components/CarCard/CarCard.vue'
|
import CarCard from '@/components/CarCard/CarCard.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
CarCard
|
CarCard
|
||||||
@@ -59,7 +115,35 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
loading: false,
|
loading: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
list: []
|
list: [],
|
||||||
|
priceForm: {
|
||||||
|
trade_term:'',
|
||||||
|
price: "", // 只存数字字符串
|
||||||
|
currency: "USD", // USD | RUB | AED | EUR
|
||||||
|
lang: "en" // en | ru | es | ar
|
||||||
|
},
|
||||||
|
currencyOptions: [
|
||||||
|
{ value: "USD", text: "美元" },
|
||||||
|
{ value: "CNY", text: "人民币" },
|
||||||
|
{ value: "RUB", text: "卢布" },
|
||||||
|
{ value: "AED", text: "迪拉姆" },
|
||||||
|
{ value: "EUR", text: "欧元" }
|
||||||
|
],
|
||||||
|
langOptions: [
|
||||||
|
{ text: "英语", value: "en" },
|
||||||
|
{ text: "俄语", value: "ru" },
|
||||||
|
{ text: "西班牙语", value: "es" },
|
||||||
|
{ text: "阿拉伯语", value: "ar" }
|
||||||
|
],
|
||||||
|
tradeTermOptions: [
|
||||||
|
{ value: "FOB", text: "FOB" },
|
||||||
|
{ value: "CIF", text: "CIF" },
|
||||||
|
{ value: "EXW", text: "EXW" },
|
||||||
|
{ value: "DDP", text: "DDP" },
|
||||||
|
{ value: "CIP", text: "CIP" },
|
||||||
|
{ value: "FCA", text: "FCA" },
|
||||||
|
{ value: "CFR", text: "CFR" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -171,6 +255,12 @@
|
|||||||
this.priceDialogItem = payload && payload.item ? payload.item : null
|
this.priceDialogItem = payload && payload.item ? payload.item : null
|
||||||
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
|
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
|
||||||
this.priceDialogValue = ''
|
this.priceDialogValue = ''
|
||||||
|
this.priceForm = {
|
||||||
|
trade_term:'',
|
||||||
|
price:"",
|
||||||
|
currency: "USD",
|
||||||
|
lang: "en"
|
||||||
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.inputDialog && this.$refs.inputDialog.open()
|
this.$refs.inputDialog && this.$refs.inputDialog.open()
|
||||||
})
|
})
|
||||||
@@ -201,25 +291,72 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
closePriceDialog() {
|
||||||
|
this.$refs.inputDialog.close()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 只允许数字 + 可选1个小数点(你要“纯整数”也行,我后面给你一行改法)
|
||||||
|
onPriceInput(e) {
|
||||||
|
let v = (e.detail && e.detail.value) ? String(e.detail.value) : String(this.priceForm.price || "")
|
||||||
|
|
||||||
|
// 过滤掉非数字和点
|
||||||
|
v = v.replace(/[^\d.]/g, "")
|
||||||
|
|
||||||
|
// 只保留第一个小数点
|
||||||
|
const parts = v.split(".")
|
||||||
|
if (parts.length > 2) {
|
||||||
|
v = parts[0] + "." + parts.slice(1).join("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉开头多余 0(保留 0.xxx)
|
||||||
|
v = v.replace(/^0+(\d)/, "$1")
|
||||||
|
if (v.startsWith(".")) v = "0" + v
|
||||||
|
|
||||||
|
this.priceForm.price = v
|
||||||
|
},
|
||||||
|
|
||||||
|
onCurrencyPickerChange(e) {
|
||||||
|
const idx = Number(e.detail.value || 0)
|
||||||
|
this.currencyIndex = idx
|
||||||
|
this.priceForm.currency = this.currencyOptions[idx]?.value || "USD"
|
||||||
|
},
|
||||||
|
|
||||||
|
onLangChange(e) {
|
||||||
|
this.priceForm.lang = e.detail.value
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmPriceDialog() {
|
||||||
|
if (!this.priceForm.trade_term) {
|
||||||
|
return uni.showToast({ title: "请选择贸易条款", icon: "none" })
|
||||||
|
}
|
||||||
|
// 校验
|
||||||
|
if (!this.priceForm.price) {
|
||||||
|
return uni.showToast({ title: "请输入价格", icon: "none" })
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
trade_term:this.priceForm.trade_term,
|
||||||
|
price: this.priceForm.price, // 数字字符串
|
||||||
|
currency: this.priceForm.currency, // USD/RUB/AED/EUR
|
||||||
|
lang: this.priceForm.lang // en/ru/es/ar
|
||||||
|
}
|
||||||
|
console.log(payload)
|
||||||
|
this.closePriceDialog()
|
||||||
|
this.dialogInputConfirm(payload)
|
||||||
|
},
|
||||||
dialogInputConfirm(val) {
|
dialogInputConfirm(val) {
|
||||||
const item = this.priceDialogItem
|
const item = this.priceDialogItem
|
||||||
const index = this.priceDialogIndex
|
const index = this.priceDialogIndex
|
||||||
const price = String(val || '').trim()
|
|
||||||
|
|
||||||
if (!item) return
|
if (!item) return
|
||||||
if (!price) {
|
if (!val.price) {
|
||||||
uni.showToast({ title: '请输入价格', icon: 'none' })
|
uni.showToast({ title: '请输入价格', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isNaN(price) || Number(price) <= 0) {
|
|
||||||
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
request({
|
request({
|
||||||
url: 'common/usedcar/produce/pdf',
|
url: 'common/usedcar/produce/pdf',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
data: { id: item.id, price }
|
data: { id: item.id, price:val.price,currency:val.currency,lang:val.lang,trade_term:val.trade_term }
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.code == 200) {
|
if (res.data.code == 200) {
|
||||||
// 通知刷新列表(你原来就是靠这个事件刷新)
|
// 通知刷新列表(你原来就是靠这个事件刷新)
|
||||||
@@ -272,6 +409,10 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.tradeTerm{
|
||||||
|
border: 1px solid #eae9e9;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
.page {
|
.page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #f4f6f8;
|
background: #f4f6f8;
|
||||||
@@ -300,4 +441,122 @@
|
|||||||
.loadmore {
|
.loadmore {
|
||||||
padding: 18rpx 0 6rpx;
|
padding: 18rpx 0 6rpx;
|
||||||
}
|
}
|
||||||
|
.price-dialog{
|
||||||
|
width: 640rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-title{
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row-col{
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-label{
|
||||||
|
width: 120rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input{
|
||||||
|
flex:1;
|
||||||
|
height: 66rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 0 18rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
.pd-input-suffix-wrap{
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-with-suffix{
|
||||||
|
padding-right: 180rpx; /* 给右侧币种留空间 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-currency-suffix{
|
||||||
|
position: absolute;
|
||||||
|
right: 14rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 140rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
::v-deep .uni-select{
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
.pd-radio-group{
|
||||||
|
display:flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx 22rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio-text{
|
||||||
|
margin-left: 10rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-actions{
|
||||||
|
display:flex;
|
||||||
|
gap: 18rpx;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-btn{
|
||||||
|
flex:1;
|
||||||
|
height: 84rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-cancel{
|
||||||
|
background:#f5f5f5;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-confirm{
|
||||||
|
background:#3F435B; /* 你喜欢绿色风格 */
|
||||||
|
color:#fff;
|
||||||
|
font-weight:600;
|
||||||
|
}
|
||||||
|
.pd-price-line{
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-price{
|
||||||
|
flex: 1;
|
||||||
|
min-width: 240rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+111
-7
@@ -79,6 +79,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
|
this.initFeishuShare()
|
||||||
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
|
// H5:处理分享兜底参数 r(如果路由没命中/经历登录回跳,会先落到首页)
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
try {
|
try {
|
||||||
@@ -98,6 +99,89 @@
|
|||||||
// #endif
|
// #endif
|
||||||
},
|
},
|
||||||
methods: {
|
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)
|
||||||
|
}
|
||||||
|
},
|
||||||
onRequestPrice(payload) {
|
onRequestPrice(payload) {
|
||||||
// payload: { item, index }
|
// payload: { item, index }
|
||||||
this.priceDialogItem = payload && payload.item ? payload.item : null
|
this.priceDialogItem = payload && payload.item ? payload.item : null
|
||||||
@@ -107,6 +191,32 @@
|
|||||||
this.$refs.inputDialog && this.$refs.inputDialog.open()
|
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) {
|
dialogInputConfirm(val) {
|
||||||
const item = this.priceDialogItem
|
const item = this.priceDialogItem
|
||||||
const index = this.priceDialogIndex
|
const index = this.priceDialogIndex
|
||||||
@@ -130,13 +240,7 @@
|
|||||||
if (res.data.code == 200) {
|
if (res.data.code == 200) {
|
||||||
// 通知刷新列表(你原来就是靠这个事件刷新)
|
// 通知刷新列表(你原来就是靠这个事件刷新)
|
||||||
this.onSearch()
|
this.onSearch()
|
||||||
|
this.downloadpdf(item)
|
||||||
// 直接调用对应卡片实例的下载方法(如果 ref 数组存在的话)
|
|
||||||
const cards = this.$refs.carCard
|
|
||||||
const card = Array.isArray(cards) ? cards[index] : cards
|
|
||||||
if (card && typeof card.downloadpdf === 'function') {
|
|
||||||
card.downloadpdf(item)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
|
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
|
||||||
}
|
}
|
||||||
|
|||||||
+301
-50
@@ -26,6 +26,7 @@
|
|||||||
>
|
>
|
||||||
<CarCard
|
<CarCard
|
||||||
:item="item"
|
:item="item"
|
||||||
|
:ismy="true"
|
||||||
@pdfchange="onSearch"
|
@pdfchange="onSearch"
|
||||||
@request-price="onRequestPrice"
|
@request-price="onRequestPrice"
|
||||||
/>
|
/>
|
||||||
@@ -33,13 +34,61 @@
|
|||||||
</view>
|
</view>
|
||||||
</z-paging>
|
</z-paging>
|
||||||
<uni-popup ref="inputDialog" type="dialog">
|
<uni-popup ref="inputDialog" type="dialog">
|
||||||
<uni-popup-dialog
|
<view class="price-dialog">
|
||||||
mode="input"
|
<view class="pd-title">设置价格</view>
|
||||||
title="请输入价格"
|
<view class="pd-row">
|
||||||
:value="priceDialogValue"
|
<view class="pd-label">贸易条款</view>
|
||||||
placeholder="请输入车辆价格"
|
<view class="pd-price-line">
|
||||||
@confirm="dialogInputConfirm"
|
<uni-data-select
|
||||||
/>
|
v-model="priceForm.trade_term"
|
||||||
|
class="tradeTerm"
|
||||||
|
:localdata="tradeTermOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">价格</view>
|
||||||
|
<view class="pd-price-line">
|
||||||
|
<view class="pd-input-suffix-wrap">
|
||||||
|
<input
|
||||||
|
class="pd-input pd-input-price pd-input-with-suffix"
|
||||||
|
v-model="priceForm.price"
|
||||||
|
type="number"
|
||||||
|
inputmode="decimal"
|
||||||
|
placeholder="请输入数字"
|
||||||
|
@input="onPriceInput"
|
||||||
|
/>
|
||||||
|
<!-- 币种下拉:放在输入框内部右侧(无边框) -->
|
||||||
|
<view class="pd-currency-suffix">
|
||||||
|
<uni-data-select
|
||||||
|
class="pd-currency-select-suffix"
|
||||||
|
v-model="priceForm.currency"
|
||||||
|
:localdata="currencyOptions"
|
||||||
|
:clear="false"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 语言单选 -->
|
||||||
|
<view class="pd-row">
|
||||||
|
<view class="pd-label">语言</view>
|
||||||
|
<radio-group class="pd-radio-group" @change="onLangChange">
|
||||||
|
<label class="pd-radio" v-for="l in langOptions" :key="l.value">
|
||||||
|
<radio :value="l.value" :checked="priceForm.lang === l.value" />
|
||||||
|
<text class="pd-radio-text">{{ l.text }}</text>
|
||||||
|
</label>
|
||||||
|
</radio-group>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="pd-actions">
|
||||||
|
<view class="pd-btn pd-cancel" @tap="closePriceDialog">取消</view>
|
||||||
|
<view class="pd-btn pd-confirm" @tap="confirmPriceDialog">确认</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
</uni-popup>
|
</uni-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@@ -62,12 +111,6 @@
|
|||||||
style: {
|
style: {
|
||||||
backgroundColor: '#007aff'
|
backgroundColor: '#007aff'
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '删除',
|
|
||||||
style: {
|
|
||||||
backgroundColor: '#F56C6C'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
keyword: '',
|
keyword: '',
|
||||||
@@ -75,7 +118,35 @@
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
loading: false,
|
loading: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
list: []
|
list: [],
|
||||||
|
priceForm: {
|
||||||
|
trade_term:'',
|
||||||
|
price: "", // 只存数字字符串
|
||||||
|
currency: "USD", // USD | RUB | AED | EUR
|
||||||
|
lang: "en" // en | ru | es | ar
|
||||||
|
},
|
||||||
|
currencyOptions: [
|
||||||
|
{ value: "USD", text: "美元" },
|
||||||
|
{ value: "CNY", text: "人民币" },
|
||||||
|
{ value: "RUB", text: "卢布" },
|
||||||
|
{ value: "AED", text: "迪拉姆" },
|
||||||
|
{ value: "EUR", text: "欧元" }
|
||||||
|
],
|
||||||
|
langOptions: [
|
||||||
|
{ text: "英语", value: "en" },
|
||||||
|
{ text: "俄语", value: "ru" },
|
||||||
|
{ text: "西班牙语", value: "es" },
|
||||||
|
{ text: "阿拉伯语", value: "ar" }
|
||||||
|
],
|
||||||
|
tradeTermOptions: [
|
||||||
|
{ value: "FOB", text: "FOB" },
|
||||||
|
{ value: "CIF", text: "CIF" },
|
||||||
|
{ value: "EXW", text: "EXW" },
|
||||||
|
{ value: "DDP", text: "DDP" },
|
||||||
|
{ value: "CIP", text: "CIP" },
|
||||||
|
{ value: "FCA", text: "FCA" },
|
||||||
|
{ value: "CFR", text: "CFR" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
@@ -187,6 +258,12 @@
|
|||||||
this.priceDialogItem = payload && payload.item ? payload.item : null
|
this.priceDialogItem = payload && payload.item ? payload.item : null
|
||||||
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
|
this.priceDialogIndex = payload && typeof payload.index === 'number' ? payload.index : -1
|
||||||
this.priceDialogValue = ''
|
this.priceDialogValue = ''
|
||||||
|
this.priceForm = {
|
||||||
|
trade_term:'',
|
||||||
|
price:"",
|
||||||
|
currency: "USD",
|
||||||
|
lang: "en"
|
||||||
|
}
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.inputDialog && this.$refs.inputDialog.open()
|
this.$refs.inputDialog && this.$refs.inputDialog.open()
|
||||||
})
|
})
|
||||||
@@ -217,29 +294,77 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
closePriceDialog() {
|
||||||
|
this.$refs.inputDialog.close()
|
||||||
|
},
|
||||||
|
|
||||||
|
// 只允许数字 + 可选1个小数点(你要“纯整数”也行,我后面给你一行改法)
|
||||||
|
onPriceInput(e) {
|
||||||
|
let v = (e.detail && e.detail.value) ? String(e.detail.value) : String(this.priceForm.price || "")
|
||||||
|
|
||||||
|
// 过滤掉非数字和点
|
||||||
|
v = v.replace(/[^\d.]/g, "")
|
||||||
|
|
||||||
|
// 只保留第一个小数点
|
||||||
|
const parts = v.split(".")
|
||||||
|
if (parts.length > 2) {
|
||||||
|
v = parts[0] + "." + parts.slice(1).join("")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 去掉开头多余 0(保留 0.xxx)
|
||||||
|
v = v.replace(/^0+(\d)/, "$1")
|
||||||
|
if (v.startsWith(".")) v = "0" + v
|
||||||
|
|
||||||
|
this.priceForm.price = v
|
||||||
|
},
|
||||||
|
|
||||||
|
onCurrencyPickerChange(e) {
|
||||||
|
const idx = Number(e.detail.value || 0)
|
||||||
|
this.currencyIndex = idx
|
||||||
|
this.priceForm.currency = this.currencyOptions[idx]?.value || "USD"
|
||||||
|
},
|
||||||
|
|
||||||
|
onLangChange(e) {
|
||||||
|
this.priceForm.lang = e.detail.value
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmPriceDialog() {
|
||||||
|
if (!this.priceForm.trade_term) {
|
||||||
|
return uni.showToast({ title: "请选择贸易条款", icon: "none" })
|
||||||
|
}
|
||||||
|
// 校验
|
||||||
|
if (!this.priceForm.price) {
|
||||||
|
return uni.showToast({ title: "请输入价格", icon: "none" })
|
||||||
|
}
|
||||||
|
|
||||||
|
const payload = {
|
||||||
|
trade_term:this.priceForm.trade_term,
|
||||||
|
price: this.priceForm.price, // 数字字符串
|
||||||
|
currency: this.priceForm.currency, // USD/RUB/AED/EUR
|
||||||
|
lang: this.priceForm.lang // en/ru/es/ar
|
||||||
|
}
|
||||||
|
console.log(payload)
|
||||||
|
this.closePriceDialog()
|
||||||
|
this.dialogInputConfirm(payload)
|
||||||
|
},
|
||||||
dialogInputConfirm(val) {
|
dialogInputConfirm(val) {
|
||||||
const item = this.priceDialogItem
|
const item = this.priceDialogItem
|
||||||
const index = this.priceDialogIndex
|
const index = this.priceDialogIndex
|
||||||
const price = String(val || '').trim()
|
|
||||||
|
|
||||||
if (!item) return
|
if (!item) return
|
||||||
if (!price) {
|
if (!val.price) {
|
||||||
uni.showToast({ title: '请输入价格', icon: 'none' })
|
uni.showToast({ title: '请输入价格', icon: 'none' })
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (isNaN(price) || Number(price) <= 0) {
|
|
||||||
uni.showToast({ title: '请输入有效的价格', icon: 'none' })
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
request({
|
request({
|
||||||
url: 'common/usedcar/produce/pdf',
|
url: 'common/usedcar/produce/pdf',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
data: { id: item.id, price }
|
data: { id: item.id, price:val.price,currency:val.currency,lang:val.lang,trade_term:val.trade_term }
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.code == 200) {
|
if (res.data.code == 200) {
|
||||||
// 通知刷新列表(你原来就是靠这个事件刷新)
|
// 通知刷新列表(你原来就是靠这个事件刷新)
|
||||||
this.onSearch()
|
this.onSearch()
|
||||||
|
|
||||||
this.downloadpdf(item)
|
this.downloadpdf(item)
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
|
uni.showToast({ title: res.data.msg || '生成失败', icon: 'none' })
|
||||||
@@ -287,40 +412,48 @@
|
|||||||
let {
|
let {
|
||||||
content
|
content
|
||||||
} = e;
|
} = e;
|
||||||
if (content.text === '删除') {
|
const id = item.id
|
||||||
uni.showModal({
|
uni.navigateTo({
|
||||||
title: '提示',
|
url: `/pages/index/publishedit?id=${id}`
|
||||||
content: '是否删除',
|
})
|
||||||
success: res => {
|
// if (content.text === '删除') {
|
||||||
if (res.confirm) {
|
// uni.showModal({
|
||||||
request({
|
// title: '提示',
|
||||||
url:'common/usedcar/destroy',
|
// content: '是否删除',
|
||||||
method:'post',
|
// success: res => {
|
||||||
data: {id:item.id}
|
// if (res.confirm) {
|
||||||
}).then(res => {
|
// request({
|
||||||
uni.showToast({
|
// url:'common/usedcar/destroy',
|
||||||
title: res.data.message,
|
// method:'post',
|
||||||
icon: 'none'
|
// data: {id:item.id}
|
||||||
});
|
// }).then(res => {
|
||||||
this.queryList()
|
// uni.showToast({
|
||||||
})
|
// title: res.data.message,
|
||||||
} else if (res.cancel) {
|
// icon: 'none'
|
||||||
console.log('用户点击取消');
|
// });
|
||||||
}
|
// this.queryList()
|
||||||
}
|
// })
|
||||||
});
|
// } else if (res.cancel) {
|
||||||
} else {
|
// console.log('用户点击取消');
|
||||||
const id = item.id
|
// }
|
||||||
uni.navigateTo({
|
// }
|
||||||
url: `/pages/index/publishedit?id=${id}`
|
// });
|
||||||
})
|
// } else {
|
||||||
}
|
// const id = item.id
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: `/pages/index/publishedit?id=${id}`
|
||||||
|
// })
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
.tradeTerm{
|
||||||
|
border: 1px solid #eae9e9;
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
.page {
|
.page {
|
||||||
min-height: 100vh;
|
min-height: 100vh;
|
||||||
background: #f4f6f8;
|
background: #f4f6f8;
|
||||||
@@ -349,4 +482,122 @@
|
|||||||
.loadmore {
|
.loadmore {
|
||||||
padding: 18rpx 0 6rpx;
|
padding: 18rpx 0 6rpx;
|
||||||
}
|
}
|
||||||
|
.price-dialog{
|
||||||
|
width: 640rpx;
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 24rpx;
|
||||||
|
padding: 28rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-title{
|
||||||
|
font-size: 34rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #111;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-row-col{
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-label{
|
||||||
|
width: 120rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input{
|
||||||
|
flex:1;
|
||||||
|
height: 66rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 16rpx;
|
||||||
|
padding: 0 18rpx;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
.pd-input-suffix-wrap{
|
||||||
|
position: relative;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-with-suffix{
|
||||||
|
padding-right: 180rpx; /* 给右侧币种留空间 */
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-currency-suffix{
|
||||||
|
position: absolute;
|
||||||
|
right: 14rpx;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
width: 140rpx;
|
||||||
|
height: 80rpx;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
::v-deep .uni-select{
|
||||||
|
border: none !important;
|
||||||
|
}
|
||||||
|
.pd-radio-group{
|
||||||
|
display:flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 16rpx 22rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio{
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-radio-text{
|
||||||
|
margin-left: 10rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-actions{
|
||||||
|
display:flex;
|
||||||
|
gap: 18rpx;
|
||||||
|
margin-top: 40rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-btn{
|
||||||
|
flex:1;
|
||||||
|
height: 84rpx;
|
||||||
|
border-radius: 18rpx;
|
||||||
|
display:flex;
|
||||||
|
align-items:center;
|
||||||
|
justify-content:center;
|
||||||
|
font-size: 30rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-cancel{
|
||||||
|
background:#f5f5f5;
|
||||||
|
color:#333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-confirm{
|
||||||
|
background:#3F435B; /* 你喜欢绿色风格 */
|
||||||
|
color:#fff;
|
||||||
|
font-weight:600;
|
||||||
|
}
|
||||||
|
.pd-price-line{
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pd-input-price{
|
||||||
|
flex: 1;
|
||||||
|
min-width: 240rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
+224
-56
@@ -1,34 +1,22 @@
|
|||||||
<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
|
<!-- <uni-nav-bar leftText=" " :fixed="true" :border="false" color="#fff" backgroundColor="#3F435B" :statusBar="true" title="首页"></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="page-head">
|
||||||
<view class="head-search">
|
<view class="head-search">
|
||||||
<u-search
|
<u-search
|
||||||
v-model="keyword"
|
v-model="keyword"
|
||||||
placeholder="请输入关键词"
|
placeholder="请输入关键词"
|
||||||
:show-action="false"
|
:show-action="false"
|
||||||
shape="round"
|
shape="round"
|
||||||
@change="onKeywordChange"
|
@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
|
||||||
v-for="item in list"
|
v-for="item in list"
|
||||||
@@ -38,10 +26,21 @@
|
|||||||
>
|
>
|
||||||
<CarCard
|
<CarCard
|
||||||
:item="item"
|
:item="item"
|
||||||
|
@pdfchange="onSearch"
|
||||||
|
@request-price="onRequestPrice"
|
||||||
/>
|
/>
|
||||||
</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>
|
||||||
|
|
||||||
@@ -55,18 +54,22 @@
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
priceDialogItem: null,
|
||||||
|
priceDialogIndex: -1,
|
||||||
|
priceDialogValue: '',
|
||||||
options1: [{
|
options1: [{
|
||||||
text: '编辑',
|
text: '编辑',
|
||||||
style: {
|
style: {
|
||||||
backgroundColor: '#007aff'
|
backgroundColor: '#007aff'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
text: '删除',
|
||||||
|
style: {
|
||||||
|
backgroundColor: '#F56C6C'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
],
|
||||||
{
|
|
||||||
text: '删除',
|
|
||||||
style: {
|
|
||||||
backgroundColor: '#F56C6C'
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
keyword: '',
|
keyword: '',
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
@@ -76,48 +79,211 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
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: {
|
||||||
onKeywordChange(val) {
|
isFeishuEnv() {
|
||||||
// val 是输入值(uView 通常会传)
|
// 飞书/ Lark 客户端内置浏览器 UA 通常包含 Feishu / Lark
|
||||||
this.keyword = val
|
try {
|
||||||
|
const ua = (navigator.userAgent || '').toLowerCase()
|
||||||
|
return ua.includes('feishu') || ua.includes('lark')
|
||||||
|
} catch (e) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 防抖:300ms 内持续输入只触发一次
|
loadFeishuJSSDK() {
|
||||||
if (this._kwTimer) clearTimeout(this._kwTimer)
|
// 动态加载飞书 H5 JS-SDK(避免你还要改 public/index.html)
|
||||||
this._kwTimer = setTimeout(() => {
|
return new Promise((resolve, reject) => {
|
||||||
this.onSearch()
|
try {
|
||||||
}, 300)
|
// 已加载
|
||||||
|
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)
|
||||||
},
|
},
|
||||||
queryList(pageNo, pageSize, from) {
|
queryList(pageNo, pageSize, from) {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
var that = this;
|
var that = this;
|
||||||
const params = {
|
const params = {
|
||||||
current: pageNo,
|
current:pageNo,
|
||||||
status: 1,
|
status:1,
|
||||||
size: 10,
|
size:10
|
||||||
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',
|
||||||
data: params
|
data: params
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.data.code == 200) {
|
if(res.data.code ==200){
|
||||||
var datas = res.data.data.records;
|
var datas = res.data.data.records;
|
||||||
this.$refs.paging.complete(datas);
|
this.$refs.paging.complete(datas);
|
||||||
} else {
|
}else{
|
||||||
}
|
}
|
||||||
uni.stopPullDownRefresh();
|
uni.stopPullDownRefresh();
|
||||||
|
//
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
goBack() {
|
swipeClick(e,item){
|
||||||
uni.navigateBack()
|
|
||||||
},
|
|
||||||
swipeClick(e, item) {
|
|
||||||
let {
|
let {
|
||||||
content
|
content
|
||||||
} = e;
|
} = e;
|
||||||
@@ -128,9 +294,9 @@
|
|||||||
success: res => {
|
success: res => {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
request({
|
request({
|
||||||
url: 'common/usedcar/destroy',
|
url:'common/usedcar/destroy',
|
||||||
method: 'post',
|
method:'post',
|
||||||
data: { id: item.id }
|
data: {id:item.id}
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: res.data.message,
|
title: res.data.message,
|
||||||
@@ -165,6 +331,8 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
z-index: 99;
|
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 {
|
||||||
|
|||||||
+135
-7
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
|
||||||
|
<view class="pages">
|
||||||
<!-- <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="content">
|
<view class="content">
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
@@ -76,7 +77,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cell">
|
<view class="cell">
|
||||||
<view>里程</view>
|
<view>里程(Km)</view>
|
||||||
<view class="right">
|
<view class="right">
|
||||||
<input placeholder="请输入里程" v-model="carinfo.mileage" />
|
<input placeholder="请输入里程" v-model="carinfo.mileage" />
|
||||||
</view>
|
</view>
|
||||||
@@ -90,11 +91,25 @@
|
|||||||
<view class="cont">
|
<view class="cont">
|
||||||
<view class="conts">产品图</view>
|
<view class="conts">产品图</view>
|
||||||
<view class="media-upload-wrapper">
|
<view class="media-upload-wrapper">
|
||||||
<uni-file-picker ref="mediaPicker" limit="20" fileMediatype="image" @select="selectMedia" @delete="delfn" >
|
<!-- #ifdef H5 -->
|
||||||
|
<view class="h5-picker-grid">
|
||||||
|
<view class="h5-thumb" v-for="(u, idx) in imagesurl" :key="idx">
|
||||||
|
<image :src="u" mode="aspectFill" class="h5-thumb-img"></image>
|
||||||
|
<view class="h5-thumb-del" @tap.stop="delfn({ index: idx })">删除</view>
|
||||||
|
</view>
|
||||||
|
<view class="upload-icon-wrapper" @tap="pickImagesH5">
|
||||||
|
<image src="/static/image/img.png" class="addimg"></image>
|
||||||
|
<!-- <view class="h5-count">{{ carinfo.images.length }}/{{ maxMedia }}</view> -->
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- #endif -->
|
||||||
|
<!-- #ifndef H5 -->
|
||||||
|
<uni-file-picker ref="mediaPicker" :limit="maxMedia" fileMediatype="image" @select="selectMedia" @delete="delfn" >
|
||||||
<view class="upload-icon-wrapper">
|
<view class="upload-icon-wrapper">
|
||||||
<image src="/static/image/img.png" mode="" class="addimg"></image>
|
<image src="/static/image/img.png" class="addimg"></image>
|
||||||
</view>
|
</view>
|
||||||
</uni-file-picker>
|
</uni-file-picker>
|
||||||
|
<!-- #endif -->
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="cont">
|
<view class="cont">
|
||||||
@@ -161,7 +176,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { request,showToast } from '@/api/apiT.js'
|
import { request,showToast } from '@/api/apiT.js'
|
||||||
@@ -177,6 +192,7 @@
|
|||||||
boundProduct:null,
|
boundProduct:null,
|
||||||
keyword:''
|
keyword:''
|
||||||
},
|
},
|
||||||
|
imagesurl:[],
|
||||||
carinfo:{
|
carinfo:{
|
||||||
product_name:'',
|
product_name:'',
|
||||||
vin:'',
|
vin:'',
|
||||||
@@ -196,7 +212,9 @@
|
|||||||
crawl_series:'',
|
crawl_series:'',
|
||||||
crawl_year:'',
|
crawl_year:'',
|
||||||
crawl_msrp:'',
|
crawl_msrp:'',
|
||||||
crawl_car_id:''
|
crawl_car_id:'',
|
||||||
|
crawl_brand_id:'',
|
||||||
|
crawl_series_id:''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -288,6 +306,8 @@
|
|||||||
this.carinfo.crawl_year = it.year
|
this.carinfo.crawl_year = it.year
|
||||||
this.carinfo.crawl_msrp = it.msrp
|
this.carinfo.crawl_msrp = it.msrp
|
||||||
this.carinfo.crawl_car_id = it.car_id
|
this.carinfo.crawl_car_id = it.car_id
|
||||||
|
this.carinfo.crawl_brand_id = it.brand_id
|
||||||
|
this.carinfo.crawl_series_id = it.series_id
|
||||||
console.log(it)
|
console.log(it)
|
||||||
this.closeBindDialog()
|
this.closeBindDialog()
|
||||||
uni.showToast({ title: '绑定成功', icon: 'none' })
|
uni.showToast({ title: '绑定成功', icon: 'none' })
|
||||||
@@ -299,6 +319,8 @@
|
|||||||
this.carinfo.crawl_year = ''
|
this.carinfo.crawl_year = ''
|
||||||
this.carinfo.crawl_msrp = ''
|
this.carinfo.crawl_msrp = ''
|
||||||
this.carinfo.crawl_car_id = ''
|
this.carinfo.crawl_car_id = ''
|
||||||
|
this.carinfo.crawl_brand_id = ''
|
||||||
|
this.carinfo.crawl_series_id = ''
|
||||||
this.bindState.boundProduct = null
|
this.bindState.boundProduct = null
|
||||||
uni.showToast({ title: '已清除绑定', icon: 'none' })
|
uni.showToast({ title: '已清除绑定', icon: 'none' })
|
||||||
},
|
},
|
||||||
@@ -350,13 +372,63 @@
|
|||||||
if(res && res.data && res.data.file_name){
|
if(res && res.data && res.data.file_name){
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
}else{
|
}else{
|
||||||
reject('上传失败')
|
reject(res)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => reject(err)
|
fail: (err) => reject(err)
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// H5 专用:绕过 uni.chooseImage/chooseMedia 的 9 张限制,使用 uni.chooseFile 支持最多 20 个
|
||||||
|
pickImagesH5() {
|
||||||
|
// const remain = this.maxMedia - this.carinfo.images.length
|
||||||
|
// if (remain <= 0) {
|
||||||
|
// return uni.showToast({ title: `最多只能上传${this.maxMedia}张`, icon: 'none' })
|
||||||
|
// }
|
||||||
|
uni.chooseFile({
|
||||||
|
count: 100,
|
||||||
|
type: 'image',
|
||||||
|
success: (res) => {
|
||||||
|
const paths = (res.tempFilePaths || (res.tempFiles || []).map(it => it.path)).filter(Boolean)
|
||||||
|
if (!paths.length) return
|
||||||
|
Promise.all(paths.map(p => this.uploadfndile(p, 'usedcarimg'))).then(urls => {
|
||||||
|
urls.forEach(url => {
|
||||||
|
this.imagesurl.push(url.file_url)
|
||||||
|
this.carinfo.images.push(url.file_name)
|
||||||
|
})
|
||||||
|
}).catch((e) => {
|
||||||
|
uni.showToast({ title: e.message, icon: 'none' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
pickAttachmentH5() {
|
||||||
|
const remain = this.maxMedia - this.carinfo.attachment.length
|
||||||
|
if (remain <= 0) {
|
||||||
|
return uni.showToast({ title: `最多只能上传${this.maxMedia}个`, icon: 'none' })
|
||||||
|
}
|
||||||
|
uni.chooseFile({
|
||||||
|
count: remain,
|
||||||
|
type: 'all',
|
||||||
|
success: (res) => {
|
||||||
|
const files = res.tempFiles || []
|
||||||
|
const paths = (res.tempFilePaths || files.map(it => it.path)).filter(Boolean)
|
||||||
|
if (!paths.length) return
|
||||||
|
Promise.all(paths.map(p => this.uploadfndile(p, 'usedcarfile'))).then(urls => {
|
||||||
|
urls.forEach((url, idx) => {
|
||||||
|
const obj = {}
|
||||||
|
obj.name = url.original_name || files[idx]?.name || '附件'
|
||||||
|
obj.src = url.file_name
|
||||||
|
this.carinfo.attachment.push(obj)
|
||||||
|
})
|
||||||
|
}).catch(() => {
|
||||||
|
uni.showToast({ title:e.message, icon: 'none' })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
selectMedia(e){
|
selectMedia(e){
|
||||||
const allowCount = this.maxMedia - this.carinfo.images.length
|
const allowCount = this.maxMedia - this.carinfo.images.length
|
||||||
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
|
const tempFilePaths = e.tempFilePaths || (e.tempFiles || []).map(item => item.path || item.url)
|
||||||
@@ -376,6 +448,7 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
delfn(e){
|
delfn(e){
|
||||||
|
this.imagesurl.splice(e.index, 1)
|
||||||
this.carinfo.images.splice(e.index, 1)
|
this.carinfo.images.splice(e.index, 1)
|
||||||
},
|
},
|
||||||
selectMedia1(e){
|
selectMedia1(e){
|
||||||
@@ -432,6 +505,9 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.pages{
|
||||||
|
max-width: 650px;
|
||||||
|
}
|
||||||
.uniui-right{
|
.uniui-right{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
@@ -739,4 +815,56 @@
|
|||||||
opacity: .45;
|
opacity: .45;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* H5 自定义选择器:用于突破 9 个限制(H5 最多 20) */
|
||||||
|
.h5-picker-grid{
|
||||||
|
display:flex;
|
||||||
|
flex-wrap:wrap;
|
||||||
|
gap: 16rpx;
|
||||||
|
align-items:flex-start;
|
||||||
|
}
|
||||||
|
.h5-thumb{
|
||||||
|
width: 210rpx;
|
||||||
|
height: 210rpx;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
overflow:hidden;
|
||||||
|
position: relative;
|
||||||
|
background: #f6f6f6;
|
||||||
|
}
|
||||||
|
.h5-thumb-img{
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
.h5-thumb-del{
|
||||||
|
position:absolute;
|
||||||
|
right: 8rpx;
|
||||||
|
top: 8rpx;
|
||||||
|
background: rgba(0,0,0,0.45);
|
||||||
|
color:#fff;
|
||||||
|
font-size: 22rpx;
|
||||||
|
padding: 6rpx 10rpx;
|
||||||
|
border-radius: 999rpx;
|
||||||
|
}
|
||||||
|
.h5-count{
|
||||||
|
margin-top: 8rpx;
|
||||||
|
font-size: 22rpx;
|
||||||
|
color:#999;
|
||||||
|
text-align:center;
|
||||||
|
}
|
||||||
|
.h5-attach-grid .h5-attach{
|
||||||
|
width: 210rpx;
|
||||||
|
min-height: 120rpx;
|
||||||
|
padding: 16rpx;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
border-radius: 12rpx;
|
||||||
|
background: #fafafa;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.h5-attach-name{
|
||||||
|
font-size: 24rpx;
|
||||||
|
color:#333;
|
||||||
|
word-break: break-all;
|
||||||
|
padding-right: 60rpx;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
+897
-645
File diff suppressed because it is too large
Load Diff
@@ -92,7 +92,7 @@
|
|||||||
const res = await request({
|
const res = await request({
|
||||||
url: 'common/auth/login',
|
url: 'common/auth/login',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: { feishu_code: code,app_id:uni.getStorageSync('fsappid')}
|
data: { feishu_code: code,app_id:uni.getStorageSync('fsappid'),is_pc:0}
|
||||||
})
|
})
|
||||||
|
|
||||||
const token = res?.data?.data?.union_id
|
const token = res?.data?.data?.union_id
|
||||||
|
|||||||
@@ -72,12 +72,12 @@
|
|||||||
async silentAuth() {
|
async silentAuth() {
|
||||||
try {
|
try {
|
||||||
// 1) 如果本地已有 token,直接进首页(丝滑)
|
// 1) 如果本地已有 token,直接进首页(丝滑)
|
||||||
const token = uni.getStorageSync('token')
|
// const token = uni.getStorageSync('token')
|
||||||
if (token) {
|
// if (token) {
|
||||||
this.title = '已登录'
|
// this.title = '已登录'
|
||||||
this.desc = '正在进入页面'
|
// this.desc = '正在进入页面'
|
||||||
return this.goRedirectSmooth()
|
// return this.goRedirectSmooth()
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 2) 获取飞书授权跳转地址(静默授权/免登)
|
// 2) 获取飞书授权跳转地址(静默授权/免登)
|
||||||
this.title = '正在跳转飞书授权'
|
this.title = '正在跳转飞书授权'
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
const res = await request({
|
const res = await request({
|
||||||
url: 'common/auth/feishu/scope',
|
url: 'common/auth/feishu/scope',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
data:{app_id:this.fsappid}
|
data:{app_id:this.fsappid,is_pc:0}
|
||||||
})
|
})
|
||||||
const auth_url = res?.data?.data?.auth_url
|
const auth_url = res?.data?.data?.auth_url
|
||||||
if (!auth_url) {
|
if (!auth_url) {
|
||||||
|
|||||||
Reference in New Issue
Block a user