Commit bc444cb2 authored by 燕南天's avatar 燕南天

串接口

parent 79cd054e
...@@ -13,7 +13,8 @@ module.exports = { ...@@ -13,7 +13,8 @@ module.exports = {
proxyTable: {}, proxyTable: {},
// Various Dev Server settings // Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST // host: 'localhost', // can be overwritten by process.env.HOST
host: '192.168.1.107', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: true, autoOpenBrowser: true,
errorOverlay: true, errorOverlay: true,
......
import request from './request'
import qs from 'qs'
export function getAdvertList() {
return request({
url: '/h5/index/getAdvertList',
method: 'post',
})
}
export function getStoreList() {
return request({
url: 'h5/index/getStoreList',
method: 'post'
})
}
export function getWorkerList() {
return request({
url: '/h5/index/getWorkerList',
method: 'post'
})
}
const host = "http://192.168.1.100:8080/store-system"
export default host
\ No newline at end of file
import axios from 'axios'
import host from './hostCfg'
// create an axios instance
const service = axios.create({
baseURL: host, // api的base_url
timeout: 5000, // request timeout
headers: {'Content-Type':'application/x-www-form-urlencoded'}
})
console.log('请求地址:'+process.env.BASE_API);
// request interceptor
service.interceptors.request.use(config => {
return config
}, error => {
alert('请求拦截,出现错误了')
})
// respone interceptor
service.interceptors.response.use(
response => response.data,
error => {
alert('响应拦截出现错误了')
})
export default service
import request from './request'
import qs from 'qs'
export function searchShopResult(data) {
return request({
url: '/h5/index/searchShopResult',
method: 'post',
data:qs.stringify(data)
})
}
// 陕西省id写死 610000
export function getCityList(data) {
return request({
url: '/pca/getCityList',
method: 'post',
data:qs.stringify(data)
})
}
export function getAreaList(data) {
return request({
url: '/pca/getAreaList',
method: 'post',
data:qs.stringify(data)
})
}
export function getDataDictsStore() {
return request({
url: '/h5/config/getDataDictsStore',
method: 'post'
})
}
import request from './request'
import qs from 'qs'
export function searchWorkerResult(data) {
return request({
url: '/h5/index/searchWorkerResult',
method: 'post',
data:qs.stringify(data)
})
}
export function getDataDictsHight() {
return request({
url: '/h5/config/getDataDictsHight',
method: 'post',
})
}
export function getDataDictsAge() {
return request({
url: '/h5/config/getDataDictsAge',
method: 'post',
})
}
...@@ -6,6 +6,8 @@ import ShopList from '@/views/shopList/index.vue' ...@@ -6,6 +6,8 @@ import ShopList from '@/views/shopList/index.vue'
import WorkerList from '@/views/workerList/index.vue' import WorkerList from '@/views/workerList/index.vue'
import ShopDetails from '@/views/shopDetails/index.vue' import ShopDetails from '@/views/shopDetails/index.vue'
import WebView from '@/views/webView/index.vue'
Vue.use(Router) Vue.use(Router)
export default new Router({ export default new Router({
...@@ -29,6 +31,11 @@ export default new Router({ ...@@ -29,6 +31,11 @@ export default new Router({
path: '/shopDetails', path: '/shopDetails',
name: 'shopDetails', name: 'shopDetails',
component: ShopDetails component: ShopDetails
},
{
path: '/webView',
name: 'webView',
component: WebView
} }
] ]
}) })
<template> <template>
<swiper :options="swiperOption"> <swiper :options="swiperOption">
<swiper-slide v-for="(item,index) in data" :key="index"> <swiper-slide v-for="(item,index) in data" :key="index">
<img :src="item.url" :alt="item.href" :data-href="item.href" @click="toWebview"> <img :src="item.advertPicUrl" :alt="item.advertPicUrl" @click="toWebview(item)">
</swiper-slide> </swiper-slide>
<div class="swiper-pagination swiper-pagination-bullets" slot="pagination"></div> <div class="swiper-pagination swiper-pagination-bullets" slot="pagination"></div>
...@@ -22,9 +22,10 @@ export default { ...@@ -22,9 +22,10 @@ export default {
}; };
}, },
methods: { methods: {
toWebview(e) { toWebview(item) {
const href = e.target.dataset.href; // const href = e.target.dataset.href;
alert("跳转到:" + href); // window.location.href = href;
this.$router.push({ name: 'webView', params: { html:item.advertContent, title:item.advertTitle}})
} }
} }
}; };
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<div class="shop-list-wrapper"> <div class="shop-list-wrapper">
<div class="list-item"> <div class="list-item">
<div class="img"> <div class="img">
<img :src="data.url" alt=""> <img :src="data.storeHomePic" alt="">
</div> </div>
<div class="item-infro"> <div class="item-infro">
<div class="name" >{{data.title}}</div> <div class="name" >{{data.storeName}}</div>
<div class="details">{{data.infro}}</div> <div class="details">{{data.storePosition}}</div>
</div> </div>
</div> </div>
</div> </div>
......
<template> <template>
<div class="staff-item"> <div class="staff-item">
<img :src="data.src" alt=""> <img :src="data.workerHomePic" alt="">
<div class="infro">{{data.bref}}</div> <div class="infro">{{data.workerName}}</div>
</div> </div>
</template> </template>
......
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
<c-header title="首页" noBack="1"></c-header> <c-header title="首页" noBack="1"></c-header>
<h-banner :data="bannerData"></h-banner> <h-banner :data="bannerData"></h-banner>
<h-item-title title="精选商家" href="/shopList"></h-item-title> <h-item-title title="精选商家" href="/shopList"></h-item-title>
<h-shop-list v-for="(item,index) in shopListData" :key="index" @click.native="toShopDetails(item.id)" :data="item"></h-shop-list> <h-shop-list v-for="(item,index) in shopListData" :key="index" @click.native="toShopDetails(item.storeId)" :data="item"></h-shop-list>
<h-item-title title="闪亮之星" href="/workerList"></h-item-title> <h-item-title title="闪亮之星" href="/workerList"></h-item-title>
<div class="staff-wrapper"> <div class="staff-wrapper">
<h-staff v-for="(item,index) in staffData" :key="index" @click.native="toDetails(item.id)" :data="item"></h-staff> <h-staff v-for="(item,index) in staffData" :key="index" @click.native="toDetails(item.workerId)" :data="item"></h-staff>
</div> </div>
</div> </div>
...@@ -20,102 +20,69 @@ import HShopList from "./components/HShopList"; ...@@ -20,102 +20,69 @@ import HShopList from "./components/HShopList";
import HItemTitle from "./components/HItemTitle"; import HItemTitle from "./components/HItemTitle";
import HStaff from "./components/HStaff"; import HStaff from "./components/HStaff";
import * as home from "../../api/home";
import axios from "axios";
export default { export default {
components: { CHeader, HBanner, HShopList, HItemTitle, HStaff }, components: { CHeader, HBanner, HShopList, HItemTitle, HStaff },
data() { data() {
return { return {
bannerData: [ bannerData: [],
{
url: "1",
href: "111"
},
{
url: "2",
href: "222"
}
],
shopListData: [
{
id: "1",
url: "12",
title: "123",
infro: "312321"
},
{
id: "2",
url: "12",
title: "123",
infro: "312321"
}
],
staffData: [ shopListData: [],
{
id: "1", staffData: []
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
}
]
}; };
}, },
beforeMount() {
this.getPageData();
},
methods: { methods: {
toShopDetails(id) { toShopDetails(id) {
this.$router.push({ name: 'shopDetails', params: { id: id }}) this.$router.push({ name: "shopDetails", params: { id: id } });
}, },
toDetails(id) { toDetails(id) {
alert(id); alert(id);
},
getPageData(cb) {
const getAdvertList = () => {
home.getAdvertList().then(res => {
this.bannerData = res.data;
});
};
const getStoreList = () => {
home.getStoreList().then(res => {
this.shopListData = res.data;
});
};
const getWorkerList = () => {
home.getWorkerList().then(res => {
this.staffData = res.data;
});
};
axios.all([getAdvertList(), getStoreList(),getWorkerList()]).then((s, f) => {
cb ? cb() : "";
});
} }
} }
}; };
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
@r:100rem; @r: 100rem;
.staff-wrapper{ .staff-wrapper {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
padding: 0 30/@r; padding: 0 30 / @r;
} }
</style> </style>
......
<template> <template>
<div class="item"> <div class="item">
<div class="img"> <div class="img">
<img :src="data.src" alt=""> <img :src="data.storeHomePic" alt="">
</div> </div>
<div class="item-infro"> <div class="item-infro">
<div class="title">{{data.title}}</div> <div class="title">{{data.storeName}}</div>
<div class="infro">{{data.infro}}</div> <div class="infro">{{data.storePosition}}</div>
<div class="adress">{{data.adress}}</div> <div class="adress">管理员:{{data.administratorsName}}</div>
</div> </div>
</div> </div>
</template> </template>
......
...@@ -10,46 +10,37 @@ ...@@ -10,46 +10,37 @@
import CHeader from '@/components/CHeader' import CHeader from '@/components/CHeader'
import SItem from './components/SItem' import SItem from './components/SItem'
import MoreShop from './components/MoreShop' import MoreShop from './components/MoreShop'
import * as shopList from "../../api/shopList"
export default { export default {
components:{CHeader,SItem,MoreShop}, components:{CHeader,SItem,MoreShop},
data(){ data(){
return { return {
shopListData:[ shopListData:[]
{
id:'1',
url:'111',
title:'1111',
infro:'1111111',
adress:'111111'
},
{
id:'2',
url:'222222',
title:'22222222',
infro:'222222222',
adress:'22222222222'
},
{
id:'3333333',
url:'33333333333333',
title:'333333333333333',
infro:'3333333333333',
adress:'33333333333333333333'
}
]
} }
}, },
beforeMount(){ beforeMount(){
this.getPageData({})
}, },
methods:{ methods:{
toDetails(id){ toDetails(id){
this.$router.push({ name: 'shopDetails', params: { id: id }}) this.$router.push({ name: 'shopDetails', params: { id: id }})
}, },
handleChooseSuccess(data){ handleChooseSuccess(data){
alert('参数'+JSON.stringify(data)) alert('参数'+JSON.stringify(data))
this.getPageData(data,()=>{
this.$refs.chooseMore.handleCancle() this.$refs.chooseMore.handleCancle()
})
},
getPageData(data,cb){
shopList.searchShopResult(data).then(res=>{
this.shopListData = res.data
cb?cb():''
})
} }
} }
} }
......
<template>
<div class="page-wrapper">
<c-header :title="title"></c-header>
<div class="web-view-content" v-html="html"></div>
</div>
</template>
<script>
import CHeader from "@/components/CHeader";
export default {
components:{CHeader},
data(){
return{
html:'',
title:''
}
},
beforeMount(){
this.html = this.$route.params.html
this.title = this.$route.params.title
}
}
</script>
<style lang="less" scoped>
@r:100rem;
.web-view-content{
background: #ff0;
padding: 20/@r;
*{
font-size: inherit!important;
}
}
</style>
<template> <template>
<div class="staff-item"> <div class="staff-item">
<img :src="data.src" alt=""> <img :src="data.workerHomePic" alt="">
<div class="infro">{{data.bref}}</div> <div class="infro">{{data.workerName}}</div>
</div> </div>
</template> </template>
......
...@@ -2,122 +2,45 @@ ...@@ -2,122 +2,45 @@
<div class="page-wrapper"> <div class="page-wrapper">
<c-header title="人员列表"></c-header> <c-header title="人员列表"></c-header>
<div class="staff-wrapper"> <div class="staff-wrapper">
<w-staff v-for="(item,index) in staffData" :key="index" :data="item" @click.native="toWorkerDetails(item.id)"></w-staff> <w-staff v-for="(item,index) in staffData" :key="index" :data="item" @click.native="toWorkerDetails(item.workerId)"></w-staff>
</div> </div>
<more-worker></more-worker> <more-worker ref="chooseMore" @emitSuccess="handleChooseSuccess"></more-worker>
</div> </div>
</template> </template>
<script> <script>
import CHeader from "@/components/CHeader"; import CHeader from "@/components/CHeader";
import WStaff from "./components/WStaff"; import WStaff from "./components/WStaff";
import MoreWorker from "./components/MoreWorker" import MoreWorker from "./components/MoreWorker"
import * as workerList from "../../api/workerList"
export default { export default {
components: { CHeader, WStaff,MoreWorker }, components: { CHeader, WStaff,MoreWorker },
data() { data() {
return { return {
staffData: [ staffData: []
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
},
{
id: "2",
url: "2",
bref: "2"
},
{
id: "1",
url: "1",
bref: "1"
}
]
}; };
}, },
beforeMount(){
this.getPageData({})
},
methods:{ methods:{
toWorkerDetails(id){ toWorkerDetails(id){
alert(id) alert(id)
},
getPageData(data,cb){
workerList.searchWorkerResult(data).then(res=>{
this.staffData = res.data
cb?cb():''
})
},
handleChooseSuccess(data){
alert('参数'+JSON.stringify(data))
this.getPageData(data,()=>{
this.$refs.chooseMore.handleCancle()
})
} }
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment