路由 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({
|
||||
...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()
|
||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -5,9 +5,9 @@
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"uview-ui": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.3.3.tgz",
|
||||
"integrity": "sha512-aDXZCptHhBCzuPujX9QyCV26y2dX7WgNpm3VX9+6fxoeA6eA8s4CneNTh5jrsKzPrUYbbEs9TSqmN7zIN3a9xQ=="
|
||||
"version": "1.5.2",
|
||||
"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": "sha1-4jDud0TIBjMJe74GU+IyvJSyAwk="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"dependencies": {
|
||||
"uview-ui": "^1.3.3"
|
||||
"uview-ui": "^1.5.2"
|
||||
},
|
||||
"devDependencies": {},
|
||||
"scripts": {
|
||||
|
@ -83,17 +83,17 @@
|
||||
<u-popup v-model="publishstate" mode="bottom">
|
||||
<view class="publish">
|
||||
<view class="list">
|
||||
<view>
|
||||
<view @click="navto('release/tosign')">
|
||||
<image></image>
|
||||
<text>直播</text>
|
||||
</view>
|
||||
<view>
|
||||
<view @click="navto('release/index')">
|
||||
<image></image>
|
||||
<text></text>
|
||||
<text>图文</text>
|
||||
</view>
|
||||
<view>
|
||||
<view @click="navto('release/video')">
|
||||
<image></image>
|
||||
<text></text>
|
||||
<text>视频</text>
|
||||
</view>
|
||||
</view>
|
||||
<image class="off"></image>
|
||||
@ -179,9 +179,10 @@ export default {
|
||||
},
|
||||
// 发布页面跳转
|
||||
release(){
|
||||
uni.navigateTo({
|
||||
url: '/pages/release/tosign'
|
||||
});
|
||||
// uni.navigateTo({
|
||||
// url: '/pages/release/tosign'
|
||||
// });
|
||||
this.publishstate = true
|
||||
},
|
||||
tabsChange(index) {
|
||||
this.swiperCurrent = index;
|
||||
@ -192,6 +193,15 @@ export default {
|
||||
this.swiperCurrent = current;
|
||||
this.current = current;
|
||||
},
|
||||
navto(url){
|
||||
this.$u.router({
|
||||
url:`/pages/${url}`
|
||||
})
|
||||
// console.log(`/pages/${url}`)
|
||||
// uni.navigateTo({
|
||||
// url: `/pages/${url}`
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -339,10 +349,14 @@ export default {
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 50rpx 84rpx 31rpx 78rpx;
|
||||
image{
|
||||
background-color: #0f0;
|
||||
}
|
||||
.list{
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
>view{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -352,6 +366,7 @@ export default {
|
||||
height: 80rpx;
|
||||
}
|
||||
>text{
|
||||
margin-top: 10rpx;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
font-weight: 400;
|
||||
@ -359,6 +374,7 @@ export default {
|
||||
}
|
||||
}
|
||||
.off{
|
||||
margin-top: 81rpx;
|
||||
width: 37rpx;
|
||||
height: 37rpx;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user