123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <template>
- <div class="orderPopup" :class="{'show':show}">
- <div class="centerLabel" v-if="data !== null">
- <div class="top">
- <span>{{data.name}}</span>
- <i class="iconfont icon-guanbi" @click="close"></i>
- </div>
- <div class="content flex-h">
- <div class="flex-item">
- <div>
- <span>规格:</span>
- <ul>
- <li v-for="(item,index) in data.spec" :class="{'active': index === activeIndex, 'grey': item.status !== 1}" :key="index" @click="selectItem(item, index)">{{item.value}}</li>
- </ul>
- </div>
- </div>
- </div>
- <div class="bottom flex-h">
- <div class="flex-item">
- <div>
- <span>¥{{data.spec[activeIndex].price}}</span>
- </div>
- </div>
- <i class="iconfont icon-jian" @click="subtract"></i>
- <input type="tel" v-model="num" readonly style="color:#000;">
- <i class="iconfont icon-jia" @click="add"></i>
- <a @click="sure">确定</a>
- </div>
- <!-- <a class="sure">确定</a> -->
- </div>
- </div>
- </template>
-
- <script>
-
- export default {
- name: '',
- props: ['show', 'data'],
- data () {
- return {
- activeIndex: 0,
- // price: 0,
- // num: 0,
- // specId: '',
- // specName: '',
- }
- },
- computed: {
- num: {
- get () {
- return this.data.spec[this.activeIndex].num
- },
- set (val) {
- console.log(this.data)
- this.data.spec[this.activeIndex].num = val
- this.$emit('returnData', {
- id: this.data.id,
- name: this.data.name,
- spec: this.data.spec[this.activeIndex].id,
- specname: this.data.spec[this.activeIndex].value,
- defaultNum: val,
- defaultPrice: this.data.spec[this.activeIndex].price || 0,
- })
- }
- },
- },
- components: {
-
- },
- created () {
-
- },
- methods: {
- sure () { // 确定
- // this.$emit('returnData', this.data)
- this.close()
- },
- subtract () { // 减
- if (this.num > 0) {
- this.num -= 1
- }
- },
- add () { // 加
- this.num += 1
- },
- selectItem (item, index) { // 选择规格
- console.log(item)
- if (item.status === 1) {
- // if (this.activeIndex === index) {
- // this.activeIndex = ''
- // this.price = 0
- // this.specId = ''
- // this.specName = ''
- // } else {
- this.activeIndex = index
- // this.price = item.price
- // this.specId = item.id
- // this.specName = item.value
- // }
- }
- },
- close () { // 关闭弹窗
- this.$emit('closePopup')
- this.resetData()
- },
- resetData () { // 重置状态
- // this.activeIndex = ''
- // this.price = 0
- // this.num = 1
- // this.specName = ''
- // this.specId = ''
- },
- }
- }
- </script>
-
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style lang="scss" scoped>
- @import "page.scss";
- </style>
|