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