[发布商品认证及商品认证展示,详情页面水晶展示位置]

This commit is contained in:
2021-11-26 11:33:51 +08:00
parent c85f1bccc0
commit 47667b9177
7 changed files with 344 additions and 272 deletions

View File

@@ -1,56 +1,40 @@
<template>
<view class="content">
<view class="form-block">
<view class="form-upd">
<view class="form-title">产品实物图片<text>点击预览长按删除</text></view>
<view class="form-imgs">
<view
class="item"
v-if="extendCover.length > 0"
@click="openImg"
@longpress="extendCover = []"
>
<image class="item-cover" :src="extendCover[0].showpath" mode="aspectFill"></image>
</view>
<view class="item item-add" v-else @click="updCover">
<image class="item-cover" src="@/static/icons/add-icon.png" mode="aspectFill"></image>
</view>
</view>
</view>
</view>
<!-- 商品基本信息 -->
<view class="form-block">
<view class="form-box picker-flex">
<label class="form-label">生产日期</label>
<picker mode="date" :value="productedAt" @change="pickerChange($event, 'productedAt')">
<view class="picker-text">
{{productedAt || '选择商品生产日期'}}
<uni-icons class="picker-icon" type="arrowright" color="#999"></uni-icons>
<block v-for="item in createInfo" :key='item.id'>
<!-- text -->
<view class="form-box inputs-flex" v-if="item.type === 1">
<label class="form-label"><span v-if='item.required'>*</span>{{item.title}}</label>
<input type="text" @input='inputT(item.name,$event)' v-model="createAddInfo[item.name]" :placeholder="`请输入${item.title}`" />
</view>
<!-- images -->
<view class="form-upd" v-if="item.type === 2">
<view class="form-title"><span v-if='item.required'>*</span>{{item.title}}<text>点击预览长按删除</text></view>
<view class="form-imgs">
<view class="item" v-if="createAddInfo[item.name].showpath" @click="openImg(item.name)"
@longpress="delImg(item.name)">
<image class="item-cover" :src="createAddInfo[item.name].showpath" mode="aspectFill"></image>
</view>
<view class="item item-add" v-else @click="updCover(item.name)">
<image class="item-cover" src="@/static/icons/add-icon.png" mode="aspectFill"></image>
</view>
</view>
</picker>
</view>
<view class="form-box picker-flex">
<label class="form-label">过期时间</label>
<picker mode="date" :value="expiriedAt" @change="pickerChange($event, 'expiriedAt')">
<view class="picker-text">
{{expiriedAt || '选择商品过期时间'}}
<uni-icons class="picker-icon" type="arrowright" color="#999"></uni-icons>
</view>
</picker>
</view>
<view class="form-box inputs-flex">
<label class="form-label">生产商名称</label>
<input type="text" v-model="productName" placeholder="输入商品生产商名称"/>
</view>
<view class="form-box inputs-flex">
<label class="form-label">生产许可证号</label>
<input type="text" v-model="lisence" placeholder="输入商品生产许可证号"/>
</view>
<view class="form-box inputs-flex">
<label class="form-label">生产商地址</label>
<input type="text" v-model="productAddress" placeholder="输入商品生产商地址"/>
</view>
</view>
<!-- date -->
<view class="form-box picker-flex" v-if="item.type === 3">
<label class="form-label"><span v-if='item.required'>*</span>{{item.title}}</label>
<picker mode="date" :value="createAddInfo[item.name]" @change="pickerChange($event, item.name)">
<view class="picker-text">
{{createAddInfo[item.name] || `选择${item.title}`}}
<uni-icons class="picker-icon" type="arrowright" color="#999"></uni-icons>
</view>
</picker>
</view>
</block>
</view>
<!-- 安全区 -->
<view class="ios-bottom"></view>
@@ -63,95 +47,120 @@
</template>
<script>
import { managesGoodsAuth, managesGoodsExtends } from '@/apis/interfaces/goods'
import { uploads } from '@/apis/interfaces/uploading'
import {
managesGoodsAuth,
managesGoodsExtends,
goodsExtendsCreate
} from '@/apis/interfaces/goods'
import {
uploads
} from '@/apis/interfaces/uploading'
export default {
data() {
return {
productedAt : '', // 生产日期
expiriedAt : '', // 过期时间
lisence : '', // 生产许可证号
productName : '', // 生产商名称
productAddress : '', // 生产商地址
extendCover : [] // 实物图片
createAddInfo: {}, // suoyou
createInfo: [], // 认证信息可以活的
};
},
created() {
if(this.$Route.query.edit === 'true' || this.$Route.query.edit ){
managesGoodsExtends(this.$Route.query.id).then(res => {
this.productedAt = res.producted_at
this.expiriedAt = res.expiried_at
this.lisence = res.lisence
this.productName = res.product_name
this.productAddress = res.product_address
this.extendCover = [{...res.cover}]
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
goodsExtendsCreate(this.$Route.query.id).then(res => {
this.createInfo = res.length > 0 ? res : []
res.filter(item => {
if (item.type === 2) {
this.$set(this.createAddInfo, item.name, {
path: '',
showpath: ''
})
} else {
this.$set(this.createAddInfo, item.name, '')
}
})
}
if (this.$Route.query.edit === 'true' || this.$Route.query.edit) {
managesGoodsExtends(this.$Route.query.id).then(res => {
console.log(res)
this.createAddInfo = res
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
methods: {
// 输入框txt 分别赋值给text
inputT(key, e) {
this.$set(this.createAddInfo, key, e.detail.value)
},
// picker选择
pickerChange(e, key){
this[key] = e.detail.value
pickerChange(e, key) {
this.$set(this.createAddInfo, key, e.detail.value)
},
// 图片预览
openImg(){
let paths = this.extendCover.map(val => {
return val.showpath
})
openImg(key) {
console.log(key)
uni.previewImage({
urls : paths,
current : 0,
urls: [this.createAddInfo[key].showpath],
current: 0,
indicator: 'number'
})
},
delImg(key){
this.$set(this.createAddInfo, key, {
path: '',
showpath:''
})
},
// 上传图片
updCover(){
updCover(key) {
uni.chooseImage({
count : 1,
success : res => {
count: 1,
success: res => {
uploads([{
uri : res.tempFilePaths[0]
uri: res.tempFilePaths[0]
}]).then(updRes => {
this.extendCover.push({
path : updRes.path[0],
showpath: updRes.url[0]
this.$nextTick(() => {
this.$set(this.createAddInfo, key, {
path: updRes.path[0],
showpath: updRes.url[0]
})
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
icon: 'none'
})
})
}
})
},
// 发布产品
submitAdd(){
let submitData = {
producted_at : this.productedAt,
expiried_at : this.expiriedAt,
lisence : this.lisence,
product_name : this.productName,
product_address : this.productAddress,
extend_cover : this.extendCover[0].path
}
submitAdd() {
let submitData = this.createAddInfo
this.createInfo.filter(item => {
if (item.type === 2) {
submitData[item.name] = this.createAddInfo[item.name].path
}
})
let submitFund = managesGoodsAuth(this.$Route.query.id, submitData)
submitFund.then(res => {
uni.setStorageSync('refresh',true)
uni.setStorageSync('refresh', true)
uni.showModal({
title : '提示',
content : '商品权证认证信息已提交,请耐心等待平台审核',
showCancel : false,
success : res => {
if(res.confirm){
if(this.$Route.query.type == 'goodsAdd'){
title: '提示',
content: '商品权证认证信息已提交,请耐心等待平台审核',
showCancel: false,
success: res => {
if (res.confirm) {
if (this.$Route.query.type == 'goodsAdd') {
this.$Router.back(this.$Route.query.edit == 'true' ? 2 : 3)
}else{
} else {
this.$Router.back()
}
}
@@ -160,7 +169,7 @@
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
icon: 'none'
})
})
}
@@ -169,20 +178,23 @@
</script>
<style lang="scss" scoped>
.content{
.content {
padding-bottom: 150rpx;
}
// 表单
.form-block{
.form-block {
background: white;
margin-top: $margin - 10;
.form-box{
.form-box {
position: relative;
padding-left: 240rpx;
padding-right: $padding;
font-size: $title-size-lg;
min-height: 80rpx;
&::after{
&::after {
position: absolute;
bottom: 0;
left: $margin;
@@ -191,26 +203,35 @@
content: " ";
background: $border-color;
}
&:last-child::after{
&:last-child::after {
display: none;
}
.form-label{
.form-label {
position: absolute;
left: $margin;
line-height: 80rpx;
top: 0;
width: calc(240rpx - #{$margin});
span{
color: #f00;
padding-right: $padding * .2;
}
}
}
.inputs-flex{
input{
.inputs-flex {
input {
height: 80rpx;
line-height: 80rpx;
}
}
.input-unit{
.input-unit {
padding-right: 200rpx;
.units{
.units {
position: absolute;
right: 0;
top: 0;
@@ -222,49 +243,61 @@
box-sizing: border-box;
}
}
.picker-flex{
.picker-text{
.picker-flex {
.picker-text {
position: relative;
line-height: 80rpx;
min-height: 80rpx;
padding-right: 80rpx;
@extend .nowrap;
.picker-icon{
.picker-icon {
right: 0;
position: absolute;
}
}
.picker-switch{
.picker-switch {
line-height: 80rpx;
min-height: 80rpx;
text-align: right;
margin-right: -15rpx;
switch{
transform:scale(0.7)
switch {
transform: scale(0.7)
}
}
}
.form-upd{
.form-title{
.form-upd {
.form-title {
font-size: $title-size-lg;
line-height: 80rpx;
padding: 0 $padding;
text{
span{
color: #f00;
padding-right: $padding * .2;
}
text {
font-size: 80%;
color: $text-gray;
}
}
.form-imgs{
.form-imgs {
margin-top: -($margin/3);
padding: 0 20rpx 20rpx;
display: flex;
flex-wrap: wrap;
.item{
.item {
width: calc(20% - 14rpx);
padding-top: calc(20% - 14rpx);
margin: 7rpx;
position: relative;
.item-cover{
.item-cover {
position: absolute;
top: 0;
left: 0;
@@ -272,10 +305,12 @@
height: 100%;
}
}
.item-add{
.item-add {
border: dashed 2rpx $border-color;
box-sizing: border-box;
.item-cover{
.item-cover {
top: calc(15% - 2rpx);
left: calc(15% - 2rpx);
width: 70%;
@@ -285,8 +320,9 @@
}
}
}
// 发布
.footer{
.footer {
background: white;
position: fixed;
bottom: 0;
@@ -295,7 +331,8 @@
padding: 20rpx $padding;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
z-index: 9;
.footer-btn{
.footer-btn {
border: none;
border-radius: 0;
background: $text-price;
@@ -304,62 +341,75 @@
font-weight: bold;
font-size: $title-size;
color: white;
&::after{
&::after {
border: none;
}
}
}
// 可选服务
.category-popup{
.category-popup {
background: #F5F5F5;
padding: 0 $padding * 2 $padding * 2 $padding * 2;
.header{
.header {
padding: $padding*2 0;
box-sizing: border-box;
@extend .vertical;
.title{
.title {
text-align: center;
font-size: $title-size + 14;
font-weight: bold;
line-height: 90rpx;
}
.subtitle{
.subtitle {
font-size: $title-size-m;
color: $text-gray;
text-align: center;
}
}
.category-flex{
.category-flex {
max-height: 50vh;
overflow-y: scroll;
.category-flex-item{
.category-flex-item {
margin-bottom: $margin;
padding: $padding;
background: white;
border:solid 1rpx white;
border: solid 1rpx white;
box-sizing: border-box;
.category-name{
.category-name {
padding-bottom: $padding/2;
font-weight: bold;
font-size: $title-size-lg;
}
.category-content{
.category-content {
font-size: $title-size-sm;
color: $text-gray;
@extend .ellipsis;
}
&.show{
&.show {
color: $text-price;
border:solid 1rpx $text-price;
border: solid 1rpx $text-price;
}
&:last-child{
&:last-child {
margin-bottom: 0;
}
}
}
.btns{
.btns {
padding-top: $padding * 2;
button{
button {
background: $text-price;
border-radius: 0;
height: 90rpx;
@@ -367,7 +417,8 @@
font-size: $title-size;
color: white;
font-weight: bold;
&::after{
&::after {
border: none;
}
}