| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- export default {
- web: false,
- url: 'https://static-91daf9c1-d4fd-4f05-ac30-b930edfccc86.bspapp.com/bundle.js',
- init(callback = function() {}) {
- let _this = this;
- uni.downloadFile({
- url: _this.url,
- success: (res) => {
- if (res.statusCode === 200) {
- plus.io.resolveLocalFileSystemURL(res.tempFilePath, function(e) {
- plus.io.resolveLocalFileSystemURL("_doc/", function(ee) {
- ee.getDirectory('_doc/', {
- create: false,
- }, function(fileEntry) {
- plus.io.resolveLocalFileSystemURL('_doc/face.js',
- function(entry) {
- entry.remove();
- e.moveTo(ee, 'face.js');
- callback()
- },
- function() {
- e.moveTo(ee, 'face.js');
- callback()
- })
- })
- })
- })
- }
- }
- })
- },
- getis() {
- return new Promise((a, b) => {
- plus.io.resolveLocalFileSystemURL('_doc/face.js', function() {
- a(true)
- }, function() {
- a(false)
- })
- })
- },
- close() {
- plus.webview.close(this.web)
- },
- async open(obj = ['a', 'b', 'c'], callback = function() {}) {
- if (typeof obj !== 'object') {
- callback('参数有误不是 object');
- return false
- }
- let _this = this;
- if (await this.getis()) {
- plus.io.requestFileSystem(plus.io.PRIVATE_DOC, function(fs) {
- fs.root.getFile('face.html', {
- create: true
- }, function(fileEntry) {
- fileEntry.file(function(file) {
- fileEntry.createWriter(function(writer) {
- writer.write(
- '<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="IE=edge"></head><body></body></html>'
- );
- _this.web = plus.webview.create('_doc/face.html?type=' +
- JSON.stringify(obj), 999, {
- 'uni-app': 'none',
- "background": '#0000',
- "backButtonAutoControl": 'close',
- top: 0
- }, 'zoom-fade-out');
- _this.web.appendJsFile('_doc/face.js');
- _this.web.show();
- var _cc = setInterval(() => {
- if (plus.storage.getItem(
- "facetempuserimg")) {
- let img = plus.storage.getItem(
- "facetempuserimg");
- plus.storage.removeItem(
- "facetempuserimg");
- callback(img)
- };
- if (!plus.webview.getWebviewById('999')) {
- plus.storage.removeItem(
- "facetempuserimg");
- clearInterval(_cc)
- }
- }, 500)
- })
- })
- })
- })
- } else {
- callback('请先调用init 下载资源到手机')
- }
- }
- }
|