C端小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

86 行
2.0 KiB

  1. const warn = (msg, getValue) => {
  2. console.warn(msg);
  3. };
  4. Component({
  5. externalClasses: ['i-class'],
  6. options: {
  7. multipleSlots: true
  8. },
  9. relations: {
  10. '../cell-group/index': {
  11. type: 'parent'
  12. }
  13. },
  14. properties: {
  15. // 左侧标题
  16. title: {
  17. type: String
  18. },
  19. // 标题下方的描述信息
  20. label: {
  21. type: String
  22. },
  23. // 右侧内容
  24. value: {
  25. type: String
  26. },
  27. // 只有点击 footer 区域才触发 tab 事件
  28. onlyTapFooter: {
  29. type: Boolean
  30. },
  31. // 是否展示右侧箭头并开启尝试以 url 跳转
  32. isLink: {
  33. type: null,
  34. value: ''
  35. },
  36. // 链接类型,可选值为 navigateTo,redirectTo,switchTab,reLaunch
  37. linkType: {
  38. type: String,
  39. value: 'navigateTo'
  40. },
  41. url: {
  42. type: String,
  43. value: ''
  44. }
  45. },
  46. data: {
  47. isLastCell: true
  48. },
  49. methods: {
  50. navigateTo () {
  51. const { url } = this.data;
  52. const type = typeof this.data.isLink;
  53. this.triggerEvent('click', {});
  54. if (!this.data.isLink || !url || url === 'true' || url === 'false') return;
  55. if (type !== 'boolean' && type !== 'string') {
  56. warn('isLink 属性值必须是一个字符串或布尔值', this.data.isLink);
  57. return;
  58. }
  59. if (['navigateTo', 'redirectTo', 'switchTab', 'reLaunch'].indexOf(this.data.linkType) === -1) {
  60. warn('linkType 属性可选值为 navigateTo,redirectTo,switchTab,reLaunch', this.data.linkType);
  61. return;
  62. }
  63. wx[this.data.linkType].call(wx, {url});
  64. },
  65. handleTap () {
  66. if (!this.data.onlyTapFooter) {
  67. this.navigateTo();
  68. }
  69. },
  70. updateIsLastCell (isLastCell) {
  71. this.setData({ isLastCell });
  72. }
  73. }
  74. });