Files
BlockChainH5/pages/goods/goodsAuth.vue

428 lines
8.7 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<!-- 商品基本信息 -->
<view class="form-block">
<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>
</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>
<!-- footer -->
<view class="footer">
<button class="footer-btn" type="default" @click="submitAdd">提交认证审核</button>
<view class="ios-bottom"></view>
</view>
</view>
</template>
<script>
import {
managesGoodsAuth,
managesGoodsExtends,
goodsExtendsCreate
} from '@/apis/interfaces/goods'
import {
uploads
} from '@/apis/interfaces/uploading'
export default {
data() {
return {
createAddInfo: {}, // suoyou
createInfo: [], // 认证信息可以活的
};
},
created() {
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.$set(this.createAddInfo, key, e.detail.value)
},
// 图片预览
openImg(key) {
console.log(key)
uni.previewImage({
urls: [this.createAddInfo[key].showpath],
current: 0,
indicator: 'number'
})
},
delImg(key){
this.$set(this.createAddInfo, key, {
path: '',
showpath:''
})
},
// 上传图片
updCover(key) {
uni.chooseImage({
count: 1,
success: res => {
uploads([{
uri: res.tempFilePaths[0]
}]).then(updRes => {
this.$nextTick(() => {
this.$set(this.createAddInfo, key, {
path: updRes.path[0],
showpath: updRes.url[0]
})
})
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
})
},
// 发布产品
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.showModal({
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 {
this.$Router.back()
}
}
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
}
}
}
</script>
<style lang="scss" scoped>
.content {
padding-bottom: 150rpx;
}
// 表单
.form-block {
background: white;
margin-top: $margin - 10;
.form-box {
position: relative;
padding-left: 240rpx;
padding-right: $padding;
font-size: $title-size-lg;
min-height: 80rpx;
&::after {
position: absolute;
bottom: 0;
left: $margin;
right: 0;
height: 1rpx;
content: " ";
background: $border-color;
}
&:last-child::after {
display: none;
}
.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 {
height: 80rpx;
line-height: 80rpx;
}
}
.input-unit {
padding-right: 200rpx;
.units {
position: absolute;
right: 0;
top: 0;
line-height: 80rpx;
height: 80rpx;
width: 200rpx;
padding-right: $padding;
text-align: right;
box-sizing: border-box;
}
}
.picker-flex {
.picker-text {
position: relative;
line-height: 80rpx;
min-height: 80rpx;
padding-right: 80rpx;
@extend .nowrap;
.picker-icon {
right: 0;
position: absolute;
}
}
.picker-switch {
line-height: 80rpx;
min-height: 80rpx;
text-align: right;
margin-right: -15rpx;
switch {
transform: scale(0.7)
}
}
}
.form-upd {
.form-title {
font-size: $title-size-lg;
line-height: 80rpx;
padding: 0 $padding;
span{
color: #f00;
padding-right: $padding * .2;
}
text {
font-size: 80%;
color: $text-gray;
}
}
.form-imgs {
margin-top: -($margin/3);
padding: 0 20rpx 20rpx;
display: flex;
flex-wrap: wrap;
.item {
width: calc(20% - 14rpx);
padding-top: calc(20% - 14rpx);
margin: 7rpx;
position: relative;
.item-cover {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
.item-add {
border: dashed 2rpx $border-color;
box-sizing: border-box;
.item-cover {
top: calc(15% - 2rpx);
left: calc(15% - 2rpx);
width: 70%;
height: 70%;
}
}
}
}
}
// 发布
.footer {
background: white;
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx $padding;
box-shadow: 0 0 4rpx 4rpx rgba($color: #000000, $alpha: .02);
z-index: 9;
.footer-btn {
border: none;
border-radius: 0;
background: $text-price;
height: 90rpx;
line-height: 90rpx;
font-weight: bold;
font-size: $title-size;
color: white;
&::after {
border: none;
}
}
}
// 可选服务
.category-popup {
background: #F5F5F5;
padding: 0 $padding * 2 $padding * 2 $padding * 2;
.header {
padding: $padding*2 0;
box-sizing: border-box;
@extend .vertical;
.title {
text-align: center;
font-size: $title-size + 14;
font-weight: bold;
line-height: 90rpx;
}
.subtitle {
font-size: $title-size-m;
color: $text-gray;
text-align: center;
}
}
.category-flex {
max-height: 50vh;
overflow-y: scroll;
.category-flex-item {
margin-bottom: $margin;
padding: $padding;
background: white;
border: solid 1rpx white;
box-sizing: border-box;
.category-name {
padding-bottom: $padding/2;
font-weight: bold;
font-size: $title-size-lg;
}
.category-content {
font-size: $title-size-sm;
color: $text-gray;
@extend .ellipsis;
}
&.show {
color: $text-price;
border: solid 1rpx $text-price;
}
&:last-child {
margin-bottom: 0;
}
}
}
.btns {
padding-top: $padding * 2;
button {
background: $text-price;
border-radius: 0;
height: 90rpx;
line-height: 90rpx;
font-size: $title-size;
color: white;
font-weight: bold;
&::after {
border: none;
}
}
}
}
</style>