InfoBuy.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <!-- Buy.vue -->
  2. <template>
  3. <view class="div main-content" v-if="detailInfo">
  4. <flex-line :is-link="true" :show-border="true" @click.native="changeCartState()">
  5. <view class="div"
  6. :class="{'isopacity':!activeBuy}"
  7. >
  8. <view class="p" v-if="number <= 0 && chooseinfo.ids.length <= 0">
  9. 请选择购买{{ chooseinfo.specification.join(',') }}数量分类
  10. </view>
  11. <view class="p" v-if="number <= 0 && chooseinfo.ids.length > 0">
  12. 已选{{ chooseinfo.specification.join(',') }},数量{{ number + 1 }}
  13. </view>
  14. <view class="p" v-if="number > 0 && chooseinfo.ids.length <= 0">
  15. 已选数量{{ number }}
  16. </view>
  17. <view class="p" v-if="number > 0 && chooseinfo.ids.length > 0">
  18. 已选{{ chooseinfo.specification.join(',') }},数量{{ number }}
  19. </view>
  20. </view>
  21. </flex-line>
  22. </view>
  23. </template>
  24. <script>
  25. import { mapState, mapMutations } from 'vuex'
  26. import flexLine from '../../../flexLine'
  27. export default {
  28. data () {
  29. return {}
  30. },
  31. components:{flexLine},
  32. computed: {
  33. ...mapState({
  34. number: state => state.goodsdetail.number,
  35. detailInfo: state => state.goodsdetail.detailInfo,
  36. chooseinfo: state => state.goodsdetail.chooseinfo
  37. }),
  38. activeBuy: function () {
  39. if (this.detailInfo.goods_storage > 0) {
  40. return true
  41. } else {
  42. return false
  43. }
  44. },
  45. },
  46. created () {},
  47. watch: {
  48. detailInfo: function (value) {
  49. this.setSpecification()
  50. }
  51. },
  52. methods: {
  53. ...mapMutations({
  54. saveCartState: 'saveCartState',
  55. saveChooseInfo: 'saveChooseInfo',
  56. changeType: 'changeType'
  57. }),
  58. changeCartState () {
  59. this.saveCartState(true)
  60. this.changeType('加入购物车')
  61. },
  62. setSpecification () {
  63. if (this.detailInfo && this.detailInfo.properties) {
  64. let data = this.detailInfo.properties
  65. let arrays = []
  66. for (let i = 0; i <= data.length - 1; i++) {
  67. arrays.push(data[i].name)
  68. }
  69. this.saveChooseInfo({ specification: arrays, ids: [] })
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style lang="scss" scoped>
  76. .main-content{padding:0 $pageSpace;background-color: #fff;}
  77. .isopacity {
  78. opacity: 0.5;
  79. }
  80. </style>