index.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import getLocationInfo from '../../utils/getLocationInfo';
  2. import { connect } from 'herculex';
  3. Component(connect({
  4. mapStateToProps: {
  5. hasTabBar: state => state.hasTabBar
  6. }
  7. })({
  8. props: {
  9. tabbarInfo: {}
  10. },
  11. data: {
  12. tabbarHeight: 0,
  13. show: false
  14. },
  15. methods: {
  16. show(show) {
  17. my.createSelectorQuery().select('.tabbar-box').boundingClientRect().exec(ret => {
  18. this.setData({
  19. tabbarHeight: ret[0].height
  20. });
  21. });
  22. show = show === undefined ? true : show;
  23. this.setData({
  24. show
  25. });
  26. },
  27. onClose() {
  28. this.setData({
  29. show: false
  30. });
  31. },
  32. handleEnable() {
  33. getLocationInfo().then(() => {
  34. this.onClose();
  35. this.props.onGetLocation();
  36. }).catch(e => {
  37. // 处理app本身没开启定位, 模拟器跟真机code不一致
  38. if (e.error === 11) {
  39. my.showToast({
  40. content: e.errorMessage || '请开启定位权限'
  41. });
  42. }
  43. });
  44. }
  45. }
  46. }));