Commit dab3659b authored by salitedfish's avatar salitedfish

阶段性提交

parent 0da74866
......@@ -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 class="flex items-center">
<div class="text-sm">{{ value }}</div>
......@@ -34,11 +34,12 @@
<input
v-model="inputValue"
type="text"
class="bg-transparent"
class="bg-transparent text-sm"
:placeholder="placeholder"
@input="cellOnChange"
/>
</div>
<input v-else-if="type === 'input-num'"
:value="inputValue"
type="number"
......@@ -47,6 +48,7 @@
class="bg-transparent"
:placeholder="placeholder"
/>
<div v-else-if="type === 'pick'">
<div class="flex flex-row items-center">
<div @click="eventEmit(type)">
......@@ -73,6 +75,7 @@
</div>
</div>
</div>
<div v-else-if="type === 'upload'" class="overflow-hidden">
<div class="flex flex-row items-center overflow-hidden">
<div
......@@ -94,15 +97,17 @@
</div>
</div>
</div>
<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
v-if="name"
class="overflow-hidden overflow-ellipsis"
class="overflow-hidden text-xs"
id="copyNodeId"
>
{{ name }}
</div>
<div ref="btn" @click="handleClickCopy(name)" class="ml-1">
<app-icon name="icon-fuzhi" size="18px"></app-icon>
</div>
......
......@@ -28,6 +28,10 @@ export class NFTService extends Service {
path: '/oss/policy',
dataType: 'application/x-www-form-urlencoded',
},
fileUpload: {
path: '/oss/upload',
dataType: 'multipart/form-data'
},
getMd5: { path: '/nft/file/md5', dataType: 'multipart/form-data' },
save: { path: '/nft/save', dataType: 'multipart/form-data' },
publish: { path: '/nft/publish', dataType: 'application/json' },
......@@ -205,6 +209,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签名
*/
......
......@@ -11,4 +11,5 @@ export interface iSaveData {
isGrant?: number
fileUrl?: string
fileName?: string
cover?: string
}
......@@ -18,7 +18,7 @@
:text='fromText.nameText'
:validate="{ maxLen: 20 }"
:placeholder="fromText.namePlaceholder"
class="text-font-white my-3"
class="text-font-white my-3 text-sm"
@cellOnChange="(v) => setCreateNFT({ value_name: v })"
></app-cell>
<app-cell
......@@ -27,7 +27,7 @@
:text="fromText.authorText"
:validate="{ maxLen: 20 }"
:placeholder="fromText.authorPlaceholder"
class="text-font-white my-3"
class="text-font-white my-3 text-sm"
@cellOnChange="(v) => setCreateNFT({ value_publisher: v })"
></app-cell>
<app-cell
......@@ -73,7 +73,7 @@
<div class="step-two" v-if="currentStep == 2">
<app-cell
:text="fromText.fileUploadText"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
type="upload"
:placeholder="fromText.filePlaceholder"
:name="fileName"
......@@ -81,7 +81,7 @@
></app-cell>
<app-cell
text="封面上传(非必填)"
class="text-font-white my-3 "
class="text-font-white my-3 text-xs"
type="upload"
placeholder="请上传相关封面"
:name="coverName"
......@@ -89,7 +89,7 @@
></app-cell>
<app-cell
:text="fromText.fileHashText"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
type="showText"
:name="fileHash"
@cellOnChange="getValue"
......@@ -101,7 +101,7 @@
labelIcon="icon-wenhao"
@clickIcon="alertPlatformSave"
:list="archivesList"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
@cellOnChange="(v) => (createNFT.archives = v)"
></app-cell>
<app-cell
......@@ -112,7 +112,7 @@
labelIcon="icon-wenhao"
@clickIcon="alertAuthorizeRead"
:list="grantList"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
@cellOnChange="(v) => (createNFT.grant = v)"
></app-cell>
<div class="fixed bottom-0 w-full left-0 flex flex-row z-30">
......@@ -138,20 +138,20 @@
text="NFT编号"
type="showText"
:name="publish.nftId"
class="text-font-white my-3 break-all"
class="text-font-white my-3 text-xs"
></app-cell>
<app-cell
:text="fromText.fileHashText"
type="showText"
:name="publish.fileHash"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
@cellOnChange="getValue"
></app-cell>
<app-cell
text="发行人地址"
type="showText"
:name="publish.wallet"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
@cellOnChange="getValue"
></app-cell>
<app-cell
......@@ -160,7 +160,7 @@
:value="1"
:disabled="true"
type="input-num"
class="text-font-white my-3"
class="text-font-white my-3 text-xs"
@cellOnChange="
(v) => {
publish.count = v;
......@@ -344,7 +344,8 @@ export default Vue.extend({
fileName: "fileName",
file: "file",
pickedList: "pickedList",
coverName: 'coverName'
coverName: 'coverName',
coverFile: "coverFile"
}),
validation(): boolean {
let disabled = true;
......@@ -442,15 +443,15 @@ export default Vue.extend({
this.$router.push("/Nft/create/pick");
},
async publishNft() {
try {
// try {
this.loading4 = true;
const result = this.$service.nftService.publish({
fileHash: this.fileHash,
id: this.publish.id,
wallet: this.publish.wallet,
nftId: this.publish.nftId,
});
// const result = this.$service.nftService.publish();
result
.then((ret: any) => {
this.success = ret === true;
......@@ -463,20 +464,22 @@ export default Vue.extend({
this.success = false;
this.errorMsg = err;
});
} catch (err) {
console.log(err);
}
// } catch (err) {
// console.log(err);
// }
},
async uploadFileToOss(file: File): Promise<string> {
const ossRet = (await this.$service.nftService.ossPolicy()) as any;
await this.$service.nftService.uploadFileToOss(file, ossRet);
const { dir, host } = ossRet;
return `${host}/${dir}${file.name}`;
},
async encryptAndPushToChain() {
this.loading2 = true;
let mistake = false;
try {
// let mistake = false;
// try {
let data = {
author: this.createNFT.value_publisher,
categoryId: parseInt(this.categoryId) ,
......@@ -492,6 +495,7 @@ export default Vue.extend({
isArchives: this.createNFT.archives,
};
} else if (this.createNFT.archives === 1) {
//需要加密存档
const fileUrl = await this.uploadFileToOss(this.file);
data = {
...data,
......@@ -502,29 +506,46 @@ export default Vue.extend({
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 } =
await this.$service.nftService.save(data);
this.publish.fileHash = fileHash;
this.publish.nftId = nftId;
this.publish.id = id;
this.publish.wallet = wallet;
} catch (err) {
mistake = true;
}
// } catch (err) {
// mistake = true;
// }
this.loading2 = false;
if (mistake) return;
// if (mistake) return ;
},
async currentStepChange(val: number) {
if (this.currentStep === 2 && val === 1) {
await this.encryptAndPushToChain();
} else if (this.currentStep === 3 && val === 1) {
await this.publishNft();
try{
if (this.currentStep === 2 && val === 1) {
await this.encryptAndPushToChain();
} else if (this.currentStep === 3 && val === 1) {
await this.publishNft();
}
}catch(err){
this.loading2 = false
return
}
if (this.currentStep < this.mySteps.length + 1) {
this.currentStep += val;
}
},
clickRepublish() {
this.currentStep = 1;
},
......
This diff is collapsed.
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