index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <div class="works con">
  3. <div class="tab">
  4. <div class="tab-l">
  5. <span @click="changeTab('list')" :class="{ active: isActive('list') }">
  6. 在线制作
  7. {{ work1TotalNum ? `(${work1TotalNum})` : "" }}
  8. </span>
  9. <span @click="changeTab('cam')" :class="{ active: isActive('cam') }">
  10. 相机生成
  11. {{ work2TotalNum ? `(${work2TotalNum})` : "" }}
  12. </span>
  13. </div>
  14. <div class="tab-r">
  15. <div class="filter">
  16. <div
  17. :class="{ active: isFilterFocus }"
  18. @focusin="onFilterFocus"
  19. @focusout="onFilterBlur"
  20. >
  21. <i class="iconfont iconworks_search search"></i>
  22. <input type="text" :placeholder="search" v-model="searchKey" />
  23. <i
  24. v-if="searchKey"
  25. @click="searchKey = ''"
  26. class="iconfont icon-toast_red del"
  27. ></i>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <template v-if="isActive('list')">
  33. <list @updateNum="handleWorkNum($event, 1)" :searchKey="searchKey"></list>
  34. </template>
  35. <template v-if="isActive('cam')">
  36. <CamList
  37. @updateNum="handleWorkNum($event, 2)"
  38. :searchKey="searchKey"
  39. ></CamList>
  40. </template>
  41. </div>
  42. </template>
  43. <script>
  44. import { mapGetters } from "vuex";
  45. import { i18n } from "@/lang";
  46. import List from "./list";
  47. import CamList from "./cam";
  48. import browser from "@/utils/browser";
  49. const allTabType = ["list", "cam"];
  50. export default {
  51. components: {
  52. List,
  53. CamList,
  54. },
  55. computed: {
  56. ...mapGetters(["info"]),
  57. isActive: function () {
  58. return (key) => {
  59. return this.currentTab === key;
  60. };
  61. },
  62. },
  63. data() {
  64. return {
  65. searchKey: "",
  66. work1TotalNum: "",
  67. work2TotalNum: "",
  68. isFilterFocus: false,
  69. search: i18n.t("material.works.search"),
  70. searchKey: "",
  71. currentTab: "list",
  72. };
  73. },
  74. mounted() {
  75. const from = browser.urlQueryValue("from");
  76. this.changeTab(from);
  77. },
  78. methods: {
  79. onFilterBlur() {},
  80. onFilterFocus() {},
  81. changeTab(type) {
  82. if (allTabType.includes(type)) {
  83. this.currentTab = type;
  84. }
  85. },
  86. handleWorkNum(val, type) {
  87. console.log("handleWorkNum", val, type);
  88. if (type === 1) {
  89. this.work1TotalNum = val;
  90. }
  91. if (type === 2) {
  92. this.work2TotalNum = val;
  93. }
  94. },
  95. },
  96. };
  97. </script>
  98. <style lang="less" scoped>
  99. .works {
  100. width: 100%;
  101. flex-direction: column;
  102. position: relative;
  103. .back-top {
  104. position: absolute;
  105. right: -80px;
  106. bottom: 30px;
  107. width: 60px;
  108. height: 60px;
  109. border-radius: 8px;
  110. background-color: #fff;
  111. z-index: 1;
  112. color: #c8c9cc;
  113. &:hover {
  114. color: #323233;
  115. }
  116. cursor: pointer;
  117. display: flex;
  118. justify-content: center;
  119. align-items: center;
  120. i {
  121. font-size: 20px;
  122. }
  123. }
  124. .tab {
  125. flex: 0 0 auto;
  126. width: 100%;
  127. display: flex;
  128. background: #fff;
  129. justify-content: space-between;
  130. align-items: center;
  131. padding: 20px 30px;
  132. .tab-l {
  133. > span {
  134. font-size: 18px;
  135. font-weight: bold;
  136. margin-right: 30px;
  137. cursor: pointer;
  138. &:hover {
  139. color: #0076f6;
  140. }
  141. &.active {
  142. color: #0076f6;
  143. }
  144. }
  145. }
  146. .tab-r {
  147. align-items: center;
  148. display: flex;
  149. .ui-button {
  150. margin-right: 20px;
  151. }
  152. }
  153. }
  154. .mask {
  155. position: absolute;
  156. width: 100%;
  157. top: 200px;
  158. height: 30px;
  159. background: linear-gradient(rgb(239, 242, 244), rgba(255, 255, 255, 0));
  160. z-index: 1;
  161. pointer-events: none;
  162. }
  163. .w-list {
  164. flex: 1 1 auto;
  165. overflow: auto;
  166. margin-top: 22px;
  167. padding-top: 8px;
  168. @gap: 20px;
  169. display: flex;
  170. flex-wrap: wrap;
  171. align-content: flex-start;
  172. // 让宽度和视口等宽,为了保证鼠标列表显示区域以外时列表也能响应滚轮事件。
  173. margin-left: calc((100vw - 100%) / -2);
  174. padding-left: calc((100vw - 100%) / 2);
  175. margin-right: calc((100vw - 100%) / -2);
  176. padding-right: calc((100vw - 100%) / 2);
  177. &::-webkit-scrollbar {
  178. width: 0;
  179. height: 0;
  180. }
  181. > li {
  182. width: calc((100% - @gap * 4) / 5);
  183. height: 322px;
  184. margin-bottom: @gap;
  185. margin-right: @gap;
  186. &:nth-of-type(5n) {
  187. margin-right: 0;
  188. }
  189. // 因为有个“创建作品”card占着空间,每次拿20个数据,每行五个,又不想每次拿到数据后最后一行只有一个card,所以把最后那个card隐藏掉。
  190. &:last-of-type.has-more-data {
  191. display: none;
  192. }
  193. .wrapper {
  194. height: 100%;
  195. background: #fff;
  196. position: relative;
  197. border-radius: 6px;
  198. overflow: hidden;
  199. .li-hover {
  200. display: none;
  201. width: 100%;
  202. height: 240px;
  203. position: absolute;
  204. top: 0;
  205. left: 0;
  206. z-index: 99;
  207. background: rgba(0, 0, 0, 0.6);
  208. .lipreview {
  209. position: absolute;
  210. top: 50%;
  211. left: 50%;
  212. transform: translate(-50%, -50%);
  213. color: #fff;
  214. display: inline-block;
  215. line-height: 40px;
  216. height: 40px;
  217. width: 100px;
  218. text-align: center;
  219. border-radius: 22px;
  220. cursor: pointer;
  221. background-color: transparent;
  222. border: 1px solid #fff;
  223. &:hover {
  224. border: none;
  225. background: #1983f6;
  226. }
  227. }
  228. .oper {
  229. display: flex;
  230. justify-content: space-around;
  231. align-items: center;
  232. position: absolute;
  233. bottom: 10px;
  234. left: 0;
  235. width: 100%;
  236. > li {
  237. color: #fff;
  238. font-size: 13px;
  239. display: flex;
  240. align-items: center;
  241. cursor: pointer;
  242. > i {
  243. font-size: 20px;
  244. margin-right: 4px;
  245. }
  246. }
  247. }
  248. }
  249. .img {
  250. width: 100%;
  251. height: 240px;
  252. position: relative;
  253. overflow: hidden;
  254. cursor: pointer;
  255. .real {
  256. height: 100%;
  257. position: absolute;
  258. top: 0;
  259. left: 50%;
  260. transform: translateX(-50%);
  261. z-index: 0;
  262. transition: all ease 0.3s;
  263. }
  264. }
  265. .li-info {
  266. font-size: 14px;
  267. padding: 10px;
  268. > div {
  269. text-align: left;
  270. &:first-of-type {
  271. > span {
  272. font-weight: bold;
  273. margin-bottom: 10px;
  274. display: inline-block;
  275. text-overflow: ellipsis;
  276. overflow: hidden;
  277. white-space: nowrap;
  278. cursor: pointer;
  279. color: #323233;
  280. font-size: 16px;
  281. }
  282. }
  283. &:last-of-type {
  284. display: flex;
  285. justify-content: space-between;
  286. align-items: center;
  287. > span {
  288. font-size: 14px;
  289. color: #969799;
  290. }
  291. > div {
  292. color: #969799;
  293. i {
  294. margin-right: 6px;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. }
  301. &:hover {
  302. .wrapper {
  303. box-shadow: 0px 2px 12px 0px rgba(50, 50, 51, 0.12);
  304. transform: translateY(-6px);
  305. .li-hover {
  306. display: block;
  307. }
  308. .img {
  309. .real {
  310. height: 108%;
  311. }
  312. }
  313. }
  314. }
  315. }
  316. .add-work {
  317. .wrapper {
  318. .add-con {
  319. position: absolute;
  320. top: 50%;
  321. left: 50%;
  322. transform: translate(-50%, -50%);
  323. text-align: center;
  324. div {
  325. width: 60px;
  326. height: 60px;
  327. border-radius: 50%;
  328. background: linear-gradient(144deg, #00aefb 0%, #0076f6 100%);
  329. position: relative;
  330. cursor: pointer;
  331. margin: 0 auto;
  332. > i {
  333. font-size: 16px;
  334. position: absolute;
  335. top: 50%;
  336. left: 50%;
  337. transform: translate(-50%, -50%);
  338. color: #fff;
  339. }
  340. }
  341. span {
  342. color: #333333;
  343. display: inline-block;
  344. margin-top: 8px;
  345. font-size: 14px;
  346. }
  347. }
  348. }
  349. }
  350. .work-list-loading-wrapper {
  351. width: 100%;
  352. margin-top: 20px;
  353. margin-bottom: 22px;
  354. .work-list-loading {
  355. display: block;
  356. margin: 0 auto;
  357. width: 50px;
  358. height: 8px;
  359. }
  360. }
  361. }
  362. }
  363. </style>
  364. <style lang="less" scoped>
  365. @import "../style.less";
  366. </style>