rechargeItem.vue 9.6 KB

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