// 上传营业执照
fail_yingye(e) {
var that = this;
var uniacid = app.siteInfo.uniacid;
var idx = e.currentTarget.dataset.index;
var yingye = that.data.yingye;
var openid = wx.getStorageSync('openid')
wx.chooseImage({
count: 1, // 默认9
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var yingyes = that.data.yingye;
var tempFilePath = res.tempFilePaths[0];
yingyes[idx].src = tempFilePath;
wx.uploadFile({
url: that.data.url + 'app/index.php?i=' + uniacid + '&c=entry&a=wxapp&do=Upload&m=pinba',
filePath: tempFilePath,
name: 'upfile',
formData: {
// 'path': 'wxchat'
},
success: function (res) {
console.log(res.data)
that.setData({
yingyes: res.data,
})
// app.util.request({
// 'url': 'entry/wxapp/Shenhe',
// data: {
// openid: openid,
// uplogo: res.data
// },
// success: function (res) {
// console.log(res.data.data)
// // that.setData({
// // myxiaofeisum: res.data.data
// // })
// },
// fail: function (err) {
// console.log(err)
// },
// })
},
fail: function (res) {
console.log(res)
},
})
that.setData({
yingye: yingyes
})
console.log(yingye)
},
fail: function (res) { }
})
},
url获取
app.util.request({
'url': 'entry/wxapp/url',
'cachetime': '0',
success: function (res) {
console.log(res)
that.setData({
url: res.data
})
},
})
<!--上传营业执照 -->
<view class='yingye sj_name'>
<view class='font28 color_666'>上传营业执照</view>
<view class='yingye_img' wx:for="{{yingye}}" wx:key="yy">
<image src='{{item.src}}' data-index='{{index}}' bindtap='fail_yingye'></image>
<view class='font26 color_666 txt_center'>{{item.txt}}</view>
</view>
</view>
来源:https://www.cnblogs.com/isuansuan/p/9957479.html