金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.7 KiB

  1. <template>
  2. <view class="g-main" :style="{marginBottom: meta.margin_bottom + 'px',background: meta.background_color}">
  3. <view class="m-lead" style="margin-bottom: 5px" v-if="groupingData.length == 1">
  4. <view class="ul-box">
  5. <view class="li-box" @tap="_changeItem" :data-index="index" v-for="(item, index) in groupingData" :key="index" >
  6. <span>{{item.name}}</span>
  7. </view>
  8. </view>
  9. </view>
  10. <view class="grouping-tap-box" v-else>
  11. <view class="tap-item" :class="tapIndex == index ? 'active' : ''" @tap="_changeItem" :data-index="index" v-for="(item, index) in groupingData" :key="index">
  12. <span>{{item.name}}</span>
  13. </view>
  14. </view>
  15. <view class="m-content" :class="groupingData.length != 1 ? 'g-bg' : ''">
  16. <view class="m-main" v-if="goods_arr.type && goods_arr.type == 'micro_page_componet_goods_group'">
  17. <view class="goods_box" :data-id="item.associate.id" @tap="_jumpToDetail" v-for="(item, index) in goods_arr.children" :key="index" >
  18. <view class="goods_image">
  19. <image :src="item.associate.img"></image>
  20. </view>
  21. <view class="title">{{item.associate.name}}</view>
  22. <view class="price"> {{item.associate.sell_price}}</view>
  23. </view>
  24. </view>
  25. <view class="m-main" v-else>
  26. <view class="img-box" :data-src="item.link" v-for="(item, index) in goods_arr.children" :key="index" @tap="_jumpImg">
  27. <image mode="widthFix" :src="item.image"></image>
  28. <view class="description" v-if="item.name">{{item.name}}</view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data() {
  37. return {
  38. currentDesc: 'news',
  39. goods_arr: [],
  40. tapIndex: 0
  41. };
  42. },
  43. props: {
  44. groupingData: {
  45. type: Array,
  46. value: ''
  47. },
  48. meta: {
  49. type: Object,
  50. value: ""
  51. }
  52. },
  53. mounted() {
  54. this.goods_arr=this.groupingData[0]
  55. },
  56. //组件的方法
  57. methods: {
  58. _changeItem(e) {
  59. var index = e.currentTarget.dataset.index;
  60. if (index == this.tapIndex) return;
  61. this.goods_arr=this.groupingData[index];
  62. this.tapIndex=index;
  63. },
  64. _jumpToDetail(e) {
  65. var id = e.currentTarget.dataset.id;
  66. wx.navigateTo({
  67. url: `/pages/store/detail/detail?id=${id}`
  68. });
  69. },
  70. _jumpImg(e) {
  71. var src = e.currentTarget.dataset.src;
  72. if (!src || src == 'uto_miniprogram') return;
  73. wx.navigateTo({
  74. url: src
  75. });
  76. }
  77. }
  78. };
  79. </script>
  80. <style rel="stylesheet/less" lang="less">
  81. @import "index-grouping";
  82. </style>