Index.vue 9.2 KB

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