首先选择图片,然后循环,再就是在点击发布的时候循环图片地址赋值,包括删除命令

js代码:

  //选择图片
uploadImgAdd: function(e) {
var imgs = this.data.imgs;
console.log(imgs)
wx.chooseImage({
sizeType: ['original', 'compressed'],
sourceType: ['album', 'camera'],
success: (res) => {
console.log(res)
let tempFilePaths = res.tempFilePaths;
let imgs = this.data.imgs;
console.log('imgs')
console.log(imgs)
//上传的图片
for (var i = 0; i < tempFilePaths.length; i++) {
if (imgs.length >= 9) {
return false;
} else {
imgs.push(tempFilePaths[i])
}
}
//上传的图片放到页面上
this.setData({
imgs: imgs
})
}
})
}, /**
* 获取上传图片地址
*/
//单击发布上传图片和内容
bindFormSubmit: function(e) {
var imgArr = this.data.imgs;
this.addPic(e, imgArr)
},
addPic: function(e, imgArr) {
console.log("imgArr")
console.log(imgArr) let uploadimagsSrc = this.data.uploadimagsSrc;
console.log("uploadimagsSrc")
console.log(uploadimagsSrc)
for (let i in imgArr) {
wx.uploadFile({
url: app.data.urls + 'images/Picture',
filePath: imgArr[i],
header: {
'content-type': 'multipart/form-data'
},
name: 'file',
success: res => {
console.log(res)
let data = res.data;
console.log(data)
console.log([...uploadimagsSrc, data])
uploadimagsSrc = [...uploadimagsSrc, data];
console.log(uploadimagsSrc)
this.setData({
uploadimagsSrc: uploadimagsSrc
})
},
})
} let timer = setInterval(() => {
//间歇调用
if (uploadimagsSrc.length == imgArr.length) {
console.log(uploadimagsSrc)
console.log(imgArr)
debugger
this.sendMessageInfo(e, uploadimagsSrc);
clearInterval(timer); //可取消由 setInterval() 函数设定的定时执行操作
}
}, 500)
},
sendMessageInfo: function(e, imagsSrc) {
var formData = e.detail.value.message
if (formData.length == 0) {
wx.showToast({
title: '意见反馈内容不能为空,说几句话吧~',
icon: 'none',
duration: 1500
})
return false;
}
var replaceLeftRig = formData.replace(/(^\s*)|(\s*$)/g, "").length
if (replaceLeftRig < 15) {
wx.showToast({
title: '意见反馈内容不能少于15个字',
icon: 'none',
duration: 1500
})
return false;
}
imagsSrc = imagsSrc.join(';')
wx.request({
url: app.data.urls + 'feedback/insertCustomerFeedback',
data: {
"customerId": app.data.customerId,
"feedbackMessages": formData,
"imagesAddress": imagsSrc,
},
method: "POST",
header: {
'content-type': 'application/json' // 默认值
},
success: function(res) {
console.log(res)
/**
*
* 异常判断
*
*
*/
if (res.data.status == 200) {
wx.showModal({
content: '谢谢您提交的反馈,后台的小哥哥会第一时间收到哦~',
showCancel: false,
confirmText: "知道了",
success: function(res) {
if (res.confirm) {
wx.navigateBack({
delta: 1
})
}
}
});
} else {
wx.showModal({
content: '系统繁忙',
showCancel: false,
confirmText: "知道了",
success: res => {
console.log(res)
}
});
} }
})
}, //删除图片
uploadImgClose: function(e) {
var imgs = this.data.imgs;
var index = e.currentTarget.dataset.index;
imgs.splice(index, 1);
this.setData({
imgs: imgs
});
// console.log(imgs)
}, feedBack/feedBack

