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