// 公共域名挂载原型链 这是main.js 里加了个global
Vue.prototype.global = {
url: 'http://sbb.nuofengtc.com'
}
//页面里直接this.global.url
uni.chooseImage({
count: 1,
success: (res) => {
uni.uploadFile({
url: this.global.url + '/index.php/api/common/upload',//地址
filePath: res.tempFilePaths[0],//获取本地图片地址
name: 'file',//类型
success: (resimg) => {
let data = JSON.parse(resimg.data);
if (data.code == 1) {
this.detail.tasksteps[index].url.push(data.data
.url); // 用于展示
this.textObj.url.push(data.data.url); // 用于验证提交
}
}
})
}
})
// 保存图片
saveImage(url) {
if (this.detail.type == 0) {
uni.saveImageToPhotosAlbum({
filePath: this.global.url + url,
success: function() {
uni.showToast({
title: '保存成功',
icon: 'none'
})
}
})
} else {
let str = this.detail.type == 6 ? '请点击报名' : this.detail.type == 4 ? '提交成功,等待审核' : '该任务待提交'
uni.showToast({
title: str,
icon: 'none'
})
}
},
// 预览图片
perviewImg(url) {
uni.previewImage({
urls: url.map(i => i = this.global.url + i),
indicator: 'number',
loop: true
})
},