pageTitle.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div class="box">
  3. <div class="c_row-item" v-if="this.$route.query.type !== 2">
  4. <el-col class="label" :span="4"> 模板名称 </el-col>
  5. <el-col :span="19" class="slider-box">
  6. <el-input v-model="name" placeholder="选填不超过15个字" maxlength="15" @change="changName" />
  7. </el-col>
  8. </div>
  9. <div class="c_row-item">
  10. <el-col class="label" :span="4"> 页面标题 </el-col>
  11. <el-col :span="19" class="slider-box">
  12. <el-input v-model="value" placeholder="选填不超过30个字" maxlength="30" @change="changVal" />
  13. </el-col>
  14. </div>
  15. <div class="c_row-item">
  16. <el-col class="label" :span="4"> 页面状态 </el-col>
  17. <el-col :span="19" class="slider-box">
  18. <el-switch :active-value="1" :inactive-value="0" v-model="isShow" @change="changeState" />
  19. </el-col>
  20. </div>
  21. <div class="c_row-item acea-row row-top">
  22. <el-col class="label" :span="4"> 背景设置 </el-col>
  23. <el-col :span="19" class="slider-box">
  24. <div class="acea-row row-between row-top color">
  25. <el-checkbox v-model="bgColor" @change="bgColorTap">背景色</el-checkbox>
  26. <el-color-picker v-model="colorPicker" @change="colorPickerTap(colorPicker)"></el-color-picker>
  27. </div>
  28. <div class="acea-row row-between row-top color">
  29. <el-checkbox v-model="bgPic" @change="bgPicTap">背景图</el-checkbox>
  30. <el-radio-group v-model="tabVal" type="button" @change="radioTap">
  31. <el-radio-button :label="index" v-for="(item, index) in picList" :key="index">
  32. <span class="iconfont-diy" :class="item"></span>
  33. </el-radio-button>
  34. </el-radio-group>
  35. </div>
  36. <div v-if="bgPic">
  37. <div class="title">建议尺寸:690 * 240px</div>
  38. <div class="boxs" @click="modalPicTap('单选')">
  39. <img :src="bgPicUrl" alt="" v-if="bgPicUrl" />
  40. <div class="upload-box" v-else>
  41. <Icon type="ios-camera-outline" size="36" />
  42. </div>
  43. <div class="replace" v-if="bgPicUrl">更换图片</div>
  44. <!--<span class="iconfont-diy icondel_1" @click.stop="bindDelete" v-if="bgPicUrl"></span>-->
  45. </div>
  46. </div>
  47. </el-col>
  48. </div>
  49. <div>
  50. <el-dialog :visible.sync="modalPic" width="950px" title="上传背景图" :close-on-click-modal="false" :z-index="1">
  51. <uploadPictures
  52. :isChoice="isChoice"
  53. @getPic="getPic"
  54. :gridBtn="gridBtn"
  55. :gridPic="gridPic"
  56. v-if="modalPic"
  57. ></uploadPictures>
  58. </el-dialog>
  59. </div>
  60. </div>
  61. </template>
  62. <script>
  63. import { mapState } from 'vuex';
  64. import uploadPictures from '@/components/uploadPictures';
  65. export default {
  66. name: 'pageTitle',
  67. components: {
  68. uploadPictures,
  69. },
  70. data() {
  71. return {
  72. value: '',
  73. name: '',
  74. isShow: true,
  75. picList: ['icondantu', 'iconpingpu', 'iconlashen'],
  76. bgColor: false,
  77. bgPic: false,
  78. tabVal: 0,
  79. colorPicker: '#f5f5f5',
  80. modalPic: false,
  81. isChoice: '单选',
  82. gridBtn: {
  83. xl: 4,
  84. lg: 8,
  85. md: 8,
  86. sm: 8,
  87. xs: 8,
  88. },
  89. gridPic: {
  90. xl: 6,
  91. lg: 8,
  92. md: 12,
  93. sm: 12,
  94. xs: 12,
  95. },
  96. bgPicUrl: '',
  97. };
  98. },
  99. created() {
  100. let state = this.$store.state.mobildConfig;
  101. this.value = state.pageTitle;
  102. this.name = state.pageName;
  103. this.isShow = state.pageShow ? true : false;
  104. this.bgColor = state.pageColor ? true : false;
  105. this.bgPic = state.pagePic ? true : false;
  106. this.colorPicker = state.pageColorPicker;
  107. this.tabVal = state.pageTabVal;
  108. this.bgPicUrl = state.pagePicUrl;
  109. },
  110. methods: {
  111. // 点击图文封面
  112. modalPicTap(title) {
  113. this.modalPic = true;
  114. },
  115. bindDelete() {
  116. this.bgPicUrl = '';
  117. },
  118. getPic(pc) {
  119. this.$nextTick(() => {
  120. this.bgPicUrl = pc.att_dir;
  121. this.modalPic = false;
  122. this.$store.commit('mobildConfig/UPPICURL', pc.att_dir);
  123. });
  124. },
  125. colorPickerTap(colorPicker) {
  126. this.$store.commit('mobildConfig/UPPICKER', colorPicker);
  127. },
  128. radioTap(val) {
  129. this.$store.commit('mobildConfig/UPRADIO', val);
  130. },
  131. changVal(val) {
  132. this.$store.commit('mobildConfig/UPTITLE', val.target.value);
  133. },
  134. changName(val) {
  135. this.$store.commit('mobildConfig/UPNAME', val.target.value);
  136. },
  137. changeState(val) {
  138. this.$store.commit('mobildConfig/UPSHOW', val);
  139. },
  140. bgColorTap(val) {
  141. this.$store.commit('mobildConfig/UPCOLOR', val);
  142. },
  143. bgPicTap(val) {
  144. this.$store.commit('mobildConfig/UPPIC', val);
  145. },
  146. },
  147. };
  148. </script>
  149. <style scoped lang="stylus">
  150. .upload-box {
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. width: 60px;
  155. height: 60px;
  156. background: #ccc;
  157. }
  158. /deep/.ivu-input {
  159. font-size: 13px !important;
  160. }
  161. .slider-box .title {
  162. color: #999999;
  163. font-size: 13px;
  164. margin-bottom: 5px;
  165. }
  166. .c_row-item {
  167. padding: 0 15px;
  168. margin-top: 22px;
  169. }
  170. .slider-box .color {
  171. margin-bottom: 15px;
  172. }
  173. .boxs {
  174. width: 60px;
  175. height: 60px;
  176. margin-bottom: 10px;
  177. position: relative;
  178. .replace {
  179. background: rgba(0, 0, 0, 0.4);
  180. border-radius: 0 0 6px 6px;
  181. position: absolute;
  182. bottom: 0;
  183. left: 0;
  184. width: 100%;
  185. color: #fff;
  186. font-size: 12px;
  187. text-align: center;
  188. height: 24px;
  189. line-height: 24px;
  190. }
  191. .iconfont-diy {
  192. position: absolute;
  193. top: -15px;
  194. right: -8px;
  195. font-size: 25px;
  196. color: #999;
  197. }
  198. img {
  199. width: 100%;
  200. height: 100%;
  201. border-radius: 6px;
  202. }
  203. }
  204. .ivu-color-picker /deep/ .ivu-select-dropdown {
  205. position: absolute;
  206. // width: 300px !important;
  207. left: 34px !important;
  208. }
  209. </style>