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

chore: update

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