h5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.1 KiB

<template>
<view class="upload">
<u-icon name="plus" size="24px" class="flex justify-center w-12 h-12 bg-blue-100 rounded-full shadow-md"
@click="handleUpload"></u-icon>
</view>
</template>
<script setup>
import {
computed,
ref
} from 'vue';
import {
useStore
} from 'vuex';
import Config from '@/common/js/config.js';
const emit = defineEmits(['success', 'error']);
const store = useStore();
const userId = computed(() => store.getters['user/userId']);
const list = ref([]);
getList();
// 导入wbs
const handleUpload = async cur => {
if (list.value.length === 1) {
store.commit('setDomain', list.value[0].url);
uni.showModal({
content: '是否上传到' + list.value[0].name,
showCancel: true,
success: async ({ confirm }) => {
if (confirm) {
try {
const res = await uni.$u.api.import();
console.log('2222', res)
// 导入WBS成功后
// 直接打开导入的项目
// emit('success');
// const { apiUrl } = Config;
// const defaultwbs = `${apiUrl}/defaultwbs`;
// res.url && (defaultwbs = res.url);
// setTimeout(() => {
// uni.navigateTo({ url: `/pages/project/project?u=${userId.value}&p=${res.id}&pname=${res.pname}&url=${res.url}` });
// }, 2000);
} catch (error) {
console.error('error: ', error);
emit('error', error);
}
}
},
});
} else {
uni.navigateTo({
url: '/pages/business/business'
})
}
};
async function getList() {
try {
const res = await uni.$u.api.getBusinessList();
list.value = res;
} catch (error) {
console.error('error: ', error);
}
}
</script>
<style lang="scss" scoped>
.upload {
position: absolute;
right: 10px;
bottom: 0;
transform: translate3d(0, 50%, 0);
color: $uni-color-primary !important;
}
</style>