diy-preview.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template id="diy-preview">
  2. <div style="position:relative">
  3. <el-scrollbar class="dp-el-scrollbar" ref="scrollbar">
  4. <div id="diy-preview-contain" class="dp-contain" ref="diyPreview" :style="mainStyle">
  5. <div id="diy-test">
  6. <div style="position: relative" data-html2canvas-ignore>
  7. <div class="dp-header-placeholder"></div>
  8. </div>
  9. <div class="drag-scroll" >
  10. <div class="secondary-card-box">
  11. <div class="header-bg"></div>
  12. <div class="body-box">
  13. <div class="secondary-card" :style="background">
  14. <div class="secondary-card-share" :style="{'background':activeItem.font_color}">分享</div>
  15. <div>
  16. <div class="secondary-card-title" :style="font_color">{{name}}</div>
  17. <div class="secondary-card-desc" :style="font_color" v-show="expire_type==1">{{expire_day}} 日有效</div>
  18. <div class="secondary-card-desc" :style="font_color" v-show="expire_type==2">{{begin_at ||'--'}}至{{end_at || '--'}}有效</div>
  19. </div>
  20. <div class="secondary-card-bottom flex-x-between flex-y-baseline">
  21. <div class="secondary-card-desc" :style="font_color">
  22. 已领 {{virtual_sales}} 张
  23. </div>
  24. <div class="flex-y-baseline">
  25. <div class="secondary-card-desc" :style="font_color">原价<span class="line-through">¥{{original_price}}</span></div>
  26. <div class="bold" :style="font_color">¥<span class="price">{{price}}</span></div>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. </div>
  32. <div class="sc-btn-box">
  33. <div class="sc-btn">
  34. <span class="sc-small-text">¥</span>{{price}} <span class="sc-small-text line-through">¥{{original_price}}</span> 立即开通
  35. </div>
  36. </div>
  37. <div class="sc-info">
  38. <div class="sc-info-title">使用规则:</div>
  39. <el-input
  40. type="textarea"
  41. :rows="10"
  42. placeholder="请输入内容"
  43. v-model="rule">
  44. </el-input>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </el-scrollbar>
  52. </div>
  53. </template>
  54. <script src="/resources/js/Sortable.min.js"></script>
  55. <script src="<?= Yii::$app->request->baseUrl ?>/resources/unpkg/vuedraggable@2.18.1/dist/vuedraggable.umd.min.js"></script>
  56. <script>
  57. Vue.component('diy-preview', {
  58. name: "diy-preview",
  59. template: '#diy-preview',
  60. props: {
  61. activeItem: {
  62. type: Object,
  63. default () {
  64. return {}
  65. }
  66. },
  67. },
  68. data() {
  69. return {
  70. static_img_prefix: '<?= Yii::getAlias('@attachurl') ?>'+'/static',
  71. };
  72. },
  73. computed: {
  74. name(){
  75. if(!this.activeItem.name){
  76. return ''
  77. } else{
  78. return this.activeItem.name
  79. }
  80. },
  81. font_color(){
  82. return {color:this.activeItem.font_color}
  83. },
  84. background(){
  85. if(!this.activeItem.background){
  86. return {'background-image':`url(${this.static_img_prefix}/addons/SecondaryCard/background2.png)`}
  87. } else{
  88. if(this.activeItem.background_type == 0){
  89. return {'background-image':`url(${this.static_img_prefix}${this.activeItem.background})`}
  90. }
  91. return {'background-image':`url(${this.activeItem.background})`}
  92. }
  93. },
  94. expire_type(){
  95. return this.activeItem.expire_type
  96. },
  97. expire_day(){
  98. if(!this.activeItem.expire_day){
  99. return '1'
  100. } else{
  101. return this.activeItem.expire_day
  102. }
  103. },
  104. begin_at(){
  105. console.log('begin_at',this.activeItem)
  106. if(!this.activeItem.begin_at){
  107. return ''
  108. } else{
  109. return this.activeItem.begin_at
  110. }
  111. },
  112. end_at(){
  113. if(!this.activeItem.end_at){
  114. return ''
  115. } else{
  116. return this.activeItem.end_at
  117. }
  118. },
  119. price(){
  120. if(!this.activeItem.price){
  121. return '0.00'
  122. } else{
  123. return this.activeItem.price
  124. }
  125. },
  126. original_price(){
  127. if(!this.activeItem.original_price){
  128. return '0.00'
  129. } else{
  130. return this.activeItem.original_price
  131. }
  132. },
  133. virtual_sales(){
  134. if(!this.activeItem.virtual_sales){
  135. return '0'
  136. } else{
  137. return this.activeItem.virtual_sales
  138. }
  139. },
  140. rule(){
  141. if(!this.activeItem.rule){
  142. return ''
  143. } else{
  144. return this.activeItem.rule
  145. }
  146. },
  147. mainStyle() {
  148. var style = {
  149. backgroundSize: "100%",
  150. backgroundRepeat: "no-repeat",
  151. backgroundPosition: "left top",
  152. backgroundColor: '#F5F5F5'
  153. }
  154. return style
  155. }
  156. },
  157. methods: {
  158. },
  159. });
  160. </script>
  161. <style>
  162. .dp-contain {
  163. position: relative;
  164. box-sizing: initial;
  165. display: flex;
  166. flex-direction: column;
  167. width: 375px;
  168. margin: 45px 20px 0;
  169. border: 1px solid #ddd;
  170. min-height: 700px;
  171. }
  172. .dp-el-scrollbar {
  173. height: 100%;
  174. }
  175. .dp-header-placeholder {
  176. width: 100%;
  177. height: 44px;
  178. background-size: 100% 100%;
  179. z-index: 99;
  180. background: url("resources/img/decorate/nav/light1.png") no-repeat;
  181. }
  182. #float {
  183. position: absolute;
  184. top: 0;
  185. left: 0;
  186. right: 0;
  187. bottom: 0;
  188. pointer-events: none;
  189. margin-top: 88px;
  190. }
  191. .dp-nav-placeholder {
  192. position: relative;
  193. height: 44px;
  194. }
  195. .dp-list-item {
  196. position: relative;
  197. }
  198. .float-dp-list-item {
  199. /* position: relative; */
  200. float: left;
  201. pointer-events: auto;
  202. }
  203. .dp-list-item .dp-close,
  204. .float-dp-list-item .dp-close {
  205. display: none;
  206. }
  207. .dp-active-item:before,
  208. .float-dp-active-item .diy-solid-line:before {
  209. box-sizing: border-box;
  210. content: "";
  211. position: absolute;
  212. top: 0;
  213. left: 0;
  214. right: 0;
  215. bottom: 0;
  216. border: 2px solid var(--diy-theme);
  217. height: 100%;
  218. z-index: 100;
  219. pointer-events: none;
  220. cursor: move;
  221. }
  222. .dp-active-item .dp-close,
  223. .float-dp-active-item .dp-close {
  224. display: block;
  225. }
  226. .slide-right {
  227. position: absolute;
  228. width: 42px;
  229. height: 200px;
  230. top: 0;
  231. bottom: 0;
  232. left: 50%;
  233. background: #73767D;
  234. margin: auto 0 auto 220px;
  235. /* margin-left: ; */
  236. border-radius: 2px;
  237. z-index: 999;
  238. }
  239. .slide-right .iconfont-el {
  240. color: #fff;
  241. display: block;
  242. text-align: center;
  243. font-size: 24px;
  244. line-height: 40px;
  245. cursor: pointer;
  246. position: relative;
  247. }
  248. .slide-right .iconfont-el>p {
  249. display: none;
  250. }
  251. .dp-close {
  252. position: absolute;
  253. top: 0;
  254. right: 0;
  255. width: 16px;
  256. height: 16px;
  257. background-color: var(--diy-theme);
  258. color: #fff;
  259. font-size: 12px;
  260. text-align: center;
  261. border-bottom-left-radius: 40px;
  262. z-index: 99;
  263. }
  264. .dp-close .el-icon-close {
  265. transform: translate(2px, -2px);
  266. }
  267. .flip-list-move {
  268. transition: transform 1s;
  269. }
  270. .dp-hover:before {
  271. box-sizing: border-box;
  272. content: "";
  273. position: absolute;
  274. top: 0;
  275. left: 0;
  276. right: 0;
  277. bottom: 0;
  278. border: 1px dashed var(--diy-theme);
  279. height: 100%;
  280. z-index: 100;
  281. pointer-events: none;
  282. cursor: move;
  283. display: none;
  284. }
  285. .dp-list-item:hover .dp-hover:before,
  286. .float-dp-list-item .diy-solid-line:hover .dp-hover:before {
  287. display: block;
  288. }
  289. .secondary-card-box .header-bg{
  290. height: 100px;
  291. background-color: #ffdd00;
  292. }
  293. .secondary-card-box .body-box {
  294. position: relative;
  295. top: -85px;
  296. margin: 16px;
  297. }
  298. .secondary-card {
  299. position: relative;
  300. height: 170px;
  301. margin: 16px 0;
  302. padding: 24px;
  303. border-radius: 14px;
  304. display: flex;
  305. flex-direction: column;
  306. justify-content: space-between;
  307. overflow: hidden;
  308. background-repeat: no-repeat;
  309. background-color: #fff;
  310. background-size: 100% 100%;
  311. box-shadow: 0 2px 12px 0 rgba(0,0,0,.2);
  312. }
  313. .secondary-card-share {
  314. position: absolute;
  315. width: 60px;
  316. right: 0;
  317. top:0;
  318. height: 22px;
  319. line-height: 22px;
  320. background: linear-gradient(172.93deg, #fdb33b 0%, #fd880e 94.38%);
  321. color:#FFF;
  322. text-align: center;
  323. border-bottom-left-radius: 22px;
  324. opacity: 0.6;
  325. }
  326. .secondary-card-title {
  327. font-size:18px;
  328. min-height:24px;
  329. font-weight: bold;
  330. width: 60%;
  331. margin-bottom: 8px;
  332. }
  333. .secondary-card-bottom {
  334. display: flex;
  335. justify-content: space-between;
  336. }
  337. .secondary-card-desc {
  338. opacity: 0.8;
  339. font-size:12px
  340. }
  341. .sc-btn-box{
  342. padding: 10px;
  343. background-color: #FFF;
  344. }
  345. .sc-btn-box .sc-btn{
  346. border-radius: 50px;
  347. height: 40px;
  348. line-height: 40px;
  349. background: linear-gradient(172.93deg, #fdb33b 0%, #fd880e 94.38%);
  350. color: #fff;
  351. margin: auto;
  352. text-align: center;
  353. font-size:16px;
  354. }
  355. .sc-btn-box .sc-small-text{
  356. font-size:10px;
  357. }
  358. .line-through {
  359. text-decoration: line-through;
  360. }
  361. .sc-info {
  362. padding: 16px 0;
  363. }
  364. .sc-info-title {
  365. font-size:14px;
  366. padding-bottom: 4px;
  367. }
  368. .flex-y-baseline{
  369. display: flex;
  370. align-items: baseline;
  371. }
  372. .price {
  373. font-size:26px;
  374. }
  375. .bold{
  376. font-weight: bold;
  377. }
  378. </style>