Code for upload iamges:

chooseImage: choose the images to upload

previewImage: preview the image and enable slide

  chooseImage() {
wx.chooseImage({
count: 3,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: res => {
let currentImages = res.tempFilePaths this.setData({
images: currentImages
})
},
}) }, previewImg(event) {
let target = event.currentTarget
let src = target.dataset.src wx.previewImage({
current: src,
urls: this.data.images
})
},

Upload to the server:

  uploadImage(cb) {
let commentImages = this.data.commentImages
let images = [] if (commentImages.length) {
let length = commentImages.length
for (let i = 0; i < length; i++) {
wx.uploadFile({
url: config.service.uploadUrl,
filePath: commentImages[i],
name: 'file',
success: res => {
let data = JSON.parse(res.data)
length-- if (!data.code) {
images.push(data.data.imgUrl)
} if (length <= 0) {
cb && cb(images)
}
},
fail: () => {
length--
}
})
}
} else {
cb && cb(images)
}
}, onInput(event) {
this.setData({
commentValue: event.detail.value.trim()
})
}, chooseImage() {
let currentImages = this.data.commentImages wx.chooseImage({
count: 3,
sizeType: ['compressed'],
sourceType: ['album', 'camera'],
success: res => { currentImages = currentImages.concat(res.tempFilePaths) let end = currentImages.length
let begin = Math.max(end - 3, 0) // latest three pictures
currentImages = currentImages.slice(begin, end) this.setData({
commentImages: currentImages
}) },
})
},

[Mini Programe] Upload Images的更多相关文章

  1. Arduino uno R3 ISP刷Rootloader for arduino pro mini

    找了好久才发现的,好东西.介绍怎么使用uno对mini 刷Rootloader **SOLUTION** Reinstall the Arduino Pro Mini Bootloader using ...

  2. Reinstall the Arduino Pro Mini Bootloade ISP(转)

    源:Reinstall the Arduino Pro Mini Bootloade ISP To resolve the errors I burned the bootloader to the ...

  3. arduino pro mini不能下载

    刚毕业时就知道arduino,但当时崇拜技术极致,喜欢把单片机的性能用到尽,觉得操作寄存器运行效率高,对arduino 这种高效模式贬为投机取巧,不过其中也一直对arduino 有关注. 随着芯片技术 ...

  4. elementUI vue upload完整示例

    elementUI 和vue 还有axios +java的完整示例, 代码敲了很久, 累死了, 以后用就直接复制了 ,很值吧!!! 1.html <!DOCTYPE html> <h ...

  5. Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)成功烧录方法

    问题: Arduino:1.6.3 (Windows 7), 板:"Arduino Pro or Pro Mini, ATmega328 (5V, 16 MHz)" Sketch ...

  6. UMEditor(Ueditor mini)修改图片上传路径

    UMEditor(Ueditor mini)修改图片上传路径 imageUp.ashx string pathbase = "/UpLoad/images/"; //保存文件夹在网 ...

  7. 让MacBook识别noppoo mini 84

    让MacBook识别noppoo mini 84 noppoo默认是没有mac驱动的,需要下载一个IOUSBHIDDriverDescriptorOverride否则无法noppoo的键位是识别错误的 ...

  8. 解决ngnix服务器上的Discuz!x2.5 Upload Error:413错误

    1.修改php.ini sudo nano /etc/php5/fpm/php.ini #打开php.ini找到并修改以下的参数,目的是修改上传限制 max_execution_time = 900 ...

  9. 中大东校小米路由器mini实现inode上网,ipv6 wifi【中大】【东校】【inode】【ipv6】

    还有不到4个月就要毕业了,前几天半夜没事捣鼓小米路由没想到竟然实现了wifi的ipv6. 正好又安利了同学一台小米路由mini,从刷机到inode到ipv6全搞了一遍. 这里将教程写出来,服务学弟妹. ...

随机推荐

  1. [转]Git使用基础篇

    http://www.git-scm.com/ https://try.github.io/levels/1/challenges/1 本文转自:http://www.open-open.com/li ...

  2. LN : leetcode 238 Product of Array Except Self

    lc 238 Product of Array Except Self 238 Product of Array Except Self Given an array of n integers wh ...

  3. GDB 使用小结

    GDB 使用小结 Gdb 不用说,两个字,非常强大 >.<,我最讨厌不识数的人了 本文适合GDB 初学和没学过的,如果你懂了,可以相互交流 既然说它很强大,它强大在哪里呢? 一般情况下,大 ...

  4. Python数据科学安装Numby,pandas,scipy,matpotlib等(IPython安装pandas)

    Python数据科学安装Numby,pandas,scipy,matpotlib等(IPython安装pandas) 如果还没有本地安装Python.IPython.notebook等请移步 上篇Py ...

  5. QS之shell script

    1 Invoke Mdoelsim In order to open Modelsim automatically, it is better to use a shell script to inv ...

  6. margin与padding如何进行区分

    margin与padding如何进行区分,这是很多学html人的困扰,其实说白了padding 就是内容与边框的空隙.而margin则是模块与模块的空隙.[3]

  7. HDU多校Round 4

    Solved:3 rank:405................................. B. Harvest of Apples 知道了S(n,m) 可以o(1)的求S(n - 1, m ...

  8. 【转载】文件上传命令rz和下载命令sz的安装

    一.xshell工具简介 Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Microsoft Windows 平台的TELNET 协议.其可以在Windows界面下用来访 ...

  9. Moving Tables POJ - 1083 (思维)

    题目大意 在一层楼上推桌子,每个空间一次只能推1种桌子,且消耗十分钟.可以同时推多个桌子,但是他们所占的空间不能是相交的如图 解法 真的很考验思维能力,首先考虑到这个走廊是有两排的,我瞬间想到了宿舍楼 ...

  10. rem js 自适应布局

    (function(doc, win) { resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',//o ...