detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <div>
  3. <div class="detail-layout">
  4. <div class="detail-header">
  5. <div class="c-title">确认订单</div>
  6. <i v-if="fromList" @click="backHandle" class="iconfont icon-shang"></i>
  7. <i v-else @click="closeHandle" class="iconfont right icon-cuowu"></i>
  8. </div>
  9. <edit
  10. :name="'收货信息'"
  11. @clickOper="handleOper('addressStatus')"
  12. :oper="addressStatus?'编辑':'收起'"
  13. :isActive="addressStatus"
  14. class="edit-item"
  15. >
  16. <div class="address show-address" slot="show">
  17. <img src="@/assets/images/address-icon.png" alt>
  18. <div>
  19. <p>{{address.shipName}}</p>
  20. <p class="p-desc">{{`${address.shipAreaPath}${address.shipAddress}`}}</p>
  21. </div>
  22. </div>
  23. <div class="address edit-address" slot="edit">
  24. <div class="input-con">
  25. <input type="text" v-model="editAdd.shipName" :placeholder="address.shipName||'姓名'">
  26. <input type="text" v-model="editAdd.shipMobile" :placeholder="address.shipMobile||'电话'">
  27. </div>
  28. <div class="input-con">
  29. <citySelect :areaPath="editAdd.shipAreaPath" @currentVal="getCurrentSelect"/>
  30. </div>
  31. <div class="input-con address-input">
  32. <input
  33. type="text"
  34. v-model="editAdd.shipAddress"
  35. :placeholder="editAdd.shipAddress||'详细地址'"
  36. >
  37. </div>
  38. <div class="btn parmary" @click="uAddress">保存</div>
  39. </div>
  40. </edit>
  41. <div class="pay-type">
  42. <div class="title">支付方式</div>
  43. <div class="body">
  44. <div class="pay-tag" :class="{'tag-active':paytype===1}" @click="paytype=1">
  45. <img src="@/assets/images/ali-pay.png" class="t-icon" alt>
  46. <span>支付宝</span>
  47. <img src="@/assets/images/tag-icon.png" class="t-click" alt>
  48. </div>
  49. <div class="pay-tag" :class="{'tag-active':paytype===0}" @click="paytype=0">
  50. <img src="@/assets/images/wechat-pay.png" class="t-icon" alt>
  51. <span>微信支付</span>
  52. <img src="@/assets/images/tag-icon.png" class="t-click" alt>
  53. </div>
  54. <div class="pay-tag" :class="{'tag-active':paytype===2}" @click="paytype=2">
  55. <img src="@/assets/images/paypal.png" class="t-icon" alt>
  56. <span>paypal</span>
  57. <img src="@/assets/images/tag-icon.png" class="t-click" alt>
  58. </div>
  59. </div>
  60. </div>
  61. <edit
  62. :name="'我的发票抬头'"
  63. @clickOper="handleOper('invoiceStatus')"
  64. :oper="invoiceStatus?'编辑':'收起'"
  65. :isActive="invoiceStatus"
  66. class="edit-item"
  67. >
  68. <div class="invoice invoice-address" slot="show">
  69. <div class="select-con">
  70. <div :class="{'tag-active':invoice==='noinvoice'}" @click="invoice='noinvoice'">
  71. <span>不需要发票</span>
  72. <img src="@/assets/images/tag-icon.png" alt>
  73. </div>
  74. <div :class="{'tag-active':invoice==='normal'}" @click="invoice='normal'">
  75. <span>增值税普通发票</span>
  76. <img src="@/assets/images/tag-icon.png" alt>
  77. </div>
  78. <div :class="{'tag-active':invoice==='zengzhi'}" @click="invoice='zengzhi'">
  79. <span>增值税专用发票</span>
  80. <i></i>
  81. <img src="@/assets/images/tag-icon.png" alt>
  82. </div>
  83. </div>
  84. <div class="invoice-detail" v-if="invoice==='normal'">
  85. <template v-if="!invoice2.title">
  86. <p class="p-desc">暂无信息</p>
  87. </template>
  88. <template v-else>
  89. <p>{{invoice2.title}}</p>
  90. <p class="p-desc">{{invoice2.code}}</p>
  91. </template>
  92. </div>
  93. <div class="invoice-detail" v-if="invoice==='zengzhi'">
  94. <template v-if="!invoice3.title">
  95. <p class="p-desc">暂无信息</p>
  96. </template>
  97. <template v-else>
  98. <p>{{invoice3.title}}</p>
  99. <p class="p-desc">{{invoice3.code}}</p>
  100. <p class="p-desc">{{invoice3.organizedAddress}}</p>
  101. <p class="p-desc">{{invoice3.registerPhone}}</p>
  102. <p class="p-desc">{{invoice3.bankName}}</p>
  103. <p class="p-desc">{{invoice3.bankAccount}}</p>
  104. </template>
  105. </div>
  106. </div>
  107. <div class="invoice edit-invoice" slot="edit">
  108. <div class="select-con">
  109. <div :class="{'tag-active':invoice==='normal'}" @click="invoice='normal'">
  110. <span>增值税普通发票</span>
  111. <img src="@/assets/images/tag-icon.png" alt>
  112. </div>
  113. <div :class="{'tag-active':invoice==='zengzhi'}" @click="invoice='zengzhi'">
  114. <span>增值税专用发票</span>
  115. <i></i>
  116. <img src="@/assets/images/tag-icon.png" alt>
  117. </div>
  118. </div>
  119. <div class="invoice-input" v-if="invoice==='normal'">
  120. <div class="input-con">
  121. <input type="text" placeholder="请输入发票抬头" v-model="editInvoice2.title">
  122. <input type="text" placeholder="请输入税务登记号(个人用户可不填)" v-model="editInvoice2.code">
  123. </div>
  124. </div>
  125. <div class="invoice-input" v-if="invoice==='zengzhi'">
  126. <div class="input-con">
  127. <input type="text" v-model="editInvoice3.title" placeholder="请输入发票抬头">
  128. <input type="text" v-model="editInvoice3.code" placeholder="请输入税务登记号(个人用户可不填)">
  129. </div>
  130. <div class="input-con">
  131. <input type="text" v-model="editInvoice3.organizedAddress" placeholder="注册地址">
  132. <input type="text" v-model="editInvoice3.registerPhone" placeholder="注册电话">
  133. </div>
  134. <div class="input-con">
  135. <input type="text" v-model="editInvoice3.bankName" placeholder="开户银行">
  136. <input type="text" v-model="editInvoice3.bankAccount" placeholder="银行账户">
  137. </div>
  138. </div>
  139. <div @click="saveInvoice(invoice)" class="btn parmary">保存</div>
  140. </div>
  141. </edit>
  142. <div class="express-type">
  143. <div class="title">物流方式</div>
  144. <img class="express-img" src="@/assets/images/sf-express.png" alt>
  145. </div>
  146. <div class="product-type">
  147. <div class="title">商品信息</div>
  148. <div class="p-info" v-for="(item,i) in sku" :key="i">
  149. <img :src="item.goodsId===4?`${$cdn}images/banner_pro.png`:`${$cdn}images/t_product.png`" alt>
  150. <div class="p-params">
  151. <h3>{{item.goodsId === 4?'四维看看 Pro':'四维看看 Lite'}}</h3>
  152. <p>本机主体 x {{item.goodsCount}}, 拍摄支架 x {{item.goodsCount}}</p>
  153. </div>
  154. <div class="p-price">¥ {{item.price}}</div>
  155. </div>
  156. <div class="p-detail">
  157. <div>
  158. <span>商品总价:</span>
  159. <span>¥{{getSum()[1]}}</span>
  160. </div>
  161. <div>
  162. <span>税费及其他费用:</span>
  163. <span>¥0</span>
  164. </div>
  165. <div>
  166. <span>运费:</span>
  167. <span>¥0</span>
  168. </div>
  169. <div>
  170. <span>合计:</span>
  171. <span>¥{{getSum()[1]}}</span>
  172. </div>
  173. </div>
  174. <div class="p-pay">
  175. <div class="agree" @click="agree=~agree">
  176. <span>
  177. <img v-if="agree" src="@/assets/images/icon-click.png" alt="">
  178. </span>
  179. <span>同意商城销售协议</span>
  180. </div>
  181. <div class="c-button purchase" @click="pay">付款</div>
  182. </div>
  183. </div>
  184. </div>
  185. </div>
  186. </template>
  187. <script>
  188. import vcenter from '@/components/vcenter'
  189. import edit from '@/components/edit'
  190. import citySelect from '@/components/citySelect'
  191. import { mapState } from 'vuex'
  192. var cloneObj = function (obj) {
  193. var newObj = {}
  194. if (obj instanceof Array) {
  195. newObj = []
  196. }
  197. for (var key in obj) {
  198. var val = obj[key] || ''
  199. newObj[key] = typeof val === 'object' ? cloneObj(val) : val
  200. }
  201. return newObj
  202. }
  203. export default {
  204. props: ['sku', 'fromList'],
  205. data () {
  206. return {
  207. agree: -1,
  208. addressStatus: true,
  209. tempSelect: '',
  210. invoiceStatus: true,
  211. invoice: 'noinvoice',
  212. paytype: 0
  213. }
  214. },
  215. components: {
  216. vcenter,
  217. edit,
  218. citySelect
  219. },
  220. computed: {
  221. ...mapState({
  222. invoice2: state => {
  223. let type = Object.prototype.toString.call(state.user.invoice2)
  224. if (type === '[object Object]') {
  225. return state.user.invoice2
  226. }
  227. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  228. return (condition ? JSON.parse(state.user.invoice2) : {})
  229. },
  230. editInvoice2: state => {
  231. let type = Object.prototype.toString.call(state.user.invoice2)
  232. if (type === '[object Object]') {
  233. return state.user.invoice2
  234. }
  235. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  236. return cloneObj(condition ? JSON.parse(state.user.invoice2) : {})
  237. },
  238. invoice3: state => {
  239. let type = Object.prototype.toString.call(state.user.invoice3)
  240. if (type === '[object Object]') {
  241. return state.user.invoice3
  242. }
  243. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  244. return (condition ? JSON.parse(state.user.invoice3) : {})
  245. },
  246. editInvoice3: state => {
  247. let type = Object.prototype.toString.call(state.user.invoice3)
  248. if (type === '[object Object]') {
  249. return state.user.invoice3
  250. }
  251. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  252. return cloneObj(condition ? JSON.parse(state.user.invoice3) : {})
  253. },
  254. token: state => state.user.token,
  255. address: state => state.user.address || {},
  256. editAdd: state => cloneObj(state.user.address) || {},
  257. language: state => state.language.current
  258. })
  259. },
  260. methods: {
  261. backHandle () {
  262. this.$emit('backList')
  263. },
  264. closeHandle () {
  265. this.$bus.$emit('hideAside')
  266. },
  267. handleOper (type) {
  268. if (type === 'invoiceStatus') {
  269. this.invoice === 'noinvoice' ? this[type] = true : this[type] = !this[type]
  270. } else {
  271. this[type] = !this[type]
  272. }
  273. },
  274. uAddress () {
  275. this.editAdd.province = this.tempSelect[0]
  276. this.editAdd.city = this.tempSelect[1]
  277. this.editAdd.shipAreaPath = this.tempSelect.join(',')
  278. let {
  279. shipAddress,
  280. shipAreaPath,
  281. province,
  282. city,
  283. shipMobile,
  284. shipName
  285. } = this.editAdd
  286. let params = {
  287. shipAddress,
  288. shipAreaPath,
  289. province,
  290. city,
  291. shipMobile,
  292. shipName
  293. }
  294. this.$http
  295. .post('/user/updateAddress', params, {
  296. headers: {
  297. token: this.token
  298. }
  299. })
  300. .then(data => {
  301. this.addressStatus = true
  302. this.$store.dispatch('getInfo', {
  303. url: '/user/getReceiverInfo',
  304. name: 'address'
  305. })
  306. })
  307. },
  308. getCurrentSelect (data) {
  309. this.tempSelect = data
  310. },
  311. getSum () {
  312. let sum = 0
  313. let count = 0
  314. this.sku.forEach(item => {
  315. sum += item.goodsCount * item.price
  316. count += item.goodsCount
  317. })
  318. return [count, sum]
  319. },
  320. async pay () {
  321. if (!this.agree) {
  322. return this.$toast.show('warn', '请同意条款')
  323. }
  324. let invoice = this.invoice === 'normal' ? this.invoice2 : this.invoice === 'zengzhi' ? this.invoice3 : null
  325. let params = {
  326. goods: this.sku,
  327. receiver: this.address,
  328. invoice: invoice,
  329. payType: this.paytype,
  330. abroad: this.language === 'en' ? 1 : 0
  331. }
  332. let res = await this.$http
  333. .post('user/order/placeOrder', params, {
  334. headers: {
  335. token: this.token
  336. }
  337. })
  338. this.$bus.$emit('hideAside')
  339. this.$store.dispatch('getCart')
  340. this.$router.push({name: 'pay',
  341. params: {
  342. payType: this.paytype,
  343. orderId: res.data.data.id,
  344. orderType: 0,
  345. orderSn: res.data.data.orderSn
  346. }})
  347. },
  348. saveInvoice (cInvoice) {
  349. let params = {}
  350. let invoiceType = ''
  351. if (cInvoice === 'normal') {
  352. invoiceType = 2
  353. params = {
  354. invoiceType,
  355. title: this.editInvoice2.title,
  356. code: this.editInvoice2.code
  357. }
  358. } else {
  359. let {title, code, organizedAddress, registerPhone, bankName, bankAccount} = this.editInvoice3
  360. invoiceType = 3
  361. params = {
  362. invoiceType,
  363. title,
  364. code,
  365. organizedAddress,
  366. registerPhone,
  367. bankName,
  368. bankAccount
  369. }
  370. }
  371. this.$http
  372. .post('user/invoice/save', params, {
  373. headers: {
  374. token: this.token
  375. }
  376. })
  377. .then(data => {
  378. this.invoiceStatus = true
  379. this.$store.dispatch('getInvoice', {
  380. type: invoiceType,
  381. params: {
  382. invoiceType: invoiceType
  383. }
  384. })
  385. })
  386. }
  387. },
  388. mounted () {
  389. if (this.address && Object.keys(this.address).length > 0) return
  390. this.$store.dispatch('getInfo', {
  391. url: '/user/getReceiverInfo',
  392. name: 'address'
  393. })
  394. }
  395. }
  396. </script>
  397. <style lang="scss" scoped>
  398. @import "./detail.scss";
  399. </style>