preview.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. <template id="course-preview">
  2. <div class="diy-course" :class="{'three-tem': searchData.styleVal == 3,'four-tem':searchData.styleVal == 4}" :style="{background: computedStyle.searchBox,'padding': marginInfos.temp}">
  3. <!-- 一行一个(1) -->
  4. <div class="course-style-big" v-if="searchData.styleVal == 1" v-for="(item,index) in courseDataBoo?searchData.courseList:3" :style="{...marginInfos.model,background: computedStyle.iptBg,...inputStyle }">
  5. <div class="diy-course-image">
  6. <div :class="hotClass" v-if="isShowHot" :style="hotStyle">{{hotName}}</div>
  7. <el-image class="big-img" :src="courseDataBoo?item.params.logo:'resources/img/decorate/default_picture.png'" fit="cover"></el-image>
  8. </div>
  9. <div class="course-model">
  10. <div class="course-title over1" :style="[{color: permession['title'].color}]" v-if="permession['title'].showAlpha">{{courseDataBoo?item.params.title:'这里是课程标题'}}</div>
  11. <div class="course-desc over2" :style="[{color: permession['desc'].color}]" v-if="permession['desc'].showAlpha">{{courseDataBoo?item.params.introduce:'这里是课程副标题'}}</div>
  12. <div flex v-if="permession['price'].showAlpha">
  13. <div class="course-price" v-if="courseDataBoo && item.params.sell_type == 2">
  14. 指定会员可看
  15. </div>
  16. <div class="course-price" v-else-if="courseDataBoo && (item.params.sell_type == 3 || item.params.price == 0)">
  17. 免费
  18. </div>
  19. <div class="course-price" v-else :style="[{color: permession['price'].color}]">
  20. ¥<span style="font-size: 14px;">{{courseDataBoo?item.params.price:'88.88'}}</span>
  21. </div>
  22. <div class="course-count" :style="[{color: permession['count'].color}]" v-if="permession['count'].showAlpha">
  23. <image class="course-hot-img" src="resources/img/decorate/course/hot.png"></image>
  24. {{courseDataBoo?item.params.vm_views+item.params.views:0}}人学习
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <!-- 列表模式 (2) -->
  30. <div class="course-style-list" v-if="searchData.styleVal == 2" v-for="(item,index) in courseDataBoo?searchData.courseList:3" :style="{...marginInfos.model,background: computedStyle.iptBg,...inputStyle }" flex>
  31. <div class="diy-course-image">
  32. <div :class="hotClass" v-if="isShowHot" :style="hotStyle">{{hotName}}</div>
  33. <!-- <el-image :src="default_src"></el-image> -->
  34. <el-image class="course-list-img" :src="courseDataBoo?item.params.logo:'resources/img/decorate/default_picture.png'" fit="cover"></el-image>
  35. </div>
  36. <div class="course-model">
  37. <div class="course-title over1" :style="[{color: permession['title'].color,'visibility': permession['title'].showAlpha?'':'hidden'}]">{{courseDataBoo?item.params.title:'这里是课程标题'}}</div>
  38. <div class="course-desc over2" :style="[{color: permession['desc'].color,'visibility': permession['desc'].showAlpha?'':'hidden'}]">{{courseDataBoo?item.params.introduce:'这里是课程副标题'}}</div>
  39. <div flex>
  40. <template v-if="permession['price'].showAlpha">
  41. <div class="course-price" v-if="courseDataBoo && item.params.sell_type == 2">
  42. 指定会员可看
  43. </div>
  44. <div class="course-price" v-else-if="courseDataBoo && (item.params.sell_type == 3 || item.params.price == 0)">
  45. 免费
  46. </div>
  47. <div class="course-price" v-else :style="[{color: permession['price'].color}]">
  48. ¥<span style="font-size: 14px;">{{courseDataBoo?item.params.price:'88.88'}}</span>
  49. </div>
  50. </template>
  51. <div class="course-count" :style="[{color: permession['count'].color}]" v-if="permession['count'].showAlpha">
  52. <image class="course-hot-img" src="resources/img/decorate/course/hot.png"></image>
  53. {{courseDataBoo?item.params.vm_views+item.params.views:0}}人学习
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. <!-- 一行两个 (3) -->
  59. <div class="course-style-two" v-if="searchData.styleVal == 3" v-for="(item,index) in courseDataBoo?searchData.courseList:3" :style="{...marginInfos.model,background: computedStyle.iptBg,...inputStyle,'max-width': (187.5 - marginInfos.modelVal - marginInfos.aboutVal) + 'px' }">
  60. <div class="diy-course-image" :style="{'max-width': (187.5 - marginInfos.modelVal - marginInfos.aboutVal) + 'px'}">
  61. <div :class="hotClass" v-if="isShowHot" :style="hotStyle">{{hotName}}</div>
  62. <el-image :style="[imgRadius]" class="course-two-img" :src="courseDataBoo?item.params.logo:'resources/img/decorate/default_picture.png'" fit="cover"></el-image>
  63. </div>
  64. <div class="course-model">
  65. <div class="course-title over1" :style="[{color: permession['title'].color}]" v-if="permession['title'].showAlpha">{{courseDataBoo?item.params.title:'这里是课程标题'}}</div>
  66. <div class="course-desc over2" :style="[{color: permession['desc'].color}]" v-if="permession['desc'].showAlpha">{{courseDataBoo?item.params.introduce:'这里是课程副标题'}}</div>
  67. <div class="course-count" :style="[{color: permession['count'].color}]" v-if="permession['count'].showAlpha">
  68. <image class="course-hot-img" src="resources/img/decorate/course/hot.png"></image>
  69. {{courseDataBoo?item.params.vm_views+item.params.views:0}}人学习
  70. </div>
  71. <template v-if="permession['price'].showAlpha">
  72. <div class="course-price" v-if="courseDataBoo && item.params.sell_type == 2">
  73. 指定会员可看
  74. </div>
  75. <div class="course-price" v-else-if="courseDataBoo && (item.params.sell_type == 3 || item.params.price == 0)">
  76. 免费
  77. </div>
  78. <div class="course-price" v-else :style="[{color: permession['price'].color}]">
  79. ¥<span style="font-size: 14px;">{{courseDataBoo?item.params.price:'88.88'}}</span>
  80. </div>
  81. </template>
  82. </div>
  83. </div>
  84. <!-- 可滑动(4) -->
  85. <div class="course-style-slide" v-if="searchData.styleVal == 4" v-for="(item,index) in courseDataBoo?searchData.courseList:3" :style="{background: computedStyle.iptBg,...inputStyle }">
  86. <div class="diy-course-image">
  87. <div :class="hotClass" v-if="isShowHot" :style="hotStyle">{{hotName}}</div>
  88. <!-- <el-image :src="default_src"></el-image> -->
  89. <el-image :style="[imgRadius]" class="course-slide-img" :src="courseDataBoo?item.params.logo:'resources/img/decorate/default_picture.png'" fit="cover"></el-image>
  90. </div>
  91. <div class="course-model">
  92. <div class="course-title over1" :style="[{color: permession['title'].color}]" v-if="permession['title'].showAlpha">{{courseDataBoo?item.params.title:'这里是课程标题'}}</div>
  93. <div class="course-desc over2" :style="[{color: permession['desc'].color}]" v-if="permession['desc'].showAlpha">{{courseDataBoo?item.params.introduce:'这里是课程副标题'}}</div>
  94. <div class="course-count" :style="[{color: permession['count'].color}]" v-if="permession['count'].showAlpha">
  95. <image class="course-hot-img" src="resources/img/decorate/course/hot.png"></image>
  96. {{courseDataBoo?item.params.vm_views+item.params.views:0}}人学习
  97. </div>
  98. <template v-if="permession['price'].showAlpha">
  99. <div class="course-price" v-if="courseDataBoo && item.params.sell_type == 2">
  100. 指定会员可看
  101. </div>
  102. <div class="course-price" v-else-if="courseDataBoo && (item.params.sell_type == 3 || item.params.price == 0)">
  103. 免费
  104. </div>
  105. <div class="course-price" v-else :style="[{color: permession['price'].color}]">
  106. ¥<span style="font-size: 14px;">{{courseDataBoo?item.params.price:'88.88'}}</span>
  107. </div>
  108. </template>
  109. </div>
  110. </div>
  111. </div>
  112. </template>
  113. <script>
  114. /**
  115. * @descriptions
  116. * 1. 组件名字必须对应模板形式 - 递归组件name
  117. * 2. 样式内容方法尽量内部维护 - 前端方便通用
  118. * 3. 父级组件会传预览数据 - activeItem
  119. */
  120. Vue.component('course-preview', {
  121. name: "course-preview",
  122. props: {
  123. activeItem: {
  124. type: Object,
  125. default () {
  126. return {}
  127. }
  128. }
  129. },
  130. template: '#course-preview',
  131. computed: {
  132. // 角标
  133. isShowHot() {
  134. var angleMark = this.activeItem.data.angleMarkType || null
  135. return angleMark && angleMark != 1
  136. },
  137. hotStyle() {
  138. var angleMark = this.activeItem.data.angleMarkType || null
  139. if (angleMark == 3 && this.activeItem.data.customImgUrl) {
  140. return {
  141. width: "76px",
  142. height: "76px",
  143. background: `url(${this.activeItem.data.customImgUrl}) no-repeat`,
  144. backgroundSize: "76px"
  145. }
  146. }
  147. return {}
  148. },
  149. hotClass() {
  150. var angleMark = this.activeItem.data.angleMarkType || null
  151. var obj = ["diy-goods-hot"]
  152. if (angleMark) {
  153. var name = ["diy-goods-hot3", "diy-goods-hot2", "diy-goods-hot1"]
  154. if (angleMark == 2 && this.activeItem.data.angleMarkStyle) {
  155. var key = name[this.activeItem.data.angleMarkStyle]
  156. obj.push(key)
  157. } else if(angleMark == 2) {
  158. obj.push("diy-goods-hot3")
  159. }
  160. }
  161. return obj
  162. },
  163. hotName() {
  164. var angleMark = this.activeItem.data.angleMarkType || null
  165. if (!this.activeItem.data.angleMarkText && angleMark == 2) {
  166. return "热卖"
  167. }
  168. return this.activeItem.data.angleMarkText
  169. },
  170. // end角标
  171. // 展示内容
  172. permession(){
  173. let obj = {}
  174. if(this.activeItem.data.showContent){
  175. this.activeItem.data.showContent.forEach(v => {
  176. obj[v.key] = v;
  177. })
  178. }
  179. return obj;
  180. },
  181. // end展示内容
  182. imgRadius(){
  183. let obj = {}
  184. if(this.computedStyle.searchIpts && this.computedStyle.searchIpts['border-top-left-radius']){
  185. obj = {
  186. 'border-top-left-radius': this.computedStyle.searchIpts['border-top-left-radius'],
  187. 'border-top-right-radius': this.computedStyle.searchIpts['border-top-right-radius'],
  188. }
  189. }
  190. return obj
  191. },
  192. marginBottomTop(){
  193. let obj = {}
  194. marginBottom: "4px"
  195. marginLeft: "0px"
  196. marginRight: "0px"
  197. marginTop: "22px"
  198. if(this.computedStyle.searchIpts && this.computedStyle.searchIpts['border-top-left-radius']){
  199. obj = {
  200. 'border-top-left-radius': this.computedStyle.searchIpts['border-top-left-radius'],
  201. 'border-top-right-radius': this.computedStyle.searchIpts['border-top-right-radius'],
  202. }
  203. }
  204. return obj
  205. },
  206. computedStyle() {
  207. console.info(this.activeItem.computedStyle,"this.activeItem.computedStylethis.activeItem.computedStylethis.activeItem.computedStylethis.activeItem.computedStylethis.activeItem.computedStyle");
  208. return this.activeItem.computedStyle
  209. },
  210. searchData() {
  211. console.info(this.activeItem.data)
  212. return this.activeItem.data
  213. },
  214. courseDataBoo(){
  215. return this.activeItem.data.courseList && this.activeItem.data.courseList.length?true:false;
  216. },
  217. inputStyle() {
  218. let tabItem = this.computedStyle.tabItem
  219. let style = {
  220. 'background': this.computedStyle.iptBg,
  221. ...this.computedStyle.searchIpts
  222. }
  223. if (tabItem && tabItem.value == 'border') style.border = '1px solid ' + (tabItem ? tabItem.color : 'transparent')
  224. if (tabItem && tabItem.value == 'shandow') style.boxShadow = tabItem ? '0 0 10px ' + tabItem.color : '0 0 10px rgba(226, 231, 244, 0.7)'
  225. console.log(style);
  226. return style
  227. },
  228. computedSize() {
  229. var width = 331;
  230. var arr = ['computedStyle', 'proportion']
  231. var result = {
  232. width,
  233. height: width
  234. }
  235. const type = getObjValue(this.activeItem, arr, 1)
  236. var b = [0, 0.5625, 0.75, 1]
  237. result.height = width * b[type]
  238. return {
  239. height: result.height + 'px'
  240. }
  241. },
  242. marginInfos(){
  243. let obj = {
  244. model: {},
  245. temp: '',
  246. modelVal: 0,
  247. aboutVal: 0,
  248. };
  249. if(this.activeItem.data.marginArr){
  250. let reg = /^[\d]+/g;
  251. if(this.activeItem.data.styleVal == 1 || this.activeItem.data.styleVal == 2){
  252. obj.model['margin-bottom'] = this.activeItem.data.marginArr[0];
  253. } else if(this.activeItem.data.styleVal == 3){
  254. let str = this.activeItem.data.marginArr[0];
  255. let num = str.match(reg)[0];
  256. let unit = str.substr(num.length,str.length);
  257. obj.model['margin'] = (Number(num) / 2) + unit;
  258. obj.modelVal = Number(num) / 2;
  259. }
  260. let aboutStr = this.activeItem.data.marginArr[3];
  261. let abouNum = aboutStr.match(reg)[0];
  262. obj.aboutVal = abouNum;
  263. obj.temp = `${this.activeItem.data.marginArr[1]} ${aboutStr} ${this.activeItem.data.marginArr[2]}`
  264. }
  265. console.info(obj)
  266. return obj;
  267. },
  268. },
  269. data() {
  270. return {}
  271. }
  272. });
  273. </script>
  274. <style>
  275. .diy-course {
  276. box-sizing: border-box;
  277. background: #FFFFFF;
  278. overflow: hidden;
  279. }
  280. .course-style-big{
  281. padding: 10px 12px;
  282. }
  283. /* 一行一个 */
  284. .big-img{
  285. height: 168px;
  286. width: 100%;
  287. border-radius: 10px;
  288. }
  289. .big-img .course-model{
  290. padding: 10px 2px 0;
  291. }
  292. /* 列表模式 */
  293. .course-style-list{
  294. padding: 12px 8px;
  295. }
  296. .course-list-img{
  297. width: 140px;
  298. height: 76px;
  299. padding-top: 0;
  300. border-radius: 10px;
  301. margin-right: 10px;
  302. }
  303. .course-style-list .course-model{
  304. flex-direction: column;
  305. flex: 1;
  306. }
  307. .course-style-list .course-desc{
  308. flex: 1;
  309. }
  310. /* 一行两个 */
  311. .course-style-two{
  312. padding: 0;
  313. /* max-width: 187.5px; */
  314. width: 100%;
  315. }
  316. .course-two-img{
  317. width: 100%;
  318. height: 100px;
  319. }
  320. .course-style-two:nth-child(odd){
  321. margin-top: 0 !important;
  322. margin-left: 0 !important;
  323. }
  324. .course-style-two:nth-child(even){
  325. margin-top: 0 !important;
  326. margin-right: 0 !important;
  327. }
  328. .course-style-two .course-model,.course-style-slide .course-model{
  329. padding: 8px;
  330. }
  331. .course-style-two .course-count,.course-style-slide .course-count{
  332. justify-content: flex-start;
  333. }
  334. /* 可滑动的 */
  335. .course-style-slide{
  336. padding: 0;
  337. max-width: 148px;
  338. margin-right: 8px;
  339. }
  340. .course-slide-img{
  341. min-width: 138px;
  342. max-width: 138px;
  343. height: 80px;
  344. }
  345. /* 公共的 */
  346. .course-model>div{
  347. margin-bottom: 4px;
  348. }
  349. .course-title{
  350. font-size: 16px;
  351. line-height: 22px;
  352. color: #202021;
  353. font-weight: 700;
  354. }
  355. .course-desc{
  356. font-size: 13px;
  357. line-height: 18px;
  358. color: #999ca7;
  359. }
  360. .course-price{
  361. font-weight: 700;
  362. color: #fd463e;
  363. font-size: 12px;
  364. color: #DB0505;
  365. }
  366. .course-count{
  367. flex: 1;
  368. font-size: 12px;
  369. color: #000;
  370. align-items: center;
  371. display: flex;
  372. justify-content: flex-end;
  373. }
  374. .course-hot-img{
  375. height: 18px;
  376. width: 18px;
  377. min-height: 18px;
  378. min-width: 18px;
  379. }
  380. .diy-course-image{
  381. position: relative;
  382. }
  383. /* 角标 */
  384. .diy-goods-hot {
  385. position: absolute;
  386. top: 0;
  387. left: 0;
  388. transform: scale(.5);
  389. transform-origin: top left;
  390. color: #fff;
  391. font-size: 22px;
  392. z-index: 99;
  393. }
  394. .diy-goods-hot1 {
  395. width: 64px;
  396. height: 44px;
  397. line-height: 44px;
  398. padding-left: 4px;
  399. background: url("resources/img/decorate/commodity-group/common_label2_3.png") no-repeat;
  400. }
  401. .diy-goods-hot2 {
  402. width: 52px;
  403. height: 56px;
  404. line-height: 44px;
  405. text-align: center;
  406. background: url("resources/img/decorate/commodity-group/common_label2_2.png") no-repeat;
  407. background-size: 52px 56px;
  408. }
  409. .diy-goods-hot3 {
  410. top: -3px;
  411. width: 60px;
  412. height: 60px;
  413. line-height: 50px;
  414. background-size: 60px;
  415. padding-left: 4px;
  416. background: url("resources/img/decorate/commodity-group/common_label2.png") no-repeat;
  417. }
  418. .three-tem{
  419. display: flex;
  420. flex-wrap: wrap;
  421. }
  422. .four-tem{
  423. display: flex;
  424. flex-wrap: nowrap;
  425. }
  426. </style>