1.提示
this.$wanlshop.msg('提示语');
2.接口
let data = {};
this.$api.post({
url:'',
data:data,
success(res){
console.log(res);
}
})
3.获取当前配置域名:
this.$store.state.common.appUrl.api
4.上传视频或图片
async test(){
var self = this;
uni.chooseMedia({
count: 9,
mediaType: ['image','video'],
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success(res) {
console.log(res);
let token = self.$store.state.user.token;
uni.request({
url: self.$store.state.common.appUrl.api + '/wanlshop/common/uploadData',
header: { token: token },
success: updata => {
uni.uploadFile({
url: updata.data.data.uploadurl,
filePath: res.tempFiles[0].tempFilePath,
formData: updata.data.data.storage == 'local' ? null : updata.data.data.multipart, // 1.0.5升级
header: { token: token },
name: 'file',
success: data => {
let path = JSON.parse(data.data).data.fullurl;
if(path.indexOf('mp4') == -1){
self.thumb.push({type:'pic',path:path});
}else{
self.thumb.push({type:'mp4',path:path})
}
if(self.thumb.length == 4){
self.thumb.splice(0,1);
}
console.log(self.thumb);
}
});
}
});
}
})
},
5.获取当前user_id或其他用户信息
console.log(this.$store.state.user.id);

这篇博客详细介绍了uni-app中如何进行消息提示、API接口调用、获取当前配置域名、上传视频或图片以及获取用户ID的操作。示例代码展示了使用$wanlshop.msg进行提示,$api.post进行接口请求,$store.state获取全局变量,uni.chooseMedia选择多媒体文件并使用uni.uploadFile上传,以及通过$store.state.user.id获取用户信息的过程。
2199

被折叠的 条评论
为什么被折叠?



