invoice.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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">
  57. <view class="list-title">开票金额</view>
  58. <view class="list-desc">¥{{ state.data.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 state = reactive({
  128. info: [
  129. {
  130. title: '订单提交',
  131. },
  132. {
  133. title: '等待开票',
  134. },
  135. {
  136. title: '开票完成',
  137. },
  138. ],
  139. data: {},
  140. jointImage: [],
  141. numImage: 0,
  142. });
  143. const statusNum = computed(() => {
  144. if (state.data.status === 'finish') {
  145. return 2;
  146. } else if (state.data.status === 'waiting') {
  147. return 1;
  148. } else {
  149. return 0;
  150. }
  151. });
  152. function onInvoice() {
  153. // #ifdef H5
  154. window.open(state.jointImage);
  155. // #endif
  156. // #ifdef MP || APP-PLUS
  157. uni.downloadFile({
  158. url: state.jointImage[0],
  159. success: function (res) {
  160. var filePath = res.tempFilePath;
  161. uni.openDocument({
  162. filePath: filePath,
  163. showMenu: true,
  164. success: function (res) {
  165. console.log('打开文档成功');
  166. },
  167. });
  168. },
  169. });
  170. // #endif
  171. }
  172. async function getInvoiceDetail(id) {
  173. const { data } = await sheep.$api.order.invoice(id);
  174. state.data = data;
  175. state.data.download_urls?.forEach((i, index) => {
  176. state.numImage = index + 1;
  177. if (i.substr(-4) != '.pdf') {
  178. state.jointImage.push(sheep.$url.static(i));
  179. } else {
  180. state.jointImage.push(sheep.$url.static(i));
  181. }
  182. });
  183. }
  184. onLoad((options) => {
  185. getInvoiceDetail(options.invoiceId);
  186. });
  187. </script>
  188. <style lang="scss" scoped>
  189. .invoice-heard {
  190. width: 100%;
  191. box-sizing: border-box;
  192. background: v-bind("sheep.$url.css('/static/img/shop/order/invoice_bg.png')") no-repeat,
  193. linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  194. background-size: 750rpx 100%;
  195. .sicon-warning-line {
  196. color: #fff;
  197. font-size: 34rpx;
  198. }
  199. .sicon-check-line {
  200. color: #fff;
  201. font-size: 34rpx;
  202. }
  203. .invoice-heard-title {
  204. font-size: 34rpx;
  205. font-weight: 500;
  206. color: #ffffff;
  207. margin-left: 8rpx;
  208. line-height: normal;
  209. }
  210. .invoice-heard-desc {
  211. font-size: 24rpx;
  212. font-weight: 500;
  213. color: #ffffff;
  214. }
  215. .invoice-heard-price {
  216. font-size: 28rpx;
  217. font-family: OPPOSANS;
  218. font-weight: 500;
  219. color: #ffffff;
  220. }
  221. }
  222. .invoice-content {
  223. width: 100%;
  224. position: relative;
  225. z-index: 3;
  226. background: #ffffff;
  227. border-radius: 20rpx;
  228. margin-top: -16rpx;
  229. .invoice-content-title {
  230. font-size: 30rpx;
  231. font-weight: 500;
  232. color: #333333;
  233. }
  234. .log-icon {
  235. .sicon-unchecked {
  236. color: #c2bec2;
  237. font-size: 44rpx;
  238. }
  239. .sicon-circlecheck {
  240. color: #e60a00;
  241. font-size: 44rpx;
  242. }
  243. .line {
  244. width: 158rpx;
  245. height: 6rpx;
  246. background: #f2f2f2;
  247. border: 2rpx solid #ffffff;
  248. }
  249. .activity-color {
  250. background: #e60a00;
  251. }
  252. }
  253. .log-title {
  254. font-size: 26rpx;
  255. font-weight: 500;
  256. color: #333333;
  257. margin-left: -26rpx;
  258. margin-top: 30rpx;
  259. }
  260. .invoice-content-list {
  261. width: 100%;
  262. padding: 0 46rpx 0 30rpx;
  263. box-sizing: border-box;
  264. }
  265. .list-title {
  266. font-size: 26rpx;
  267. font-weight: 500;
  268. color: #999999;
  269. margin-right: 44rpx;
  270. margin-bottom: 36rpx;
  271. }
  272. .list-desc {
  273. font-size: 26rpx;
  274. font-weight: 500;
  275. color: #333333;
  276. margin-bottom: 36rpx;
  277. }
  278. .invoice-img {
  279. width: 200rpx;
  280. height: 110rpx;
  281. }
  282. .invoice-img-num {
  283. width: 216rpx;
  284. height: 40rpx;
  285. background: rgba(#000000, 0.45);
  286. font-size: 24rpx;
  287. font-weight: 500;
  288. color: #ffffff;
  289. text-align: center;
  290. margin-top: -30rpx;
  291. z-index: 1;
  292. }
  293. .invoice-img-title {
  294. font-size: 24rpx;
  295. font-weight: 500;
  296. color: #999999;
  297. }
  298. }
  299. .invoice-order {
  300. width: 100%;
  301. padding-top: 30rpx;
  302. box-sizing: border-box;
  303. background: #fff;
  304. border-radius: 20rpx;
  305. }
  306. .goods-box {
  307. border-bottom: 2rpx solid #dfdfdf;
  308. }
  309. .invoice-order-list {
  310. padding: 40rpx 24rpx 0 24rpx;
  311. .list-title {
  312. font-size: 26rpx;
  313. font-weight: 500;
  314. color: #999999;
  315. margin-right: 44rpx;
  316. margin-bottom: 36rpx;
  317. }
  318. .list-desc {
  319. font-size: 26rpx;
  320. font-weight: 500;
  321. color: #333333;
  322. margin-bottom: 36rpx;
  323. }
  324. }
  325. </style>