order.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  1. <template>
  2. <div class="order-layout">
  3. <div v-if="total">
  4. <div class="order-item" v-for="(item,i) in myorder.list" :key="i">
  5. <div class="o-top">{{langOrders.numbers}}{{item.orderSn}}</div>
  6. <div class="o-title">
  7. <span>{{langOrders.product}}</span>
  8. <span>{{langOrders.quantity}}</span>
  9. <span>{{langOrders.subtotal}}</span>
  10. </div>
  11. <div class="o-detail" v-for="(sub,index) in item.orderItems" :key="index">
  12. <div class="od-name">
  13. <img class="thumbnail" :src="sub.pic" alt>
  14. <div>
  15. <p>{{cameraName[sub.goodsId]}}</p>
  16. <p v-for="(sb,i) in detail[sub.goodsId]" :key="i" v-html="sb"></p>
  17. </div>
  18. </div>
  19. <div class="count">{{sub.goodsCount}}</div>
  20. <div class="sum">{{sub.goodsPrice*sub.goodsCount}}</div>
  21. </div>
  22. <div class="sum-price">
  23. <div></div>
  24. <div>{{langOrders.total}}{{item.goodsAmount}}</div>
  25. </div>
  26. <div class="inovice-con" :class="{'ic-active':item.showInvoice}">
  27. <div class="o-invoiceTitle">
  28. <span>{{langOrders.invoice}}</span>
  29. <span v-if="getStatus(item) !== 'shipped'" @click="edit"><i class="iconfont icon-edit"></i>{{langOrders.edit}}</span>
  30. <!-- <span v-else><i class="iconfont icon-choice"></i>发票已寄出</span> -->
  31. </div>
  32. <div class="o-invoice">
  33. <editInvoice :data="getItemInvoice(item)" :orderId='item.id' :invoiceId="item.invoice&&(item.invoice.id)"/>
  34. </div>
  35. </div>
  36. <div class="bottom-area">
  37. <div class="bottom-left">
  38. <template v-if="getStatus(item) === 'unpaid'">
  39. <span></span>
  40. </template>
  41. <template v-else-if="getStatus(item) === 'shipped'">
  42. <span class="expreeNum">{{langOrders.wlNum}}{{item.orderItems[0].expressNum}}</span>
  43. </template>
  44. <template v-else-if="getStatus(item) === 'unshipped'">
  45. <span class="expreeNum">{{langOrders.unshipped}}</span>
  46. </template>
  47. <template v-else-if="getStatus(item) === 'finish'">
  48. <span class="expreeNum">{{langOrders.finish}}</span>
  49. </template>
  50. <template v-else-if="getStatus(item) === 'partShipped'">
  51. <span class="expreeNum">{{langOrders.partShipped}}</span>
  52. </template>
  53. <template v-else-if="getStatus(item) === 'received'">
  54. <span class="expreeNum">{{langOrders.received}}:{{item.orderItems[0].expressNum}}</span>
  55. </template>
  56. <template v-else>
  57. <span class="expreeNum">{{langOrders.hasCancal}}</span>
  58. </template>
  59. </div>
  60. <div class="to-pay">
  61. <span class="cancel btns" @click="changeIvoiceStatus(i,item)">{{langOrders.invoice}}</span>
  62. <template v-if="getStatus(item) === 'unpaid'">
  63. <span class="cancel btns" @click="cancal(item)">{{langOrders.cancal}}</span>
  64. <span class="pay btns" @click="toPay(item)">{{langOrders.pay}}</span>
  65. </template>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div class="scene-nothing" v-else>
  71. <img :src="`${$cdn}images/nothing.png`" alt>
  72. <div>{{langOrders.norecord}}</div>
  73. </div>
  74. <div class="paging" v-if="total">
  75. <Paging @clickHandle="pageChange" @maxPage="data=>maxPage=data" :current="currentPage" :total="total" :equable="pageSize"/>
  76. </div>
  77. </div>
  78. </template>
  79. <script>
  80. import Vue from 'vue'
  81. import { mapState } from 'vuex'
  82. import Paging from '@/components/Paging'
  83. import editInvoice from '@/components/editInvoice'
  84. let typeName = {
  85. 2: '增值税普票(电子发票)',
  86. 3: '增值税专用发票'
  87. }
  88. let typeNameEn = {
  89. 'no': 'No invoice required',
  90. 2: 'VAT invoice (E-mail)',
  91. 3: 'VAT special invoice'
  92. }
  93. let cameraName = {
  94. 7: `四维看看 三脚架套装`,
  95. 1: `四维看看 Lite二目相机`,
  96. 4: `四维看看 Pro八目相机`
  97. }
  98. let cameraNameEn = {
  99. 7: `4D KanKan Pro Tripod Set`,
  100. 1: `四维看看 Lite二目相机`,
  101. 4: `4DKanKan Pro Camera`
  102. }
  103. let detail = {
  104. 7: ['四维看看 三脚架套装(标准色)'],
  105. 1: [
  106. '四维看看 Lite二目相机(静谧黑)',
  107. '容量套餐(5G)',
  108. '四维看看 Lite专用三脚架(标准色)'
  109. ],
  110. 4: ['四维看看 Pro八目相机(静谧黑)', '容量套餐(10G)']
  111. }
  112. let detailEn = {
  113. 7: ['4D KanKan Pro Tripod Set (Standard)'],
  114. 1: [
  115. '四维看看 Lite二目相机(静谧黑)',
  116. '容量套餐(5G)',
  117. '四维看看 Lite专用三脚架(标准色)'
  118. ],
  119. 4: ['4DKanKan Pro Camera (Night Sky Black)', 'Storage Plan (10G)']
  120. }
  121. export default {
  122. components: { Paging, editInvoice },
  123. data () {
  124. return {
  125. pageSize: 2,
  126. currentPage: 1,
  127. total: 0,
  128. maxPage: 0,
  129. showInvoice: false,
  130. currentI: '',
  131. currentItem: ''
  132. }
  133. },
  134. watch: {
  135. currentPage () {
  136. this.getList()
  137. }
  138. },
  139. computed: {
  140. ...mapState({
  141. token: state => state.user.token,
  142. langToast: state => state.language.home.toast,
  143. language: state => state.language.current,
  144. langOrders: state => state.language.home.manage.myOrders,
  145. cameraName: state => {
  146. return state.language.current === 'en' ? cameraNameEn : cameraName
  147. },
  148. typeName: state => {
  149. return state.language.current === 'en' ? typeNameEn : typeName
  150. },
  151. detail: state => {
  152. return state.language.current === 'en' ? detailEn : detail
  153. },
  154. myorder: state => {
  155. let type = Object.prototype.toString.call(state.user.myorder)
  156. if (type === '[object Object]') {
  157. return state.user.myorder
  158. }
  159. let condition = state.user.myorder && state.user.myorder !== 'null' && type !== '[object Array]'
  160. return condition ? JSON.parse(state.user.myorder) : {}
  161. }
  162. })
  163. },
  164. mounted () {
  165. this.$bus.$on('editItem', data => {
  166. this.currentItem['invoice'] = data
  167. Vue.set(this.myorder.list, this.currentI, this.currentItem)
  168. })
  169. this.getList()
  170. },
  171. methods: {
  172. edit () {
  173. this.$bus.$emit('isOrderInvoice', false)
  174. },
  175. changeIvoiceStatus (i, item) {
  176. item.showInvoice = !item.showInvoice
  177. this.$bus.$emit('isOrderInvoice', true)
  178. this.currentI = i
  179. this.currentItem = item
  180. Vue.set(this.myorder.list, i, item)
  181. },
  182. getItemInvoice (item) {
  183. let invoice = item.invoice
  184. if (!invoice) {
  185. return ''
  186. }
  187. invoice['typeName'] = this.typeName[invoice.type]
  188. return invoice
  189. },
  190. pageChange (data) {
  191. this.currentPage = data
  192. },
  193. async getList () {
  194. window.scrollTo(0, 0)
  195. let params = {
  196. type: '',
  197. pageNum: this.currentPage,
  198. pageSize: this.pageSize
  199. }
  200. await this.$store.dispatch('getUserOrder', params)
  201. this.pageSize = this.myorder.pageSize
  202. this.total = this.myorder.total || 0
  203. },
  204. getStatus (item) {
  205. let temp = ''
  206. let sPay = function () {
  207. switch (item.shippingStatus) {
  208. case 'unshipped':
  209. temp = 'unshipped'
  210. break
  211. case 'partShipped':
  212. temp = 'partShipped'
  213. break
  214. case 'shipped':
  215. temp = 'shipped'
  216. break
  217. case 'received':
  218. temp = 'received'
  219. break
  220. default:
  221. break
  222. }
  223. }
  224. let pPay = function () {
  225. switch (item.paymentStatus) {
  226. case 'unpaid':
  227. temp = 'unpaid'
  228. break
  229. case 'paid':
  230. sPay()
  231. break
  232. default:
  233. break
  234. }
  235. }
  236. switch (item.orderStatus) {
  237. case 'unprocessed':
  238. pPay()
  239. break
  240. case 'completed':
  241. temp = 'finish'
  242. break
  243. case 'processed':
  244. sPay()
  245. break
  246. default:
  247. break
  248. }
  249. return temp
  250. },
  251. toPay (item) {
  252. this.$router.push({
  253. name: 'pay',
  254. query: {
  255. payType: 0,
  256. orderId: item.id,
  257. orderType: 0,
  258. orderSn: item.orderSn
  259. }
  260. })
  261. },
  262. async cancal (item) {
  263. this.$toast.showConfirm('warn', this.langToast['15'], async () => {
  264. let params = {
  265. orderId: item.id
  266. }
  267. let res = await this.$http({
  268. method: 'post',
  269. data: params,
  270. headers: {
  271. token: this.token
  272. },
  273. url: '/user/order/cancel'
  274. })
  275. let data = res.data
  276. if (data.code === 0) {
  277. return this.$toast.show('success', this.langToast['37'], () => {
  278. this.currentPage = this.currentPage >= this.maxPage ? this.maxPage : this.currentPage
  279. this.getList()
  280. })
  281. }
  282. return this.$toast.show('error', this.langToast['38'])
  283. })
  284. }
  285. }
  286. }
  287. </script>
  288. <style lang="scss" scoped>
  289. $theme-color: #1fe4dc;
  290. $border-color: #e7e7e7;
  291. .btns {
  292. cursor: pointer;
  293. width: 126px;
  294. display: inline-block;
  295. height: 36px;
  296. line-height: 36px;
  297. color: #2d2d2d;
  298. text-align: center;
  299. font-size: 16px;
  300. background: $theme-color;
  301. border: 1px solid $theme-color;
  302. margin-left: 26px;
  303. }
  304. .order-layout {
  305. width: 90%;
  306. color: #2d2d2d;
  307. .order-item {
  308. margin: 40px;
  309. border: 1px solid $border-color;
  310. .inovice-con{
  311. max-height: 0;
  312. overflow: hidden;
  313. }
  314. .ic-active{
  315. max-height: 500px;
  316. transition: 0.3s ease max-height;
  317. }
  318. .o-top {
  319. color: #68b8f1;
  320. line-height: 60px;
  321. height: 60px;
  322. font-size: 16px;
  323. padding: 0 20px;
  324. user-select: none;
  325. border-bottom: 1px solid $border-color;
  326. }
  327. .o-title,.o-invoiceTitle {
  328. user-select: none;
  329. display: flex;
  330. height: 50px;
  331. padding: 0 85px;
  332. align-items: center;
  333. line-height: 50px;
  334. border-bottom: 1px solid $border-color;
  335. background: #fafafa;
  336. span {
  337. font-size: 14px;
  338. flex: 1;
  339. text-align: center;
  340. &:first-child {
  341. flex: 5;
  342. text-align: left;
  343. }
  344. &:last-child{
  345. text-align: right;
  346. }
  347. }
  348. }
  349. .o-invoiceTitle{
  350. align-items: center;
  351. .iconfont{
  352. vertical-align: middle;
  353. font-size: 20px;
  354. margin-right: 5px;
  355. }
  356. .icon-edit{
  357. color: #21e4dc;
  358. }
  359. .icon-choice{
  360. color: #02e430;
  361. }
  362. span {
  363. display: inline-block;
  364. vertical-align: middle;
  365. &:last-child{
  366. transform: translateX(11px);
  367. cursor: pointer;
  368. }
  369. &:first-child {
  370. flex: 1;
  371. transform: translateX(0);
  372. text-align: left;
  373. }
  374. }
  375. }
  376. .o-invoice{
  377. display: flex;
  378. align-items: center;
  379. padding: 10px 20px 10px 85px;
  380. color: #4a4a4a;
  381. font-size: 14px;
  382. border-bottom: 1px solid $border-color;
  383. }
  384. .o-detail {
  385. display: flex;
  386. align-items: center;
  387. height: 100px;
  388. line-height: 100px;
  389. padding: 0 85px;
  390. color: #4a4a4a;
  391. font-size: 14px;
  392. border-bottom: 1px solid $border-color;
  393. .od-name {
  394. display: flex;
  395. align-items: center;
  396. flex: 5;
  397. .thumbnail {
  398. width: 55px;
  399. margin-left: -13px;
  400. margin-right: 60px;
  401. }
  402. p {
  403. line-height: 1.5;
  404. font-size: 14px;
  405. color: #969696;
  406. &:first-of-type{
  407. font-weight: bold;
  408. color: #2d2d2d;
  409. }
  410. }
  411. }
  412. .count {
  413. flex: 1;
  414. text-align: center;
  415. }
  416. .sum {
  417. flex: 1;
  418. text-align: right;
  419. }
  420. }
  421. .sum-price {
  422. display: flex;
  423. height: 50px;
  424. line-height: 50px;
  425. padding: 0 85px;
  426. border-bottom: 1px solid $border-color;
  427. div {
  428. flex: 2;
  429. color: #4a4a4a;
  430. font-size: 14px;
  431. &:last-child {
  432. flex: 1;
  433. text-align: right;
  434. }
  435. }
  436. }
  437. .bottom-area{
  438. position: relative;
  439. .bottom-left{
  440. position: absolute;
  441. top: 50%;
  442. left: 85px;
  443. color: #a0a0a0;
  444. transform: translateY(-50%);
  445. }
  446. .to-pay {
  447. text-align: right;
  448. height: 90px;
  449. line-height: 90px;
  450. padding: 0 25px;
  451. .cancel {
  452. font-size: 16px;
  453. border: 1px solid #ccc;
  454. display: inline-block;
  455. text-align: center;
  456. cursor: pointer;
  457. background: none;
  458. }
  459. .expreeNum {
  460. margin-right: 60px;
  461. color: #2d2d2d;
  462. }
  463. }
  464. }
  465. }
  466. .scene-nothing{
  467. padding: 42px 0 150px 0;
  468. text-align: center;
  469. img{
  470. padding-bottom: 22px;
  471. }
  472. div{
  473. font-size: 16px;
  474. color: #969696;
  475. }
  476. }
  477. .paging {
  478. // border-left: #e5e5e5 1px solid;
  479. height: 100%;
  480. margin-bottom: 40px;
  481. & /deep/ .layout {
  482. text-align: left;
  483. margin-top: 40px;
  484. margin-left: 15px;
  485. }
  486. & /deep/ .layout a:not(:last-child) {
  487. margin: 10px 8px;
  488. font-size: 16px;
  489. display: inline-block;
  490. font-weight: 500;
  491. cursor: pointer;
  492. user-select: none;
  493. color: #999;
  494. position: relative;
  495. transition: color 0.3s;
  496. }
  497. & /deep/ .layout a:last-child {
  498. position: relative;
  499. top: -5px;
  500. display: -ms-inline-flexbox;
  501. display: inline-flex;
  502. -ms-flex-align: center;
  503. align-items: center;
  504. height: 22px;
  505. padding: 0 9.6px;
  506. padding: 0 0.6rem;
  507. }
  508. & /deep/ .layout a:last-child::before,
  509. & /deep/ .layout a:last-child::after {
  510. content: "";
  511. display: inline-block;
  512. will-change: transform;
  513. transition: transform 0.3s;
  514. }
  515. & /deep/ .layout a:not(:last-child).active::after,
  516. & /deep/ .layout a:not(:last-child).active,
  517. & /deep/ .layout a:not(:last-child):hover,
  518. & /deep/ .layout a:not(:last-child):hover::after {
  519. color: #111111;
  520. transform: scaleX(1);
  521. }
  522. & /deep/ .layout a:not(:last-child)::after {
  523. content: "";
  524. height: 3px;
  525. width: 140%;
  526. background-color: #111;
  527. display: block;
  528. margin-left: -20%;
  529. margin-top: 3px;
  530. transform-origin: 50% 50%;
  531. transform: scaleX(0);
  532. will-change: transform;
  533. transition: transform 0.3s;
  534. }
  535. }
  536. }
  537. @media screen and (min-width: 2000px) {
  538. .order-layout {
  539. width: 75%;
  540. }
  541. }
  542. @media screen and (max-width: 1700px){
  543. .order-layout {
  544. width: 95%;
  545. }
  546. }
  547. @media screen and (max-width: 1500px){
  548. .order-layout {
  549. .order-item{
  550. .o-title,.o-invoiceTitle,.o-detail {
  551. padding: 0 45px;
  552. }
  553. .o-invoice{
  554. padding: 10px 45px;
  555. }
  556. }
  557. }
  558. }
  559. </style>