index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. // dist/status-show/index.js
  2. Component({
  3. /**
  4. * 组件的属性列表
  5. */
  6. externalClasses: ['l-class', 'l-image-class', 'l-button-class', 'l-describe-class'],
  7. properties: {
  8. show: Boolean,
  9. type: {
  10. type: String,
  11. value: 'success',
  12. observer: '_changeStatus'
  13. },
  14. image: String,
  15. describe: String,
  16. buttonText: String,
  17. bgColor: {
  18. type: String,
  19. value: '#fff'
  20. },
  21. fullScreen: {
  22. type: Boolean,
  23. value: true,
  24. },
  25. openApi: {
  26. type: Boolean,
  27. value: true
  28. },
  29. custom: {
  30. type: Boolean,
  31. value: false
  32. }
  33. },
  34. /**
  35. * 组件的初始数据
  36. */
  37. data: {
  38. },
  39. attached() {
  40. this._changeStatus();
  41. if (this.data.openApi) this._init();
  42. },
  43. pageLifetimes: {
  44. show() {
  45. this._init();
  46. },
  47. },
  48. /**
  49. * 组件的方法列表
  50. */
  51. methods: {
  52. _init() {
  53. wx.lin = wx.lin || {};
  54. wx.lin.showStatusShow = (options) => {
  55. const {
  56. type = 'success',
  57. image = '',
  58. describe = '',
  59. buttonText = '',
  60. bgColor = '#fff',
  61. fullScreen = true
  62. } = { ...options };
  63. this.setData({
  64. show: true,
  65. type,
  66. image,
  67. describe,
  68. buttonText,
  69. bgColor,
  70. fullScreen
  71. });
  72. };
  73. wx.lin.hideStatusShow = () => {
  74. this.setData({
  75. show: false
  76. });
  77. };
  78. },
  79. _changeStatus() {
  80. switch (this.properties.type) {
  81. case 'success':
  82. this.setData({
  83. typeImage: 'image/success.png',
  84. typeText: '操作成功~'
  85. });
  86. break;
  87. case 'error':
  88. this.setData({
  89. typeImage: 'image/error.png',
  90. typeText: '操作失败~'
  91. });
  92. break;
  93. case 'cart':
  94. this.setData({
  95. typeImage: 'image/cart.png',
  96. typeText: '购物车空空如也,去逛逛吧~'
  97. });
  98. break;
  99. case 'order':
  100. this.setData({
  101. typeImage: 'image/order.png',
  102. typeText: '您暂时还没有订单哦~'
  103. });
  104. break;
  105. case 'network':
  106. this.setData({
  107. typeImage: 'image/network.png',
  108. typeText: '糟糕!网络错误~'
  109. });
  110. break;
  111. case 'address':
  112. this.setData({
  113. typeImage: 'image/address.png',
  114. typeText: '您暂时还没有地址哦~'
  115. });
  116. break;
  117. case 'product':
  118. this.setData({
  119. typeImage: 'image/product.png',
  120. typeText: '暂时还没有商品哦~~'
  121. });
  122. break;
  123. case 'data':
  124. this.setData({
  125. typeImage: 'image/data.png',
  126. typeText: '暂时还没有相关数据哦~~'
  127. });
  128. break;
  129. }
  130. },
  131. tapStatusShow() {
  132. this.triggerEvent('lincorvertap', {}, {
  133. bubbles: true,
  134. composed: true
  135. });
  136. }
  137. }
  138. });