This commit is contained in:
zmr900709 2020-07-16 14:36:07 +08:00
commit 34e1c2811a
10 changed files with 198 additions and 101 deletions

View File

@ -1,13 +0,0 @@
export default {
init(vm){
return {
// 首页协议 列子
// documentInfo({document_code}) {
// return vm.$u.post('StartUp/documentInfo', {
// document_code : document_code
// });
// },
}
}
}

View File

@ -1,14 +1,21 @@
// 此处第二个参数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
// import shop from "./api/shop"
import user from "./api/user"
const install = (Vue, vm) => {
let userApi = user.init(vm)
// let shopApi = shop.init(vm)
// 此处没有使用传入的params参数
let api = {
getLiveSpec(){
return vm.$u.get("Streaming/getLiveSpec")
},
login({member_name,member_password}){
return vm.$u.post("Login/login",{member_name,member_password})
},
createLivesp({spec_name}){
return vm.$u.post("Streaming/createLivesp",{spec_name})
}
}
// 将各个定义的接口名称统一放进对象挂载到vm.$u.api(因为vm就是this也即this.$u.api)下
vm.$u.api = {...userApi};
vm.$u.api = api;
}
export default {

View File

@ -1,62 +1,20 @@
const install = (Vue, vm) => {
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
baseUrl: 'https://dmmall.sdbairui.com/api',
baseUrl: 'https://dmmall.sdbairui.com//storeapi',
loadingText: '努力加载中~',
loadingTime: 800
loadingTime: 800,
// 设置自定义头部content-type
// header: {
// "Authorization" : "122"
// }
// ......
});
// 请求拦截配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
// 引用token
// 方式一存放在vuex的token假设使用了uView封装的vuex方式
// 见https://uviewui.com/components/globalVariable.html
// config.header.token = vm.token;
// 方式二如果没有使用uView封装的vuex方法那么需要使用$store.state获取
// config.header.token = vm.$store.state.token;
// 方式三如果token放在了globalData通过getApp().globalData获取
// config.header.token = getApp().globalData.username;
// 方式四如果token放在了Storage本地存储中拦截是每次请求都执行的
// 所以哪怕您重新登录修改了Storage下一次的请求将会是最新值
const token = uni.getStorageSync('token');
// console.log(token);
// config.header.token = token;
config.header.Authorization = 'Bearer' + " " + token;
// config.header.Token = 'xxxxxx';
// 可以对某个url进行特别处理此url参数为this.$u.get(url)中的url值
// if(config.url == '/user/login') config.header.noToken = true;
// 最后需要将config进行return
return config;
// 如果return一个false值则会取消本次请求
// if(config.url == '/user/rest') return false; // 取消某次请求
}
// // 响应拦截,判断状态码是否通过
// Vue.prototype.$u.http.interceptor.response = (res) => {
// if(res.code == 200) {
// // res为服务端返回值可能有coderesult等字段
// // 这里对res.result进行返回将会在this.$u.post(url).then(res => {})的then回调中的res的到
// // 如果配置了originalData为true请留意这里的返回值
// return res.result;
// } else if(res.code == 201) {
// // 假设201为token失效这里跳转登录
// vm.$u.toast('验证失败,请重新登录');
// setTimeout(() => {
// // 此为uView的方法详见路由相关文档
// vm.$u.route('/pages/user/login')
// }, 1500)
// return false;
// } else {
// // 如果返回false则会调用Promise的reject回调
// // 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中res为服务端的返回值
// return false;
// }
// }
}
export default {

View File

@ -4,8 +4,8 @@
<view>
<view class="titles">标签</view>
<view class="form-view" @click="show_add()">+ 新建标签</view>
<view class="form-view" :class=" {'cur': rSelect.indexOf(index)!=-1} " @tap="tapInfo(index)" v-for="(item,index) in fileListes"
:key="index">{{item}}</view>
<view class="form-view" :class=" {'cur': rSelect.indexOf(item.id)!=-1} " @tap="tapInfo(item.id)" v-for="(item,index) in fileListes"
:key="index">{{item.spec_name}}</view>
</view>
<!-- 添加标签的按钮 -->
<u-popup v-model="show" mode="center" border-radius="14" :closeable="true">
@ -32,11 +32,11 @@
// 使
action: 'http://www.example.com/upload',
fileList: [],
fileListes: ["美妆", "博主穿搭", "美妆", "美妆", "美妆", "美妆", "美妆", "博主穿搭"],
show: false,
rSelect: []
}
},
props:['fileListes'],
methods: {
show_add() {
console.log(this.show)

View File

@ -11,10 +11,6 @@ App.mpType = 'app'
const app = new Vue({
...App
})
app.$mount()
// http拦截器将此部分放在new Vue()和app.$mount()之间才能App.vue中正常使用
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
@ -22,4 +18,5 @@ Vue.use(httpInterceptor, app)
// http接口API集中管理引入部分
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
app.$mount()

5
package-lock.json generated
View File

@ -6,8 +6,13 @@
"dependencies": {
"uview-ui": {
"version": "1.5.2",
<<<<<<< HEAD
"resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.5.2.tgz",
"integrity": "sha512-FV9G+gZTAZKEE2m85ahIbIRiC/fdzTl+eNXDIMBoyc9b+fQWQhEtmAfu6huu7AtKuTI6gfqaYn6WGcmqYvr76w=="
=======
"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="
>>>>>>> fa383397b331ec0091096becf886f978cc1277fc
}
}
}

View File

@ -3,7 +3,29 @@
"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
},
"pages": [
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"titleNView": false,
"animationType": "slide-in-bottom"
}
}
},
{
"path": "pages/release/tosign",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"titleNView": false,
"backgroundColor": "#f00",
"animationType": "slide-in-bottom"
}
}
},
{
"path": "pages/messages/messagesList",
"style": {
@ -39,17 +61,6 @@
}
}
},
{
"path": "pages/login/login",
"style": {
"navigationBarTitleText": "",
"navigationStyle": "custom",
"app-plus": {
"titleNView": false,
"animationType": "slide-in-bottom"
}
}
},
{
"path": "pages/release/video",
"style": {
@ -191,5 +202,29 @@
"navigationBarTitleText": "uni-app",
"navigationBarBackgroundColor": "#F8F8F8",
"backgroundColor": "#F8F8F8"
},
"tabBar":{
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"height": "50px",
"fontSize": "10px",
"iconWidth": "24px",
"spacing": "3px",
"list": [{
"pagePath": "pages/index/index",
"iconPath": "",
"selectedIconPath": "",
"text": "首页",
"selectedColor":"#FBFBFB"
}, {
"pagePath": "pages/user/index",
"iconPath": "",
"selectedIconPath": "",
"text": "我的",
"selectedColor":"#FBFBFB"
}]
}
}

