seo优化网站多少钱,珠海 电商 网站建设,前端网站开发上线的流程,如何让自己网站排名提高这里写目录标题 微信小程序检测是否有存储权限wx.getSetting 图片上传从HTML中提取img标签的src属性多图片下载 微信小程序检测是否有存储权限
wx.getSetting
上传前判断是否开启存储权限#xff0c;如果不检测直接上传会出现fail的情况
var _this this
wx.getSetting({su… 这里写目录标题 微信小程序检测是否有存储权限wx.getSetting 图片上传从HTML中提取img标签的src属性多图片下载 微信小程序检测是否有存储权限
wx.getSetting
上传前判断是否开启存储权限如果不检测直接上传会出现fail的情况
var _this this
wx.getSetting({success(res) {if (res.authSetting[scope.writePhotosAlbum]) {// 已获得存储相册授权_this.writeInImg()}else {// 未获得存储相册授权wx.showModal({title: 提示,content: 需要您授权保存相册,showCancel: false,success: () {wx.openSetting({success(settingdata) {//再进行图片上传操作_this.writeInImg()}})}})}}})图片上传
从HTML中提取img标签的src属性
后端返回一个字符串内容是标签img需要截取出src中的图片链接 getImage(){const srcRegex /img\s(?:[^]*?\s)?src\s*\s*([])((?:[^\1]|\\\1|.)*?)\1/gconst result [...this.data.details.goods_content.matchAll(srcRegex)]const imgSrcs result.map(v v[2])return imgSrcs[0]},多图片下载
Page({/*** 页面的初始数据*/data: {imgList: [https://tys.zye.com/upload/1/common/20231110/207169967318.jpg,https://tys.zye.com/upload/1/common/20231110/207169967318.jpg,https://tys.zye.com/upload/1/common/20231110/207169967318.jpg, ],
}writeInImg() {let imgList this.data.imgList let imglength imgList.length; // 要下载的总条数let index 0;wx.showLoading({title: 加载中,})for (let i 0; i imgList.length; i) {wx.downloadFile({url: imgList[i],success: function(res) {var temp res.tempFilePathwx.saveImageToPhotosAlbum({filePath: temp,success(res) {index;// 全部下载完后触发if (index imglength) {wx.hideLoading();wx.showToast({title:下载成功,icon:success,duration:2000})}},fail(err){wx.hideLoading();console.log(下载失败)}})}})}},