|
@@ -9,20 +9,15 @@
|
|
|
<text class="iconfont icon-chevron-down" />
|
|
|
</view>
|
|
|
<view slot="center">
|
|
|
- <u-search
|
|
|
- placeholder="请输入搜索内容"
|
|
|
- :showAction="false"
|
|
|
- v-model="keyword"
|
|
|
- @click="$Router.push('/pages/client/clientPackage/search')"
|
|
|
- :disabled="true"
|
|
|
- />
|
|
|
+ <u-search placeholder="请输入搜索内容" :showAction="false" v-model="keyword"
|
|
|
+ @click="$Router.push('/pages/client/clientPackage/search')" :disabled="true" />
|
|
|
</view>
|
|
|
</u-navbar>
|
|
|
</view>
|
|
|
|
|
|
<!-- 轮播图 -->
|
|
|
<view class="home-swiper">
|
|
|
- <u-swiper :list="swiperList" indicator />
|
|
|
+ <u-swiper :list="swiperUrlList" @click="handlerSwiperSkip" indicator />
|
|
|
</view>
|
|
|
|
|
|
<!-- 商品分类 -->
|
|
@@ -38,22 +33,14 @@
|
|
|
|
|
|
<!-- 热门推荐 -->
|
|
|
<view class="hot">
|
|
|
- <u-cell
|
|
|
- :border="false"
|
|
|
- value="查看更多"
|
|
|
- isLink
|
|
|
- @click="$Router.push('/pages/client/clientPackage/storeHot')"
|
|
|
- >
|
|
|
+ <u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pages/client/clientPackage/storeHot')">
|
|
|
<view slot="title" class="hot-title"> 热门推荐 </view>
|
|
|
</u-cell>
|
|
|
<block v-if="homeData.recommends && homeData.recommends.length > 0">
|
|
|
<view>
|
|
|
<u-grid :border="false" col="2">
|
|
|
- <u-grid-item
|
|
|
- @click="$Router.push(`/pages/client/clientPackage/storeDetail?id=${item.id}`)"
|
|
|
- v-for="item in homeData.recommends"
|
|
|
- :key="item.id"
|
|
|
- >
|
|
|
+ <u-grid-item @click="$Router.push(`/pages/client/clientPackage/storeDetail?id=${item.id}`)"
|
|
|
+ v-for="item in homeData.recommends" :key="item.id">
|
|
|
<recommend-item :item="item"></recommend-item>
|
|
|
</u-grid-item>
|
|
|
</u-grid>
|
|
@@ -66,22 +53,14 @@
|
|
|
|
|
|
<!-- 附近商家 -->
|
|
|
<view class="near">
|
|
|
- <u-cell
|
|
|
- :border="false"
|
|
|
- value="查看更多"
|
|
|
- isLink
|
|
|
- @click="$Router.push('/pages/client/clientPackage/storeNearby')"
|
|
|
- >
|
|
|
+ <u-cell :border="false" value="查看更多" isLink @click="$Router.push('/pages/client/clientPackage/storeNearby')">
|
|
|
<view slot="title" class="near-title"> 附近商家 </view>
|
|
|
</u-cell>
|
|
|
<block v-if="homeData.nears && homeData.nears.length > 0">
|
|
|
<view>
|
|
|
<u-grid :border="false" col="2">
|
|
|
- <u-grid-item
|
|
|
- @click="$Router.push(`/pages/client/clientPackage/storeDetail?id=${item.id}`)"
|
|
|
- v-for="item in homeData.nears"
|
|
|
- :key="item.id"
|
|
|
- >
|
|
|
+ <u-grid-item @click="$Router.push(`/pages/client/clientPackage/storeDetail?id=${item.id}`)"
|
|
|
+ v-for="item in homeData.nears" :key="item.id">
|
|
|
<hot-item :item="item"></hot-item>
|
|
|
</u-grid-item>
|
|
|
</u-grid>
|
|
@@ -101,195 +80,182 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { getCurrentLocation, getHomePageApi, getSwiperListApi } from '@/api/client/home';
|
|
|
-import { mapGetters } from 'vuex';
|
|
|
-import RecommendItem from '@/components/merchant/RecommendItem.vue';
|
|
|
-import HotItem from '@/components/merchant/HotItem.vue';
|
|
|
-import dragButton from '@/components/drag/drag-button.vue';
|
|
|
+ import {
|
|
|
+ getCurrentLocation,
|
|
|
+ getHomePageApi,
|
|
|
+ getSwiperListApi
|
|
|
+ } from '@/api/client/home';
|
|
|
+ import {
|
|
|
+ mapGetters
|
|
|
+ } from 'vuex';
|
|
|
+ import RecommendItem from '@/components/merchant/RecommendItem.vue';
|
|
|
+ import HotItem from '@/components/merchant/HotItem.vue';
|
|
|
+ import dragButton from '@/components/drag/drag-button.vue';
|
|
|
|
|
|
-export default {
|
|
|
- components: {
|
|
|
- RecommendItem,
|
|
|
- HotItem,
|
|
|
- dragButton,
|
|
|
- },
|
|
|
- data() {
|
|
|
- return {
|
|
|
- list: [],
|
|
|
- keyword: '',
|
|
|
- // swiperList: [
|
|
|
- // 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
|
|
|
- // 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
|
|
|
- // 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
|
|
|
- // ],
|
|
|
- swiperList: [], // 轮播图
|
|
|
- homeData: {
|
|
|
- categories: [],
|
|
|
- nears: [],
|
|
|
- recommends: [],
|
|
|
- },
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- ...mapGetters(['location']),
|
|
|
- categories() {
|
|
|
- let initData = this.homeData.categories.map(item => {
|
|
|
- if (!item.icon) {
|
|
|
- item.icon = 'level';
|
|
|
- }
|
|
|
- return item;
|
|
|
- });
|
|
|
- let result =
|
|
|
- initData.length > 14
|
|
|
- ? initData.splice(0, 14).concat([
|
|
|
- {
|
|
|
- id: 'all',
|
|
|
- icon: 'grid-fill',
|
|
|
- name: '全部',
|
|
|
- type: {
|
|
|
- code: 'ALL',
|
|
|
- description: '全部',
|
|
|
- },
|
|
|
- },
|
|
|
- ])
|
|
|
- : initData.push({
|
|
|
- id: 'all',
|
|
|
- icon: 'grid-fill',
|
|
|
- name: '全部',
|
|
|
- });
|
|
|
- return result;
|
|
|
+ export default {
|
|
|
+ components: {
|
|
|
+ RecommendItem,
|
|
|
+ HotItem,
|
|
|
+ dragButton,
|
|
|
},
|
|
|
- },
|
|
|
-
|
|
|
- // watch: {
|
|
|
- // location: {
|
|
|
- // handler: async function (newVal) {
|
|
|
- // const result = await getCurrentLocation({latitude: 36.70864,longitude: 119.13279});
|
|
|
- // const param = Object.assign(
|
|
|
- // {},
|
|
|
- // {
|
|
|
- // region: result.data.id,
|
|
|
- // },
|
|
|
- // newVal,
|
|
|
- // );
|
|
|
- // this.getHomeData(param);
|
|
|
- // },
|
|
|
- // },
|
|
|
- // },
|
|
|
- onShow() {
|
|
|
- let params = {
|
|
|
- region: 370705,
|
|
|
- longitude: 119.13279,
|
|
|
- latitude: 36.70864
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ list: [],
|
|
|
+ keyword: '',
|
|
|
+ swiperUrlList: [], // 轮播图url列表
|
|
|
+ swiperList:[],
|
|
|
+ homeData: {
|
|
|
+ categories: [],
|
|
|
+ nears: [],
|
|
|
+ recommends: [],
|
|
|
+ },
|
|
|
+ queryParams:{
|
|
|
+ longitude:'',
|
|
|
+ latitude:'',
|
|
|
+ region:''
|
|
|
}
|
|
|
- this.getHomeData(params)
|
|
|
- },
|
|
|
+ };
|
|
|
+ },
|
|
|
|
|
|
- //页面加载
|
|
|
- async onLoad() {
|
|
|
- uni.hideTabBar()
|
|
|
- setTimeout(() => {
|
|
|
- this.list = new Array(10000).fill(1);
|
|
|
- }, 5000);
|
|
|
- uni.getLocation({
|
|
|
- type: 'gcj02',
|
|
|
- success: res => {
|
|
|
- this.location.longitude = res.longitude;
|
|
|
- this.location.latitude = res.latitude;
|
|
|
- this.$store.commit('SET_LOCATION', {
|
|
|
- longitude: res.longitude,
|
|
|
- latitude: res.latitude,
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['location']),
|
|
|
+ categories() {
|
|
|
+ let initData = this.homeData.categories.map(item => {
|
|
|
+ if (!item.icon) {
|
|
|
+ item.icon = 'level';
|
|
|
+ }
|
|
|
+ return item;
|
|
|
});
|
|
|
+ let result =
|
|
|
+ initData.length > 14 ?
|
|
|
+ initData.splice(0, 14).concat([{
|
|
|
+ id: 'all',
|
|
|
+ icon: 'grid-fill',
|
|
|
+ name: '全部',
|
|
|
+ type: {
|
|
|
+ code: 'ALL',
|
|
|
+ description: '全部',
|
|
|
+ },
|
|
|
+ }, ]) :
|
|
|
+ initData.push({
|
|
|
+ id: 'all',
|
|
|
+ icon: 'grid-fill',
|
|
|
+ name: '全部',
|
|
|
+ });
|
|
|
+ return result;
|
|
|
},
|
|
|
- fail: () => {
|
|
|
- this.manualGetLocation();
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.getSwiperList();
|
|
|
- },
|
|
|
- methods: {
|
|
|
- /* 轮播图 */
|
|
|
- getSwiperList() {
|
|
|
- getSwiperListApi().then(res => {
|
|
|
- res.data.map(rs=>{
|
|
|
- this.swiperList.push(rs.viewUrl)
|
|
|
- })
|
|
|
- console.log('this.swiperList',this.swiperList);
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
- // 获取首页数据
|
|
|
- getHomeData(location) {
|
|
|
- getHomePageApi(location)
|
|
|
- .then(res => {
|
|
|
- this.homeData = res.data;
|
|
|
- // 将分类数据做缓存处理
|
|
|
- this.$store.commit('SET_CATEGORIES', this.homeData.categories);
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.log(err);
|
|
|
+ onShow() {
|
|
|
+ // 页面显示时 获取当前零维度
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: res => {
|
|
|
+ this.queryParams.longitude = res.longitude;
|
|
|
+ this.queryParams.latitude = res.latitude;
|
|
|
+ // getCurrentLocation 获取当前编码region
|
|
|
+ getCurrentLocation({latitude: res.latitude,longitude: res.longitude}).then(rs=>{
|
|
|
+ this.queryParams.region = rs.data.id;
|
|
|
+ this.getHomeData(this.queryParams)
|
|
|
+ this.$store.commit('SET_LOCATION', {
|
|
|
+ longitude: res.longitude,
|
|
|
+ latitude: res.latitude,
|
|
|
+ region: rs.data.id,
|
|
|
+ });
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: () => {
|
|
|
+ this.manualGetLocation();
|
|
|
+ },
|
|
|
});
|
|
|
},
|
|
|
+ mounted() {
|
|
|
+ this.getSwiperList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ /* 轮播图 */
|
|
|
+ getSwiperList() {
|
|
|
+ getSwiperListApi().then(res => {
|
|
|
+ this.swiperList = res.data
|
|
|
+ res.data.map(rs => {
|
|
|
+ this.swiperUrlList.push(rs.viewUrl)
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 获取首页数据
|
|
|
+ getHomeData(location) {
|
|
|
+ getHomePageApi(location)
|
|
|
+ .then(res => {
|
|
|
+ this.homeData = res.data;
|
|
|
+ // 将分类数据做缓存处理
|
|
|
+ this.$store.commit('SET_CATEGORIES', this.homeData.categories);
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 手动选择城市
|
|
|
+ manualGetLocation() {
|
|
|
+ console.log("@@@@")
|
|
|
+ // uni.chooseLocation({
|
|
|
+ // success: res => {
|
|
|
+ // this.$store.commit('SET_LOCATION', {
|
|
|
+ // longitude: res.longitude,
|
|
|
+ // latitude: res.latitude,
|
|
|
+ // });
|
|
|
+ // },fail:err=>{
|
|
|
|
|
|
- // 手动选择城市
|
|
|
- manualGetLocation() {
|
|
|
- uni.chooseLocation({
|
|
|
- success: res => {
|
|
|
- this.$store.commit('SET_LOCATION', {
|
|
|
- longitude: res.longitude,
|
|
|
- latitude: res.latitude,
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ // 点击swiper跳转
|
|
|
+ handlerSwiperSkip(e){
|
|
|
+ console.log("@@@swiperList", this.swiperList[e])
|
|
|
+ },
|
|
|
+ // 点击菜单
|
|
|
+ handleMenuClick(item) {
|
|
|
+ if (item.id === 'all') {
|
|
|
+ this.$Router.push('/pages/client/clientPackage/category');
|
|
|
+ } else {
|
|
|
+ uni.navigateTo({
|
|
|
+ url: `/pages/client/clientPackage/storeList?id=${item.id}`,
|
|
|
});
|
|
|
- },
|
|
|
- });
|
|
|
- },
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ /* 询价 */
|
|
|
+ btnClick() {
|
|
|
+ // uni.chooseImage({
|
|
|
+ // count: 9,
|
|
|
+ // sizeType: ['original', 'compressed'],
|
|
|
+ // sourceType: ['camera', 'album'],
|
|
|
+ // success: res => {
|
|
|
+ // const tempFilePaths = res.tempFilePaths;
|
|
|
+ // this.uploadFileAlbum();
|
|
|
+ // },
|
|
|
+ // });
|
|
|
|
|
|
- // 点击菜单
|
|
|
- handleMenuClick(item) {
|
|
|
- if (item.id === 'all') {
|
|
|
- this.$Router.push('/pages/client/clientPackage/category');
|
|
|
- } else {
|
|
|
uni.navigateTo({
|
|
|
- url: `/pages/client/clientPackage/storeList?id=${item.id}`,
|
|
|
+ url: `/pages/client/clientUser/inquiry`,
|
|
|
});
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /* 询价 */
|
|
|
- btnClick() {
|
|
|
- // uni.chooseImage({
|
|
|
- // count: 9,
|
|
|
- // sizeType: ['original', 'compressed'],
|
|
|
- // sourceType: ['camera', 'album'],
|
|
|
- // success: res => {
|
|
|
- // const tempFilePaths = res.tempFilePaths;
|
|
|
- // this.uploadFileAlbum();
|
|
|
- // },
|
|
|
- // });
|
|
|
-
|
|
|
- uni.navigateTo({
|
|
|
- url: `/pages/client/clientUser/inquiry`,
|
|
|
- });
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- uploadFileAlbum() {
|
|
|
- uni.uploadFile({
|
|
|
- url: '', //服务器地址
|
|
|
- fileType: 'image', //ZFB必填,不然报错
|
|
|
- filePath: tempFilePaths[0], //这个就是我们上面拍照返回或者先中照片返回的数组
|
|
|
- name: 'imgFile',
|
|
|
- success: uploadFileRes => {
|
|
|
- let imgData = JSON.parse(uploadFileRes.data);
|
|
|
- this.imgDataUrl = imgData.data.imgUrl;
|
|
|
- },
|
|
|
- });
|
|
|
+ // uploadFileAlbum() {
|
|
|
+ // uni.uploadFile({
|
|
|
+ // url: '', //服务器地址
|
|
|
+ // fileType: 'image', //ZFB必填,不然报错
|
|
|
+ // filePath: tempFilePaths[0], //这个就是我们上面拍照返回或者先中照片返回的数组
|
|
|
+ // name: 'imgFile',
|
|
|
+ // success: uploadFileRes => {
|
|
|
+ // let imgData = JSON.parse(uploadFileRes.data);
|
|
|
+ // this.imgDataUrl = imgData.data.imgUrl;
|
|
|
+ // },
|
|
|
+ // });
|
|
|
+ // },
|
|
|
},
|
|
|
- },
|
|
|
-};
|
|
|
+ };
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-@import './index.scss';
|
|
|
+ @import './index.scss';
|
|
|
</style>
|