index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481
  1. <template>
  2. <view :style="colorStyle">
  3. <view class="acea-row nav">
  4. <view class="acea-row row-center-wrapper" :class="{ on: nav === 1 }" @click="navTab(1)">{{ $t(`发票记录`) }}</view>
  5. <view class="acea-row row-center-wrapper" :class="{ on: nav === 2 }" @click="navTab(2)">{{ $t(`抬头管理`) }}</view>
  6. </view>
  7. <view v-show="nav === 1" class="record-wrapper">
  8. <view v-for="item in orderList" :key="item.id" class="item">
  9. <view class="item-hd acea-row">
  10. <image class="image" :src="item.order.cartInfo[0].productInfo.image"></image>
  11. <view class="text">{{ item.order.cartInfo[0].productInfo.store_name + item.order.cartInfo[0].productInfo.attrInfo.suk || '' }}</view>
  12. </view>
  13. <view class="item-bd acea-row row-between-wrapper">
  14. <view>
  15. <view class="name">{{ item.header_type === 1 ? $t(`个人`) : $t(`企业`) }}{{ item.type === 1 ? $t(`普通`) : $t(`专用`) }}{{ $t(`发票`) }}</view>
  16. <view>{{ $t(`申请时间`) }} {{ item.add_time }}</view>
  17. </view>
  18. <view class="money">
  19. {{ $t(`¥`) }}
  20. <text class="num">{{ item.order.pay_price }}</text>
  21. </view>
  22. </view>
  23. <view class="item-ft acea-row row-between-wrapper">
  24. <view>{{ item.is_invoice ? $t(`已开票`) : $t(`未开票`) }}</view>
  25. <view class="acea-row row-center-wrapper">
  26. <view class="link mr20" @click="getInvoiceLink(item.id)" v-if="item.is_invoice == 1 && item.unique_num != '' && item.red_invoice_num == ''">复制</view>
  27. <navigator class="link" :url="`/pages/users/user_invoice_order/index?order_id=${item.order.order_id}`">{{ $t(`查看详情`) }}</navigator>
  28. </view>
  29. </view>
  30. </view>
  31. <view v-show="page === 2 && !orderList.length" class="nothing">
  32. <image :src="imgHost + '/statics/images/noInvoice.png'"></image>
  33. <view>{{ $t(`没有发票信息哟~`) }}</view>
  34. </view>
  35. </view>
  36. <view v-show="nav === 2">
  37. <view v-if="invoiceList.length" class="list">
  38. <template v-for="item in invoiceList">
  39. <view v-if="item.type === 1 || (item.type === 2 && specialInvoice)" :key="item.id" class="item">
  40. <view class="acea-row item-hd">
  41. <view class="acea-row row-middle">
  42. <view class="name">{{ item.name }}</view>
  43. <view v-if="item.is_default" class="label">{{ $t(`默认`) }}</view>
  44. </view>
  45. <view class="type" :class="{ special: item.type === 2 }">
  46. {{ item.type === 1 && item.header_type === 1 ? $t(`个人普通发票`) : item.type === 1 && item.header_type === 2 ? $t(`企业普通发票`) : $t(`企业专用发票`) }}
  47. </view>
  48. </view>
  49. <view class="item-bd">
  50. <view class="cell">{{ $t(`联系邮箱`) }} {{ item.email }}</view>
  51. <view v-if="item.header_type === 2" class="cell">{{ $t(`企业税号`) }} {{ item.duty_number }}</view>
  52. <view v-if="item.header_type === 1 && item.drawer_phone" class="cell">{{ $t(`联系电话`) }} {{ item.drawer_phone }}</view>
  53. </view>
  54. <view class="acea-row row-right item-ft">
  55. <view class="btn" @click="editInvoice(item.id)">
  56. <text class="iconfont icon-bianji"></text>
  57. {{ $t(`编辑`) }}
  58. </view>
  59. <view class="btn" @click="deleteInvoice(item.id)">
  60. <text class="iconfont icon-shanchu"></text>
  61. {{ $t(`删除`) }}
  62. </view>
  63. </view>
  64. </view>
  65. </template>
  66. </view>
  67. <view v-show="page === 2 && !invoiceList.length" class="nothing">
  68. <image :src="imgHost + '/statics/images/noInvoice.png'"></image>
  69. <view>{{ $t(`没有发票信息哟~`) }}</view>
  70. </view>
  71. <navigator class="add-link" :url="`/pages/users/user_invoice_form/index?specialInvoice=${specialInvoice}`">
  72. <text class="iconfont icon-fapiao"></text>
  73. {{ $t(`添加新发票`) }}
  74. </navigator>
  75. </view>
  76. <!-- #ifndef MP -->
  77. <home></home>
  78. <!-- #endif -->
  79. </view>
  80. </template>
  81. <script>
  82. import home from '@/components/home';
  83. import { mapGetters } from 'vuex';
  84. import { invoiceList, invoiceDelete, getUserInfo } from '@/api/user.js';
  85. import { orderInvoiceList, getInvoiceLink } from '@/api/order.js';
  86. import colors from '@/mixins/color.js';
  87. import { HTTP_REQUEST_URL } from '@/config/app';
  88. export default {
  89. components: {
  90. home
  91. },
  92. mixins: [colors],
  93. data() {
  94. return {
  95. imgHost: HTTP_REQUEST_URL,
  96. orderList: [],
  97. invoiceList: [],
  98. nav: 1, // 1:发票记录 2:抬头管理
  99. page: 1,
  100. limit: 30,
  101. loading: false,
  102. finished: false,
  103. specialInvoice: true
  104. };
  105. },
  106. watch: {
  107. nav: {
  108. immediate: true,
  109. handler(value) {
  110. this.page = 1;
  111. switch (value) {
  112. case 1:
  113. this.orderList = [];
  114. this.getOrderList();
  115. break;
  116. case 2:
  117. this.invoiceList = [];
  118. this.getInvoiceList();
  119. break;
  120. }
  121. }
  122. }
  123. },
  124. computed: mapGetters(['isLogin']),
  125. onLoad(option) {
  126. if (option.from === 'invoice_form') {
  127. this.nav = 2;
  128. }
  129. this.getUserInfo();
  130. },
  131. methods: {
  132. getInvoiceLink(id) {
  133. uni.showLoading({
  134. title: '复制中'
  135. });
  136. getInvoiceLink(id).then((res) => {
  137. // #ifdef APP-PLUS
  138. plus.runtime.openWeb(res.data.downloadBase64.pdfUrl);
  139. // #endif
  140. // #ifndef APP-PLUS
  141. uni.setClipboardData({
  142. data: res.data.downloadBase64.pdfUrl,
  143. success: () =>
  144. uni.showToast({
  145. title: '链接已复制'
  146. })
  147. });
  148. // #endif
  149. });
  150. },
  151. getUserInfo() {
  152. getUserInfo().then((res) => {
  153. const { special_invoice } = res.data;
  154. this.specialInvoice = special_invoice;
  155. });
  156. },
  157. // 菜单切换
  158. navTab(nav) {
  159. if (this.nav !== nav) {
  160. this.nav = nav;
  161. }
  162. },
  163. // 记录列表
  164. getOrderList() {
  165. uni.showLoading({
  166. title: this.$t(`加载中`)
  167. });
  168. orderInvoiceList({
  169. page: this.page,
  170. limit: this.limit
  171. })
  172. .then((res) => {
  173. const { data } = res;
  174. uni.hideLoading();
  175. this.orderList = this.orderList.concat(data);
  176. this.finished = data.length < this.limit;
  177. this.page += 1;
  178. })
  179. .catch((err) => {
  180. uni.showToast({
  181. title: err.msg,
  182. icon: 'none'
  183. });
  184. });
  185. },
  186. // 发票列表
  187. getInvoiceList() {
  188. uni.showLoading({
  189. title: this.$t(`加载中`)
  190. });
  191. invoiceList({
  192. page: this.page,
  193. limit: this.limit
  194. })
  195. .then((res) => {
  196. const { data } = res;
  197. uni.hideLoading();
  198. this.invoiceList = this.invoiceList.concat(data);
  199. this.finished = data.length < this.limit;
  200. this.page += 1;
  201. })
  202. .catch((err) => {
  203. uni.showToast({
  204. title: err.msg,
  205. icon: 'none'
  206. });
  207. });
  208. },
  209. // 编辑发票
  210. editInvoice(id) {
  211. uni.navigateTo({
  212. url: `/pages/users/user_invoice_form/index?id=${id}`
  213. });
  214. },
  215. // 删除发票
  216. deleteInvoice(id) {
  217. let that = this;
  218. uni.showModal({
  219. content: that.$t(`删除该发票?`),
  220. confirmColor: '#E93323',
  221. success(res) {
  222. if (res.confirm) {
  223. invoiceDelete(id)
  224. .then(() => {
  225. that.$util.Tips(
  226. {
  227. title: that.$t(`删除成功`),
  228. icon: 'success'
  229. },
  230. () => {
  231. let index = that.invoiceList.findIndex((value) => {
  232. return value.id == id;
  233. });
  234. that.invoiceList.splice(index, 1);
  235. }
  236. );
  237. })
  238. .catch((err) => {
  239. return that.$util.Tips({
  240. title: err
  241. });
  242. });
  243. }
  244. }
  245. });
  246. }
  247. }
  248. };
  249. </script>
  250. <style lang="scss" scoped>
  251. .mr20 {
  252. margin-right: 20rpx;
  253. }
  254. .nav {
  255. position: fixed;
  256. top: 0;
  257. left: 0;
  258. z-index: 9;
  259. width: 100%;
  260. height: 90rpx;
  261. background-color: #ffffff;
  262. }
  263. .nav .acea-row {
  264. flex: 1;
  265. border-top: 3rpx solid transparent;
  266. border-bottom: 3rpx solid transparent;
  267. font-size: 30rpx;
  268. color: #282828;
  269. }
  270. .nav .on {
  271. border-bottom-color: var(--view-theme);
  272. color: var(--view-theme);
  273. }
  274. .list {
  275. padding: 14rpx 32rpx;
  276. margin-top: 90rpx;
  277. padding-bottom: 180rpx;
  278. }
  279. .list .item {
  280. padding: 28rpx 32rpx;
  281. background-color: #ffffff;
  282. }
  283. .list .item ~ .item {
  284. margin-top: 14rpx;
  285. }
  286. .list .item-hd .acea-row {
  287. flex: 1;
  288. min-width: 0;
  289. }
  290. .list .name {
  291. font-weight: 600;
  292. font-size: 30rpx;
  293. color: #282828;
  294. }
  295. .list .label {
  296. width: 56rpx;
  297. height: 28rpx;
  298. border: 1rpx solid var(--view-theme);
  299. margin-left: 18rpx;
  300. font-size: 20rpx;
  301. line-height: 26rpx;
  302. text-align: center;
  303. color: var(--view-theme);
  304. }
  305. .list .type {
  306. // width: 172rpx;
  307. height: 42rpx;
  308. margin-left: 30rpx;
  309. background-color: #fcf0e0;
  310. font-size: 24rpx;
  311. line-height: 42rpx;
  312. text-align: center;
  313. color: #d67300;
  314. padding: 0 8rpx;
  315. }
  316. .list .type.special {
  317. background-color: #fde9e7;
  318. color: #e93323;
  319. }
  320. .list .item-bd {
  321. margin-top: 18rpx;
  322. }
  323. .list .cell {
  324. font-size: 26rpx;
  325. color: #666666;
  326. }
  327. .list .cell ~ .cell {
  328. margin-top: 12rpx;
  329. }
  330. .list .item-ft {
  331. margin-top: 11rpx;
  332. .copy {
  333. margin-right: 20rpx;
  334. font-size: 24rpx;
  335. }
  336. }
  337. .list .btn {
  338. font-size: 26rpx;
  339. color: #282828;
  340. }
  341. .list .btn ~ .btn {
  342. margin-left: 35rpx;
  343. }
  344. .list .btn .iconfont {
  345. margin-right: 10rpx;
  346. font-size: 24rpx;
  347. color: #000000;
  348. }
  349. .add-link {
  350. position: fixed;
  351. right: 30rpx;
  352. bottom: 53rpx;
  353. left: 30rpx;
  354. height: 86rpx;
  355. border-radius: 43rpx;
  356. background-color: var(--view-theme);
  357. font-size: 30rpx;
  358. line-height: 86rpx;
  359. text-align: center;
  360. color: #ffffff;
  361. .iconfont {
  362. margin-right: 14rpx;
  363. font-size: 28rpx;
  364. }
  365. }
  366. .nothing {
  367. margin-top: 254rpx;
  368. font-size: 26rpx;
  369. text-align: center;
  370. color: #999999;
  371. .image {
  372. width: 400rpx;
  373. height: 260rpx;
  374. margin-bottom: 20rpx;
  375. }
  376. }
  377. .record-wrapper {
  378. margin-top: 110rpx;
  379. .item {
  380. padding-right: 30rpx;
  381. padding-left: 30rpx;
  382. border-radius: 6rpx;
  383. margin: 30rpx;
  384. background-color: #ffffff;
  385. .item-hd {
  386. padding-top: 36rpx;
  387. padding-bottom: 36rpx;
  388. .image {
  389. width: 78rpx;
  390. height: 78rpx;
  391. border-radius: 6rpx;
  392. }
  393. .text {
  394. flex: 1;
  395. display: -webkit-box;
  396. -webkit-box-orient: vertical;
  397. -webkit-line-clamp: 2;
  398. overflow: hidden;
  399. margin-left: 24rpx;
  400. font-size: 26rpx;
  401. line-height: 37rpx;
  402. color: #282828;
  403. }
  404. }
  405. .item-bd {
  406. padding: 26rpx 30rpx 25rpx 32rpx;
  407. border-radius: 20rpx;
  408. background-color: #f5f6f7;
  409. font-size: 26rpx;
  410. line-height: 37rpx;
  411. color: #818181;
  412. .name {
  413. margin-bottom: 8rpx;
  414. font-weight: bold;
  415. font-size: 26rpx;
  416. color: #282828;
  417. }
  418. .money {
  419. font-weight: bold;
  420. font-size: 24rpx;
  421. color: #282828;
  422. .num {
  423. font-size: 32rpx;
  424. }
  425. }
  426. }
  427. .item-ft {
  428. padding-top: 30rpx;
  429. padding-bottom: 30rpx;
  430. font-weight: bold;
  431. font-size: 28rpx;
  432. color: #282828;
  433. .link {
  434. width: 150rpx;
  435. height: 57rpx;
  436. border: 1rpx solid #707070;
  437. border-radius: 29rpx;
  438. font-weight: normal;
  439. font-size: 26rpx;
  440. line-height: 57rpx;
  441. text-align: center;
  442. color: #282828;
  443. }
  444. }
  445. }
  446. }
  447. </style>