|
1 | 1 | <template>
|
2 | 2 | <section class="m-istyle">
|
3 |
| - <dl @mouseover="over"> |
| 3 | + <dl @mouseover="mouseover"> |
4 | 4 | <dt>有格调</dt>
|
5 |
| - <dd |
6 |
| - :class="{active:kind==='all'}" |
7 |
| - kind="all" |
8 |
| - keyword="景点">全部</dd> |
9 |
| - <dd |
10 |
| - :class="{active:kind==='part'}" |
11 |
| - kind="part" |
12 |
| - keyword="美食">约会聚餐</dd> |
13 |
| - <dd |
14 |
| - :class="{active:kind==='spa'}" |
15 |
| - kind="spa" |
16 |
| - keyword="丽人">丽人SPA</dd> |
17 |
| - <dd |
18 |
| - :class="{active:kind==='movie'}" |
19 |
| - kind="movie" |
20 |
| - keyword="电影">电影演出</dd> |
21 |
| - <dd |
22 |
| - :class="{active:kind==='travel'}" |
23 |
| - kind="travel" |
24 |
| - keyword="旅游">品质出游</dd> |
| 5 | + <dd :class="{active:kind==='all'}" kind="all" keyword="景点">全部</dd> |
| 6 | + <dd :class="{active:kind==='part'}" kind="part" keyword="美食">约会聚餐</dd> |
| 7 | + <dd :class="{active:kind==='spa'}" kind="spa" keyword="丽人">丽人SPA</dd> |
| 8 | + <dd :class="{active:kind==='movie'}" kind="movie" keyword="电影">电影演出</dd> |
| 9 | + <dd :class="{active:kind==='travel'}" kind="travel" keyword="旅游">品质出游</dd> |
25 | 10 | </dl>
|
26 | 11 | <ul class="ibody">
|
27 |
| - <!-- <li |
28 |
| - v-for="item in cur" |
29 |
| - :key="item.title"> |
30 |
| - <el-card |
31 |
| - :body-style="{ padding: '0px' }" |
32 |
| - shadow="never"> |
33 |
| - <img |
34 |
| - :src="item.img" |
35 |
| - class="image"> |
| 12 | + <li v-for="item in cur" :key="item.title"> |
| 13 | + <el-card :body-style="{ padding: '0px' }" shadow="never"> |
| 14 | + <img :src="item.img" class="image"> |
36 | 15 | <ul class="cbody">
|
37 | 16 | <li class="title">{{ item.title }}</li>
|
38 |
| - <li class="pos"><span>{{ item.pos }}</span></li> |
39 |
| - <li class="price">¥<em>{{ item.price }}</em><span>/起</span></li> |
| 17 | + <li class="pos"> |
| 18 | + <span>{{ item.pos }}</span> |
| 19 | + </li> |
| 20 | + <li class="price"> |
| 21 | + ¥ |
| 22 | + <em>{{ item.price }}</em> |
| 23 | + <span>/起</span> |
| 24 | + </li> |
40 | 25 | </ul>
|
41 | 26 | </el-card>
|
42 |
| - </li> --> |
| 27 | + </li> |
43 | 28 | </ul>
|
44 | 29 | </section>
|
45 | 30 | </template>
|
46 | 31 | <script>
|
| 32 | +import { createNamespacedHelpers } from "vuex"; |
| 33 | +const { mapState } = createNamespacedHelpers("geo"); |
| 34 | +const axios = require("../../server/interface/utils/axios"); |
47 | 35 | export default {
|
48 | 36 | data: () => {
|
49 | 37 | return {
|
50 |
| - kind: 'all', |
| 38 | + kind: "all", |
51 | 39 | list: {
|
52 | 40 | all: [],
|
53 | 41 | part: [],
|
54 | 42 | spa: [],
|
55 | 43 | movie: [],
|
56 | 44 | travel: []
|
57 | 45 | }
|
58 |
| - } |
| 46 | + }; |
59 | 47 | },
|
60 | 48 | computed: {
|
61 |
| - // cur: function () { |
62 |
| - // return this.list[this.kind] |
63 |
| - // } |
| 49 | + ...mapState({ |
| 50 | + position: state => state.position |
| 51 | + }), |
| 52 | + cur: function() { |
| 53 | + return this.list[this.kind]; |
| 54 | + } |
64 | 55 | },
|
65 |
| - async mounted(){ |
66 |
| - // let {status, data:{count, pois}} = await this.$axios.get('/search/resultsByKeywords', { |
67 |
| - // params: { |
68 |
| - // keyword: '景点', |
69 |
| - // city: this.$store.state.geo.position.city |
70 |
| - // } |
71 |
| - // }) |
72 |
| - // if(status === 200 && count > 0) { |
73 |
| - // let r = pois.filter((item)=>item.photos.length).map((item, index)=>{ |
74 |
| - // return { |
75 |
| - // title: item.name, |
76 |
| - // pos: item.type.split(';')[0], |
77 |
| - // price: item.biz_ext.cost || '暂无', |
78 |
| - // img: item.photos[0].url, |
79 |
| - // url: '//abc.com' |
80 |
| - // } |
81 |
| - // }) |
82 |
| - // this.list[this.kind]=r.slice(0,9); |
83 |
| - // } |
84 |
| - // else |
85 |
| - // { |
86 |
| - // this.list[this.kind]= []; |
87 |
| - // } |
| 56 | + // 默认初始化的时候,获取一次数据 |
| 57 | + async mounted() { |
| 58 | + let { |
| 59 | + status, |
| 60 | + data: { count, pois } |
| 61 | + } = await axios.get("/search/resultsByKeywords", { |
| 62 | + params: { |
| 63 | + keyword: "景点", |
| 64 | + city: this.position.city |
| 65 | + } |
| 66 | + }); |
| 67 | + if (status === 200 && count > 0) { |
| 68 | + let r = pois |
| 69 | + .filter(item => item.photos.length) |
| 70 | + .map((item, index) => { |
| 71 | + return { |
| 72 | + title: item.name, |
| 73 | + pos: item.type.split(";")[0], |
| 74 | + price: item.biz_ext.cost || "暂无", |
| 75 | + img: item.photos[0].url, |
| 76 | + url: "//abc.com" |
| 77 | + }; |
| 78 | + }); |
| 79 | + this.list[this.kind] = r.slice(0, 9); |
| 80 | + } else { |
| 81 | + this.list[this.kind] = []; |
| 82 | + } |
88 | 83 | },
|
89 | 84 | methods: {
|
90 |
| - over: async function(e) { |
91 |
| - // let dom = e.target |
92 |
| - // let tag = dom.tagName.toLowerCase() |
93 |
| - // let self = this |
94 |
| - // if (tag === 'dd') { |
95 |
| - // this.kind = dom.getAttribute('kind') |
96 |
| - // let keyword = dom.getAttribute('keyword') |
97 |
| -
|
98 |
| - // let {status, data:{count, pois}} = await self.$axios.get('/search/resultsByKeywords', { |
99 |
| - // params: { |
100 |
| - // keyword, |
101 |
| - // city: this.$store.state.geo.position.city |
102 |
| - // } |
103 |
| - // }) |
104 |
| - // if(status === 200 && count > 0) { |
105 |
| - // let r = pois.filter((item)=>item.photos.length).map((item, index)=>{ |
106 |
| - // return { |
107 |
| - // title: item.name, |
108 |
| - // pos: item.type.split(';')[0], |
109 |
| - // price: item.biz_ext.cost || '暂无', |
110 |
| - // img: item.photos[0].url, |
111 |
| - // url: '//abc.com' |
112 |
| - // } |
113 |
| - // }) |
114 |
| - // this.list[this.kind]=r.slice(0,9); |
115 |
| - // } |
116 |
| - // else |
117 |
| - // { |
118 |
| - // this.list[this.kind]= []; |
119 |
| - // } |
120 |
| -
|
121 |
| - // } |
| 85 | + mouseover: async function(e) { |
| 86 | + let dom = e.target; |
| 87 | + let tag = dom.tagName.toLowerCase(); |
| 88 | + let self = this; |
| 89 | + if (tag === "dd") { |
| 90 | + this.kind = dom.getAttribute("kind"); |
| 91 | + let keyword = dom.getAttribute("keyword"); |
| 92 | + let { |
| 93 | + status, |
| 94 | + data: { count, pois } |
| 95 | + } = await axios.get("/search/resultsByKeywords", { |
| 96 | + params: { |
| 97 | + keyword, |
| 98 | + city: this.position.city |
| 99 | + } |
| 100 | + }); |
| 101 | + if (status === 200 && count > 0) { |
| 102 | + // 根据实际业务进行数据过滤 |
| 103 | + let r = pois |
| 104 | + .filter(item => item.photos.length) |
| 105 | + .map((item, index) => { |
| 106 | + // 再次进行数据结构的修改 |
| 107 | + return { |
| 108 | + title: item.name, |
| 109 | + pos: item.type.split(";")[0], |
| 110 | + price: item.biz_ext.cost || "暂无", |
| 111 | + img: item.photos[0].url, |
| 112 | + url: "//abc.com" |
| 113 | + }; |
| 114 | + }); |
| 115 | + this.list[this.kind] = r.slice(0, 9); |
| 116 | + } else { |
| 117 | + this.list[this.kind] = []; |
| 118 | + } |
| 119 | + } |
122 | 120 | }
|
123 | 121 | }
|
124 |
| -} |
| 122 | +}; |
125 | 123 | </script>
|
126 | 124 | <style lang="scss">
|
127 |
| - @import "@/assets/css/index/artistic.scss"; |
| 125 | +@import "@/assets/css/index/artistic.scss"; |
128 | 126 | </style>
|
0 commit comments