collectList.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="collect">
  3. <view class="collect_list">
  4. <u-tabs :list="listCollect" @click="clickCollect" lineWidth="30" lineColor="#5992bb" :activeStyle="{
  5. color: '#303133',
  6. fontWeight: 'bold',
  7. transform: 'scale(1.05)',
  8. }" :inactiveStyle="{
  9. color: '#606266',
  10. transform: 'scale(1)',
  11. }" itemStyle="padding-left: 15px; padding-right: 15px; height: 34px;" />
  12. </view>
  13. <view>
  14. <view v-if="init_list.length > 0">
  15. <view class="text">以下是您收藏的商品服务</view>
  16. <!-- 收藏的服务 -->
  17. <serviceItem v-if="indexs == 0" :item="init_list" @uploadIniList="uploadIniList"></serviceItem>
  18. <goodsItem v-else :item="init_list" @uploadIniList="uploadIniList" />
  19. </view>
  20. <u-empty v-else mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" />
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import serviceItem from '@/components/service/index.vue';
  26. import goodsItem from "@/components/service/goodsItem.vue"
  27. import { maintainFavoritePaging, getFavouriteGoods } from '@/api/client/mine.js';
  28. import { getCurrentLocation } from '@/api/client/home';
  29. import { mapGetters } from "vuex"
  30. export default {
  31. components: {
  32. serviceItem,
  33. goodsItem
  34. },
  35. data() {
  36. return {
  37. queryParams: {
  38. size: 10,
  39. type: 'MERCHANT',
  40. region: null, //地区编码
  41. longitude: null , //经度
  42. latitude: null, //纬度
  43. },
  44. init_list: [],
  45. listCollect: [{
  46. id: 1,
  47. name: '商家',
  48. },
  49. {
  50. id: 1,
  51. name: '服务',
  52. },
  53. ],
  54. indexs: 0,
  55. };
  56. },
  57. mounted() {
  58. let { latitude , longitude , region } = this.location
  59. this.queryParams.latitude = latitude
  60. this.queryParams.longitude = longitude
  61. this.queryParams.region = region
  62. this.handlerInitList();
  63. },
  64. computed:{
  65. ...mapGetters(['location'])
  66. },
  67. methods: {
  68. // 初始化商家列表信息
  69. handlerInitList() {
  70. maintainFavoritePaging(this.queryParams).then(res => {
  71. if (res.code === 'OK' && res.data) {
  72. res.data.map(rs => {
  73. this.init_list.push(rs.simpleMerchantVO);
  74. });
  75. } else {
  76. uni.showToast({
  77. title: '数据请求失败',
  78. icon: 'none',
  79. });
  80. }
  81. });
  82. },
  83. // 初始化服务列表
  84. handlerInitGoodsList() {
  85. getFavouriteGoods().then(res => {
  86. if (res.code === 'OK' && res.data) {
  87. res.data.map(rs => {
  88. this.init_list.push(rs.goods);
  89. });
  90. } else {
  91. uni.showToast({
  92. title: '数据请求失败',
  93. icon: 'none',
  94. });
  95. }
  96. });
  97. },
  98. clickCollect(e) {
  99. this.init_list = []
  100. this.indexs = e.index
  101. switch (e.index) {
  102. case 0:
  103. this.handlerInitList()
  104. break;
  105. case 1:
  106. this.handlerInitGoodsList()
  107. break;
  108. }
  109. },
  110. uploadIniList(e) {
  111. this.init_list = []
  112. if (e == 1) {
  113. this.handlerInitGoodsList()
  114. this.indexs = 1
  115. } else {
  116. this.handlerInitList()
  117. this.indexs = 0
  118. }
  119. }
  120. },
  121. };
  122. </script>
  123. <style lang="scss" scoped>
  124. .collect {
  125. min-height: 100vh;
  126. background-color: #efefef;
  127. &_list {
  128. display: flex;
  129. height: 70rpx;
  130. justify-content: center;
  131. align-items: center;
  132. background-color: #fff;
  133. margin-bottom: 40rpx;
  134. }
  135. .text {
  136. text-align: center;
  137. padding: 40rpx;
  138. color: #999;
  139. }
  140. }
  141. </style>