index.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. "use strict";
  2. var _page = _interopRequireDefault(require("../../common/page"));
  3. var _config = _interopRequireDefault(require("./config"));
  4. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  5. function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
  6. function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
  7. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  8. var items = [{
  9. text: _config["default"].pro1Name,
  10. children: _config["default"].pro1
  11. }, {
  12. text: _config["default"].pro2Name,
  13. children: _config["default"].pro2
  14. }, {
  15. text: _config["default"].pro3Name,
  16. disabled: true,
  17. children: _config["default"].pro3
  18. }];
  19. (0, _page["default"])({
  20. data: {
  21. items: items,
  22. badgeItems: items.slice(0, 2).map(function (item, index) {
  23. if (index === 0) {
  24. return _objectSpread(_objectSpread({}, item), {}, {
  25. dot: true
  26. });
  27. }
  28. if (index === 1) {
  29. return _objectSpread(_objectSpread({}, item), {}, {
  30. badge: 5
  31. });
  32. }
  33. return item;
  34. }),
  35. mainActiveIndex: 0,
  36. activeId: 0,
  37. mainActiveIndexMulti: 0,
  38. activeIdMulti: []
  39. },
  40. onClickNav: function onClickNav(_ref) {
  41. var detail = _ref.detail;
  42. this.setData({
  43. mainActiveIndex: detail.index || 0
  44. });
  45. },
  46. onClickItem: function onClickItem(_ref2) {
  47. var detail = _ref2.detail;
  48. var activeId = this.data.activeId === detail.id ? null : detail.id;
  49. this.setData({
  50. activeId: activeId
  51. });
  52. },
  53. onClickNavMulti: function onClickNavMulti(_ref3) {
  54. var detail = _ref3.detail;
  55. this.setData({
  56. mainActiveIndexMulti: detail.index || 0
  57. });
  58. },
  59. onClickItemMulti: function onClickItemMulti(_ref4) {
  60. var detail = _ref4.detail;
  61. var activeIdMulti = this.data.activeIdMulti;
  62. var idx = activeIdMulti.indexOf(detail.id);
  63. if (idx > -1) {
  64. activeIdMulti.splice(idx, 1);
  65. } else {
  66. activeIdMulti.push(detail.id);
  67. }
  68. this.$spliceData({
  69. activeIdMulti: activeIdMulti
  70. });
  71. }
  72. });