路由 uview升级 api
This commit is contained in:
parent
6e727816ce
commit
a2f522479b
17
common/http.api.js
Normal file
17
common/http.api.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
// 此处第二个参数vm,就是我们在页面使用的this,你可以通过vm获取vuex等操作,更多内容详见uView对拦截器的介绍部分:
|
||||||
|
// https://uviewui.com/js/http.html#%E4%BD%95%E8%B0%93%E8%AF%B7%E6%B1%82%E6%8B%A6%E6%88%AA%EF%BC%9F
|
||||||
|
const install = (Vue, vm) => {
|
||||||
|
// 此处没有使用传入的params参数
|
||||||
|
let api = {
|
||||||
|
getLiveSpec(){
|
||||||
|
return vm.$u.get("Streaming/getLiveSpec")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 将各个定义的接口名称,统一放进对象挂载到vm.$u.api(因为vm就是this,也即this.$u.api)下
|
||||||
|
vm.$u.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
install
|
||||||
|
}
|
17
common/http.interceptor.js
Normal file
17
common/http.interceptor.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const install = (Vue, vm) => {
|
||||||
|
// 此为自定义配置参数,具体参数见上方说明
|
||||||
|
Vue.prototype.$u.http.setConfig({
|
||||||
|
baseUrl: 'https://dmmall.sdbairui.com//storeapi/',
|
||||||
|
loadingText: '努力加载中~',
|
||||||
|
loadingTime: 800,
|
||||||
|
// 设置自定义头部content-type
|
||||||
|
// header: {
|
||||||
|
// 'content-type': 'xxx'
|
||||||
|
// }
|
||||||
|
// ......
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
install
|
||||||
|
}
|
8
main.js
8
main.js
@ -11,4 +11,12 @@ App.mpType = 'app'
|
|||||||
const app = new Vue({
|
const app = new Vue({
|
||||||
...App
|
...App
|
||||||
})
|
})
|
||||||
|
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
|
||||||
|
import httpInterceptor from '@/common/http.interceptor.js'
|
||||||
|
Vue.use(httpInterceptor, app)
|
||||||
|
|
||||||
|
// http接口API集中管理引入部分
|
||||||
|
import httpApi from '@/common/http.api.js'
|
||||||
|
Vue.use(httpApi, app)
|
||||||
|
|
||||||
app.$mount()
|
app.$mount()
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -5,9 +5,9 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uview-ui": {
|
"uview-ui": {
|
||||||
"version": "1.3.3",
|
"version": "1.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.3.3.tgz",
|
"resolved": "https://registry.npm.taobao.org/uview-ui/download/uview-ui-1.5.2.tgz?cache=0&sync_timestamp=1594781920423&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fuview-ui%2Fdownload%2Fuview-ui-1.5.2.tgz",
|
||||||
"integrity": "sha512-aDXZCptHhBCzuPujX9QyCV26y2dX7WgNpm3VX9+6fxoeA6eA8s4CneNTh5jrsKzPrUYbbEs9TSqmN7zIN3a9xQ=="
|
"integrity": "sha1-4jDud0TIBjMJe74GU+IyvJSyAwk="
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "main.js",
|
"main": "main.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"uview-ui": "^1.3.3"
|
"uview-ui": "^1.5.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -83,17 +83,17 @@
|
|||||||
<u-popup v-model="publishstate" mode="bottom">
|
<u-popup v-model="publishstate" mode="bottom">
|
||||||
<view class="publish">
|
<view class="publish">
|
||||||
<view class="list">
|
<view class="list">
|
||||||
<view>
|
<view @click="navto('release/tosign')">
|
||||||
<image></image>
|
<image></image>
|
||||||
<text>直播</text>
|
<text>直播</text>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view @click="navto('release/index')">
|
||||||
<image></image>
|
<image></image>
|
||||||
<text></text>
|
<text>图文</text>
|
||||||
</view>
|
</view>
|
||||||
<view>
|
<view @click="navto('release/video')">
|
||||||
<image></image>
|
<image></image>
|
||||||
<text></text>
|
<text>视频</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<image class="off"></image>
|
<image class="off"></image>
|
||||||
@ -179,9 +179,10 @@ export default {
|
|||||||
},
|
},
|
||||||
// 发布页面跳转
|
// 发布页面跳转
|
||||||
release(){
|
release(){
|
||||||
uni.navigateTo({
|
// uni.navigateTo({
|
||||||
url: '/pages/release/tosign'
|
// url: '/pages/release/tosign'
|
||||||
});
|
// });
|
||||||
|
this.publishstate = true
|
||||||
},
|
},
|
||||||
tabsChange(index) {
|
tabsChange(index) {
|
||||||
this.swiperCurrent = index;
|
this.swiperCurrent = index;
|
||||||
@ -192,6 +193,15 @@ export default {
|
|||||||
this.swiperCurrent = current;
|
this.swiperCurrent = current;
|
||||||
this.current = current;
|
this.current = current;
|
||||||
},
|
},
|
||||||
|
navto(url){
|
||||||
|
this.$u.router({
|
||||||
|
url:`/pages/${url}`
|
||||||
|
})
|
||||||
|
// console.log(`/pages/${url}`)
|
||||||
|
// uni.navigateTo({
|
||||||
|
// url: `/pages/${url}`
|
||||||
|
// });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -339,10 +349,14 @@ export default {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 50rpx 84rpx 31rpx 78rpx;
|
padding: 50rpx 84rpx 31rpx 78rpx;
|
||||||
|
image{
|
||||||
|
background-color: #0f0;
|
||||||
|
}
|
||||||
.list{
|
.list{
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
width: 100%;
|
||||||
>view{
|
>view{
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -352,6 +366,7 @@ export default {
|
|||||||
height: 80rpx;
|
height: 80rpx;
|
||||||
}
|
}
|
||||||
>text{
|
>text{
|
||||||
|
margin-top: 10rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
@ -359,6 +374,7 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.off{
|
.off{
|
||||||
|
margin-top: 81rpx;
|
||||||
width: 37rpx;
|
width: 37rpx;
|
||||||
height: 37rpx;
|
height: 37rpx;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user