detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625
  1. <template>
  2. <div>
  3. <div class="detail-layout" ref="detaillayout">
  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 @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="`${$cdn}images/address-icon.png`" alt>
  18. <template v-if="address.shipName">
  19. <div>
  20. <p>{{address.shipName}}</p>
  21. <p class="p-desc">{{`${address.shipAreaPath}${address.shipAddress}`}}</p>
  22. </div>
  23. </template>
  24. <template v-else>
  25. <div class="p-desc no-info">暂无信息</div>
  26. </template>
  27. </div>
  28. <div class="address edit-address" slot="edit">
  29. <div class="input-con">
  30. <input type="text" v-model="editAdd.shipName" :placeholder="'姓名'">
  31. <input type="text" v-model="editAdd.shipMobile" :placeholder="'电话'">
  32. </div>
  33. <div class="input-con">
  34. <citySelect :areaPath="editAdd.shipAreaPath" @currentVal="getCurrentSelect"/>
  35. </div>
  36. <div class="input-con address-input">
  37. <input
  38. type="text"
  39. v-model="editAdd.shipAddress"
  40. :placeholder="'详细地址'"
  41. >
  42. </div>
  43. <div class="btn parmary" @click="uAddress">保存</div>
  44. </div>
  45. </edit>
  46. <edit
  47. :name="'我的发票抬头'"
  48. @clickOper="handleOper('invoiceStatus')"
  49. :oper="invoiceStatus?'编辑':'收起'"
  50. :isActive="invoiceStatus"
  51. class="edit-item"
  52. style="padding:0 30px 20px"
  53. >
  54. <div class="invoice invoice-address" slot="show">
  55. <div class="select-con">
  56. <div :class="{'tag-active':invoice==='noinvoice'}" @click="invoice='noinvoice'">
  57. <span>不需要发票</span>
  58. <img :src="`${$cdn}images/tag-icon.png`" alt>
  59. </div>
  60. <div :class="{'tag-active':invoice==='normal'}" @click="invoice='normal'">
  61. <span>增值税普票(电子发票)</span>
  62. <img :src="`${$cdn}images/tag-icon.png`" alt>
  63. </div>
  64. <div :class="{'tag-active':invoice==='zengzhi'}" @click="invoice='zengzhi'">
  65. <span>增值税专用发票</span>
  66. <i></i>
  67. <img :src="`${$cdn}images/tag-icon.png`" alt>
  68. </div>
  69. </div>
  70. <div class="invoice-detail" v-if="invoice==='normal'">
  71. <template v-if="!invoice2.title">
  72. <p class="p-desc">暂无信息</p>
  73. </template>
  74. <template v-else>
  75. <p>{{invoice2.title}}</p>
  76. <p class="p-desc">{{invoice2.code}}</p>
  77. <p class="p-desc">{{invoice2.emailAddress}}</p>
  78. </template>
  79. </div>
  80. <div class="invoice-detail" v-if="invoice==='zengzhi'">
  81. <template v-if="!invoice3.title">
  82. <p class="p-desc">暂无信息</p>
  83. </template>
  84. <template v-else>
  85. <p>{{invoice3.title}}</p>
  86. <p class="p-desc">{{invoice3.code}}</p>
  87. <p class="p-desc">{{invoice3.organizedAddress}}</p>
  88. <p class="p-desc">{{invoice3.registerPhone}}</p>
  89. <p class="p-desc">{{invoice3.bankName}}</p>
  90. <p class="p-desc">{{invoice3.bankAccount}}</p>
  91. </template>
  92. </div>
  93. </div>
  94. <div class="invoice edit-invoice" slot="edit">
  95. <div class="select-con">
  96. <div :class="{'tag-active':invoice==='normal'}" @click="invoice='normal'">
  97. <span>增值税普票(电子发票)</span>
  98. <img :src="`${$cdn}images/tag-icon.png`" alt>
  99. </div>
  100. <div :class="{'tag-active':invoice==='zengzhi'}" @click="invoice='zengzhi'">
  101. <span>增值税专用发票</span>
  102. <i></i>
  103. <img :src="`${$cdn}images/tag-icon.png`" alt>
  104. </div>
  105. </div>
  106. <div class="invoice-input" v-if="invoice==='normal'">
  107. <div class="input-con">
  108. <input type="text" placeholder="请输入发票抬头" maxlength="20" v-model="editInvoice2.title">
  109. <input type="text" placeholder="请输入18位税务登记号" oninput="value=value.replace(/[^\w\.\/]/ig,'')" maxlength='18' v-model="editInvoice2.code">
  110. </div>
  111. <div class="input-con">
  112. <input type="text" placeholder="请输入电子邮箱" maxlength="30" v-model="editInvoice2.emailAddress">
  113. </div>
  114. </div>
  115. <div class="invoice-input" v-if="invoice==='zengzhi'">
  116. <div class="input-con">
  117. <input type="text" v-model="editInvoice3.title" maxlength="20" placeholder="请输入发票抬头">
  118. <input type="text" maxlength='18' v-model="editInvoice3.code" oninput="value=value.replace(/[^\w\.\/]/ig,'')" placeholder="请输入18位税务登记号">
  119. </div>
  120. <div class="input-con">
  121. <input type="text" maxlength="100" v-model="editInvoice3.organizedAddress" placeholder="注册地址">
  122. <input type="text" maxlength="20" oninput="value=value.replace(/[^\d\-]/g,'')" v-model="editInvoice3.registerPhone" placeholder="注册电话">
  123. </div>
  124. <div class="input-con">
  125. <input type="text" maxlength="40" v-model="editInvoice3.bankName" placeholder="开户银行">
  126. <input type="text" maxlength="40" v-model="editInvoice3.bankAccount" placeholder="银行账户">
  127. </div>
  128. </div>
  129. <div @click="saveInvoice(invoice)" class="btn parmary">保存</div>
  130. </div>
  131. </edit>
  132. <div class="express-type">
  133. <div class="title">物流方式</div>
  134. <img class="express-img" :src="`${$cdn}images/sf-express.png`" alt>
  135. </div>
  136. <div class="product-type">
  137. <div class="title">商品信息</div>
  138. <div class="p-info" v-for="(item,i) in sku" :key="i">
  139. <div class="p-img">
  140. <div class="pi-con">
  141. <img :src="pictures[item.goodsId]">
  142. </div>
  143. </div>
  144. <div class="p-params">
  145. <h3>{{cameraName[item.goodsId]}}</h3>
  146. <ul>
  147. <li v-for="(sub,i) in detail[item.goodsId]" :key="i">
  148. <span>{{sub}}</span>
  149. <span style="margin-left:5px;">x{{item.goodsCount}}</span>
  150. </li>
  151. </ul>
  152. </div>
  153. <div>
  154. <div class="numAP">
  155. <i :class="{fobid:item.goodsCount<=1}" @click="operNum(item,'-')">-</i>
  156. <span>{{item.goodsCount}}</span>
  157. <i @click="operNum(item,'+')">+</i>
  158. </div>
  159. <div v-if="cannotdel['id']===item.goodsId&&cannotdel['status']" class="error-txt"><span>至少要购买1件</span></div>
  160. </div>
  161. <div class="oper">
  162. <span @click="rmItem(item)">移除</span>
  163. </div>
  164. <div class="p-price"><span>¥ {{item.price*item.goodsCount}}</span></div>
  165. </div>
  166. <div class="p-detail">
  167. <div>
  168. <span>商品总价:</span>
  169. <span>¥{{getSum()[1]}}</span>
  170. </div>
  171. <div>
  172. <span>税费及其他费用:</span>
  173. <span>¥0</span>
  174. </div>
  175. <div>
  176. <span>运费:</span>
  177. <span>¥0</span>
  178. </div>
  179. <div>
  180. <span>合计:</span>
  181. <span>¥{{getSum()[1]}}</span>
  182. </div>
  183. </div>
  184. <div class="p-pay">
  185. <div class="agree" @click="handleCluse">
  186. <span>
  187. <img v-if="showCluse" :src="`${$cdn}images/icon-click.png`" alt="">
  188. </span>
  189. <!-- <router-link class="jump-a" target="_blank" :to="{name: 'service_list', params: {id: 'clause', active: 'pro'}}">同意四维看看销售协议</router-link> -->
  190. <span>同意四维看看销售协议</span>
  191. </div>
  192. <div class="c-button purchase" :style="{backgroundColor:showCluse?'#1fe4dc':'#e2e2e2'}" @click="pay">付款</div>
  193. </div>
  194. </div>
  195. </div>
  196. </div>
  197. </template>
  198. <script>
  199. import vcenter from '@/components/vcenter'
  200. import edit from '@/components/edit'
  201. import citySelect from '@/components/citySelect'
  202. import { mapState } from 'vuex'
  203. import { reg } from '@/util'
  204. var cloneObj = function (obj) {
  205. var newObj = {}
  206. if (obj instanceof Array) {
  207. newObj = []
  208. }
  209. for (var key in obj) {
  210. var val = obj[key] || ''
  211. newObj[key] = typeof val === 'object' ? cloneObj(val) : val
  212. }
  213. return newObj
  214. }
  215. let cameraName = {
  216. 7: `四维看看 三脚架套装`,
  217. 1: `四维看看 Lite二目相机`,
  218. 4: `四维看看 Pro八目相机`
  219. }
  220. let cameraNameEn = {
  221. 7: `4D KanKan Pro Tripod Set`,
  222. 1: `四维看看 Lite二目相机`,
  223. 4: `4DKanKan Pro Camera`
  224. }
  225. let detail = {
  226. 7: ['四维看看 三脚架套装(标准色)'],
  227. 1: [
  228. '四维看看 Lite二目相机(静谧黑)',
  229. '容量套餐(5G)',
  230. '四维看看 Lite专用三脚架(标准色)'
  231. ],
  232. 4: ['四维看看 Pro八目相机(静谧黑)', '容量套餐(10G)']
  233. }
  234. let detailEn = {
  235. 7: ['4D KanKan Pro Tripod Set (Standard)'],
  236. 1: [
  237. '四维看看 Lite二目相机(静谧黑)',
  238. '容量套餐(5G)',
  239. '四维看看 Lite专用三脚架(标准色)'
  240. ],
  241. 4: ['4DKanKan Pro Camera (Night Sky Black)', 'Storage Plan (10G)']
  242. }
  243. export default {
  244. props: ['psku', 'fromList', 'active'],
  245. data () {
  246. let pictures = {
  247. 7: `${this.$cdn}images/zhijia.png`,
  248. 1: `${this.$cdn}images/withzhijia.png`,
  249. 4: `${this.$cdn}images/banner_pro.png`
  250. }
  251. return {
  252. showCluse: true,
  253. pictures,
  254. addressStatus: true,
  255. tempSelect: '',
  256. invoiceStatus: true,
  257. invoice: 'noinvoice',
  258. paytype: 0,
  259. cannotdel: {
  260. id: '',
  261. status: false
  262. }
  263. }
  264. },
  265. components: {
  266. vcenter,
  267. edit,
  268. citySelect
  269. },
  270. watch: {
  271. active (newVal) {
  272. this.$refs.detaillayout.scroll(0, 0)
  273. }
  274. },
  275. computed: {
  276. ...mapState({
  277. cameraName: state => {
  278. return state.language.current === 'en' ? cameraNameEn : cameraName
  279. },
  280. detail: state => {
  281. return state.language.current === 'en' ? detailEn : detail
  282. },
  283. invoice2: state => {
  284. let type = Object.prototype.toString.call(state.user.invoice2)
  285. if (type === '[object Object]') {
  286. return state.user.invoice2
  287. }
  288. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  289. return (condition ? JSON.parse(state.user.invoice2) : {})
  290. },
  291. editInvoice2: state => {
  292. let type = Object.prototype.toString.call(state.user.invoice2)
  293. if (type === '[object Object]') {
  294. return state.user.invoice2
  295. }
  296. let condition = state.user.invoice2 && state.user.invoice2 !== 'null' && type !== '[object Array]'
  297. return cloneObj(condition ? JSON.parse(state.user.invoice2) : {})
  298. },
  299. invoice3: state => {
  300. let type = Object.prototype.toString.call(state.user.invoice3)
  301. if (type === '[object Object]') {
  302. return state.user.invoice3
  303. }
  304. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  305. return (condition ? JSON.parse(state.user.invoice3) : {})
  306. },
  307. editInvoice3: state => {
  308. let type = Object.prototype.toString.call(state.user.invoice3)
  309. if (type === '[object Object]') {
  310. return state.user.invoice3
  311. }
  312. let condition = state.user.invoice3 && state.user.invoice3 !== 'null' && type !== '[object Array]'
  313. return cloneObj(condition ? JSON.parse(state.user.invoice3) : {})
  314. },
  315. token: state => state.user.token,
  316. address: state => state.user.address || {},
  317. langToast: state => state.language.home.toast,
  318. editAdd: state => cloneObj(state.user.address) || {},
  319. language: state => state.language.current
  320. }),
  321. sku () {
  322. return this.psku
  323. }
  324. },
  325. methods: {
  326. handleCluse () {
  327. this.showCluse = !this.showCluse
  328. this.$bus.$emit('openClause', {
  329. show: this.showCluse,
  330. type: 'cart'
  331. })
  332. },
  333. rmItem (item) {
  334. let arr = []
  335. this.sku.forEach(sub => {
  336. if (sub.goodsId !== item.goodsId) {
  337. arr.push(sub)
  338. }
  339. })
  340. arr.length <= 0 ? this.$toast.show('warn', this.langToast['14']) : this.$toast.showConfirm('warn', this.langToast['15'], () => {
  341. this.$emit('fixSku', arr)
  342. })
  343. },
  344. operNum (item, type) {
  345. if (item.goodsCount <= 1 && type === '-') {
  346. this.cannotdel = {
  347. id: item.goodsId,
  348. status: true
  349. }
  350. } else {
  351. let arr = []
  352. this.sku.forEach(sub => {
  353. if (sub.goodsId === item.goodsId) {
  354. sub['goodsCount'] = type === '+' ? ++item.goodsCount : --item.goodsCount
  355. }
  356. arr.push(sub)
  357. })
  358. this.cannotdel = {
  359. id: item.goodsId,
  360. status: false
  361. }
  362. this.$emit('fixSku', arr)
  363. }
  364. },
  365. backHandle () {
  366. this.$emit('backList')
  367. },
  368. closeHandle () {
  369. this.$bus.$emit('hideAside')
  370. },
  371. handleOper (type) {
  372. if (type === 'invoiceStatus') {
  373. this.invoice === 'noinvoice' ? this[type] = true : this[type] = !this[type]
  374. } else {
  375. this[type] = !this[type]
  376. }
  377. },
  378. uAddress () {
  379. this.editAdd.province = this.tempSelect[0]
  380. this.editAdd.city = this.tempSelect[1]
  381. this.editAdd.shipAreaPath = this.tempSelect.join(',')
  382. let {
  383. shipAddress,
  384. shipAreaPath,
  385. province,
  386. city,
  387. shipMobile,
  388. shipName
  389. } = this.editAdd
  390. let params = {
  391. shipAddress,
  392. shipAreaPath,
  393. province,
  394. city,
  395. shipMobile,
  396. shipName
  397. }
  398. this.$http
  399. .post('/user/updateAddress', params, {
  400. headers: {
  401. token: this.token
  402. }
  403. })
  404. .then(data => {
  405. this.addressStatus = true
  406. this.$store.dispatch('getInfo', {
  407. url: '/user/getReceiverInfo',
  408. name: 'address'
  409. })
  410. })
  411. },
  412. getCurrentSelect (data) {
  413. this.tempSelect = data
  414. },
  415. getSum () {
  416. let sum = 0
  417. let count = 0
  418. this.sku.forEach(item => {
  419. sum += item.goodsCount * item.price
  420. count += item.goodsCount
  421. })
  422. return [count, sum]
  423. },
  424. async pay () {
  425. if (!this.showCluse) {
  426. return
  427. }
  428. if (!this.invoiceStatus) {
  429. return this.$toast.show('warn', this.langToast['17'])
  430. }
  431. if (!this.addressStatus) {
  432. return this.$toast.show('warn', this.langToast['18'])
  433. }
  434. if (this.invoice === 'normal' && !this.invoice2.title) {
  435. return this.$toast.show('warn', this.langToast['20'])
  436. }
  437. if (this.invoice === 'zengzhi' && !this.invoice3.title) {
  438. return this.$toast.show('warn', this.langToast['20'])
  439. }
  440. if (!this.address.shipName) {
  441. return this.$toast.show('warn', this.langToast['19'])
  442. }
  443. let invoice = this.invoice === 'normal' ? this.invoice2 : this.invoice === 'zengzhi' ? this.invoice3 : null
  444. if (invoice) {
  445. invoice['invoiceType'] = invoice['type']
  446. }
  447. let params = {
  448. goods: this.sku,
  449. receiver: this.address,
  450. invoice: invoice,
  451. payType: this.paytype,
  452. abroad: this.language === 'en' ? 1 : 0
  453. }
  454. let res = await this.$http
  455. .post('user/order/placeOrder', params, {
  456. headers: {
  457. token: this.token
  458. }
  459. })
  460. this.$bus.$emit('hideAside')
  461. this.$store.dispatch('getCart')
  462. this.$router.push({name: 'pay',
  463. params: {
  464. payType: this.paytype,
  465. orderId: res.data.data.id,
  466. orderType: 0,
  467. orderSn: res.data.data.orderSn
  468. }})
  469. },
  470. saveInvoice (cInvoice) {
  471. let isObject = function (obj) {
  472. return JSON.stringify(obj) === '{}' ? '' : obj
  473. }
  474. let params = {}
  475. let invoiceType = ''
  476. let check = value => {
  477. for (let i = 0, len = value.length; i < len; i++) {
  478. if (!value[i].val) {
  479. return this.$toast.show('warn', (this.language === 'en' ? value[i].En : value[i].name) + this.langToast['7'])
  480. }
  481. }
  482. return true
  483. }
  484. if (cInvoice === 'normal') {
  485. invoiceType = 2
  486. let title = isObject(this.editInvoice2.title)
  487. let code = isObject(this.editInvoice2.code)
  488. let emailAddress = isObject(this.editInvoice2.emailAddress)
  489. if (code && code.length !== 18) {
  490. return this.$toast.show('warn', this.langToast['21'])
  491. }
  492. if (!reg.email.test(emailAddress)) {
  493. return this.$toast.show('warn', this.langToast['8'])
  494. }
  495. params = {
  496. invoiceType,
  497. title,
  498. code,
  499. emailAddress
  500. }
  501. let checkStr = [
  502. {
  503. name: '发票抬头',
  504. En: 'Title',
  505. val: title
  506. },
  507. {
  508. name: '电子邮箱',
  509. En: 'Email',
  510. val: emailAddress
  511. }
  512. ]
  513. if (!check(checkStr)) {
  514. return
  515. }
  516. } else {
  517. let {title: title1, code: code1, organizedAddress: organizedAddress1, registerPhone: registerPhone1, bankName: bankName1, bankAccount: bankAccount1} = this.editInvoice3
  518. invoiceType = 3
  519. let title = isObject(title1)
  520. let code = isObject(code1)
  521. let organizedAddress = isObject(organizedAddress1)
  522. let registerPhone = isObject(registerPhone1)
  523. let bankName = isObject(bankName1)
  524. let bankAccount = isObject(bankAccount1)
  525. params = {
  526. invoiceType,
  527. title,
  528. code,
  529. organizedAddress,
  530. registerPhone,
  531. bankName,
  532. bankAccount
  533. }
  534. let checkStr = [
  535. {
  536. name: '发票抬头',
  537. En: 'Title',
  538. val: title
  539. },
  540. {
  541. name: '税务登记号',
  542. En: 'Code',
  543. val: code
  544. },
  545. {
  546. name: '注册地址',
  547. En: 'Organized Address',
  548. val: organizedAddress
  549. },
  550. {
  551. name: '注册电话',
  552. En: 'Register Phone',
  553. val: registerPhone
  554. },
  555. {
  556. name: '开户银行',
  557. En: 'Bank Name',
  558. val: bankName
  559. },
  560. {
  561. name: '银行账号',
  562. En: 'Bank Account',
  563. val: bankAccount
  564. }
  565. ]
  566. if (!check(checkStr)) {
  567. return
  568. }
  569. if (!code || code.length !== 18) {
  570. return this.$toast.show('warn', this.langToast['21'])
  571. }
  572. if (!reg.guhua.test(registerPhone)) {
  573. return this.$toast.show('warn', this.langToast['22'])
  574. }
  575. }
  576. this.$http
  577. .post('user/invoice/save', params, {
  578. headers: {
  579. token: this.token
  580. }
  581. })
  582. .then(data => {
  583. this.invoiceStatus = true
  584. this.$store.dispatch('getInvoice', {
  585. type: invoiceType,
  586. params: {
  587. invoiceType: invoiceType
  588. }
  589. })
  590. })
  591. }
  592. },
  593. mounted () {
  594. this.$bus.$on('isAgree', data => {
  595. this.showCluse = data
  596. })
  597. if (this.address && Object.keys(this.address).length > 0) return
  598. this.$store.dispatch('getInfo', {
  599. url: '/user/getReceiverInfo',
  600. name: 'address'
  601. })
  602. }
  603. }
  604. </script>
  605. <style lang="scss" scoped>
  606. @import "./detail.scss";
  607. </style>