index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view :class="[AppTheme]" :data-key="uikey" :data-theme="template">
  3. <Utitle v-if="component && uikey=='U_title'" :styles="styles" :datas="datas">
  4. </Utitle>
  5. <Ublank v-else-if="component && uikey=='U_blank'" :styles="styles" :datas="datas">
  6. </Ublank>
  7. <Uline v-else-if="component && uikey=='U_line'" :styles="styles" :datas="datas">
  8. </Uline>
  9. <Urichtext v-else-if="component && uikey=='U_richtext'" :styles="styles" :datas="datas">
  10. </Urichtext>
  11. <Ucube v-else-if="component && uikey=='U_cube'" :styles="styles" :datas="datas">
  12. </Ucube>
  13. <Usimplegraph v-else-if="component && uikey=='U_simplegraph'" :styles="styles" :datas="datas">
  14. </Usimplegraph>
  15. <Uvideo v-else-if="component && uikey=='U_video'" :styles="styles" :datas="datas">
  16. </Uvideo>
  17. <Uslideshow ref="slideshow" v-else-if="component && uikey=='U_slideshow'" :styles="styles" :datas="datas">
  18. </Uslideshow>
  19. <Ubutton v-else-if="component && uikey=='U_button'" :styles="styles" :datas="datas">
  20. </Ubutton>
  21. <Ususpendbutton v-else-if="component && uikey=='U_suspendbutton'" :styles="styles" :datas="datas">
  22. </Ususpendbutton>
  23. <Ubull v-else-if="component && uikey=='U_bull'" :styles="styles" :datas="datas">
  24. </Ubull>
  25. <Uactivity v-else-if="component && uikey=='U_activity'" :styles="styles" :datas="datas">
  26. </Uactivity>
  27. <Umonitor v-else-if="component && uikey=='U_monitor'" :styles="styles" :datas="datas">
  28. </Umonitor>
  29. <Uadopt v-else-if="component && uikey=='U_adopt'" :styles="styles" :datas="datas">
  30. </Uadopt>
  31. <Uland v-else-if="component && uikey=='U_land'" :styles="styles" :datas="datas">
  32. </Uland>
  33. <Ucoupon v-else-if="component && uikey=='U_coupon'" :styles="styles" :datas="datas">
  34. </Ucoupon>
  35. <Ugoods v-else-if="component && uikey=='U_goods'" :styles="styles" :datas="datas">
  36. </Ugoods>
  37. <Ugoods2 ref="goodlist" v-else-if="component && uikey=='U_goods2'" :styles="styles" :datas="datas">
  38. </Ugoods2>
  39. <Unavbar v-else-if="component && uikey=='U_navbar'" :styles="styles" :datas="datas">
  40. </Unavbar>
  41. <Useckill v-else-if="component && uikey=='U_seckill'" :styles="styles" :datas="datas">
  42. </Useckill>
  43. <Upublic v-else-if="component && uikey=='U_public'" :styles="styles" :datas="datas">
  44. </Upublic>
  45. <Uweather v-else-if="component && uikey=='U_weather'" :styles="styles" :datas="datas">
  46. </Uweather>
  47. </view>
  48. </template>
  49. <script>
  50. // 加载失败的组件
  51. import ErrorComponent from './load-error.vue';
  52. // import defaultGoods from '@/resource/images/default-goods.png';
  53. // 默认的商品数据
  54. const default_goods_item = {
  55. // goods_sn: "269004202",
  56. // goods_title: "Asymmetric Striped Slit Shirt Dress - Dark Gree",
  57. // goods_img: defaultGoods,
  58. tsk_price: 9.99, // 秒杀价格
  59. shop_price: 9.99, // 销售价
  60. market_price: 19.99, // 市场价
  61. discount: 50,
  62. promotions: [
  63. '<span>BUY <em class="special fb">1</em> GET 1 <em class="special fb ml5" data-orgp="">99%</em> OFF</span>',
  64. '<span>BUY <em class="special fb">1</em> GET 1 <em class="special fb ml5" data-orgp="">99%</em> OFF</span>'
  65. ]
  66. };
  67. // 默认的商品数据列表
  68. const default_goods_list = [
  69. default_goods_item,
  70. default_goods_item,
  71. default_goods_item,
  72. default_goods_item
  73. ];
  74. import Unavbar from '@/components/ui-component/U_navbar/m/index.vue';
  75. import Utitle from '@/components/ui-component/U_title/m/index.vue';
  76. import Uslideshow from '@/components/ui-component/U_slideshow/m/index.vue';
  77. import Ubutton from '@/components/ui-component/U_button/m/index.vue';
  78. import Ublank from '@/components/ui-component/U_blank/m/index.vue';
  79. import Uline from '@/components/ui-component/U_line/m/index.vue';
  80. import Urichtext from '@/components/ui-component/U_richtext/m/index.vue';
  81. import Ucube from '@/components/ui-component/U_cube/m/index.vue';
  82. import Usimplegraph from '@/components/ui-component/U_simplegraph/m/index.vue';
  83. import Uvideo from '@/components/ui-component/U_video/m/index.vue';
  84. import Ubull from '@/components/ui-component/U_bull/m/index.vue';
  85. import Umonitor from '@/components/ui-component/U_monitor/m/index.vue';
  86. import Uland from '@/components/ui-component/U_land/m/index.vue';
  87. import Uadopt from '@/components/ui-component/U_adopt/m/index.vue';
  88. import Ugoods from '@/components/ui-component/U_goods/m/index.vue';
  89. import Ugoods2 from '@/components/ui-component/U_goods2/m/index.vue';
  90. import Uactivity from '@/components/ui-component/U_activity/m/index.vue';
  91. import Ucoupon from '@/components/ui-component/U_coupon/m/index.vue';
  92. import Uweather from '@/components/ui-component/U_weather/m/index.vue';
  93. import Upublic from '@/components/ui-component/U_public/m/index.vue';
  94. import Useckill from '@/components/ui-component/U_seckill/m/index.vue';
  95. export default {
  96. props: {
  97. // 组件KEY
  98. uikey: {
  99. type: String,
  100. required: true,
  101. default: 'U000001',
  102. },
  103. // 模版名
  104. template: {
  105. type: String,
  106. required: true,
  107. default: 'template1'
  108. },
  109. vdc: {
  110. type: Object
  111. }
  112. },
  113. components: {
  114. Unavbar,
  115. Ugoods2,
  116. Utitle,
  117. Uslideshow,
  118. Ubutton,
  119. Ublank,
  120. Uline,
  121. Urichtext,
  122. Ucube,
  123. Usimplegraph,
  124. Uvideo,
  125. Ubull,
  126. Umonitor,
  127. Uland,
  128. Uadopt,
  129. Ugoods,
  130. Uactivity,
  131. Ucoupon,
  132. Uweather,
  133. Upublic,
  134. Useckill,
  135. ErrorComponent
  136. },
  137. data() {
  138. return {
  139. };
  140. },
  141. computed: {
  142. // 当前环境, 1=装修页, 2=预览, 3=发布
  143. env() {
  144. return this.$store.state.page.env;
  145. },
  146. // 当前组件信息
  147. component() {
  148. return this.vdc;
  149. },
  150. // 功能数据
  151. datas() {
  152. // 如果有配置项的话
  153. if (this.component.is_loaded_config && this.component.hasOwnProperty('config')) {
  154. const datas = {};
  155. Object.keys(this.component.config.datas).map(key => {
  156. datas[key] = this.component.config.datas[key].value;
  157. });
  158. return datas;
  159. } else {
  160. return this.component.remote_data || {};
  161. }
  162. },
  163. // 样式数据
  164. styles() {
  165. // 如果有配置项的话
  166. if (this.component.is_loaded_config && this.component.hasOwnProperty('config')) {
  167. const styles = {};
  168. Object.keys(this.component.config.styles).map(key => {
  169. styles[key] = this.component.config.styles[key].value;
  170. });
  171. return styles;
  172. } else {
  173. return this.component.remote_style || {};
  174. }
  175. },
  176. },
  177. methods: {
  178. toBottom(type) {
  179. let that = this
  180. that.$refs.goodlist.toBottom(type)
  181. },
  182. init() {
  183. let that = this
  184. if (that.$refs.slideshow) {
  185. that.$refs.slideshow.init()
  186. }
  187. },
  188. },
  189. };
  190. </script>
  191. <style scoped>
  192. .custom-transition .lazy-component-enter {
  193. opacity: 0;
  194. }
  195. .custom-transition .lazy-component-enter-to {
  196. opacity: 1;
  197. }
  198. .custom-transition .lazy-component-enter-active {
  199. transition: all 0.5s;
  200. }
  201. .custom-transition .lazy-component-leave {
  202. opacity: 1;
  203. }
  204. .custom-transition .lazy-component-leave-to {
  205. opacity: 0;
  206. }
  207. .custom-transition .lazy-component-leave-active {
  208. transition: all 0.5s;
  209. }
  210. </style>