海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

326 lines
9.4 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <template>
  2. <view>
  3. <view class="lf-p-t-20 head" v-if="tab_list_father.length">
  4. <u-tabs :list="tab_list_father" :is-scroll="true" :current="current_father" @change="tabChangeFather()"></u-tabs>
  5. </view>
  6. <view>
  7. <map class="lf-map-height" :longitude="self_longitude" :latitude="self_latitude" :markers="markers_list">
  8. </map>
  9. </view>
  10. <view class="lf-m-t-40 lf-p-l-32 lf-p-r-32">
  11. <view class="lf-row-between lf-m-b-40">
  12. <view class="lf-font-32 lf-color-222">地图上的门店</view>
  13. <view class="lf-font-24 lf-color-blue lf-row-center">
  14. <text class="lf-iconfont lf-icon-dingwei lf-m-r-10 lf-font-22"></text>
  15. 我的位置
  16. </view>
  17. </view>
  18. <view class="special_tab" style="position: relative;">
  19. <u-tabs :list="tab_list" active-color="#1998FE" inactive-color='#777777' :is-scroll="true" @click="clicksort" :current="current" @change="tabChange"></u-tabs>
  20. <view style="position: absolute;right: 44rpx;top: 20rpx;display: flex;flex-direction: column;">
  21. <u-icon name="arrow-up" style="font-size: 20rpx;" :class="sort==0?'':'lf-color-blue'"></u-icon>
  22. <u-icon name="arrow-down" style="font-size: 20rpx;" :class="sort==0?'lf-color-blue':''"></u-icon>
  23. </view>
  24. </view>
  25. <swiper :style="{height: 'calc('+ windowHeight +'px - 110rpx)', width: '100%'}" :current="current" @change="swiperChange">
  26. <swiper-item v-for="(tabItem, tabIndex) in tab_list" :key="tabIndex">
  27. <scroll-view class="com" :scroll-y="true" :refresher-enabled="true" :refresher-triggered="tabItem.isRefresher" @scrolltolower="onScrolltolower" @refresherrefresh="onRefresherrefresh">
  28. <view class="lf-m-t-20"></view>
  29. <view>
  30. <!-- 活动列表 -->
  31. <view class="content">
  32. <view class="item" v-for="(item,index) of tabItem.list" :key="index">
  33. <!-- <view class="cover">
  34. <image :src="item.picture" class="lf-w-100 lf-h-100" mode="aspectFill"></image>
  35. </view>
  36. <view style="width: 420rpx;">
  37. <view class="lf-font-28 lf-color-333 lf-line-2">{{item.title}}</view>
  38. <view class="lf-font-24 lf-color-gray lf-line-2 lf-m-t-10" style="min-height: 64rpx;">本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩</view>
  39. <view class="lf-flex lf-m-t-25">
  40. <lf-price :price="item.price"></lf-price>
  41. <text class="lf-font-24 lf-color-gray lf-line-through lf-m-l-15">¥{{item.original_price}}</text>
  42. </view>
  43. </view> -->
  44. <view class="lf-row-between lf-m-t-40">
  45. <view class="lf-row-between">
  46. <view class="lf-m-r-20">
  47. <image style="width: 46rpx;height: 46rpx;" :src="item.picture" mode="aspectFill"></image>
  48. </view>
  49. <view class="lf-flex-column">
  50. <view class="lf-font-28 lf-color-222 lf-line-1" style="max-width: 510rpx;">{{item.title}}</view>
  51. <view class="lf-font-24 lf-color-999 lf-flex lf-m-t-18">
  52. <view>
  53. <text class="lf-iconfont lf-icon-dingwei1" style="font-size: 10px!important;"></text>
  54. </view>
  55. <view class="lf-line-2 lf-m-l-10" style="max-width: 480rpx;">
  56. 瑞希开发
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view>
  62. <text class="lf-iconfont lf-icon-daohang"></text>
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 加载 -->
  68. <view class="loading-more">
  69. <text v-if="tabItem.list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  70. <lf-nocontent v-else></lf-nocontent>
  71. </view>
  72. </view>
  73. </scroll-view>
  74. </swiper-item>
  75. </swiper>
  76. <!-- 回到顶部 -->
  77. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  78. </view>
  79. </view>
  80. </template>ß
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. tab_list_father: [],
  86. current_father: 0,
  87. windowHeight: 0,
  88. markers_list: [
  89. {
  90. id: 0,
  91. name: '时尚',
  92. address: '杭州市',
  93. latitude: 30.353351,
  94. longitude: 120.231010,
  95. width: 50,
  96. height: 50
  97. }
  98. ],
  99. self_latitude: '',
  100. self_longitude: '',
  101. //排序
  102. tab_list: [
  103. {
  104. id: 1,
  105. name: '销量',
  106. list: [],
  107. isRefresher: false,
  108. loadingClass: true,
  109. loadingText: '正在加载中',
  110. page: 1,
  111. isPage: true,
  112. type: 1
  113. },
  114. {
  115. id: 2,
  116. name: '距离',
  117. list: [],
  118. isRefresher: false,
  119. loadingClass: true,
  120. loadingText: '正在加载中',
  121. page: 1,
  122. isPage: true,
  123. type: 4
  124. },
  125. {
  126. id: 4,
  127. name: '价格',
  128. list: [],
  129. isRefresher: false,
  130. loadingClass: true,
  131. loadingText: '正在加载中',
  132. page: 1,
  133. isPage: true,
  134. type: 3
  135. },
  136. ],
  137. current: 0,
  138. loadingClass: false,
  139. loadingText: '已加载全部数据~',
  140. page: 1,
  141. isPage: true,
  142. pageSize: 20,
  143. sort: 0,
  144. }
  145. },
  146. onLoad() {
  147. this.getCategory();
  148. this.windowHeight = getApp().globalData.windowHeight;
  149. this.getShopDistance();
  150. },
  151. methods: {
  152. //获取当前位置 计算商店距离
  153. getShopDistance() {
  154. let that = this;
  155. wx.getLocation({
  156. type: 'wgs84',
  157. isHighAccuracy: true,
  158. success (res) {
  159. that.self_latitude = res.latitude
  160. that.self_longitude = res.longitude
  161. console.log(that.self_longitude)
  162. console.log(that.self_latitude)
  163. console.log(res)
  164. },
  165. fail(err) {
  166. console.log(err)
  167. }
  168. })
  169. },
  170. tabChangeFather(index){
  171. this.current_father = index;
  172. this.clearTabItem()
  173. if(this.tab_list_father[index].list.length <= 0){
  174. this.getActivityList(); // tab下没有数据,请求第一页
  175. }
  176. },
  177. clearTabItem(){
  178. let tab_item = this.tab_list[this.current];
  179. tab_item.page = 1;
  180. tab_item.isPage = true;
  181. tab_item.isRefresher = true;
  182. tab_item.loadingClass = true;
  183. tab_item.loadingText = '正在加载中';
  184. tab_item.list = [];
  185. },
  186. getCategory(options = {}) {
  187. this.$http(this.API.API_CATEGORYLIST).then(res => {
  188. let res_list = res.data || [];
  189. let tab_list_father = res_list.map(item => {
  190. return {
  191. id: item.id,
  192. name: item.name,
  193. list: [],
  194. isRefresher: false,
  195. loadingClass: true,
  196. loadingText: '正在加载中',
  197. page: 1,
  198. isPage: true,
  199. pid: item.pid
  200. }
  201. });
  202. let list = []
  203. tab_list_father.forEach((item,index) => {
  204. if(item.pid == 0) {
  205. list.push(item)
  206. }
  207. })
  208. console.log(list)
  209. this.tab_list_father = list;
  210. console.log(this.tab_list_father)
  211. this.getActivityList()
  212. }).catch(err => {
  213. })
  214. },
  215. clicksort(index) {
  216. if(index == 2) {
  217. if(this.sort == 0) {
  218. this.sort = 1
  219. }else {
  220. this.sort = 0
  221. }
  222. this.getActivityList()
  223. }else {
  224. return
  225. }
  226. },
  227. tabChange(index){
  228. this.current = index;
  229. console.log('重复只想')
  230. this.getActivityList()
  231. },
  232. // 滑块下标值变化
  233. swiperChange(event){
  234. this.current = event.detail.current;
  235. if(event.detail.source == '') return; // 如果是被动出发,没有事件类型则不做处理
  236. },
  237. changeSort(sort) {
  238. console.log('排序')
  239. this.sort != this.sort
  240. this.getActivityList()
  241. },
  242. // scroll-view 下拉刷新
  243. onRefresherrefresh(){
  244. this.tab_list[this.current].isRefresher = true;
  245. this.$u.throttle(() => {
  246. this.clearTabItem();
  247. this.getActivityList();
  248. }, 200);
  249. },
  250. // 页面触底,加载下一页
  251. onScrolltolower(){
  252. let tab_item = this.tab_list[this.current];
  253. if(tab_item.isPage){
  254. tab_item.page = tab_item.page + 1;
  255. this.getActivityList();
  256. }
  257. },
  258. getActivityList(){
  259. let tab_item = this.tab_list_father[this.current_father];
  260. let sort_type = this.tab_list[this.current].type;
  261. console.log('页数',tab_item.id)
  262. if(this.$shared.isValueType(tab_item) == 'undefined') return;
  263. this.$http(this.API.API_ADVICELIST,{page: tab_item.page,category_id: tab_item.id,type: sort_type,by: this.sort}).then(res => {
  264. let isPage = res.data.next_page_url == null?false:true;
  265. tab_item.isPage = isPage;
  266. if(!isPage){
  267. tab_item.loadingClass = false;
  268. tab_item.loadingText = '没有更多数据啦~';
  269. }
  270. this.tab_list[this.current].isRefresher = false;
  271. console.log(this.tab_list[this.current].isRefresher )
  272. console.log(this.tab_list[this.current])
  273. if(tab_item.page == 1){
  274. tab_item.list = res.data.data;
  275. }else{
  276. tab_item.list.push(...res.data.data);
  277. }
  278. }).catch(err => {
  279. })
  280. },
  281. }
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. .com{
  286. width: 100%;
  287. height: 100%;
  288. box-sizing: border-box;
  289. padding: 0rpx 28rpx;
  290. }
  291. .lf-map-height {
  292. width: 100%;
  293. height: 500rpx;
  294. }
  295. /deep/.special_tab .u-scroll-box {
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. border-bottom: 1rpx solid rgba(0, 0, 0, 0.1);
  300. }
  301. /deep/.special_tab .u-scroll-box .u-tab-bar {
  302. background-color: #1998FE!important;
  303. width: 80rpx!important;
  304. position: absolute;
  305. left: 0;
  306. bottom: -12rpx;
  307. }
  308. /deep/.special_tab .u-tabs .u-scroll-box .u-tab-bar {
  309. background-color: #1998FE!important;
  310. width: 56rpx!important;
  311. position: absolute;
  312. height: 5rpx!important;
  313. left: 8rpx;
  314. bottom: -4rpx;
  315. }
  316. /deep/.special_tab .u-tab-item {
  317. font-size: 28rpx!important;
  318. }
  319. </style>