123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877 |
- <template>
- <div
- class="scroll-container"
- ref="w-list-ref"
- @scroll.self="onWorkListScroll"
- >
- <div class="back-top" @click="onClickBackTop" v-show="isShowBackTopBtn">
- <i class="iconfont icon-top"></i>
- </div>
- <div class="mask" v-show="isShowMask"></div>
- <!-- 断网时,输入关键字触发网络请求后,骨架图的隐藏会触发v-infinite-scroll,原因未知。进而导致循环触发,因此list为空时要禁用v-infinite-scroll -->
- <ul
- class="w-list"
- v-if="!(list.length === 0 && !hasMoreData)"
- v-infinite-scroll="requestMoreData"
- :infinite-scroll-disabled="
- !hasMoreData || isRequestingMoreData || list.length === 0
- "
- >
- <!-- <li class="add-work" @click="add">
- <div class="wrapper">
- <div class="add-con">
- <div>
- <i class="iconfont icon-works_add"></i>
- </div>
- <span>{{ create }}</span>
- </div>
- </div>
- </li> -->
- <!-- 骨架图 -->
- <template v-if="isRequestingMoreData && list.length === 0">
- <li v-for="index in 19" :key="index">
- <div class="wrapper">
- <workCardSkeleton></workCardSkeleton>
- </div>
- </li>
- </template>
- <li
- v-for="(item, i) in list"
- :key="i"
- :class="{ 'has-more-data': hasMoreData }"
- >
- <div class="wrapper" :class="{ disabled: item.calcStatus === 0 }">
- <div class="li-hover">
- <span class="lipreview" @click="handlePreview(item)">{{
- preview
- }}</span>
- <ul class="oper">
- <li class="comfirmhover" @click="edit(item)">
- <i class="iconfont icon-works_editor"></i>{{ edittips }}
- </li>
- <li class="comfirmhover" @click="openShare(item)">
- <i class="iconfont icon-works_share"></i>{{ share }}
- </li>
- <li class="cancelhover" @click="del(item, i)">
- <i class="iconfont icon-works_delete"></i>{{ deltips }}
- </li>
- </ul>
- </div>
- <div class="img" @click="handlePreview(item)">
- <img class="real" :src="item.icon || $thumb" alt="" />
- <span class="snCode" v-if="item.snCode">
- SN: {{ item.snCode }}</span
- >
- <div class="calc-mask" v-if="item.calcStatus === 0">
- <span>{{ calcing }}</span>
- <svg
- xmlns="http://www.w3.org/2000/svg"
- width="1em"
- height="1em"
- viewBox="0 0 24 24"
- >
- <circle cx="4" cy="12" r="3" fill="currentColor">
- <animate
- id="svgSpinners3DotsFade0"
- fill="freeze"
- attributeName="opacity"
- begin="0;svgSpinners3DotsFade1.end-0.25s"
- dur="0.75s"
- values="1;0.2"
- />
- </circle>
- <circle cx="12" cy="12" r="3" fill="currentColor" opacity="0.4">
- <animate
- fill="freeze"
- attributeName="opacity"
- begin="svgSpinners3DotsFade0.begin+0.15s"
- dur="0.75s"
- values="1;0.2"
- />
- </circle>
- <circle cx="20" cy="12" r="3" fill="currentColor" opacity="0.3">
- <animate
- id="svgSpinners3DotsFade1"
- fill="freeze"
- attributeName="opacity"
- begin="svgSpinners3DotsFade0.begin+0.3s"
- dur="0.75s"
- values="1;0.2"
- />
- </circle>
- </svg>
- </div>
- </div>
- <div class="li-info">
- <div>
- <span class="shenglve tttttt" :title="item.name || no_title">{{
- item.name || no_title
- }}</span>
- </div>
- <div>
- <span>{{ item.createTime.split(" ")[0] }}</span>
- <div :title="item.visit">
- <i class="iconfont icon-works_look"></i
- >{{ item.visit > 10000 ? "1w+" : item.visit }}
- </div>
- </div>
- </div>
- </div>
- </li>
- <div
- class="work-list-loading-wrapper"
- v-show="isRequestingMoreData && list.length !== 0"
- >
- <img
- class="work-list-loading"
- :src="require('@/assets/images/icons/work-list-loading.gif')"
- />
- </div>
- </ul>
- <div
- class="nodata"
- v-if="list.length == 0 && !hasMoreData && lastestUsedSearchKey"
- >
- <img :src="$noresult" alt="" />
- <span>{{ no_search_result }}~</span>
- </div>
- <div
- class="nodata"
- v-if="list.length == 0 && !hasMoreData && !lastestUsedSearchKey"
- >
- <img :src="config.empty" alt="" />
- <span>{{ no_works }}</span>
- <!-- <button @click="add" class="upload-btn-in-table">{{ create }}</button> -->
- </div>
- <share
- :show="showShare"
- :item="shareItem"
- @close="showShare = false"
- ></share>
- <preview
- v-if="showItem"
- :name="showItem.name"
- :show="showPreview"
- :ifr="`./show.html?id=${showItem.id}&lang=${$lang}`"
- :dark="false"
- @close="showPreview = false"
- />
- <div class="dialog" style="z-index: 1000" v-if="isShowMaterialSelector">
- <MaterialSelector
- :isDarkTheme="false"
- :title="select_material"
- :selectableType="['pano', '3D']"
- :isMultiSelection="true"
- initialMaterialType="pano"
- @cancel="isShowMaterialSelector = false"
- @submit="handleSubmitFromMaterialSelector"
- />
- </div>
- </div>
- </template>
- <script>
- import share from "../popup/share";
- import preview from "@/components/preview";
- import workCardSkeleton from "@/components/workCardSkeleton.vue";
- import config from "@/config";
- import { debounce } from "@/utils/other.js";
- import MaterialSelector from "@/components/materialSelector.vue";
- import { mapGetters } from "vuex";
- import { i18n } from "@/lang";
- import { $waiting } from "@/components/shared/loading";
- import {
- addWorks,
- getCamWorksList,
- delWorks,
- getPanoInfo,
- saveWorks,
- } from "@/api";
- export default {
- components: {
- share,
- preview,
- workCardSkeleton,
- MaterialSelector,
- },
- computed: {
- ...mapGetters(["info"]),
- },
- props: {
- searchKey: String,
- },
- data() {
- return {
- myWorks: i18n.t("material.works.my"),
- create: i18n.t("material.works.create"),
- search: i18n.t("material.works.search"),
- preview: i18n.t("material.works.preview"),
- edittips: i18n.t("material.works.edit"),
- share: i18n.t("material.works.share"),
- deltips: i18n.t("material.works.delete"),
- no_works: i18n.t("material.works.no_works_cam"),
- no_title: i18n.t("gather.no_title"),
- no_search_result: i18n.t("gather.no_search_result"),
- select_material: i18n.t("gather.select_material"),
- calcing: i18n.t("material.works.calcing"),
- config,
- list: [],
- workTotalNum: undefined,
- hasMoreData: true,
- isRequestingMoreData: false,
- lastestUsedSearchKey: "",
- isFilterFocus: false,
- showShare: false,
- showPreview: false,
- showItem: "",
- shareItem: "",
- isBackingTop: false,
- isShowBackTopBtn: false,
- isShowMask: false,
- isShowMaterialSelector: false,
- newWorkId: "",
- };
- },
- mounted() {
- this.requestMoreData();
- },
- watch: {
- searchKey: {
- handler: function (val) {
- if (val.length > 0) {
- this.selectedList = [];
- }
- this.refreshListDebounced();
- },
- immediate: false,
- },
- workTotalNum: {
- handler: function (val) {
- if (val) {
- this.$emit("updateNum", val);
- }
- },
- immediate: true,
- },
- },
- methods: {
- onFilterFocus() {
- this.isFilterFocus = true;
- },
- onFilterBlur() {
- this.isFilterFocus = false;
- },
- refreshListDebounced: debounce(
- function () {
- this.list = [];
- this.isRequestingMoreData = false;
- this.hasMoreData = true;
- this.requestMoreData();
- },
- 500,
- false
- ),
- openShare(data) {
- console.log(data);
- getPanoInfo(data.id, (data) => {
- if (data.scenes.length <= 0) {
- return this.$msg.warning(this.$i18n.t("material.works.no_link"));
- }
- this.showShare = true;
- this.shareItem = data;
- });
- },
- handlePreview(item) {
- getPanoInfo(item.id, (data) => {
- if (data.scenes.length <= 0) {
- return this.$msg.warning(this.$i18n.t("material.works.no_link"));
- }
- this.showItem = {
- ...item,
- ...data,
- };
- this.showPreview = true;
- });
- },
- add() {
- // 新建作品,弹窗让用户给作品选择素材。
- $waiting.show();
- addWorks({}, (res) => {
- $waiting.hide();
- this.newWorkId = res.data.id;
- this.isShowMaterialSelector = true;
- });
- },
- handleSubmitFromMaterialSelector(selected) {
- $waiting.show();
- // 拿新作品的初始数据
- getPanoInfo(
- this.newWorkId,
- // 拿到了。
- (data) => {
- // 往里边添加用户选中的素材。
- this.$store.commit("SetInfo", data);
- console.log("selected", selected);
- for (const [key, item] of Object.entries(selected)) {
- if (item.materialType === "pano") {
- let newScene = {
- icon: item.icon,
- sceneCode: item.sceneCode,
- sceneTitle: item.name,
- category: this.info.catalogs[0].id,
- type: "pano",
- id: "s_" + this.$randomWord(true, 8, 8),
- };
- console.log("key", key);
- if (Number(key) === 0) {
- //新建时开天空mask
- newScene = Object.assign(newScene, this.info.scenes[0]);
- newScene.customMask.sky.isShow = true;
- this.info.scenes[0] = newScene;
- } else {
- newScene = Object.assign(newScene, {
- customMask: this.info.scenes[0].customMask,
- initVisual: this.info.scenes[0].initVisual,
- });
- newScene.customMask.sky.isShow = true;
- this.info.scenes.push(newScene);
- }
- } else if (item.materialType === "3D") {
- let newScene = {
- icon: item.thumb,
- sceneCode: item.num,
- sceneTitle: item.sceneName,
- category: this.info.catalogs[0].id,
- type: "4dkk",
- id: "s_" + this.$randomWord(true, 8, 8),
- };
- if (Number(key) === 0) {
- this.info.scenes[0] = null;
- this.info.scenes[0] = newScene;
- } else {
- this.info.scenes.push(newScene);
- }
- }
- }
- // 保存新作品
- saveWorks(
- {
- id: this.newWorkId,
- password: "",
- someData: {
- ...this.info,
- status: 1,
- icon: this.info.scenes[0].icon,
- },
- },
- // 保存成功
- () => {
- $waiting.hide();
- // 隐藏素材选择弹窗
- this.isShowMaterialSelector = false;
- // 刷新作品列表
- this.list = [];
- this.isRequestingMoreData = false;
- this.hasMoreData = true;
- this.requestMoreData()
- .then(() => {
- // 刷新成功
- // 弹出提示窗口
- this.$confirm({
- title: this.$i18n.t("tips_code.tips"),
- content: this.$i18n.t("material.works.had_created"),
- okText: this.$i18n.t("material.works.goto_preview"),
- ok: () => {
- this.handlePreview(this.list[0]);
- this.newWorkId = "";
- this.$store.commit("SetInfo", {});
- },
- ok2Text: this.$i18n.t("material.works.continue_edit"),
- ok2: () => {
- window.open(
- `./edit.html?id=${this.newWorkId}&lang=${this.$lang}`
- );
- this.newWorkId = "";
- this.$store.commit("SetInfo", {});
- },
- });
- })
- .catch(() => {
- this.$msg.message(
- this.$i18n.t("material.works.had_created_but_no_link")
- );
- console.error("已成功新建作品,但刷新作品列表失败。");
- });
- },
- // 保存失败,删除新建的作品。
- (error) => {
- $waiting.hide();
- console.error("保存失败:", error);
- delWorks(this.newWorkId);
- this.newWorkId = "";
- this.$store.commit("SetInfo", {});
- }
- );
- },
- // 没拿到,删除新建的作品。
- (error) => {
- console.error("没拿到新建的作品数据:", error);
- delWorks(this.newWorkId);
- this.newWorkId = "";
- }
- );
- },
- edit(item) {
- const from = this.$route.name;
- window.open(`./edit.html?id=${item.id}&lang=${this.$lang}&from=cam`);
- },
- del(item, index) {
- this.$confirm({
- title: this.$i18n.t("material.works.delete_work"),
- content: this.$i18n.t("material.works.comfirm_delete"),
- ok: () => {
- $waiting.show();
- delWorks(item.id, () => {
- this.$msg.success(this.$i18n.t("gather.delete_success"));
- this.isRequestingMoreData = true;
- const lastestUsedSearchKey = this.searchKey;
- getCamWorksList(
- {
- pageNum: this.list.length,
- pageSize: 1,
- searchKey: this.searchKey,
- },
- (data) => {
- $waiting.hide();
- this.list.splice(index, 1);
- this.list = this.list.concat(data.data.list);
- if (this.list.length === data.data.total) {
- this.hasMoreData = false;
- }
- this.isRequestingMoreData = false;
- this.lastestUsedSearchKey = lastestUsedSearchKey;
- if (!lastestUsedSearchKey) {
- this.workTotalNum = data.data.total;
- }
- // TODO: 这是干啥呢?
- this.$nextTick(() => {
- this.$bus.emit("refreshTips");
- });
- },
- () => {
- $waiting.hide();
- this.lastestUsedSearchKey = lastestUsedSearchKey;
- this.isRequestingMoreData = false;
- }
- );
- });
- },
- });
- },
- requestMoreData() {
- this.isRequestingMoreData = true;
- const lastestUsedSearchKey = this.searchKey;
- return new Promise((resolve, reject) => {
- getCamWorksList(
- {
- pageNum: Math.floor(this.list.length / config.PAGE_SIZE) + 1,
- pageSize: config.PAGE_SIZE,
- searchKey: this.searchKey,
- },
- (data) => {
- this.list = this.list.concat(data.data.list);
- if (this.list.length === data.data.total) {
- this.hasMoreData = false;
- }
- this.isRequestingMoreData = false;
- this.lastestUsedSearchKey = lastestUsedSearchKey;
- if (!lastestUsedSearchKey) {
- this.workTotalNum = data.data.total;
- }
- // TODO: 这是干啥呢?
- this.$nextTick(() => {
- this.$bus.emit("refreshTips");
- });
- resolve();
- },
- () => {
- this.isRequestingMoreData = false;
- this.lastestUsedSearchKey = lastestUsedSearchKey;
- reject();
- }
- );
- });
- },
- onClickBackTop() {
- if (this.isBackingTop) {
- return;
- }
- this.isBackingTop = true;
- const startTime = Date.now();
- const totalScroll = this.$refs["w-list-ref"].scrollTop;
- const fn = () => {
- if (this.$refs["w-list-ref"].scrollTop === 0) {
- this.isBackingTop = false;
- return;
- }
- const nowTime = Date.now();
- const assumeScrollTop =
- totalScroll - ((nowTime - startTime) * totalScroll) / 500;
- this.$refs["w-list-ref"].scrollTop =
- assumeScrollTop > 0 ? assumeScrollTop : 0;
- requestAnimationFrame(fn);
- };
- requestAnimationFrame(fn);
- },
- onWorkListScroll(e) {
- if (e.target.scrollTop >= 30) {
- !this.isShowMask && (this.isShowMask = true);
- } else {
- this.isShowMask && (this.isShowMask = false);
- }
- if (e.target.scrollTop >= 600) {
- this.isShowBackTopBtn = true;
- } else {
- this.isShowBackTopBtn = false;
- }
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .scroll-container {
- flex: 1 1 auto;
- overflow: auto;
- margin-left: calc((100vw - 100%) / -2);
- padding-left: calc((100vw - 100%) / 2);
- margin-right: calc((100vw - 100%) / -2);
- padding-right: calc((100vw - 100%) / 2);
- &::-webkit-scrollbar {
- width: 0;
- height: 0;
- }
- .back-top {
- position: absolute;
- right: -80px;
- bottom: 30px;
- width: 60px;
- height: 60px;
- border-radius: 8px;
- background-color: #fff;
- z-index: 1;
- color: #c8c9cc;
- &:hover {
- color: #323233;
- }
- cursor: pointer;
- display: flex;
- justify-content: center;
- align-items: center;
- i {
- font-size: 20px;
- }
- }
- .mask {
- position: absolute;
- width: 100%;
- top: 180px;
- height: 30px;
- background: linear-gradient(rgb(239, 242, 244), rgba(255, 255, 255, 0));
- z-index: 1;
- pointer-events: none;
- }
- .w-list {
- margin-top: 22px;
- padding-top: 8px;
- width: 100%;
- @gap: 20px;
- display: flex;
- flex-wrap: wrap;
- align-content: flex-start;
- > li {
- width: calc((100% - @gap * 4) / 5);
- height: 322px;
- margin-bottom: @gap;
- margin-right: @gap;
- &:nth-of-type(5n) {
- margin-right: 0;
- }
- // 因为有个“创建作品”card占着空间,每次拿20个数据,每行五个,又不想每次拿到数据后最后一行只有一个card,所以把最后那个card隐藏掉。
- &:last-of-type.has-more-data {
- display: none;
- }
- .wrapper {
- height: 100%;
- background: #fff;
- position: relative;
- border-radius: 6px;
- overflow: hidden;
- .calc-mask {
- display: none;
- width: 100%;
- height: 100%;
- top: 0;
- position: absolute;
- left: 0;
- z-index: 10;
- pointer-events: none;
- justify-content: center;
- align-items: center;
- color: #fff;
- display: flex;
- flex-direction: column;
- font-size: 15px;
- svg {
- width: 28px;
- height: 28px;
- }
- }
- &.disabled {
- > * {
- pointer-events: none;
- }
- .calc-mask {
- background: rgba(0, 0, 0, 0.6);
- display: flex;
- }
- }
- .li-hover {
- display: none;
- width: 100%;
- height: 240px;
- position: absolute;
- top: 0;
- left: 0;
- z-index: 99;
- background: rgba(0, 0, 0, 0.6);
- .lipreview {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- color: #fff;
- display: inline-block;
- line-height: 40px;
- height: 40px;
- width: 100px;
- text-align: center;
- border-radius: 22px;
- cursor: pointer;
- background-color: transparent;
- border: 1px solid #fff;
- &:hover {
- border: none;
- background: #1983f6;
- }
- }
- .oper {
- display: flex;
- justify-content: space-around;
- align-items: center;
- position: absolute;
- bottom: 10px;
- left: 0;
- width: 100%;
- > li {
- color: #fff;
- font-size: 13px;
- display: flex;
- align-items: center;
- cursor: pointer;
- > i {
- font-size: 20px;
- margin-right: 4px;
- }
- }
- }
- }
- .img {
- width: 100%;
- height: 240px;
- position: relative;
- overflow: hidden;
- cursor: pointer;
- .snCode {
- position: absolute;
- z-index: 100;
- color: #fff;
- min-width: 116px;
- height: 36px;
- background: rgba(0, 0, 0, 0.6);
- border-radius: 0px 0px 0px 10px;
- top: 0;
- right: 0;
- font-size: 13px;
- text-align: center;
- line-height: 36px;
- white-space: nowrap;
- }
- .real {
- height: 100%;
- position: absolute;
- top: 0;
- left: 50%;
- transform: translateX(-50%);
- z-index: 0;
- transition: all ease 0.3s;
- }
- }
- .li-info {
- font-size: 14px;
- padding: 10px;
- > div {
- text-align: left;
- &:first-of-type {
- > span {
- font-weight: bold;
- margin-bottom: 10px;
- display: inline-block;
- text-overflow: ellipsis;
- overflow: hidden;
- white-space: nowrap;
- cursor: pointer;
- color: #323233;
- font-size: 16px;
- }
- }
- &:last-of-type {
- display: flex;
- justify-content: space-between;
- align-items: center;
- > span {
- font-size: 14px;
- color: #969799;
- }
- > div {
- color: #969799;
- i {
- margin-right: 6px;
- }
- }
- }
- }
- }
- }
- &:hover {
- .wrapper:not(.disabled) {
- box-shadow: 0px 2px 12px 0px rgba(50, 50, 51, 0.12);
- transform: translateY(-6px);
- .li-hover {
- display: block;
- }
- .img {
- .real {
- height: 108%;
- }
- }
- }
- }
- }
- .add-work {
- .wrapper {
- .add-con {
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- text-align: center;
- div {
- width: 60px;
- height: 60px;
- border-radius: 50%;
- background: linear-gradient(144deg, #00aefb 0%, #0076f6 100%);
- position: relative;
- cursor: pointer;
- margin: 0 auto;
- > i {
- font-size: 16px;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%, -50%);
- color: #fff;
- }
- }
- span {
- color: #333333;
- display: inline-block;
- margin-top: 8px;
- font-size: 14px;
- }
- }
- }
- }
- .work-list-loading-wrapper {
- width: 100%;
- margin-top: 20px;
- margin-bottom: 22px;
- .work-list-loading {
- display: block;
- margin: 0 auto;
- width: 50px;
- height: 8px;
- }
- }
- }
- }
- </style>
- <style lang="less" scoped>
- @import "../style.less";
- </style>
|