preview.php 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template id="nav-preview">
  2. <div :class="{abso: activeItem.data.styleChoose == 2}">
  3. <!-- 导航栏丢到这 - 每个页面固定有这个 -->
  4. <div class="nav-preview" :style="containStyle">
  5. <div class="nav-contain flex" :style="containStyle1">
  6. <div class="nav-cont-title over1" :style="[titleStyle]" v-if="isShowName">
  7. <img v-if="contentType" :src="src" alt="" style="display:block;max-width: 112px; height:30px">
  8. <span v-else>{{activeItem.data.name || "标题"}}</span>
  9. </div>
  10. <!-- <div v-if="searchSwitch" class="search-input over1" :style="serachStyle">
  11. <i class="search-icon el-icon-search" :style="iconStyle"></i>
  12. <span class="over1">{{activeItem.data.placeholder || '请输入描述'}}</span>
  13. </div> -->
  14. <!-- <div v-if="searchSwitch" style="width: 98px;order: 2"></div> -->
  15. </div>
  16. <img class="mp-icon" :src="topStatusBar.bg1">
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. Vue.component('nav-preview', {
  22. name: "nav-preview",
  23. props: {
  24. activeItem: {
  25. type: Object,
  26. default () {
  27. return {}
  28. }
  29. },
  30. mainPage: {
  31. type: Object,
  32. default () {
  33. return {}
  34. }
  35. },
  36. },
  37. template: '#nav-preview',
  38. computed: {
  39. containStyle1() {
  40. var positionChoose = this.activeItem.data.positionChoose || 0
  41. var result = {}
  42. if (!this.searchSwitch) {
  43. result['justify-content'] = positionChoose == 0 ? 'flex-start' : 'center';
  44. }
  45. return result
  46. },
  47. contentType() {
  48. const contentType = this.activeItem.data.contentType
  49. return contentType == 2
  50. },
  51. containStyle() {
  52. const rgbaColor = this.activeItem.computedStyle.statusBarColor
  53. return {
  54. backgroundColor: rgbaColor
  55. }
  56. },
  57. topStatusBar() {
  58. const rgbaColor = this.activeItem.computedStyle.statusBarColor
  59. var type = rgbaColor ? getContrastYIQ(rgbaColor) : 'light'
  60. var result = {
  61. light: {
  62. bg: `url("resources/img/decorate/nav/light1.png") no-repeat`,
  63. bg1: `resources/img/decorate/nav/light2.png`
  64. },
  65. dark: {
  66. bg: `url("resources/img/decorate/nav/dark1.png") no-repeat`,
  67. bg1: `resources/img/decorate/nav/dark2.png`
  68. }
  69. }
  70. return result[type]
  71. },
  72. titleStyle() {
  73. var style = this.activeItem.computedStyle.titleDistance || {}
  74. var color = this.activeItem.computedStyle.statusBar == 1 ? "#000" : "#fff"
  75. var order = this.activeItem.data.positionChoose || 0
  76. var positionChoose = this.activeItem.data.positionChoose || 0
  77. var result = {
  78. color,
  79. order,
  80. background: this.activeItem.computedStyle.titleBgColor,
  81. fontSize: `${style.fontSize || 14}px`,
  82. height: `${style.height || 0}px`,
  83. lineHeight: `${style.height || 0}px`,
  84. }
  85. console.log(positionChoose, 'positionChoose')
  86. if (positionChoose == 1) {} else {
  87. result.marginRight = "10px"
  88. }
  89. return result
  90. },
  91. serachStyle() {
  92. var borderType = {
  93. 1: "none",
  94. 2: "1px solid #000",
  95. 3: "2px solid #000"
  96. }
  97. var borderRadiusType = {
  98. 1: "30px",
  99. 2: "0"
  100. }
  101. var textAlignType = {
  102. 1: "flex-start",
  103. 2: "center",
  104. 3: "flex-end"
  105. }
  106. var style = this.activeItem.computedStyle.searchDistance || {}
  107. var color = this.activeItem.computedStyle.searchColor
  108. var border = this.activeItem.computedStyle.border
  109. var borderStr = borderType[border]
  110. var searchMarPad = this.activeItem.computedStyle.searchMarPad || {}
  111. var borderRadius = this.activeItem.computedStyle.searchBorder
  112. var textAlign = textAlignType[this.activeItem.computedStyle.searchPosition]
  113. var positionChoose = this.activeItem.data.positionChoose || 0
  114. var result = {
  115. backgroundColor: this.activeItem.computedStyle.searchBgColor,
  116. fontSize: `${style.fontSize || 14}px`,
  117. height: `${style.height || 29}px`,
  118. borderRadius: `${borderRadiusType[borderRadius]}`,
  119. border: borderStr,
  120. justifyContent: textAlign,
  121. color,
  122. }
  123. if (positionChoose == 1) {
  124. result.width = '84px'
  125. } else {
  126. result.flex = '1'
  127. }
  128. return result
  129. },
  130. src() {
  131. return this.activeItem.data.logoSrc
  132. },
  133. icon() {
  134. var {
  135. icon
  136. } = this.activeItem.computedStyle
  137. if (icon && icon.key !== "text") {
  138. return icon
  139. }
  140. return false
  141. },
  142. iconStyle() {
  143. var style = this.activeItem.computedStyle.iconSize || {}
  144. return {
  145. width: `${style.size || 14}px`,
  146. height: `${style.size || 14}px`,
  147. }
  148. },
  149. searchSwitch() {
  150. return this.activeItem.data.isShowSearch == 1
  151. },
  152. isShowName() {
  153. return this.activeItem.data.isShowName == 1
  154. },
  155. },
  156. data() {
  157. return {}
  158. }
  159. });
  160. </script>
  161. <style>
  162. .nav-preview {
  163. position: relative;
  164. }
  165. .nav-contain {
  166. position: relative;
  167. box-sizing: border-box;
  168. height: 44px;
  169. padding: 0 10px;
  170. justify-content: space-between;
  171. align-items: center;
  172. flex: 1;
  173. }
  174. .nav-cont-title {
  175. display: flex;
  176. align-items: center;
  177. font-size: 16px;
  178. font-family: PingFang SC;
  179. font-weight: bold;
  180. color: #000000;
  181. text-align: center;
  182. }
  183. .flex {
  184. display: flex;
  185. }
  186. .flex-start {
  187. justify-content: flex-start;
  188. padding-left: 6px;
  189. }
  190. .mp-icon {
  191. position: absolute;
  192. top: 0;
  193. bottom: 0;
  194. margin: auto;
  195. right: 10px;
  196. width: 88px;
  197. z-index: 999;
  198. }
  199. .search-input {
  200. box-sizing: border-box;
  201. display: flex;
  202. align-items: center;
  203. width: 141px;
  204. background: #ddd;
  205. border-radius: 44px;
  206. padding: 0 10px;
  207. color: #fff;
  208. border: none;
  209. line-height: 1;
  210. font-size: 14px;
  211. }
  212. .search-icon {
  213. width: 14px;
  214. height: 14px;
  215. font-size: 16px;
  216. margin-right: 4px;
  217. }
  218. .search-center {
  219. left: 0;
  220. right: 0;
  221. }
  222. .title-img {
  223. width: 72px;
  224. height: 25px;
  225. background-color: #ddd;
  226. }
  227. .searchSwitch {
  228. display: flex;
  229. }
  230. .dp-nav-placeholder-icon {
  231. position: absolute;
  232. top: 44px;
  233. right: 0;
  234. width: 98px;
  235. height: 44px;
  236. z-index: 999;
  237. border-radius: 25px;
  238. z-index: 99;
  239. }
  240. .abso {
  241. position: absolute;
  242. width: 100%;
  243. box-sizing: border-box;
  244. z-index: 100;
  245. }
  246. </style>