提交 2ec5186a authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 629aa582
......@@ -5,8 +5,9 @@ import md5 from 'blueimp-md5'
import { useUserStore } from '@/stores/user'
import { uploadFileByUrl } from '@/utils/upload'
const props = defineProps({ kindId: { type: Number, default: 447 } })
const model = defineModel()
const emit = defineEmits(['close'])
const emit = defineEmits(['close', 'save'])
const userStore = useUserStore()
......@@ -15,7 +16,7 @@ const userStore = useUserStore()
* @param obj 参数对象,对象中的所有属性全部参与签名的生成
* @returns {string} 签名
*/
const buildSign = obj => {
const buildSign = (obj) => {
const signParameterArray = []
for (const key in obj) {
signParameterArray.push(`${key}=${obj[key]}`)
......@@ -38,13 +39,14 @@ const buildVersion2Sign = (appId, expireTime, userFlag, appSecret) => {
app_id: appId,
expire_time: expireTime,
user_flag: userFlag,
app_secret: appSecret
app_secret: appSecret,
}
return buildSign(signParameterObj)
}
window.chuangkitComplete = async result => {
window.chuangkitComplete = async (result) => {
console.log(result)
if (!result.cktMessage) {
return
}
......@@ -53,6 +55,7 @@ window.chuangkitComplete = async result => {
const uploadedURL = await uploadFileByUrl(url)
model.value = uploadedURL
}
emit('save', model.value)
}
if ([1, 2, 3].includes(result.kind)) {
emit('close')
......@@ -63,7 +66,7 @@ let cktInstance
function openDesignPage() {
const appId = '54d9adec77d0402794018d166110f3dd'
const appSecret = '08097010E0EF4B85EE2B8CE438328249'
const userFlag = userStore.user.id
const userFlag = userStore.user.id + props.kindId.toString()
const expireTime = Date.now()
const sign = buildVersion2Sign(appId, expireTime, userFlag, appSecret)
const params = {
......@@ -71,13 +74,13 @@ function openDesignPage() {
expire_time: expireTime,
user_flag: userFlag,
device_type: 1,
kind_id: 447,
kind_id: props.kindId,
version: '2.0',
sign: sign,
enable_authorize: '1',
taxpayer_name: 'chuangkit',
taxpayer_phone: '13820659475',
taxpayer_number: '91120116636067462H'
taxpayer_number: '91120116636067462H',
}
cktInstance = new CktDesign(params)
......
......@@ -3,6 +3,7 @@ import { Plus, UploadFilled, Picture } from '@element-plus/icons-vue'
import { useFileDialog } from '@vueuse/core'
import { upload } from '@/utils/upload'
import dayjs from 'dayjs'
const ChuangKitDesign = defineAsyncComponent(() => import('@/components/ChuangKitDesign.vue'))
const props = defineProps({
modelValue: { type: [Array, String], default: () => [] },
......@@ -47,6 +48,19 @@ const handleOpen = (i = 0) => {
const getTitle = (i) => (i === 0 && props.firstTitle) || props.title
const getTips = (i) => (i === 0 && props.firstTips) || props.tips
const designVisible = ref(false)
const handleOpenDesign = (i = 0) => {
index.value = i
designVisible.value = true
}
const handleDesignSave = (url) => {
const nowTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
const result = { name: '未命名', size: '未知', type: 'image/png', url, upload_time: nowTime }
const updatedValue = [...props.modelValue]
updatedValue[index.value] = result
emit('update:modelValue', updatedValue)
}
</script>
<template>
<div class="upload-wrapper">
......@@ -57,7 +71,7 @@ const getTips = (i) => (i === 0 && props.firstTips) || props.tips
<li @click="handleOpen(i)">
<i class="el-icon"><UploadFilled /></i>本地上传
</li>
<li v-if="!isVideo">
<li @click="handleOpenDesign(i)" v-if="!isVideo">
<i class="el-icon"><Picture /></i>图库选择
</li>
</ul>
......@@ -110,6 +124,7 @@ const getTips = (i) => (i === 0 && props.firstTips) || props.tips
</template>
</el-popover>
</template>
<ChuangKitDesign :kindId="29" @save="handleDesignSave" @close="designVisible = false" v-if="designVisible"></ChuangKitDesign>
</div>
</template>
......
......@@ -3,7 +3,7 @@ import { getChuanKitDesignList } from '../api'
import { useUserStore } from '@/stores/user'
import { uploadFileByUrl } from '@/utils/upload'
const ChuangKitDesign = defineAsyncComponent(() => import('./ChuangKitDesign.vue'))
const ChuangKitDesign = defineAsyncComponent(() => import('@/components/ChuangKitDesign.vue'))
const userStore = useUserStore()
......@@ -12,7 +12,7 @@ const active = ref('')
const designVisible = ref(false)
const data = reactive({
list: [],
count: 0
count: 0,
})
async function fetchList() {
const res = await getChuanKitDesignList({ user_flag: userStore.user.id, page_no: 1, page_size: 1000, time_order: 1 })
......@@ -35,7 +35,11 @@ function onClose() {
<div class="image-design">
<el-button type="primary" @click="designVisible = true">打开编辑器</el-button>
<ul>
<li v-for="item in data.list" :key="item.designId" :class="{ active: item.designId === active }" @click="handleClick(item)">
<li
v-for="item in data.list"
:key="item.designId"
:class="{ active: item.designId === active }"
@click="handleClick(item)">
<img :src="item.thumbUrl" />
</li>
</ul>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论