微信小程序 上传图的功能的更多相关文章

  1. 微信小程序上传Excel文本文件功能

    问题: 在开发过程中会发现微信小程序有很多功能都还不能满足我们的需求,谁叫客户就是上帝呢,前几天小编遇到了这么个问题,就是用微信小程序上传文件,但是还以为微信带有这个模块,可是查了许久还是没有找到,只 ...

  2. 微信小程序上传多张图片,及php后台处理

    微信小程序上传多张图片,级小程序页面布局直接来代码index.wxml <view class='body' style='width:{{windowWidth}}px;height:{{wi ...

  3. 微信小程序上传与下载文件

    需要准备的工作: ①.建立微信小程序工程,编写以下代码. ②.通过IDE建立springboot+web工程,编写接收文件以及提供下载文件的方式,并将上传的文件相关信息记录在mysql数据库中.具体请 ...

  4. 微信小程序上传后发布或者体验版测试无数据解决办法

    在做微信小程序开发的过程中,发现小程序在本地调用接口的数据都显示,但是上传之后,发现手机体验没有数据.以下为解决办法: 1.先清除缓存试试. 2.打开微信小程序工具右上角的详情——项目设置,将“不校验 ...

  5. Taro 微信小程序 上传文件到minio

    小程序前端上传文件不建议直接引用minio的js npm包,一来是这个包本身较大,会影响小程序的体积,二来是ak sk需要放到前端存储,不够安全,因此建议通过请求后端拿到签名数据后上传. 由于小程序的 ...

  6. 微信小程序-上传照片-多张显示

    图片就是一个简单的效果 实现 先看wxml和wxss代码 <view class='in-demand'> <view class='dema-title'> <text ...

  7. 微信小程序上传文件遇到的坑

    在开发小程序时,使用的花生壳做的内网映射,域名使用花生壳卖的https域名 在做小程序文件上传时,调用接口,老是报错. Caused by: org.apache.commons.fileupload ...

  8. 微信小程序-上传下载

    wx.uploadFile(OBJECT) 上传 将本地资源上传到开发者服务器.如页面通过 wx.chooseImage(图片)/wx.chooseVideo(视频) 等接口获取到一个本地资源的临时文 ...

  9. 微信小程序上传一或多张图片

    一.要点 1.选取图片 wx.chooseImage({ sizeType: [], // original 原图,compressed 压缩图,默认二者都有 sourceType: [], // a ...

随机推荐

  1. sklearn学习3----模型选择和评估(1)训练集和测试集的切分

    来自链接:https://blog.csdn.net/zahuopuboss/article/details/54948181 1.sklearn.model_selection.train_test ...

  2. Github添加SSHkey

    Git详细教程可参考廖雪峰的Git教程 1. 打开 Git Bash,输入cd ~/.ssh——回车(看你是否有了ssh key 密钥,有了就备份): 2. 输入ssh-keygen -t rsa - ...

  3. python课堂知识的几点总结

    1.执行python脚本的两种方式:利用python进入解释器和找到可执行文件1.py 2.位和字节:一个字节是8位,计算机运行时是以字节为单位,存储的时候是以位为单位 3.编码发展:ASCII只有0 ...

  4. [LeetCode] 350. 两个数组的交集 II intersection-of-two-arrays-ii(排序)

    思路: 先找到set的交集,然后分别计算交集中的每个元素在两个原始数组中出现的最小次数. class Solution(object): def intersect(self, nums1, nums ...

  5. python 面向对象 类的内置方法

    判断是不是类cls的对象 class A: pass a = A() print(isinstance(a,A)) 判断类sub是不是super的子类 class A: pass class B(A) ...

  6. [using_microsoft_infopath_2010]Chapter4 使用SharePoint列表表单

    本章概要: 1.把SharePoint列表表单转换成InfoPath可用形式 2.使用字段和控件 3.规划表单布局 4.理解列表表单的局限性

  7. AWS使用心得:当初我曾错过的那些宝贵经验

    在今天的文章中,我整理出了大量当初以前错过.而至今仍将我追悔莫及的Amazon Web Services(简称AWS)使用心得. 在几年来的实践其中,我通过在AWS之上新手构建及部署各类应用程序而积累 ...

  8. 浅谈SaaS应用开发的难度

    近期做SaaS应用的非常多,这样的模式是未来的一种趋势,这样的模式的最大优点就是云计算的优点--节约资源.网上有非常多人觉得SaaS非常easy,就是一个多用户租赁模式.这样的认识也不能说不正确.由于 ...

  9. react-route4 按需加载配置心得

    本篇文章主要记录笔者项目中使用 react-route + webpack 做路由按需加载的心得,可能只有笔者一个人看,权当日记了.   很久很久以前,react-route还是2.X和3.X版本的时 ...

  10. JavaScript中Array方法总览

    title: JavaScript中Array方法总览 toc: true date: 2018-10-13 12:48:14 push(x) 将x添加到数组最后,可添加多个值,返回数组长度.改变原数 ...