consume.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <view>
  3. <u-navbar :is-back="false" title=" " >
  4. <view class="margin-left-20 text-cut-1" style="width: 100%;z-index: 99;" @click="chooseLocation()">
  5. <view v-if="$isEmpty(location)" @click.stop="$u.toast('暂无位置信息')">
  6. <u-icon name="map-fill" color="#000" size="34"></u-icon>
  7. <text class="padding-left-sm " style="font-size: 34rpx;">暂无位置信息</text>
  8. </view>
  9. <view class="" v-else>
  10. <u-icon name="map-fill" color="#000" size="34"></u-icon>
  11. <text class="padding-left-sm " style="font-size: 34rpx;">{{location}}</text>
  12. </view>
  13. </view>
  14. </u-navbar>
  15. <tabsSwiper @currentChange="currentChange" ref="tabsSwiper" activeColor="#efc232">
  16. <view slot="swiper1">
  17. <card1 :list="shopList"></card1>
  18. </view>
  19. <view slot="swiper2">
  20. <card2 :list="mallList"></card2>
  21. </view>
  22. </tabsSwiper>
  23. </view>
  24. </template>
  25. <script>
  26. import card2 from "./comps/card2.vue"
  27. import card1 from "./comps/card1.vue"
  28. import tabsSwiper from './comps/tabsSwiper.vue'
  29. export default {
  30. components: {
  31. tabsSwiper,
  32. card1,
  33. card2
  34. },
  35. data() {
  36. return {
  37. background: {
  38. background: '#FF9549'
  39. },
  40. location: '珠江新城',
  41. //数据列表
  42. shopList:[],
  43. mallList:[],
  44. //当前taginedx
  45. current:0,
  46. }
  47. },
  48. onLoad() {
  49. this.fetchList()
  50. },
  51. methods: {
  52. fetchList(){
  53. if (this.current==0) {
  54. this.fetchShopList()
  55. }else if (this.current==1) {
  56. this.fetchMallList()
  57. }
  58. },
  59. fetchShopList(){
  60. this.$api.shop.list().then(res=>{
  61. this.shopList=res.data.records
  62. this.$forceUpdate()
  63. this.$refs.tabsSwiper.initSwiperHeight('.list0')
  64. })
  65. },
  66. fetchMallList(){
  67. this.$api.mall.list().then(res=>{
  68. this.mallList=res.data.records
  69. this.$forceUpdate()
  70. this.$refs.tabsSwiper.initSwiperHeight('.list1')
  71. })
  72. },
  73. currentChange(index){
  74. this.current=index
  75. this.fetchList()
  76. },
  77. chooseLocation(){
  78. console.log("选择位置");
  79. let that=this
  80. uni.chooseLocation({
  81. success: function (res) {
  82. console.log(res);
  83. that.location=res.name
  84. },
  85. fail: (err) => {
  86. console.log(err);
  87. }
  88. });
  89. },
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. page {
  95. background-color: #f6f6f6;
  96. }
  97. </style>