consume.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. let params={
  90. auditStatus:'PASS'
  91. }
  92. this.$api.mall.list(params).then(res=>{
  93. this.mallList=res.data.records
  94. this.$forceUpdate()
  95. this.$refs.tabsSwiper.initSwiperHeight('.list1')
  96. })
  97. },
  98. currentChange(index){
  99. this.current=index
  100. this.fetchList()
  101. },
  102. getLocaltion(){
  103. let _this=this
  104. uni.getLocation({
  105. type: 'gcj02 ',
  106. success: function (res) {
  107. let params={
  108. longitude:res.longitude,
  109. latitude:res.latitude
  110. }
  111. _this.$u.vuex('vuex_location',params)
  112. _this.$api.activity.getLocation(params).then(resp=>{
  113. _this.location=resp.data.result.formatted_addresses.recommend
  114. })
  115. },
  116. fail: (err) => {
  117. console.log(err);
  118. }
  119. });
  120. },
  121. chooseLocation(){
  122. console.log("选择位置");
  123. let _this=this
  124. uni.chooseLocation({
  125. success: function (res) {
  126. let params={
  127. longitude:res.longitude,
  128. latitude:res.latitude
  129. }
  130. _this.$u.vuex('vuex_location',params)
  131. _this.location=res.name
  132. },
  133. fail: (err) => {
  134. console.log(err);
  135. }
  136. });
  137. },
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. page {
  143. background-color: #f6f6f6;
  144. }
  145. </style>