uni.showToast() 提示消息
uni.showToast({icon: 'success',title: '操作成功'
})
icon:可填
success: 显示成功图标,
error: 显示错误图标;
fail: 显示错误图标,此时title文本无长度显示;
exception: 显示异常图标,此时title文本无长度显示;
loading: 显示加载图标;
none: 不显示图标
mask:是否显示透明蒙层,防止触摸穿透,默认:false
image:自定义图标的本地路径(app端暂不支持gif)
uni.showLoading() 显示 loading 提示框, 需主动调用
uni.showLoading({title: '加载中...',mask:true,//加载的时候不能点
});
uni.hideLoading 才能关闭提示框
uni.hideLoading()
uni.chooseMedia()拍摄或从手机相册中选择图片或视频
uni.uploadFile()上传文件
以下是一个例子,需求是拍照或者上传图片带参数给后端,成功之后跳转页面
photograph() {let that = thisuni.chooseMedia({count: 1,success(res) {uni.showLoading({title: '加载中...',mask:true,});uni.uploadFile({url: url + '/user/faceMatch',filePath: res.tempFiles[0].tempFilePath,name: 'file',formData: {'shopId': that.$store.state.shopId,'nickName': '',},success: (res) => {console.log(res);let tempdata = JSON.parse(res.data)if (tempdata.code === 200) {console.log(res);uni.navigateTo({url: `/pages/manualFaceScan/destruction?id=${tempdata.data.userId}`})uni.hideLoading();} else {uni.showToast({icon: 'error',title: '识别失败'})}},fail(e) {console.log(e, 'eeee');}})},fail(err) {console.log(err, 'err');}})
},