index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view>
  3. <van-button
  4. :id="id"
  5. :lang="lang"
  6. :type="type"
  7. :color="color"
  8. :plain="plain"
  9. :loading="loading"
  10. :disabled="disabled"
  11. :open-type="openType"
  12. :class="utils.bem('goods-action-button', [type, { first: isFirst, last: isLast, plain: plain }])"
  13. custom-class="van-goods-action-button__inner"
  14. :business-id="businessId"
  15. :session-from="sessionFrom"
  16. :app-parameter="appParameter"
  17. :send-message-img="sendMessageImg"
  18. :send-message-path="sendMessagePath"
  19. :show-message-card="showMessageCard"
  20. :send-message-title="sendMessageTitle"
  21. @click="onClick($event, { tagId: id })"
  22. @error="bindError($event, { tagId: id })"
  23. @contact="bindContact($event, { tagId: id })"
  24. @opensetting="bindOpenSetting($event, { tagId: id })"
  25. @getuserinfo="bindGetUserInfo($event, { tagId: id })"
  26. @getphonenumber="bindGetPhoneNumber($event, { tagId: id })"
  27. @launchapp="bindLaunchApp($event, { tagId: id })"
  28. >
  29. {{ text }}
  30. <slot></slot>
  31. </van-button>
  32. </view>
  33. </template>
  34. <script module="utils" lang="wxs" src="@/node_modules/@vant/weapp/dist/wxs/utils.wxs"></script>
  35. <script>
  36. import { VantComponent } from '../common/component';
  37. import { link } from '../mixins/link';
  38. import { button } from '../mixins/button';
  39. import { openType } from '../mixins/open-type';
  40. export default {
  41. data() {
  42. return {
  43. isFirst: '',
  44. isLast: '',
  45. id: '',
  46. lang: '',
  47. openType: '',
  48. businessId: '',
  49. sessionFrom: '',
  50. appParameter: '',
  51. sendMessageImg: '',
  52. sendMessagePath: '',
  53. showMessageCard: '',
  54. sendMessageTitle: ''
  55. };
  56. },
  57. mixins: [link, button, openType],
  58. '../goods-action/index': {
  59. type: 'ancestor',
  60. name: 'goods-action',
  61. current: 'goods-action-button'
  62. },
  63. props: {
  64. text: String,
  65. color: String,
  66. loading: Boolean,
  67. disabled: Boolean,
  68. plain: Boolean,
  69. type: {
  70. type: String,
  71. default: 'danger'
  72. }
  73. },
  74. methods: {
  75. onClick(event, _dataset) {
  76. /* ---处理dataset begin--- */
  77. this.handleDataset(event, _dataset);
  78. /* ---处理dataset end--- */
  79. this.$emit('click', event.detail);
  80. this.jumpLink();
  81. },
  82. updateStyle() {
  83. if (this.parent == null) {
  84. return;
  85. }
  86. const { children = [] } = this.parent;
  87. const { length } = children;
  88. const index = children.indexOf(this);
  89. this.setData({
  90. isFirst: index === 0,
  91. isLast: index === length - 1
  92. });
  93. },
  94. bindError(e, _dataset) {
  95. /* ---处理dataset begin--- */
  96. this.handleDataset(e, _dataset);
  97. /* ---处理dataset end--- */
  98. console.log('占位:函数 bindError 未声明');
  99. },
  100. bindContact(e, _dataset) {
  101. /* ---处理dataset begin--- */
  102. this.handleDataset(e, _dataset);
  103. /* ---处理dataset end--- */
  104. console.log('占位:函数 bindContact 未声明');
  105. },
  106. bindOpenSetting(e, _dataset) {
  107. /* ---处理dataset begin--- */
  108. this.handleDataset(e, _dataset);
  109. /* ---处理dataset end--- */
  110. console.log('占位:函数 bindOpenSetting 未声明');
  111. },
  112. bindGetUserInfo(e, _dataset) {
  113. /* ---处理dataset begin--- */
  114. this.handleDataset(e, _dataset);
  115. /* ---处理dataset end--- */
  116. console.log('占位:函数 bindGetUserInfo 未声明');
  117. },
  118. bindGetPhoneNumber(e, _dataset) {
  119. /* ---处理dataset begin--- */
  120. this.handleDataset(e, _dataset);
  121. /* ---处理dataset end--- */
  122. console.log('占位:函数 bindGetPhoneNumber 未声明');
  123. },
  124. bindLaunchApp(e, _dataset) {
  125. /* ---处理dataset begin--- */
  126. this.handleDataset(e, _dataset);
  127. /* ---处理dataset end--- */
  128. console.log('占位:函数 bindLaunchApp 未声明');
  129. }
  130. }
  131. };
  132. </script>
  133. <style>
  134. @import './index.css';
  135. </style>