advertising.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="model-view">
  3. <div class="model-view-content">
  4. <div class="content">
  5. <div class="wap-title">首页</div>
  6. <div class="draggable">
  7. <!-- 全屏 -->
  8. <div class="full-shadow" v-if="type == 'full'">
  9. <img :src="advertising[0].img" alt="" />
  10. </div>
  11. </div>
  12. </div>
  13. </div>
  14. <div class="model-config">
  15. <div class="decorate">
  16. <div class="decorate-title">全屏广告</div>
  17. <div class="decorate-list">
  18. <div
  19. class="decorate-item"
  20. v-for="(item, index) in advertising"
  21. :key="index"
  22. >
  23. <div class="decorate-item-title">
  24. <div>设置</div>
  25. </div>
  26. <div class="decorate-item-box">
  27. <!-- 选择照片 -->
  28. <div class="decorate-view">
  29. <div class="decorate-view-title">选择图片</div>
  30. <div>
  31. <img class="show-image" :src="item.img" alt />
  32. <input
  33. type="file"
  34. class="hidden-input"
  35. @change="changeFile(item, index)"
  36. ref="files"
  37. :id="'files' + index"
  38. />
  39. <div class="tips">
  40. 建议尺寸
  41. <span>{{ item.size }}</span>
  42. </div>
  43. </div>
  44. <div class="selectBtn">
  45. <Button
  46. size="small"
  47. @click="handleClickFile(item, index)"
  48. ghost
  49. type="primary"
  50. >选择照片</Button
  51. >
  52. </div>
  53. </div>
  54. <!-- 选择连接 -->
  55. <div class="decorate-view">
  56. <div class="decorate-view-title">选择图片</div>
  57. <div>
  58. <Button
  59. ghost
  60. type="primary"
  61. size="small"
  62. @click="clickLink(item)"
  63. >选择链接</Button
  64. >
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <!-- <Button type="primary" @click="addDecorate()" ghost>添加</Button> -->
  71. <liliDialog ref="liliDialog" :types="linkType"></liliDialog>
  72. </div>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import { btnWay } from "./btn.js";
  78. export default {
  79. data() {
  80. return {
  81. btnWay, // 按钮类型
  82. type: "full", // 是否全屏
  83. //全屏广告
  84. advertising: [
  85. {
  86. img:
  87. "https://st-gdx.dancf.com/gaodingx/0/uxms/design/20200903-182035-5e87.png?x-oss-process=image/resize,w_932/interlace,1,image/format,webp",
  88. size: "750*1624",
  89. },
  90. ],
  91. linkType: "", // 选择类型
  92. };
  93. },
  94. methods: {},
  95. mounted() {
  96. console.log(this.btnWay);
  97. },
  98. methods: {
  99. // 点击链接
  100. clickLink(item) {
  101. this.$refs.liliDialog.open('link')
  102. },
  103. // 关闭
  104. closeDecorate(index) {
  105. this.$nextTick(() => {
  106. this.btnWay.splice(index, 1);
  107. });
  108. },
  109. //点击图片解析成base64
  110. changeFile(item, index) {
  111. const file = document.getElementById("files" + index).files[0];
  112. if (file == void 0) return false;
  113. const reader = new FileReader();
  114. reader.readAsDataURL(file);
  115. this.$nextTick((res) => {
  116. reader.onload = (e) => {
  117. item.img = e.target.result;
  118. };
  119. });
  120. },
  121. // 点击选择照片
  122. handleClickFile(item, index) {
  123. document.getElementById("files" + index).click();
  124. // console.log(let files = files)
  125. },
  126. },
  127. };
  128. </script>
  129. <style scoped lang="scss">
  130. @import "./style.scss";
  131. @import "./decorate.scss";
  132. .decorate-radio {
  133. margin: 10px 0;
  134. }
  135. .window-shadow,
  136. .full-shadow {
  137. display: flex;
  138. position: absolute;
  139. top: 0;
  140. width: 100%;
  141. height: 100%;
  142. background: rgba(0, 0, 0, 0.2);
  143. left: 0;
  144. align-items: center;
  145. justify-content: center;
  146. }
  147. .window-shadow {
  148. > img {
  149. width: 306px;
  150. height: 418px;
  151. }
  152. }
  153. .full-shadow {
  154. > img {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. }
  159. .draggable {
  160. position: relative;
  161. }
  162. .btn-item {
  163. > img {
  164. margin: 4px 0;
  165. border-radius: 50%;
  166. width: 30px;
  167. height: 30px;
  168. }
  169. }
  170. </style>