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
})
}
})
}
},
本文来自微信小程序开发者论坛 微信小程序工厂 http://www.xcxgc.com 转载请保留。
微信小程序开发者回答:
娇***:
你好,请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。
本文网址:http://www.91bianli.com/kaifazhinan/59190.html