index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="confirm-layout">
  3. <div class="time-line">
  4. <div class="line"></div>
  5. <div class="auth">
  6. <img :src="`${$cdn}images/hasLogin.png`" alt="" class="timeline-icon">
  7. <div class="timeline-text">登录信息</div>
  8. </div>
  9. <div class="shipping">
  10. <img :src="`${$cdn}images/spot.png`" alt="" class="timeline-icon">
  11. <div class="timeline-text">配送信息</div>
  12. </div>
  13. <div class="payment">
  14. <img :src="`${$cdn}images/ic_schedule_default_mb@2x.png`" alt="" class="timeline-icon">
  15. <div class="timeline-text">支付信息</div>
  16. </div>
  17. <div class="review">
  18. <img :src="`${$cdn}images/ic_schedule_default_mb@2x.png`" alt="" class="timeline-icon">
  19. <div class="timeline-text">订单提交</div>
  20. </div>
  21. </div>
  22. <div class="box-con">
  23. <div class="bc-title">收货地址</div>
  24. <div class="bc-item address-item" v-if="isShowAddress">
  25. <div class="bc-ct">
  26. <div class="bc-contact">
  27. {{address.shipName}}
  28. <div>{{address.shipMobile}}</div>
  29. </div>
  30. <div class="bc-locotion">
  31. {{`${address.shipAreaPath}${address.shipAddress}`}}
  32. </div>
  33. </div>
  34. <div class="bc-edit" @click="isShowAddress=false">编辑</div>
  35. </div>
  36. <div class="address-con" v-else>
  37. <citySelect :address='address' :token="token" @closeSelect="data=>{isShowAddress=data}" />
  38. </div>
  39. </div>
  40. <div class="box-con">
  41. <div class="bc-title">物流方式</div>
  42. <div class="bc-item express-item">
  43. <div class="item-method">顺丰速运</div>
  44. <div class="item-time">标准配送</div>
  45. </div>
  46. </div>
  47. <div class="box-con">
  48. <div class="bc-title">发票</div>
  49. <div class="invoice-con" :class="{'invoice-focus':selected}">
  50. <div class="invoice-select" @click="selected=!selected">
  51. <div class="select-txt">{{selectedTxt}}</div>
  52. <i class="iconfont icon-xia"></i>
  53. </div>
  54. <ul class="invoice-item" :class="{'invoice-active':selected}">
  55. <li v-for="(item,i) in invoiceType" :key="i" @click="handleItem(item)">{{item.name}}</li>
  56. </ul>
  57. <cinvoices v-if="selectedId!==1" :invoice='invoice2' :selectedId='selectedId' :invoicet="invoice3" :token="token" @closeInvoice="data=>{isShowInvoice=data}"/>
  58. </div>
  59. </div>
  60. <div class="btn-confirm" @click="next()">下一步</div>
  61. </div>
  62. </template>
  63. <script>
  64. import { mapState } from 'vuex'
  65. import citySelect from '@/components/citySelect'
  66. import cinvoices from '@/components/cinvoices'
  67. var cloneObj = function (obj) {
  68. var newObj = {}
  69. if (obj instanceof Array) {
  70. newObj = []
  71. }
  72. for (var key in obj) {
  73. var val = obj[key]
  74. newObj[key] = typeof val === 'object' ? cloneObj(val) : val
  75. }
  76. return newObj
  77. }
  78. export default {
  79. components: {
  80. citySelect,
  81. cinvoices
  82. },
  83. computed: {
  84. ...mapState({
  85. token: state => state.user.token,
  86. invoice2: state => {
  87. let type = Object.prototype.toString.call(state.user.invoice2)
  88. if (type === '[object Object]') {
  89. return state.user.invoice2
  90. }
  91. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  92. return (condition ? JSON.parse(state.user.invoice2) : {})
  93. },
  94. invoice3: state => {
  95. let type = Object.prototype.toString.call(state.user.invoice3)
  96. if (type === '[object Object]') {
  97. return state.user.invoice3
  98. }
  99. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  100. return (condition ? JSON.parse(state.user.invoice3) : {})
  101. },
  102. payinfo: state => {
  103. let type = Object.prototype.toString.call(state.user.payinfo)
  104. if (type === '[object Object]') {
  105. return state.user.payinfo
  106. }
  107. let condition = state.user.payinfo && state.user.payinfo !== 'null' && type !== '[object Array]'
  108. return condition ? JSON.parse(state.user.payinfo) : {}
  109. },
  110. address: state => cloneObj(state.user.address) || {}
  111. })
  112. },
  113. data () {
  114. let invoiceType = [{
  115. id: 1,
  116. name: '不需要发票'
  117. }, {
  118. id: 2,
  119. name: '增值税普通发票'
  120. }, {
  121. id: 3,
  122. name: '增值税专用发票'
  123. }]
  124. return {
  125. invoiceType,
  126. selected: false,
  127. selectedTxt: '不需要发票',
  128. selectedId: 1,
  129. isShowAddress: true
  130. }
  131. },
  132. methods: {
  133. handleItem (item) {
  134. this.selectedTxt = item.name
  135. this.selectedId = item.id
  136. this.selected = false
  137. },
  138. next () {
  139. let temp = cloneObj(this.payinfo)
  140. let invoice = this.selectedId === 2 ? this.invoice2 : this.selectedId === 3 ? this.invoice3 : null
  141. console.log(invoice)
  142. temp['invoice'] = invoice
  143. temp['receiver'] = this.address
  144. this.$store.commit('PAYINFO', temp)
  145. this.$router.push({path: '/paytype'})
  146. }
  147. },
  148. mounted () {
  149. if (this.address && Object.keys(this.address).length > 0) return
  150. this.$store.dispatch('getInfo', {
  151. url: '/user/getReceiverInfo',
  152. name: 'address'
  153. })
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. @import './style.scss';
  159. </style>