微信

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <template>
  2. <div class="orderPopup" :class="{'show':show}">
  3. <div class="centerLabel" v-if="data !== null">
  4. <div class="top">
  5. <span>{{data.name}}</span>
  6. <i class="iconfont icon-guanbi" @click="close"></i>
  7. </div>
  8. <div class="content flex-h">
  9. <div class="flex-item">
  10. <div>
  11. <span>规格:</span>
  12. <ul>
  13. <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>
  14. </ul>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="bottom flex-h">
  19. <div class="flex-item">
  20. <div>
  21. <span>¥{{data.spec[activeIndex].price}}</span>
  22. </div>
  23. </div>
  24. <i class="iconfont icon-jian" @click="subtract"></i>
  25. <input type="tel" v-model="num" readonly style="color:#000;">
  26. <i class="iconfont icon-jia" @click="add"></i>
  27. <a @click="sure">确定</a>
  28. </div>
  29. <!-- <a class="sure">确定</a> -->
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: '',
  36. props: ['show', 'data'],
  37. data () {
  38. return {
  39. activeIndex: 0,
  40. // price: 0,
  41. // num: 0,
  42. // specId: '',
  43. // specName: '',
  44. }
  45. },
  46. computed: {
  47. num: {
  48. get () {
  49. return this.data.spec[this.activeIndex].num
  50. },
  51. set (val) {
  52. console.log(this.data)
  53. this.data.spec[this.activeIndex].num = val
  54. this.$emit('returnData', {
  55. id: this.data.id,
  56. name: this.data.name,
  57. spec: this.data.spec[this.activeIndex].id,
  58. specname: this.data.spec[this.activeIndex].value,
  59. defaultNum: val,
  60. defaultPrice: this.data.spec[this.activeIndex].price || 0,
  61. })
  62. }
  63. },
  64. },
  65. components: {
  66. },
  67. created () {
  68. },
  69. methods: {
  70. sure () { // 确定
  71. // this.$emit('returnData', this.data)
  72. this.close()
  73. },
  74. subtract () { // 减
  75. if (this.num > 0) {
  76. this.num -= 1
  77. }
  78. },
  79. add () { // 加
  80. this.num += 1
  81. },
  82. selectItem (item, index) { // 选择规格
  83. console.log(item)
  84. if (item.status === 1) {
  85. // if (this.activeIndex === index) {
  86. // this.activeIndex = ''
  87. // this.price = 0
  88. // this.specId = ''
  89. // this.specName = ''
  90. // } else {
  91. this.activeIndex = index
  92. // this.price = item.price
  93. // this.specId = item.id
  94. // this.specName = item.value
  95. // }
  96. }
  97. },
  98. close () { // 关闭弹窗
  99. this.$emit('closePopup')
  100. this.resetData()
  101. },
  102. resetData () { // 重置状态
  103. // this.activeIndex = ''
  104. // this.price = 0
  105. // this.num = 1
  106. // this.specName = ''
  107. // this.specId = ''
  108. },
  109. }
  110. }
  111. </script>
  112. <!-- Add "scoped" attribute to limit CSS to this component only -->
  113. <style lang="scss" scoped>
  114. @import "page.scss";
  115. </style>