|
@@ -7,16 +7,16 @@
|
|
|
<li
|
|
|
v-for="(item, index) in shops"
|
|
|
:key="index">
|
|
|
- <p class="category">{{ item.category }}</p>
|
|
|
+ <p class="category">{{ item.category_type_name }}</p>
|
|
|
<div class="wrap">
|
|
|
<!--第一个默认占位-->
|
|
|
<p></p>
|
|
|
<p
|
|
|
- v-for="(shop, idx) in item.child"
|
|
|
+ v-for="(shop, idx) in item.category_data"
|
|
|
:key="idx"
|
|
|
@click="handleJump(shop)">
|
|
|
- <i :style="{backgroundImage: 'url(' + shop.icon + ')'}"></i>
|
|
|
- <span>{{ shop.name }}</span>
|
|
|
+ <i :style="{backgroundImage: 'url(' + shop.category_img_url + ')'}"></i>
|
|
|
+ <span>{{ shop.category_name }}</span>
|
|
|
</p>
|
|
|
</div>
|
|
|
</li>
|
|
@@ -37,6 +37,7 @@
|
|
|
<script>
|
|
|
import BScroll from 'better-scroll'
|
|
|
import Mall from './mall'
|
|
|
+import { getHomeList } from './api'
|
|
|
|
|
|
export default {
|
|
|
name: 'index',
|
|
@@ -46,24 +47,12 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
shopsScroll: null,
|
|
|
- shops: [
|
|
|
- {
|
|
|
- category: '外卖',
|
|
|
- child: [
|
|
|
- {
|
|
|
- icon: require('./image/ic_eleme@2x.png'),
|
|
|
- name: '饿了么'
|
|
|
- }
|
|
|
- ]
|
|
|
- }
|
|
|
- ]
|
|
|
+ shops: []
|
|
|
}
|
|
|
},
|
|
|
activated () {
|
|
|
if (!this.$route.meta.isUseCache) {
|
|
|
- setTimeout(() => {
|
|
|
- this._initScroll()
|
|
|
- }, 500)
|
|
|
+ this.fetchData()
|
|
|
} else {
|
|
|
if (this.shopsScroll) {
|
|
|
this.shopsScroll.refresh()
|
|
@@ -82,6 +71,17 @@ export default {
|
|
|
},
|
|
|
handleShowMall () {
|
|
|
this.$refs.myMall.show()
|
|
|
+ },
|
|
|
+ async fetchData () {
|
|
|
+ try {
|
|
|
+ const { status, data } = await getHomeList()
|
|
|
+ if (status) {
|
|
|
+ this.shops = data
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ this._initScroll()
|
|
|
+ }, 500)
|
|
|
+ } catch (err) {}
|
|
|
}
|
|
|
},
|
|
|
beforeDestroy () {
|