海南旅游项目 前端仓库
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.

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