@tarojs/taro-h5 4.0.0-beta.8 → 4.0.0-beta.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/base/index.d.ts +1 -1
- package/dist/api/base/index.js +1 -1
- package/dist/api/base/index.js.map +1 -1
- package/dist/api/device/clipboard.js +6 -0
- package/dist/api/device/clipboard.js.map +1 -1
- package/dist/api/device/network.js.map +1 -1
- package/dist/api/device/sms.js.map +1 -1
- package/dist/api/index.js +3 -1
- package/dist/api/index.js.map +1 -1
- package/dist/api/location/chooseLocation.js +2 -2
- package/dist/api/location/chooseLocation.js.map +1 -1
- package/dist/api/location/getLocation.js +2 -2
- package/dist/api/location/getLocation.js.map +1 -1
- package/dist/api/location/index.d.ts +2 -7
- package/dist/api/location/index.js +2 -8
- package/dist/api/location/index.js.map +1 -1
- package/dist/api/location/locationChange.d.ts +7 -0
- package/dist/api/location/locationChange.js +130 -0
- package/dist/api/location/locationChange.js.map +1 -0
- package/dist/api/location/utils.d.ts +2 -0
- package/dist/api/location/utils.js +4 -0
- package/dist/api/location/utils.js.map +1 -0
- package/dist/api/network/request/index.js +9 -7
- package/dist/api/network/request/index.js.map +1 -1
- package/dist/api/network/websocket/index.d.ts +2 -1
- package/dist/api/network/websocket/index.js +1 -1
- package/dist/api/network/websocket/index.js.map +1 -1
- package/dist/api/storage/index.js.map +1 -1
- package/dist/api/taro.js +2 -2
- package/dist/api/taro.js.map +1 -1
- package/dist/api/ui/animation/index.js +68 -38
- package/dist/api/ui/animation/index.js.map +1 -1
- package/dist/api/ui/interaction/actionSheet.d.ts +12 -0
- package/dist/api/ui/interaction/actionSheet.js +34 -12
- package/dist/api/ui/interaction/actionSheet.js.map +1 -1
- package/dist/api/ui/interaction/index.js +2 -1
- package/dist/api/ui/interaction/index.js.map +1 -1
- package/dist/api/ui/interaction/modal.d.ts +2 -0
- package/dist/api/ui/interaction/modal.js +3 -1
- package/dist/api/ui/interaction/modal.js.map +1 -1
- package/dist/api/ui/navigation-bar/index.d.ts +8 -2
- package/dist/api/ui/navigation-bar/index.js +22 -5
- package/dist/api/ui/navigation-bar/index.js.map +1 -1
- package/dist/api/wxml/IntersectionObserver.js +2 -1
- package/dist/api/wxml/IntersectionObserver.js.map +1 -1
- package/dist/api/wxml/MediaQueryObserver.js.map +1 -1
- package/dist/api/wxml/index.js.map +1 -1
- package/dist/api/wxml/nodesRef.js +5 -2
- package/dist/api/wxml/nodesRef.js.map +1 -1
- package/dist/index.cjs.d.ts +42 -11
- package/dist/index.cjs.js +2238 -2029
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +42 -11
- package/dist/index.esm.js +2239 -2031
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/handler.d.ts +2 -0
- package/dist/utils/handler.js +8 -0
- package/dist/utils/handler.js.map +1 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +7 -8
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
import { setTitle, history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
2
|
+
import { setNavigationBarLoading, setTitle, setNavigationBarStyle, history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
3
3
|
export { getCurrentPages, history, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '@tarojs/router';
|
|
4
4
|
import { isFunction, toKebabCase, PLATFORM_TYPE } from '@tarojs/shared';
|
|
5
5
|
import { hooks, Current as Current$1, getCurrentPage, getHomePage, eventCenter as eventCenter$1 } from '@tarojs/runtime';
|
|
@@ -70,6 +70,10 @@ class CallbackManager {
|
|
|
70
70
|
this.callbacks.splice(pos, 1);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
else {
|
|
74
|
+
// Note: 参数为空,则取消所有的事件监听
|
|
75
|
+
this.callbacks = [];
|
|
76
|
+
}
|
|
73
77
|
};
|
|
74
78
|
/** 获取回调函数数量 */
|
|
75
79
|
this.count = () => {
|
|
@@ -87,6 +91,10 @@ class CallbackManager {
|
|
|
87
91
|
}
|
|
88
92
|
});
|
|
89
93
|
};
|
|
94
|
+
/** 清空所有回调 */
|
|
95
|
+
this.clear = () => {
|
|
96
|
+
this.callbacks = [];
|
|
97
|
+
};
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|
|
@@ -137,7 +145,7 @@ function findDOM(inst) {
|
|
|
137
145
|
}
|
|
138
146
|
const page = Current$1.page;
|
|
139
147
|
const path = page === null || page === void 0 ? void 0 : page.path;
|
|
140
|
-
const msg = '
|
|
148
|
+
const msg = '没有找到已经加载了的页面,请在页面加载完成后使用此 API。';
|
|
141
149
|
if (path == null) {
|
|
142
150
|
throw new Error(msg);
|
|
143
151
|
}
|
|
@@ -679,7 +687,7 @@ function arrayBufferToBase64(arrayBuffer) {
|
|
|
679
687
|
return fromByteArray(arrayBuffer);
|
|
680
688
|
}
|
|
681
689
|
function base64ToArrayBuffer(base64) {
|
|
682
|
-
return toByteArray(base64);
|
|
690
|
+
return toByteArray(base64).buffer;
|
|
683
691
|
}
|
|
684
692
|
|
|
685
693
|
const TextBaseLineMap = {
|
|
@@ -1452,2209 +1460,2395 @@ const batchSetStorage = /* @__PURE__ */ temporarilyNotSupport('batchSetStorage')
|
|
|
1452
1460
|
const batchGetStorageSync = /* @__PURE__ */ temporarilyNotSupport('batchGetStorageSync');
|
|
1453
1461
|
const batchGetStorage = /* @__PURE__ */ temporarilyNotSupport('batchGetStorage');
|
|
1454
1462
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1463
|
+
const noop = function () { };
|
|
1464
|
+
class ActionSheet {
|
|
1465
|
+
constructor() {
|
|
1466
|
+
this.options = {
|
|
1467
|
+
alertText: '',
|
|
1468
|
+
itemList: [],
|
|
1469
|
+
itemColor: '#000000',
|
|
1470
|
+
success: noop,
|
|
1471
|
+
fail: noop,
|
|
1472
|
+
complete: noop,
|
|
1473
|
+
};
|
|
1474
|
+
this.style = {
|
|
1475
|
+
maskStyle: {
|
|
1476
|
+
position: 'fixed',
|
|
1477
|
+
'z-index': '1000',
|
|
1478
|
+
top: '0',
|
|
1479
|
+
right: '0',
|
|
1480
|
+
left: '0',
|
|
1481
|
+
bottom: '0',
|
|
1482
|
+
background: 'rgba(0,0,0,0.6)',
|
|
1483
|
+
},
|
|
1484
|
+
actionSheetStyle: {
|
|
1485
|
+
'z-index': '4999',
|
|
1486
|
+
position: 'fixed',
|
|
1487
|
+
left: '0',
|
|
1488
|
+
bottom: '0',
|
|
1489
|
+
'-webkit-transform': 'translate(0, 100%)',
|
|
1490
|
+
transform: 'translate(0, 100%)',
|
|
1491
|
+
width: '100%',
|
|
1492
|
+
'line-height': '1.6',
|
|
1493
|
+
background: '#EFEFF4',
|
|
1494
|
+
'-webkit-transition': '-webkit-transform .3s',
|
|
1495
|
+
transition: 'transform .3s',
|
|
1496
|
+
'border-radius': '15px 15px 0 0',
|
|
1497
|
+
},
|
|
1498
|
+
menuStyle: {
|
|
1499
|
+
'background-color': '#FCFCFD',
|
|
1500
|
+
'border-radius': '15px 15px 0 0',
|
|
1501
|
+
},
|
|
1502
|
+
cellStyle: {
|
|
1503
|
+
position: 'relative',
|
|
1504
|
+
padding: '10px 0',
|
|
1505
|
+
'text-align': 'center',
|
|
1506
|
+
'font-size': '18px',
|
|
1507
|
+
},
|
|
1508
|
+
titleStyle: {
|
|
1509
|
+
position: 'relative',
|
|
1510
|
+
padding: '10px 0',
|
|
1511
|
+
'text-align': 'center',
|
|
1512
|
+
'font-size': '16px',
|
|
1513
|
+
color: 'rgba(0,0,0,0.8)',
|
|
1514
|
+
display: 'none',
|
|
1515
|
+
},
|
|
1516
|
+
cancelStyle: {
|
|
1517
|
+
'margin-top': '6px',
|
|
1518
|
+
padding: '10px 0',
|
|
1519
|
+
'text-align': 'center',
|
|
1520
|
+
'font-size': '18px',
|
|
1521
|
+
color: '#000000',
|
|
1522
|
+
'background-color': '#FCFCFD',
|
|
1523
|
+
},
|
|
1524
|
+
};
|
|
1525
|
+
this.lastConfig = {};
|
|
1500
1526
|
}
|
|
1501
|
-
|
|
1502
|
-
return
|
|
1527
|
+
create(options = {}) {
|
|
1528
|
+
return new Promise((resolve) => {
|
|
1529
|
+
// style
|
|
1530
|
+
const { maskStyle, actionSheetStyle, menuStyle, cellStyle, titleStyle, cancelStyle } = this.style;
|
|
1531
|
+
// configuration
|
|
1532
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
1533
|
+
this.lastConfig = config;
|
|
1534
|
+
// wrapper
|
|
1535
|
+
this.el = document.createElement('div');
|
|
1536
|
+
this.el.className = 'taro__actionSheet';
|
|
1537
|
+
this.el.style.opacity = '0';
|
|
1538
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
1539
|
+
// mask
|
|
1540
|
+
this.mask = document.createElement('div');
|
|
1541
|
+
this.mask.setAttribute('style', inlineStyle(maskStyle));
|
|
1542
|
+
// actionSheet
|
|
1543
|
+
this.actionSheet = document.createElement('div');
|
|
1544
|
+
this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
|
|
1545
|
+
// menu
|
|
1546
|
+
this.menu = document.createElement('div');
|
|
1547
|
+
this.menu.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, menuStyle), { color: config.itemColor })));
|
|
1548
|
+
// cells
|
|
1549
|
+
this.cells = config.itemList.map((item, index) => {
|
|
1550
|
+
const cell = document.createElement('div');
|
|
1551
|
+
cell.className = 'taro-actionsheet__cell';
|
|
1552
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
1553
|
+
cell.textContent = item;
|
|
1554
|
+
cell.dataset.tapIndex = `${index}`;
|
|
1555
|
+
cell.onclick = (e) => {
|
|
1556
|
+
this.hide();
|
|
1557
|
+
const target = e.currentTarget;
|
|
1558
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
1559
|
+
resolve(index);
|
|
1560
|
+
};
|
|
1561
|
+
return cell;
|
|
1562
|
+
});
|
|
1563
|
+
// title
|
|
1564
|
+
this.title = document.createElement('div');
|
|
1565
|
+
this.title.setAttribute('style', inlineStyle(titleStyle));
|
|
1566
|
+
this.title.className = 'taro-actionsheet__cell';
|
|
1567
|
+
this.title.textContent = config.alertText;
|
|
1568
|
+
this.title.style.display = config.alertText ? 'block' : 'none';
|
|
1569
|
+
// cancel
|
|
1570
|
+
this.cancel = document.createElement('div');
|
|
1571
|
+
this.cancel.setAttribute('style', inlineStyle(cancelStyle));
|
|
1572
|
+
this.cancel.textContent = '取消';
|
|
1573
|
+
// result
|
|
1574
|
+
this.menu.appendChild(this.title);
|
|
1575
|
+
this.cells.forEach((item) => this.menu.appendChild(item));
|
|
1576
|
+
this.actionSheet.appendChild(this.menu);
|
|
1577
|
+
this.actionSheet.appendChild(this.cancel);
|
|
1578
|
+
this.el.appendChild(this.mask);
|
|
1579
|
+
this.el.appendChild(this.actionSheet);
|
|
1580
|
+
// callbacks
|
|
1581
|
+
const cb = () => {
|
|
1582
|
+
this.hide();
|
|
1583
|
+
resolve('cancel');
|
|
1584
|
+
};
|
|
1585
|
+
this.mask.onclick = cb;
|
|
1586
|
+
this.cancel.onclick = cb;
|
|
1587
|
+
// show immediately
|
|
1588
|
+
document.body.appendChild(this.el);
|
|
1589
|
+
setTimeout(() => {
|
|
1590
|
+
this.el.style.opacity = '1';
|
|
1591
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
1592
|
+
}, 0);
|
|
1593
|
+
});
|
|
1503
1594
|
}
|
|
1504
|
-
})
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1595
|
+
show(options = {}) {
|
|
1596
|
+
return new Promise((resolve) => {
|
|
1597
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
1598
|
+
this.lastConfig = config;
|
|
1599
|
+
if (this.hideOpacityTimer)
|
|
1600
|
+
clearTimeout(this.hideOpacityTimer);
|
|
1601
|
+
if (this.hideDisplayTimer)
|
|
1602
|
+
clearTimeout(this.hideDisplayTimer);
|
|
1603
|
+
// itemColor
|
|
1604
|
+
if (config.itemColor)
|
|
1605
|
+
this.menu.style.color = config.itemColor;
|
|
1606
|
+
// cells
|
|
1607
|
+
const { cellStyle } = this.style;
|
|
1608
|
+
config.itemList.forEach((item, index) => {
|
|
1609
|
+
let cell;
|
|
1610
|
+
if (this.cells[index]) {
|
|
1611
|
+
// assign new content
|
|
1612
|
+
cell = this.cells[index];
|
|
1613
|
+
}
|
|
1614
|
+
else {
|
|
1615
|
+
// create new cell
|
|
1616
|
+
cell = document.createElement('div');
|
|
1617
|
+
cell.className = 'taro-actionsheet__cell';
|
|
1618
|
+
cell.setAttribute('style', inlineStyle(cellStyle));
|
|
1619
|
+
cell.dataset.tapIndex = `${index}`;
|
|
1620
|
+
this.cells.push(cell);
|
|
1621
|
+
this.menu.appendChild(cell);
|
|
1622
|
+
}
|
|
1623
|
+
cell.textContent = item;
|
|
1624
|
+
cell.onclick = (e) => {
|
|
1625
|
+
this.hide();
|
|
1626
|
+
const target = e.currentTarget;
|
|
1627
|
+
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
1628
|
+
resolve(index);
|
|
1629
|
+
};
|
|
1630
|
+
});
|
|
1631
|
+
const cellsLen = this.cells.length;
|
|
1632
|
+
const itemListLen = config.itemList.length;
|
|
1633
|
+
if (cellsLen > itemListLen) {
|
|
1634
|
+
for (let i = itemListLen; i < cellsLen; i++) {
|
|
1635
|
+
this.menu.removeChild(this.cells[i]);
|
|
1636
|
+
}
|
|
1637
|
+
this.cells.splice(itemListLen);
|
|
1638
|
+
}
|
|
1639
|
+
this.title.textContent = config.alertText;
|
|
1640
|
+
this.title.style.display = config.alertText ? 'block' : 'none';
|
|
1641
|
+
// callbacks
|
|
1642
|
+
const cb = () => {
|
|
1643
|
+
this.hide();
|
|
1644
|
+
resolve('cancel');
|
|
1645
|
+
};
|
|
1646
|
+
this.mask.onclick = cb;
|
|
1647
|
+
this.cancel.onclick = cb;
|
|
1648
|
+
// show
|
|
1649
|
+
this.el.style.display = 'block';
|
|
1650
|
+
setTimeout(() => {
|
|
1651
|
+
this.el.style.opacity = '1';
|
|
1652
|
+
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
1653
|
+
}, 0);
|
|
1654
|
+
});
|
|
1513
1655
|
}
|
|
1514
|
-
|
|
1515
|
-
|
|
1656
|
+
hide() {
|
|
1657
|
+
if (this.hideOpacityTimer)
|
|
1658
|
+
clearTimeout(this.hideOpacityTimer);
|
|
1659
|
+
if (this.hideDisplayTimer)
|
|
1660
|
+
clearTimeout(this.hideDisplayTimer);
|
|
1661
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
1662
|
+
this.el.style.opacity = '0';
|
|
1663
|
+
setTransform(this.actionSheet, 'translate(0, 100%)');
|
|
1664
|
+
this.hideDisplayTimer = setTimeout(() => {
|
|
1665
|
+
this.el.style.display = 'none';
|
|
1666
|
+
}, 200);
|
|
1667
|
+
}, 0);
|
|
1516
1668
|
}
|
|
1517
|
-
}
|
|
1669
|
+
}
|
|
1518
1670
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1671
|
+
class Modal {
|
|
1672
|
+
constructor() {
|
|
1673
|
+
this.options = {
|
|
1674
|
+
title: '',
|
|
1675
|
+
content: '',
|
|
1676
|
+
showCancel: true,
|
|
1677
|
+
cancelText: '取消',
|
|
1678
|
+
cancelColor: '#000000',
|
|
1679
|
+
confirmText: '确定',
|
|
1680
|
+
confirmColor: '#3CC51F'
|
|
1681
|
+
};
|
|
1682
|
+
this.style = {
|
|
1683
|
+
maskStyle: {
|
|
1684
|
+
position: 'fixed',
|
|
1685
|
+
'z-index': '1000',
|
|
1686
|
+
top: '0',
|
|
1687
|
+
right: '0',
|
|
1688
|
+
left: '0',
|
|
1689
|
+
bottom: '0',
|
|
1690
|
+
background: 'rgba(0,0,0,0.6)'
|
|
1691
|
+
},
|
|
1692
|
+
modalStyle: {
|
|
1693
|
+
'z-index': '4999',
|
|
1694
|
+
position: 'fixed',
|
|
1695
|
+
top: '50%',
|
|
1696
|
+
left: '50%',
|
|
1697
|
+
transform: 'translate(-50%, -50%)',
|
|
1698
|
+
width: '80%',
|
|
1699
|
+
'max-width': '300px',
|
|
1700
|
+
'border-radius': '3px',
|
|
1701
|
+
'text-align': 'center',
|
|
1702
|
+
'line-height': '1.6',
|
|
1703
|
+
overflow: 'hidden',
|
|
1704
|
+
background: '#FFFFFF'
|
|
1705
|
+
},
|
|
1706
|
+
titleStyle: {
|
|
1707
|
+
padding: '20px 24px 9px',
|
|
1708
|
+
'font-size': '18px'
|
|
1709
|
+
},
|
|
1710
|
+
textStyle: {
|
|
1711
|
+
padding: '0 24px 12px',
|
|
1712
|
+
'min-height': '40px',
|
|
1713
|
+
'font-size': '15px',
|
|
1714
|
+
'line-height': '1.3',
|
|
1715
|
+
color: '#808080',
|
|
1716
|
+
'word-wrap': 'break-word',
|
|
1717
|
+
'word-break': 'break-all',
|
|
1718
|
+
},
|
|
1719
|
+
footStyle: {
|
|
1720
|
+
position: 'relative',
|
|
1721
|
+
'line-height': '48px',
|
|
1722
|
+
'font-size': '18px',
|
|
1723
|
+
display: 'flex'
|
|
1724
|
+
},
|
|
1725
|
+
btnStyle: {
|
|
1726
|
+
position: 'relative',
|
|
1727
|
+
'-webkit-box-flex': '1',
|
|
1728
|
+
'-webkit-flex': '1',
|
|
1729
|
+
flex: '1'
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1537
1732
|
}
|
|
1538
|
-
|
|
1539
|
-
return
|
|
1733
|
+
create(options = {}) {
|
|
1734
|
+
return new Promise((resolve) => {
|
|
1735
|
+
var _a, _b;
|
|
1736
|
+
// style
|
|
1737
|
+
const { maskStyle, modalStyle, titleStyle, textStyle, footStyle, btnStyle } = this.style;
|
|
1738
|
+
// configuration
|
|
1739
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
1740
|
+
// wrapper
|
|
1741
|
+
this.el = document.createElement('div');
|
|
1742
|
+
this.el.className = 'taro__modal';
|
|
1743
|
+
this.el.style.opacity = '0';
|
|
1744
|
+
this.el.style.transition = 'opacity 0.2s linear';
|
|
1745
|
+
const eventHandler = (e) => {
|
|
1746
|
+
e.stopPropagation();
|
|
1747
|
+
e.preventDefault();
|
|
1748
|
+
};
|
|
1749
|
+
// mask
|
|
1750
|
+
const mask = document.createElement('div');
|
|
1751
|
+
mask.className = 'taro-modal__mask';
|
|
1752
|
+
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
1753
|
+
mask.ontouchmove = eventHandler;
|
|
1754
|
+
// modal
|
|
1755
|
+
const modal = document.createElement('div');
|
|
1756
|
+
modal.className = 'taro-modal__content';
|
|
1757
|
+
modal.setAttribute('style', inlineStyle(modalStyle));
|
|
1758
|
+
modal.ontouchmove = eventHandler;
|
|
1759
|
+
// title
|
|
1760
|
+
const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
|
|
1761
|
+
this.title = document.createElement('div');
|
|
1762
|
+
this.title.className = 'taro-modal__title';
|
|
1763
|
+
this.title.setAttribute('style', inlineStyle(titleCSS));
|
|
1764
|
+
this.title.textContent = config.title;
|
|
1765
|
+
// text
|
|
1766
|
+
const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
1767
|
+
this.text = document.createElement('div');
|
|
1768
|
+
this.text.className = 'taro-modal__text';
|
|
1769
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
1770
|
+
this.text.textContent = config.content;
|
|
1771
|
+
// foot
|
|
1772
|
+
const foot = document.createElement('div');
|
|
1773
|
+
foot.className = 'taro-modal__foot';
|
|
1774
|
+
foot.setAttribute('style', inlineStyle(footStyle));
|
|
1775
|
+
// cancel button
|
|
1776
|
+
const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
|
|
1777
|
+
this.cancel = document.createElement('div');
|
|
1778
|
+
this.cancel.className = 'taro-model__btn taro-model__cancel';
|
|
1779
|
+
this.cancel.setAttribute('style', inlineStyle(cancelCSS));
|
|
1780
|
+
this.cancel.textContent = config.cancelText;
|
|
1781
|
+
this.cancel.onclick = () => {
|
|
1782
|
+
this.hide();
|
|
1783
|
+
resolve('cancel');
|
|
1784
|
+
};
|
|
1785
|
+
// confirm button
|
|
1786
|
+
this.confirm = document.createElement('div');
|
|
1787
|
+
this.confirm.className = 'taro-model__btn taro-model__confirm';
|
|
1788
|
+
this.confirm.setAttribute('style', inlineStyle(btnStyle));
|
|
1789
|
+
this.confirm.style.color = config.confirmColor;
|
|
1790
|
+
this.confirm.textContent = config.confirmText;
|
|
1791
|
+
this.confirm.onclick = () => {
|
|
1792
|
+
this.hide();
|
|
1793
|
+
resolve('confirm');
|
|
1794
|
+
};
|
|
1795
|
+
// result
|
|
1796
|
+
foot.appendChild(this.cancel);
|
|
1797
|
+
foot.appendChild(this.confirm);
|
|
1798
|
+
modal.appendChild(this.title);
|
|
1799
|
+
modal.appendChild(this.text);
|
|
1800
|
+
modal.appendChild(foot);
|
|
1801
|
+
this.el.appendChild(mask);
|
|
1802
|
+
this.el.appendChild(modal);
|
|
1803
|
+
// show immediately
|
|
1804
|
+
document.body.appendChild(this.el);
|
|
1805
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
1806
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
1807
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
1808
|
+
});
|
|
1540
1809
|
}
|
|
1541
|
-
}
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1810
|
+
show(options = {}) {
|
|
1811
|
+
return new Promise((resolve) => {
|
|
1812
|
+
var _a, _b;
|
|
1813
|
+
const config = Object.assign(Object.assign({}, this.options), options);
|
|
1814
|
+
if (this.hideOpacityTimer)
|
|
1815
|
+
clearTimeout(this.hideOpacityTimer);
|
|
1816
|
+
if (this.hideDisplayTimer)
|
|
1817
|
+
clearTimeout(this.hideDisplayTimer);
|
|
1818
|
+
// title & text
|
|
1819
|
+
const { textStyle } = this.style;
|
|
1820
|
+
if (config.title) {
|
|
1821
|
+
this.title.textContent = config.title;
|
|
1822
|
+
// none => block
|
|
1823
|
+
this.title.style.display = 'block';
|
|
1824
|
+
this.text.setAttribute('style', inlineStyle(textStyle));
|
|
1552
1825
|
}
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1826
|
+
else {
|
|
1827
|
+
this.title.textContent = '';
|
|
1828
|
+
// block => none
|
|
1829
|
+
this.title.style.display = 'none';
|
|
1830
|
+
const textCSS = Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
1831
|
+
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
1832
|
+
}
|
|
1833
|
+
this.text.textContent = config.content || '';
|
|
1834
|
+
// showCancel
|
|
1835
|
+
this.cancel.style.display = config.showCancel ? 'block' : 'none';
|
|
1836
|
+
// cancelText
|
|
1837
|
+
this.cancel.textContent = config.cancelText || '';
|
|
1838
|
+
// cancelColor
|
|
1839
|
+
this.cancel.style.color = config.cancelColor || '';
|
|
1840
|
+
// confirmText
|
|
1841
|
+
this.confirm.textContent = config.confirmText || '';
|
|
1842
|
+
// confirmColor
|
|
1843
|
+
this.confirm.style.color = config.confirmColor || '';
|
|
1844
|
+
// cbs
|
|
1845
|
+
this.cancel.onclick = () => {
|
|
1846
|
+
this.hide();
|
|
1847
|
+
resolve('cancel');
|
|
1848
|
+
};
|
|
1849
|
+
this.confirm.onclick = () => {
|
|
1850
|
+
this.hide();
|
|
1851
|
+
resolve('confirm');
|
|
1852
|
+
};
|
|
1853
|
+
// show
|
|
1854
|
+
this.el.style.display = 'block';
|
|
1855
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
1856
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
1857
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
1858
|
+
});
|
|
1577
1859
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1860
|
+
hide() {
|
|
1861
|
+
if (this.hideOpacityTimer)
|
|
1862
|
+
clearTimeout(this.hideOpacityTimer);
|
|
1863
|
+
if (this.hideDisplayTimer)
|
|
1864
|
+
clearTimeout(this.hideDisplayTimer);
|
|
1865
|
+
this.currentPath = null;
|
|
1866
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
1867
|
+
this.el.style.opacity = '0';
|
|
1868
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
1869
|
+
}, 0);
|
|
1580
1870
|
}
|
|
1581
|
-
}
|
|
1582
|
-
/**
|
|
1583
|
-
* 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
|
|
1584
|
-
*/
|
|
1585
|
-
const onCompassChange = callback => {
|
|
1586
|
-
callbackManager$2.add(callback);
|
|
1587
|
-
};
|
|
1588
|
-
/**
|
|
1589
|
-
* 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
1590
|
-
*/
|
|
1591
|
-
const offCompassChange = callback => {
|
|
1592
|
-
callbackManager$2.remove(callback);
|
|
1593
|
-
};
|
|
1594
|
-
|
|
1595
|
-
// 联系人
|
|
1596
|
-
const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact');
|
|
1597
|
-
const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact');
|
|
1598
|
-
|
|
1599
|
-
// 加密
|
|
1600
|
-
const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues');
|
|
1601
|
-
|
|
1602
|
-
// 陀螺仪
|
|
1603
|
-
const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope');
|
|
1604
|
-
const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope');
|
|
1605
|
-
const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange');
|
|
1606
|
-
const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange');
|
|
1607
|
-
|
|
1608
|
-
// 蓝牙-信标(Beacon)
|
|
1609
|
-
const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery');
|
|
1610
|
-
const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery');
|
|
1611
|
-
const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate');
|
|
1612
|
-
const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange');
|
|
1613
|
-
const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate');
|
|
1614
|
-
const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange');
|
|
1615
|
-
const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons');
|
|
1616
|
-
|
|
1617
|
-
// 键盘
|
|
1618
|
-
const onKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('onKeyboardHeightChange');
|
|
1619
|
-
const offKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('offKeyboardHeightChange');
|
|
1620
|
-
const hideKeyboard = /* @__PURE__ */ temporarilyNotSupport('hideKeyboard');
|
|
1621
|
-
const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange');
|
|
1622
|
-
|
|
1623
|
-
// 内存
|
|
1624
|
-
const onMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('onMemoryWarning');
|
|
1625
|
-
const offMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('offMemoryWarning');
|
|
1871
|
+
}
|
|
1626
1872
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1873
|
+
class Toast {
|
|
1874
|
+
constructor() {
|
|
1875
|
+
this.options = {
|
|
1876
|
+
title: '',
|
|
1877
|
+
icon: 'none',
|
|
1878
|
+
image: '',
|
|
1879
|
+
duration: 1500,
|
|
1880
|
+
mask: false
|
|
1881
|
+
};
|
|
1882
|
+
this.style = {
|
|
1883
|
+
maskStyle: {
|
|
1884
|
+
position: 'fixed',
|
|
1885
|
+
'z-index': '1000',
|
|
1886
|
+
top: '0',
|
|
1887
|
+
right: '0',
|
|
1888
|
+
left: '0',
|
|
1889
|
+
bottom: '0'
|
|
1890
|
+
},
|
|
1891
|
+
toastStyle: {
|
|
1892
|
+
'z-index': '5000',
|
|
1893
|
+
'box-sizing': 'border-box',
|
|
1894
|
+
display: 'flex',
|
|
1895
|
+
'flex-direction': 'column',
|
|
1896
|
+
'justify-content': 'center',
|
|
1897
|
+
'-webkit-justify-content': 'center',
|
|
1898
|
+
position: 'fixed',
|
|
1899
|
+
top: '50%',
|
|
1900
|
+
left: '50%',
|
|
1901
|
+
'min-width': '120px',
|
|
1902
|
+
'max-width': '200px',
|
|
1903
|
+
'min-height': '120px',
|
|
1904
|
+
padding: '15px',
|
|
1905
|
+
transform: 'translate(-50%, -50%)',
|
|
1906
|
+
'border-radius': '5px',
|
|
1907
|
+
'text-align': 'center',
|
|
1908
|
+
'line-height': '1.6',
|
|
1909
|
+
color: '#FFFFFF',
|
|
1910
|
+
background: 'rgba(17, 17, 17, 0.7)'
|
|
1911
|
+
},
|
|
1912
|
+
successStyle: {
|
|
1913
|
+
margin: '6px auto',
|
|
1914
|
+
width: '38px',
|
|
1915
|
+
height: '38px',
|
|
1916
|
+
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTQ4OTYzMjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzNDgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMjE5Ljk1MiA1MTIuNTc2bDIxMC40MzIgMjEwLjQzMi00NS4yNDggNDUuMjU2LTIxMC40MzItMjEwLjQzMnoiIHAtaWQ9IjQzNDkiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNzk5LjY3MiAyNjIuMjY0bDQ1LjI1NiA0NS4yNTYtNDYwLjQ2NCA0NjAuNDY0LTQ1LjI1Ni00NS4yNTZ6IiBwLWlkPSI0MzUwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
|
|
1917
|
+
'background-size': '100%'
|
|
1918
|
+
},
|
|
1919
|
+
errrorStyle: {
|
|
1920
|
+
margin: '6px auto',
|
|
1921
|
+
width: '38px',
|
|
1922
|
+
height: '38px',
|
|
1923
|
+
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTUxMDU1MTgzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE0MDc2IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNTggNjQgNjQgMjY0LjU4IDY0IDUxMnMyMDAuNTggNDQ4IDQ0OCA0NDggNDQ4LTIwMC41OCA0NDgtNDQ4Uzc1OS40MiA2NCA1MTIgNjR6IG0wIDc1MmEzNiAzNiAwIDEgMSAzNi0zNiAzNiAzNiAwIDAgMS0zNiAzNnogbTUxLjgzLTU1MS45NUw1NDggNjM2YTM2IDM2IDAgMCAxLTcyIDBsLTE1LjgzLTM3MS45NWMtMC4xLTEuMzMtMC4xNy0yLjY4LTAuMTctNC4wNWE1MiA1MiAwIDAgMSAxMDQgMGMwIDEuMzctMC4wNyAyLjcyLTAuMTcgNC4wNXoiIHAtaWQ9IjE0MDc3IiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
|
|
1924
|
+
'background-size': '100%'
|
|
1925
|
+
},
|
|
1926
|
+
loadingStyle: {
|
|
1927
|
+
margin: '6px auto',
|
|
1928
|
+
width: '38px',
|
|
1929
|
+
height: '38px',
|
|
1930
|
+
'-webkit-animation': 'taroLoading 1s steps(12, end) infinite',
|
|
1931
|
+
animation: 'taroLoading 1s steps(12, end) infinite',
|
|
1932
|
+
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat',
|
|
1933
|
+
'background-size': '100%'
|
|
1934
|
+
},
|
|
1935
|
+
imageStyle: {
|
|
1936
|
+
margin: '6px auto',
|
|
1937
|
+
width: '40px',
|
|
1938
|
+
height: '40px',
|
|
1939
|
+
background: 'transparent no-repeat',
|
|
1940
|
+
'background-size': '100%'
|
|
1941
|
+
},
|
|
1942
|
+
textStyle: {
|
|
1943
|
+
margin: '0',
|
|
1944
|
+
'font-size': '16px'
|
|
1945
|
+
}
|
|
1946
|
+
};
|
|
1651
1947
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1948
|
+
create(options = {}, _type = 'toast') {
|
|
1949
|
+
var _a, _b;
|
|
1950
|
+
// style
|
|
1951
|
+
const { maskStyle, toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle, textStyle } = this.style;
|
|
1952
|
+
// configuration
|
|
1953
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
|
|
1954
|
+
// wrapper
|
|
1955
|
+
this.el = document.createElement('div');
|
|
1956
|
+
this.el.className = 'taro__toast';
|
|
1957
|
+
this.el.style.opacity = '0';
|
|
1958
|
+
this.el.style.transition = 'opacity 0.1s linear';
|
|
1959
|
+
this.el.ontouchmove = (e) => {
|
|
1960
|
+
e.stopPropagation();
|
|
1961
|
+
e.preventDefault();
|
|
1962
|
+
};
|
|
1963
|
+
// mask
|
|
1964
|
+
this.mask = document.createElement('div');
|
|
1965
|
+
this.mask.setAttribute('style', inlineStyle(maskStyle));
|
|
1966
|
+
this.mask.style.display = config.mask ? 'block' : 'none';
|
|
1967
|
+
// icon
|
|
1968
|
+
this.icon = document.createElement('p');
|
|
1969
|
+
if (config.image) {
|
|
1970
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
1971
|
+
}
|
|
1972
|
+
else {
|
|
1973
|
+
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
1974
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
1975
|
+
}
|
|
1976
|
+
// toast
|
|
1977
|
+
this.toast = document.createElement('div');
|
|
1978
|
+
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
1979
|
+
'min-height': '0',
|
|
1980
|
+
padding: '10px 15px'
|
|
1981
|
+
} : {}))));
|
|
1982
|
+
// title
|
|
1983
|
+
this.title = document.createElement('p');
|
|
1984
|
+
this.title.setAttribute('style', inlineStyle(textStyle));
|
|
1985
|
+
this.title.textContent = config.title;
|
|
1986
|
+
// result
|
|
1987
|
+
this.toast.appendChild(this.icon);
|
|
1988
|
+
this.toast.appendChild(this.title);
|
|
1989
|
+
this.el.appendChild(this.mask);
|
|
1990
|
+
this.el.appendChild(this.toast);
|
|
1991
|
+
// show immediately
|
|
1992
|
+
document.body.appendChild(this.el);
|
|
1993
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
1994
|
+
this.type = config._type;
|
|
1995
|
+
// disappear after duration
|
|
1996
|
+
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
1997
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
1998
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
1999
|
+
return '';
|
|
1654
2000
|
}
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
beta: evt.beta,
|
|
1671
|
-
gamma: evt.gamma
|
|
1672
|
-
});
|
|
1673
|
-
}, intervalObj.interval);
|
|
1674
|
-
window.addEventListener('deviceorientation', deviceMotionListener, true);
|
|
2001
|
+
show(options = {}, _type = 'toast') {
|
|
2002
|
+
var _a, _b;
|
|
2003
|
+
const config = Object.assign(Object.assign(Object.assign({}, this.options), options), { _type });
|
|
2004
|
+
if (this.hideOpacityTimer)
|
|
2005
|
+
clearTimeout(this.hideOpacityTimer);
|
|
2006
|
+
if (this.hideDisplayTimer)
|
|
2007
|
+
clearTimeout(this.hideDisplayTimer);
|
|
2008
|
+
// title
|
|
2009
|
+
this.title.textContent = config.title || '';
|
|
2010
|
+
// mask
|
|
2011
|
+
this.mask.style.display = config.mask ? 'block' : 'none';
|
|
2012
|
+
// image
|
|
2013
|
+
const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style;
|
|
2014
|
+
if (config.image) {
|
|
2015
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
1675
2016
|
}
|
|
1676
2017
|
else {
|
|
1677
|
-
|
|
2018
|
+
if (!config.image && config.icon) {
|
|
2019
|
+
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
2020
|
+
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
2021
|
+
}
|
|
1678
2022
|
}
|
|
1679
|
-
|
|
2023
|
+
// toast
|
|
2024
|
+
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
2025
|
+
'min-height': '0',
|
|
2026
|
+
padding: '10px 15px'
|
|
2027
|
+
} : {}))));
|
|
2028
|
+
// show
|
|
2029
|
+
this.el.style.display = 'block';
|
|
2030
|
+
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
2031
|
+
this.type = config._type;
|
|
2032
|
+
// disappear after duration
|
|
2033
|
+
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
2034
|
+
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
2035
|
+
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
2036
|
+
return '';
|
|
1680
2037
|
}
|
|
1681
|
-
|
|
1682
|
-
|
|
2038
|
+
hide(duration = 0, type = '') {
|
|
2039
|
+
if (type && type !== this.type)
|
|
2040
|
+
return;
|
|
2041
|
+
if (this.hideOpacityTimer)
|
|
2042
|
+
clearTimeout(this.hideOpacityTimer);
|
|
2043
|
+
if (this.hideDisplayTimer)
|
|
2044
|
+
clearTimeout(this.hideDisplayTimer);
|
|
2045
|
+
this.currentPath = null;
|
|
2046
|
+
this.hideOpacityTimer = setTimeout(() => {
|
|
2047
|
+
this.el.style.opacity = '0';
|
|
2048
|
+
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
|
|
2049
|
+
}, duration);
|
|
1683
2050
|
}
|
|
1684
|
-
}
|
|
1685
|
-
/**
|
|
1686
|
-
* 监听设备方向变化事件。
|
|
1687
|
-
*/
|
|
1688
|
-
const onDeviceMotionChange = callback => {
|
|
1689
|
-
callbackManager$1.add(callback);
|
|
1690
|
-
};
|
|
1691
|
-
/**
|
|
1692
|
-
* 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。
|
|
1693
|
-
*/
|
|
1694
|
-
const offDeviceMotionChange = callback => {
|
|
1695
|
-
callbackManager$1.remove(callback);
|
|
1696
|
-
};
|
|
2051
|
+
}
|
|
1697
2052
|
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
2053
|
+
// 交互
|
|
2054
|
+
let status = 'default';
|
|
2055
|
+
// inject necessary style
|
|
2056
|
+
function init(doc) {
|
|
2057
|
+
if (status === 'ready')
|
|
2058
|
+
return;
|
|
2059
|
+
const taroStyle = doc.createElement('style');
|
|
2060
|
+
taroStyle.textContent =
|
|
2061
|
+
'@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:last-child):after {content: "";position: absolute;left: 0;bottom: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}';
|
|
2062
|
+
doc.querySelector('head').appendChild(taroStyle);
|
|
2063
|
+
status = 'ready';
|
|
1701
2064
|
}
|
|
1702
|
-
const
|
|
1703
|
-
|
|
2065
|
+
const toast = new Toast();
|
|
2066
|
+
const modal = new Modal();
|
|
2067
|
+
const actionSheet = new ActionSheet();
|
|
2068
|
+
const showToast = (options = { title: '' }) => {
|
|
2069
|
+
init(document);
|
|
2070
|
+
options = Object.assign({
|
|
2071
|
+
title: '',
|
|
2072
|
+
icon: 'success',
|
|
2073
|
+
image: '',
|
|
2074
|
+
duration: 1500,
|
|
2075
|
+
mask: false
|
|
2076
|
+
}, options);
|
|
1704
2077
|
const { success, fail, complete } = options;
|
|
1705
|
-
const handle = new MethodHandler({ name: '
|
|
1706
|
-
|
|
1707
|
-
// 浏览器不支持获取网络状态
|
|
1708
|
-
if (!connection) {
|
|
1709
|
-
return handle.success({ networkType });
|
|
1710
|
-
}
|
|
1711
|
-
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
1712
|
-
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
1713
|
-
if (!isNaN(Number(connection.type))) {
|
|
1714
|
-
switch (connection.type) {
|
|
1715
|
-
// @ts-ignore
|
|
1716
|
-
case connection.WIFI:
|
|
1717
|
-
networkType = 'wifi';
|
|
1718
|
-
break;
|
|
1719
|
-
// @ts-ignore
|
|
1720
|
-
case connection.CELL_3G:
|
|
1721
|
-
networkType = '3g';
|
|
1722
|
-
break;
|
|
1723
|
-
// @ts-ignore
|
|
1724
|
-
case connection.CELL_2G:
|
|
1725
|
-
networkType = '2g';
|
|
1726
|
-
break;
|
|
1727
|
-
default:
|
|
1728
|
-
// ETHERNET, UNKNOWN
|
|
1729
|
-
networkType = 'unknown';
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
else if (connection.type) {
|
|
1733
|
-
// @ts-ignore
|
|
1734
|
-
networkType = connection.type; // Only supports the type value.
|
|
1735
|
-
// @ts-ignore
|
|
1736
|
-
}
|
|
1737
|
-
else if (connection.effectiveType) {
|
|
1738
|
-
// @ts-ignore
|
|
1739
|
-
networkType = connection.effectiveType;
|
|
1740
|
-
}
|
|
1741
|
-
return handle.success({ networkType });
|
|
1742
|
-
};
|
|
1743
|
-
const networkStatusManager = new CallbackManager();
|
|
1744
|
-
const networkStatusListener = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1745
|
-
const { networkType } = yield getNetworkType();
|
|
1746
|
-
const isConnected = networkType !== 'none';
|
|
1747
|
-
const obj = { isConnected, networkType };
|
|
1748
|
-
networkStatusManager.trigger(obj);
|
|
1749
|
-
});
|
|
1750
|
-
/**
|
|
1751
|
-
* 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
|
|
1752
|
-
* - 出现三次以上连接超时
|
|
1753
|
-
* - 出现三次 rtt 超过 400
|
|
1754
|
-
* - 出现三次以上的丢包
|
|
1755
|
-
* > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
|
|
1756
|
-
*/
|
|
1757
|
-
const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange');
|
|
1758
|
-
const onNetworkStatusChange = callback => {
|
|
1759
|
-
networkStatusManager.add(callback);
|
|
1760
|
-
const connection = getConnection();
|
|
1761
|
-
if (connection && networkStatusManager.count() === 1) {
|
|
1762
|
-
connection.addEventListener('change', networkStatusListener);
|
|
1763
|
-
}
|
|
1764
|
-
};
|
|
1765
|
-
const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange');
|
|
1766
|
-
const offNetworkStatusChange = callback => {
|
|
1767
|
-
networkStatusManager.remove(callback);
|
|
1768
|
-
const connection = getConnection();
|
|
1769
|
-
if (connection && networkStatusManager.count() === 0) {
|
|
1770
|
-
connection.removeEventListener('change', networkStatusListener);
|
|
1771
|
-
}
|
|
1772
|
-
};
|
|
1773
|
-
const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress');
|
|
1774
|
-
|
|
1775
|
-
// NFC
|
|
1776
|
-
const stopHCE = /* @__PURE__ */ temporarilyNotSupport('stopHCE');
|
|
1777
|
-
const startHCE = /* @__PURE__ */ temporarilyNotSupport('startHCE');
|
|
1778
|
-
const sendHCEMessage = /* @__PURE__ */ temporarilyNotSupport('sendHCEMessage');
|
|
1779
|
-
const onHCEMessage = /* @__PURE__ */ temporarilyNotSupport('onHCEMessage');
|
|
1780
|
-
const offHCEMessage = /* @__PURE__ */ temporarilyNotSupport('offHCEMessage');
|
|
1781
|
-
const getNFCAdapter = /* @__PURE__ */ temporarilyNotSupport('getNFCAdapter');
|
|
1782
|
-
const getHCEState = /* @__PURE__ */ temporarilyNotSupport('getHCEState');
|
|
1783
|
-
|
|
1784
|
-
const makePhoneCall = (options) => {
|
|
1785
|
-
// options must be an Object
|
|
1786
|
-
const isObject = shouldBeObject(options);
|
|
1787
|
-
if (!isObject.flag) {
|
|
1788
|
-
const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
|
|
1789
|
-
console.error(res.errMsg);
|
|
1790
|
-
return Promise.reject(res);
|
|
1791
|
-
}
|
|
1792
|
-
const { phoneNumber, success, fail, complete } = options;
|
|
1793
|
-
const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete });
|
|
1794
|
-
if (typeof phoneNumber !== 'string') {
|
|
2078
|
+
const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
|
|
2079
|
+
if (typeof options.title !== 'string') {
|
|
1795
2080
|
return handle.fail({
|
|
1796
2081
|
errMsg: getParameterError({
|
|
1797
|
-
para: '
|
|
2082
|
+
para: 'title',
|
|
1798
2083
|
correct: 'String',
|
|
1799
|
-
wrong:
|
|
2084
|
+
wrong: options.title
|
|
1800
2085
|
})
|
|
1801
2086
|
});
|
|
1802
2087
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
formatResult: res => ({
|
|
1812
|
-
errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
|
|
1813
|
-
result: res.resultStr
|
|
1814
|
-
})
|
|
1815
|
-
});
|
|
1816
|
-
|
|
1817
|
-
// 屏幕
|
|
1818
|
-
const setVisualEffectOnCapture = /* @__PURE__ */ temporarilyNotSupport('setVisualEffectOnCapture');
|
|
1819
|
-
const setScreenBrightness = /* @__PURE__ */ temporarilyNotSupport('setScreenBrightness');
|
|
1820
|
-
const setKeepScreenOn = /* @__PURE__ */ temporarilyNotSupport('setKeepScreenOn');
|
|
1821
|
-
const onUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('onUserCaptureScreen');
|
|
1822
|
-
const offUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('offUserCaptureScreen');
|
|
1823
|
-
const getScreenBrightness = /* @__PURE__ */ temporarilyNotSupport('getScreenBrightness');
|
|
1824
|
-
const onScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('onScreenRecordingStateChanged');
|
|
1825
|
-
const offScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('offScreenRecordingStateChanged');
|
|
1826
|
-
const getScreenRecordingState = /* @__PURE__ */ temporarilyNotSupport('getScreenRecordingState');
|
|
1827
|
-
|
|
1828
|
-
// 短信
|
|
1829
|
-
const sendSms = /* @__PURE__ */ temporarilyNotSupport('sendSms');
|
|
1830
|
-
|
|
1831
|
-
const vibrator = function vibrator(mm) {
|
|
1832
|
-
try {
|
|
1833
|
-
return window.navigator.vibrate(mm);
|
|
1834
|
-
}
|
|
1835
|
-
catch (e) {
|
|
1836
|
-
console.warn('当前浏览器不支持 vibrate。');
|
|
2088
|
+
if (typeof options.duration !== 'number') {
|
|
2089
|
+
return handle.fail({
|
|
2090
|
+
errMsg: getParameterError({
|
|
2091
|
+
para: 'duration',
|
|
2092
|
+
correct: 'Number',
|
|
2093
|
+
wrong: options.duration
|
|
2094
|
+
})
|
|
2095
|
+
});
|
|
1837
2096
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
if (vibrator(15)) {
|
|
1845
|
-
return handle.success();
|
|
2097
|
+
if (options.image && typeof options.image !== 'string')
|
|
2098
|
+
options.image = '';
|
|
2099
|
+
options.mask = !!options.mask;
|
|
2100
|
+
let errMsg = '';
|
|
2101
|
+
if (!toast.el) {
|
|
2102
|
+
errMsg = toast.create(options, 'toast');
|
|
1846
2103
|
}
|
|
1847
2104
|
else {
|
|
1848
|
-
|
|
2105
|
+
errMsg = toast.show(options, 'toast');
|
|
1849
2106
|
}
|
|
2107
|
+
return handle.success({ errMsg });
|
|
1850
2108
|
};
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
1855
|
-
const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete });
|
|
1856
|
-
if (vibrator(400)) {
|
|
2109
|
+
const hideToast = ({ noConflict = false, success, fail, complete } = {}) => {
|
|
2110
|
+
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete });
|
|
2111
|
+
if (!toast.el)
|
|
1857
2112
|
return handle.success();
|
|
2113
|
+
toast.hide(0, noConflict ? 'toast' : '');
|
|
2114
|
+
return handle.success();
|
|
2115
|
+
};
|
|
2116
|
+
const showLoading = (options = { title: '' }) => {
|
|
2117
|
+
init(document);
|
|
2118
|
+
options = Object.assign({
|
|
2119
|
+
title: '',
|
|
2120
|
+
mask: false
|
|
2121
|
+
}, options);
|
|
2122
|
+
const { success, fail, complete } = options;
|
|
2123
|
+
const handle = new MethodHandler({ name: 'showLoading', success, fail, complete });
|
|
2124
|
+
const config = {
|
|
2125
|
+
icon: 'loading',
|
|
2126
|
+
image: '',
|
|
2127
|
+
duration: -1
|
|
2128
|
+
};
|
|
2129
|
+
options = Object.assign({}, options, config);
|
|
2130
|
+
if (typeof options.title !== 'string') {
|
|
2131
|
+
return handle.fail({
|
|
2132
|
+
errMsg: getParameterError({
|
|
2133
|
+
para: 'title',
|
|
2134
|
+
correct: 'String',
|
|
2135
|
+
wrong: options.title
|
|
2136
|
+
})
|
|
2137
|
+
});
|
|
2138
|
+
}
|
|
2139
|
+
options.mask = !!options.mask;
|
|
2140
|
+
let errMsg = '';
|
|
2141
|
+
if (!toast.el) {
|
|
2142
|
+
errMsg = toast.create(options, 'loading');
|
|
1858
2143
|
}
|
|
1859
2144
|
else {
|
|
1860
|
-
|
|
2145
|
+
errMsg = toast.show(options, 'loading');
|
|
1861
2146
|
}
|
|
2147
|
+
return handle.success({ errMsg });
|
|
1862
2148
|
};
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
const onWifiConnected = /* @__PURE__ */ temporarilyNotSupport('onWifiConnected');
|
|
1870
|
-
const onGetWifiList = /* @__PURE__ */ temporarilyNotSupport('onGetWifiList');
|
|
1871
|
-
const offWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('offWifiConnectedWithPartialInfo');
|
|
1872
|
-
const offWifiConnected = /* @__PURE__ */ temporarilyNotSupport('offWifiConnected');
|
|
1873
|
-
const offGetWifiList = /* @__PURE__ */ temporarilyNotSupport('offGetWifiList');
|
|
1874
|
-
const getWifiList = /* @__PURE__ */ temporarilyNotSupport('getWifiList');
|
|
1875
|
-
const getConnectedWifi = /* @__PURE__ */ temporarilyNotSupport('getConnectedWifi');
|
|
1876
|
-
const connectWifi = /* @__PURE__ */ temporarilyNotSupport('connectWifi');
|
|
1877
|
-
|
|
1878
|
-
// 第三方平台
|
|
1879
|
-
const getExtConfigSync = /* @__PURE__ */ temporarilyNotSupport('getExtConfigSync');
|
|
1880
|
-
const getExtConfig = /* @__PURE__ */ temporarilyNotSupport('getExtConfig');
|
|
1881
|
-
|
|
1882
|
-
// 文件
|
|
1883
|
-
const saveFileToDisk = /* @__PURE__ */ temporarilyNotSupport('saveFileToDisk');
|
|
1884
|
-
const saveFile = /* @__PURE__ */ temporarilyNotSupport('saveFile');
|
|
1885
|
-
const removeSavedFile = /* @__PURE__ */ temporarilyNotSupport('removeSavedFile');
|
|
1886
|
-
const openDocument = /* @__PURE__ */ temporarilyNotSupport('openDocument');
|
|
1887
|
-
const getSavedFileList = /* @__PURE__ */ temporarilyNotSupport('getSavedFileList');
|
|
1888
|
-
const getSavedFileInfo = /* @__PURE__ */ temporarilyNotSupport('getSavedFileInfo');
|
|
1889
|
-
const getFileSystemManager = /* @__PURE__ */ temporarilyNotSupport('getFileSystemManager');
|
|
1890
|
-
const getFileInfo = /* @__PURE__ */ temporarilyNotSupport('getFileInfo');
|
|
1891
|
-
|
|
1892
|
-
const getApp = function () {
|
|
1893
|
-
return Taro.getCurrentInstance().app;
|
|
2149
|
+
const hideLoading = ({ noConflict = false, success, fail, complete } = {}) => {
|
|
2150
|
+
const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete });
|
|
2151
|
+
if (!toast.el)
|
|
2152
|
+
return handle.success();
|
|
2153
|
+
toast.hide(0, noConflict ? 'loading' : '');
|
|
2154
|
+
return handle.success();
|
|
1894
2155
|
};
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
}
|
|
1907
|
-
// 解构回调函数
|
|
2156
|
+
const showModal = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2157
|
+
init(document);
|
|
2158
|
+
options = Object.assign({
|
|
2159
|
+
title: '',
|
|
2160
|
+
content: '',
|
|
2161
|
+
showCancel: true,
|
|
2162
|
+
cancelText: '取消',
|
|
2163
|
+
cancelColor: '#000000',
|
|
2164
|
+
confirmText: '确定',
|
|
2165
|
+
confirmColor: '#3CC51F'
|
|
2166
|
+
}, options);
|
|
1908
2167
|
const { success, fail, complete } = options;
|
|
1909
|
-
const handle = new MethodHandler({ name: '
|
|
1910
|
-
|
|
1911
|
-
const positionOptions = {
|
|
1912
|
-
enableHighAccuracy: options.isHighAccuracy || (options.altitude != null),
|
|
1913
|
-
// maximumAge: defaultMaximumAge, // 允许取多久以内的缓存位置
|
|
1914
|
-
timeout: options.highAccuracyExpireTime // 高精度定位超时时间
|
|
1915
|
-
};
|
|
1916
|
-
// Web端API实现暂时仅支持GPS坐标系
|
|
1917
|
-
if (((_a = options.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== 'WGS84') {
|
|
2168
|
+
const handle = new MethodHandler({ name: 'showModal', success, fail, complete });
|
|
2169
|
+
if (typeof options.title !== 'string') {
|
|
1918
2170
|
return handle.fail({
|
|
1919
|
-
errMsg:
|
|
2171
|
+
errMsg: getParameterError({
|
|
2172
|
+
para: 'title',
|
|
2173
|
+
correct: 'String',
|
|
2174
|
+
wrong: options.title
|
|
2175
|
+
})
|
|
1920
2176
|
});
|
|
1921
2177
|
}
|
|
1922
|
-
|
|
1923
|
-
const geolocationSupported = navigator.geolocation;
|
|
1924
|
-
if (!geolocationSupported) {
|
|
2178
|
+
if (typeof options.content !== 'string') {
|
|
1925
2179
|
return handle.fail({
|
|
1926
|
-
errMsg:
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
navigator.geolocation.getCurrentPosition((position) => {
|
|
1932
|
-
const result = {
|
|
1933
|
-
/** 位置的精确度 */
|
|
1934
|
-
accuracy: position.coords.accuracy,
|
|
1935
|
-
/** 高度,单位 m */
|
|
1936
|
-
altitude: position.coords.altitude,
|
|
1937
|
-
/** 水平精度,单位 m */
|
|
1938
|
-
horizontalAccuracy: position.coords.accuracy,
|
|
1939
|
-
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
1940
|
-
latitude: position.coords.latitude,
|
|
1941
|
-
/** 经度,范围为 -180~180,负数表示西经 */
|
|
1942
|
-
longitude: position.coords.longitude,
|
|
1943
|
-
/** 速度,单位 m/s */
|
|
1944
|
-
speed: position.coords.speed,
|
|
1945
|
-
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
1946
|
-
verticalAccuracy: position.coords.altitudeAccuracy || 0,
|
|
1947
|
-
/** 调用结果,自动补充 */
|
|
1948
|
-
errMsg: ''
|
|
1949
|
-
};
|
|
1950
|
-
handle.success(result, { resolve, reject });
|
|
1951
|
-
}, (error) => {
|
|
1952
|
-
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
1953
|
-
}, positionOptions);
|
|
1954
|
-
});
|
|
1955
|
-
};
|
|
1956
|
-
const getLocation = /* @__PURE__ */ processOpenApi({
|
|
1957
|
-
name: 'getLocation',
|
|
1958
|
-
standardMethod: getLocationByW3CApi
|
|
1959
|
-
});
|
|
1960
|
-
|
|
1961
|
-
function styleInject(css, ref) {
|
|
1962
|
-
if ( ref === void 0 ) ref = {};
|
|
1963
|
-
var insertAt = ref.insertAt;
|
|
1964
|
-
|
|
1965
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
1966
|
-
|
|
1967
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
1968
|
-
var style = document.createElement('style');
|
|
1969
|
-
style.type = 'text/css';
|
|
1970
|
-
|
|
1971
|
-
if (insertAt === 'top') {
|
|
1972
|
-
if (head.firstChild) {
|
|
1973
|
-
head.insertBefore(style, head.firstChild);
|
|
1974
|
-
} else {
|
|
1975
|
-
head.appendChild(style);
|
|
1976
|
-
}
|
|
1977
|
-
} else {
|
|
1978
|
-
head.appendChild(style);
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
if (style.styleSheet) {
|
|
1982
|
-
style.styleSheet.cssText = css;
|
|
1983
|
-
} else {
|
|
1984
|
-
style.appendChild(document.createTextNode(css));
|
|
1985
|
-
}
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
var css_248z = ".taro_choose_location{background-color:#fff;display:flex;flex-direction:column;height:100%;position:fixed;top:100%;transition:top .3s ease;width:100%;z-index:1}.taro_choose_location_bar{background-color:#ededed;color:#090909;display:flex;flex:0 95px;height:95px}.taro_choose_location_back{flex:0 45px;height:30px;margin-top:30px;position:relative;width:33px}.taro_choose_location_back:before{border:15px solid transparent;border-right-color:#090909;content:\"\";display:block;height:0;left:0;position:absolute;top:0;width:0}.taro_choose_location_back:after{border:15px solid transparent;border-right-color:#ededed;content:\"\";display:block;height:0;left:3px;position:absolute;top:0;width:0}.taro_choose_location_title{flex:1;line-height:95px;padding-left:30px}.taro_choose_location_submit{background-color:#08bf62;border:none;color:#fff;font-size:28px;height:60px;line-height:60px;margin:18px 30px 0 0;padding:0;width:110px}.taro_choose_location_frame{flex:1}";
|
|
1989
|
-
var stylesheet=".taro_choose_location{background-color:#fff;display:flex;flex-direction:column;height:100%;position:fixed;top:100%;transition:top .3s ease;width:100%;z-index:1}.taro_choose_location_bar{background-color:#ededed;color:#090909;display:flex;flex:0 95px;height:95px}.taro_choose_location_back{flex:0 45px;height:30px;margin-top:30px;position:relative;width:33px}.taro_choose_location_back:before{border:15px solid transparent;border-right-color:#090909;content:\"\";display:block;height:0;left:0;position:absolute;top:0;width:0}.taro_choose_location_back:after{border:15px solid transparent;border-right-color:#ededed;content:\"\";display:block;height:0;left:3px;position:absolute;top:0;width:0}.taro_choose_location_title{flex:1;line-height:95px;padding-left:30px}.taro_choose_location_submit{background-color:#08bf62;border:none;color:#fff;font-size:28px;height:60px;line-height:60px;margin:18px 30px 0 0;padding:0;width:110px}.taro_choose_location_frame{flex:1}";
|
|
1990
|
-
styleInject(css_248z,{"insertAt":"top"});
|
|
1991
|
-
|
|
1992
|
-
let container = null;
|
|
1993
|
-
function createLocationChooser(handler, key = LOCATION_APIKEY, mapOpt = {}) {
|
|
1994
|
-
var _a, _b, _c;
|
|
1995
|
-
const { latitude, longitude } = mapOpt, opts = __rest(mapOpt, ["latitude", "longitude"]);
|
|
1996
|
-
const query = Object.assign({ key, type: 1, coord: ((_a = mapOpt.coord) !== null && _a !== void 0 ? _a : [latitude, longitude].every(e => Number(e) >= 0)) ? `${latitude},${longitude}` : undefined, referer: 'myapp' }, opts);
|
|
1997
|
-
if (!container) {
|
|
1998
|
-
const html = `
|
|
1999
|
-
<div class='taro_choose_location'>
|
|
2000
|
-
<div class='taro_choose_location_bar'>
|
|
2001
|
-
<div class='taro_choose_location_back'></div>
|
|
2002
|
-
<p class='taro_choose_location_title'>位置</p>
|
|
2003
|
-
<button class='taro_choose_location_submit'>完成</button>
|
|
2004
|
-
</div>
|
|
2005
|
-
<iframe class='taro_choose_location_frame' frameborder='0' src="https://apis.map.qq.com/tools/locpicker?${stringify(query, { arrayFormat: 'comma', skipNull: true })}" />
|
|
2006
|
-
</div>
|
|
2007
|
-
`;
|
|
2008
|
-
container = document.createElement('div');
|
|
2009
|
-
container.innerHTML = html;
|
|
2010
|
-
}
|
|
2011
|
-
const main = container.querySelector('.taro_choose_location');
|
|
2012
|
-
function show() {
|
|
2013
|
-
setTimeout(() => {
|
|
2014
|
-
main.style.top = '0';
|
|
2180
|
+
errMsg: getParameterError({
|
|
2181
|
+
para: 'content',
|
|
2182
|
+
correct: 'String',
|
|
2183
|
+
wrong: options.content
|
|
2184
|
+
})
|
|
2015
2185
|
});
|
|
2016
2186
|
}
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
hide();
|
|
2026
|
-
handler();
|
|
2187
|
+
if (typeof options.cancelText !== 'string') {
|
|
2188
|
+
return handle.fail({
|
|
2189
|
+
errMsg: getParameterError({
|
|
2190
|
+
para: 'cancelText',
|
|
2191
|
+
correct: 'String',
|
|
2192
|
+
wrong: options.cancelText
|
|
2193
|
+
})
|
|
2194
|
+
});
|
|
2027
2195
|
}
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2196
|
+
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
2197
|
+
return handle.fail({
|
|
2198
|
+
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
2199
|
+
});
|
|
2032
2200
|
}
|
|
2033
|
-
(
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
};
|
|
2041
|
-
}
|
|
2042
|
-
/**
|
|
2043
|
-
* 打开地图选择位置。
|
|
2044
|
-
*/
|
|
2045
|
-
const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
2046
|
-
const key = LOCATION_APIKEY;
|
|
2047
|
-
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
2048
|
-
return new Promise((resolve, reject) => {
|
|
2049
|
-
const chooseLocation = {};
|
|
2050
|
-
if (!key) {
|
|
2051
|
-
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2052
|
-
return handle.fail({
|
|
2053
|
-
errMsg: 'LOCATION_APIKEY needed'
|
|
2054
|
-
}, { resolve, reject });
|
|
2055
|
-
}
|
|
2056
|
-
const onMessage = event => {
|
|
2057
|
-
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
2058
|
-
const loc = event.data;
|
|
2059
|
-
// 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
|
|
2060
|
-
if (!loc || loc.module !== 'locationPicker')
|
|
2061
|
-
return;
|
|
2062
|
-
chooseLocation.name = loc.poiname;
|
|
2063
|
-
chooseLocation.address = loc.poiaddress;
|
|
2064
|
-
chooseLocation.latitude = loc.latlng.lat;
|
|
2065
|
-
chooseLocation.longitude = loc.latlng.lng;
|
|
2066
|
-
};
|
|
2067
|
-
const chooser = createLocationChooser(res => {
|
|
2068
|
-
window.removeEventListener('message', onMessage, false);
|
|
2069
|
-
setTimeout(() => {
|
|
2070
|
-
chooser.remove();
|
|
2071
|
-
}, 300);
|
|
2072
|
-
if (res) {
|
|
2073
|
-
return handle.fail(res, { resolve, reject });
|
|
2074
|
-
}
|
|
2075
|
-
else {
|
|
2076
|
-
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2077
|
-
return handle.success(chooseLocation, { resolve, reject });
|
|
2078
|
-
}
|
|
2079
|
-
else {
|
|
2080
|
-
return handle.fail({}, { resolve, reject });
|
|
2081
|
-
}
|
|
2082
|
-
}
|
|
2083
|
-
}, key, mapOpts);
|
|
2084
|
-
document.body.appendChild(chooser.container);
|
|
2085
|
-
window.addEventListener('message', onMessage, false);
|
|
2086
|
-
chooser.show();
|
|
2087
|
-
});
|
|
2088
|
-
};
|
|
2089
|
-
|
|
2090
|
-
// 位置
|
|
2091
|
-
const stopLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('stopLocationUpdate');
|
|
2092
|
-
const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground');
|
|
2093
|
-
const startLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdate');
|
|
2094
|
-
const openLocation = /* @__PURE__ */ processOpenApi({
|
|
2095
|
-
name: 'openLocation',
|
|
2096
|
-
defaultOptions: { scale: 18 }
|
|
2097
|
-
});
|
|
2098
|
-
const onLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('onLocationChangeError');
|
|
2099
|
-
const onLocationChange = /* @__PURE__ */ temporarilyNotSupport('onLocationChange');
|
|
2100
|
-
const offLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('offLocationChangeError');
|
|
2101
|
-
const offLocationChange = /* @__PURE__ */ temporarilyNotSupport('offLocationChange');
|
|
2102
|
-
const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi');
|
|
2103
|
-
const getFuzzyLocation = /* @__PURE__ */ temporarilyNotSupport('getFuzzyLocation');
|
|
2104
|
-
|
|
2105
|
-
class InnerAudioContext {
|
|
2106
|
-
constructor() {
|
|
2107
|
-
this.__startTime = 0;
|
|
2108
|
-
this.__isFirstPlay = true;
|
|
2109
|
-
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
2110
|
-
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
2111
|
-
this.stop = () => {
|
|
2112
|
-
this.pause();
|
|
2113
|
-
this.seek(0);
|
|
2114
|
-
this.stopStack.trigger();
|
|
2115
|
-
};
|
|
2116
|
-
this.seek = (position) => {
|
|
2117
|
-
if (this.Instance) {
|
|
2118
|
-
this.Instance.currentTime = position;
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
/**
|
|
2122
|
-
* @TODO destroy得并不干净
|
|
2123
|
-
*/
|
|
2124
|
-
this.destroy = () => {
|
|
2125
|
-
this.stop();
|
|
2126
|
-
if (this.Instance) {
|
|
2127
|
-
this.Instance = undefined;
|
|
2128
|
-
}
|
|
2129
|
-
};
|
|
2130
|
-
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
2131
|
-
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
2132
|
-
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
2133
|
-
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
2134
|
-
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
2135
|
-
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
2136
|
-
this.onError = (callback) => this.errorStack.add(callback);
|
|
2137
|
-
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
2138
|
-
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
2139
|
-
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
2140
|
-
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
2141
|
-
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
2142
|
-
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
2143
|
-
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
2144
|
-
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
2145
|
-
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
2146
|
-
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
2147
|
-
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
2148
|
-
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
2149
|
-
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
2150
|
-
this.Instance = new Audio();
|
|
2151
|
-
this.errorStack = new CallbackManager();
|
|
2152
|
-
this.stopStack = new CallbackManager();
|
|
2153
|
-
this.Instance.onerror = this.errorStack.trigger;
|
|
2154
|
-
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
2155
|
-
this.onPlay(() => {
|
|
2156
|
-
if (this.__isFirstPlay) {
|
|
2157
|
-
this.__isFirstPlay = false;
|
|
2158
|
-
this.seek(this.startTime);
|
|
2159
|
-
}
|
|
2201
|
+
if (typeof options.confirmText !== 'string') {
|
|
2202
|
+
return handle.fail({
|
|
2203
|
+
errMsg: getParameterError({
|
|
2204
|
+
para: 'confirmText',
|
|
2205
|
+
correct: 'String',
|
|
2206
|
+
wrong: options.confirmText
|
|
2207
|
+
})
|
|
2160
2208
|
});
|
|
2161
2209
|
}
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
if (timeRange) {
|
|
2167
|
-
for (let i = 0; i < timeRange.length; i++) {
|
|
2168
|
-
if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
|
|
2169
|
-
return timeRange.end(i);
|
|
2170
|
-
}
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
return 0;
|
|
2210
|
+
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
2211
|
+
return handle.fail({
|
|
2212
|
+
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
2213
|
+
});
|
|
2174
2214
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
set volume(e) { this.setProperty('volume', e); }
|
|
2184
|
-
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
2185
|
-
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
2186
|
-
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
2187
|
-
set obeyMuteSwitch(_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')(); }
|
|
2188
|
-
get obeyMuteSwitch() { return true; }
|
|
2189
|
-
set startTime(e) { this.__startTime = e; }
|
|
2190
|
-
get startTime() { return this.__startTime || 0; }
|
|
2191
|
-
set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
|
|
2192
|
-
get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
|
|
2193
|
-
setProperty(key, value) {
|
|
2194
|
-
if (this.Instance) {
|
|
2195
|
-
this.Instance[key] = value;
|
|
2196
|
-
}
|
|
2215
|
+
if (typeof options.cancelColor !== 'string') {
|
|
2216
|
+
return handle.fail({
|
|
2217
|
+
errMsg: getParameterError({
|
|
2218
|
+
para: 'cancelColor',
|
|
2219
|
+
correct: 'String',
|
|
2220
|
+
wrong: options.cancelColor
|
|
2221
|
+
})
|
|
2222
|
+
});
|
|
2197
2223
|
}
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
this.onNext = permanentlyNotSupport('BackgroundAudioManager.onNext');
|
|
2241
|
-
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
2242
|
-
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
2243
|
-
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
2244
|
-
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
2245
|
-
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
2246
|
-
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
2247
|
-
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
2248
|
-
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
2249
|
-
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
2250
|
-
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
2251
|
-
this.offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev');
|
|
2252
|
-
this.offNext = permanentlyNotSupport('BackgroundAudioManager.offNext');
|
|
2253
|
-
this.Instance = new Audio();
|
|
2254
|
-
this.errorStack = new CallbackManager();
|
|
2255
|
-
this.stopStack = new CallbackManager();
|
|
2256
|
-
this.Instance.onerror = this.errorStack.trigger;
|
|
2257
|
-
this.Instance.autoplay = true;
|
|
2258
|
-
this.onPlay(() => {
|
|
2259
|
-
if (this.currentTime !== this.startTime) {
|
|
2260
|
-
this.seek(this.startTime);
|
|
2261
|
-
}
|
|
2224
|
+
if (typeof options.confirmColor !== 'string') {
|
|
2225
|
+
return handle.fail({
|
|
2226
|
+
errMsg: getParameterError({
|
|
2227
|
+
para: 'confirmColor',
|
|
2228
|
+
correct: 'String',
|
|
2229
|
+
wrong: options.confirmColor
|
|
2230
|
+
})
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2233
|
+
options.showCancel = !!options.showCancel;
|
|
2234
|
+
let result = '';
|
|
2235
|
+
if (!modal.el) {
|
|
2236
|
+
result = yield modal.create(options);
|
|
2237
|
+
}
|
|
2238
|
+
else {
|
|
2239
|
+
result = yield modal.show(options);
|
|
2240
|
+
}
|
|
2241
|
+
const res = { cancel: !1, confirm: !1 };
|
|
2242
|
+
res[result] = !0;
|
|
2243
|
+
return handle.success(res);
|
|
2244
|
+
});
|
|
2245
|
+
function hideModal() {
|
|
2246
|
+
if (!modal.el)
|
|
2247
|
+
return;
|
|
2248
|
+
modal.hide();
|
|
2249
|
+
}
|
|
2250
|
+
const showActionSheet = (options = { itemList: [] }, methodName = 'showActionSheet') => __awaiter(void 0, void 0, void 0, function* () {
|
|
2251
|
+
init(document);
|
|
2252
|
+
options = Object.assign({
|
|
2253
|
+
itemColor: '#000000',
|
|
2254
|
+
itemList: []
|
|
2255
|
+
}, options);
|
|
2256
|
+
const { success, fail, complete } = options;
|
|
2257
|
+
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
2258
|
+
// list item String
|
|
2259
|
+
if (!Array.isArray(options.itemList)) {
|
|
2260
|
+
return handle.fail({
|
|
2261
|
+
errMsg: getParameterError({
|
|
2262
|
+
para: 'itemList',
|
|
2263
|
+
correct: 'Array',
|
|
2264
|
+
wrong: options.itemList
|
|
2265
|
+
})
|
|
2262
2266
|
});
|
|
2263
2267
|
}
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
set startTime(e) { this.__startTime = e; }
|
|
2267
|
-
get startTime() { return this.__startTime || 0; }
|
|
2268
|
-
set title(e) { this.dataset('title', e); }
|
|
2269
|
-
get title() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.title) || ''; }
|
|
2270
|
-
set epname(e) { this.dataset('epname', e); }
|
|
2271
|
-
get epname() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.epname) || ''; }
|
|
2272
|
-
set singer(e) { this.dataset('singer', e); }
|
|
2273
|
-
get singer() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.singer) || ''; }
|
|
2274
|
-
set coverImgUrl(e) { this.dataset('coverImgUrl', e); }
|
|
2275
|
-
get coverImgUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.coverImgUrl) || ''; }
|
|
2276
|
-
set webUrl(e) { this.dataset('webUrl', e); }
|
|
2277
|
-
get webUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.webUrl) || ''; }
|
|
2278
|
-
set protocol(e) { this.dataset('protocol', e); }
|
|
2279
|
-
get protocol() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.protocol) || ''; }
|
|
2280
|
-
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
2281
|
-
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
2282
|
-
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
2283
|
-
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
2284
|
-
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || false; }
|
|
2285
|
-
get buffered() {
|
|
2286
|
-
const { currentTime = 0, buffered: timeRange } = this.Instance || {};
|
|
2287
|
-
if (timeRange) {
|
|
2288
|
-
for (let i = 0; i < timeRange.length; i++) {
|
|
2289
|
-
if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
|
|
2290
|
-
return timeRange.end(i);
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
}
|
|
2294
|
-
return 0;
|
|
2268
|
+
if (options.itemList.length < 1) {
|
|
2269
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' });
|
|
2295
2270
|
}
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
setProperty(key, value) {
|
|
2299
|
-
if (this.Instance) {
|
|
2300
|
-
this.Instance[key] = value;
|
|
2301
|
-
}
|
|
2271
|
+
if (options.itemList.length > 6) {
|
|
2272
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' });
|
|
2302
2273
|
}
|
|
2303
|
-
|
|
2304
|
-
if (
|
|
2305
|
-
|
|
2274
|
+
for (let i = 0; i < options.itemList.length; i++) {
|
|
2275
|
+
if (typeof options.itemList[i] !== 'string') {
|
|
2276
|
+
return handle.fail({
|
|
2277
|
+
errMsg: getParameterError({
|
|
2278
|
+
para: `itemList[${i}]`,
|
|
2279
|
+
correct: 'String',
|
|
2280
|
+
wrong: options.itemList[i]
|
|
2281
|
+
})
|
|
2282
|
+
});
|
|
2306
2283
|
}
|
|
2307
2284
|
}
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
// 背景音频
|
|
2311
|
-
const stopBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('stopBackgroundAudio');
|
|
2312
|
-
const seekBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('seekBackgroundAudio');
|
|
2313
|
-
const playBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('playBackgroundAudio');
|
|
2314
|
-
const pauseBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('pauseBackgroundAudio');
|
|
2315
|
-
const onBackgroundAudioStop = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioStop');
|
|
2316
|
-
const onBackgroundAudioPlay = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPlay');
|
|
2317
|
-
const onBackgroundAudioPause = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPause');
|
|
2318
|
-
const getBackgroundAudioPlayerState = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioPlayerState');
|
|
2319
|
-
/**
|
|
2320
|
-
* 获取全局唯一的背景音频管理器
|
|
2321
|
-
*/
|
|
2322
|
-
const getBackgroundAudioManager = () => new BackgroundAudioManager();
|
|
2323
|
-
|
|
2324
|
-
// 相机
|
|
2325
|
-
const createCameraContext = /* @__PURE__ */ temporarilyNotSupport('createCameraContext');
|
|
2326
|
-
|
|
2327
|
-
const saveImageToPhotosAlbum = (options) => {
|
|
2328
|
-
const methodName = 'saveImageToPhotosAlbum';
|
|
2329
|
-
// options must be an Object
|
|
2330
|
-
const isObject = shouldBeObject(options);
|
|
2331
|
-
if (!isObject.flag) {
|
|
2332
|
-
const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
|
|
2333
|
-
console.error(res.errMsg);
|
|
2334
|
-
return Promise.reject(res);
|
|
2335
|
-
}
|
|
2336
|
-
const { filePath, success, fail, complete, } = options;
|
|
2337
|
-
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
2338
|
-
if (typeof filePath !== 'string') {
|
|
2285
|
+
if (typeof options.itemColor !== 'string') {
|
|
2339
2286
|
return handle.fail({
|
|
2340
2287
|
errMsg: getParameterError({
|
|
2341
|
-
para: '
|
|
2288
|
+
para: 'itemColor',
|
|
2342
2289
|
correct: 'String',
|
|
2343
|
-
wrong:
|
|
2290
|
+
wrong: options.itemColor
|
|
2344
2291
|
})
|
|
2345
2292
|
});
|
|
2346
2293
|
}
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
/**
|
|
2352
|
-
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
2353
|
-
*/
|
|
2354
|
-
const getImageInfo = (options) => {
|
|
2355
|
-
// options must be an Object
|
|
2356
|
-
const isObject = shouldBeObject(options);
|
|
2357
|
-
if (!isObject.flag) {
|
|
2358
|
-
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
2359
|
-
console.error(res.errMsg);
|
|
2360
|
-
return Promise.reject(res);
|
|
2294
|
+
let result = '';
|
|
2295
|
+
if (!actionSheet.el) {
|
|
2296
|
+
result = yield actionSheet.create(options);
|
|
2361
2297
|
}
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
path: getBase64Image(image) || src
|
|
2385
|
-
}, { resolve, reject });
|
|
2386
|
-
};
|
|
2387
|
-
image.onerror = (e) => {
|
|
2388
|
-
handle.fail({
|
|
2389
|
-
errMsg: e.message
|
|
2390
|
-
}, { resolve, reject });
|
|
2391
|
-
};
|
|
2392
|
-
image.src = src;
|
|
2393
|
-
});
|
|
2394
|
-
};
|
|
2298
|
+
else {
|
|
2299
|
+
result = yield actionSheet.show(options);
|
|
2300
|
+
}
|
|
2301
|
+
if (typeof result === 'string') {
|
|
2302
|
+
return handle.fail(({ errMsg: result }));
|
|
2303
|
+
}
|
|
2304
|
+
else {
|
|
2305
|
+
return handle.success(({ tapIndex: result }));
|
|
2306
|
+
}
|
|
2307
|
+
});
|
|
2308
|
+
Taro.eventCenter.on('__afterTaroRouterChange', () => {
|
|
2309
|
+
var _a, _b;
|
|
2310
|
+
if (toast.currentPath && toast.currentPath !== ((_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path)) {
|
|
2311
|
+
hideToast();
|
|
2312
|
+
hideLoading();
|
|
2313
|
+
}
|
|
2314
|
+
if (modal.currentPath && modal.currentPath !== ((_b = Current$1.page) === null || _b === void 0 ? void 0 : _b.path)) {
|
|
2315
|
+
hideModal();
|
|
2316
|
+
}
|
|
2317
|
+
});
|
|
2318
|
+
const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
|
|
2319
|
+
const disableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('disableAlertBeforeUnload');
|
|
2395
2320
|
|
|
2396
2321
|
/**
|
|
2397
|
-
*
|
|
2322
|
+
* 剪贴板部分的api参考了Chameleon项目的实现:
|
|
2323
|
+
*
|
|
2324
|
+
* setClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/setClipBoardData
|
|
2325
|
+
* getClipboardData: https://github.com/chameleon-team/chameleon-api/tree/master/src/interfaces/getClipBoardData
|
|
2398
2326
|
*/
|
|
2327
|
+
const CLIPBOARD_STORAGE_NAME = 'taro_clipboard';
|
|
2328
|
+
document.addEventListener('copy', () => {
|
|
2329
|
+
var _a;
|
|
2330
|
+
setStorage({
|
|
2331
|
+
key: CLIPBOARD_STORAGE_NAME,
|
|
2332
|
+
data: (_a = window.getSelection()) === null || _a === void 0 ? void 0 : _a.toString()
|
|
2333
|
+
}).catch(e => {
|
|
2334
|
+
console.error(e);
|
|
2335
|
+
});
|
|
2336
|
+
});
|
|
2399
2337
|
/**
|
|
2400
|
-
*
|
|
2338
|
+
* 设置系统剪贴板的内容
|
|
2401
2339
|
*/
|
|
2402
|
-
const
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2340
|
+
const setClipboardData = ({ data, success, fail, complete }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2341
|
+
const handle = new MethodHandler({ name: 'setClipboardData', success, fail, complete });
|
|
2342
|
+
try {
|
|
2343
|
+
setStorageSync(CLIPBOARD_STORAGE_NAME, data);
|
|
2344
|
+
/**
|
|
2345
|
+
* 已于 iPhone 6s Plus iOS 13.1.3 上的 Safari 测试通过
|
|
2346
|
+
* iOS < 10 的系统可能无法使用编程方式访问剪贴板,参考:
|
|
2347
|
+
* https://stackoverflow.com/questions/34045777/copy-to-clipboard-using-javascript-in-ios/34046084
|
|
2348
|
+
*/
|
|
2349
|
+
if (isFunction(document.execCommand)) {
|
|
2350
|
+
const textarea = document.createElement('textarea');
|
|
2351
|
+
textarea.readOnly = true;
|
|
2352
|
+
textarea.value = data;
|
|
2353
|
+
textarea.style.position = 'absolute';
|
|
2354
|
+
textarea.style.width = '100px';
|
|
2355
|
+
textarea.style.left = '-10000px';
|
|
2356
|
+
document.body.appendChild(textarea);
|
|
2357
|
+
textarea.select();
|
|
2358
|
+
textarea.setSelectionRange(0, textarea.value.length);
|
|
2359
|
+
document.execCommand('copy');
|
|
2360
|
+
document.body.removeChild(textarea);
|
|
2361
|
+
}
|
|
2362
|
+
else {
|
|
2363
|
+
throw new Error('Unsupported Function: \'document.execCommand\'.');
|
|
2364
|
+
}
|
|
2365
|
+
showToast({
|
|
2366
|
+
title: '内容已复制',
|
|
2367
|
+
icon: 'none',
|
|
2368
|
+
duration: 1500
|
|
2425
2369
|
});
|
|
2370
|
+
return handle.success();
|
|
2426
2371
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
if (!isObject.flag) {
|
|
2430
|
-
const res = { errMsg: `previewImage:fail ${isObject.msg}` };
|
|
2431
|
-
console.error(res.errMsg);
|
|
2432
|
-
return Promise.reject(res);
|
|
2372
|
+
catch (e) {
|
|
2373
|
+
return handle.fail({ errMsg: e.message });
|
|
2433
2374
|
}
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
};
|
|
2441
|
-
// 路由改变后应该关闭预览框
|
|
2442
|
-
eventCenter$1.on('__taroRouterChange', removeHandler);
|
|
2443
|
-
container.classList.add('preview-image');
|
|
2444
|
-
container.style.cssText =
|
|
2445
|
-
'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;';
|
|
2446
|
-
container.addEventListener('click', removeHandler);
|
|
2447
|
-
const swiper = document.createElement('taro-swiper-core');
|
|
2448
|
-
// @ts-ignore
|
|
2449
|
-
swiper.full = true;
|
|
2450
|
-
// @ts-ignore
|
|
2451
|
-
swiper.zoom = true;
|
|
2452
|
-
let children = [];
|
|
2375
|
+
});
|
|
2376
|
+
/**
|
|
2377
|
+
* 获取系统剪贴板的内容
|
|
2378
|
+
*/
|
|
2379
|
+
const getClipboardData = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2380
|
+
const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete });
|
|
2453
2381
|
try {
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
catch (error) {
|
|
2457
|
-
return handle.fail({
|
|
2458
|
-
errMsg: error,
|
|
2459
|
-
});
|
|
2382
|
+
const data = getStorageSync(CLIPBOARD_STORAGE_NAME);
|
|
2383
|
+
return handle.success({ data });
|
|
2460
2384
|
}
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
swiper.appendChild(child);
|
|
2385
|
+
catch (e) {
|
|
2386
|
+
return handle.fail({ errMsg: e.message });
|
|
2464
2387
|
}
|
|
2465
|
-
const currentIndex = typeof current === 'number' ? current : urls.indexOf(current);
|
|
2466
|
-
swiper.current = currentIndex;
|
|
2467
|
-
container.appendChild(swiper);
|
|
2468
|
-
document.body.appendChild(container);
|
|
2469
|
-
return handle.success();
|
|
2470
2388
|
});
|
|
2471
2389
|
|
|
2390
|
+
const callbackManager$2 = new CallbackManager();
|
|
2391
|
+
let compassListener;
|
|
2472
2392
|
/**
|
|
2473
|
-
*
|
|
2474
|
-
* @author leeenx
|
|
2393
|
+
* Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation
|
|
2475
2394
|
*/
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
this.sheet = null;
|
|
2480
|
-
this.appendStyleSheet = () => {
|
|
2481
|
-
if (this.$style) {
|
|
2482
|
-
const head = document.getElementsByTagName('head')[0];
|
|
2483
|
-
this.$style.setAttribute('type', 'text/css');
|
|
2484
|
-
this.$style.setAttribute('data-type', 'Taro');
|
|
2485
|
-
head.appendChild(this.$style);
|
|
2486
|
-
this.sheet = this.$style.sheet;
|
|
2487
|
-
}
|
|
2488
|
-
if (this.sheet && !('insertRule' in this.sheet)) {
|
|
2489
|
-
console.warn('当前浏览器不支持 stylesheet.insertRule 接口');
|
|
2490
|
-
}
|
|
2491
|
-
};
|
|
2492
|
-
// 添加样式命令
|
|
2493
|
-
this.add = (cssText, index = 0) => {
|
|
2494
|
-
var _a;
|
|
2495
|
-
if (this.sheet === null) {
|
|
2496
|
-
// $style 未插入到 DOM
|
|
2497
|
-
this.appendStyleSheet();
|
|
2498
|
-
}
|
|
2499
|
-
(_a = this.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssText, index);
|
|
2500
|
-
};
|
|
2501
|
-
this.$style = document.createElement('style');
|
|
2395
|
+
const deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {
|
|
2396
|
+
if ('on' + item in window) {
|
|
2397
|
+
return item;
|
|
2502
2398
|
}
|
|
2503
|
-
}
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
const
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
TRANSITION_END = 'msTransitionEnd';
|
|
2528
|
-
TRANSFORM = '-ms-transform';
|
|
2529
|
-
}
|
|
2530
|
-
let animId = 0;
|
|
2531
|
-
class Animation {
|
|
2532
|
-
constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
|
|
2533
|
-
// 属性组合
|
|
2534
|
-
this.rules = [];
|
|
2535
|
-
// transform 对象
|
|
2536
|
-
this.transform = [`${TRANSFORM}:`];
|
|
2537
|
-
// 组合动画
|
|
2538
|
-
this.steps = [];
|
|
2539
|
-
// 动画 map ----- 永久保留
|
|
2540
|
-
this.animationMap = {};
|
|
2541
|
-
// animationMap 的长度
|
|
2542
|
-
this.animationMapCount = 0;
|
|
2543
|
-
// 默认值
|
|
2544
|
-
this.setDefault(duration, delay, timingFunction, transformOrigin);
|
|
2545
|
-
this.unit = unit;
|
|
2546
|
-
// atom 环境下,animation 属性不会显示,所以要改成 data-animation
|
|
2547
|
-
let animAttr = 'animation';
|
|
2548
|
-
// 动画 id
|
|
2549
|
-
this.id = ++animId;
|
|
2550
|
-
// 监听事件
|
|
2551
|
-
document.body.addEventListener(TRANSITION_END, (e) => {
|
|
2552
|
-
const target = e.target;
|
|
2553
|
-
if (target.getAttribute(animAttr) === null) {
|
|
2554
|
-
animAttr = 'data-animation';
|
|
2399
|
+
}) || '';
|
|
2400
|
+
/**
|
|
2401
|
+
* 停止监听罗盘数据
|
|
2402
|
+
*/
|
|
2403
|
+
const stopCompass = ({ success, fail, complete } = {}) => {
|
|
2404
|
+
const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete });
|
|
2405
|
+
try {
|
|
2406
|
+
window.removeEventListener(deviceorientationEventName, compassListener, true);
|
|
2407
|
+
return handle.success();
|
|
2408
|
+
}
|
|
2409
|
+
catch (e) {
|
|
2410
|
+
return handle.fail({ errMsg: e.message });
|
|
2411
|
+
}
|
|
2412
|
+
};
|
|
2413
|
+
let CompassChangeTrigger = false;
|
|
2414
|
+
/**
|
|
2415
|
+
* 开始监听罗盘数据
|
|
2416
|
+
*/
|
|
2417
|
+
const startCompass = ({ success, fail, complete } = {}) => {
|
|
2418
|
+
const handle = new MethodHandler({ name: 'startCompass', success, fail, complete });
|
|
2419
|
+
try {
|
|
2420
|
+
if (deviceorientationEventName !== '') {
|
|
2421
|
+
if (compassListener) {
|
|
2422
|
+
stopCompass();
|
|
2555
2423
|
}
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
if (animName === `taro-h5-poly-fill/${this.id}/create-animation`) {
|
|
2562
|
-
const [animIndex, __stepIndex = 0] = animPath.split('--');
|
|
2563
|
-
const stepIndex = Number(__stepIndex);
|
|
2564
|
-
// 动画总的关键帧
|
|
2565
|
-
const animStepsCount = this.animationMap[`${animName}__${animIndex}`];
|
|
2566
|
-
const animStepsMaxIndex = animStepsCount - 1;
|
|
2567
|
-
if (stepIndex < animStepsMaxIndex) {
|
|
2568
|
-
// 播放下一个关键帧(因为 nerv 和 react 有差异所以 animation & data-animation 都需要写)
|
|
2569
|
-
target.setAttribute(animAttr, `${animName}__${animIndex}--${stepIndex + 1}`);
|
|
2570
|
-
if (animAttr === 'animation') {
|
|
2571
|
-
// Nerv 环境,animation & data-animation 双重保险
|
|
2572
|
-
target.setAttribute('data-animation', `${animName}__${animIndex}--${stepIndex + 1}`);
|
|
2573
|
-
}
|
|
2424
|
+
compassListener = throttle((evt) => {
|
|
2425
|
+
const isAndroid = getDeviceInfo().system === 'AndroidOS';
|
|
2426
|
+
if (isAndroid && !evt.absolute && !CompassChangeTrigger) {
|
|
2427
|
+
CompassChangeTrigger = true;
|
|
2428
|
+
console.warn('Warning: In \'onCompassChange\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .');
|
|
2574
2429
|
}
|
|
2575
|
-
|
|
2576
|
-
|
|
2430
|
+
const alpha = evt.alpha || 0;
|
|
2431
|
+
/**
|
|
2432
|
+
* 由于平台差异,accuracy 在 iOS/Android 的值不同。
|
|
2433
|
+
* - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。
|
|
2434
|
+
* - Android:accuracy 是一个 string 类型的枚举值。
|
|
2435
|
+
*/
|
|
2436
|
+
const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha;
|
|
2437
|
+
callbackManager$2.trigger({
|
|
2438
|
+
direction: 360 - alpha,
|
|
2439
|
+
accuracy: accuracy
|
|
2440
|
+
});
|
|
2441
|
+
}, 5000);
|
|
2442
|
+
window.addEventListener(deviceorientationEventName, compassListener, true);
|
|
2443
|
+
}
|
|
2444
|
+
else {
|
|
2445
|
+
throw new Error('compass is not supported');
|
|
2446
|
+
}
|
|
2447
|
+
return handle.success();
|
|
2448
|
+
}
|
|
2449
|
+
catch (e) {
|
|
2450
|
+
return handle.fail({ errMsg: e.message });
|
|
2451
|
+
}
|
|
2452
|
+
};
|
|
2453
|
+
/**
|
|
2454
|
+
* 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
|
|
2455
|
+
*/
|
|
2456
|
+
const onCompassChange = callback => {
|
|
2457
|
+
callbackManager$2.add(callback);
|
|
2458
|
+
};
|
|
2459
|
+
/**
|
|
2460
|
+
* 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
|
|
2461
|
+
*/
|
|
2462
|
+
const offCompassChange = callback => {
|
|
2463
|
+
callbackManager$2.remove(callback);
|
|
2464
|
+
};
|
|
2465
|
+
|
|
2466
|
+
// 联系人
|
|
2467
|
+
const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact');
|
|
2468
|
+
const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact');
|
|
2469
|
+
|
|
2470
|
+
// 加密
|
|
2471
|
+
const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues');
|
|
2472
|
+
|
|
2473
|
+
// 陀螺仪
|
|
2474
|
+
const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope');
|
|
2475
|
+
const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope');
|
|
2476
|
+
const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange');
|
|
2477
|
+
const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange');
|
|
2478
|
+
|
|
2479
|
+
// 蓝牙-信标(Beacon)
|
|
2480
|
+
const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery');
|
|
2481
|
+
const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery');
|
|
2482
|
+
const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate');
|
|
2483
|
+
const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange');
|
|
2484
|
+
const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate');
|
|
2485
|
+
const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange');
|
|
2486
|
+
const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons');
|
|
2487
|
+
|
|
2488
|
+
// 键盘
|
|
2489
|
+
const onKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('onKeyboardHeightChange');
|
|
2490
|
+
const offKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('offKeyboardHeightChange');
|
|
2491
|
+
const hideKeyboard = /* @__PURE__ */ temporarilyNotSupport('hideKeyboard');
|
|
2492
|
+
const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange');
|
|
2493
|
+
|
|
2494
|
+
// 内存
|
|
2495
|
+
const onMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('onMemoryWarning');
|
|
2496
|
+
const offMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('offMemoryWarning');
|
|
2497
|
+
|
|
2498
|
+
const callbackManager$1 = new CallbackManager();
|
|
2499
|
+
let deviceMotionListener;
|
|
2500
|
+
const INTERVAL_MAP = {
|
|
2501
|
+
game: {
|
|
2502
|
+
interval: 20,
|
|
2503
|
+
frequency: 50
|
|
2504
|
+
},
|
|
2505
|
+
ui: {
|
|
2506
|
+
interval: 60,
|
|
2507
|
+
frequency: 16.67
|
|
2508
|
+
},
|
|
2509
|
+
normal: {
|
|
2510
|
+
interval: 200,
|
|
2511
|
+
frequency: 5
|
|
2577
2512
|
}
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2513
|
+
};
|
|
2514
|
+
/**
|
|
2515
|
+
* 停止监听设备方向的变化。
|
|
2516
|
+
*/
|
|
2517
|
+
const stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
|
|
2518
|
+
const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete });
|
|
2519
|
+
try {
|
|
2520
|
+
window.removeEventListener('deviceorientation', deviceMotionListener, true);
|
|
2521
|
+
return handle.success();
|
|
2584
2522
|
}
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
this.DEFAULT = { duration, delay, timingFunction, transformOrigin };
|
|
2523
|
+
catch (e) {
|
|
2524
|
+
return handle.fail({ errMsg: e.message });
|
|
2588
2525
|
}
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2526
|
+
};
|
|
2527
|
+
/**
|
|
2528
|
+
* 开始监听设备方向的变化。
|
|
2529
|
+
*/
|
|
2530
|
+
const startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {
|
|
2531
|
+
const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete });
|
|
2532
|
+
try {
|
|
2533
|
+
const intervalObj = INTERVAL_MAP[interval];
|
|
2534
|
+
if (window.DeviceOrientationEvent) {
|
|
2535
|
+
if (deviceMotionListener) {
|
|
2536
|
+
stopDeviceMotionListening();
|
|
2537
|
+
}
|
|
2538
|
+
deviceMotionListener = throttle((evt) => {
|
|
2539
|
+
callbackManager$1.trigger({
|
|
2540
|
+
alpha: evt.alpha,
|
|
2541
|
+
beta: evt.beta,
|
|
2542
|
+
gamma: evt.gamma
|
|
2543
|
+
});
|
|
2544
|
+
}, intervalObj.interval);
|
|
2545
|
+
window.addEventListener('deviceorientation', deviceMotionListener, true);
|
|
2546
|
+
}
|
|
2547
|
+
else {
|
|
2548
|
+
throw new Error('deviceMotion is not supported');
|
|
2549
|
+
}
|
|
2550
|
+
return handle.success();
|
|
2592
2551
|
}
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
return this;
|
|
2552
|
+
catch (e) {
|
|
2553
|
+
return handle.fail({ errMsg: e.message });
|
|
2596
2554
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2555
|
+
};
|
|
2556
|
+
/**
|
|
2557
|
+
* 监听设备方向变化事件。
|
|
2558
|
+
*/
|
|
2559
|
+
const onDeviceMotionChange = callback => {
|
|
2560
|
+
callbackManager$1.add(callback);
|
|
2561
|
+
};
|
|
2562
|
+
/**
|
|
2563
|
+
* 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。
|
|
2564
|
+
*/
|
|
2565
|
+
const offDeviceMotionChange = callback => {
|
|
2566
|
+
callbackManager$1.remove(callback);
|
|
2567
|
+
};
|
|
2568
|
+
|
|
2569
|
+
function getConnection() {
|
|
2570
|
+
// @ts-ignore
|
|
2571
|
+
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection;
|
|
2572
|
+
}
|
|
2573
|
+
const getNetworkType = (options = {}) => {
|
|
2574
|
+
const connection = getConnection();
|
|
2575
|
+
const { success, fail, complete } = options;
|
|
2576
|
+
const handle = new MethodHandler({ name: 'getNetworkType', success, fail, complete });
|
|
2577
|
+
let networkType = 'unknown';
|
|
2578
|
+
// 浏览器不支持获取网络状态
|
|
2579
|
+
if (!connection) {
|
|
2580
|
+
return handle.success({ networkType });
|
|
2600
2581
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2582
|
+
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
2583
|
+
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
2584
|
+
if (!isNaN(Number(connection.type))) {
|
|
2585
|
+
switch (connection.type) {
|
|
2586
|
+
// @ts-ignore
|
|
2587
|
+
case connection.WIFI:
|
|
2588
|
+
networkType = 'wifi';
|
|
2589
|
+
break;
|
|
2590
|
+
// @ts-ignore
|
|
2591
|
+
case connection.CELL_3G:
|
|
2592
|
+
networkType = '3g';
|
|
2593
|
+
break;
|
|
2594
|
+
// @ts-ignore
|
|
2595
|
+
case connection.CELL_2G:
|
|
2596
|
+
networkType = '2g';
|
|
2597
|
+
break;
|
|
2598
|
+
default:
|
|
2599
|
+
// ETHERNET, UNKNOWN
|
|
2600
|
+
networkType = 'unknown';
|
|
2607
2601
|
}
|
|
2608
|
-
return this;
|
|
2609
2602
|
}
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2603
|
+
else if (connection.type) {
|
|
2604
|
+
// @ts-ignore
|
|
2605
|
+
networkType = connection.type; // Only supports the type value.
|
|
2606
|
+
// @ts-ignore
|
|
2613
2607
|
}
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2608
|
+
else if (connection.effectiveType) {
|
|
2609
|
+
// @ts-ignore
|
|
2610
|
+
networkType = connection.effectiveType;
|
|
2617
2611
|
}
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2612
|
+
return handle.success({ networkType });
|
|
2613
|
+
};
|
|
2614
|
+
const networkStatusManager = new CallbackManager();
|
|
2615
|
+
const networkStatusListener = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2616
|
+
const { networkType } = yield getNetworkType();
|
|
2617
|
+
const isConnected = networkType !== 'none';
|
|
2618
|
+
const obj = { isConnected, networkType };
|
|
2619
|
+
networkStatusManager.trigger(obj);
|
|
2620
|
+
});
|
|
2621
|
+
/**
|
|
2622
|
+
* 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
|
|
2623
|
+
* - 出现三次以上连接超时
|
|
2624
|
+
* - 出现三次 rtt 超过 400
|
|
2625
|
+
* - 出现三次以上的丢包
|
|
2626
|
+
* > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
|
|
2627
|
+
*/
|
|
2628
|
+
const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange');
|
|
2629
|
+
const onNetworkStatusChange = callback => {
|
|
2630
|
+
networkStatusManager.add(callback);
|
|
2631
|
+
const connection = getConnection();
|
|
2632
|
+
if (connection && networkStatusManager.count() === 1) {
|
|
2633
|
+
connection.addEventListener('change', networkStatusListener);
|
|
2621
2634
|
}
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2635
|
+
};
|
|
2636
|
+
const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange');
|
|
2637
|
+
const offNetworkStatusChange = callback => {
|
|
2638
|
+
networkStatusManager.remove(callback);
|
|
2639
|
+
const connection = getConnection();
|
|
2640
|
+
if (connection && networkStatusManager.count() === 0) {
|
|
2641
|
+
connection.removeEventListener('change', networkStatusListener);
|
|
2625
2642
|
}
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2643
|
+
};
|
|
2644
|
+
const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress');
|
|
2645
|
+
|
|
2646
|
+
// NFC
|
|
2647
|
+
const stopHCE = /* @__PURE__ */ temporarilyNotSupport('stopHCE');
|
|
2648
|
+
const startHCE = /* @__PURE__ */ temporarilyNotSupport('startHCE');
|
|
2649
|
+
const sendHCEMessage = /* @__PURE__ */ temporarilyNotSupport('sendHCEMessage');
|
|
2650
|
+
const onHCEMessage = /* @__PURE__ */ temporarilyNotSupport('onHCEMessage');
|
|
2651
|
+
const offHCEMessage = /* @__PURE__ */ temporarilyNotSupport('offHCEMessage');
|
|
2652
|
+
const getNFCAdapter = /* @__PURE__ */ temporarilyNotSupport('getNFCAdapter');
|
|
2653
|
+
const getHCEState = /* @__PURE__ */ temporarilyNotSupport('getHCEState');
|
|
2654
|
+
|
|
2655
|
+
const makePhoneCall = (options) => {
|
|
2656
|
+
// options must be an Object
|
|
2657
|
+
const isObject = shouldBeObject(options);
|
|
2658
|
+
if (!isObject.flag) {
|
|
2659
|
+
const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` };
|
|
2660
|
+
console.error(res.errMsg);
|
|
2661
|
+
return Promise.reject(res);
|
|
2629
2662
|
}
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2663
|
+
const { phoneNumber, success, fail, complete } = options;
|
|
2664
|
+
const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete });
|
|
2665
|
+
if (typeof phoneNumber !== 'string') {
|
|
2666
|
+
return handle.fail({
|
|
2667
|
+
errMsg: getParameterError({
|
|
2668
|
+
para: 'phoneNumber',
|
|
2669
|
+
correct: 'String',
|
|
2670
|
+
wrong: phoneNumber
|
|
2671
|
+
})
|
|
2672
|
+
});
|
|
2633
2673
|
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2674
|
+
window.location.href = `tel:${phoneNumber}`;
|
|
2675
|
+
return handle.success();
|
|
2676
|
+
};
|
|
2677
|
+
|
|
2678
|
+
// 扫码
|
|
2679
|
+
const scanCode = /* @__PURE__ */ processOpenApi({
|
|
2680
|
+
name: 'scanQRCode',
|
|
2681
|
+
defaultOptions: { needResult: 1 },
|
|
2682
|
+
formatResult: res => ({
|
|
2683
|
+
errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
|
|
2684
|
+
result: res.resultStr
|
|
2685
|
+
})
|
|
2686
|
+
});
|
|
2687
|
+
|
|
2688
|
+
// 屏幕
|
|
2689
|
+
const setVisualEffectOnCapture = /* @__PURE__ */ temporarilyNotSupport('setVisualEffectOnCapture');
|
|
2690
|
+
const setScreenBrightness = /* @__PURE__ */ temporarilyNotSupport('setScreenBrightness');
|
|
2691
|
+
const setKeepScreenOn = /* @__PURE__ */ temporarilyNotSupport('setKeepScreenOn');
|
|
2692
|
+
const onUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('onUserCaptureScreen');
|
|
2693
|
+
const offUserCaptureScreen = /* @__PURE__ */ temporarilyNotSupport('offUserCaptureScreen');
|
|
2694
|
+
const getScreenBrightness = /* @__PURE__ */ temporarilyNotSupport('getScreenBrightness');
|
|
2695
|
+
const onScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('onScreenRecordingStateChanged');
|
|
2696
|
+
const offScreenRecordingStateChanged = /* @__PURE__ */ temporarilyNotSupport('offScreenRecordingStateChanged');
|
|
2697
|
+
const getScreenRecordingState = /* @__PURE__ */ temporarilyNotSupport('getScreenRecordingState');
|
|
2698
|
+
|
|
2699
|
+
// 短信
|
|
2700
|
+
const sendSms = /* @__PURE__ */ temporarilyNotSupport('sendSms');
|
|
2701
|
+
|
|
2702
|
+
const vibrator = function vibrator(mm) {
|
|
2703
|
+
try {
|
|
2704
|
+
return window.navigator.vibrate(mm);
|
|
2637
2705
|
}
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
return this;
|
|
2706
|
+
catch (e) {
|
|
2707
|
+
console.warn('当前浏览器不支持 vibrate。');
|
|
2641
2708
|
}
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2709
|
+
};
|
|
2710
|
+
/**
|
|
2711
|
+
* 使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
|
|
2712
|
+
*/
|
|
2713
|
+
const vibrateShort = ({ success, fail, complete } = {}) => {
|
|
2714
|
+
const handle = new MethodHandler({ name: 'vibrateShort', success, fail, complete });
|
|
2715
|
+
if (vibrator(15)) {
|
|
2716
|
+
return handle.success();
|
|
2645
2717
|
}
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
return this;
|
|
2718
|
+
else {
|
|
2719
|
+
return handle.fail({ errMsg: 'style is not support' });
|
|
2649
2720
|
}
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2721
|
+
};
|
|
2722
|
+
/**
|
|
2723
|
+
* 使手机发生较长时间的振动(400 ms)
|
|
2724
|
+
*/
|
|
2725
|
+
const vibrateLong = ({ success, fail, complete } = {}) => {
|
|
2726
|
+
const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete });
|
|
2727
|
+
if (vibrator(400)) {
|
|
2728
|
+
return handle.success();
|
|
2653
2729
|
}
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
this.transform.push(`translate(${x}, ${y})`);
|
|
2657
|
-
return this;
|
|
2730
|
+
else {
|
|
2731
|
+
return handle.fail({ errMsg: 'style is not support' });
|
|
2658
2732
|
}
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2733
|
+
};
|
|
2734
|
+
|
|
2735
|
+
// Wi-Fi
|
|
2736
|
+
const stopWifi = /* @__PURE__ */ temporarilyNotSupport('stopWifi');
|
|
2737
|
+
const startWifi = /* @__PURE__ */ temporarilyNotSupport('startWifi');
|
|
2738
|
+
const setWifiList = /* @__PURE__ */ temporarilyNotSupport('setWifiList');
|
|
2739
|
+
const onWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('onWifiConnectedWithPartialInfo');
|
|
2740
|
+
const onWifiConnected = /* @__PURE__ */ temporarilyNotSupport('onWifiConnected');
|
|
2741
|
+
const onGetWifiList = /* @__PURE__ */ temporarilyNotSupport('onGetWifiList');
|
|
2742
|
+
const offWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('offWifiConnectedWithPartialInfo');
|
|
2743
|
+
const offWifiConnected = /* @__PURE__ */ temporarilyNotSupport('offWifiConnected');
|
|
2744
|
+
const offGetWifiList = /* @__PURE__ */ temporarilyNotSupport('offGetWifiList');
|
|
2745
|
+
const getWifiList = /* @__PURE__ */ temporarilyNotSupport('getWifiList');
|
|
2746
|
+
const getConnectedWifi = /* @__PURE__ */ temporarilyNotSupport('getConnectedWifi');
|
|
2747
|
+
const connectWifi = /* @__PURE__ */ temporarilyNotSupport('connectWifi');
|
|
2748
|
+
|
|
2749
|
+
// 第三方平台
|
|
2750
|
+
const getExtConfigSync = /* @__PURE__ */ temporarilyNotSupport('getExtConfigSync');
|
|
2751
|
+
const getExtConfig = /* @__PURE__ */ temporarilyNotSupport('getExtConfig');
|
|
2752
|
+
|
|
2753
|
+
// 文件
|
|
2754
|
+
const saveFileToDisk = /* @__PURE__ */ temporarilyNotSupport('saveFileToDisk');
|
|
2755
|
+
const saveFile = /* @__PURE__ */ temporarilyNotSupport('saveFile');
|
|
2756
|
+
const removeSavedFile = /* @__PURE__ */ temporarilyNotSupport('removeSavedFile');
|
|
2757
|
+
const openDocument = /* @__PURE__ */ temporarilyNotSupport('openDocument');
|
|
2758
|
+
const getSavedFileList = /* @__PURE__ */ temporarilyNotSupport('getSavedFileList');
|
|
2759
|
+
const getSavedFileInfo = /* @__PURE__ */ temporarilyNotSupport('getSavedFileInfo');
|
|
2760
|
+
const getFileSystemManager = /* @__PURE__ */ temporarilyNotSupport('getFileSystemManager');
|
|
2761
|
+
const getFileInfo = /* @__PURE__ */ temporarilyNotSupport('getFileInfo');
|
|
2762
|
+
|
|
2763
|
+
const getApp = function () {
|
|
2764
|
+
return Taro.getCurrentInstance().app;
|
|
2765
|
+
};
|
|
2766
|
+
// 自定义组件
|
|
2767
|
+
const getCurrentInstance = Taro.getCurrentInstance;
|
|
2768
|
+
|
|
2769
|
+
const isGeolocationSupported = () => !!navigator.geolocation;
|
|
2770
|
+
|
|
2771
|
+
const getLocationByW3CApi = (options) => {
|
|
2772
|
+
var _a;
|
|
2773
|
+
// 断言 options 必须是 Object
|
|
2774
|
+
const isObject = shouldBeObject(options);
|
|
2775
|
+
if (!isObject.flag) {
|
|
2776
|
+
const res = { errMsg: `getLocation:fail ${isObject.msg}` };
|
|
2777
|
+
console.error(res.errMsg);
|
|
2778
|
+
return Promise.reject(res);
|
|
2663
2779
|
}
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2780
|
+
// 解构回调函数
|
|
2781
|
+
const { success, fail, complete } = options;
|
|
2782
|
+
const handle = new MethodHandler({ name: 'getLocation', success, fail, complete });
|
|
2783
|
+
// const defaultMaximumAge = 5 * 1000
|
|
2784
|
+
const positionOptions = {
|
|
2785
|
+
enableHighAccuracy: options.isHighAccuracy || (options.altitude != null),
|
|
2786
|
+
// maximumAge: defaultMaximumAge, // 允许取多久以内的缓存位置
|
|
2787
|
+
timeout: options.highAccuracyExpireTime // 高精度定位超时时间
|
|
2788
|
+
};
|
|
2789
|
+
// Web端API实现暂时仅支持GPS坐标系
|
|
2790
|
+
if (((_a = options.type) === null || _a === void 0 ? void 0 : _a.toUpperCase()) !== 'WGS84') {
|
|
2791
|
+
return handle.fail({
|
|
2792
|
+
errMsg: 'This coordinate system type is not temporarily supported'
|
|
2793
|
+
});
|
|
2668
2794
|
}
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2795
|
+
// 判断当前浏览器是否支持位置API
|
|
2796
|
+
if (!isGeolocationSupported()) {
|
|
2797
|
+
return handle.fail({
|
|
2798
|
+
errMsg: 'The current browser does not support this feature'
|
|
2799
|
+
});
|
|
2673
2800
|
}
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2801
|
+
// 开始获取位置
|
|
2802
|
+
return new Promise((resolve, reject) => {
|
|
2803
|
+
navigator.geolocation.getCurrentPosition((position) => {
|
|
2804
|
+
const result = {
|
|
2805
|
+
/** 位置的精确度 */
|
|
2806
|
+
accuracy: position.coords.accuracy,
|
|
2807
|
+
/** 高度,单位 m */
|
|
2808
|
+
altitude: position.coords.altitude,
|
|
2809
|
+
/** 水平精度,单位 m */
|
|
2810
|
+
horizontalAccuracy: position.coords.accuracy,
|
|
2811
|
+
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
2812
|
+
latitude: position.coords.latitude,
|
|
2813
|
+
/** 经度,范围为 -180~180,负数表示西经 */
|
|
2814
|
+
longitude: position.coords.longitude,
|
|
2815
|
+
/** 速度,单位 m/s */
|
|
2816
|
+
speed: position.coords.speed,
|
|
2817
|
+
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
2818
|
+
verticalAccuracy: position.coords.altitudeAccuracy || 0,
|
|
2819
|
+
/** 调用结果,自动补充 */
|
|
2820
|
+
errMsg: ''
|
|
2821
|
+
};
|
|
2822
|
+
handle.success(result, { resolve, reject });
|
|
2823
|
+
}, (error) => {
|
|
2824
|
+
handle.fail({ errMsg: error.message }, { resolve, reject });
|
|
2825
|
+
}, positionOptions);
|
|
2826
|
+
});
|
|
2827
|
+
};
|
|
2828
|
+
const getLocation = /* @__PURE__ */ processOpenApi({
|
|
2829
|
+
name: 'getLocation',
|
|
2830
|
+
standardMethod: getLocationByW3CApi
|
|
2831
|
+
});
|
|
2832
|
+
|
|
2833
|
+
function styleInject(css, ref) {
|
|
2834
|
+
if ( ref === void 0 ) ref = {};
|
|
2835
|
+
var insertAt = ref.insertAt;
|
|
2836
|
+
|
|
2837
|
+
if (!css || typeof document === 'undefined') { return; }
|
|
2838
|
+
|
|
2839
|
+
var head = document.head || document.getElementsByTagName('head')[0];
|
|
2840
|
+
var style = document.createElement('style');
|
|
2841
|
+
style.type = 'text/css';
|
|
2842
|
+
|
|
2843
|
+
if (insertAt === 'top') {
|
|
2844
|
+
if (head.firstChild) {
|
|
2845
|
+
head.insertBefore(style, head.firstChild);
|
|
2846
|
+
} else {
|
|
2847
|
+
head.appendChild(style);
|
|
2678
2848
|
}
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2849
|
+
} else {
|
|
2850
|
+
head.appendChild(style);
|
|
2851
|
+
}
|
|
2852
|
+
|
|
2853
|
+
if (style.styleSheet) {
|
|
2854
|
+
style.styleSheet.cssText = css;
|
|
2855
|
+
} else {
|
|
2856
|
+
style.appendChild(document.createTextNode(css));
|
|
2857
|
+
}
|
|
2858
|
+
}
|
|
2859
|
+
|
|
2860
|
+
var css_248z = ".taro_choose_location{background-color:#fff;display:flex;flex-direction:column;height:100%;position:fixed;top:100%;transition:top .3s ease;width:100%;z-index:1}.taro_choose_location_bar{background-color:#ededed;color:#090909;display:flex;flex:0 95px;height:95px}.taro_choose_location_back{flex:0 45px;height:30px;margin-top:30px;position:relative;width:33px}.taro_choose_location_back:before{border:15px solid transparent;border-right-color:#090909;content:\"\";display:block;height:0;left:0;position:absolute;top:0;width:0}.taro_choose_location_back:after{border:15px solid transparent;border-right-color:#ededed;content:\"\";display:block;height:0;left:3px;position:absolute;top:0;width:0}.taro_choose_location_title{flex:1;line-height:95px;padding-left:30px}.taro_choose_location_submit{background-color:#08bf62;border:none;color:#fff;font-size:28px;height:60px;line-height:60px;margin:18px 30px 0 0;padding:0;width:110px}.taro_choose_location_frame{flex:1}";
|
|
2861
|
+
var stylesheet=".taro_choose_location{background-color:#fff;display:flex;flex-direction:column;height:100%;position:fixed;top:100%;transition:top .3s ease;width:100%;z-index:1}.taro_choose_location_bar{background-color:#ededed;color:#090909;display:flex;flex:0 95px;height:95px}.taro_choose_location_back{flex:0 45px;height:30px;margin-top:30px;position:relative;width:33px}.taro_choose_location_back:before{border:15px solid transparent;border-right-color:#090909;content:\"\";display:block;height:0;left:0;position:absolute;top:0;width:0}.taro_choose_location_back:after{border:15px solid transparent;border-right-color:#ededed;content:\"\";display:block;height:0;left:3px;position:absolute;top:0;width:0}.taro_choose_location_title{flex:1;line-height:95px;padding-left:30px}.taro_choose_location_submit{background-color:#08bf62;border:none;color:#fff;font-size:28px;height:60px;line-height:60px;margin:18px 30px 0 0;padding:0;width:110px}.taro_choose_location_frame{flex:1}";
|
|
2862
|
+
styleInject(css_248z,{"insertAt":"top"});
|
|
2863
|
+
|
|
2864
|
+
let container = null;
|
|
2865
|
+
function createLocationChooser(handler, key = LOCATION_APIKEY, mapOpt = {}) {
|
|
2866
|
+
var _a, _b, _c;
|
|
2867
|
+
const { latitude, longitude } = mapOpt, opts = __rest(mapOpt, ["latitude", "longitude"]);
|
|
2868
|
+
const query = Object.assign({ key, type: 1, coord: ((_a = mapOpt.coord) !== null && _a !== void 0 ? _a : [latitude, longitude].every(e => Number(e) >= 0)) ? `${latitude},${longitude}` : undefined, referer: 'myapp' }, opts);
|
|
2869
|
+
if (!container) {
|
|
2870
|
+
const html = `
|
|
2871
|
+
<div class='taro_choose_location'>
|
|
2872
|
+
<div class='taro_choose_location_bar'>
|
|
2873
|
+
<div class='taro_choose_location_back'></div>
|
|
2874
|
+
<p class='taro_choose_location_title'>位置</p>
|
|
2875
|
+
<button class='taro_choose_location_submit'>完成</button>
|
|
2876
|
+
</div>
|
|
2877
|
+
<iframe class='taro_choose_location_frame' frameborder='0' src="https://apis.map.qq.com/tools/locpicker?${stringify(query, { arrayFormat: 'comma', skipNull: true })}" />
|
|
2878
|
+
</div>
|
|
2879
|
+
`;
|
|
2880
|
+
container = document.createElement('div');
|
|
2881
|
+
container.innerHTML = html;
|
|
2682
2882
|
}
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2883
|
+
const main = container.querySelector('.taro_choose_location');
|
|
2884
|
+
function show() {
|
|
2885
|
+
setTimeout(() => {
|
|
2886
|
+
main.style.top = '0';
|
|
2887
|
+
});
|
|
2686
2888
|
}
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
this.rules.push(`width: ${value}`);
|
|
2690
|
-
return this;
|
|
2889
|
+
function hide() {
|
|
2890
|
+
main.style.top = '100%';
|
|
2691
2891
|
}
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
return this;
|
|
2892
|
+
function back() {
|
|
2893
|
+
hide();
|
|
2894
|
+
handler({ errMsg: 'cancel' });
|
|
2696
2895
|
}
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
|
|
2700
|
-
return this;
|
|
2896
|
+
function submit() {
|
|
2897
|
+
hide();
|
|
2898
|
+
handler();
|
|
2701
2899
|
}
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2900
|
+
function remove() {
|
|
2901
|
+
container === null || container === void 0 ? void 0 : container.remove();
|
|
2902
|
+
container = null;
|
|
2903
|
+
window.removeEventListener('popstate', back);
|
|
2706
2904
|
}
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2905
|
+
(_b = container.querySelector('.taro_choose_location_back')) === null || _b === void 0 ? void 0 : _b.addEventListener('click', back);
|
|
2906
|
+
(_c = container.querySelector('.taro_choose_location_submit')) === null || _c === void 0 ? void 0 : _c.addEventListener('click', submit);
|
|
2907
|
+
window.addEventListener('popstate', back);
|
|
2908
|
+
return {
|
|
2909
|
+
show,
|
|
2910
|
+
remove,
|
|
2911
|
+
container,
|
|
2912
|
+
};
|
|
2913
|
+
}
|
|
2914
|
+
/**
|
|
2915
|
+
* 打开地图选择位置。
|
|
2916
|
+
*/
|
|
2917
|
+
const chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
|
|
2918
|
+
const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete });
|
|
2919
|
+
return new Promise((resolve, reject) => {
|
|
2920
|
+
const chooseLocation = {};
|
|
2921
|
+
if (typeof LOCATION_APIKEY === 'undefined') {
|
|
2922
|
+
console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY');
|
|
2923
|
+
return handle.fail({
|
|
2924
|
+
errMsg: 'LOCATION_APIKEY needed'
|
|
2925
|
+
}, { resolve, reject });
|
|
2926
|
+
}
|
|
2927
|
+
const key = LOCATION_APIKEY;
|
|
2928
|
+
const onMessage = event => {
|
|
2929
|
+
// 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
|
|
2930
|
+
const loc = event.data;
|
|
2931
|
+
// 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
|
|
2932
|
+
if (!loc || loc.module !== 'locationPicker')
|
|
2933
|
+
return;
|
|
2934
|
+
chooseLocation.name = loc.poiname;
|
|
2935
|
+
chooseLocation.address = loc.poiaddress;
|
|
2936
|
+
chooseLocation.latitude = loc.latlng.lat;
|
|
2937
|
+
chooseLocation.longitude = loc.latlng.lng;
|
|
2938
|
+
};
|
|
2939
|
+
const chooser = createLocationChooser(res => {
|
|
2940
|
+
window.removeEventListener('message', onMessage, false);
|
|
2941
|
+
setTimeout(() => {
|
|
2942
|
+
chooser.remove();
|
|
2943
|
+
}, 300);
|
|
2944
|
+
if (res) {
|
|
2945
|
+
return handle.fail(res, { resolve, reject });
|
|
2946
|
+
}
|
|
2947
|
+
else {
|
|
2948
|
+
if (chooseLocation.latitude && chooseLocation.longitude) {
|
|
2949
|
+
return handle.success(chooseLocation, { resolve, reject });
|
|
2950
|
+
}
|
|
2951
|
+
else {
|
|
2952
|
+
return handle.fail({}, { resolve, reject });
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
}, key, mapOpts);
|
|
2956
|
+
document.body.appendChild(chooser.container);
|
|
2957
|
+
window.addEventListener('message', onMessage, false);
|
|
2958
|
+
chooser.show();
|
|
2959
|
+
});
|
|
2960
|
+
};
|
|
2961
|
+
|
|
2962
|
+
const _successCbManager = new CallbackManager();
|
|
2963
|
+
const _errorCbManager = new CallbackManager();
|
|
2964
|
+
let _watchID = -1;
|
|
2965
|
+
function onLocationChange(callback) {
|
|
2966
|
+
_successCbManager.add(callback);
|
|
2967
|
+
}
|
|
2968
|
+
function offLocationChange(callback) {
|
|
2969
|
+
if (callback && typeof callback === 'function') {
|
|
2970
|
+
_successCbManager.remove(callback);
|
|
2711
2971
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2972
|
+
else if (callback === undefined) {
|
|
2973
|
+
_successCbManager.clear();
|
|
2974
|
+
}
|
|
2975
|
+
else {
|
|
2976
|
+
console.warn('offLocationChange failed');
|
|
2716
2977
|
}
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
`${this.transform.join(' ')}!important`,
|
|
2725
|
-
`${TRANSFORM}-origin: ${transformOrigin}`,
|
|
2726
|
-
`transition: all ${duration}ms ${timingFunction} ${delay}ms`
|
|
2727
|
-
]
|
|
2728
|
-
.filter(item => item !== '' && item !== `${TRANSFORM}:`)
|
|
2729
|
-
.join(';'));
|
|
2730
|
-
// 清空 rules 和 transform
|
|
2731
|
-
this.rules = [];
|
|
2732
|
-
this.transform = [`${TRANSFORM}:`];
|
|
2733
|
-
return this;
|
|
2978
|
+
}
|
|
2979
|
+
function onLocationChangeError(callback) {
|
|
2980
|
+
_errorCbManager.add(callback);
|
|
2981
|
+
}
|
|
2982
|
+
function offLocationChangeError(callback) {
|
|
2983
|
+
if (callback && typeof callback === 'function') {
|
|
2984
|
+
_errorCbManager.remove(callback);
|
|
2734
2985
|
}
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
const animIndex = `taro-h5-poly-fill/${this.id}/create-animation__${this.animationMapCount++}`;
|
|
2738
|
-
// 记录动画分几个 step
|
|
2739
|
-
this.animationMap[animIndex] = this.steps.length;
|
|
2740
|
-
// 吐出 step
|
|
2741
|
-
this.steps.forEach((step, index) => {
|
|
2742
|
-
const selector = index === 0
|
|
2743
|
-
? `[animation="${animIndex}"], [data-animation="${animIndex}"]`
|
|
2744
|
-
: `[animation="${animIndex}--${index}"], [data-animation="${animIndex}--${index}"]`;
|
|
2745
|
-
styleSheet.add(`${selector} { ${step} }`);
|
|
2746
|
-
});
|
|
2747
|
-
// 清空 steps
|
|
2748
|
-
this.steps = [];
|
|
2749
|
-
return animIndex;
|
|
2986
|
+
else if (callback === undefined) {
|
|
2987
|
+
_errorCbManager.clear();
|
|
2750
2988
|
}
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
return this.createAnimationData();
|
|
2989
|
+
else {
|
|
2990
|
+
console.warn('offLocationChangeError failed');
|
|
2754
2991
|
}
|
|
2755
2992
|
}
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
const
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
const
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
return handle.success({ status: 'loaded' });
|
|
2993
|
+
/**
|
|
2994
|
+
* 开始监听位置信息
|
|
2995
|
+
* @param opts
|
|
2996
|
+
* @returns
|
|
2997
|
+
*/
|
|
2998
|
+
function startLocationUpdateByW3CApi(opts) {
|
|
2999
|
+
// 断言 options 必须是 Object
|
|
3000
|
+
const isObject = shouldBeObject(opts);
|
|
3001
|
+
if (!isObject.flag) {
|
|
3002
|
+
const res = { errMsg: `startLocationUpdate:fail ${isObject.msg}` };
|
|
3003
|
+
console.error(res.errMsg);
|
|
3004
|
+
return Promise.reject(res);
|
|
3005
|
+
}
|
|
3006
|
+
const { success, fail, complete } = opts;
|
|
3007
|
+
const handle = new MethodHandler({ name: 'startLocationUpdate', success, fail, complete });
|
|
3008
|
+
// 判断当前浏览器是否支持位置API
|
|
3009
|
+
if (!isGeolocationSupported()) {
|
|
3010
|
+
return handle.fail({
|
|
3011
|
+
errMsg: 'The current browser does not support this feature'
|
|
3012
|
+
});
|
|
3013
|
+
}
|
|
3014
|
+
try {
|
|
3015
|
+
if (_watchID > -1) {
|
|
3016
|
+
console.error('startLocationUpdate:fail');
|
|
3017
|
+
return handle.fail();
|
|
2782
3018
|
}
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
3019
|
+
else {
|
|
3020
|
+
_watchID = navigator.geolocation.watchPosition(({ coords }) => {
|
|
3021
|
+
const { latitude, longitude, altitude, accuracy, speed } = coords;
|
|
3022
|
+
_successCbManager.trigger({
|
|
3023
|
+
accuracy,
|
|
3024
|
+
altitude,
|
|
3025
|
+
horizontalAccuracy: 0,
|
|
3026
|
+
verticalAccuracy: 0,
|
|
3027
|
+
latitude,
|
|
3028
|
+
longitude,
|
|
3029
|
+
speed,
|
|
3030
|
+
});
|
|
3031
|
+
}, err => {
|
|
3032
|
+
_errorCbManager.trigger({
|
|
3033
|
+
errMsg: 'Watch Position error',
|
|
3034
|
+
err
|
|
3035
|
+
});
|
|
3036
|
+
}, {
|
|
3037
|
+
timeout: 10,
|
|
3038
|
+
maximumAge: 0,
|
|
3039
|
+
enableHighAccuracy: true,
|
|
2787
3040
|
});
|
|
3041
|
+
return handle.success();
|
|
2788
3042
|
}
|
|
2789
3043
|
}
|
|
2790
|
-
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
3044
|
+
catch (error) {
|
|
3045
|
+
return handle.fail();
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
/**
|
|
3049
|
+
* 停止监听位置信息
|
|
3050
|
+
* @param opts
|
|
3051
|
+
* @returns
|
|
3052
|
+
*/
|
|
3053
|
+
function stopLocationUpdateByW3CApi(opts) {
|
|
3054
|
+
const isObject = shouldBeObject(opts);
|
|
3055
|
+
if (!isObject.flag) {
|
|
3056
|
+
const res = { errMsg: `stopLocationUpdate:fail ${isObject.msg}` };
|
|
3057
|
+
console.error(res.errMsg);
|
|
3058
|
+
return Promise.reject(res);
|
|
3059
|
+
}
|
|
3060
|
+
const { success, fail, complete } = opts;
|
|
3061
|
+
const handle = new MethodHandler({ name: 'stopLocationUpdate', success, fail, complete });
|
|
3062
|
+
// 判断当前浏览器是否支持位置API
|
|
3063
|
+
if (!isGeolocationSupported()) {
|
|
3064
|
+
return handle.fail({
|
|
3065
|
+
errMsg: 'The current browser does not support this feature'
|
|
3066
|
+
});
|
|
3067
|
+
}
|
|
3068
|
+
try {
|
|
3069
|
+
navigator.geolocation.clearWatch(_watchID);
|
|
3070
|
+
_watchID = -1;
|
|
3071
|
+
return handle.success();
|
|
3072
|
+
}
|
|
3073
|
+
catch (error) {
|
|
3074
|
+
return handle.fail();
|
|
2817
3075
|
}
|
|
3076
|
+
}
|
|
3077
|
+
const stopLocationUpdate = /* @__PURE__ */ processOpenApi({
|
|
3078
|
+
name: 'stopLocationUpdate',
|
|
3079
|
+
standardMethod: stopLocationUpdateByW3CApi
|
|
3080
|
+
});
|
|
3081
|
+
const startLocationUpdate = /* @__PURE__ */ processOpenApi({
|
|
3082
|
+
name: 'startLocationUpdate',
|
|
3083
|
+
standardMethod: startLocationUpdateByW3CApi
|
|
2818
3084
|
});
|
|
2819
3085
|
|
|
2820
|
-
const
|
|
2821
|
-
|
|
3086
|
+
const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground');
|
|
3087
|
+
const openLocation = /* @__PURE__ */ processOpenApi({
|
|
3088
|
+
name: 'openLocation',
|
|
3089
|
+
defaultOptions: { scale: 18 }
|
|
3090
|
+
});
|
|
3091
|
+
const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi');
|
|
3092
|
+
const getFuzzyLocation = /* @__PURE__ */ temporarilyNotSupport('getFuzzyLocation');
|
|
3093
|
+
|
|
3094
|
+
class InnerAudioContext {
|
|
2822
3095
|
constructor() {
|
|
2823
|
-
this.
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
3096
|
+
this.__startTime = 0;
|
|
3097
|
+
this.__isFirstPlay = true;
|
|
3098
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
3099
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
3100
|
+
this.stop = () => {
|
|
3101
|
+
this.pause();
|
|
3102
|
+
this.seek(0);
|
|
3103
|
+
this.stopStack.trigger();
|
|
2829
3104
|
};
|
|
2830
|
-
this.
|
|
2831
|
-
|
|
2832
|
-
position
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
3105
|
+
this.seek = (position) => {
|
|
3106
|
+
if (this.Instance) {
|
|
3107
|
+
this.Instance.currentTime = position;
|
|
3108
|
+
}
|
|
3109
|
+
};
|
|
3110
|
+
/**
|
|
3111
|
+
* @TODO destroy得并不干净
|
|
3112
|
+
*/
|
|
3113
|
+
this.destroy = () => {
|
|
3114
|
+
this.stop();
|
|
3115
|
+
if (this.Instance) {
|
|
3116
|
+
this.Instance = undefined;
|
|
3117
|
+
}
|
|
3118
|
+
};
|
|
3119
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
3120
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
3121
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
3122
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
3123
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
3124
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
3125
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
3126
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
3127
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
3128
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
3129
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
3130
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
3131
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
3132
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
3133
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
3134
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
3135
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
3136
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
3137
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
3138
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
3139
|
+
this.Instance = new Audio();
|
|
3140
|
+
this.errorStack = new CallbackManager();
|
|
3141
|
+
this.stopStack = new CallbackManager();
|
|
3142
|
+
this.Instance.onerror = this.errorStack.trigger;
|
|
3143
|
+
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
3144
|
+
this.onPlay(() => {
|
|
3145
|
+
if (this.__isFirstPlay) {
|
|
3146
|
+
this.__isFirstPlay = false;
|
|
3147
|
+
this.seek(this.startTime);
|
|
3148
|
+
}
|
|
3149
|
+
});
|
|
3150
|
+
}
|
|
3151
|
+
set autoplay(e) { this.setProperty('autoplay', e); }
|
|
3152
|
+
get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
|
|
3153
|
+
get buffered() {
|
|
3154
|
+
const { currentTime = 0, buffered: timeRange } = this.Instance || {};
|
|
3155
|
+
if (timeRange) {
|
|
3156
|
+
for (let i = 0; i < timeRange.length; i++) {
|
|
3157
|
+
if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
|
|
3158
|
+
return timeRange.end(i);
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
return 0;
|
|
3163
|
+
}
|
|
3164
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
3165
|
+
set currentTime(e) { this.seek(e); }
|
|
3166
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
3167
|
+
set loop(e) { this.setProperty('loop', e); }
|
|
3168
|
+
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
3169
|
+
get paused() { var _a, _b; return (_b = (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) !== null && _b !== void 0 ? _b : true; }
|
|
3170
|
+
set src(e) { this.setProperty('src', e); }
|
|
3171
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
3172
|
+
set volume(e) { this.setProperty('volume', e); }
|
|
3173
|
+
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
3174
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
3175
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
3176
|
+
set obeyMuteSwitch(_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')(); }
|
|
3177
|
+
get obeyMuteSwitch() { return true; }
|
|
3178
|
+
set startTime(e) { this.__startTime = e; }
|
|
3179
|
+
get startTime() { return this.__startTime || 0; }
|
|
3180
|
+
set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
|
|
3181
|
+
get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
|
|
3182
|
+
setProperty(key, value) {
|
|
3183
|
+
if (this.Instance) {
|
|
3184
|
+
this.Instance[key] = value;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
|
|
3189
|
+
// 音频
|
|
3190
|
+
const stopVoice = /* @__PURE__ */ temporarilyNotSupport('stopVoice');
|
|
3191
|
+
const setInnerAudioOption = /* @__PURE__ */ temporarilyNotSupport('setInnerAudioOption');
|
|
3192
|
+
const playVoice = /* @__PURE__ */ temporarilyNotSupport('playVoice');
|
|
3193
|
+
const pauseVoice = /* @__PURE__ */ temporarilyNotSupport('pauseVoice');
|
|
3194
|
+
const getAvailableAudioSources = /* @__PURE__ */ temporarilyNotSupport('getAvailableAudioSources');
|
|
3195
|
+
const createWebAudioContext = /* @__PURE__ */ temporarilyNotSupport('createWebAudioContext');
|
|
3196
|
+
const createMediaAudioPlayer = /* @__PURE__ */ temporarilyNotSupport('createMediaAudioPlayer');
|
|
3197
|
+
/**
|
|
3198
|
+
* 创建内部 audio 上下文 InnerAudioContext 对象。
|
|
3199
|
+
*/
|
|
3200
|
+
const createInnerAudioContext = () => new InnerAudioContext();
|
|
3201
|
+
const createAudioContext = /* @__PURE__ */ temporarilyNotSupport('createAudioContext');
|
|
3202
|
+
|
|
3203
|
+
class BackgroundAudioManager {
|
|
3204
|
+
constructor() {
|
|
3205
|
+
this.__startTime = 0;
|
|
3206
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
3207
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
3208
|
+
this.seek = (position) => {
|
|
3209
|
+
if (this.Instance) {
|
|
3210
|
+
this.Instance.currentTime = position;
|
|
2869
3211
|
}
|
|
2870
3212
|
};
|
|
2871
|
-
this.
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
}
|
|
2909
|
-
// cancel
|
|
2910
|
-
this.cancel = document.createElement('div');
|
|
2911
|
-
this.cancel.setAttribute('style', inlineStyle(cancelStyle));
|
|
2912
|
-
this.cancel.textContent = '取消';
|
|
2913
|
-
// result
|
|
2914
|
-
this.cells.forEach(item => this.menu.appendChild(item));
|
|
2915
|
-
this.actionSheet.appendChild(this.menu);
|
|
2916
|
-
this.actionSheet.appendChild(this.cancel);
|
|
2917
|
-
this.el.appendChild(this.mask);
|
|
2918
|
-
this.el.appendChild(this.actionSheet);
|
|
2919
|
-
// callbacks
|
|
2920
|
-
const cb = () => {
|
|
2921
|
-
this.hide();
|
|
2922
|
-
resolve('cancel');
|
|
2923
|
-
};
|
|
2924
|
-
this.mask.onclick = cb;
|
|
2925
|
-
this.cancel.onclick = cb;
|
|
2926
|
-
// show immediately
|
|
2927
|
-
document.body.appendChild(this.el);
|
|
2928
|
-
setTimeout(() => {
|
|
2929
|
-
this.el.style.opacity = '1';
|
|
2930
|
-
setTransform(this.actionSheet, 'translate(0, 0)');
|
|
2931
|
-
}, 0);
|
|
3213
|
+
this.stop = () => {
|
|
3214
|
+
this.pause();
|
|
3215
|
+
this.seek(0);
|
|
3216
|
+
this.stopStack.trigger();
|
|
3217
|
+
};
|
|
3218
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
3219
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
3220
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
3221
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
3222
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
3223
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
3224
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
3225
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
3226
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
3227
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
3228
|
+
this.onPrev = permanentlyNotSupport('BackgroundAudioManager.onPrev');
|
|
3229
|
+
this.onNext = permanentlyNotSupport('BackgroundAudioManager.onNext');
|
|
3230
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
3231
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
3232
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
3233
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
3234
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
3235
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
3236
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
3237
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
3238
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
3239
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
3240
|
+
this.offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev');
|
|
3241
|
+
this.offNext = permanentlyNotSupport('BackgroundAudioManager.offNext');
|
|
3242
|
+
this.Instance = new Audio();
|
|
3243
|
+
this.errorStack = new CallbackManager();
|
|
3244
|
+
this.stopStack = new CallbackManager();
|
|
3245
|
+
this.Instance.onerror = this.errorStack.trigger;
|
|
3246
|
+
this.Instance.autoplay = true;
|
|
3247
|
+
this.onPlay(() => {
|
|
3248
|
+
if (this.currentTime !== this.startTime) {
|
|
3249
|
+
this.seek(this.startTime);
|
|
3250
|
+
}
|
|
2932
3251
|
});
|
|
2933
3252
|
}
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
}
|
|
2962
|
-
cell.textContent = item;
|
|
2963
|
-
cell.onclick = e => {
|
|
2964
|
-
this.hide();
|
|
2965
|
-
const target = e.currentTarget;
|
|
2966
|
-
const index = Number(target === null || target === void 0 ? void 0 : target.dataset.tapIndex) || 0;
|
|
2967
|
-
resolve(index);
|
|
2968
|
-
};
|
|
2969
|
-
});
|
|
2970
|
-
const cellsLen = this.cells.length;
|
|
2971
|
-
const itemListLen = config.itemList.length;
|
|
2972
|
-
if (cellsLen > itemListLen) {
|
|
2973
|
-
for (let i = itemListLen; i < cellsLen; i++) {
|
|
2974
|
-
this.menu.removeChild(this.cells[i]);
|
|
3253
|
+
set src(e) { this.setProperty('src', e); }
|
|
3254
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
3255
|
+
set startTime(e) { this.__startTime = e; }
|
|
3256
|
+
get startTime() { return this.__startTime || 0; }
|
|
3257
|
+
set title(e) { this.dataset('title', e); }
|
|
3258
|
+
get title() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.title) || ''; }
|
|
3259
|
+
set epname(e) { this.dataset('epname', e); }
|
|
3260
|
+
get epname() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.epname) || ''; }
|
|
3261
|
+
set singer(e) { this.dataset('singer', e); }
|
|
3262
|
+
get singer() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.singer) || ''; }
|
|
3263
|
+
set coverImgUrl(e) { this.dataset('coverImgUrl', e); }
|
|
3264
|
+
get coverImgUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.coverImgUrl) || ''; }
|
|
3265
|
+
set webUrl(e) { this.dataset('webUrl', e); }
|
|
3266
|
+
get webUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.webUrl) || ''; }
|
|
3267
|
+
set protocol(e) { this.dataset('protocol', e); }
|
|
3268
|
+
get protocol() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.protocol) || ''; }
|
|
3269
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
3270
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
3271
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
3272
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
3273
|
+
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || false; }
|
|
3274
|
+
get buffered() {
|
|
3275
|
+
const { currentTime = 0, buffered: timeRange } = this.Instance || {};
|
|
3276
|
+
if (timeRange) {
|
|
3277
|
+
for (let i = 0; i < timeRange.length; i++) {
|
|
3278
|
+
if (timeRange.start(i) <= currentTime && timeRange.end(i) >= currentTime) {
|
|
3279
|
+
return timeRange.end(i);
|
|
2975
3280
|
}
|
|
2976
|
-
this.cells.splice(itemListLen);
|
|
2977
3281
|
}
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
}
|
|
3282
|
+
}
|
|
3283
|
+
return 0;
|
|
3284
|
+
}
|
|
3285
|
+
set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
|
|
3286
|
+
get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
|
|
3287
|
+
setProperty(key, value) {
|
|
3288
|
+
if (this.Instance) {
|
|
3289
|
+
this.Instance[key] = value;
|
|
3290
|
+
}
|
|
3291
|
+
}
|
|
3292
|
+
dataset(key, value) {
|
|
3293
|
+
if (this.Instance) {
|
|
3294
|
+
this.Instance.dataset[key] = value;
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
|
|
3299
|
+
// 背景音频
|
|
3300
|
+
const stopBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('stopBackgroundAudio');
|
|
3301
|
+
const seekBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('seekBackgroundAudio');
|
|
3302
|
+
const playBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('playBackgroundAudio');
|
|
3303
|
+
const pauseBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('pauseBackgroundAudio');
|
|
3304
|
+
const onBackgroundAudioStop = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioStop');
|
|
3305
|
+
const onBackgroundAudioPlay = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPlay');
|
|
3306
|
+
const onBackgroundAudioPause = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPause');
|
|
3307
|
+
const getBackgroundAudioPlayerState = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioPlayerState');
|
|
3308
|
+
/**
|
|
3309
|
+
* 获取全局唯一的背景音频管理器
|
|
3310
|
+
*/
|
|
3311
|
+
const getBackgroundAudioManager = () => new BackgroundAudioManager();
|
|
3312
|
+
|
|
3313
|
+
// 相机
|
|
3314
|
+
const createCameraContext = /* @__PURE__ */ temporarilyNotSupport('createCameraContext');
|
|
3315
|
+
|
|
3316
|
+
const saveImageToPhotosAlbum = (options) => {
|
|
3317
|
+
const methodName = 'saveImageToPhotosAlbum';
|
|
3318
|
+
// options must be an Object
|
|
3319
|
+
const isObject = shouldBeObject(options);
|
|
3320
|
+
if (!isObject.flag) {
|
|
3321
|
+
const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
|
|
3322
|
+
console.error(res.errMsg);
|
|
3323
|
+
return Promise.reject(res);
|
|
2992
3324
|
}
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
}
|
|
3325
|
+
const { filePath, success, fail, complete, } = options;
|
|
3326
|
+
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
3327
|
+
if (typeof filePath !== 'string') {
|
|
3328
|
+
return handle.fail({
|
|
3329
|
+
errMsg: getParameterError({
|
|
3330
|
+
para: 'filePath',
|
|
3331
|
+
correct: 'String',
|
|
3332
|
+
wrong: filePath
|
|
3333
|
+
})
|
|
3334
|
+
});
|
|
3003
3335
|
}
|
|
3004
|
-
|
|
3336
|
+
createDownload(filePath);
|
|
3337
|
+
return handle.success();
|
|
3338
|
+
};
|
|
3005
3339
|
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3340
|
+
/**
|
|
3341
|
+
* 获取图片信息。网络图片需先配置download域名才能生效。
|
|
3342
|
+
*/
|
|
3343
|
+
const getImageInfo = (options) => {
|
|
3344
|
+
// options must be an Object
|
|
3345
|
+
const isObject = shouldBeObject(options);
|
|
3346
|
+
if (!isObject.flag) {
|
|
3347
|
+
const res = { errMsg: `getImageInfo:fail ${isObject.msg}` };
|
|
3348
|
+
console.error(res.errMsg);
|
|
3349
|
+
return Promise.reject(res);
|
|
3350
|
+
}
|
|
3351
|
+
const getBase64Image = (image) => {
|
|
3352
|
+
try {
|
|
3353
|
+
const canvas = document.createElement('canvas');
|
|
3354
|
+
canvas.width = image.width;
|
|
3355
|
+
canvas.height = image.height;
|
|
3356
|
+
const ctx = canvas.getContext('2d');
|
|
3357
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(image, 0, 0, image.width, image.height);
|
|
3358
|
+
return canvas.toDataURL('image/png');
|
|
3359
|
+
}
|
|
3360
|
+
catch (e) {
|
|
3361
|
+
console.error('getImageInfo:get base64 fail', e);
|
|
3362
|
+
}
|
|
3363
|
+
};
|
|
3364
|
+
const { src, success, fail, complete } = options;
|
|
3365
|
+
const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete });
|
|
3366
|
+
return new Promise((resolve, reject) => {
|
|
3367
|
+
const image = new Image();
|
|
3368
|
+
image.crossOrigin = '';
|
|
3369
|
+
image.onload = () => {
|
|
3370
|
+
handle.success({
|
|
3371
|
+
width: image.naturalWidth,
|
|
3372
|
+
height: image.naturalHeight,
|
|
3373
|
+
path: getBase64Image(image) || src
|
|
3374
|
+
}, { resolve, reject });
|
|
3016
3375
|
};
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
top: '0',
|
|
3022
|
-
right: '0',
|
|
3023
|
-
left: '0',
|
|
3024
|
-
bottom: '0',
|
|
3025
|
-
background: 'rgba(0,0,0,0.6)'
|
|
3026
|
-
},
|
|
3027
|
-
modalStyle: {
|
|
3028
|
-
'z-index': '4999',
|
|
3029
|
-
position: 'fixed',
|
|
3030
|
-
top: '50%',
|
|
3031
|
-
left: '50%',
|
|
3032
|
-
transform: 'translate(-50%, -50%)',
|
|
3033
|
-
width: '80%',
|
|
3034
|
-
'max-width': '300px',
|
|
3035
|
-
'border-radius': '3px',
|
|
3036
|
-
'text-align': 'center',
|
|
3037
|
-
'line-height': '1.6',
|
|
3038
|
-
overflow: 'hidden',
|
|
3039
|
-
background: '#FFFFFF'
|
|
3040
|
-
},
|
|
3041
|
-
titleStyle: {
|
|
3042
|
-
padding: '20px 24px 9px',
|
|
3043
|
-
'font-size': '18px'
|
|
3044
|
-
},
|
|
3045
|
-
textStyle: {
|
|
3046
|
-
padding: '0 24px 12px',
|
|
3047
|
-
'min-height': '40px',
|
|
3048
|
-
'font-size': '15px',
|
|
3049
|
-
'line-height': '1.3',
|
|
3050
|
-
color: '#808080'
|
|
3051
|
-
},
|
|
3052
|
-
footStyle: {
|
|
3053
|
-
position: 'relative',
|
|
3054
|
-
'line-height': '48px',
|
|
3055
|
-
'font-size': '18px',
|
|
3056
|
-
display: 'flex'
|
|
3057
|
-
},
|
|
3058
|
-
btnStyle: {
|
|
3059
|
-
position: 'relative',
|
|
3060
|
-
'-webkit-box-flex': '1',
|
|
3061
|
-
'-webkit-flex': '1',
|
|
3062
|
-
flex: '1'
|
|
3063
|
-
}
|
|
3376
|
+
image.onerror = (e) => {
|
|
3377
|
+
handle.fail({
|
|
3378
|
+
errMsg: e.message
|
|
3379
|
+
}, { resolve, reject });
|
|
3064
3380
|
};
|
|
3065
|
-
|
|
3066
|
-
|
|
3381
|
+
image.src = src;
|
|
3382
|
+
});
|
|
3383
|
+
};
|
|
3384
|
+
|
|
3385
|
+
/**
|
|
3386
|
+
* previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
|
|
3387
|
+
*/
|
|
3388
|
+
/**
|
|
3389
|
+
* 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
|
|
3390
|
+
*/
|
|
3391
|
+
const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3392
|
+
// TODO 改为通过 window.__taroAppConfig 获取配置的 Swiper 插件创建节点
|
|
3393
|
+
defineCustomElementTaroSwiperCore();
|
|
3394
|
+
defineCustomElementTaroSwiperItemCore();
|
|
3395
|
+
function loadImage(url, loadFail) {
|
|
3067
3396
|
return new Promise((resolve) => {
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
const
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3086
|
-
mask.ontouchmove = eventHandler;
|
|
3087
|
-
// modal
|
|
3088
|
-
const modal = document.createElement('div');
|
|
3089
|
-
modal.className = 'taro-modal__content';
|
|
3090
|
-
modal.setAttribute('style', inlineStyle(modalStyle));
|
|
3091
|
-
modal.ontouchmove = eventHandler;
|
|
3092
|
-
// title
|
|
3093
|
-
const titleCSS = config.title ? titleStyle : Object.assign(Object.assign({}, titleStyle), { display: 'none' });
|
|
3094
|
-
this.title = document.createElement('div');
|
|
3095
|
-
this.title.className = 'taro-modal__title';
|
|
3096
|
-
this.title.setAttribute('style', inlineStyle(titleCSS));
|
|
3097
|
-
this.title.textContent = config.title;
|
|
3098
|
-
// text
|
|
3099
|
-
const textCSS = config.title ? textStyle : Object.assign(Object.assign({}, textStyle), { padding: '40px 20px 26px', color: '#353535' });
|
|
3100
|
-
this.text = document.createElement('div');
|
|
3101
|
-
this.text.className = 'taro-modal__text';
|
|
3102
|
-
this.text.setAttribute('style', inlineStyle(textCSS));
|
|
3103
|
-
this.text.textContent = config.content;
|
|
3104
|
-
// foot
|
|
3105
|
-
const foot = document.createElement('div');
|
|
3106
|
-
foot.className = 'taro-modal__foot';
|
|
3107
|
-
foot.setAttribute('style', inlineStyle(footStyle));
|
|
3108
|
-
// cancel button
|
|
3109
|
-
const cancelCSS = Object.assign(Object.assign({}, btnStyle), { color: config.cancelColor, display: config.showCancel ? 'block' : 'none' });
|
|
3110
|
-
this.cancel = document.createElement('div');
|
|
3111
|
-
this.cancel.className = 'taro-model__btn taro-model__cancel';
|
|
3112
|
-
this.cancel.setAttribute('style', inlineStyle(cancelCSS));
|
|
3113
|
-
this.cancel.textContent = config.cancelText;
|
|
3114
|
-
this.cancel.onclick = () => {
|
|
3115
|
-
this.hide();
|
|
3116
|
-
resolve('cancel');
|
|
3117
|
-
};
|
|
3118
|
-
// confirm button
|
|
3119
|
-
this.confirm = document.createElement('div');
|
|
3120
|
-
this.confirm.className = 'taro-model__btn taro-model__confirm';
|
|
3121
|
-
this.confirm.setAttribute('style', inlineStyle(btnStyle));
|
|
3122
|
-
this.confirm.style.color = config.confirmColor;
|
|
3123
|
-
this.confirm.textContent = config.confirmText;
|
|
3124
|
-
this.confirm.onclick = () => {
|
|
3125
|
-
this.hide();
|
|
3126
|
-
resolve('confirm');
|
|
3127
|
-
};
|
|
3128
|
-
// result
|
|
3129
|
-
foot.appendChild(this.cancel);
|
|
3130
|
-
foot.appendChild(this.confirm);
|
|
3131
|
-
modal.appendChild(this.title);
|
|
3132
|
-
modal.appendChild(this.text);
|
|
3133
|
-
modal.appendChild(foot);
|
|
3134
|
-
this.el.appendChild(mask);
|
|
3135
|
-
this.el.appendChild(modal);
|
|
3136
|
-
// show immediately
|
|
3137
|
-
document.body.appendChild(this.el);
|
|
3138
|
-
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
3139
|
-
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
3140
|
-
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
3397
|
+
const item = document.createElement('taro-swiper-item-core');
|
|
3398
|
+
item.style.cssText = 'display:flex;align-items:start;justify-content:center;overflow-y:scroll;';
|
|
3399
|
+
const image = new Image();
|
|
3400
|
+
image.style.maxWidth = '100%';
|
|
3401
|
+
image.src = url;
|
|
3402
|
+
const div = document.createElement('div');
|
|
3403
|
+
div.classList.add('swiper-zoom-container');
|
|
3404
|
+
div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
|
|
3405
|
+
div.appendChild(image);
|
|
3406
|
+
item.appendChild(div);
|
|
3407
|
+
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
3408
|
+
resolve(item);
|
|
3409
|
+
if (isFunction(loadFail)) {
|
|
3410
|
+
image.addEventListener('error', (err) => {
|
|
3411
|
+
loadFail({ errMsg: err.message });
|
|
3412
|
+
});
|
|
3413
|
+
}
|
|
3141
3414
|
});
|
|
3142
3415
|
}
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
// confirmColor
|
|
3176
|
-
this.confirm.style.color = config.confirmColor || '';
|
|
3177
|
-
// cbs
|
|
3178
|
-
this.cancel.onclick = () => {
|
|
3179
|
-
this.hide();
|
|
3180
|
-
resolve('cancel');
|
|
3181
|
-
};
|
|
3182
|
-
this.confirm.onclick = () => {
|
|
3183
|
-
this.hide();
|
|
3184
|
-
resolve('confirm');
|
|
3185
|
-
};
|
|
3186
|
-
// show
|
|
3187
|
-
this.el.style.display = 'block';
|
|
3188
|
-
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
3189
|
-
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
3190
|
-
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
3416
|
+
// options must be an Object
|
|
3417
|
+
const isObject = shouldBeObject(options);
|
|
3418
|
+
if (!isObject.flag) {
|
|
3419
|
+
const res = { errMsg: `previewImage:fail ${isObject.msg}` };
|
|
3420
|
+
console.error(res.errMsg);
|
|
3421
|
+
return Promise.reject(res);
|
|
3422
|
+
}
|
|
3423
|
+
const { urls = [], current = '', success, fail, complete } = options;
|
|
3424
|
+
const handle = new MethodHandler({ name: 'previewImage', success, fail, complete });
|
|
3425
|
+
const container = document.createElement('div');
|
|
3426
|
+
const removeHandler = () => {
|
|
3427
|
+
eventCenter$1.off('__taroRouterChange', removeHandler);
|
|
3428
|
+
container.remove();
|
|
3429
|
+
};
|
|
3430
|
+
// 路由改变后应该关闭预览框
|
|
3431
|
+
eventCenter$1.on('__taroRouterChange', removeHandler);
|
|
3432
|
+
container.classList.add('preview-image');
|
|
3433
|
+
container.style.cssText =
|
|
3434
|
+
'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;';
|
|
3435
|
+
container.addEventListener('click', removeHandler);
|
|
3436
|
+
const swiper = document.createElement('taro-swiper-core');
|
|
3437
|
+
// @ts-ignore
|
|
3438
|
+
swiper.full = true;
|
|
3439
|
+
// @ts-ignore
|
|
3440
|
+
swiper.zoom = true;
|
|
3441
|
+
let children = [];
|
|
3442
|
+
try {
|
|
3443
|
+
children = yield Promise.all(urls.map((e) => loadImage(e, fail)));
|
|
3444
|
+
}
|
|
3445
|
+
catch (error) {
|
|
3446
|
+
return handle.fail({
|
|
3447
|
+
errMsg: error,
|
|
3191
3448
|
});
|
|
3192
3449
|
}
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
if (this.hideDisplayTimer)
|
|
3197
|
-
clearTimeout(this.hideDisplayTimer);
|
|
3198
|
-
this.currentPath = null;
|
|
3199
|
-
this.hideOpacityTimer = setTimeout(() => {
|
|
3200
|
-
this.el.style.opacity = '0';
|
|
3201
|
-
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 200);
|
|
3202
|
-
}, 0);
|
|
3450
|
+
for (let i = 0; i < children.length; i++) {
|
|
3451
|
+
const child = children[i];
|
|
3452
|
+
swiper.appendChild(child);
|
|
3203
3453
|
}
|
|
3204
|
-
|
|
3454
|
+
const currentIndex = typeof current === 'number' ? current : urls.indexOf(current);
|
|
3455
|
+
swiper.current = currentIndex;
|
|
3456
|
+
container.appendChild(swiper);
|
|
3457
|
+
document.body.appendChild(container);
|
|
3458
|
+
return handle.success();
|
|
3459
|
+
});
|
|
3205
3460
|
|
|
3206
|
-
|
|
3461
|
+
/**
|
|
3462
|
+
* H5 下的 styleSheet 操作
|
|
3463
|
+
* @author leeenx
|
|
3464
|
+
*/
|
|
3465
|
+
class StyleSheet {
|
|
3207
3466
|
constructor() {
|
|
3208
|
-
this
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3467
|
+
this.$style = null;
|
|
3468
|
+
this.sheet = null;
|
|
3469
|
+
this.appendStyleSheet = () => {
|
|
3470
|
+
if (this.$style) {
|
|
3471
|
+
const head = document.getElementsByTagName('head')[0];
|
|
3472
|
+
this.$style.setAttribute('type', 'text/css');
|
|
3473
|
+
this.$style.setAttribute('data-type', 'Taro');
|
|
3474
|
+
head.appendChild(this.$style);
|
|
3475
|
+
this.sheet = this.$style.sheet;
|
|
3476
|
+
}
|
|
3477
|
+
if (this.sheet && !('insertRule' in this.sheet)) {
|
|
3478
|
+
console.warn('当前浏览器不支持 stylesheet.insertRule 接口');
|
|
3479
|
+
}
|
|
3214
3480
|
};
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
left: '0',
|
|
3222
|
-
bottom: '0'
|
|
3223
|
-
},
|
|
3224
|
-
toastStyle: {
|
|
3225
|
-
'z-index': '5000',
|
|
3226
|
-
'box-sizing': 'border-box',
|
|
3227
|
-
display: 'flex',
|
|
3228
|
-
'flex-direction': 'column',
|
|
3229
|
-
'justify-content': 'center',
|
|
3230
|
-
'-webkit-justify-content': 'center',
|
|
3231
|
-
position: 'fixed',
|
|
3232
|
-
top: '50%',
|
|
3233
|
-
left: '50%',
|
|
3234
|
-
'min-width': '120px',
|
|
3235
|
-
'max-width': '200px',
|
|
3236
|
-
'min-height': '120px',
|
|
3237
|
-
padding: '15px',
|
|
3238
|
-
transform: 'translate(-50%, -50%)',
|
|
3239
|
-
'border-radius': '5px',
|
|
3240
|
-
'text-align': 'center',
|
|
3241
|
-
'line-height': '1.6',
|
|
3242
|
-
color: '#FFFFFF',
|
|
3243
|
-
background: 'rgba(17, 17, 17, 0.7)'
|
|
3244
|
-
},
|
|
3245
|
-
successStyle: {
|
|
3246
|
-
margin: '6px auto',
|
|
3247
|
-
width: '38px',
|
|
3248
|
-
height: '38px',
|
|
3249
|
-
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTQ4OTYzMjA0IiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjQzNDgiIHdpZHRoPSIyMDAiIGhlaWdodD0iMjAwIj48cGF0aCBkPSJNMjE5Ljk1MiA1MTIuNTc2bDIxMC40MzIgMjEwLjQzMi00NS4yNDggNDUuMjU2LTIxMC40MzItMjEwLjQzMnoiIHAtaWQ9IjQzNDkiIGZpbGw9IiNmZmZmZmYiPjwvcGF0aD48cGF0aCBkPSJNNzk5LjY3MiAyNjIuMjY0bDQ1LjI1NiA0NS4yNTYtNDYwLjQ2NCA0NjAuNDY0LTQ1LjI1Ni00NS4yNTZ6IiBwLWlkPSI0MzUwIiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
|
|
3250
|
-
'background-size': '100%'
|
|
3251
|
-
},
|
|
3252
|
-
errrorStyle: {
|
|
3253
|
-
margin: '6px auto',
|
|
3254
|
-
width: '38px',
|
|
3255
|
-
height: '38px',
|
|
3256
|
-
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB0PSIxNjM5NTUxMDU1MTgzIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjE0MDc2IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTUxMiA2NEMyNjQuNTggNjQgNjQgMjY0LjU4IDY0IDUxMnMyMDAuNTggNDQ4IDQ0OCA0NDggNDQ4LTIwMC41OCA0NDgtNDQ4Uzc1OS40MiA2NCA1MTIgNjR6IG0wIDc1MmEzNiAzNiAwIDEgMSAzNi0zNiAzNiAzNiAwIDAgMS0zNiAzNnogbTUxLjgzLTU1MS45NUw1NDggNjM2YTM2IDM2IDAgMCAxLTcyIDBsLTE1LjgzLTM3MS45NWMtMC4xLTEuMzMtMC4xNy0yLjY4LTAuMTctNC4wNWE1MiA1MiAwIDAgMSAxMDQgMGMwIDEuMzctMC4wNyAyLjcyLTAuMTcgNC4wNXoiIHAtaWQ9IjE0MDc3IiBmaWxsPSIjZmZmZmZmIj48L3BhdGg+PC9zdmc+) no-repeat',
|
|
3257
|
-
'background-size': '100%'
|
|
3258
|
-
},
|
|
3259
|
-
loadingStyle: {
|
|
3260
|
-
margin: '6px auto',
|
|
3261
|
-
width: '38px',
|
|
3262
|
-
height: '38px',
|
|
3263
|
-
'-webkit-animation': 'taroLoading 1s steps(12, end) infinite',
|
|
3264
|
-
animation: 'taroLoading 1s steps(12, end) infinite',
|
|
3265
|
-
background: 'transparent url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMjAiIGhlaWdodD0iMTIwIiB2aWV3Qm94PSIwIDAgMTAwIDEwMCI+PHBhdGggZmlsbD0ibm9uZSIgZD0iTTAgMGgxMDB2MTAwSDB6Ii8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTlFOUU5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDAgLTMwKSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iIzk4OTY5NyIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgzMCAxMDUuOTggNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjOUI5OTlBIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDYwIDc1Ljk4IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0EzQTFBMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSg5MCA2NSA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNBQkE5QUEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoMTIwIDU4LjY2IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0IyQjJCMiIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgxNTAgNTQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjQkFCOEI5IiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKDE4MCA1MCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDMkMwQzEiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTE1MCA0NS45OCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNDQkNCQ0IiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTEyMCA0MS4zNCA2NSkiLz48cmVjdCB3aWR0aD0iNyIgaGVpZ2h0PSIyMCIgeD0iNDYuNSIgeT0iNDAiIGZpbGw9IiNEMkQyRDIiIHJ4PSI1IiByeT0iNSIgdHJhbnNmb3JtPSJyb3RhdGUoLTkwIDM1IDY1KSIvPjxyZWN0IHdpZHRoPSI3IiBoZWlnaHQ9IjIwIiB4PSI0Ni41IiB5PSI0MCIgZmlsbD0iI0RBREFEQSIgcng9IjUiIHJ5PSI1IiB0cmFuc2Zvcm09InJvdGF0ZSgtNjAgMjQuMDIgNjUpIi8+PHJlY3Qgd2lkdGg9IjciIGhlaWdodD0iMjAiIHg9IjQ2LjUiIHk9IjQwIiBmaWxsPSIjRTJFMkUyIiByeD0iNSIgcnk9IjUiIHRyYW5zZm9ybT0icm90YXRlKC0zMCAtNS45OCA2NSkiLz48L3N2Zz4=) no-repeat',
|
|
3266
|
-
'background-size': '100%'
|
|
3267
|
-
},
|
|
3268
|
-
imageStyle: {
|
|
3269
|
-
margin: '6px auto',
|
|
3270
|
-
width: '40px',
|
|
3271
|
-
height: '40px',
|
|
3272
|
-
background: 'transparent no-repeat',
|
|
3273
|
-
'background-size': '100%'
|
|
3274
|
-
},
|
|
3275
|
-
textStyle: {
|
|
3276
|
-
margin: '0',
|
|
3277
|
-
'font-size': '16px'
|
|
3481
|
+
// 添加样式命令
|
|
3482
|
+
this.add = (cssText, index = 0) => {
|
|
3483
|
+
var _a;
|
|
3484
|
+
if (this.sheet === null) {
|
|
3485
|
+
// $style 未插入到 DOM
|
|
3486
|
+
this.appendStyleSheet();
|
|
3278
3487
|
}
|
|
3488
|
+
(_a = this.sheet) === null || _a === void 0 ? void 0 : _a.insertRule(cssText, index);
|
|
3279
3489
|
};
|
|
3490
|
+
this.$style = document.createElement('style');
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
const styleSheet = new StyleSheet();
|
|
3494
|
+
// 监听事件
|
|
3495
|
+
let TRANSITION_END = 'transitionend';
|
|
3496
|
+
let TRANSFORM = 'transform';
|
|
3497
|
+
const $detect = document.createElement('div');
|
|
3498
|
+
$detect.style.cssText = '-webkit-animation-name:webkit;-moz-animation-name:moz;-ms-animation-name:ms;animation-name:standard;';
|
|
3499
|
+
if ($detect.style['animation-name'] === 'standard') {
|
|
3500
|
+
// 支持标准写法
|
|
3501
|
+
TRANSITION_END = 'transitionend';
|
|
3502
|
+
TRANSFORM = 'transform';
|
|
3503
|
+
}
|
|
3504
|
+
else if ($detect.style['-webkit-animation-name'] === 'webkit') {
|
|
3505
|
+
// webkit 前缀
|
|
3506
|
+
TRANSITION_END = 'webkitTransitionEnd';
|
|
3507
|
+
TRANSFORM = '-webkit-transform';
|
|
3508
|
+
}
|
|
3509
|
+
else if ($detect.style['-moz-animation-name'] === 'moz') {
|
|
3510
|
+
// moz 前缀
|
|
3511
|
+
TRANSITION_END = 'mozTransitionEnd';
|
|
3512
|
+
TRANSFORM = '-moz-transform';
|
|
3513
|
+
}
|
|
3514
|
+
else if ($detect.style['-ms-animation-name'] === 'ms') {
|
|
3515
|
+
// ms 前缀
|
|
3516
|
+
TRANSITION_END = 'msTransitionEnd';
|
|
3517
|
+
TRANSFORM = '-ms-transform';
|
|
3518
|
+
}
|
|
3519
|
+
let animId = 0;
|
|
3520
|
+
class Animation {
|
|
3521
|
+
constructor({ duration = 400, delay = 0, timingFunction = 'linear', transformOrigin = '50% 50% 0', unit = 'px' } = {}) {
|
|
3522
|
+
// 属性组合
|
|
3523
|
+
this.rules = [];
|
|
3524
|
+
// transform 对象
|
|
3525
|
+
this.transform = [];
|
|
3526
|
+
// 组合动画
|
|
3527
|
+
this.steps = [];
|
|
3528
|
+
// 动画 map ----- 永久保留
|
|
3529
|
+
this.animationMap = {};
|
|
3530
|
+
// animationMap 的长度
|
|
3531
|
+
this.animationMapCount = 0;
|
|
3532
|
+
// 历史动画
|
|
3533
|
+
this.historyAnimations = [];
|
|
3534
|
+
// 历史规则
|
|
3535
|
+
this.historyRules = [];
|
|
3536
|
+
// 默认值
|
|
3537
|
+
this.setDefault(duration, delay, timingFunction, transformOrigin);
|
|
3538
|
+
this.unit = unit;
|
|
3539
|
+
// atom 环境下,animation 属性不会显示,所以要改成 data-animation
|
|
3540
|
+
let animAttr = 'animation';
|
|
3541
|
+
// 动画 id
|
|
3542
|
+
this.id = ++animId;
|
|
3543
|
+
// 监听事件
|
|
3544
|
+
document.body.addEventListener(TRANSITION_END, (e) => {
|
|
3545
|
+
const target = e.target;
|
|
3546
|
+
if (target.getAttribute(animAttr) === null) {
|
|
3547
|
+
animAttr = 'data-animation';
|
|
3548
|
+
}
|
|
3549
|
+
const animData = target.getAttribute(animAttr);
|
|
3550
|
+
// 没有动画存在
|
|
3551
|
+
if (animData === null)
|
|
3552
|
+
return;
|
|
3553
|
+
const [animName, animPath] = animData.split('__');
|
|
3554
|
+
if (animName === `taro-h5-poly-fill/${this.id}/create-animation`) {
|
|
3555
|
+
const [animIndex, __stepIndex = 0] = animPath.split('--');
|
|
3556
|
+
const stepIndex = Number(__stepIndex);
|
|
3557
|
+
// 动画总的关键帧
|
|
3558
|
+
const animStepsCount = this.animationMap[`${animName}__${animIndex}`];
|
|
3559
|
+
const animStepsMaxIndex = animStepsCount - 1;
|
|
3560
|
+
if (stepIndex < animStepsMaxIndex) {
|
|
3561
|
+
// 播放下一个关键帧(因为 nerv 和 react 有差异所以 animation & data-animation 都需要写)
|
|
3562
|
+
target.setAttribute(animAttr, `${animName}__${animIndex}--${stepIndex + 1}`);
|
|
3563
|
+
if (animAttr === 'data-animation') {
|
|
3564
|
+
// Nerv 环境,animation & data-animation 双重保险
|
|
3565
|
+
target.setAttribute('animation', `${animName}__${animIndex}--${stepIndex + 1}`);
|
|
3566
|
+
}
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
});
|
|
3570
|
+
}
|
|
3571
|
+
transformUnit(...args) {
|
|
3572
|
+
const ret = [];
|
|
3573
|
+
args.forEach(each => {
|
|
3574
|
+
ret.push(isNaN(each) ? each : `${each}${this.unit}`);
|
|
3575
|
+
});
|
|
3576
|
+
return ret;
|
|
3577
|
+
}
|
|
3578
|
+
// 设置默认值
|
|
3579
|
+
setDefault(duration, delay, timingFunction, transformOrigin) {
|
|
3580
|
+
this.DEFAULT = { duration, delay, timingFunction, transformOrigin };
|
|
3581
|
+
}
|
|
3582
|
+
matrix(a, b, c, d, tx, ty) {
|
|
3583
|
+
this.transform.push({ key: 'matrix', transform: `matrix(${a}, ${b}, ${c}, ${d}, ${tx}, ${ty})` });
|
|
3584
|
+
return this;
|
|
3280
3585
|
}
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
// wrapper
|
|
3288
|
-
this.el = document.createElement('div');
|
|
3289
|
-
this.el.className = 'taro__toast';
|
|
3290
|
-
this.el.style.opacity = '0';
|
|
3291
|
-
this.el.style.transition = 'opacity 0.1s linear';
|
|
3292
|
-
this.el.ontouchmove = (e) => {
|
|
3293
|
-
e.stopPropagation();
|
|
3294
|
-
e.preventDefault();
|
|
3295
|
-
};
|
|
3296
|
-
// mask
|
|
3297
|
-
this.mask = document.createElement('div');
|
|
3298
|
-
this.mask.setAttribute('style', inlineStyle(maskStyle));
|
|
3299
|
-
this.mask.style.display = config.mask ? 'block' : 'none';
|
|
3300
|
-
// icon
|
|
3301
|
-
this.icon = document.createElement('p');
|
|
3302
|
-
if (config.image) {
|
|
3303
|
-
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
3304
|
-
}
|
|
3305
|
-
else {
|
|
3306
|
-
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
3307
|
-
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
3308
|
-
}
|
|
3309
|
-
// toast
|
|
3310
|
-
this.toast = document.createElement('div');
|
|
3311
|
-
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
3312
|
-
'min-height': '0',
|
|
3313
|
-
padding: '10px 15px'
|
|
3314
|
-
} : {}))));
|
|
3315
|
-
// title
|
|
3316
|
-
this.title = document.createElement('p');
|
|
3317
|
-
this.title.setAttribute('style', inlineStyle(textStyle));
|
|
3318
|
-
this.title.textContent = config.title;
|
|
3319
|
-
// result
|
|
3320
|
-
this.toast.appendChild(this.icon);
|
|
3321
|
-
this.toast.appendChild(this.title);
|
|
3322
|
-
this.el.appendChild(this.mask);
|
|
3323
|
-
this.el.appendChild(this.toast);
|
|
3324
|
-
// show immediately
|
|
3325
|
-
document.body.appendChild(this.el);
|
|
3326
|
-
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
3327
|
-
this.type = config._type;
|
|
3328
|
-
// disappear after duration
|
|
3329
|
-
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
3330
|
-
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
3331
|
-
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
3332
|
-
return '';
|
|
3586
|
+
matrix3d(a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3, a4, b4, c4, d4) {
|
|
3587
|
+
this.transform.push({
|
|
3588
|
+
key: 'matrix3d',
|
|
3589
|
+
transform: `matrix3d(${a1}, ${b1}, ${c1}, ${d1}, ${a2}, ${b2}, ${c2}, ${d2}, ${a3}, ${b3}, ${c3}, ${d3}, ${a4}, ${b4}, ${c4}, ${d4})`,
|
|
3590
|
+
});
|
|
3591
|
+
return this;
|
|
3333
3592
|
}
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
if (
|
|
3340
|
-
|
|
3341
|
-
// title
|
|
3342
|
-
this.title.textContent = config.title || '';
|
|
3343
|
-
// mask
|
|
3344
|
-
this.mask.style.display = config.mask ? 'block' : 'none';
|
|
3345
|
-
// image
|
|
3346
|
-
const { toastStyle, successStyle, errrorStyle, loadingStyle, imageStyle } = this.style;
|
|
3347
|
-
if (config.image) {
|
|
3348
|
-
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, imageStyle), { 'background-image': `url(${config.image})` })));
|
|
3593
|
+
rotate(angle) {
|
|
3594
|
+
this.transform.push({ key: 'rotate', transform: `rotate(${angle}deg)` });
|
|
3595
|
+
return this;
|
|
3596
|
+
}
|
|
3597
|
+
rotate3d(x, y, z, angle) {
|
|
3598
|
+
if (typeof y !== 'number') {
|
|
3599
|
+
this.transform.push({ key: 'rotate3d', transform: `rotate3d(${x})` });
|
|
3349
3600
|
}
|
|
3350
3601
|
else {
|
|
3351
|
-
|
|
3352
|
-
const iconStyle = config.icon === 'loading' ? loadingStyle : config.icon === 'error' ? errrorStyle : successStyle;
|
|
3353
|
-
this.icon.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, iconStyle), (config.icon === 'none' ? { display: 'none' } : {}))));
|
|
3354
|
-
}
|
|
3602
|
+
this.transform.push({ key: 'rotate3d', transform: `rotate3d(${x}, ${y || 0}, ${z || 0}, ${angle || 0}deg)` });
|
|
3355
3603
|
}
|
|
3356
|
-
|
|
3357
|
-
this.toast.setAttribute('style', inlineStyle(Object.assign(Object.assign({}, toastStyle), (config.icon === 'none' ? {
|
|
3358
|
-
'min-height': '0',
|
|
3359
|
-
padding: '10px 15px'
|
|
3360
|
-
} : {}))));
|
|
3361
|
-
// show
|
|
3362
|
-
this.el.style.display = 'block';
|
|
3363
|
-
setTimeout(() => { this.el.style.opacity = '1'; }, 0);
|
|
3364
|
-
this.type = config._type;
|
|
3365
|
-
// disappear after duration
|
|
3366
|
-
config.duration >= 0 && this.hide(config.duration, this.type);
|
|
3367
|
-
// Current.page不存在时说明路由还未挂载,此时需根据url来分配将要渲染的页面path
|
|
3368
|
-
this.currentPath = (_b = (_a = Current$1.page) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : getCurrentPath();
|
|
3369
|
-
return '';
|
|
3604
|
+
return this;
|
|
3370
3605
|
}
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
if (this.hideOpacityTimer)
|
|
3375
|
-
clearTimeout(this.hideOpacityTimer);
|
|
3376
|
-
if (this.hideDisplayTimer)
|
|
3377
|
-
clearTimeout(this.hideDisplayTimer);
|
|
3378
|
-
this.currentPath = null;
|
|
3379
|
-
this.hideOpacityTimer = setTimeout(() => {
|
|
3380
|
-
this.el.style.opacity = '0';
|
|
3381
|
-
this.hideDisplayTimer = setTimeout(() => { this.el.style.display = 'none'; }, 100);
|
|
3382
|
-
}, duration);
|
|
3606
|
+
rotateX(angle) {
|
|
3607
|
+
this.transform.push({ key: 'rotateX', transform: `rotateX(${angle}deg)` });
|
|
3608
|
+
return this;
|
|
3383
3609
|
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
let status = 'default';
|
|
3388
|
-
// inject necessary style
|
|
3389
|
-
function init(doc) {
|
|
3390
|
-
if (status === 'ready')
|
|
3391
|
-
return;
|
|
3392
|
-
const taroStyle = doc.createElement('style');
|
|
3393
|
-
taroStyle.textContent = '@font-face{font-weight:normal;font-style:normal;font-family:"taro";src:url("data:application/x-font-ttf;charset=utf-8;base64, AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzJWs0t/AAABfAAAAFZjbWFwqVgGvgAAAeAAAAGGZ2x5Zph7qG0AAANwAAAAdGhlYWQRFoGhAAAA4AAAADZoaGVhCCsD7AAAALwAAAAkaG10eAg0AAAAAAHUAAAADGxvY2EADAA6AAADaAAAAAhtYXhwAQ4AJAAAARgAAAAgbmFtZYrphEEAAAPkAAACVXBvc3S3shtSAAAGPAAAADUAAQAAA+gAAABaA+gAAAAAA+gAAQAAAAAAAAAAAAAAAAAAAAMAAQAAAAEAAADih+FfDzz1AAsD6AAAAADXB57LAAAAANcHnssAAP/sA+gDOgAAAAgAAgAAAAAAAAABAAAAAwAYAAEAAAAAAAIAAAAKAAoAAAD/AAAAAAAAAAEAAAAKAB4ALAABREZMVAAIAAQAAAAAAAAAAQAAAAFsaWdhAAgAAAABAAAAAQAEAAQAAAABAAgAAQAGAAAAAQAAAAAAAQK8AZAABQAIAnoCvAAAAIwCegK8AAAB4AAxAQIAAAIABQMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUGZFZABAAHjqCAPoAAAAWgPoABQAAAABAAAAAAAAA+gAAABkAAAD6AAAAAAABQAAAAMAAAAsAAAABAAAAV4AAQAAAAAAWAADAAEAAAAsAAMACgAAAV4ABAAsAAAABgAEAAEAAgB46gj//wAAAHjqCP//AAAAAAABAAYABgAAAAEAAgAAAQYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAKAAAAAAAAAACAAAAeAAAAHgAAAABAADqCAAA6ggAAAACAAAAAAAAAAwAOgABAAD/7AAyABQAAgAANzMVFB4UKAAAAAABAAAAAAO7AzoAFwAAEy4BPwE+AR8BFjY3ATYWFycWFAcBBiInPQoGBwUHGgzLDCELAh0LHwsNCgr9uQoeCgGzCyEOCw0HCZMJAQoBvgkCCg0LHQv9sQsKAAAAAAAAEgDeAAEAAAAAAAAAHQAAAAEAAAAAAAEABAAdAAEAAAAAAAIABwAhAAEAAAAAAAMABAAoAAEAAAAAAAQABAAsAAEAAAAAAAUACwAwAAEAAAAAAAYABAA7AAEAAAAAAAoAKwA/AAEAAAAAAAsAEwBqAAMAAQQJAAAAOgB9AAMAAQQJAAEACAC3AAMAAQQJAAIADgC/AAMAAQQJAAMACADNAAMAAQQJAAQACADVAAMAAQQJAAUAFgDdAAMAAQQJAAYACADzAAMAAQQJAAoAVgD7AAMAAQQJAAsAJgFRCiAgQ3JlYXRlZCBieSBmb250LWNhcnJpZXIKICB3ZXVpUmVndWxhcndldWl3ZXVpVmVyc2lvbiAxLjB3ZXVpR2VuZXJhdGVkIGJ5IHN2ZzJ0dGYgZnJvbSBGb250ZWxsbyBwcm9qZWN0Lmh0dHA6Ly9mb250ZWxsby5jb20ACgAgACAAQwByAGUAYQB0AGUAZAAgAGIAeQAgAGYAbwBuAHQALQBjAGEAcgByAGkAZQByAAoAIAAgAHcAZQB1AGkAUgBlAGcAdQBsAGEAcgB3AGUAdQBpAHcAZQB1AGkAVgBlAHIAcwBpAG8AbgAgADEALgAwAHcAZQB1AGkARwBlAG4AZQByAGEAdABlAGQAIABiAHkAIABzAHYAZwAyAHQAdABmACAAZgByAG8AbQAgAEYAbwBuAHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAABeAd1bmlFQTA4AAAAAAA=") format("truetype");}@-webkit-keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}@keyframes taroLoading{0%{-webkit-transform:rotate3d(0, 0, 1, 0deg);}100%{-webkit-transform:rotate3d(0, 0, 1, 360deg);transform:rotate3d(0, 0, 1, 360deg);}}.taro-modal__foot:after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);} .taro-model__btn:active {background-color: #EEEEEE}.taro-model__btn:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;width: 1px;bottom: 0;border-left: 1px solid #D5D5D6;color: #D5D5D6;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleX(0.5);transform: scaleX(0.5);}.taro-actionsheet__cell:not(:first-child):after {content: "";position: absolute;left: 0;top: 0;right: 0;height: 1px;border-top: 1px solid #e5e5e5;color: #e5e5e5;-webkit-transform-origin: 0 0;transform-origin: 0 0;-webkit-transform: scaleY(0.5);transform: scaleY(0.5);}';
|
|
3394
|
-
doc.querySelector('head').appendChild(taroStyle);
|
|
3395
|
-
status = 'ready';
|
|
3396
|
-
}
|
|
3397
|
-
const toast = new Toast();
|
|
3398
|
-
const modal = new Modal();
|
|
3399
|
-
const actionSheet = new ActionSheet();
|
|
3400
|
-
const showToast = (options = { title: '' }) => {
|
|
3401
|
-
init(document);
|
|
3402
|
-
options = Object.assign({
|
|
3403
|
-
title: '',
|
|
3404
|
-
icon: 'success',
|
|
3405
|
-
image: '',
|
|
3406
|
-
duration: 1500,
|
|
3407
|
-
mask: false
|
|
3408
|
-
}, options);
|
|
3409
|
-
const { success, fail, complete } = options;
|
|
3410
|
-
const handle = new MethodHandler({ name: 'showToast', success, fail, complete });
|
|
3411
|
-
if (typeof options.title !== 'string') {
|
|
3412
|
-
return handle.fail({
|
|
3413
|
-
errMsg: getParameterError({
|
|
3414
|
-
para: 'title',
|
|
3415
|
-
correct: 'String',
|
|
3416
|
-
wrong: options.title
|
|
3417
|
-
})
|
|
3418
|
-
});
|
|
3610
|
+
rotateY(angle) {
|
|
3611
|
+
this.transform.push({ key: 'rotateY', transform: `rotateY(${angle}deg)` });
|
|
3612
|
+
return this;
|
|
3419
3613
|
}
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
para: 'duration',
|
|
3424
|
-
correct: 'Number',
|
|
3425
|
-
wrong: options.duration
|
|
3426
|
-
})
|
|
3427
|
-
});
|
|
3614
|
+
rotateZ(angle) {
|
|
3615
|
+
this.transform.push({ key: 'rotateZ', transform: `rotateZ(${angle}deg)` });
|
|
3616
|
+
return this;
|
|
3428
3617
|
}
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
if (!toast.el) {
|
|
3434
|
-
errMsg = toast.create(options, 'toast');
|
|
3618
|
+
scale(x, y) {
|
|
3619
|
+
const scaleY = (typeof y !== 'undefined' && y !== null) ? y : x;
|
|
3620
|
+
this.transform.push({ key: 'scale', transform: `scale(${x}, ${scaleY})` });
|
|
3621
|
+
return this;
|
|
3435
3622
|
}
|
|
3436
|
-
|
|
3437
|
-
|
|
3623
|
+
scale3d(x, y, z) {
|
|
3624
|
+
this.transform.push({ key: 'scale3d', transform: `scale3d(${x}, ${y}, ${z})` });
|
|
3625
|
+
return this;
|
|
3438
3626
|
}
|
|
3439
|
-
|
|
3440
|
-
};
|
|
3441
|
-
|
|
3442
|
-
const handle = new MethodHandler({ name: 'hideToast', success, fail, complete });
|
|
3443
|
-
if (!toast.el)
|
|
3444
|
-
return handle.success();
|
|
3445
|
-
toast.hide(0, noConflict ? 'toast' : '');
|
|
3446
|
-
return handle.success();
|
|
3447
|
-
};
|
|
3448
|
-
const showLoading = (options = { title: '' }) => {
|
|
3449
|
-
init(document);
|
|
3450
|
-
options = Object.assign({
|
|
3451
|
-
title: '',
|
|
3452
|
-
mask: false
|
|
3453
|
-
}, options);
|
|
3454
|
-
const { success, fail, complete } = options;
|
|
3455
|
-
const handle = new MethodHandler({ name: 'showLoading', success, fail, complete });
|
|
3456
|
-
const config = {
|
|
3457
|
-
icon: 'loading',
|
|
3458
|
-
image: '',
|
|
3459
|
-
duration: -1
|
|
3460
|
-
};
|
|
3461
|
-
options = Object.assign({}, options, config);
|
|
3462
|
-
if (typeof options.title !== 'string') {
|
|
3463
|
-
return handle.fail({
|
|
3464
|
-
errMsg: getParameterError({
|
|
3465
|
-
para: 'title',
|
|
3466
|
-
correct: 'String',
|
|
3467
|
-
wrong: options.title
|
|
3468
|
-
})
|
|
3469
|
-
});
|
|
3627
|
+
scaleX(scale) {
|
|
3628
|
+
this.transform.push({ key: 'scaleX', transform: `scaleX(${scale})` });
|
|
3629
|
+
return this;
|
|
3470
3630
|
}
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
errMsg = toast.create(options, 'loading');
|
|
3631
|
+
scaleY(scale) {
|
|
3632
|
+
this.transform.push({ key: 'scaleY', transform: `scaleY(${scale})` });
|
|
3633
|
+
return this;
|
|
3475
3634
|
}
|
|
3476
|
-
|
|
3477
|
-
|
|
3635
|
+
scaleZ(scale) {
|
|
3636
|
+
this.transform.push({ key: 'scaleZ', transform: `scaleZ(${scale})` });
|
|
3637
|
+
return this;
|
|
3478
3638
|
}
|
|
3479
|
-
|
|
3480
|
-
};
|
|
3481
|
-
|
|
3482
|
-
const handle = new MethodHandler({ name: 'hideLoading', success, fail, complete });
|
|
3483
|
-
if (!toast.el)
|
|
3484
|
-
return handle.success();
|
|
3485
|
-
toast.hide(0, noConflict ? 'loading' : '');
|
|
3486
|
-
return handle.success();
|
|
3487
|
-
};
|
|
3488
|
-
const showModal = (options = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3489
|
-
init(document);
|
|
3490
|
-
options = Object.assign({
|
|
3491
|
-
title: '',
|
|
3492
|
-
content: '',
|
|
3493
|
-
showCancel: true,
|
|
3494
|
-
cancelText: '取消',
|
|
3495
|
-
cancelColor: '#000000',
|
|
3496
|
-
confirmText: '确定',
|
|
3497
|
-
confirmColor: '#3CC51F'
|
|
3498
|
-
}, options);
|
|
3499
|
-
const { success, fail, complete } = options;
|
|
3500
|
-
const handle = new MethodHandler({ name: 'showModal', success, fail, complete });
|
|
3501
|
-
if (typeof options.title !== 'string') {
|
|
3502
|
-
return handle.fail({
|
|
3503
|
-
errMsg: getParameterError({
|
|
3504
|
-
para: 'title',
|
|
3505
|
-
correct: 'String',
|
|
3506
|
-
wrong: options.title
|
|
3507
|
-
})
|
|
3508
|
-
});
|
|
3639
|
+
skew(x, y) {
|
|
3640
|
+
this.transform.push({ key: 'skew', transform: `skew(${x}deg, ${y}deg)` });
|
|
3641
|
+
return this;
|
|
3509
3642
|
}
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3643
|
+
skewX(angle) {
|
|
3644
|
+
this.transform.push({ key: 'skewX', transform: `skewX(${angle}deg)` });
|
|
3645
|
+
return this;
|
|
3646
|
+
}
|
|
3647
|
+
skewY(angle) {
|
|
3648
|
+
this.transform.push({ key: 'skewY', transform: `skewY(${angle}deg)` });
|
|
3649
|
+
return this;
|
|
3650
|
+
}
|
|
3651
|
+
translate(x, y) {
|
|
3652
|
+
[x, y] = this.transformUnit(x, y);
|
|
3653
|
+
this.transform.push({ key: 'translate', transform: `translate(${x}, ${y})` });
|
|
3654
|
+
return this;
|
|
3518
3655
|
}
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
correct: 'String',
|
|
3524
|
-
wrong: options.cancelText
|
|
3525
|
-
})
|
|
3526
|
-
});
|
|
3656
|
+
translate3d(x, y, z) {
|
|
3657
|
+
[x, y, z] = this.transformUnit(x, y, z);
|
|
3658
|
+
this.transform.push({ key: 'translate3d', transform: `translate3d(${x}, ${y}, ${z})` });
|
|
3659
|
+
return this;
|
|
3527
3660
|
}
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3661
|
+
translateX(translate) {
|
|
3662
|
+
[translate] = this.transformUnit(translate);
|
|
3663
|
+
this.transform.push({ key: 'translateX', transform: `translateX(${translate})` });
|
|
3664
|
+
return this;
|
|
3532
3665
|
}
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
correct: 'String',
|
|
3538
|
-
wrong: options.confirmText
|
|
3539
|
-
})
|
|
3540
|
-
});
|
|
3666
|
+
translateY(translate) {
|
|
3667
|
+
[translate] = this.transformUnit(translate);
|
|
3668
|
+
this.transform.push({ key: 'translateY', transform: `translateY(${translate})` });
|
|
3669
|
+
return this;
|
|
3541
3670
|
}
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3671
|
+
translateZ(translate) {
|
|
3672
|
+
[translate] = this.transformUnit(translate);
|
|
3673
|
+
this.transform.push({ key: 'translateZ', transform: `translateZ(${translate})` });
|
|
3674
|
+
return this;
|
|
3546
3675
|
}
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
para: 'cancelColor',
|
|
3551
|
-
correct: 'String',
|
|
3552
|
-
wrong: options.cancelColor
|
|
3553
|
-
})
|
|
3554
|
-
});
|
|
3676
|
+
opacity(value) {
|
|
3677
|
+
this.rules.push({ key: 'opacity', rule: `opacity: ${value}` });
|
|
3678
|
+
return this;
|
|
3555
3679
|
}
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
para: 'confirmColor',
|
|
3560
|
-
correct: 'String',
|
|
3561
|
-
wrong: options.confirmColor
|
|
3562
|
-
})
|
|
3563
|
-
});
|
|
3680
|
+
backgroundColor(value) {
|
|
3681
|
+
this.rules.push({ key: 'backgroundColor', rule: `background-color: ${value}` });
|
|
3682
|
+
return this;
|
|
3564
3683
|
}
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3684
|
+
width(value) {
|
|
3685
|
+
[value] = this.transformUnit(value);
|
|
3686
|
+
this.rules.push({ key: 'width', rule: `width: ${value}` });
|
|
3687
|
+
return this;
|
|
3569
3688
|
}
|
|
3570
|
-
|
|
3571
|
-
|
|
3689
|
+
height(value) {
|
|
3690
|
+
[value] = this.transformUnit(value);
|
|
3691
|
+
this.rules.push({ key: 'height', rule: `height: ${value}` });
|
|
3692
|
+
return this;
|
|
3572
3693
|
}
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
function hideModal() {
|
|
3578
|
-
if (!modal.el)
|
|
3579
|
-
return;
|
|
3580
|
-
modal.hide();
|
|
3581
|
-
}
|
|
3582
|
-
const showActionSheet = (options = { itemList: [] }, methodName = 'showActionSheet') => __awaiter(void 0, void 0, void 0, function* () {
|
|
3583
|
-
init(document);
|
|
3584
|
-
options = Object.assign({
|
|
3585
|
-
itemColor: '#000000',
|
|
3586
|
-
itemList: []
|
|
3587
|
-
}, options);
|
|
3588
|
-
const { success, fail, complete } = options;
|
|
3589
|
-
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
3590
|
-
// list item String
|
|
3591
|
-
if (!Array.isArray(options.itemList)) {
|
|
3592
|
-
return handle.fail({
|
|
3593
|
-
errMsg: getParameterError({
|
|
3594
|
-
para: 'itemList',
|
|
3595
|
-
correct: 'Array',
|
|
3596
|
-
wrong: options.itemList
|
|
3597
|
-
})
|
|
3598
|
-
});
|
|
3694
|
+
top(value) {
|
|
3695
|
+
[value] = this.transformUnit(value);
|
|
3696
|
+
this.rules.push({ key: 'top', rule: `top: ${value}` });
|
|
3697
|
+
return this;
|
|
3599
3698
|
}
|
|
3600
|
-
|
|
3601
|
-
|
|
3699
|
+
right(value) {
|
|
3700
|
+
[value] = this.transformUnit(value);
|
|
3701
|
+
this.rules.push({ key: 'right', rule: `right: ${value}` });
|
|
3702
|
+
return this;
|
|
3602
3703
|
}
|
|
3603
|
-
|
|
3604
|
-
|
|
3704
|
+
bottom(value) {
|
|
3705
|
+
[value] = this.transformUnit(value);
|
|
3706
|
+
this.rules.push({ key: 'bottom', rule: `bottom: ${value}` });
|
|
3707
|
+
return this;
|
|
3605
3708
|
}
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
para: `itemList[${i}]`,
|
|
3611
|
-
correct: 'String',
|
|
3612
|
-
wrong: options.itemList[i]
|
|
3613
|
-
})
|
|
3614
|
-
});
|
|
3615
|
-
}
|
|
3709
|
+
left(value) {
|
|
3710
|
+
[value] = this.transformUnit(value);
|
|
3711
|
+
this.rules.push({ key: 'left', rule: `left: ${value}` });
|
|
3712
|
+
return this;
|
|
3616
3713
|
}
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3714
|
+
// 关键帧载入
|
|
3715
|
+
step(arg = {}) {
|
|
3716
|
+
const { DEFAULT } = this;
|
|
3717
|
+
const { duration = DEFAULT.duration, delay = DEFAULT.delay, timingFunction = DEFAULT.timingFunction, transformOrigin = DEFAULT.transformOrigin, } = arg;
|
|
3718
|
+
// 生成一条 transition 动画
|
|
3719
|
+
this.transform.map((t0) => {
|
|
3720
|
+
const index = this.historyAnimations.findIndex((t1) => t1.key === t0.key);
|
|
3721
|
+
if (index === -1) {
|
|
3722
|
+
this.historyAnimations.push(t0);
|
|
3723
|
+
}
|
|
3724
|
+
else {
|
|
3725
|
+
this.historyAnimations[index] = t0;
|
|
3726
|
+
}
|
|
3624
3727
|
});
|
|
3728
|
+
const transforms = this.historyAnimations.map((t) => t.transform);
|
|
3729
|
+
const transformSequence = transforms.length > 0 ? `${TRANSFORM}:${transforms.join(' ')}!important` : '';
|
|
3730
|
+
this.rules.map((r0) => {
|
|
3731
|
+
const index = this.historyRules.findIndex((r1) => r1.key === r0.key);
|
|
3732
|
+
if (index === -1) {
|
|
3733
|
+
this.historyRules.push(r0);
|
|
3734
|
+
}
|
|
3735
|
+
else {
|
|
3736
|
+
this.historyRules[index] = r0;
|
|
3737
|
+
}
|
|
3738
|
+
});
|
|
3739
|
+
const rules = this.historyRules.map((t) => t.rule);
|
|
3740
|
+
const ruleSequence = rules.length > 0 ? rules.map((rule) => `${rule}!important`).join(';') : '';
|
|
3741
|
+
this.steps.push([
|
|
3742
|
+
ruleSequence,
|
|
3743
|
+
transformSequence,
|
|
3744
|
+
`${TRANSFORM}-origin: ${transformOrigin}`,
|
|
3745
|
+
`transition: all ${duration}ms ${timingFunction} ${delay}ms`,
|
|
3746
|
+
]
|
|
3747
|
+
.filter((item) => item !== '')
|
|
3748
|
+
.join(';'));
|
|
3749
|
+
// 清空 rules 和 transform
|
|
3750
|
+
this.rules = [];
|
|
3751
|
+
this.transform = [];
|
|
3752
|
+
return this;
|
|
3625
3753
|
}
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3754
|
+
// 创建底层数据
|
|
3755
|
+
createAnimationData() {
|
|
3756
|
+
const animIndex = `taro-h5-poly-fill/${this.id}/create-animation__${this.animationMapCount++}`;
|
|
3757
|
+
// 记录动画分几个 step
|
|
3758
|
+
this.animationMap[animIndex] = this.steps.length;
|
|
3759
|
+
// 吐出 step
|
|
3760
|
+
this.steps.forEach((step, index) => {
|
|
3761
|
+
const selector = index === 0
|
|
3762
|
+
? `[animation="${animIndex}"], [data-animation="${animIndex}"]`
|
|
3763
|
+
: `[animation="${animIndex}--${index}"], [data-animation="${animIndex}--${index}"]`;
|
|
3764
|
+
styleSheet.add(`${selector} { ${step} }`);
|
|
3765
|
+
});
|
|
3766
|
+
// 清空 steps
|
|
3767
|
+
this.steps = [];
|
|
3768
|
+
return animIndex;
|
|
3629
3769
|
}
|
|
3630
|
-
|
|
3631
|
-
|
|
3770
|
+
// 动画数据产出
|
|
3771
|
+
export() {
|
|
3772
|
+
return this.createAnimationData();
|
|
3632
3773
|
}
|
|
3633
|
-
|
|
3634
|
-
|
|
3774
|
+
}
|
|
3775
|
+
// h5 的 createAnimation
|
|
3776
|
+
const createAnimation = (option) => {
|
|
3777
|
+
return new Animation(option);
|
|
3778
|
+
};
|
|
3779
|
+
|
|
3780
|
+
// 背景
|
|
3781
|
+
const setBackgroundTextStyle = /* @__PURE__ */ temporarilyNotSupport('setBackgroundTextStyle');
|
|
3782
|
+
const setBackgroundColor = /* @__PURE__ */ temporarilyNotSupport('setBackgroundColor');
|
|
3783
|
+
|
|
3784
|
+
// 自定义组件
|
|
3785
|
+
const nextTick = Taro.nextTick;
|
|
3786
|
+
|
|
3787
|
+
// 字体
|
|
3788
|
+
const loadFontFace = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
3789
|
+
options = Object.assign({ global: false }, options);
|
|
3790
|
+
const { success, fail, complete, family, source, desc = {} } = options;
|
|
3791
|
+
const handle = new MethodHandler({ name: 'loadFontFace', success, fail, complete });
|
|
3792
|
+
// @ts-ignore
|
|
3793
|
+
const fonts = document.fonts;
|
|
3794
|
+
if (fonts) {
|
|
3795
|
+
// @ts-ignore
|
|
3796
|
+
const fontFace = new FontFace(family, source, desc);
|
|
3797
|
+
try {
|
|
3798
|
+
yield fontFace.load();
|
|
3799
|
+
fonts.add(fontFace);
|
|
3800
|
+
return handle.success({ status: 'loaded' });
|
|
3801
|
+
}
|
|
3802
|
+
catch (error) {
|
|
3803
|
+
return handle.fail({
|
|
3804
|
+
status: 'error',
|
|
3805
|
+
errMsg: error.message || error,
|
|
3806
|
+
});
|
|
3807
|
+
}
|
|
3635
3808
|
}
|
|
3636
3809
|
else {
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3810
|
+
const style = document.createElement('style');
|
|
3811
|
+
let innerText = `font-family:"${family}";src:${source};font-style:${desc.style || 'normal'};font-weight:${desc.weight || 'normal'};font-variant:${desc.variant || 'normal'};`;
|
|
3812
|
+
if (desc.ascentOverride) {
|
|
3813
|
+
innerText += `ascent-override:${desc.ascentOverride};`;
|
|
3814
|
+
}
|
|
3815
|
+
if (desc.descentOverride) {
|
|
3816
|
+
innerText += `descent-override:${desc.descentOverride};`;
|
|
3817
|
+
}
|
|
3818
|
+
if (desc.featureSettings) {
|
|
3819
|
+
innerText += `font-feature-settings:${desc.featureSettings};`;
|
|
3820
|
+
}
|
|
3821
|
+
if (desc.lineGapOverride) {
|
|
3822
|
+
innerText += `line-gap-override:${desc.lineGapOverride};`;
|
|
3823
|
+
}
|
|
3824
|
+
if (desc.stretch) {
|
|
3825
|
+
innerText += `font-stretch:${desc.stretch};`;
|
|
3826
|
+
}
|
|
3827
|
+
if (desc.unicodeRange) {
|
|
3828
|
+
innerText += `unicode-range:${desc.unicodeRange};`;
|
|
3829
|
+
}
|
|
3830
|
+
if (desc.variationSettings) {
|
|
3831
|
+
innerText += `font-variation-settings:${desc.variationSettings};`;
|
|
3832
|
+
}
|
|
3833
|
+
style.innerText = `@font-face{${innerText}}`;
|
|
3834
|
+
document.head.appendChild(style);
|
|
3835
|
+
return handle.success({ status: 'loaded' });
|
|
3648
3836
|
}
|
|
3649
3837
|
});
|
|
3650
|
-
const enableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('enableAlertBeforeUnload');
|
|
3651
|
-
const disableAlertBeforeUnload = /* @__PURE__ */ temporarilyNotSupport('disableAlertBeforeUnload');
|
|
3652
3838
|
|
|
3653
3839
|
// 菜单
|
|
3654
3840
|
const getMenuButtonBoundingClientRect = /* @__PURE__ */ temporarilyNotSupport('getMenuButtonBoundingClientRect');
|
|
3655
3841
|
|
|
3656
3842
|
// 导航栏
|
|
3657
|
-
|
|
3843
|
+
/**
|
|
3844
|
+
* 展示导航栏 loading 状态
|
|
3845
|
+
*/
|
|
3846
|
+
function showNavigationBarLoading(options = {}) {
|
|
3847
|
+
const { success, fail, complete } = options;
|
|
3848
|
+
const handle = new MethodHandler({ name: 'showNavigationBarLoading', success, fail, complete });
|
|
3849
|
+
setNavigationBarLoading(true);
|
|
3850
|
+
return handle.success();
|
|
3851
|
+
}
|
|
3658
3852
|
function setNavigationBarTitle(options) {
|
|
3659
3853
|
// options must be an Object
|
|
3660
3854
|
const isObject = shouldBeObject(options);
|
|
@@ -3681,15 +3875,24 @@ function setNavigationBarTitle(options) {
|
|
|
3681
3875
|
* 设置页面导航条颜色
|
|
3682
3876
|
*/
|
|
3683
3877
|
const setNavigationBarColor = (options) => {
|
|
3684
|
-
const { backgroundColor, success, fail, complete } = options;
|
|
3878
|
+
const { backgroundColor, frontColor, success, fail, complete } = options;
|
|
3685
3879
|
const handle = new MethodHandler({ name: 'setNavigationBarColor', success, fail, complete });
|
|
3686
3880
|
const meta = document.createElement('meta');
|
|
3687
3881
|
meta.setAttribute('name', 'theme-color');
|
|
3688
3882
|
meta.setAttribute('content', backgroundColor);
|
|
3689
3883
|
document.head.appendChild(meta);
|
|
3884
|
+
setNavigationBarStyle({ frontColor, backgroundColor });
|
|
3690
3885
|
return handle.success();
|
|
3691
3886
|
};
|
|
3692
|
-
|
|
3887
|
+
/**
|
|
3888
|
+
* 隐藏导航栏 loading 状态
|
|
3889
|
+
*/
|
|
3890
|
+
function hideNavigationBarLoading(options = {}) {
|
|
3891
|
+
const { success, fail, complete } = options;
|
|
3892
|
+
const handle = new MethodHandler({ name: 'hideNavigationBarLoading', success, fail, complete });
|
|
3893
|
+
setNavigationBarLoading(false);
|
|
3894
|
+
return handle.success();
|
|
3895
|
+
}
|
|
3693
3896
|
const hideHomeButton = /* @__PURE__ */ temporarilyNotSupport('hideHomeButton');
|
|
3694
3897
|
|
|
3695
3898
|
/**
|
|
@@ -4759,7 +4962,10 @@ function _request(options = {}) {
|
|
|
4759
4962
|
const { success, complete, fail } = options;
|
|
4760
4963
|
const params = {};
|
|
4761
4964
|
const res = {};
|
|
4762
|
-
let { cache = 'default', credentials, data, dataType, header = {}, jsonp, method = 'GET', mode, responseType, signal, timeout
|
|
4965
|
+
let { cache = 'default', credentials, data, dataType, header = {}, jsonp, method = 'GET', mode, responseType, signal, timeout, url = '' } = options, opts = __rest(options, ["cache", "credentials", "data", "dataType", "header", "jsonp", "method", "mode", "responseType", "signal", "timeout", "url"]);
|
|
4966
|
+
if (typeof timeout !== 'number') {
|
|
4967
|
+
timeout = NETWORK_TIMEOUT;
|
|
4968
|
+
}
|
|
4763
4969
|
Object.assign(params, opts);
|
|
4764
4970
|
if (jsonp) {
|
|
4765
4971
|
// @ts-ignore
|
|
@@ -4825,12 +5031,10 @@ function _request(options = {}) {
|
|
|
4825
5031
|
else {
|
|
4826
5032
|
controller = new window.AbortController();
|
|
4827
5033
|
params.signal = controller.signal;
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
}, timeout);
|
|
4833
|
-
}
|
|
5034
|
+
timeoutTimer = setTimeout(function () {
|
|
5035
|
+
if (controller)
|
|
5036
|
+
controller.abort();
|
|
5037
|
+
}, timeout);
|
|
4834
5038
|
}
|
|
4835
5039
|
params.credentials = credentials;
|
|
4836
5040
|
const p = fetch(url, params)
|
|
@@ -5405,7 +5609,8 @@ class TaroH5IntersectionObserver {
|
|
|
5405
5609
|
intersectionRatio: entry.intersectionRatio,
|
|
5406
5610
|
intersectionRect: entry.intersectionRect,
|
|
5407
5611
|
relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },
|
|
5408
|
-
|
|
5612
|
+
// 使用时间戳而不是entry.time,跟微信小程序一致
|
|
5613
|
+
time: Date.now(),
|
|
5409
5614
|
};
|
|
5410
5615
|
// web端会默认首次触发
|
|
5411
5616
|
if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {
|
|
@@ -5553,15 +5758,18 @@ class NodesRef {
|
|
|
5553
5758
|
}
|
|
5554
5759
|
fields(fields, cb) {
|
|
5555
5760
|
const { _selector, _component, _single, _selectorQuery } = this;
|
|
5556
|
-
const { id, dataset, rect, size, scrollOffset, properties = [], computedStyle = [] } = fields;
|
|
5761
|
+
const { id, dataset, rect, size, scrollOffset, context, node, properties = [], computedStyle = [] } = fields;
|
|
5557
5762
|
_selectorQuery._push(_selector, _component, _single, {
|
|
5558
5763
|
id,
|
|
5559
5764
|
dataset,
|
|
5560
5765
|
rect,
|
|
5561
5766
|
size,
|
|
5562
5767
|
scrollOffset,
|
|
5768
|
+
context,
|
|
5769
|
+
node,
|
|
5770
|
+
nodeCanvasType: node,
|
|
5563
5771
|
properties,
|
|
5564
|
-
computedStyle
|
|
5772
|
+
computedStyle,
|
|
5565
5773
|
}, cb);
|
|
5566
5774
|
return _selectorQuery;
|
|
5567
5775
|
}
|
|
@@ -5835,9 +6043,9 @@ const pxTransform = function (size = 0) {
|
|
|
5835
6043
|
const config = getConfig.call(this);
|
|
5836
6044
|
const baseFontSize = config.baseFontSize || defaultBaseFontSize;
|
|
5837
6045
|
const deviceRatio = config.deviceRatio || defaultDesignRatio;
|
|
5838
|
-
const designWidth = ((
|
|
6046
|
+
const designWidth = ((input = 0) => isFunction(config.designWidth)
|
|
5839
6047
|
? config.designWidth(input)
|
|
5840
|
-
: config.designWidth)
|
|
6048
|
+
: config.designWidth)(size);
|
|
5841
6049
|
if (!(designWidth in config.deviceRatio)) {
|
|
5842
6050
|
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
|
|
5843
6051
|
}
|
|
@@ -5882,5 +6090,5 @@ taro.initPxTransform = initPxTransform;
|
|
|
5882
6090
|
taro.canIUseWebp = canIUseWebp;
|
|
5883
6091
|
taro.getAppInfo = getAppInfo;
|
|
5884
6092
|
|
|
5885
|
-
export { Behavior, Current, ENV_TYPE, Events, Link, NodesRef, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addRecentColorSign, addVideoToFavorites, advancedGeneralIdentify, animalClassify, applyAddToMyApps, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, batchGetStorage, batchGetStorageSync, batchSetStorage, batchSetStorageSync, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsAddedToMyMiniProgram, checkIsOpenAccessibility, checkIsPictureInPictureActive, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, cleanInterceptors, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCacheManager, createCameraContext, createCanvasContext, createInferenceSession, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaQueryObserver, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, cropImage, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, editImage, enableAlertBeforeUnload, env, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAppInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getChannelsShareKey, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getDeviceVoIPList, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getGuildInfo, getHCEState, getImageInfo, getInferenceEnvInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getPrivacySetting, getQQRunData, getRandomValues, getRealtimeLogManager, getRecorderManager, getRendererUserAgent, getSavedFileInfo, getSavedFileList, getScreenBrightness, getScreenRecordingState, getSelectedTextRange, getSetting, getShareInfo, getSkylineInfo, getSkylineInfoSync, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptorify, interceptors, isAddedToMyApps, isBluetoothDevicePaired, isVKSupport, join1v1Chat, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLazyLoadError, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offScreenRecordingStateChanged, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatSpeakersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWifiConnectedWithPartialInfo, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLazyLoadError, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNeedPrivacyAuthorization, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onScreenRecordingStateChanged, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openChannelsUserProfile, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openPrivacyContract, openQzonePublish, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadAssets, preloadSkylineView, preloadSubPackage, preloadWebview, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestDeviceVoIP, requestOrderPayment, requestPayment, requestPluginPayment, requestPolymerPayment, requestSubscribeDeviceMessage, requestSubscribeMessage, requirePlugin, requirePrivacyAuthorize, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSms, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setCustomDress, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setOfficialDress, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, tradePay, updateQQApp, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
|
|
6093
|
+
export { Behavior, Current, ENV_TYPE, Events, Link, NodesRef, SocketTask, addCard, addFileToFavorites, addInterceptor, addPhoneCalendar, addPhoneContact, addPhoneRepeatCalendar, addRecentColorSign, addVideoToFavorites, advancedGeneralIdentify, animalClassify, applyAddToMyApps, arrayBufferToBase64, authPrivateMessage, authorize, authorizeForMiniProgram, base64ToArrayBuffer, batchGetStorage, batchGetStorageSync, batchSetStorage, batchSetStorageSync, canIUseWebp, canvasGetImageData, canvasPutImageData, canvasToTempFilePath, carClassify, checkIsAddedToMyMiniProgram, checkIsOpenAccessibility, checkIsPictureInPictureActive, checkIsSoterEnrolledInDevice, checkIsSupportFacialRecognition, checkIsSupportSoterAuthentication, checkSession, chooseAddress, chooseContact, chooseImage, chooseInvoice, chooseInvoiceTitle, chooseLicensePlate, chooseLocation, chooseMedia, chooseMessageFile, choosePoi, chooseVideo, cleanInterceptors, clearStorage, clearStorageSync, closeBLEConnection, closeBluetoothAdapter, closeSocket, cloud, compressImage, compressVideo, connectSocket, connectWifi, createAnimation, createAudioContext, createBLEConnection, createBLEPeripheralServer, createBufferURL, createCacheManager, createCameraContext, createCanvasContext, createInferenceSession, createInnerAudioContext, createIntersectionObserver, createInterstitialAd, createLivePlayerContext, createLivePusherContext, createMapContext, createMediaAudioPlayer, createMediaContainer, createMediaQueryObserver, createMediaRecorder, createOffscreenCanvas, createRewardedVideoAd, createSelectorQuery, createTCPSocket, createUDPSocket, createVKSession, createVideoContext, createVideoDecoder, createWebAudioContext, createWorker, cropImage, taro as default, disableAlertBeforeUnload, dishClassify, downloadFile, editImage, enableAlertBeforeUnload, env, eventCenter, exitMiniProgram, exitVoIPChat, faceDetect, faceVerifyForPay, getAccountInfoSync, getApp, getAppAuthorizeSetting, getAppBaseInfo, getAppInfo, getAvailableAudioSources, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, getBackgroundAudioManager, getBackgroundAudioPlayerState, getBackgroundFetchData, getBackgroundFetchToken, getBatteryInfo, getBatteryInfoSync, getBeacons, getBluetoothAdapterState, getBluetoothDevices, getChannelsLiveInfo, getChannelsLiveNoticeInfo, getChannelsShareKey, getClipboardData, getConnectedBluetoothDevices, getConnectedWifi, getCurrentInstance, getDeviceInfo, getDeviceVoIPList, getEnterOptionsSync, getEnv, getExptInfoSync, getExtConfig, getExtConfigSync, getFileInfo, getFileSystemManager, getFuzzyLocation, getGroupEnterInfo, getGuildInfo, getHCEState, getImageInfo, getInferenceEnvInfo, getLaunchOptionsSync, getLocalIPAddress, getLocation, getLogManager, getMenuButtonBoundingClientRect, getNFCAdapter, getNetworkType, getOpenUserInfo, getPerformance, getPrivacySetting, getQQRunData, getRandomValues, getRealtimeLogManager, getRecorderManager, getRendererUserAgent, getSavedFileInfo, getSavedFileList, getScreenBrightness, getScreenRecordingState, getSelectedTextRange, getSetting, getShareInfo, getSkylineInfo, getSkylineInfoSync, getStorage, getStorageInfo, getStorageInfoSync, getStorageSync, getSwanId, getSystemInfo, getSystemInfoAsync, getSystemInfoSync, getSystemSetting, getUpdateManager, getUserCryptoManager, getUserInfo, getUserProfile, getVideoInfo, getWeRunData, getWifiList, getWindowInfo, hideHomeButton, hideKeyboard, hideLoading, hideNavigationBarLoading, hideShareMenu, hideTabBar, hideTabBarRedDot, hideToast, imageAudit, initFaceDetect, initPxTransform, initTabBarApis, interceptorify, interceptors, isAddedToMyApps, isBluetoothDevicePaired, isVKSupport, join1v1Chat, joinVoIPChat, loadFontFace, login, logoClassify, makeBluetoothPair, makePhoneCall, navigateBackMiniProgram, navigateBackSmartProgram, navigateToMiniProgram, navigateToSmartGameProgram, navigateToSmartProgram, nextTick, notifyBLECharacteristicValueChange, objectDetectIdentify, ocrBankCard, ocrDrivingLicense, ocrIdCard, ocrVehicleLicense, offAccelerometerChange, offAppHide, offAppShow, offAudioInterruptionBegin, offAudioInterruptionEnd, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, offBLEPeripheralConnectionStateChanged, offBeaconServiceChange, offBeaconUpdate, offBluetoothAdapterStateChange, offBluetoothDeviceFound, offCompassChange, offCopyUrl, offDeviceMotionChange, offError, offGetWifiList, offGyroscopeChange, offHCEMessage, offKeyboardHeightChange, offLazyLoadError, offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, offLocationChange, offLocationChangeError, offMemoryWarning, offNetworkStatusChange, offNetworkWeakChange, offPageNotFound, offScreenRecordingStateChanged, offThemeChange, offUnhandledRejection, offUserCaptureScreen, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatSpeakersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, offWifiConnected, offWifiConnectedWithPartialInfo, offWindowResize, onAccelerometerChange, onAppHide, onAppShow, onAudioInterruptionBegin, onAudioInterruptionEnd, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, onBLEPeripheralConnectionStateChanged, onBackgroundAudioPause, onBackgroundAudioPlay, onBackgroundAudioStop, onBackgroundFetchData, onBeaconServiceChange, onBeaconUpdate, onBluetoothAdapterStateChange, onBluetoothDeviceFound, onCompassChange, onCopyUrl, onDeviceMotionChange, onError, onGetWifiList, onGyroscopeChange, onHCEMessage, onKeyboardHeightChange, onLazyLoadError, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, onLocationChange, onLocationChangeError, onMemoryWarning, onNeedPrivacyAuthorization, onNetworkStatusChange, onNetworkWeakChange, onPageNotFound, onScreenRecordingStateChanged, onSocketClose, onSocketError, onSocketMessage, onSocketOpen, onThemeChange, onUnhandledRejection, onUserCaptureScreen, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, onWifiConnected, onWifiConnectedWithPartialInfo, onWindowResize, openAppAuthorizeSetting, openBluetoothAdapter, openBusinessView, openCard, openChannelsActivity, openChannelsEvent, openChannelsLive, openChannelsUserProfile, openCustomerServiceChat, openDocument, openEmbeddedMiniProgram, openLocation, openPrivacyContract, openQzonePublish, openSetting, openSystemBluetoothSetting, openVideoEditor, options, pageScrollTo, pauseBackgroundAudio, pauseVoice, plantClassify, playBackgroundAudio, playVoice, pluginLogin, preload, preloadAssets, preloadSkylineView, preloadSubPackage, preloadWebview, previewImage, previewMedia, pxTransform, readBLECharacteristicValue, removeSavedFile, removeStorage, removeStorageSync, removeTabBarBadge, reportAnalytics, reportEvent, reportMonitor, reportPerformance, request, requestDeviceVoIP, requestOrderPayment, requestPayment, requestPluginPayment, requestPolymerPayment, requestSubscribeDeviceMessage, requestSubscribeMessage, requirePlugin, requirePrivacyAuthorize, reserveChannelsLive, revokeBufferURL, saveFile, saveFileToDisk, saveImageToPhotosAlbum, saveVideoToPhotosAlbum, scanCode, seekBackgroundAudio, sendHCEMessage, sendSms, sendSocketMessage, setBLEMTU, setBackgroundColor, setBackgroundFetchToken, setBackgroundTextStyle, setClipboardData, setCustomDress, setEnable1v1Chat, setEnableDebug, setInnerAudioOption, setKeepScreenOn, setNavigationBarColor, setNavigationBarTitle, setOfficialDress, setPageInfo, setScreenBrightness, setStorage, setStorageSync, setTabBarBadge, setTabBarItem, setTabBarStyle, setTopBarText, setVisualEffectOnCapture, setWifiList, setWindowSize, shareFileMessage, shareToWeRun, shareVideoMessage, showActionSheet, showLoading, showModal, showNavigationBarLoading, showRedPackage, showShareImageMenu, showShareMenu, showTabBar, showTabBarRedDot, showToast, startAccelerometer, startBeaconDiscovery, startBluetoothDevicesDiscovery, startCompass, startDeviceMotionListening, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, startGyroscope, startHCE, startLocalServiceDiscovery, startLocationUpdate, startLocationUpdateBackground, startPullDownRefresh, startRecord, startSoterAuthentication, startWifi, stopAccelerometer, stopBackgroundAudio, stopBeaconDiscovery, stopBluetoothDevicesDiscovery, stopCompass, stopDeviceMotionListening, stopFaceDetect, stopGyroscope, stopHCE, stopLocalServiceDiscovery, stopLocationUpdate, stopPullDownRefresh, stopRecord, stopVoice, stopWifi, subscribeVoIPVideoMembers, textReview, textToAudio, tradePay, updateQQApp, updateShareMenu, updateVoIPChatMuteConfig, updateWeChatApp, uploadFile, vibrateLong, vibrateShort, writeBLECharacteristicValue };
|
|
5886
6094
|
//# sourceMappingURL=index.esm.js.map
|