orderItem.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <div class="order-item" :key="i">
  3. <!-- <div class="o-top"></div> -->
  4. <div class="o-title">
  5. <span>
  6. <span class="orderSn table-header">{{$t('manage.myOrders.numbers')}}{{item.orderSn}}</span>
  7. <span class="orderTime">{{ item.orderTime }}</span>
  8. </span>
  9. <span class="table-header">{{$t('manage.myOrders.quantity')}}</span>
  10. <span class="table-header">{{$t('manage.myOrders.subtotal')}}</span>
  11. <span class="table-header">{{$t('manage.myOrders.total1')}}</span>
  12. </div>
  13. <div class="o-detail" v-for="(sub,index) in item.orderItems" :key="index">
  14. <div class="od-name">
  15. <img class="thumbnail" :src="sub.pic" alt>
  16. <div>
  17. <p>{{$t(`manage.cameraName.${sub.goodsId}`)}}</p>
  18. <p v-for="(sb,i) in $t(`manage.orderDetail.${sub.goodsId}`)" :key="i" v-html="sb"></p>
  19. </div>
  20. </div>
  21. <div class="count">{{sub.goodsCount}}</div>
  22. <div class="sum">{{sub.goodsPrice*sub.goodsCount}}</div>
  23. <div class="sum"></div>
  24. </div>
  25. <div class="sum-price">
  26. <div>¥{{item.goodsAmount}}</div>
  27. </div>
  28. <div class="inovice-con" :class="{'ic-active':item.showInvoice}">
  29. <div class="o-invoiceTitle">
  30. <span>{{$t('manage.myOrders.invoice')}}</span>
  31. <span v-if="getStatus(item) !== 'shipped'" @click="edit"><i class="iconfont icon-edit"></i>{{$t('manage.myOrders.edit')}}</span>
  32. <!-- <span v-else><i class="iconfont icon-choice"></i>发票已寄出</span> -->
  33. </div>
  34. <div class="o-invoice">
  35. <editInvoice :data="getItemInvoice(item)" :orderId='item.id' :invoiceId="item.invoice&&(item.invoice.id)"/>
  36. </div>
  37. </div>
  38. <div class="bottom-area">
  39. <div class="bottom-left">
  40. <template v-if="getStatus(item) === 'unpaid'">
  41. <span></span>
  42. </template>
  43. <template v-else-if="getStatus(item) === 'shipped'">
  44. <span class="expreeNum">{{$t('manage.myOrders.wlNum')}}{{item.orderItems[0].expressNum}}</span>
  45. </template>
  46. <template v-else-if="getStatus(item) === 'unshipped'">
  47. <span class="expreeNum">{{$t('manage.myOrders.unshipped')}}</span>
  48. </template>
  49. <template v-else-if="getStatus(item) === 'finish'">
  50. <span class="expreeNum">{{$t('manage.myOrders.finish')}}</span>
  51. </template>
  52. <template v-else-if="getStatus(item) === 'partShipped'">
  53. <span class="expreeNum">{{$t('manage.myOrders.partShipped')}}</span>
  54. </template>
  55. <template v-else-if="getStatus(item) === 'received'">
  56. <span class="expreeNum">{{$t('manage.myOrders.received')}}:{{item.orderItems[0].expressNum}}</span>
  57. </template>
  58. <template v-else-if="getStatus(item) === 'expire'">
  59. <span class="expreeNum">{{$t('manage.myOrders.expire')}}</span>
  60. </template>
  61. <template v-else>
  62. <span class="expreeNum">{{$t('manage.myOrders.hasCancal')}}</span>
  63. </template>
  64. </div>
  65. <div class="to-pay">
  66. <template v-if="getStatus(item) !== 'expire'">
  67. <span class="cancel btns" @click="changeIvoiceStatus(i,item)">{{item.invoice && item.invoice.type ? $t('manage.myOrders.invoiceInfo') : $t('manage.myOrders.invoice')}}</span>
  68. <template v-if="getStatus(item) === 'unpaid'">
  69. <span class="cancel btns" @click="cancal(item)">{{$t('manage.myOrders.cancal')}}</span>
  70. <span class="pay btns" @click="toPay(item)">{{$t('manage.myOrders.pay')}}</span>
  71. </template>
  72. </template>
  73. </div>
  74. </div>
  75. </div>
  76. </template>
  77. <script>
  78. import { mapState } from 'vuex'
  79. import editInvoice from '@/components/editInvoice'
  80. export default {
  81. props: {
  82. item: Object,
  83. i: Number
  84. },
  85. inject: ['getList'],
  86. provide () {
  87. return {
  88. hideInvoice: this.hideInvoice,
  89. saveInvoiceData: this.saveInvoice
  90. }
  91. },
  92. data () {
  93. return {
  94. showInvoice: true
  95. }
  96. },
  97. computed: {
  98. ...mapState({
  99. token: state => state.user.token,
  100. language: state => state.language.current,
  101. myorder: state => {
  102. let type = Object.prototype.toString.call(state.user.myorder)
  103. if (type === '[object Object]') {
  104. return state.user.myorder
  105. }
  106. let condition = state.user.myorder && state.user.myorder !== 'null' && type !== '[object Array]'
  107. return condition ? JSON.parse(state.user.myorder) : {}
  108. }
  109. })
  110. },
  111. components: {
  112. editInvoice
  113. },
  114. mounted () {
  115. this.$set(this.item, 'showInvoice', false)
  116. },
  117. methods: {
  118. edit () {
  119. this.showInvoice = false
  120. },
  121. hideInvoice () {
  122. this.showInvoice = true
  123. },
  124. changeIvoiceStatus (i, item) {
  125. // item.showInvoice = !item.showInvoice
  126. // this.$set(this.item, 'showInvoice', item.showInvoice)
  127. this.$bus.$emit('order/showInvoice', {
  128. order: item,
  129. orderId: item.id,
  130. data: this.getItemInvoice(item),
  131. invoiceId: item.invoice&&(item.invoice.id)
  132. })
  133. },
  134. saveInvoice (data) {
  135. this.$set(this.item, 'invoice', data)
  136. },
  137. getItemInvoice (item) {
  138. let invoice = item.invoice
  139. console.log(item)
  140. if (!invoice) {
  141. return ''
  142. }
  143. invoice['typeName'] = this.$t(`manage.invoiceTypeName.${invoice.type}`)
  144. return invoice
  145. },
  146. getStatus (item) {
  147. let temp = ''
  148. let sPay = function () {
  149. switch (item.shippingStatus) {
  150. case 'unshipped':
  151. temp = 'unshipped'
  152. break
  153. case 'partShipped':
  154. temp = 'partShipped'
  155. break
  156. case 'shipped':
  157. temp = 'shipped'
  158. break
  159. case 'received':
  160. temp = 'received'
  161. break
  162. default:
  163. break
  164. }
  165. }
  166. let pPay = function () {
  167. switch (item.paymentStatus) {
  168. case 'unpaid':
  169. temp = 'unpaid'
  170. break
  171. case 'paid':
  172. sPay()
  173. break
  174. default:
  175. break
  176. }
  177. }
  178. switch (item.orderStatus) {
  179. case 'unprocessed':
  180. pPay()
  181. break
  182. case 'completed':
  183. temp = 'finish'
  184. break
  185. case 'processed':
  186. sPay()
  187. break
  188. case 'expire':
  189. temp = 'expire'
  190. break
  191. default:
  192. break
  193. }
  194. return temp
  195. },
  196. toPay (item) {
  197. this.$router.push({
  198. name: 'pay',
  199. query: {
  200. payType: 0,
  201. orderId: item.id,
  202. orderType: 0,
  203. orderSn: item.orderSn
  204. }
  205. })
  206. },
  207. async cancal (item) {
  208. this.$toast.showConfirm('warn', this.$t('toast.15'), async () => {
  209. let params = {
  210. orderId: item.id
  211. }
  212. let res = await this.$http({
  213. method: 'post',
  214. data: params,
  215. headers: {
  216. token: this.token
  217. },
  218. url: '/user/order/cancel'
  219. })
  220. let data = res.data
  221. if (data.code === 0) {
  222. return this.$toast.show('success', this.$t('toast.37'), () => {
  223. this.currentPage = this.currentPage >= this.maxPage ? this.maxPage : this.currentPage
  224. this.getList()
  225. })
  226. }
  227. return this.$toast.show('error', this.$t('toast.38'))
  228. })
  229. }
  230. }
  231. }
  232. </script>
  233. <style lang="less" scoped>
  234. .order-item {
  235. margin-bottom: 40px;
  236. border: 1px solid #EBEBEB;
  237. .inovice-con{
  238. max-height: 0;
  239. overflow: hidden;
  240. }
  241. .ic-active{
  242. max-height: 500px;
  243. transition: 0.3s ease max-height;
  244. }
  245. .o-top {
  246. color: #68b8f1;
  247. line-height: 60px;
  248. height: 60px;
  249. font-size: 16px;
  250. padding: 0 20px;
  251. user-select: none;
  252. border-bottom: 1px solid #EBEBEB;
  253. }
  254. .o-title,.o-invoiceTitle {
  255. user-select: none;
  256. display: flex;
  257. height: 32px;
  258. padding: 0 20px;
  259. align-items: center;
  260. line-height: 32px;
  261. // border-bottom: 1px solid #EBEBEB;
  262. background: #F7F7F7;
  263. span {
  264. font-size: 14px;
  265. flex: 1;
  266. text-align: center;
  267. &:first-child {
  268. flex: 5;
  269. text-align: left;
  270. }
  271. }
  272. }
  273. .orderSn {
  274. color: #323233;
  275. margin-right: 15px;
  276. }
  277. .o-invoiceTitle{
  278. align-items: center;
  279. .iconfont{
  280. vertical-align: middle;
  281. font-size: 20px;
  282. margin-right: 5px;
  283. }
  284. .icon-edit{
  285. color: #15BEC8;
  286. }
  287. .icon-choice{
  288. color: #02e430;
  289. }
  290. span {
  291. display: inline-block;
  292. vertical-align: middle;
  293. &:last-child{
  294. transform: translateX(11px);
  295. cursor: pointer;
  296. }
  297. &:first-child {
  298. flex: 1;
  299. transform: translateX(0);
  300. text-align: left;
  301. }
  302. }
  303. }
  304. .o-invoice{
  305. display: flex;
  306. align-items: center;
  307. padding: 10px 20px 10px 85px;
  308. color: #4a4a4a;
  309. font-size: 14px;
  310. border-bottom: 1px solid #EBEBEB;
  311. }
  312. .o-detail {
  313. display: flex;
  314. align-items: center;
  315. height: 86px;
  316. line-height: 86px;
  317. padding: 0 20px;
  318. color: #4a4a4a;
  319. font-size: 14px;
  320. border-bottom: 1px solid #EBEBEB;
  321. .od-name {
  322. display: flex;
  323. align-items: center;
  324. flex: 5;
  325. .thumbnail {
  326. width: 55px;
  327. margin-right: 10px;
  328. }
  329. p {
  330. line-height: 1.5;
  331. font-size: 14px;
  332. color: #969696;
  333. &:first-of-type{
  334. font-weight: bold;
  335. color: #2d2d2d;
  336. }
  337. }
  338. }
  339. .count {
  340. flex: 1;
  341. text-align: center;
  342. }
  343. .sum {
  344. flex: 1;
  345. text-align: center;
  346. }
  347. }
  348. position: relative;
  349. .sum-price {
  350. position: absolute;
  351. color: #4a4a4a;
  352. display: flex;
  353. align-items: center;
  354. justify-content: center;
  355. right: 1px;
  356. top: 33px;
  357. bottom: 51px;
  358. background-color: #fff;
  359. width: calc(calc(100% - 40px) / 8 + 20px);
  360. border-left: 1px solid #EBEBEB;
  361. font-weight: 400;
  362. color: #202020;
  363. font-size: 20px;
  364. }
  365. .bottom-area{
  366. position: relative;
  367. .bottom-left{
  368. position: absolute;
  369. top: 50%;
  370. left: 20px;
  371. color: #a0a0a0;
  372. transform: translateY(-50%);
  373. font-size: 14px;
  374. color: #323233;
  375. }
  376. .to-pay {
  377. text-align: right;
  378. height: 50px;
  379. line-height: 50px;
  380. padding: 0 25px;
  381. .cancel {
  382. font-size: 14px;
  383. // border: 1px solid #ccc;
  384. display: inline-block;
  385. text-align: center;
  386. cursor: pointer;
  387. background: #fff;
  388. color: #202020;
  389. border: 1px solid #323233;
  390. width: 104px;
  391. height: 32px;
  392. line-height: 32px;
  393. border-radius: 4px;
  394. }
  395. .pay {
  396. background: #15BEC8;
  397. font-size: 14px;
  398. color: #fff;
  399. display: inline-block;
  400. width: 104px;
  401. height: 32px;
  402. line-height: 32px;
  403. text-align: center;
  404. cursor: pointer;
  405. border-radius: 4px;
  406. }
  407. .expreeNum {
  408. margin-right: 60px;
  409. color: #323233;
  410. }
  411. }
  412. }
  413. }
  414. .table-header {
  415. font-weight: 600;
  416. color: #202020;
  417. }
  418. </style>