consume.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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="32"></u-icon>
  7. <text class="padding-left-sm " style="font-size: 32rpx;">暂无位置信息</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. <mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
  18. @up="upCallback" :down="downOption" :up="upOption">
  19. <card1 :list="shopList" :list1="shopList1" @filter="filter" @goDetail1="goDetail1"></card1>
  20. </mescroll-body>
  21. </view>
  22. <view slot="swiper2">
  23. <mescroll-body :height="height" ref="mescrollRef" @init="mescrollInit" @down="downCallback"
  24. @up="upCallback" :down="downOption" :up="upOption">
  25. <card2 :list="mallList"></card2>
  26. </mescroll-body>
  27. </view>
  28. </tabsSwiper>
  29. <login ref="login" @signIn="signIn"></login>
  30. </view>
  31. </template>
  32. <script>
  33. import MescrollMixin from "@/components/mescroll-body/mescroll-mixins.js";
  34. import card2 from "./comps/card2.vue"
  35. import card1 from "./comps/card1.vue"
  36. import tabsSwiper from './comps/tabsSwiper.vue'
  37. import login from "@/components/login.vue"
  38. export default {
  39. mixins: [MescrollMixin],
  40. components: {
  41. tabsSwiper,
  42. card1,
  43. card2,
  44. login
  45. },
  46. data() {
  47. return {
  48. background: {
  49. background: '#FF9549'
  50. },
  51. location: '',
  52. //数据列表
  53. list: [],
  54. shopList: [],
  55. shopList1: [{
  56. cover: 'https://guosen-bucket-ldt.obs.cn-south-1.myhuaweicloud.com:443/c3f3d4e115ad437b98157c01d5c7e3de-%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20211229114436.jpg',
  57. name: '彩食鲜',
  58. score: 5,
  59. sales: 10,
  60. latitude: 0,
  61. longitude: 0,
  62. labelKey: '网店'
  63. }],
  64. mallList: [],
  65. //当前taginedx
  66. current: 0,
  67. filterValue: '',
  68. downOption: {
  69. use: false
  70. }
  71. }
  72. },
  73. onLoad() {
  74. this.getLocaltion()
  75. },
  76. methods: {
  77. downCallback() {
  78. setTimeout(() => {
  79. uni.showToast({
  80. title: "刷新成功",
  81. icon: "none"
  82. })
  83. this.mescroll.resetUpScroll();
  84. }, 1000)
  85. },
  86. upCallback(mescroll) {
  87. try {
  88. if (this.current == 0) {
  89. this.fetchShopList(mescroll)
  90. } else {
  91. this.fetchMallList(mescroll)
  92. }
  93. } catch (e) {
  94. this.mescroll.endErr()
  95. }
  96. },
  97. filter(index) {
  98. this.filterValue = ""
  99. switch (index) {
  100. case 1:
  101. this.filterValue = "sales"
  102. break;
  103. case 2:
  104. this.filterValue = "score"
  105. break;
  106. default:
  107. break;
  108. }
  109. this.mescroll.resetUpScroll();
  110. },
  111. goDetail1(){
  112. if (this.$isEmpty(this.vuex_phone) || this.$isEmpty(uni.getStorageSync('userInfo'))) {
  113. this.$refs.login.show()
  114. }else{
  115. this.BccH5SignAuthentication();
  116. }
  117. },
  118. async BccH5SignAuthentication(){
  119. let params = {
  120. code: this.vuex_phone,
  121. name: uni.getStorageSync('userInfo').nickName,
  122. telephone: this.vuex_phone
  123. }
  124. let res = await this.$api.shop.getBccH5SignAuthentication(params)
  125. if(res.success){
  126. uni.navigateTo({
  127. url: "/pages/webview/webview?url=" + res.data
  128. })
  129. }
  130. },
  131. async fetchShopList(mescroll) {
  132. let params = {
  133. current: mescroll.num,
  134. size: mescroll.size,
  135. auditStatus: 'PASS'
  136. }
  137. if (!this.$isEmpty(this.filterValue)) {
  138. params.filter = this.filterValue
  139. }
  140. let res = await this.$api.shop.list(params)
  141. let data = res.data.records
  142. let total = res.data.total
  143. mescroll.endBySize(data.length, total);
  144. if (mescroll.num == 1) this.shopList = []; //如果是第一页需手动制空列表
  145. this.shopList = this.shopList.concat(data); //追加新数据
  146. this.$forceUpdate()
  147. this.$refs.tabsSwiper.initSwiperHeight('.list0')
  148. },
  149. async fetchMallList(mescroll) {
  150. let params = {
  151. current: mescroll.num,
  152. size: mescroll.size,
  153. auditStatus: 'PASS'
  154. }
  155. let res = await this.$api.mall.list(params)
  156. let data = res.data.records
  157. let total = res.data.total
  158. mescroll.endBySize(data.length, total);
  159. if (mescroll.num == 1) this.mallList = []; //如果是第一页需手动制空列表
  160. this.mallList = this.mallList.concat(data); //追加新数据
  161. this.$forceUpdate()
  162. this.$refs.tabsSwiper.initSwiperHeight('.list1')
  163. },
  164. currentChange(index) {
  165. this.current = index
  166. this.mescroll.resetUpScroll();
  167. },
  168. getLocaltion() {
  169. let _this = this
  170. uni.getLocation({
  171. type: 'gcj02 ',
  172. success: function(res) {
  173. let params = {
  174. longitude: res.longitude,
  175. latitude: res.latitude
  176. }
  177. _this.$u.vuex('vuex_location', params)
  178. _this.$api.activity.getLocation(params).then(resp => {
  179. _this.location = resp.data.result.formatted_addresses.recommend
  180. })
  181. },
  182. fail: (err) => {
  183. console.log(err);
  184. }
  185. });
  186. },
  187. chooseLocation() {
  188. console.log("选择位置");
  189. let _this = this
  190. uni.chooseLocation({
  191. success: function(res) {
  192. let params = {
  193. longitude: res.longitude,
  194. latitude: res.latitude
  195. }
  196. _this.$u.vuex('vuex_location', params)
  197. _this.location = res.name
  198. },
  199. fail: (err) => {
  200. console.log(err);
  201. }
  202. });
  203. },
  204. }
  205. }
  206. </script>
  207. <style lang="scss" scoped>
  208. page {
  209. background-color: #f6f6f6;
  210. }
  211. </style>