goods-nav.nvue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <template>
  2. <view class="uni-container">
  3. <uni-card is-full>
  4. <text class="uni-h6"> uni-goods-nav 组件主要用于电商类应用底部导航,可自定义加入购物车,购买等操作</text>
  5. </uni-card>
  6. <uni-section title="基础用法" type="line">
  7. <uni-goods-nav @click="onClick"/>
  8. </uni-section>
  9. <uni-section title="自定义用法" type="line">
  10. <uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup" @click="onClick" @buttonClick="buttonClick" />
  11. <uni-goods-nav :fill="true" :options="options" :button-group="customButtonGroup1" @click="onClick" @buttonClick="buttonClick" style="margin-top: 20px;" />
  12. </uni-section>
  13. <view class="goods-carts">
  14. <uni-goods-nav :options="options" :fill="true" :button-group="buttonGroup" @click="onClick" @buttonClick="buttonClick"/>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. components: {},
  21. data() {
  22. return {
  23. options: [{
  24. icon: 'chat',
  25. text: '客服'
  26. }, {
  27. icon: 'shop',
  28. text: '店铺',
  29. info: 2,
  30. infoBackgroundColor:'#007aff',
  31. infoColor:"#f5f5f5"
  32. }, {
  33. icon: 'cart',
  34. text: '购物车',
  35. info: 2
  36. }],
  37. buttonGroup: [{
  38. text: '加入购物车',
  39. backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
  40. color: '#fff'
  41. },
  42. {
  43. text: '立即购买',
  44. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  45. color: '#fff'
  46. }
  47. ],
  48. customButtonGroup: [{
  49. text: '加入购物车',
  50. backgroundColor: 'linear-gradient(90deg, #1E83FF, #0053B8)',
  51. color: '#fff'
  52. },
  53. {
  54. text: '立即购买',
  55. backgroundColor: 'linear-gradient(90deg, #60F3FF, #088FEB)',
  56. color: '#fff'
  57. }
  58. ],
  59. customButtonGroup1: [
  60. {
  61. text: '立即购买',
  62. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  63. color: '#fff'
  64. }
  65. ]
  66. }
  67. },
  68. onLoad() {},
  69. methods: {
  70. onClick(e) {
  71. uni.showToast({
  72. title: `点击${e.content.text}`,
  73. icon: 'none'
  74. })
  75. },
  76. buttonClick(e) {
  77. console.log(e)
  78. this.options[2].info++
  79. }
  80. }
  81. }
  82. </script>
  83. <style lang="scss">
  84. .example-body {
  85. padding: 0;
  86. /* #ifndef APP-NVUE */
  87. display: block;
  88. /* #endif */
  89. }
  90. .goods-carts {
  91. /* #ifndef APP-NVUE */
  92. display: flex;
  93. /* #endif */
  94. flex-direction: column;
  95. position: fixed;
  96. left: 0;
  97. right: 0;
  98. /* #ifdef H5 */
  99. left: var(--window-left);
  100. right: var(--window-right);
  101. /* #endif */
  102. bottom: 0;
  103. }
  104. </style>