Commit 5b9697b5 authored by hanfeng zhang's avatar hanfeng zhang

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

parents 342dceb0 1f0424b8
...@@ -96,7 +96,11 @@ ...@@ -96,7 +96,11 @@
> >
{{ name }} {{ name }}
</div> </div>
<div :data-clipboard-text="name" ref="btn" @click="handleClickCopy" 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>
</div> </div>
...@@ -208,10 +212,23 @@ export default Vue.extend({ ...@@ -208,10 +212,23 @@ export default Vue.extend({
cellOnChange() { cellOnChange() {
this.$emit("cellOnChange", this.inputValue); this.$emit("cellOnChange", this.inputValue);
}, },
handleClickCopy() { handleClickCopy(text: string | number) {
const btn = this.$refs.btn as HTMLElement; this.$util.cliboard(text);
new Clipboard(btn);
this.$toast("复制成功"); this.$toast("复制成功");
// const btn = this.$refs.btn as HTMLElement;
// const clipboard = new Clipboard(btn);
// clipboard.on("success", function (e) {
// console.info("Action:", e.action);
// console.info("Text:", e.text);
// console.info("Trigger:", e.trigger);
// e.clearSelection();
// });
// clipboard.on("error", function (e) {
// console.error("Action:", e.action);
// console.error("Trigger:", e.trigger);
// });
// this.$toast("复制成功");
}, },
onCancel() {}, onCancel() {},
onSelect(value: any) { onSelect(value: any) {
......
...@@ -255,7 +255,6 @@ export class NFTService extends Service { ...@@ -255,7 +255,6 @@ export class NFTService extends Service {
Object.keys(data).forEach((keyName) => { Object.keys(data).forEach((keyName) => {
const value = data[keyName as keyof iSaveData] const value = data[keyName as keyof iSaveData]
value? fd.append(keyName, typeof value === 'number' ? String(value) : value):'' value? fd.append(keyName, typeof value === 'number' ? String(value) : value):''
}) })
return (await this.service.post(this.router.save.path, fd, { return (await this.service.post(this.router.save.path, fd, {
......
export interface iSaveData { export interface iSaveData {
author: string id?: number
categoryId: number nftId?: string,
fileHash: string author?: string
isArchives: number categoryId?: number
name: string fileHash?: string
synopsis: string isArchives?: number
theme: string name?: string
isGrant: number synopsis?: string
theme?: string
isGrant?: number
fileUrl?: string fileUrl?: string
fileName?:string fileName?: string
} }
import ClipboardJS from 'clipboard'
export default function (text: string | number) {
const ele = document.createElement('div')
ele.setAttribute('data-clipboard-text', text.toString())
document.body.appendChild(ele)
const clipboard = new ClipboardJS(ele)
// document.body.removeChild(ele)
}
import {token,userMsg} from './userInfoUtils' import {token,userMsg} from './userInfoUtils'
import validator from 'validator' import validator from 'validator'
import cliboard from "./cliboard"
export default { export default {
install(Vue: any) { install(Vue: any) {
...@@ -8,6 +9,7 @@ export default { ...@@ -8,6 +9,7 @@ export default {
token: token, token: token,
userMsg: userMsg, userMsg: userMsg,
validator:validator, validator:validator,
cliboard,
} }
} }
} }
......
import {token,userMsg} from './userInfoUtils' import {token,userMsg} from './userInfoUtils'
import validator from 'validator' import validator from 'validator'
import cliboard from './cliboard'
export interface UTIL_INTERFACE{ export interface UTIL_INTERFACE{
token: typeof token, token: typeof token,
userMsg: typeof userMsg userMsg: typeof userMsg
validator: typeof validator validator: typeof validator
cliboard: typeof cliboard
} }
\ No newline at end of file
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<Layout-Child class="page-scroll"> <Layout-Child class="page-scroll">
<div class="w-7/12 mx-auto my-6"> <div class="w-7/12 mx-auto my-6">
<app-steps <app-steps
v-if="currentStep !== 4"
:data="mySteps" :data="mySteps"
:currentStep="currentStep" :currentStep="currentStep"
@stepOnChange="stepOnChange" @stepOnChange="stepOnChange"
...@@ -171,12 +172,45 @@ ...@@ -171,12 +172,45 @@
></app-btn> ></app-btn>
</div> </div>
</div> </div>
<div v-if="currentStep == 4" class="text-font-white">
<div
v-if="loading4"
class="flex flex-col items-center w-full pt-16 justify-center"
>
<breeding-rhombus-spinner
:animation-duration="2000"
:size="60"
:color="'#0078FF'"
/>
<div class="mt-6 text-font-white">loading...</div>
</div>
<div v-else class="text-center">
<div v-if="success">
<div>恭喜您获得NFT证书</div>
<img src="@/assets/img/starBg.png" class="w-full" alt="" />
<div>保存下载</div>
<img src="@/assets/icons/close_publish.png" class=" w-5 mx-auto mt-10" alt="" />
</div>
<div
v-else
class="flex flex-col items-center w-full pt-16 justify-center"
>
<img src="@/assets/img/earth.png" class="w-8/12" alt="" />
<div class="mt-16">抱歉,NFT发布失败!</div>
<div>失败原因:{{ errorMsg }}</div>
<div class="republishBtn mt-6" @click="clickRepublish">
重新发行
</div>
</div>
</div>
</div>
</div> </div>
</Layout-Child> </Layout-Child>
</template> </template>
<script lang="ts"> <script lang="ts">
import { iSaveData } from "@/service/nftService/types"; import { iSaveData } from "@/service/nftService/types";
import { BreedingRhombusSpinner } from "epic-spinners";
import { Dialog } from "vant"; import { Dialog } from "vant";
import Vue from "vue"; import Vue from "vue";
import { mapMutations, mapState } from "vuex"; import { mapMutations, mapState } from "vuex";
...@@ -224,6 +258,9 @@ export default Vue.extend({ ...@@ -224,6 +258,9 @@ export default Vue.extend({
currentStep: 1, currentStep: 1,
loading2: false, loading2: false,
loading3: false, loading3: false,
loading4: false,
success: true,
errorMsg: "",
}; };
}, },
components: { components: {
...@@ -231,6 +268,7 @@ export default Vue.extend({ ...@@ -231,6 +268,7 @@ export default Vue.extend({
"app-steps": () => import("@/components/common/Steps.vue"), "app-steps": () => import("@/components/common/Steps.vue"),
"app-cell": () => import("@/components/common/Cell.vue"), "app-cell": () => import("@/components/common/Cell.vue"),
"app-btn": () => import("@/components/common/Btn.vue"), "app-btn": () => import("@/components/common/Btn.vue"),
BreedingRhombusSpinner,
}, },
async mounted() { async mounted() {
const list = await this.$service.nftService.getCategory(); const list = await this.$service.nftService.getCategory();
...@@ -315,26 +353,34 @@ export default Vue.extend({ ...@@ -315,26 +353,34 @@ export default Vue.extend({
}, },
async publishNft() { async publishNft() {
/* 加密上链的下一步点击回调 */
this.loading3 = true;
try { try {
await this.$service.nftService.publish({ this.loading4 = true;
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,
}); });
this.$router.back(); result
.then((ret: any) => {
this.success = ret === true;
this.loading4 = false;
ret !== true && (this.errorMsg = ret);
})
.catch((err) => {
this.loading4 = false;
this.success = false;
this.errorMsg = err;
});
} catch (err) { } catch (err) {
console.log(err); console.log(err);
} }
this.loading3 = false;
}, },
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;
...@@ -388,6 +434,19 @@ export default Vue.extend({ ...@@ -388,6 +434,19 @@ export default Vue.extend({
this.currentStep += val; this.currentStep += val;
} }
}, },
clickRepublish() {
this.currentStep = 1;
},
}, },
}); });
</script> </script>
<style scoped>
.republishBtn {
width: 100px;
height: 34px;
background: #0078ff;
box-shadow: 0px 1px 6px 0px #252836;
border-radius: 29px;
line-height: 34px;
}
</style>
\ No newline at end of file
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