index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="confirm-layout">
  3. <div class="confirm-title">确认订单</div>
  4. <div class="box-con">
  5. <div class="bc-title">收货地址</div>
  6. <div class="bc-item address-item" :class="{'is-active': item.id === address.id}" v-for="item in addressList" :key="item.id" @click="address = item">
  7. <div class="bc-ct">
  8. <div class="bc-contact">
  9. {{item.shipName}}
  10. <div>{{item.shipMobile}}</div>
  11. </div>
  12. <div class="bc-locotion">
  13. {{`${item.shipAreaPath}${item.shipAddress}`}}
  14. </div>
  15. </div>
  16. </div>
  17. <div class="noaddress" v-if="addressList.length < 3">
  18. <p @click="$router.push({name: 'addressCreate'})"><h-icon type="jiahao" />新增收货地址</p>
  19. </div>
  20. </div>
  21. <div class="box-con">
  22. <div class="bc-title">发票信息</div>
  23. <div class="invoice-con" :class="{'invoice-focus':selected}">
  24. <div class="invoice-select" @click="selected=!selected">
  25. <div class="select-txt">{{selectedTxt}}</div>
  26. <i class="iconfont icon-xia"></i>
  27. </div>
  28. <ul class="invoice-item" :class="{'invoice-active':selected}">
  29. <li v-for="(item,i) in invoiceType" :key="i" @click="handleItem(item)">{{item.name}}</li>
  30. </ul>
  31. <cinvoices v-if="selectedId!==1" :invoice='invoice2' :selectedId='selectedId' :invoicet="invoice3" @showInvoice="data=>{showinvoice=data}" :token="token" @closeInvoice="data=>{isShowInvoice=data}"/>
  32. </div>
  33. </div>
  34. <div class="box-con">
  35. <div class="bc-title">商品信息</div>
  36. <div class="confirm-products">
  37. <div class="confirm-products-item" v-for="(item,i) in payinfo.goods" :key="i">
  38. <div class="product-thumb" :style="{'background-image': `url(${pictures[item.goodsId]})`}">
  39. <!-- <img :src="" alt=""> -->
  40. </div>
  41. <div class="product-info">
  42. <div class="product-name">
  43. <p class="img-p">{{cameraName[item.goodsId]}}</p>
  44. </div>
  45. <ul>
  46. <li class="product-name" v-for="(item,i) in detail[item.goodsId]" :key="i">{{item}}</li>
  47. </ul>
  48. <div class="product-count">
  49. <span class="product-price">¥{{item.price}} x {{item.goodsCount}}</span>
  50. <span class="product-sum fr">¥{{item.price*item.goodsCount}}</span>
  51. </div>
  52. </div>
  53. </div>
  54. <div class="cart-table-count">
  55. <div class="cart-table-count-item">
  56. <span class="title">商品总价:</span>
  57. <span class="price">¥{{getSum()[1]}}</span>
  58. </div>
  59. <div class="cart-table-count-item">
  60. <span class="title">税费及其他费用:</span>
  61. <span class="price">
  62. ¥0
  63. </span>
  64. </div>
  65. <div class="cart-table-count-item">
  66. <span class="title">运费:</span>
  67. <span class="price">
  68. <span class="free-shipping">
  69. ¥0
  70. </span>
  71. </span>
  72. </div>
  73. <div class="cart-table-total cart-table-count-item">
  74. <span class="total-title">合计:</span>
  75. <span class="total-price">¥{{getSum()[1]}}</span>
  76. </div>
  77. </div>
  78. <!-- <div class="xieyi"><input type="checkbox" />我已阅读并同意四维看看用户协议</div> -->
  79. </div>
  80. <div class="btn-confirm" @click="next()">付款</div>
  81. </div>
  82. </div>
  83. </template>
  84. <script>
  85. import { mapState } from 'vuex'
  86. import cinvoices from '@/components/cinvoices'
  87. var cloneObj = function (obj) {
  88. var newObj = {}
  89. if (obj instanceof Array) {
  90. newObj = []
  91. }
  92. for (var key in obj) {
  93. var val = obj[key] || ''
  94. newObj[key] = typeof val === 'object' ? cloneObj(val) : val
  95. }
  96. return newObj
  97. }
  98. export default {
  99. components: {
  100. cinvoices,
  101. showinvoice: true
  102. },
  103. computed: {
  104. ...mapState({
  105. token: state => state.user.token,
  106. invoice2: state => {
  107. let type = Object.prototype.toString.call(state.user.invoice2)
  108. if (type === '[object Object]') {
  109. return state.user.invoice2
  110. }
  111. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  112. return (condition ? JSON.parse(state.user.invoice2) : {})
  113. },
  114. invoice3: state => {
  115. let type = Object.prototype.toString.call(state.user.invoice3)
  116. if (type === '[object Object]') {
  117. return state.user.invoice3
  118. }
  119. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  120. return (condition ? JSON.parse(state.user.invoice3) : {})
  121. },
  122. payinfo: state => {
  123. let type = Object.prototype.toString.call(state.user.payinfo)
  124. if (type === '[object Object]') {
  125. return state.user.payinfo
  126. }
  127. let condition = state.user.payinfo && state.user.payinfo !== 'null' && type !== '[object Array]'
  128. return condition ? JSON.parse(state.user.payinfo) : {}
  129. },
  130. // address: state => cloneObj(state.user.address) || {},
  131. addressList: state => state.user.addressList
  132. })
  133. },
  134. data () {
  135. let invoiceType = [{
  136. id: 1,
  137. name: '不需要发票'
  138. }, {
  139. id: 2,
  140. name: '增值税普票(电子发票)'
  141. }, {
  142. id: 3,
  143. name: '增值税专用发票'
  144. }]
  145. let pictures = {
  146. 7: `${this.$cdn}images/zhijia.png`,
  147. 1: `${this.$cdn}images/t_product.png`,
  148. 4: `${this.$cdn}images/banner_pro.png`
  149. }
  150. let cameraName = {
  151. 7: `四维看看 三脚架套装`,
  152. 1: `四维看看 Lite二目相机`,
  153. 4: `四维看看 Pro八目相机`
  154. }
  155. let detail = {
  156. 7: ['四维看看 三脚架套装(标准色)'],
  157. 1: [
  158. '四维看看 Lite二目相机(静谧黑)',
  159. '容量套餐(5G/5年)',
  160. '四维看看 Lite专用三脚架(标准色)'
  161. ],
  162. 4: ['四维看看 Pro八目相机(静谧黑)', '容量套餐(10G)']
  163. }
  164. return {
  165. pictures,
  166. cameraName,
  167. detail,
  168. invoiceType,
  169. selected: false,
  170. selectedTxt: '不需要发票',
  171. selectedId: 1,
  172. isShowAddress: true,
  173. showinvoice: true,
  174. address: cloneObj({})
  175. }
  176. },
  177. methods: {
  178. handleItem (item) {
  179. this.selectedTxt = item.name
  180. this.selectedId = item.id
  181. this.selected = false
  182. },
  183. next () {
  184. if (!this.address.shipName) {
  185. return this.$toast.show('warn', '请先填写收货地址')
  186. }
  187. if (!this.isShowAddress) {
  188. return this.$toast.show('warn', '请先保存收货信息')
  189. }
  190. if (!this.showinvoice && this.selectedId !== 1) {
  191. return this.$toast.show('warn', '请先保存发票信息')
  192. }
  193. let temp = cloneObj(this.payinfo)
  194. let invoice = this.selectedId === 2 ? this.invoice2 : this.selectedId === 3 ? this.invoice3 : null
  195. temp['invoice'] = invoice
  196. temp['receiver'] = this.address
  197. temp['selectedId'] = this.selectedId
  198. temp['selectedTxt'] = this.selectedTxt
  199. this.$store.commit('PAYINFO', temp)
  200. this.$router.push({path: '/paytype'})
  201. },
  202. getSum () {
  203. let sum = 0
  204. let count = 0
  205. this.payinfo.goods && this.payinfo.goods.forEach(item => {
  206. sum += item.goodsCount * item.price
  207. count += item.goodsCount
  208. })
  209. return [count, sum]
  210. }
  211. },
  212. async mounted () {
  213. this.selectedId = this.payinfo.selectedId ? this.payinfo.selectedId : 1
  214. this.selectedTxt = this.payinfo.selectedTxt ? this.payinfo.selectedTxt : '不需要发票'
  215. this.$store.dispatch('getInfo', {
  216. url: '/user/getReceiverInfo',
  217. name: 'address'
  218. })
  219. await this.$store.dispatch('updateAddressList')
  220. this.address = this.addressList[0]
  221. }
  222. }
  223. </script>
  224. <style lang="scss" scoped>
  225. @import './style.scss';
  226. .confirm-products-item {
  227. display: flex;
  228. padding: 10px 0 17px;
  229. border-bottom: 1px solid #EBEBEB;
  230. }
  231. .confirm-title {
  232. font-size: 14px;
  233. font-weight: bold;
  234. padding: 27px 0 17px 20px;
  235. line-height: 21px;
  236. border-bottom: 1px solid #EBEBEB;
  237. }
  238. .product-thumb {
  239. width: 60px;
  240. height: 60px;
  241. background-repeat: no-repeat;
  242. background-size: auto 100%;
  243. background-position: center center;
  244. border: 1px solid #EBEBEB;
  245. margin-right: 10px;
  246. }
  247. .product-info {
  248. font-size: 12px;
  249. color: #202020;
  250. flex: 1;
  251. ul {
  252. height: 46px;
  253. }
  254. .product-name {
  255. color: #909090;
  256. line-height: 18px;
  257. .img-p {
  258. font-size: 14px;
  259. font-weight: bold;
  260. line-height: 21px;
  261. margin-bottom: 3px;
  262. color: #202020;
  263. }
  264. }
  265. }
  266. .cart-table-count {
  267. text-align: right;
  268. padding-top: 17px;
  269. .cart-table-count-item {
  270. margin-bottom: 4px;
  271. line-height: 18px;
  272. }
  273. .cart-table-total {
  274. font-size: 14px;
  275. font-weight: bold;
  276. margin-top: 13px;
  277. line-height: 20px;
  278. }
  279. }
  280. </style>