Index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. <template>
  2. <page-meta :root-font-size="fontSize+'px'"></page-meta>
  3. <home-base :show="editablePage && editablePage.editable_page_theme_config && editablePage.editable_page_theme_config.if_show_footer==1">
  4. <view class="div container" :style="pageStyle">
  5. <view class="div" v-for='(editablePageConfig,key) in editablePageConfigList' :key="key">
  6. <model1 v-if='editablePageConfig.editable_page_model_id==1'
  7. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model1>
  8. <model2 v-if='editablePageConfig.editable_page_model_id==2'
  9. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model2>
  10. <model6 v-if='editablePageConfig.editable_page_model_id==6'
  11. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model6>
  12. <model12 v-if='editablePageConfig.editable_page_model_id==12'
  13. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model12>
  14. <model13 v-if='editablePageConfig.editable_page_model_id==13'
  15. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model13>
  16. <model14 v-if='editablePageConfig.editable_page_model_id==14'
  17. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model14>
  18. <model15 v-if='editablePageConfig.editable_page_model_id==15'
  19. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model15>
  20. <model16 v-if='editablePageConfig.editable_page_model_id==16'
  21. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model16>
  22. <model17 v-if='editablePageConfig.editable_page_model_id==17'
  23. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model17>
  24. <model18 v-if='editablePageConfig.editable_page_model_id==18'
  25. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model18>
  26. <model19 v-if='editablePageConfig.editable_page_model_id==19'
  27. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model19>
  28. <model20 v-if='editablePageConfig.editable_page_model_id==20'
  29. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model20>
  30. <model21 v-if='editablePageConfig.editable_page_model_id==21'
  31. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model21>
  32. <model22 v-if='editablePageConfig.editable_page_model_id==22'
  33. v-bind:editablePageConfig="editablePageConfig" v-bind:editablePage="editablePage"></model22>
  34. </view>
  35. <uni-popup ref="isshow" :mask-click="false">
  36. <view class="jump-adv">
  37. <image mode="aspectFit" class="jump-adv-image" :src="showimage">
  38. <view class="jump-adv-button iconfont" @click="closeAdv()">&#xe65a;</view>
  39. </view>
  40. </uni-popup>
  41. <view
  42. v-if="editablePage && editablePage.editable_page_theme_config && editablePage.editable_page_theme_config.if_show_button==1"
  43. class="float-button" :style="floatButtonStyle">
  44. <image class="img" mode="aspectFit" :src="editablePage.editable_page_theme_config.button_image" />
  45. </view>
  46. </view>
  47. </home-base>
  48. </template>
  49. <script>
  50. import {
  51. getFontSize
  52. } from '@/util/common'
  53. import HomeBase from '../HomeBase'
  54. import {
  55. mapState,
  56. mapMutations
  57. } from 'vuex'
  58. import HomeCommonSearch from '../common/HomeCommonSearch'
  59. import {
  60. getEditablePageConfigList
  61. } from '../../../api/homeindex'
  62. import Model1 from './editable_page_model/Model1'
  63. import Model2 from './editable_page_model/Model2'
  64. import Model6 from './editable_page_model/Model6'
  65. import Model12 from './editable_page_model/Model12'
  66. import Model13 from './editable_page_model/Model13'
  67. import Model14 from './editable_page_model/Model14'
  68. import Model15 from './editable_page_model/Model15'
  69. import Model16 from './editable_page_model/Model16'
  70. import Model17 from './editable_page_model/Model17'
  71. import Model18 from './editable_page_model/Model18'
  72. import Model19 from './editable_page_model/Model19'
  73. import Model20 from './editable_page_model/Model20'
  74. import Model21 from './editable_page_model/Model21'
  75. import Model22 from './editable_page_model/Model22'
  76. export default {
  77. name: 'SpecialIndex',
  78. data() {
  79. return {
  80. special_id:0,
  81. floatButtonStyle: {},
  82. showimage: '',
  83. pageStyle: {},
  84. editablePage: {},
  85. editablePageConfigList: []
  86. }
  87. },
  88. props: ['pagePath', 'itemId'],
  89. components: {
  90. HomeBase,
  91. HomeCommonSearch,
  92. Model1,
  93. Model2,
  94. Model6,
  95. Model12,
  96. Model13,
  97. Model14,
  98. Model15,
  99. Model16,
  100. Model17,
  101. Model18,
  102. Model19,
  103. Model20,
  104. Model21,
  105. Model22
  106. },
  107. computed: {
  108. fontSize() {
  109. return getFontSize()
  110. },
  111. ...mapState({
  112. special: state => state.home.special,
  113. closePopupAdv: state => state.home.closePopupAdv,
  114. }),
  115. },
  116. mounted() {
  117. getEditablePageConfigList(this.special_id, this.pagePath, this.itemId).then(res => {
  118. this.editablePage = res.result.editable_page
  119. this.editablePageConfigList = res.result.editable_page_config_list
  120. if (this.pagePath) {
  121. this.saveHomeSpecial({
  122. pagePath: this.pagePath,
  123. storeId: '',
  124. itemId: this.itemId,
  125. editablePage: this.editablePage,
  126. editablePageConfigList: this.editablePageConfigList
  127. })
  128. }
  129. if (this.editablePage) {
  130. this.pageStyle = {
  131. backgroundColor: this.editablePage.editable_page_theme_config.back_color,
  132. paddingLeft: this.editablePage.editable_page_theme_config.page_margin + 'px',
  133. paddingRight: this.editablePage.editable_page_theme_config.page_margin + 'px',
  134. paddingBottom: (this.editablePage['editable_page_theme_config'][
  135. 'if_show_footer'] == 1 ? 60 : 0) + 'px',
  136. backgroundImage: 'url(' + this.editablePage.editable_page_theme_config.back_image +
  137. ')'
  138. }
  139. uni.setNavigationBarTitle({
  140. title: this.editablePage.editable_page_name
  141. })
  142. if (this.editablePage.editable_page_theme_config.if_show_jump == 1 && this.editablePage
  143. .editable_page_theme_config.jump_image) {
  144. this.showimage = this.editablePage.editable_page_theme_config.jump_image
  145. if (!this.closePopupAdv) {
  146. this.showPopup('isshow')
  147. }
  148. }
  149. var inset
  150. switch (this.editablePage.editable_page_theme_config.button_position) {
  151. case '1':
  152. inset = this.editablePage.editable_page_theme_config.button_margin +
  153. 'px auto auto 0px'
  154. break
  155. case '2':
  156. inset = this.editablePage.editable_page_theme_config.button_margin +
  157. 'px 0px auto auto'
  158. break
  159. case '3':
  160. inset = 'auto auto ' + this.editablePage.editable_page_theme_config.button_margin +
  161. 'px 0px'
  162. break
  163. case '4':
  164. inset = 'auto 0px ' + this.editablePage.editable_page_theme_config.button_margin +
  165. 'px auto'
  166. break
  167. }
  168. this.floatButtonStyle = {
  169. inset: inset,
  170. paddingLeft: this.editablePage.editable_page_theme_config.page_margin + 'px',
  171. paddingRight: this.editablePage.editable_page_theme_config.page_margin + 'px'
  172. }
  173. }
  174. }).catch(function(error) {
  175. uni.showToast({
  176. icon: 'none',
  177. title: error.message
  178. })
  179. })
  180. },
  181. onLoad: function(option) {
  182. this.special_id = option.special_id
  183. if (!this.special_id && !this.pagePath) {
  184. uni.showToast({
  185. icon: 'none',
  186. title: '缺少参数'
  187. })
  188. }
  189. },
  190. methods: {
  191. ...mapMutations({
  192. saveHomeSpecial: 'saveHomeSpecial',
  193. saveClosePopupAdv: 'saveClosePopupAdv'
  194. }),
  195. showPopup(id) {
  196. this.$refs[id].open()
  197. },
  198. hidePopup(id) {
  199. this.$refs[id].close()
  200. },
  201. closeAdv() {
  202. this.hidePopup('isshow')
  203. this.saveClosePopupAdv({
  204. closePopupAdv: true
  205. })
  206. },
  207. }
  208. }
  209. </script>
  210. <style scoped lang="scss">
  211. .container {
  212. background-repeat: no-repeat;
  213. background-size: 100%;
  214. }
  215. .jump-adv {
  216. position: relative;
  217. }
  218. .jump-adv-image {
  219. max-width: 100%;
  220. }
  221. .jump-adv-button {
  222. position: absolute;
  223. top: 0;
  224. right: 0;
  225. width: 20px;
  226. height: 20px;
  227. line-height: 20px;
  228. border-radius: 20px;
  229. text-align: center;
  230. background-color: rgba(255, 255, 255, .5);
  231. cursor: pointer;
  232. }
  233. .float-button {
  234. position: fixed;
  235. z-index: 2;
  236. }
  237. .float-button .img {
  238. width: 40px;
  239. height: 40px;
  240. }
  241. </style>