invoice.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <!-- 订单详情 -->
  2. <template>
  3. <s-layout title="发票详情" class="invoice-wrap" navbar="inner">
  4. <view
  5. class="invoice-heard ss-flex-col ss-row-right ss-col-center"
  6. :style="[
  7. {
  8. marginTop: '-' + Number(statusBarHeight + 88) + 'rpx',
  9. paddingTop: Number(statusBarHeight + 88) + 'rpx',
  10. },
  11. ]"
  12. >
  13. <view class="ss-flex ss-m-t-32 ss-m-b-32">
  14. <text
  15. class="sicon-warning-line"
  16. v-if="state.data.status === 'waiting' || state.data.status === 'unpaid'"
  17. ></text>
  18. <text class="sicon-check-line" v-if="state.data.status === 'finish'"></text>
  19. <view class="invoice-heard-title">{{ state.data.status_text }}</view>
  20. </view>
  21. <view class="ss-flex ss-m-b-52">
  22. <view class="ss-m-r-20 invoice-heard-desc">预计可开发票金额:</view>
  23. <view class="invoice-heard-price">¥{{ state.data.amount }}</view>
  24. </view>
  25. </view>
  26. <view class="invoice-content ss-flex-col ss-col-center">
  27. <view class="ss-m-t-50 ss-m-b-42 invoice-content-title">增值税电子普通发票</view>
  28. <view class="ss-flex ss-m-b-64">
  29. <view v-for="(item, index) in state.info" :key="item.title">
  30. <view class="log-icon ss-flex">
  31. <text class="sicon-circlecheck" v-if="statusNum >= index"></text>
  32. <text class="sicon-unchecked" v-else></text>
  33. <view
  34. v-if="state.info.length - 1 != index"
  35. class="line"
  36. :class="statusNum >= index ? 'activity-color' : ''"
  37. ></view>
  38. </view>
  39. <view class="log-title">{{ item.title }}</view>
  40. </view>
  41. </view>
  42. <view class="invoice-content-list ss-flex ss-row-between ss-col-top">
  43. <view class="">
  44. <view class="ss-flex">
  45. <view class="list-title">发票类型</view>
  46. <view class="list-desc">{{ state.data.type_text }}</view>
  47. </view>
  48. <view class="ss-flex">
  49. <view class="list-title">发票抬头</view>
  50. <view class="list-desc">{{ state.data.name }}</view>
  51. </view>
  52. <view class="ss-flex" v-if="state.data.type === 'company'">
  53. <view class="list-title">发票税号</view>
  54. <view class="list-desc">{{ state.data.tax_no }}</view>
  55. </view>
  56. <view class="ss-flex" v-if="state.data.status === 'finish'">
  57. <view class="list-title">实开金额</view>
  58. <view class="list-desc">¥{{ state.data.invoice_amount }}</view>
  59. </view>
  60. <view class="ss-flex" v-if="state.data.status === 'finish'">
  61. <view class="list-title">开票时间</view>
  62. <view class="list-desc">{{ state.data.finish_time }}</view>
  63. </view>
  64. <view class="ss-flex">
  65. <view class="list-title">申请时间</view>
  66. <view class="list-desc">{{ state.data.create_time }}</view>
  67. </view>
  68. </view>
  69. <view
  70. class="invoice-content-img ss-flex-col ss-col-center"
  71. v-if="state.data.status === 'finish'"
  72. >
  73. <su-image
  74. class="invoice-img"
  75. isPreview
  76. :previewList="state.jointImage"
  77. :current="0"
  78. :src="sheep.$url.static('/static/img/shop/order/invoice_thumb.png')"
  79. :height="110"
  80. mode="scaleToFill"
  81. v-if="state.jointImage[0].substr(-4) != '.pdf'"
  82. ></su-image>
  83. <!-- TODO: 发票为多个pdf时 -->
  84. <view v-if="state.jointImage[0].substr(-4) == '.pdf'" @tap="onInvoice">
  85. <image
  86. :src="sheep.$url.static('/static/img/shop/order/invoice_thumb.png')"
  87. class="invoice-img"
  88. ></image>
  89. </view>
  90. <view class="invoice-img-num">共{{ state.numImage }}张</view>
  91. <view class="invoice-img-title">点击预览发票</view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="invoice-order ss-m-t-20">
  96. <view class="goods-box" v-for="item in state.data.order_items" :key="item.id">
  97. <s-goods-item
  98. :img="item.goods_image"
  99. :title="item.goods_title"
  100. :skuText="item.goods_sku_text"
  101. :price="item.goods_price"
  102. :num="item.goods_num"
  103. />
  104. </view>
  105. <view class="invoice-order-list">
  106. <view class="ss-flex">
  107. <view class="list-title">订单状态</view>
  108. <view class="list-desc">{{ state.data.order?.status_text }}</view>
  109. </view>
  110. <view class="ss-flex">
  111. <view class="list-title">订单编号</view>
  112. <view class="list-desc">{{ state.data.order?.order_sn }}</view>
  113. </view>
  114. <view class="ss-flex">
  115. <view class="list-title">下单时间</view>
  116. <view class="list-desc">{{ state.data.order?.create_time }}</view>
  117. </view>
  118. </view>
  119. </view>
  120. </s-layout>
  121. </template>
  122. <script setup>
  123. import sheep from '@/sheep';
  124. import { onLoad } from '@dcloudio/uni-app';
  125. import { computed, reactive } from 'vue';
  126. const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
  127. const headerBg = sheep.$url.css('/static/img/shop/order/invoice_bg.png');
  128. const state = reactive({
  129. info: [
  130. {
  131. title: '订单提交',
  132. },
  133. {
  134. title: '等待开票',
  135. },
  136. {
  137. title: '开票完成',
  138. },
  139. ],
  140. data: {},
  141. jointImage: [],
  142. numImage: 0,
  143. });
  144. const statusNum = computed(() => {
  145. if (state.data.status === 'finish') {
  146. return 2;
  147. } else if (state.data.status === 'waiting') {
  148. return 1;
  149. } else {
  150. return 0;
  151. }
  152. });
  153. function onInvoice() {
  154. // #ifdef H5
  155. window.open(state.jointImage);
  156. // #endif
  157. // #ifdef MP || APP-PLUS
  158. uni.downloadFile({
  159. url: state.jointImage[0],
  160. success: function (res) {
  161. var filePath = res.tempFilePath;
  162. uni.openDocument({
  163. filePath: filePath,
  164. showMenu: true,
  165. success: function (res) {
  166. console.log('打开文档成功');
  167. },
  168. });
  169. },
  170. });
  171. // #endif
  172. }
  173. async function getInvoiceDetail(id) {
  174. const { data } = await sheep.$api.order.invoice(id);
  175. state.data = data;
  176. state.data.download_urls?.forEach((i, index) => {
  177. state.numImage = index + 1;
  178. if (i.substr(-4) != '.pdf') {
  179. state.jointImage.push(sheep.$url.static(i));
  180. } else {
  181. state.jointImage.push(sheep.$url.static(i));
  182. }
  183. });
  184. }
  185. onLoad((options) => {
  186. getInvoiceDetail(options.invoiceId);
  187. });
  188. </script>
  189. <style lang="scss" scoped>
  190. .invoice-heard {
  191. width: 100%;
  192. box-sizing: border-box;
  193. background: v-bind(headerBg) no-repeat,
  194. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  195. background-size: 750rpx 100%;
  196. .sicon-warning-line {
  197. color: #fff;
  198. font-size: 34rpx;
  199. }
  200. .sicon-check-line {
  201. color: #fff;
  202. font-size: 34rpx;
  203. }
  204. .invoice-heard-title {
  205. font-size: 34rpx;
  206. font-weight: 500;
  207. color: #ffffff;
  208. margin-left: 8rpx;
  209. line-height: normal;
  210. }
  211. .invoice-heard-desc {
  212. font-size: 24rpx;
  213. font-weight: 500;
  214. color: #ffffff;
  215. }
  216. .invoice-heard-price {
  217. font-size: 28rpx;
  218. font-family: OPPOSANS;
  219. font-weight: 500;
  220. color: #ffffff;
  221. }
  222. }
  223. .invoice-content {
  224. width: 100%;
  225. position: relative;
  226. z-index: 3;
  227. background: #ffffff;
  228. border-radius: 20rpx;
  229. margin-top: -16rpx;
  230. .invoice-content-title {
  231. font-size: 30rpx;
  232. font-weight: 500;
  233. color: #333333;
  234. }
  235. .log-icon {
  236. .sicon-unchecked {
  237. color: #c2bec2;
  238. font-size: 44rpx;
  239. }
  240. .sicon-circlecheck {
  241. color: #e60a00;
  242. font-size: 44rpx;
  243. }
  244. .line {
  245. width: 158rpx;
  246. height: 6rpx;
  247. background: #f2f2f2;
  248. border: 2rpx solid #ffffff;
  249. }
  250. .activity-color {
  251. background: #e60a00;
  252. }
  253. }
  254. .log-title {
  255. font-size: 26rpx;
  256. font-weight: 500;
  257. color: #333333;
  258. margin-left: -26rpx;
  259. margin-top: 30rpx;
  260. }
  261. .invoice-content-list {
  262. width: 100%;
  263. padding: 0 46rpx 0 30rpx;
  264. box-sizing: border-box;
  265. }
  266. .list-title {
  267. font-size: 26rpx;
  268. font-weight: 500;
  269. color: #999999;
  270. margin-right: 44rpx;
  271. margin-bottom: 36rpx;
  272. }
  273. .list-desc {
  274. font-size: 26rpx;
  275. font-weight: 500;
  276. color: #333333;
  277. margin-bottom: 36rpx;
  278. }
  279. .invoice-img {
  280. width: 200rpx;
  281. height: 110rpx;
  282. }
  283. .invoice-img-num {
  284. width: 216rpx;
  285. height: 40rpx;
  286. background: rgba(#000000, 0.45);
  287. font-size: 24rpx;
  288. font-weight: 500;
  289. color: #ffffff;
  290. text-align: center;
  291. margin-top: -30rpx;
  292. z-index: 1;
  293. }
  294. .invoice-img-title {
  295. font-size: 24rpx;
  296. font-weight: 500;
  297. color: #999999;
  298. }
  299. }
  300. .invoice-order {
  301. width: 100%;
  302. padding-top: 30rpx;
  303. box-sizing: border-box;
  304. background: #fff;
  305. border-radius: 20rpx;
  306. }
  307. .goods-box {
  308. border-bottom: 2rpx solid #dfdfdf;
  309. }
  310. .invoice-order-list {
  311. padding: 40rpx 24rpx 0 24rpx;
  312. .list-title {
  313. font-size: 26rpx;
  314. font-weight: 500;
  315. color: #999999;
  316. margin-right: 44rpx;
  317. margin-bottom: 36rpx;
  318. }
  319. .list-desc {
  320. font-size: 26rpx;
  321. font-weight: 500;
  322. color: #333333;
  323. margin-bottom: 36rpx;
  324. }
  325. }
  326. </style>