consume.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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" @filter="filter"></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. filterValue:''
  47. }
  48. },
  49. onLoad() {
  50. this.fetchList()
  51. this.getLocaltion()
  52. },
  53. methods: {
  54. filter(index){
  55. this.filterValue=""
  56. switch (index){
  57. case 1:
  58. this.filterValue="sales"
  59. break;
  60. case 2:
  61. this.filterValue="score"
  62. break;
  63. default:
  64. break;
  65. }
  66. this.fetchShopList()
  67. },
  68. fetchList(){
  69. if (this.current==0) {
  70. this.fetchShopList()
  71. }else if (this.current==1) {
  72. this.fetchMallList()
  73. }
  74. },
  75. fetchShopList(){
  76. let params={
  77. auditStatus:'PASS'
  78. }
  79. if (!this.$isEmpty(this.filterValue)) {
  80. params.filter=this.filterValue
  81. }
  82. this.$api.shop.list(params).then(res=>{
  83. this.shopList=res.data.records
  84. this.$forceUpdate()
  85. this.$refs.tabsSwiper.initSwiperHeight('.list0')
  86. })
  87. },
  88. fetchMallList(){
  89. this.$api.mall.list().then(res=>{
  90. this.mallList=res.data.records
  91. this.$forceUpdate()
  92. this.$refs.tabsSwiper.initSwiperHeight('.list1')
  93. })
  94. },
  95. currentChange(index){
  96. this.current=index
  97. this.fetchList()
  98. },
  99. getLocaltion(){
  100. let _this=this
  101. uni.getLocation({
  102. type: 'gcj02 ',
  103. success: function (res) {
  104. let params={
  105. longitude:res.longitude,
  106. latitude:res.latitude
  107. }
  108. _this.$u.vuex('vuex_location',params)
  109. _this.$api.activity.getLocation(params).then(resp=>{
  110. _this.location=resp.data.result.formatted_addresses.recommend
  111. })
  112. },
  113. fail: (err) => {
  114. console.log(err);
  115. }
  116. });
  117. },
  118. chooseLocation(){
  119. console.log("选择位置");
  120. let _this=this
  121. uni.chooseLocation({
  122. success: function (res) {
  123. let params={
  124. longitude:res.longitude,
  125. latitude:res.latitude
  126. }
  127. _this.$u.vuex('vuex_location',params)
  128. _this.location=res.name
  129. },
  130. fail: (err) => {
  131. console.log(err);
  132. }
  133. });
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. page {
  140. background-color: #f6f6f6;
  141. }
  142. </style>