收藏
回答

ios上传图片厚刷新页面 在上传图片 上传的还是前一张

框架类型 问题类型 API/组件名称 终端类型 操作系统 微信版本 基础库版本
小程序 Bug wx.chooseImage 客户端 iOS 6.6.6 2.0.4

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

})

}

})

}


},


回答关注问题邀请回答
收藏

1 个回答

  • 疯狂的小辣椒
    疯狂的小辣椒
    2018-05-04

    你好,请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2018-05-04
    有用
    回复
登录 后发表内容