4249关注12704浏览
upDateImg: function () {
var that = this
wx.chooseImage({
count: 1, // 默认9
success: function (res) {
var tempFilePaths = res.tempFilePaths
that.setData({
picPath: res.tempFilePaths[0]
})
wx.uploadFile({
url: 'https://ewxedu.cn/ykssp/wx/main/v2/assetPictureUpload', //仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
header: { "Content-Type": "image/jpeg" },
name: 'file',
formData: {
wxOpenId: app.data.wxOpenId,
},
success: function (res) {
console.log(res)
var data = res.data
that.setData({
picPath: JSON.parse(data).result
})
//do something
}
})
}
})
},
formSubmit: function (e) {
var that = this
if (that.data.repairProject == '' || that.data.repairProject == undefined) {
wx.showModal({
title: '提示',
content: '请输入维修项',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
} else {
var imgUrl = ''
if (that.data.picPath != '../../images/add.png') {
imgUrl = that.data.picPath
}
wx.request({
url: 'https://ewxedu.cn/ykssp/wx/main/v2/applicationRepair', //仅为示例,并非真实的接口地址
data: {
repairProject: encodeURI(that.data.repairProject),
repairContent: encodeURI(that.data.repairContent),
repairPlace: encodeURI(that.data.repairPlace),
picPath: imgUrl,
wxOpenId: app.data.wxOpenId
},
header: { "Content-Type": "application/x-www-form-urlencoded" },
success: function (res) {
console.log(res)
var page = getCurrentPages().pop()
page.onLoad();
that.setData({
picPath: '../../images/add.png'
})
wx.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
})
}
})
}
},
-
至过去的我
2044人对此回答表示赞同
我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>