picture_cube.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <div class="mobile-page">
  3. <div
  4. class="advert"
  5. :class="{ pageOn: bgStyle === 1 }"
  6. :style="{
  7. marginLeft: prConfig + 'px',
  8. marginRight: prConfig + 'px',
  9. marginTop: slider + 'px',
  10. background: bgColor,
  11. }"
  12. >
  13. <div class="advertItem01 acea-row" v-if="style === 0" v-for="(item, index) in picList" :key="index">
  14. <img :src="item.image" v-if="item.image" />
  15. <div class="empty-box" v-else>
  16. <span class="iconfont-diy icontupian"></span>
  17. </div>
  18. </div>
  19. <div class="advertItem02 acea-row" v-if="style === 1">
  20. <div class="item" v-for="(item, index) in picList" :key="index">
  21. <img :src="item.image" v-if="item.image" />
  22. <div class="empty-box" v-else>
  23. <span class="iconfont-diy icontupian"></span>
  24. </div>
  25. </div>
  26. </div>
  27. <div class="advertItem02 advertItem03 acea-row" v-if="style === 2">
  28. <div class="item" v-for="(item, index) in picList" :key="index">
  29. <img :src="item.image" v-if="item.image" />
  30. <div class="empty-box" v-else>
  31. <span class="iconfont-diy icontupian"></span>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="advertItem04 acea-row" v-if="style === 3">
  36. <div class="item">
  37. <img :src="picList[0].image" v-if="picList[0].image" />
  38. <div class="empty-box" v-else>
  39. <span class="iconfont-diy icontupian"></span>
  40. </div>
  41. </div>
  42. <div class="item">
  43. <div class="pic">
  44. <img :src="picList[1].image" v-if="picList[1].image" />
  45. <div class="empty-box" v-else>
  46. <span class="iconfont-diy icontupian"></span>
  47. </div>
  48. </div>
  49. <div class="pic">
  50. <img :src="picList[2].image" v-if="picList[2].image" />
  51. <div class="empty-box" v-else>
  52. <span class="iconfont-diy icontupian"></span>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="advertItem02 advertItem05 acea-row" v-if="style === 4">
  58. <div class="item" v-for="(item, index) in picList" :key="index">
  59. <img :src="item.image" v-if="item.image" />
  60. <div class="empty-box" v-else>
  61. <span class="iconfont-diy icontupian"></span>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="advertItem06 acea-row" v-if="style === 5">
  66. <div class="item" v-for="(item, index) in picList" :key="index">
  67. <img :src="item.image" v-if="item.image" />
  68. <div class="empty-box" v-else>
  69. <span class="iconfont-diy icontupian"></span>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { mapState } from 'vuex';
  78. export default {
  79. name: 'picture_cube',
  80. cname: '图片魔方',
  81. configName: 'c_picture_cube',
  82. icon: 'iconshangpinfenlei1',
  83. type: 0, // 0 基础组件 1 营销组件 2工具组件
  84. defaultName: 'pictureCube', // 外面匹配名称
  85. props: {
  86. index: {
  87. type: null,
  88. },
  89. num: {
  90. type: null,
  91. },
  92. },
  93. computed: {
  94. ...mapState('mobildConfig', ['defaultArray']),
  95. },
  96. watch: {
  97. pageData: {
  98. handler(nVal, oVal) {
  99. this.setConfig(nVal);
  100. },
  101. deep: true,
  102. },
  103. num: {
  104. handler(nVal, oVal) {
  105. let data = this.$store.state.mobildConfig.defaultArray[nVal];
  106. this.setConfig(data);
  107. },
  108. deep: true,
  109. },
  110. defaultArray: {
  111. handler(nVal, oVal) {
  112. let data = this.$store.state.mobildConfig.defaultArray[this.num];
  113. this.setConfig(data);
  114. },
  115. deep: true,
  116. },
  117. },
  118. data() {
  119. return {
  120. // 默认初始化数据禁止修改
  121. defaultConfig: {
  122. name: 'pictureCube',
  123. timestamp: this.num,
  124. tabConfig: {
  125. title: '选择样式',
  126. tabVal: 0,
  127. type: 1,
  128. tabList: [
  129. {
  130. name: '样式一',
  131. icon: 'iconyangshi1',
  132. count: 1,
  133. },
  134. {
  135. name: '样式二',
  136. icon: 'iconyangshi2',
  137. count: 2,
  138. },
  139. {
  140. name: '样式三',
  141. icon: 'iconyangshi3',
  142. count: 3,
  143. },
  144. {
  145. name: '样式四',
  146. icon: 'iconyangshi9',
  147. count: 3,
  148. },
  149. {
  150. name: '样式五',
  151. icon: 'iconyangshi8',
  152. count: 4,
  153. },
  154. {
  155. name: '样式六',
  156. icon: 'iconyangshi4',
  157. count: 4,
  158. },
  159. ],
  160. },
  161. picStyle: {
  162. tabVal: 0,
  163. picList: [],
  164. },
  165. menuConfig: {
  166. title: '',
  167. maxList: 1,
  168. isCube: 1,
  169. list: [
  170. {
  171. img: '',
  172. info: [
  173. {
  174. title: '链接',
  175. tips: '请输入链接',
  176. value: '',
  177. max: 100,
  178. },
  179. ],
  180. },
  181. ],
  182. },
  183. bgColor: {
  184. title: '背景颜色',
  185. default: [
  186. {
  187. item: '#fff',
  188. },
  189. ],
  190. color: [
  191. {
  192. item: '#fff',
  193. },
  194. ],
  195. },
  196. bgStyle: {
  197. title: '背景样式',
  198. name: 'bgStyle',
  199. type: 0,
  200. list: [
  201. {
  202. val: '直角',
  203. icon: 'iconPic_square',
  204. },
  205. {
  206. val: '圆角',
  207. icon: 'iconPic_fillet',
  208. },
  209. ],
  210. },
  211. prConfig: {
  212. title: '背景边距',
  213. val: 0,
  214. min: 0,
  215. },
  216. // 页面间距
  217. mbConfig: {
  218. title: '页面间距',
  219. val: 0,
  220. min: 0,
  221. },
  222. },
  223. pageData: {},
  224. style: 0,
  225. picList: [],
  226. bgColor: [],
  227. slider: 0,
  228. bgStyle: 0,
  229. prConfig: 0,
  230. };
  231. },
  232. mounted() {
  233. this.$nextTick(() => {
  234. this.pageData = this.$store.state.mobildConfig.defaultArray[this.num];
  235. this.setConfig(this.pageData);
  236. });
  237. },
  238. methods: {
  239. setConfig(data) {
  240. if (!data) return;
  241. if (data.tabConfig) {
  242. this.style = data.tabConfig.tabVal;
  243. this.bgStyle = data.bgStyle.type;
  244. this.prConfig = data.prConfig.val;
  245. this.slider = data.mbConfig.val;
  246. this.bgColor = data.bgColor.color[0].item;
  247. if (!data.picStyle.picList.length) {
  248. this.picList = [
  249. {
  250. image: '',
  251. link: '',
  252. },
  253. ];
  254. } else {
  255. this.picList = data.picStyle.picList;
  256. }
  257. }
  258. },
  259. },
  260. };
  261. </script>
  262. <style scoped lang="stylus">
  263. .pageOn{
  264. border-radius 12px!important
  265. .advertItem01{
  266. img{
  267. border-radius 10px
  268. }
  269. }
  270. .advertItem02{
  271. .item{
  272. &:nth-child(1){
  273. img{
  274. border-radius 10px 0 0 10px
  275. }
  276. }
  277. &:nth-child(2){
  278. img{
  279. border-radius 0 10px 10px 0
  280. }
  281. }
  282. }
  283. }
  284. .advertItem03{
  285. .item{
  286. &:nth-child(1){
  287. img{
  288. border-radius 10px 0 0 10px
  289. }
  290. }
  291. &:nth-child(2){
  292. img{
  293. border-radius 0
  294. }
  295. }
  296. &:nth-child(3){
  297. img{
  298. border-radius 0 10px 10px 0
  299. }
  300. }
  301. }
  302. }
  303. .advertItem04{
  304. .item{
  305. &:nth-child(1){
  306. img{
  307. border-radius 10px 0 0 10px
  308. }
  309. }
  310. &:nth-child(2){
  311. .pic{
  312. &:nth-child(1){
  313. img{
  314. border-radius 0 10px 0 0
  315. }
  316. }
  317. &:nth-child(2){
  318. img{
  319. border-radius 0 0 10px 0
  320. }
  321. }
  322. }
  323. }
  324. }
  325. }
  326. .advertItem05{
  327. .item{
  328. &:nth-child(1){
  329. img{
  330. border-radius 10px 0 0 10px
  331. }
  332. }
  333. &:nth-child(2){
  334. img{
  335. border-radius 0
  336. }
  337. }
  338. &:nth-child(4){
  339. img{
  340. border-radius 0 10px 10px 0
  341. }
  342. }
  343. }
  344. }
  345. .advertItem06{
  346. .item{
  347. &:nth-child(1){
  348. img{
  349. border-radius 10px 0 0 0
  350. }
  351. }
  352. &:nth-child(2){
  353. img{
  354. border-radius 0 10px 0 0
  355. }
  356. }
  357. &:nth-child(3){
  358. img{
  359. border-radius 0 0 0 10px
  360. }
  361. }
  362. &:nth-child(4){
  363. img{
  364. border-radius 0 0 10px 0
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .mobile-page{
  371. .advert{
  372. .advertItem01{
  373. width 100%;
  374. height 100%;
  375. .empty-box{
  376. width 100%;
  377. height 379px;
  378. border-radius 0;
  379. .icontupian{
  380. font-size 50px;
  381. color #999;
  382. }
  383. }
  384. img{
  385. width 100%;
  386. height 100%
  387. }
  388. }
  389. .advertItem02{
  390. width 100%
  391. .item{
  392. width 50%;
  393. height auto;
  394. img{
  395. width 100%;
  396. height 100%;
  397. }
  398. .empty-box{
  399. width 100%;
  400. height 189.5px;
  401. border-radius 0;
  402. }
  403. }
  404. }
  405. .advertItem03{
  406. .item{
  407. width 33.3333%;
  408. .empty-box{
  409. width 100%;
  410. height 126.4px;
  411. border-radius 0;
  412. }
  413. }
  414. }
  415. .advertItem04{
  416. .item{
  417. width 50%;
  418. height 189.5px;
  419. .empty-box{
  420. width 100%;
  421. height 100%;
  422. border-radius 0;
  423. }
  424. img{
  425. width 100%;
  426. height 100%;
  427. }
  428. .pic{
  429. width 100%;
  430. height 94.75px;
  431. }
  432. }
  433. }
  434. .advertItem05{
  435. .item{
  436. width 25%;
  437. .empty-box{
  438. width 100%;
  439. height 94.75px;
  440. border-radius 0;
  441. }
  442. }
  443. }
  444. .advertItem06{
  445. .item{
  446. width 50%;
  447. height 95px;
  448. img{
  449. width 100%;
  450. height 100%;
  451. }
  452. .empty-box{
  453. width 100%;
  454. height 100%;
  455. border-radius 0;
  456. }
  457. }
  458. }
  459. }
  460. }
  461. </style>