style.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template id="course-style">
  2. <div class="course-style">
  3. <!-- 公共 -->
  4. <diy-tabs class="fill-border-top" title="样式" radio_text='text' :default_color="defaultForm.default_color" @change="colorSelect"></diy-tabs>
  5. <diy-style-contain title="风格" class="clear-diy-style fill-border-top">
  6. <el-radio-group v-model="style" @change="onStyleList">
  7. <el-radio-button :label="item.label" v-for="(item,index) in styleList" :key="index">
  8. <div flex="cross:center" class="flex-x-center" style="width: 56px;height: 38px;">
  9. <img :src="item.src" style="width: 26px;">
  10. </div>
  11. </el-radio-button>
  12. </el-radio-group>
  13. </diy-style-contain>
  14. <diy-style-contain title="选择课程" class="clear-diy-style fill-border-top">
  15. <div class="pick-goods">
  16. <com-pick-link @selected="selectNavUrl" :default-select-list="selectList" :pick-type="pickType" :default-tabs="[{name: 'marketing',children:['course_cate'] }]">
  17. <div class="add-goods-btn">+添加({{ courseList.length + '/' + maxDataLength }})</div>
  18. </com-pick-link>
  19. <div flex="cross:center" style="margin-top: 20px;flex-wrap:wrap" v-if="courseList.length">
  20. <div class="pickImgItem" v-for="(item,index) in courseList" :key="index" @mouseenter="mouseenter(index)" @mouseleave="mouseleave(index)">
  21. <el-image style="width: 50px; height: 50px" :src="item.params.logo" fit="contain"></el-image>
  22. <div v-show="index == pickIndex || item.visible">
  23. <el-popover placement="bottom" v-model="item.visible">
  24. <p class="diy-del-text">确定删除吗?</p>
  25. <div flex="cross:center">
  26. <el-button class="diy-del-btn" size="mini" plain @click="delModel(index)">删除</el-button>
  27. <el-button size="mini" plain @click="item.visible = false">取消</el-button>
  28. </div>
  29. <i class="el-icon-close" slot="reference" style="color:#999;"></i>
  30. </el-popover>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </diy-style-contain>
  36. <diy-style-contain title="角标设置" class="fill-border-top">
  37. <el-radio-group v-model="angleMark" @change="onAngleMark">
  38. <el-radio :label="item.label" v-for="(item,index) in angleMarkList" :key="index">{{item.value}}</el-radio>
  39. </el-radio-group>
  40. <div class="shopping-cart-func" v-show="angleMark == 2">
  41. <div class="shop-cart-row" flex="cross:center">
  42. <div class="leabl">样式</div>
  43. <diy-tab v-model="angleMarkStyleList" :default-index="angleMarkStyleIndex" @change="onAngleMarkChange($event, 'angleMarkStyle')">
  44. <template v-slot="{item, isSelect}">
  45. <div flex="cross:center" :class="{'shop-cart-col': true,'selected': isSelect}">
  46. <img :src="item.src" style="width: 28px;">
  47. </div>
  48. </template>
  49. </diy-tab>
  50. </div>
  51. <div class="shop-cart-row" flex="cross:center">
  52. <div class="leabl">文字</div>
  53. <el-input style="flex: 1;" v-model="angleMarkText" placeholder="请输入内容" maxlength="2" size="small" show-word-limit @input="onAngleMarkChange($event, 'angleMarkText')"></el-input>
  54. </div>
  55. </div>
  56. <div class="shopping-cart-func" v-show="angleMark == 3">
  57. <diy-img-setting :img-infos="imageUrl" def-img-count="1" :show-url="false" :suggest-site="2" suggest-size-text="建议图片宽度76,高度76。" :img-contain-style="{padding: 0}" :show-title="false" @change="addIconImg"></diy-img-setting>
  58. </div>
  59. </diy-style-contain>
  60. <diy-style-contain title="显示内容 " class="show-content fill-border-top">
  61. <el-checkbox-group v-model="contentCheckList" @change="onContentChange">
  62. <div v-for="(item,index) in showContentList" :key="index">
  63. <div flex="cross:center" class="flex-y-center" style="margin-bottom: 12px;">
  64. <el-checkbox :label="item.label">
  65. <span>{{item.name}}</span>
  66. </el-checkbox>
  67. <el-color-picker v-if="!item.disableColor" class="show-content-pick" color-format="colorFormat" v-model="item.color" @change="onContentChange"></el-color-picker>
  68. <el-input v-if="!item.disableColor" v-model="item.color" @input="updateInput($event,index)" class="diy-text-btn"></el-input>
  69. </div>
  70. </div>
  71. </el-checkbox-group>
  72. </diy-style-contain>
  73. <diy-color class="fill-border-top" :color-infos="defaultForm.colorInfos" :def-color="defaultForm.defColor" @chang="updateColor"></diy-color>
  74. <diy-size-setting class="fill-border-top" top-name="边距" :size-infos="sizeInfos" :max-value="50" @chang="marginChange"></diy-size-setting>
  75. <diy-size-setting class="fill-border-top" top-name="圆角设置" :size-infos="defaultForm.radiusInfos" :max-value="20" @chang="RadiusChange($event, 'radius')"></diy-size-setting>
  76. </div>
  77. </template>
  78. <script>
  79. Vue.component('course-style', {
  80. name: "course-style",
  81. mixins: [basicMixins],
  82. template: '#course-style',
  83. props: {
  84. activeItem: {
  85. type: Object,
  86. default () {
  87. return {}
  88. }
  89. }
  90. },
  91. data() {
  92. return {
  93. // 风格
  94. style: 1,
  95. styleList: [{
  96. label: 1,
  97. src: "resources/img/decorate/commodity-group/style1.png"
  98. }, {
  99. label: 2,
  100. src: "resources/img/decorate/commodity-group/style2.png"
  101. }, {
  102. label: 3,
  103. src: "resources/img/decorate/commodity-group/style3.png"
  104. }, {
  105. label: 4,
  106. src: "resources/img/decorate/commodity-group/style7.png"
  107. }],
  108. // 角标
  109. angleMarkStyleIndex: 0,
  110. angleMarkStyleList: [{
  111. label: 1,
  112. src: "resources/img/decorate/commodity-group/hot-1.png"
  113. }, {
  114. label: 2,
  115. src: "resources/img/decorate/commodity-group/hot-2.png"
  116. }, {
  117. label: 3,
  118. src: "resources/img/decorate/commodity-group/hot-3.png"
  119. }, ],
  120. angleMarkText: "",
  121. angleMark: 1,
  122. angleMarkList: [{
  123. label: 1,
  124. value: "不显示"
  125. }, {
  126. label: 2,
  127. value: "系统图标"
  128. }, {
  129. label: 3,
  130. value: "自定义"
  131. }],
  132. imageUrl: [],
  133. // 显示内容
  134. contentCheckList: [],
  135. showContentList: [{
  136. label: 1,
  137. name: "课程标题",
  138. color: "#202021",
  139. key: 'title',
  140. showAlpha: true
  141. }, {
  142. label: 2,
  143. name: "课程描述",
  144. color: "#999ca7",
  145. key: 'desc',
  146. showAlpha: true
  147. }, {
  148. label: 3,
  149. name: "课程价格",
  150. color: "#DB0505",
  151. key: 'price',
  152. showAlpha: true
  153. }, {
  154. label: 4,
  155. name: "学习人数",
  156. color: "#000000",
  157. key: 'count',
  158. showAlpha: true
  159. }
  160. ],
  161. //选择商品
  162. pickType: ['course_cate'],
  163. pickIndex: -1,
  164. courseList: [],
  165. maxDataLength: 20,
  166. // 间距
  167. sizeInfos: [
  168. {
  169. name: "间距", //名字
  170. value: 6, //值
  171. maxValue: 50, //最大值
  172. unit: "px", //单位
  173. hidden: false, //是否隐藏
  174. },
  175. {
  176. name: "上边距", //名字
  177. value: 0, //值
  178. maxValue: 50, //最大值
  179. unit: "px", //单位
  180. hidden: false, //是否隐藏
  181. },
  182. {
  183. name: "下边距", //名字
  184. value: 0, //值
  185. maxValue: 50, //最大值
  186. unit: "px", //单位
  187. hidden: false, //是否隐藏
  188. },
  189. {
  190. name: "左右边距", //名字
  191. value: 8, //值
  192. maxValue: 20, //最大值
  193. unit: "px", //单位
  194. hidden: false, //是否隐藏
  195. },
  196. ]
  197. }
  198. },
  199. methods: {
  200. init() {
  201. basicMixins.methods.init.call(this); // 以前的数据调用一下
  202. let arr2 = ['computedStyle', 'iptBg']
  203. var comBgColor = {
  204. name: '组件背景', //名字
  205. color: getObjValue(this.result, arr2, this.defaultForm.defColor), //颜色
  206. showAlpha: false, //是否开启透明度
  207. }
  208. // 更改mixins初始数据
  209. this.defaultForm.colorInfos.push(comBgColor)
  210. if(this.result.data.styleVal){
  211. this.style = this.result.data.styleVal;
  212. } else {
  213. this.result.data.styleVal = this.style;
  214. }
  215. if(this.result.data.showContent){
  216. this.showContentList = this.result.data.showContent;
  217. this.contentCheckList.push(...this.showContentList.filter(v => v.showAlpha).map((val) =>{ return val.label}))
  218. } else {
  219. this.result.data.showContent = this.showContentList;
  220. this.contentCheckList.push(...this.showContentList.map((val) =>{ return val.label}))
  221. }
  222. if(!this.result.data.marginArr){
  223. this.marginChange();
  224. } else {
  225. this.sizeInfos = this.result.data.marginData;
  226. }
  227. if(this.result.data.courseList){
  228. this.courseList = this.result.data.courseList;
  229. } else {
  230. this.result.data.courseList = [];
  231. }
  232. if(this.result.data.angleMarkStyle && this.result.data.angleMarkStyle != -1){
  233. this.angleMarkStyleIndex = this.result.data.angleMarkStyle;
  234. }
  235. if(this.result.data.angleMarkText){
  236. this.angleMarkText = this.result.data.angleMarkText;
  237. }
  238. if(this.result.data.angleMarkType){
  239. this.angleMark = this.result.data.angleMarkType;
  240. }
  241. //
  242. },
  243. updateColor(e) { // 选择颜色
  244. this.result.computedStyle.searchBox = e[0].color
  245. this.result.computedStyle.iptBg = e[1].color
  246. this.$emit("update", this.result)
  247. },
  248. // 风格
  249. onStyleList(val){
  250. if(val == 4){
  251. this.sizeInfos[0].hidden = true;
  252. } else {
  253. this.sizeInfos[0].hidden = false;
  254. }
  255. this.updateInfos("styleVal",val);
  256. },
  257. // 角标
  258. onAngleMark(e){
  259. this.updateInfos('angleMarkType',e);
  260. },
  261. onAngleMarkChange(e,key){
  262. if(key == "angleMarkStyle"){
  263. let label = e.label;
  264. let index = this.angleMarkStyleList.findIndex(v => v.label == label)
  265. e = index;
  266. }
  267. this.updateInfos(key,e);
  268. },
  269. addIconImg(arr){
  270. this.imageUrl = arr;
  271. this.updateInfos("customImgUrl",arr[0].imgUrl);
  272. },
  273. // 展示内容
  274. onContentChange(){
  275. /* var result = this.showContentList.filter(item => {
  276. return this.contentCheckList.indexOf(item.label) !== -1
  277. })
  278. console.log(this.showContentList); */
  279. this.showContentList.forEach(item => {
  280. if(this.contentCheckList.indexOf(item.label) == -1){
  281. item.showAlpha = false;
  282. } else {
  283. item.showAlpha = true;
  284. }
  285. })
  286. console.log(this.showContentList);
  287. this.updateInfos("showContent",this.showContentList);
  288. },
  289. updateInput(val, index){
  290. if (val.length == 0) {
  291. val = "transparent";
  292. this.showContentList[index].color = val;
  293. }
  294. this.showContentList[index].color = val == "transparent" ? "" : val;
  295. this.updateInfos("showContent",this.showContentList);
  296. },
  297. // 添加
  298. selectNavUrl(arr) {
  299. for(let i = 0;i < arr.length;i++){
  300. if(this.courseList.length >= this.maxDataLength){
  301. this.$message({
  302. message: `最多添加${this.maxDataLength}条`,
  303. type: 'warning'
  304. });
  305. return;
  306. }
  307. this.courseList.push(arr[i]);
  308. }
  309. this.updateInfos("courseList",this.courseList);
  310. },
  311. // 删除
  312. delModel(index) {
  313. this.courseList.splice(index, 1)
  314. this.updateInfos("courseList",this.courseList);
  315. },
  316. mouseenter(index) {
  317. this.pickIndex = index
  318. },
  319. mouseleave() {
  320. this.pickIndex = -1
  321. },
  322. // 边距
  323. marginChange(arr){
  324. let that = this;
  325. let newArr = [];
  326. arr = arr || this.sizeInfos;
  327. arr.forEach(v => {
  328. newArr.push(v.value + v.unit);
  329. })
  330. if(!that.result.data.marginArr){
  331. that.$set(that.result.data,'marginArr',newArr)
  332. } else {
  333. that.result.data.marginArr = newArr;
  334. }
  335. that.result.data.marginData = arr;
  336. this.updateInfos();
  337. },
  338. updateInfos(key,val){
  339. if(key){
  340. this.result.data[key] = val;
  341. }
  342. this.$emit("update", this.result)
  343. },
  344. }
  345. });
  346. </script>
  347. <style>
  348. /* 清理组件默认样式 */
  349. .clear-diy-style .el-radio-button__inner {
  350. background-color: transparent;
  351. padding: 0;
  352. }
  353. .shop-cart-row .el-radio-group {
  354. display: flex;
  355. align-items: center;
  356. }
  357. .shop-cart-row .el-radio-button__inner {
  358. display: flex;
  359. width: 42px;
  360. height: 42px;
  361. align-items: center;
  362. justify-content: center;
  363. background-color: transparent;
  364. padding: 0;
  365. }
  366. .shop-cart-row {
  367. margin-bottom: 20px;
  368. }
  369. .clear-diy-style .com-pick-link-content {
  370. width: 100%;
  371. }
  372. .course-style .show-content .el-color-picker {
  373. height: 30px;
  374. }
  375. .course-style .el-checkbox {
  376. width: 100px;
  377. }
  378. /* 修改element基础样式 */
  379. .course-style .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  380. background-color: transparent;
  381. }
  382. </style>