index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="scenic">
  3. <zs-skeleton type="scenic" :loading="loading"></zs-skeleton>
  4. <view class="search-box" @click="handleSearch">
  5. <view class="city-box">
  6. <image class="icon" src="@/static/blue-position.png" mode=""></image>
  7. <view class="city">
  8. {{city}}
  9. </view>
  10. </view>
  11. <input class="search" disabled v-model="value" type="text" placeholder="景点名称" />
  12. </view>
  13. <view class="more-box">
  14. <view class="title">
  15. 猜你喜欢
  16. </view>
  17. <!-- <view class="btn-box">
  18. 更多 <image class="btn" src="@/static/right.png" mode=""></image>
  19. </view> -->
  20. </view>
  21. <zs-list class="list" mt="20rpx" @load="loadMore" :status="status">
  22. <view class="left">
  23. <view class="item" v-for="item in list" :key="item.tripartiteJson.scenicId" @click="goDetail(item)">
  24. <zs-img :src="item.logoPath" width="340rpx" height="340rpx" mode="widthFix"></zs-img>
  25. <view class="info">
  26. <view class="title">
  27. {{item.tripartiteJson.scenicName}}
  28. </view>
  29. <view class="address-box">
  30. <view class="price-box">
  31. <view class="unit">
  32. </view>
  33. <view class="price">
  34. <!-- {{item.tripartiteJson.ticketList.length?item.tripartiteJson.ticketList[0].salePrice:0}} -->
  35. {{item.tripartiteJson.ticketList | filterMinPrice}}
  36. </view>
  37. <view class="text">
  38. </view>
  39. </view>
  40. <!-- <view class="address">
  41. </view> -->
  42. <view class="distance">
  43. {{(item.shopVo.distance/1000).toFixed(2)}} KM
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="right">
  50. <view class="item" v-for="item in list1" :key="item.tripartiteJson.scenicId" @click="goDetail(item)">
  51. <zs-img :src="item.logoPath" width="340rpx" height="340rpx" mode="widthFix"></zs-img>
  52. <view class="info">
  53. <view class="title">
  54. {{item.tripartiteJson.scenicName}}
  55. </view>
  56. <view class="address-box">
  57. <view class="price-box">
  58. <view class="unit">
  59. </view>
  60. <view class="price">
  61. <!-- {{item.tripartiteJson.ticketList.length?item.tripartiteJson.ticketList[0].salePrice:0}} -->
  62. {{item.tripartiteJson.ticketList | filterMinPrice}}
  63. </view>
  64. <view class="text">
  65. </view>
  66. </view>
  67. <!-- <view class="address">
  68. </view> -->
  69. <view class="distance">
  70. {{(item.shopVo.distance/1000).toFixed(2)}} KM
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </zs-list>
  77. </view>
  78. </template>
  79. <script>
  80. import {getScenicList} from '@/api/scenic.js'
  81. import { search } from '@/api/shop.js';
  82. export default {
  83. data() {
  84. return {
  85. city: uni.getStorageSync('city'),
  86. value:'',
  87. status:'more',
  88. // query:{
  89. // key: uni.getStorageSync('city'),
  90. // page: 1,
  91. // pageSize: 20
  92. // },
  93. query:{
  94. queryName:'',
  95. menuId: 1,
  96. 'location.lat':0,
  97. 'location.lon':0,
  98. pageCurrent:1,
  99. pageSize:20
  100. },
  101. list:[],
  102. list1:[],
  103. loading:false,
  104. }
  105. },
  106. filters: {
  107. filterDistance: function(item) {
  108. let blocation = item.blocation.split(',')
  109. let location = JSON.parse(uni.getStorageSync('location'))
  110. /*参数:两地的经纬度数值*/
  111. var radLat1 = location.latitude * Math.PI / 180.0;
  112. var radLat2 = location.longitude* Math.PI / 180.0;
  113. var a = radLat1 - radLat2;
  114. var b = location.longitude* Math.PI / 180.0 - blocation[0]* Math.PI / 180.0;
  115. var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
  116. Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
  117. s = s * 6378137.0;//地球半径 单位米;
  118. s = Math.round(s * 10000) / 10000 /1000 //输出为千米
  119. s = s.toFixed(0)
  120. return s
  121. },
  122. filterMinPrice(list){
  123. if(list.length){
  124. let arr = JSON.parse(JSON.stringify(list))
  125. arr.sort(function(a,b){a.salePrice - b.salePrice})
  126. return arr[0].salePrice
  127. console.log(arr);
  128. }else{
  129. return 0
  130. }
  131. }
  132. },
  133. methods: {
  134. handleSearch() {
  135. uni.navigateTo({
  136. url:'/scenic/search'
  137. })
  138. },
  139. goDetail(item){
  140. uni.navigateTo({
  141. url:`/scenic/detail?id=${item.tripartiteJson.scenicId}&epId=${item.shopVo.shopId}`
  142. })
  143. },
  144. loadMore(){
  145. // this.getScenicList()
  146. // this.search()
  147. },
  148. getScenicList(){
  149. this.status = 'loading'
  150. getScenicList(this.query).then(res=>{
  151. this.loading = false
  152. if(res.state == 'Success'){
  153. let list = []
  154. let list1 = []
  155. res.content.data.rows.map((item,index)=>{
  156. if(index%2 == 0){
  157. list.push(item)
  158. }else{
  159. list1.push(item)
  160. }
  161. })
  162. this.list = this.list.concat(list)
  163. this.list1 = this.list1.concat(list1)
  164. console.log(this.list,this.list1);
  165. if((this.list.length + this.list1.length)>= res.content.data.totalCount){
  166. this.status = 'noMore'
  167. }else{
  168. this.status = 'more'
  169. this.query.page++
  170. }
  171. }
  172. })
  173. },
  174. search() {
  175. if(this.status == 'noMore' || this.status == 'loading' || !this.query['location.lat']) return
  176. console.log('加载数据',this.status,this.list,this.list1,this.query.pageCurrent);
  177. this.status = 'loading'
  178. search(this.query).then(res=>{
  179. if(res.state == 'Success'){
  180. this.loading = false
  181. let list = []
  182. let list1 = []
  183. let data = res.content.records
  184. data.map((item,index)=>{
  185. item.tripartiteJson = JSON.parse(item.tripartiteJson)
  186. if(index%2 == 0){
  187. list.push(item)
  188. }else{
  189. list1.push(item)
  190. }
  191. })
  192. // 存储原始数据
  193. this.list = this.list.concat(list)
  194. this.list1 = this.list1.concat(list1)
  195. this.status = 'noMore'
  196. // if(this.query.pageCurrent == res.content.pages){
  197. // this.status = 'noMore'
  198. // }else{
  199. // this.status = 'more'
  200. // this.query.pageCurrent++
  201. // }
  202. }
  203. })
  204. }
  205. },
  206. onLoad() {
  207. this.loading = true
  208. uni.getLocation({
  209. type: 'gcj02',
  210. success: (res) => {
  211. // 解析地址
  212. this.query['location.lat'] = res.latitude
  213. this.query['location.lon'] = res.longitude
  214. console.log(this);
  215. // 存储经纬度
  216. uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
  217. this.search()
  218. }
  219. })
  220. }
  221. }
  222. </script>
  223. <style lang="scss" >
  224. .scenic{
  225. background: #F9F9F9;
  226. min-height: 100vh;
  227. padding: 112rpx 24rpx 0;
  228. .search-box{
  229. position: fixed;
  230. top: 20rpx;
  231. left: 24rpx;
  232. width: 702rpx;
  233. height: 72rpx;
  234. // padding: 16rpx;
  235. box-sizing: border-box;
  236. z-index: 9;
  237. .city-box{
  238. position: absolute;
  239. left: 0;
  240. top: 50%;
  241. transform: translateY(-50%);
  242. display: flex;
  243. align-items: center;
  244. padding: 0 28rpx;
  245. border-right: 1rpx solid #F0F0F0;
  246. .icon{
  247. width: 30rpx;
  248. height: 30rpx;
  249. }
  250. .city{
  251. font-weight: 600;
  252. font-size: 28rpx;
  253. color: #222222;
  254. margin-left: 6rpx;
  255. }
  256. }
  257. .search{
  258. width: 702rpx;
  259. height: 72rpx;
  260. background: #FFFFFF;
  261. border-radius: 40rpx 40rpx 40rpx 40rpx;
  262. padding-left: 230rpx;
  263. padding-right: 100rpx;
  264. box-sizing: border-box;
  265. }
  266. }
  267. .more-box{
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-between;
  271. .title{
  272. font-weight: 600;
  273. font-size: 32rpx;
  274. color: #222222;
  275. }
  276. .btn-box{
  277. display: flex;
  278. align-items: center;
  279. font-weight: 300;
  280. font-size: 24rpx;
  281. color: #AAAAAA;
  282. .btn{
  283. width: 48rpx;
  284. height: 48rpx;
  285. }
  286. }
  287. }
  288. .zs-list{
  289. display: flex;
  290. flex-wrap: wrap;
  291. justify-content: space-between;
  292. .item{
  293. background: #FFFFFF;
  294. border-radius: 16rpx;
  295. margin-bottom: 20rpx;
  296. .info{
  297. padding: 16rpx 16rpx 20rpx;
  298. width: 100%;
  299. box-sizing: border-box;
  300. .title{
  301. font-weight: 400;
  302. font-size: 24rpx;
  303. color: #222222;
  304. width: 300rpx;
  305. white-space: nowrap;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. }
  309. .price-box{
  310. display: flex;
  311. align-items: flex-end;
  312. margin-top: 12rpx;
  313. .unit{
  314. font-weight: 600;
  315. font-size: 20rpx;
  316. color: $uni-color-primary;
  317. }
  318. .price{
  319. font-weight: 600;
  320. font-size: 36rpx;
  321. color: $uni-color-primary;
  322. }
  323. .text{
  324. font-weight: 300;
  325. font-size: 24rpx;
  326. color: #AAAAAA;
  327. margin-left: 6rpx;
  328. }
  329. }
  330. .address-box{
  331. display: flex;
  332. align-items: flex-end;
  333. justify-content: space-between;
  334. font-weight: 300;
  335. font-size: 20rpx;
  336. color: #AAAAAA;
  337. margin-top: 12rpx;
  338. }
  339. }
  340. }
  341. }
  342. }
  343. </style>