<!-- Buy.vue -->
<template>
	<view class="div main-content" v-if="detailInfo">
		<flex-line :is-link="true" :show-border="true" @click.native="changeCartState()">
			<view class="div"
					:class="{'isopacity':!activeBuy}"
			>
				<view class="p" v-if="number <= 0">
					请选择购买数量分类
				</view>

				<view class="p" v-if="number > 0">
					已选数量{{ number }}
				</view>

			</view>
		</flex-line>

	</view>
</template>

<script>
import { mapState, mapMutations } from 'vuex'
import FlexLine from '../../../flexLine'
export default {
  components: { FlexLine },
  data () {
    return {}
  },

  computed: {
    ...mapState({
      number: state => state.pointsgoods.number,
      detailInfo: state => state.pointsgoods.detailInfo
    })
  },

  created () {},

  methods: {
    ...mapMutations({
      saveCartState: 'saveCartState',
      changeType: 'changeType'
    }),

    activeBuy: function () {
      if (this.detailInfo.pgoods_storage > 0) {
        return true
      } else {
        return false
      }
    },

    changeCartState () {
      this.saveCartState(true)
      this.changeType('加入购物车')
    }

  }
}
</script>

<style lang="scss" scoped>
	.main-content{padding:0 $pageSpace;background-color: #fff;}
	.isopacity {
		opacity: 0.5;
	}
</style>
