路由 uview升级 api

This commit is contained in:
luyuan 2020-07-16 10:02:57 +08:00
parent 6e727816ce
commit a2f522479b
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
6 changed files with 70 additions and 12 deletions

17
common/http.api.js Normal file
View 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
}

View 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
}

View File

@ -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
View File

@ -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="
}
}
}

View File

@ -4,7 +4,7 @@
"description": "",
"main": "main.js",
"dependencies": {
"uview-ui": "^1.3.3"
"uview-ui": "^1.5.2"
},
"devDependencies": {},
"scripts": {

View File

@ -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;
}