style.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template id="nav-style">
  2. <div class="fill-border-top nav-style">
  3. <diy-style-contain :show-title="false" :default-style="{}">
  4. <div class="diy-nav-tabs">
  5. <el-radio-group v-model="tabsNav" @change="onChange($event,'tabsNav')">
  6. <el-radio-button :label="item.value" v-for="(item,index) in tabsNavList" :key="index">{{item.label}}</el-radio-button>
  7. </el-radio-group>
  8. </div>
  9. </diy-style-contain>
  10. <div v-if="tabsNav == 2">
  11. <diy-main-page :main-page="mainPage" @change="mainPageChange" />
  12. </div>
  13. <div v-else-if="tabsNav == 3">
  14. <diy-share @change="shareChange" :default-data="defaultShareData"></diy-share>
  15. </div>
  16. <div v-else>
  17. <div>
  18. <diy-style-contain title="标题">
  19. <div class="flex flex-y-center flex-x-sw gutter-bot-10">
  20. <div class="second-level">内容形式</div>
  21. <el-radio-group v-model="contentType" @change="onChangeData($event,'contentType')">
  22. <el-radio-button :label="item.value" v-for="(item,index) in contentTypeList" :key="index">{{item.label}}</el-radio-button>
  23. </el-radio-group>
  24. </div>
  25. <div v-if="contentType == 1" class="flex flex-y-center flex-x-sw flex-x-sw gutter-bot-10">
  26. <div class="second-level"> </div>
  27. <el-input class="name-input" v-model="name" size="small" placeholder="请输入商城名称" @input="onChangeData($event,'name')" :maxlength="10" show-word-limit />
  28. </div>
  29. <div v-else class="flex flex-y-center flex-x-sw gutter-bot-10">
  30. <div class="second-level"> </div>
  31. <div style="height:88px;background: #ddd">
  32. <diy-img-setting :img-infos="imageUrl" def-img-count="1" :show-url="false" :suggest-site="2" suggest-size-text="建议 112x30" :img-contain-style="{padding: 0}" :show-title="false" @change="addIconImg($event,'logoSrc')"></diy-img-setting>
  33. </div>
  34. </div>
  35. <div class="flex flex-y-center flex-x-sw">
  36. <div class="second-level">位置选择</div>
  37. <el-radio-group v-model="positionChoose" @change="onChangeData($event,'positionChoose')">
  38. <el-radio-button :label="item.value" v-for="(item,index) in positionChooseList" :key="index">{{item.label}}</el-radio-button>
  39. </el-radio-group>
  40. </div>
  41. </diy-style-contain>
  42. <diy-style-contain title="风格">
  43. <div class="flex flex-y-center flex-x-sw">
  44. <div class="second-level">风格选择</div>
  45. <el-radio-group v-model="styleChoose" @change="onChangeData($event,'styleChoose')">
  46. <el-radio-button :label="item.value" v-for="(item,index) in styleChooseList" :key="index">{{item.label}}</el-radio-button>
  47. </el-radio-group>
  48. </div>
  49. </diy-style-contain>
  50. <diy-style-contain title="样式设置">
  51. <div class="flex flex-y-center flex-x-sw">
  52. <div class="second-level">文字颜色</div>
  53. <el-radio-group v-model="statusBar" @change="onChange($event,'statusBar')">
  54. <el-radio-button :label="item.value" v-for="(item,index) in statusBarList" :key="index">{{item.label}}</el-radio-button>
  55. </el-radio-group>
  56. </div>
  57. <diy-color :contain-obj="containObj" :color-infos="defaultForm.statusBarColor" @chang="updateColor($event,'statusBarColor')" style="padding: 0"></diy-color>
  58. </diy-style-contain>
  59. </div>
  60. </div>
  61. </div>
  62. </template>
  63. <script>
  64. Vue.component('nav-style', {
  65. name: "nav-style",
  66. template: '#nav-style',
  67. props: {
  68. activeItem: {
  69. type: Object,
  70. default () {
  71. return {}
  72. }
  73. },
  74. },
  75. data() {
  76. return {
  77. styleChoose: 1,
  78. styleChooseList:[{
  79. label: "标准",
  80. value: "1"
  81. }, {
  82. label: "沉浸式",
  83. value: "2"
  84. }],
  85. contentType: 1,
  86. contentTypeList: [{
  87. label: "文字",
  88. value: "1"
  89. }, {
  90. label: "图片",
  91. value: "2"
  92. }],
  93. // defaultShareData: null,
  94. imageUrl: [],
  95. imageUrl1: [],
  96. containObj: {
  97. showTitle: false
  98. },
  99. tabsNav: 1,
  100. tabsNavList: [{
  101. label: "导航设置",
  102. value: "1"
  103. }, {
  104. label: "页面设置",
  105. value: "2"
  106. }, {
  107. label: "分享配置",
  108. value: "3"
  109. }],
  110. statusBar: -1,
  111. statusBarList: [{
  112. label: "黑色",
  113. value: "1"
  114. }, {
  115. label: "白色",
  116. value: "2"
  117. }],
  118. isShowName: -1,
  119. nameList: [{
  120. label: "是",
  121. value: "1"
  122. }, {
  123. label: "否",
  124. value: "2"
  125. }],
  126. positionChoose: 0,
  127. positionChooseList: [{
  128. label: "居左",
  129. value: "0"
  130. }, {
  131. label: "居中",
  132. value: "1"
  133. }],
  134. border: -1,
  135. borderList: [{
  136. label: "无",
  137. value: "1"
  138. }, {
  139. label: "细",
  140. value: "2"
  141. }, {
  142. label: "粗",
  143. value: "3"
  144. }],
  145. icon: -1,
  146. iconList: [{
  147. label: "icon1",
  148. value: "1",
  149. key: "text",
  150. text: "隐藏"
  151. }, {
  152. label: "icon2",
  153. value: "2",
  154. key: "src",
  155. src: "resources/img/decorate/search1.png",
  156. width: 12,
  157. height: 12
  158. }, {
  159. label: "icon3",
  160. value: "3",
  161. key: "src",
  162. src: "resources/img/decorate/search3.png",
  163. width: 18,
  164. height: 15
  165. }],
  166. searchBorder: -1,
  167. searchBorderList: [{
  168. label: "圆角",
  169. value: "1"
  170. }, {
  171. label: "直角",
  172. value: "2"
  173. }],
  174. name: "",
  175. // placeholder: "",
  176. defaultForm: {
  177. // 商城名称
  178. titleBgColor: [{
  179. name: '底部背景', //名字
  180. color: "transparent", //颜色
  181. showAlpha: false, //是否开启透明度
  182. }, ],
  183. titleDistance: [{
  184. name: '文字大小', //名字
  185. value: 16, //值
  186. unit: "px", //单位
  187. disabled: false, //是否禁用
  188. maxValue: 20,
  189. }, {
  190. name: '高度', //名字
  191. value: 0, //值
  192. unit: "px", //单位
  193. disabled: false, //是否禁用
  194. maxValue: 44,
  195. }, {
  196. name: '宽度', //名字
  197. value: 50, //值
  198. unit: "px", //单位
  199. disabled: false, //是否禁用
  200. maxValue: 200,
  201. }, {
  202. name: '左侧距离', //名字
  203. value: 20, //值
  204. unit: "px", //单位
  205. disabled: false, //是否禁用
  206. maxValue: 100,
  207. }],
  208. // 背景
  209. statusBarColor: [{
  210. name: '背景颜色', //名字
  211. color: "transparent", //颜色
  212. showAlpha: true, //是否开启透明度
  213. }, ],
  214. // 搜索
  215. searchColor: [{
  216. name: '文字颜色', //名字
  217. color: "transparent", //颜色
  218. showAlpha: false, //是否开启透明度
  219. }, {
  220. name: '背景颜色', //名字
  221. color: "transparent", //颜色
  222. showAlpha: true, //是否开启透明度
  223. }, ],
  224. searchDistance: [{
  225. name: '文字大小', //名字
  226. value: 0, //值
  227. unit: "px", //单位
  228. disabled: false, //是否禁用
  229. maxValue: 20,
  230. }, {
  231. name: '高度', //名字
  232. value: 29, //值
  233. unit: "px", //单位
  234. disabled: false, //是否禁用
  235. maxValue: 44,
  236. }],
  237. searchMarPad: [{
  238. name: '左侧距离', //名字
  239. value: 30, //值
  240. unit: "px", //单位
  241. disabled: false, //是否禁用
  242. maxValue: 200,
  243. }, {
  244. name: '左内边距', //名字
  245. value: 0, //值
  246. unit: "px", //单位
  247. disabled: false, //是否禁用
  248. maxValue: 100,
  249. }],
  250. iconSize: [{
  251. name: '图标大小', //名字
  252. value: 0, //值
  253. unit: "px", //单位
  254. disabled: false, //是否禁用
  255. maxValue: 40,
  256. }],
  257. // 默认
  258. defColor: "transparent",
  259. },
  260. }
  261. },
  262. created() {
  263. if (PageShareData.pageIndex) {
  264. this.tabsNav = 2
  265. }
  266. this.$eventBus.$on("onPageClick", () => {
  267. this.tabsNav = 2
  268. })
  269. this.init()
  270. },
  271. destroyed() {
  272. PageShareData.pageIndex = false
  273. this.$eventBus.$off("onPageClick")
  274. },
  275. computed: {
  276. mainPage() {
  277. return this.activeItem.data.mainPage
  278. },
  279. defaultShareData() {
  280. return this.activeItem.data.share
  281. }
  282. },
  283. methods: {
  284. shareChange(e) {
  285. const result = {
  286. title: e[0].value,
  287. desc: e[1].value,
  288. appletImg: e[2].value,
  289. officialAccountImg: e[4].value
  290. }
  291. this.result.data.share = result;
  292. console.log(this.result.data)
  293. this.$emit("update", this.result);
  294. },
  295. mainPageChange(item) {
  296. this.result.data.mainPage = item;
  297. this.$emit("update", this.result);
  298. },
  299. // 图片
  300. addIconImg(arr, type) {
  301. this.imageUrl = arr
  302. this.updateUrl(arr, type)
  303. },
  304. addIconImg1(arr, type) {
  305. this.imageUrl1 = arr
  306. this.updateUrl(arr, type)
  307. },
  308. updateUrl(arr, type) {
  309. this.result.data[type] = arr[0].imgUrl;
  310. this.$emit("update", this.result);
  311. },
  312. setValue(key, value) {
  313. // 空值不做 赋值操作
  314. if (value) {
  315. this[key] = value
  316. }
  317. },
  318. init() {
  319. // 初始化 - 傻瓜式复制
  320. this.result = deepClone(this.activeItem)
  321. this.setValue("statusBar", this.result.computedStyle.statusBar)
  322. this.setValue("border", this.result.computedStyle.border)
  323. this.setValue("isShowName", this.result.data.isShowName)
  324. this.setValue("name", this.result.data.name)
  325. this.setValue("positionChoose", this.result.data.positionChoose)
  326. // this.setValue("defaultShareData", this.result.data.share)
  327. console.log(this.result.data, 'this.result.data')
  328. this.setValue("styleChoose", this.result.data.styleChoose)
  329. let a = ['computedStyle', 'icon', 'value']
  330. this.icon = getObjValue(this.result, a, 1)
  331. let arr = ['computedStyle', 'titleBgColor']
  332. this.defaultForm.titleBgColor = [{
  333. name: '底部背景', //名字
  334. color: getObjValue(this.result, arr, "transparent"), //颜色
  335. showAlpha: true, //是否开启透明度
  336. }, ]
  337. let arr1 = ['computedStyle', 'titleDistance', 'fontSize']
  338. let arr2 = ['computedStyle', 'titleDistance', 'height']
  339. let arr3 = ['computedStyle', 'titleDistance', 'width']
  340. let arr4 = ['computedStyle', 'titleDistance', 'marginLeft']
  341. this.defaultForm.titleDistance = [{
  342. name: '文字大小', //名字
  343. value: getObjValue(this.result, arr1, 16),
  344. unit: "px", //单位
  345. disabled: false, //是否禁用
  346. maxValue: 20,
  347. }, {
  348. name: '高度', //名字
  349. value: getObjValue(this.result, arr2, 0),
  350. unit: "px", //单位
  351. disabled: false, //是否禁用
  352. maxValue: 44,
  353. }, {
  354. name: '宽度', //名字
  355. value: getObjValue(this.result, arr3, 32),
  356. unit: "px", //单位
  357. disabled: false, //是否禁用
  358. maxValue: 200,
  359. }, {
  360. name: '左侧距离', //名字
  361. value: getObjValue(this.result, arr4, 20),
  362. unit: "px", //单位
  363. disabled: false, //是否禁用
  364. maxValue: 100,
  365. }]
  366. let arr6 = ['computedStyle', 'searchColor']
  367. let arr7 = ['computedStyle', 'searchBgColor']
  368. this.defaultForm.searchColor = [{
  369. name: '文字颜色', //名字
  370. color: getObjValue(this.result, arr6, "transparent"), //颜色
  371. showAlpha: false, //是否开启透明度
  372. }, {
  373. name: '背景颜色', //名字
  374. color: getObjValue(this.result, arr7, "transparent"), //颜色
  375. showAlpha: false, //是否开启透明度
  376. }, ]
  377. let arr8 = ['computedStyle', 'statusBarColor']
  378. this.defaultForm.statusBarColor = [{
  379. name: '背景颜色', //名字
  380. color: getObjValue(this.result, arr8, "transparent"),
  381. showAlpha: false, //是否开启透明度
  382. }, ]
  383. let arr9 = ['computedStyle', 'searchDistance', 'fontSize']
  384. let arr10 = ['computedStyle', 'searchDistance', 'height']
  385. this.defaultForm.searchDistance = [{
  386. name: '文字大小', //名字
  387. value: getObjValue(this.result, arr9, 16), //值
  388. unit: "px", //单位
  389. disabled: false, //是否禁用
  390. maxValue: 20,
  391. }, {
  392. name: '高度', //名字
  393. value: getObjValue(this.result, arr10, 29), //值
  394. unit: "px", //单位
  395. disabled: false, //是否禁用
  396. maxValue: 44,
  397. }]
  398. let arr11 = ['computedStyle', 'searchMarPad', 'marginLeft']
  399. let arr12 = ['computedStyle', 'searchMarPad', 'paddingLeft']
  400. this.defaultForm.searchMarPad = [{
  401. name: '左侧距离', //名字
  402. value: getObjValue(this.result, arr11, 20), //值
  403. unit: "px", //单位
  404. disabled: false, //是否禁用
  405. maxValue: 200,
  406. }, {
  407. name: '左内边距', //名字
  408. value: getObjValue(this.result, arr12, 0), //值
  409. unit: "px", //单位
  410. disabled: false, //是否禁用
  411. maxValue: 100,
  412. }]
  413. let arr13 = ['computedStyle', 'iconSize', 'size']
  414. this.defaultForm.iconSize = [{
  415. name: '图标大小', //名字
  416. value: getObjValue(this.result, arr13, 0), //值
  417. unit: "px", //单位
  418. disabled: false, //是否禁用
  419. maxValue: 40,
  420. }]
  421. // 图片
  422. this.imageUrl = []
  423. if (this.activeItem.data.logoSrc) {
  424. this.imageUrl.push({
  425. imgUrl: this.result.data.logoSrc
  426. })
  427. }
  428. this.imageUrl1 = []
  429. if (this.activeItem.data.backSrc) {
  430. this.imageUrl1.push({
  431. imgUrl: this.result.data.backSrc
  432. })
  433. }
  434. },
  435. /**
  436. * key对应属性名字
  437. */
  438. onChange(event, key) {
  439. if (key === 'icon') {
  440. this.result.computedStyle[key] = this.iconList.find(item => (item.value === event))
  441. } else {
  442. this.result.computedStyle[key] = event
  443. }
  444. this.$emit("update", this.result)
  445. },
  446. onChangeData(event, key) {
  447. this.result.data[key] = event
  448. this.$emit("update", this.result)
  449. },
  450. updateColor(e, type) { // 选择颜色
  451. const cb = {
  452. titleBgColor: () => {
  453. this.result.computedStyle.titleBgColor = e[0].color
  454. },
  455. statusBarColor: () => {
  456. this.result.computedStyle.statusBarColor = e[0].color
  457. },
  458. searchColor: () => {
  459. this.result.computedStyle.searchColor = e[0].color
  460. this.result.computedStyle.searchBgColor = e[1].color
  461. },
  462. }
  463. cb[type] && cb[type]()
  464. this.$emit("update", this.result)
  465. },
  466. sliderChange(arr, type) { // 边距
  467. const cb = {
  468. titleDistance: () => {
  469. var target = this.result.computedStyle.titleDistance || {}
  470. var result = {
  471. fontSize: arr[0].value,
  472. height: arr[1].value,
  473. width: arr[2].value,
  474. marginLeft: arr[3].value,
  475. }
  476. this.result.computedStyle.titleDistance = Object.assign({}, target, result)
  477. },
  478. searchDistance: () => {
  479. var target = this.result.computedStyle.searchDistance || {}
  480. var result = {
  481. fontSize: arr[0].value,
  482. height: arr[1].value,
  483. }
  484. this.result.computedStyle.searchDistance = Object.assign({}, target, result)
  485. },
  486. searchMarPad: () => {
  487. var target = this.result.computedStyle.searchMarPad || {}
  488. var result = {
  489. marginLeft: arr[0].value,
  490. paddingLeft: arr[1].value,
  491. }
  492. this.result.computedStyle.searchMarPad = Object.assign({}, target, result)
  493. },
  494. iconSize: () => {
  495. var target = this.result.computedStyle.iconSize || {}
  496. var result = {
  497. size: arr[0].value,
  498. }
  499. this.result.computedStyle.iconSize = Object.assign({}, target, result)
  500. },
  501. }
  502. cb[type] && cb[type]()
  503. this.$emit("update", this.result)
  504. },
  505. }
  506. });
  507. </script>
  508. <style>
  509. .flex {
  510. display: flex;
  511. }
  512. .flex-y-center {
  513. align-items: center;
  514. }
  515. .flex-x-sw {
  516. justify-content: space-between;
  517. }
  518. .gutter-2 {
  519. padding: 20px;
  520. }
  521. .gutter-bot-10 {
  522. margin-bottom: 20px;
  523. }
  524. .gutter-top-10 {
  525. margin-top: 20px;
  526. }
  527. .name-input {
  528. width: 169px;
  529. }
  530. .desc {
  531. padding: 0 20px;
  532. font-size: 13px;
  533. color: #CACACA;
  534. background-color: #fff;
  535. }
  536. .nav-style .diy-name {
  537. text-align: left;
  538. flex: 1;
  539. }
  540. .clear-diy-style .diy-style-contain {
  541. padding: 0;
  542. }
  543. .second-level {
  544. font-size: 14px;
  545. font-weight: bold;
  546. color: #999999;
  547. }
  548. .searchPosition .el-radio-button__inner {
  549. padding: 8px 10px;
  550. }
  551. .search-position-icon {
  552. padding: 0;
  553. width: 24px;
  554. }
  555. .iconList .el-radio-button__inner {
  556. padding: 6px 14px;
  557. }
  558. .flex {
  559. display: flex;
  560. }
  561. .flex-y-c {
  562. align-items: center;
  563. }
  564. /* 修改element样式 */
  565. .diy-nav-tabs .el-radio-group {
  566. width: 100%;
  567. }
  568. .diy-nav-tabs .el-radio-button {
  569. width: 33.33%;
  570. }
  571. .diy-nav-tabs .el-radio-button__inner {
  572. width: 100%;
  573. }
  574. .nav-style .el-radio-button__orig-radio:checked+.el-radio-button__inner {
  575. background-color: transparent;
  576. color: var(--diy-theme);
  577. border-color: var(--diy-theme);
  578. }
  579. </style>