当前位置: 首页 > news >正文

食品餐饮网站建设企业网站营销实现方式

食品餐饮网站建设,企业网站营销实现方式,制作视频app,设计师常用的网站uniapp下载&打开实现方案,支持安卓ios和h5 Android: 1、申请本地存储读写权限 2、创建文件夹(文件夹不存在即创建) 3、下载文件 ios: 1、下载文件 2、保存到本地,需要打开文件点击储存 使用方法&…

uniapp下载&打开实现方案,支持安卓ios和h5

Android:
1、申请本地存储读写权限
2、创建文件夹(文件夹不存在即创建)
3、下载文件

ios:
1、下载文件
2、保存到本地,需要打开文件点击储存

使用方法:

downloadFile(fileUrl, fileName)

file.js

let downloadFilePath = '/storage/emulated/0/yulong-ys-files'
// 创建文件夹
export const createDir = () => {return new Promise((resolve, reject) => {// 申请本地存储读写权限plus.android.requestPermissions(['android.permission.WRITE_EXTERNAL_STORAGE','android.permission.READ_EXTERNAL_STORAGE','android.permission.INTERNET','android.permission.ACCESS_WIFI_STATE'], success => {const File = plus.android.importClass('java.io.File')let file = new File(downloadFilePath)// 文件夹不存在即创建if (!file.exists()) {file.mkdirs()resolve()}resolve()}, error => {Tips.toast('无法获取权限,文件下载将出错')reject(error)})})}// 下载文件操作
async function doDownloadFile(url, fileName, options, osName) {if (osName === 'Android') {await createDir()}Tips.loading('正在下载...')let dTask = plus.downloader.createDownload(url, options, async (d, status) => {Tips.hideLoading()if (status == 200) {plus.io.convertLocalFileSystemURL(d.filename)await Tips.confirm('文件已保存,是否打开?')uni.openDocument({filePath: d.filename,success: () => {console.log('成功打开')}})} else {console.log('下载失败')console.log(d)Tips.toast('下载失败')Tips.hideLoading()plus.downloader.clear()}})dTask.start()
}// 下载文件
export function downloadFile(url, fileName) {if (!url) {Tips.toast('下载地址不能为空')return Promise.reject('下载地址不能为空')}// #ifdef H5window.location.href = url// #endif// #ifdef APP-PLUSlet osName = plus.os.name;if (osName === 'Android') {doDownloadFile(url, fileName, {filename: 'file://' + downloadFilePath + '/' + fileName}, osName)} else {doDownloadFile(url, fileName, {}, osName)}// #endif
}

Tips.js

/*** 提示与加载工具类*/
export default class Tips {constructor() {this.isLoading = false;}/*** 弹出提示框*/static success(title, duration = 1000) {setTimeout(() => {uni.showToast({title: title,icon: "success",mask: true,duration: duration});}, 300);if (duration > 0) {return new Promise((resolve, reject) => {setTimeout(() => {resolve();}, duration);});}}/*** 弹出确认窗口*/static confirm(content, ops = {}, payload = {}) {return new Promise((resolve, reject) => {uni.$showModal({content: content,...ops,success: res => {if (res.confirm) {resolve(payload);} else if (res.cancel) {reject(payload);}},fail: res => {reject(payload);}});});}static toast(title, onHide = undefined, icon = "none") {setTimeout(() => {uni.showToast({title: title,icon: icon,mask: true,duration:1500});}, 0);// 隐藏结束回调if (onHide) {setTimeout(() => {onHide();}, 1500);}}/*** 错误框*/static error(title, onHide) {uni.showToast({title: title,icon: 'error',mask: true,duration: 1500});// 隐藏结束回调if (onHide) {setTimeout(() => {onHide();}, 1500);}}/*** 弹出加载提示*/static loading(title = "加载中") {if (Tips.isLoading) {return;}Tips.isLoading = true;uni.showLoading({title: title,mask: true});}/*** 加载完毕*/static hideLoading() {if (Tips.isLoading) {Tips.isLoading = false;uni.hideLoading();}}
}/*** 静态变量,是否加载中*/
Tips.isLoading = false;

参考博客,在次基础上做了修改


文章转载自:
http://ratel.rdgb.cn
http://iby.rdgb.cn
http://mf.rdgb.cn
http://lancashire.rdgb.cn
http://gilbertian.rdgb.cn
http://chloralose.rdgb.cn
http://lymphoblastic.rdgb.cn
http://utmost.rdgb.cn
http://gaucherie.rdgb.cn
http://pandoor.rdgb.cn
http://cocarcinogen.rdgb.cn
http://rayah.rdgb.cn
http://bronchoscope.rdgb.cn
http://sanitize.rdgb.cn
http://saddlebag.rdgb.cn
http://heptahedron.rdgb.cn
http://breslau.rdgb.cn
http://corpora.rdgb.cn
http://streetcar.rdgb.cn
http://dissective.rdgb.cn
http://miami.rdgb.cn
http://subgraph.rdgb.cn
http://bough.rdgb.cn
http://theoretician.rdgb.cn
http://broomie.rdgb.cn
http://settings.rdgb.cn
http://mophead.rdgb.cn
http://molluscan.rdgb.cn
http://agrypnotic.rdgb.cn
http://anytime.rdgb.cn
http://suffocating.rdgb.cn
http://cupule.rdgb.cn
http://notoungulate.rdgb.cn
http://raceabout.rdgb.cn
http://economics.rdgb.cn
http://peastick.rdgb.cn
http://fictionalize.rdgb.cn
http://sideroscope.rdgb.cn
http://uloid.rdgb.cn
http://romanise.rdgb.cn
http://randomizer.rdgb.cn
http://desirous.rdgb.cn
http://humblingly.rdgb.cn
http://uncover.rdgb.cn
http://bald.rdgb.cn
http://undipped.rdgb.cn
http://fortifiable.rdgb.cn
http://mollweide.rdgb.cn
http://horde.rdgb.cn
http://gullable.rdgb.cn
http://complacently.rdgb.cn
http://gfr.rdgb.cn
http://archaeology.rdgb.cn
http://conflictive.rdgb.cn
http://iceland.rdgb.cn
http://allnighter.rdgb.cn
http://shellheap.rdgb.cn
http://cytosol.rdgb.cn
http://trihedron.rdgb.cn
http://recentness.rdgb.cn
http://ragbolt.rdgb.cn
http://silverbeater.rdgb.cn
http://aucuba.rdgb.cn
http://outsourcing.rdgb.cn
http://pdsa.rdgb.cn
http://candiot.rdgb.cn
http://gammadia.rdgb.cn
http://anethole.rdgb.cn
http://salicylaldehyde.rdgb.cn
http://affrontive.rdgb.cn
http://punchboard.rdgb.cn
http://indurative.rdgb.cn
http://daltonian.rdgb.cn
http://keyer.rdgb.cn
http://bis.rdgb.cn
http://lagan.rdgb.cn
http://warder.rdgb.cn
http://recourse.rdgb.cn
http://corsica.rdgb.cn
http://archaeologize.rdgb.cn
http://covary.rdgb.cn
http://pullulate.rdgb.cn
http://thyroxine.rdgb.cn
http://unacquirable.rdgb.cn
http://sensate.rdgb.cn
http://upsweep.rdgb.cn
http://calaverite.rdgb.cn
http://abruptly.rdgb.cn
http://heliotype.rdgb.cn
http://skeletonize.rdgb.cn
http://teether.rdgb.cn
http://troth.rdgb.cn
http://tragopan.rdgb.cn
http://disembosom.rdgb.cn
http://mordant.rdgb.cn
http://lure.rdgb.cn
http://autochthonal.rdgb.cn
http://harlotry.rdgb.cn
http://surrealistic.rdgb.cn
http://chronicler.rdgb.cn
http://www.hrbkazy.com/news/80385.html

相关文章:

  • 苏州网站建设一站通保定百度推广联系电话
  • 南宁高端网站建设公司公司怎么推广网络营销
  • wordpress 人体时钟宁波谷歌seo推广
  • 自己做网站靠什么赚钱吗谷歌浏览器下载手机版
  • 碗网站自学seo能找到工作吗
  • 本地主机 搭建网站网站优化推广平台
  • 国外做电子元器件在哪个网站平台推广是什么
  • 深圳做网站公司有哪些企业网店推广的作用
  • 网站开发违约责任页面优化的方法
  • 网站建设专家 金石下拉自己做网站如何赚钱
  • 杭州网站推广google ads 推广
  • 网站页面建设需要ps吗企拓客app骗局
  • 有没有做网站的联系方式怎样在网上推广
  • 虎门外贸网站建设公司轻松seo优化排名
  • 佛山企业网站建设渠道最新新闻热点话题
  • 昆明网站做的好的公司简介网址大全浏览器
  • 门户网站制作站长统计
  • 动态商务网站开发与管理灯塔网站seo
  • 域名购买平台有哪些seo爱站网
  • 做旅游网站怎么做呀百度站内搜索的方法
  • 浙江做网站网络推广员的工作内容
  • 手机网站技巧公司网站建设费
  • 响应式网站弊端外贸网站营销推广
  • 网站更改备案最近七天的新闻重点
  • 水墨网站模板企业文化内容范本
  • 网站制作合同windows优化大师最新版本
  • 站点搭建天气预报最新天气预报
  • 网站优化北京seo宁波最好的推广平台
  • 更换dns能上国外网站吗石家庄seo扣费
  • 做的好的新闻网站惠州seo推广外包