View File

@ -46,6 +46,7 @@
<view class="title">投诉简介</view>
<textarea placeholder-style="color:#999999" placeholder="请输入内容" />
</view>
<!-- 事件 -->
<view class="btn" @click="showComplaint=true">确定</view>
</view>
</scroll-view>
@ -65,7 +66,7 @@
</scroll-view>
</swiper-item>
</swiper>
<view class="release-btn">
<view class="release-btn" @click="publish">
<image src="/static/home/1.png"></image>
<view class="text" @click="release()">发布</view>
</view>
@ -76,7 +77,26 @@
<view>投诉成功</view>
<view>请等待审核结果</view>
</view>
<view class="btn">确认</view>
<view class="btn" @click="showComplaint = false">确认</view>
</view>
</u-popup>
<u-popup v-model="publishstate" mode="bottom">
<view class="publish">
<view class="list">
<view @click="navto('release/tosign')">
<image></image>
<text>直播</text>
</view>
<view @click="navto('release/index')">
<image></image>
<text>图文</text>
</view>
<view @click="navto('release/video')">
<image></image>
<text>视频</text>
</view>
</view>
<image class="off"></image>
</view>
</u-popup>
</view>
@ -136,7 +156,8 @@ export default {
}
]
}
]
],
publishstate:true
}
},
components: {
@ -146,6 +167,9 @@ export default {
},
methods: {
publish(){
},
setWorker(e) {
// console.log(e);
this.worker = {
@ -155,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;
@ -168,6 +193,15 @@ export default {
this.swiperCurrent = current;
this.current = current;
},
navto(url){
this.$u.route({
url:`/pages/${url}`
})
// console.log(`/pages/${url}`)
// uni.navigateTo({
// url: `/pages/${url}`
// });
}
}
}
</script>
@ -309,5 +343,41 @@ export default {
margin: 0 auto;
}
}
.publish{
display: flex;
flex-direction: column;
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;
align-items: center;
>image{
width: 94rpx;
height: 80rpx;
}
>text{
margin-top: 10rpx;
font-size: 28rpx;
color: #333;
font-weight: 400;
}
}
}
.off{
margin-top: 81rpx;
width: 37rpx;
height: 37rpx;
}
}
}
</style>

View File

@ -9,15 +9,16 @@
<view class="title">账号登录</view>
<view class="labales">
<image src=""></image>
<input type="tel" placeholder="请输入账号" />
<input v-model="zhanghao" type="tel" placeholder="请输入账号" />
</view>
<view class="labales">
<image src=""></image>
<input type="password" placeholder="请输入密码" />
<input v-model="mima" type="password" placeholder="请输入密码" />
</view>
</view>
<!-- denglu QQ weixin -->
<u-button>{{login}}</u-button>
<u-button @click="logins">{{login}}</u-button>
<u-toast ref="uToast" />
</view>
</view>
</template>
@ -32,6 +33,8 @@
value: '',
login: '登录',
show: false,
zhanghao:"",
mima:""
};
},
@ -54,6 +57,34 @@
},
loading(){
},
logins(){
this.$u.api.login({member_name:this.zhanghao,member_password:this.mima}).then((res)=>{
console.log(res)
if(res.errCode != 0){
this.$refs.uToast.show({
title: res.message,
type: 'error'
})
}else{
uni.setStorageSync("token",res.data.token)
uni.setStorageSync("userinfo",res.data)
this.$u.route({
url:"/pages/index/index",
type:"switchTab"
})
}
})
}
},
onLoad(){
let token = uni.getStorageSync('token');
if(token != undefined && token){
this.$u.route({
url:"/pages/index/index"
})
}
}
};

View File

@ -26,7 +26,7 @@
</u-form-item>
</u-form>
<!-- 标签的引入 -->
<tap_tosign></tap_tosign>
<tap_tosign :fileListes="fileListes"></tap_tosign>
<view class="titles">直播封面图</view>
<u-upload :max-count="1" :show-progress="true" del-color="#ececec" upload-text="上传" del-bg-color="#fff"></u-upload>
</view>
@ -56,7 +56,8 @@
max : '优秀的标题可以卖的更好哦~',
titleMaxLength : '20',
show: false,
relerest: '开始直播'
relerest: '开始直播',
fileListes:[]
};
},
@ -89,6 +90,12 @@
this.max = String(this.max).slice(0, this.titleMaxLength);
}
}
},
onLoad(){
this.$u.api.getLiveSpec().then((res)=>{
console.log(res)
this.fileListes = res.data
})
}
};
</script>