Commit e3f025e1 authored by hanfeng zhang's avatar hanfeng zhang

Merge branch 'main' of gitlab.33.cn:HF_web/NFT

parents 062a89eb fb253934
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<!-- 右边 --> <!-- 右边 -->
<div class="right flex items-center overflow-hidden"> <div class="right flex items-center overflow-ellipsis">
<div v-if="type == 'click'" @click="eventEmit(type)"> <div v-if="type == 'click'" @click="eventEmit(type)">
<div class="flex items-center"> <div class="flex items-center">
<div class="text-sm">{{ value }}</div> <div class="text-sm">{{ value }}</div>
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
@input="cellOnChange" @input="cellOnChange"
/> />
</div> </div>
<input v-else-if="type === 'input-num'" <input v-else-if="type === 'input-num'"
:value="inputValue" :value="inputValue"
type="number" type="number"
...@@ -48,6 +49,7 @@ ...@@ -48,6 +49,7 @@
class="bg-transparent" class="bg-transparent"
:placeholder="placeholder" :placeholder="placeholder"
/> />
<div v-else-if="type === 'pick'"> <div v-else-if="type === 'pick'">
<div class="flex flex-row items-center"> <div class="flex flex-row items-center">
<div @click="eventEmit(type)"> <div @click="eventEmit(type)">
...@@ -74,11 +76,12 @@ ...@@ -74,11 +76,12 @@
</div> </div>
</div> </div>
</div> </div>
<div v-else-if="type === 'upload'" class="overflow-hidden"> <div v-else-if="type === 'upload'" class="overflow-hidden">
<div class="flex flex-row items-center overflow-hidden"> <div class="flex flex-row items-center overflow-hidden">
<div <div
v-if="name" v-if="name"
class="overflow-hidden overflow-ellipsis" class="overflow-hidden overflow-ellipsis whitespace-nowrap w-48 text-right"
@click="cellOnChange" @click="cellOnChange"
> >
{{ name }} {{ name }}
...@@ -95,15 +98,17 @@ ...@@ -95,15 +98,17 @@
</div> </div>
</div> </div>
</div> </div>
<div v-else-if="type === 'showText'" class="overflow-hidden"> <div v-else-if="type === 'showText'" class="overflow-hidden">
<div class="flex flex-row items-center overflow-hidden"> <div class="flex flex-row items-center overflow-ellipsis">
<div <div
v-if="name" v-if="name"
class="overflow-hidden overflow-ellipsis" class=" overflow-hidden overflow-ellipsis whitespace-nowrap text-sm w-56"
id="copyNodeId" id="copyNodeId"
> >
{{ name }} {{ name }}
</div> </div>
<div ref="btn" @click="handleClickCopy(name)" class="ml-1"> <div ref="btn" @click="handleClickCopy(name)" class="ml-1">
<app-icon name="icon-fuzhi" size="18px"></app-icon> <app-icon name="icon-fuzhi" size="18px"></app-icon>
</div> </div>
...@@ -112,7 +117,7 @@ ...@@ -112,7 +117,7 @@
<div v-else-if="type === 'select'" class="overflow-hidden"> <div v-else-if="type === 'select'" class="overflow-hidden">
<div class="flex flex-row items-center overflow-hidden"> <div class="flex flex-row items-center overflow-hidden">
<div <div
class="overflow-hidden overflow-ellipsis" class="overflow-hidden overflow-ellipsis "
@click="eventEmit(type)" @click="eventEmit(type)"
> >
{{ getNameOfSelect(selected) }} {{ getNameOfSelect(selected) }}
...@@ -124,8 +129,8 @@ ...@@ -124,8 +129,8 @@
</div> </div>
<div v-else-if="type === 'image'"> <div v-else-if="type === 'image'">
<div class="flex flex-row items-center self-end"> <div class="flex flex-row items-center self-end">
<div class='w-20 pr-1'> <div class='w-20 h-20 pr-1 flex items-center'>
<img :src="value" class='rounded-full w-18 object-fill' > <van-image width="80" height="80" lazy-load show-loading show-error round fit="cover" :src="value"/>
</div> </div>
<app-icon v-if="icon" :name="icon" class="self-center"></app-icon> <app-icon v-if="icon" :name="icon" class="self-center"></app-icon>
</div> </div>
...@@ -183,6 +188,7 @@ export default Vue.extend({ ...@@ -183,6 +188,7 @@ export default Vue.extend({
name: [String, Number], name: [String, Number],
selected: [String, Number, Object], selected: [String, Number, Object],
list: Array, list: Array,
validate:Object,
}, },
data() { data() {
return { return {
...@@ -215,8 +221,8 @@ export default Vue.extend({ ...@@ -215,8 +221,8 @@ export default Vue.extend({
} }
}, },
cellOnChange(e:any) { cellOnChange(e:any) {
if(e.target.value && e.target.value.length >= 15) { if(e.target.value && e.target.value.length >= this.validate.maxLen) {
this.inputValue = (this.inputValue as string).slice(0,15) this.inputValue = (this.inputValue as string).slice(0,this.validate.maxLen)
} }
this.$emit("cellOnChange", this.inputValue); this.$emit("cellOnChange", this.inputValue);
}, },
......
...@@ -28,6 +28,10 @@ export class NFTService extends Service { ...@@ -28,6 +28,10 @@ export class NFTService extends Service {
path: '/oss/policy', path: '/oss/policy',
dataType: 'application/x-www-form-urlencoded', dataType: 'application/x-www-form-urlencoded',
}, },
fileUpload: {
path: '/oss/upload',
dataType: 'multipart/form-data'
},
getMd5: { path: '/nft/file/md5', dataType: 'multipart/form-data' }, getMd5: { path: '/nft/file/md5', dataType: 'multipart/form-data' },
save: { path: '/nft/save', dataType: 'multipart/form-data' }, save: { path: '/nft/save', dataType: 'multipart/form-data' },
publish: { path: '/nft/publish', dataType: 'application/json' }, publish: { path: '/nft/publish', dataType: 'application/json' },
...@@ -209,6 +213,18 @@ export class NFTService extends Service { ...@@ -209,6 +213,18 @@ export class NFTService extends Service {
}) })
} }
//普通文件上传
async fileUpload(file:File):Promise<string>{
const fd = new FormData()
fd.append('file',file)
return await this.service.post(this.router.fileUpload.path,fd,{
headers: {
Authorization: this.getAuth(),
'Content-Type': this.router.fileUpload.dataType,
}
})
}
/** /**
* 完成OSS签名 * 完成OSS签名
*/ */
......
...@@ -11,4 +11,5 @@ export interface iSaveData { ...@@ -11,4 +11,5 @@ export interface iSaveData {
isGrant?: number isGrant?: number
fileUrl?: string fileUrl?: string
fileName?: string fileName?: string
cover?: string
} }
...@@ -16,18 +16,18 @@ ...@@ -16,18 +16,18 @@
v-model="createNFT.value_name" v-model="createNFT.value_name"
type="input" type="input"
:text='fromText.nameText' :text='fromText.nameText'
:validate="{ maxLen: 20 }" :validate="{ maxLen: 15 }"
:placeholder="fromText.namePlaceholder" :placeholder="fromText.namePlaceholder"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="(v) => setCreateNFT({ value_name: v })" @cellOnChange="(v) => setCreateNFT({ value_name: v })"
></app-cell> ></app-cell>
<app-cell <app-cell
v-model="createNFT.value_publisher" v-model="createNFT.value_publisher"
type="input" type="input"
:text="fromText.authorText" :text="fromText.authorText"
:validate="{ maxLen: 20 }" :validate="{ maxLen: 15 }"
:placeholder="fromText.authorPlaceholder" :placeholder="fromText.authorPlaceholder"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="(v) => setCreateNFT({ value_publisher: v })" @cellOnChange="(v) => setCreateNFT({ value_publisher: v })"
></app-cell> ></app-cell>
<app-cell <app-cell
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
v-model="createNFT.value_des" v-model="createNFT.value_des"
name="des" name="des"
id="nft-des" id="nft-des"
cols="10" cols="30"
maxlength="500" maxlength="500"
:placeholder="fromText.desPlaceholder" :placeholder="fromText.desPlaceholder"
rows="10" rows="10"
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
rounded-md rounded-md
text-sm text-sm
" "
@input="textareaChange"
></textarea> ></textarea>
</div> </div>
<div class="fixed bottom-3 w-full left-0 z-30"> <div class="fixed bottom-3 w-full left-0 z-30">
...@@ -73,7 +72,7 @@ ...@@ -73,7 +72,7 @@
<div class="step-two" v-if="currentStep == 2"> <div class="step-two" v-if="currentStep == 2">
<app-cell <app-cell
:text="fromText.fileUploadText" :text="fromText.fileUploadText"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
type="upload" type="upload"
:placeholder="fromText.filePlaceholder" :placeholder="fromText.filePlaceholder"
:name="fileName" :name="fileName"
...@@ -81,7 +80,7 @@ ...@@ -81,7 +80,7 @@
></app-cell> ></app-cell>
<app-cell <app-cell
text="封面上传(非必填)" text="封面上传(非必填)"
class="text-font-white my-3 " class="text-font-white my-3 text-sm"
type="upload" type="upload"
placeholder="请上传相关封面" placeholder="请上传相关封面"
:name="coverName" :name="coverName"
...@@ -89,7 +88,7 @@ ...@@ -89,7 +88,7 @@
></app-cell> ></app-cell>
<app-cell <app-cell
:text="fromText.fileHashText" :text="fromText.fileHashText"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
type="showText" type="showText"
:name="fileHash" :name="fileHash"
@cellOnChange="getValue" @cellOnChange="getValue"
...@@ -101,7 +100,7 @@ ...@@ -101,7 +100,7 @@
labelIcon="icon-wenhao" labelIcon="icon-wenhao"
@clickIcon="alertPlatformSave" @clickIcon="alertPlatformSave"
:list="archivesList" :list="archivesList"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="(v) => (createNFT.archives = v)" @cellOnChange="(v) => (createNFT.archives = v)"
></app-cell> ></app-cell>
<app-cell <app-cell
...@@ -112,7 +111,7 @@ ...@@ -112,7 +111,7 @@
labelIcon="icon-wenhao" labelIcon="icon-wenhao"
@clickIcon="alertAuthorizeRead" @clickIcon="alertAuthorizeRead"
:list="grantList" :list="grantList"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="(v) => (createNFT.grant = v)" @cellOnChange="(v) => (createNFT.grant = v)"
></app-cell> ></app-cell>
<div class="fixed bottom-3 w-full left-0 flex flex-row z-30"> <div class="fixed bottom-3 w-full left-0 flex flex-row z-30">
...@@ -138,20 +137,20 @@ ...@@ -138,20 +137,20 @@
text="NFT编号" text="NFT编号"
type="showText" type="showText"
:name="publish.nftId" :name="publish.nftId"
class="text-font-white my-3 break-all" class="text-font-white my-3 text-sm"
></app-cell> ></app-cell>
<app-cell <app-cell
:text="fromText.fileHashText" :text="fromText.fileHashText"
type="showText" type="showText"
:name="publish.fileHash" :name="publish.fileHash"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="getValue" @cellOnChange="getValue"
></app-cell> ></app-cell>
<app-cell <app-cell
text="发行人地址" text="发行人地址"
type="showText" type="showText"
:name="publish.wallet" :name="publish.wallet"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange="getValue" @cellOnChange="getValue"
></app-cell> ></app-cell>
<app-cell <app-cell
...@@ -160,7 +159,7 @@ ...@@ -160,7 +159,7 @@
:value="1" :value="1"
:disabled="true" :disabled="true"
type="input-num" type="input-num"
class="text-font-white my-3" class="text-font-white my-3 text-sm"
@cellOnChange=" @cellOnChange="
(v) => { (v) => {
publish.count = v; publish.count = v;
...@@ -344,7 +343,8 @@ export default Vue.extend({ ...@@ -344,7 +343,8 @@ export default Vue.extend({
fileName: "fileName", fileName: "fileName",
file: "file", file: "file",
pickedList: "pickedList", pickedList: "pickedList",
coverName: 'coverName' coverName: 'coverName',
coverFile: "coverFile"
}), }),
validation(): boolean { validation(): boolean {
let disabled = true; let disabled = true;
...@@ -442,15 +442,15 @@ export default Vue.extend({ ...@@ -442,15 +442,15 @@ export default Vue.extend({
this.$router.push("/Nft/create/pick"); this.$router.push("/Nft/create/pick");
}, },
async publishNft() { async publishNft() {
try { // try {
this.loading4 = true; this.loading4 = true;
const result = this.$service.nftService.publish({ const result = this.$service.nftService.publish({
fileHash: this.fileHash, fileHash: this.fileHash,
id: this.publish.id, id: this.publish.id,
wallet: this.publish.wallet, wallet: this.publish.wallet,
nftId: this.publish.nftId, nftId: this.publish.nftId,
}); });
// const result = this.$service.nftService.publish();
result result
.then((ret: any) => { .then((ret: any) => {
this.success = ret === true; this.success = ret === true;
...@@ -463,20 +463,22 @@ export default Vue.extend({ ...@@ -463,20 +463,22 @@ export default Vue.extend({
this.success = false; this.success = false;
this.errorMsg = err; this.errorMsg = err;
}); });
} catch (err) { // } catch (err) {
console.log(err); // console.log(err);
} // }
}, },
async uploadFileToOss(file: File): Promise<string> { async uploadFileToOss(file: File): Promise<string> {
const ossRet = (await this.$service.nftService.ossPolicy()) as any; const ossRet = (await this.$service.nftService.ossPolicy()) as any;
await this.$service.nftService.uploadFileToOss(file, ossRet); await this.$service.nftService.uploadFileToOss(file, ossRet);
const { dir, host } = ossRet; const { dir, host } = ossRet;
return `${host}/${dir}${file.name}`; return `${host}/${dir}${file.name}`;
}, },
async encryptAndPushToChain() { async encryptAndPushToChain() {
this.loading2 = true; this.loading2 = true;
let mistake = false; // let mistake = false;
try { // try {
let data = { let data = {
author: this.createNFT.value_publisher, author: this.createNFT.value_publisher,
categoryId: parseInt(this.categoryId) , categoryId: parseInt(this.categoryId) ,
...@@ -492,6 +494,7 @@ export default Vue.extend({ ...@@ -492,6 +494,7 @@ export default Vue.extend({
isArchives: this.createNFT.archives, isArchives: this.createNFT.archives,
}; };
} else if (this.createNFT.archives === 1) { } else if (this.createNFT.archives === 1) {
//需要加密存档
const fileUrl = await this.uploadFileToOss(this.file); const fileUrl = await this.uploadFileToOss(this.file);
data = { data = {
...data, ...data,
...@@ -502,37 +505,54 @@ export default Vue.extend({ ...@@ -502,37 +505,54 @@ export default Vue.extend({
isGrant: this.createNFT.grant, isGrant: this.createNFT.grant,
}; };
} }
if(this.coverFile){
const coverImgUrl = await this.$service.nftService.fileUpload(this.coverFile)
data = {
...data,
cover: coverImgUrl
}
}
const { id, nftId, wallet, fileHash } = const { id, nftId, wallet, fileHash } =
await this.$service.nftService.save(data); await this.$service.nftService.save(data);
this.publish.fileHash = fileHash; this.publish.fileHash = fileHash;
this.publish.nftId = nftId; this.publish.nftId = nftId;
this.publish.id = id; this.publish.id = id;
this.publish.wallet = wallet; this.publish.wallet = wallet;
} catch (err) {
mistake = true;
} // } catch (err) {
// mistake = true;
// }
this.loading2 = false; this.loading2 = false;
if (mistake) return; // if (mistake) return ;
}, },
async currentStepChange(val: number) { async currentStepChange(val: number) {
if (this.currentStep === 2 && val === 1) { try{
await this.encryptAndPushToChain(); if (this.currentStep === 2 && val === 1) {
} else if (this.currentStep === 3 && val === 1) { await this.encryptAndPushToChain();
await this.publishNft(); } else if (this.currentStep === 3 && val === 1) {
await this.publishNft();
}
}catch(err){
this.loading2 = false
return
} }
if (this.currentStep < this.mySteps.length + 1) { if (this.currentStep < this.mySteps.length + 1) {
this.currentStep += val; this.currentStep += val;
} }
}, },
clickRepublish() { clickRepublish() {
this.currentStep = 1; this.currentStep = 1;
}, },
textareaChange(e:any){ // textareaChange(e:any){
if(e.target.value.length >= 500) { // if(e.target.value.length >= 500) {
this.createNFT.value_des = e.target.value.slice(0,500) // this.createNFT.value_des = e.target.value.slice(0,500)
} // }
} // }
}, },
}); });
</script> </script>
......
This diff is collapsed.
...@@ -161,10 +161,10 @@ ...@@ -161,10 +161,10 @@
import Vue from "vue"; import Vue from "vue";
import SkeletonNftDetail from "@/components/common/Skeleton/SkeletonNftDetail.vue" import SkeletonNftDetail from "@/components/common/Skeleton/SkeletonNftDetail.vue"
import { token } from '@/util/userInfoUtils' import { token } from '@/util/userInfoUtils'
import anquanzhongxin89 from "@/assets/img/img-anquanzhongxin89.png" import anquanzhongxin89 from "@/assets/img/check.png"
import chakan from "@/assets/img/img-chakan.png" import chakan from "@/assets/img/upload.png"
import atupian from "@/assets/img/img-a-tupian.png" import atupian from "@/assets/img/transfer.png"
import BOSSyingyetingchushi from "@/assets/img/img-BOSS-yingyeting-chushi.png" import BOSSyingyetingchushi from "@/assets/img/certigicate.png"
const apps = [ const apps = [
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment