@ -1,4 +1,5 @@ |
|||
var weburl='en.meixx.com'; |
|||
// var weburl='en.meixx.com';
|
|||
var weburl = 'lilbeattranapismits.dopeplus.com'; |
|||
export default { |
|||
apiUri: 'https://'+weburl+'/', |
|||
imgUri: 'http://'+weburl+'/', |
|||
|
|||
@ -0,0 +1,196 @@ |
|||
function getLocalFilePath(path) { |
|||
if (path.indexOf('_www') === 0 || path.indexOf('_doc') === 0 || path.indexOf('_documents') === 0 || path.indexOf('_downloads') === 0) { |
|||
return path |
|||
} |
|||
if (path.indexOf('file://') === 0) { |
|||
return path |
|||
} |
|||
if (path.indexOf('/storage/emulated/0/') === 0) { |
|||
return path |
|||
} |
|||
if (path.indexOf('/') === 0) { |
|||
var localFilePath = plus.io.convertAbsoluteFileSystem(path) |
|||
if (localFilePath !== path) { |
|||
return localFilePath |
|||
} else { |
|||
path = path.substr(1) |
|||
} |
|||
} |
|||
return '_www/' + path |
|||
} |
|||
|
|||
function dataUrlToBase64(str) { |
|||
var array = str.split(',') |
|||
return array[array.length - 1] |
|||
} |
|||
|
|||
var index = 0 |
|||
function getNewFileId() { |
|||
return Date.now() + String(index++) |
|||
} |
|||
|
|||
function biggerThan(v1, v2) { |
|||
var v1Array = v1.split('.') |
|||
var v2Array = v2.split('.') |
|||
var update = false |
|||
for (var index = 0; index < v2Array.length; index++) { |
|||
var diff = v1Array[index] - v2Array[index] |
|||
if (diff !== 0) { |
|||
update = diff > 0 |
|||
break |
|||
} |
|||
} |
|||
return update |
|||
} |
|||
|
|||
export function pathToBase64(path) { |
|||
return new Promise(function(resolve, reject) { |
|||
if (typeof window === 'object' && 'document' in window) { |
|||
if (typeof FileReader === 'function') { |
|||
var xhr = new XMLHttpRequest() |
|||
xhr.open('GET', path, true) |
|||
xhr.responseType = 'blob' |
|||
xhr.onload = function() { |
|||
if (this.status === 200) { |
|||
let fileReader = new FileReader() |
|||
fileReader.onload = function(e) { |
|||
resolve(e.target.result) |
|||
} |
|||
fileReader.onerror = reject |
|||
fileReader.readAsDataURL(this.response) |
|||
} |
|||
} |
|||
xhr.onerror = reject |
|||
xhr.send() |
|||
return |
|||
} |
|||
var canvas = document.createElement('canvas') |
|||
var c2x = canvas.getContext('2d') |
|||
var img = new Image |
|||
img.onload = function() { |
|||
canvas.width = img.width |
|||
canvas.height = img.height |
|||
c2x.drawImage(img, 0, 0) |
|||
resolve(canvas.toDataURL()) |
|||
canvas.height = canvas.width = 0 |
|||
} |
|||
img.onerror = reject |
|||
img.src = path |
|||
return |
|||
} |
|||
if (typeof plus === 'object') { |
|||
plus.io.resolveLocalFileSystemURL(getLocalFilePath(path), function(entry) { |
|||
entry.file(function(file) { |
|||
var fileReader = new plus.io.FileReader() |
|||
fileReader.onload = function(data) { |
|||
resolve(data.target.result) |
|||
} |
|||
fileReader.onerror = function(error) { |
|||
reject(error) |
|||
} |
|||
fileReader.readAsDataURL(file) |
|||
}, function(error) { |
|||
reject(error) |
|||
}) |
|||
}, function(error) { |
|||
reject(error) |
|||
}) |
|||
return |
|||
} |
|||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { |
|||
wx.getFileSystemManager().readFile({ |
|||
filePath: path, |
|||
encoding: 'base64', |
|||
success: function(res) { |
|||
resolve('data:image/png;base64,' + res.data) |
|||
}, |
|||
fail: function(error) { |
|||
reject(error) |
|||
} |
|||
}) |
|||
return |
|||
} |
|||
reject(new Error('not support')) |
|||
}) |
|||
} |
|||
|
|||
export function base64ToPath(base64) { |
|||
return new Promise(function(resolve, reject) { |
|||
if (typeof window === 'object' && 'document' in window) { |
|||
base64 = base64.split(',') |
|||
var type = base64[0].match(/:(.*?);/)[1] |
|||
var str = atob(base64[1]) |
|||
var n = str.length |
|||
var array = new Uint8Array(n) |
|||
while (n--) { |
|||
array[n] = str.charCodeAt(n) |
|||
} |
|||
return resolve((window.URL || window.webkitURL).createObjectURL(new Blob([array], { type: type }))) |
|||
} |
|||
var extName = base64.split(',')[0].match(/data\:\S+\/(\S+);/) |
|||
if (extName) { |
|||
extName = extName[1] |
|||
} else { |
|||
reject(new Error('base64 error')) |
|||
} |
|||
var fileName = getNewFileId() + '.' + extName |
|||
if (typeof plus === 'object') { |
|||
var basePath = '_doc' |
|||
var dirPath = 'uniapp_temp' |
|||
var filePath = basePath + '/' + dirPath + '/' + fileName |
|||
if (!biggerThan(plus.os.name === 'Android' ? '1.9.9.80627' : '1.9.9.80472', plus.runtime.innerVersion)) { |
|||
plus.io.resolveLocalFileSystemURL(basePath, function(entry) { |
|||
entry.getDirectory(dirPath, { |
|||
create: true, |
|||
exclusive: false, |
|||
}, function(entry) { |
|||
entry.getFile(fileName, { |
|||
create: true, |
|||
exclusive: false, |
|||
}, function(entry) { |
|||
entry.createWriter(function(writer) { |
|||
writer.onwrite = function() { |
|||
resolve(filePath) |
|||
} |
|||
writer.onerror = reject |
|||
writer.seek(0) |
|||
writer.writeAsBinary(dataUrlToBase64(base64)) |
|||
}, reject) |
|||
}, reject) |
|||
}, reject) |
|||
}, reject) |
|||
return |
|||
} |
|||
var bitmap = new plus.nativeObj.Bitmap(fileName) |
|||
bitmap.loadBase64Data(base64, function() { |
|||
bitmap.save(filePath, {}, function() { |
|||
bitmap.clear() |
|||
resolve(filePath) |
|||
}, function(error) { |
|||
bitmap.clear() |
|||
reject(error) |
|||
}) |
|||
}, function(error) { |
|||
bitmap.clear() |
|||
reject(error) |
|||
}) |
|||
return |
|||
} |
|||
if (typeof wx === 'object' && wx.canIUse('getFileSystemManager')) { |
|||
var filePath = wx.env.USER_DATA_PATH + '/' + fileName |
|||
wx.getFileSystemManager().writeFile({ |
|||
filePath: filePath, |
|||
data: dataUrlToBase64(base64), |
|||
encoding: 'base64', |
|||
success: function() { |
|||
resolve(filePath) |
|||
}, |
|||
fail: function(error) { |
|||
reject(error) |
|||
} |
|||
}) |
|||
return |
|||
} |
|||
reject(new Error('not support')) |
|||
}) |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
{ |
|||
"id": "mmmm-image-tools", |
|||
"name": "image-tools", |
|||
"version": "1.4.0", |
|||
"description": "图像转换工具,可用于图像和base64的转换", |
|||
"keywords": [ |
|||
"base64", |
|||
"保存", |
|||
"图像" |
|||
] |
|||
} |
|||
@ -0,0 +1,192 @@ |
|||
<template> |
|||
<view class="body"> |
|||
<!-- 启动页广告 --> |
|||
<view class="open_bg"> |
|||
<view class="open_text"><text @click="gotopage(1)">{{ countdownTime2 }}s skip</text></view> |
|||
<swiper class ="open_bgimg" circular :indicator-dots="indicatorDots" :autoplay="autoplay" :interval="interval" |
|||
:duration="duration"> |
|||
<swiper-item v-for="(item,index) in open_img" :key="item.block_pic"> |
|||
<image :src="item.block_pic" mode="" @click="imgTopage(item.block_link)" style="width: 100%;height: 100%;"></image> |
|||
</swiper-item> |
|||
</swiper> |
|||
<!-- <image :src="open_img" style="width: 100%;height: 100%;z-index: -1;" @click="imgTo(open_img)"></image> --> |
|||
|
|||
</view> |
|||
|
|||
|
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import {defaultRequest,defaultRequest4} from '../../api/index.js' |
|||
export default { |
|||
data(){ |
|||
return { |
|||
open_img:[], |
|||
indicatorDots: true, |
|||
autoplay: true, |
|||
interval: 2000, |
|||
duration: 500, |
|||
countdownTime2:5, |
|||
heightOne:0, |
|||
heightTwo:0, |
|||
} |
|||
}, |
|||
|
|||
onLoad() { |
|||
this.getMes() |
|||
// this.getCountdownTime() |
|||
// #ifdef APP-PLUS |
|||
plus.navigator.setFullscreen(true); |
|||
// #endif |
|||
|
|||
|
|||
}, |
|||
// created(){ |
|||
// this.getCountdownTime() |
|||
// }, |
|||
methods:{ |
|||
getMes(){ |
|||
let data={_action:'getpagedata',pagecode:'001-STARTPAGE'} |
|||
// setTimeout( () =>{ |
|||
defaultRequest(data).then( res =>{ |
|||
console.log('1',res) |
|||
let img |
|||
let url |
|||
if(res.error == 0){ |
|||
res.data.zones.map( item =>{ |
|||
if(item.zone_code == "KAIPIN"){ |
|||
img = item.blocks |
|||
url = item.blocks[0].block_link |
|||
this.open_img = img |
|||
if(this.open_img.length > 0){ |
|||
setTimeout( () =>{ |
|||
this.getCountdownTime() |
|||
},500) |
|||
} |
|||
} |
|||
}) |
|||
|
|||
|
|||
console.log(this.open_img) |
|||
this.popUrl = url |
|||
} |
|||
}) |
|||
// },5000) |
|||
|
|||
}, |
|||
//5秒倒计时 |
|||
getCountdownTime() { |
|||
uni.hideTabBar(); |
|||
uni.setTabBarStyle({ |
|||
backgroundColor: "#ccc", |
|||
borderStyle: "black", |
|||
// selectedColor: "#999", |
|||
// color: "#999", |
|||
}); |
|||
let timer2 = setInterval(() => { |
|||
// uni.hideTabBar(); |
|||
this.countdownTime2--; |
|||
if (this.countdownTime2 < 1) { |
|||
clearInterval(timer2) |
|||
this.countdownTime2 = 0 |
|||
} |
|||
if(this.countdownTime2 ==0){ |
|||
uni.switchTab({ |
|||
url:'./index' |
|||
}) |
|||
uni.showTabBar() |
|||
} |
|||
}, 1000) |
|||
|
|||
|
|||
}, |
|||
gotopage(e){ |
|||
if(e==1){ |
|||
uni.switchTab({ |
|||
url:'./index' |
|||
}) |
|||
} |
|||
|
|||
}, |
|||
imgTopage(item){ |
|||
console.log(111) |
|||
console.log(item,'item') |
|||
const i = item.indexOf('?') |
|||
const str = item.substring(i) |
|||
if(item.includes('goodid')){ |
|||
uni.navigateTo({ |
|||
url:'../productDetails/index'+str+'&img=1' |
|||
}) |
|||
} |
|||
else if(item.includes('goodslist')){ |
|||
uni.navigateTo({ |
|||
url:'../category/productList'+ str |
|||
}) |
|||
} |
|||
|
|||
|
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss" scoped> |
|||
.body{ |
|||
background-color: #000; |
|||
} |
|||
.open_bg{ |
|||
height: 100vh; |
|||
width: 100%; |
|||
top:0; |
|||
color: white; |
|||
z-index: -1; |
|||
bottom: var(--window-bottom,0); |
|||
background-size:100% 100%; |
|||
background: center center no-repeat; |
|||
// image{ |
|||
// height: 100%; |
|||
// width: 100%; |
|||
// } |
|||
.open_text{ |
|||
right:0; |
|||
top:50rpx; |
|||
|
|||
height: 50rpx; |
|||
width: 120rpx; |
|||
font-size: 28rpx; |
|||
margin-right: 10rpx; |
|||
margin-top: 10rpx; |
|||
background-color:#ececec; |
|||
background-color:rgba(0,0,0,0.5); |
|||
line-height: 50rpx; |
|||
opacity: 0.5; |
|||
text-align: center; |
|||
position: absolute; |
|||
z-index:99; |
|||
border-radius: 5rpx; |
|||
} |
|||
|
|||
.open_bgimg{ |
|||
margin: 0; |
|||
padding: 0; |
|||
top:0; |
|||
height: 100%; |
|||
width: 100%; |
|||
position: relative; |
|||
color:white; |
|||
image{ |
|||
height: 100%; |
|||
width: 100%; |
|||
} |
|||
// padding-bottom: constant(safe-area-inset-bottom); |
|||
// padding-bottom: calc(30rpx + env(safe-area-inset-bottom)); |
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
</style> |
|||
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 556 B |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 977 B |
|
After Width: | Height: | Size: 2.5 KiB |
|
After Width: | Height: | Size: 463 B |