index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. <template>
  2. <!-- 发票管理模块 -->
  3. <view :style="colorStyle">
  4. <view class="acea-row nav">
  5. <view class="acea-row row-center-wrapper" :class="{ on: nav === 1 }" @click="navTab(1)">发票记录</view>
  6. <view class="acea-row row-center-wrapper" :class="{ on: nav === 2 }" @click="navTab(2)">抬头管理</view>
  7. </view>
  8. <view class="nav-placeholder"></view>
  9. <view v-show="nav === 1" class="record-wrapper">
  10. <view v-for="item in orderList" :key="item.id" class="item">
  11. <view class="item-hd acea-row row-between-wrapper">
  12. <view>订单号:{{ item.order.order_id }}</view>
  13. <view class="status">{{ item.is_invoice ? '已开票' : '未开票' }}</view>
  14. </view>
  15. <view class="item-cart acea-row">
  16. <image :src="item.order.cartInfo[0].productInfo.image" class="image"></image>
  17. <view class="text">{{ item.order.cartInfo[0].productInfo.store_name + item.order.cartInfo[0].productInfo.attrInfo.suk || '' }}</view>
  18. </view>
  19. <view class="item-bd acea-row row-middle">
  20. <view class="text">
  21. <view class="">电子{{ item.type == 1 ? '普通' : '专用' }}发票-{{ item.header_type == 1 ? '个人' : '企业' }}</view>
  22. <view class="info">商家退款审核中,请您耐心等待。</view>
  23. </view>
  24. <BaseMoney :money="item.order.pay_price" symbolSize="20" integerSize="36" decimalSize="20" color="#333333" weight></BaseMoney>
  25. </view>
  26. <view class="item-ft acea-row row-right">
  27. <navigator class="link" :url="`/pages/users/user_invoice_order/index?order_id=${item.order.order_id}`">查看详情</navigator>
  28. </view>
  29. </view>
  30. <view class="px-20 mt-20" v-show="!orderList.length">
  31. <emptyPage title="暂无发票信息" src="/statics/images/noInvoice.gif"></emptyPage>
  32. </view>
  33. </view>
  34. <view v-show="nav === 2">
  35. <view v-if="invoiceList.length" class="list">
  36. <template v-for="item in invoiceList">
  37. <view v-if="item.type === 1 || item.type === 2 && specialInvoice" :key="item.id" class="item">
  38. <view class="item-hd">{{ item.type == 1 ? '普通' : '专用' }}发票抬头-{{ item.header_type == 1 ? '个人' : '企业' }}</view>
  39. <tui-swipe-action :operateWidth="60">
  40. <template v-slot:content>
  41. <view class="item-bd acea-row row-middle">
  42. <view class="item-text">
  43. <view class="name-wrap acea-row row-middle">
  44. <view class="name">{{ item.name }}</view>
  45. <view v-if="item.is_default" class="badge acea-row row-middle">默认</view>
  46. </view>
  47. <view v-if="item.header_type == 1">{{ item.drawer_phone }}</view>
  48. <view v-else>{{ item.duty_number }}</view>
  49. </view>
  50. <view class="edit acea-row row-center-wrapper" @click="editInvoice(item.id)">
  51. <text class="iconfont icon-ic_edit"></text>
  52. </view>
  53. </view>
  54. </template>
  55. <template v-slot:button>
  56. <view class="delete acea-row row-center-wrapper" @click="deleteInvoice(item.id)">删除</view>
  57. </template>
  58. </tui-swipe-action>
  59. </view>
  60. </template>
  61. </view>
  62. <view class="px-20 mt-20" v-show="!invoiceList.length">
  63. <emptyPage title="暂无发票信息" src="/statics/images/noInvoice.gif"></emptyPage>
  64. </view>
  65. <navigator class="add-link" :url="`/pages/users/user_invoice_form/index?specialInvoice=${specialInvoice}`">添加发票抬头</navigator>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import emptyPage from '@/components/emptyPage.vue';
  71. import {
  72. mapGetters
  73. } from "vuex";
  74. import {
  75. invoiceList,
  76. invoiceDelete,
  77. getUserInfo
  78. } from '@/api/user.js';
  79. import {
  80. orderInvoiceList
  81. } from '@/api/order.js';
  82. import colors from '@/mixins/color.js';
  83. import {
  84. HTTP_REQUEST_URL
  85. } from '@/config/app';
  86. import tuiSwipeAction from '@/components/tui-swipe-action/index.vue';
  87. export default {
  88. components: {
  89. tuiSwipeAction,
  90. emptyPage
  91. },
  92. mixins: [colors],
  93. data() {
  94. return {
  95. orderList: [],
  96. invoiceList: [],
  97. nav: 1, // 1:发票记录 2:抬头管理
  98. page: 1,
  99. limit: 30,
  100. loading: false,
  101. finished: false,
  102. specialInvoice: true,
  103. imgHost: HTTP_REQUEST_URL
  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. onShow() {
  132. uni.removeStorageSync('form_type_cart');
  133. },
  134. methods: {
  135. getUserInfo() {
  136. getUserInfo().then(res => {
  137. const {
  138. special_invoice
  139. } = res.data;
  140. this.specialInvoice = special_invoice
  141. });
  142. },
  143. // 菜单切换
  144. navTab(nav) {
  145. if (this.nav !== nav) {
  146. this.nav = nav;
  147. }
  148. },
  149. // 记录列表
  150. getOrderList() {
  151. uni.showLoading({
  152. title: '加载中'
  153. });
  154. orderInvoiceList({
  155. page: this.page,
  156. limit: this.limit
  157. }).then(res => {
  158. const {
  159. data
  160. } = res;
  161. uni.hideLoading();
  162. this.orderList = this.orderList.concat(data);
  163. this.finished = data.length < this.limit;
  164. this.page += 1;
  165. }).catch(err => {
  166. uni.showToast({
  167. title: err.msg,
  168. icon: 'none'
  169. });
  170. });
  171. },
  172. // 发票列表
  173. getInvoiceList() {
  174. uni.showLoading({
  175. title: '加载中'
  176. });
  177. invoiceList({
  178. page: this.page,
  179. limit: this.limit
  180. }).then(res => {
  181. const {
  182. data
  183. } = res;
  184. uni.hideLoading();
  185. this.invoiceList = this.invoiceList.concat(data);
  186. this.finished = data.length < this.limit;
  187. this.page += 1;
  188. }).catch(err => {
  189. uni.showToast({
  190. title: err.msg,
  191. icon: 'none'
  192. });
  193. });
  194. },
  195. // 编辑发票
  196. editInvoice(id) {
  197. uni.navigateTo({
  198. url: `/pages/users/user_invoice_form/index?id=${id}`
  199. });
  200. },
  201. // 删除发票
  202. deleteInvoice(id) {
  203. let that = this;
  204. uni.showModal({
  205. content: '删除该发票?',
  206. confirmColor: '#E93323',
  207. success(res) {
  208. if (res.confirm) {
  209. invoiceDelete(id).then(() => {
  210. that.$util.Tips({
  211. title: '删除成功',
  212. icon: 'success'
  213. }, () => {
  214. let index = that.invoiceList.findIndex(value => {
  215. return value.id == id;
  216. });
  217. that.invoiceList.splice(index, 1);
  218. });
  219. }).catch(err => {
  220. return that.$util.Tips({
  221. title: err
  222. });
  223. });
  224. }
  225. }
  226. });
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="scss" scoped>
  232. .nav {
  233. position: fixed;
  234. top: 0;
  235. left: 0;
  236. z-index: 9;
  237. width: 100%;
  238. height: 90rpx;
  239. // background-color: #FFFFFF;
  240. }
  241. .nav .acea-row {
  242. position: relative;
  243. flex: 1;
  244. font-size: 28rpx;
  245. color: #333333;
  246. &::after {
  247. content: "";
  248. position: absolute;
  249. bottom: 8rpx;
  250. left: 50%;
  251. width: 116rpx;
  252. height: 6rpx;
  253. border-radius: 6rpx;
  254. background-color: transparent;
  255. transform: translateX(-50%);
  256. }
  257. }
  258. .nav .on {
  259. font-weight: 500;
  260. font-size: 30rpx;
  261. color: var(--view-theme);
  262. &::after {
  263. background-color: var(--view-theme);
  264. }
  265. }
  266. .nav-placeholder {
  267. height: 90rpx;
  268. }
  269. .list {
  270. padding: 14rpx 32rpx;
  271. margin-bottom: 140rpx;
  272. }
  273. .list .item {
  274. border-radius: 24rpx;
  275. background-color: #FFFFFF;
  276. overflow: hidden;
  277. }
  278. .list .item~.item {
  279. margin-top: 14rpx;
  280. }
  281. .list .item-hd {
  282. position: relative;
  283. padding: 24rpx;
  284. font-size: 24rpx;
  285. line-height: 34rpx;
  286. color: #333333;
  287. &::after {
  288. content: "";
  289. position: absolute;
  290. right: 24rpx;
  291. bottom: 0;
  292. left: 24rpx;
  293. height: 1px;
  294. background-color: #F5F5F5;
  295. }
  296. }
  297. .list .item-hd .acea-row {
  298. flex: 1;
  299. min-width: 0;
  300. }
  301. .list .item-bd {
  302. padding: 32rpx 24rpx;
  303. }
  304. .list .item-text {
  305. flex: 1;
  306. min-width: 0;
  307. font-size: 24rpx;
  308. line-height: 34rpx;
  309. color: #999999;
  310. }
  311. .list .name-wrap {
  312. display: inline-flex;
  313. max-width: 100%;
  314. margin-bottom: 12rpx;
  315. }
  316. .list .name {
  317. flex: 1;
  318. min-width: 0;
  319. overflow: hidden;
  320. text-overflow: ellipsis;
  321. font-weight: 500;
  322. font-size: 28rpx;
  323. line-height: 40rpx;
  324. color: #333333;
  325. }
  326. .list .badge {
  327. height: 34rpx;
  328. padding: 0 8rpx;
  329. border-radius: 8rpx;
  330. margin-left: 8rpx;
  331. background-color: #FCEAE9;
  332. font-size: 22rpx;
  333. color: var(--view-theme);
  334. }
  335. .list .edit {
  336. width: 56rpx;
  337. height: 56rpx;
  338. border-radius: 50%;
  339. background-color: #F5F5F5;
  340. .iconfont {
  341. font-size: 32rpx;
  342. color: #333333;
  343. }
  344. }
  345. .list .delete {
  346. width: 120rpx;
  347. height: 100%;
  348. background-color: var(--view-theme);
  349. font-size: 24rpx;
  350. color: #FFFFFF;
  351. }
  352. .list .type.special {
  353. background-color: #FDE9E7;
  354. color: #E93323;
  355. }
  356. .list .cell {
  357. font-size: 26rpx;
  358. color: #666666;
  359. }
  360. .list .cell~.cell {
  361. margin-top: 12rpx;
  362. }
  363. .list .item-ft {
  364. margin-top: 11rpx;
  365. }
  366. .list .btn {
  367. font-size: 26rpx;
  368. color: #282828;
  369. cursor: pointer;
  370. }
  371. .list .btn~.btn {
  372. margin-left: 35rpx;
  373. }
  374. .list .btn .iconfont {
  375. margin-right: 10rpx;
  376. font-size: 24rpx;
  377. color: #000000;
  378. }
  379. .add-link {
  380. position: fixed;
  381. right: 30rpx;
  382. bottom: calc(20rpx + env(safe-area-inset-bottom));
  383. left: 30rpx;
  384. height: 86rpx;
  385. border-radius: 43rpx;
  386. background-color: var(--view-theme);
  387. font-size: 30rpx;
  388. line-height: 86rpx;
  389. text-align: center;
  390. color: #FFFFFF;
  391. .iconfont {
  392. margin-right: 14rpx;
  393. font-size: 28rpx;
  394. }
  395. }
  396. .record-wrapper {
  397. .item {
  398. padding: 32rpx 24rpx;
  399. border-radius: 24rpx;
  400. margin: 20rpx;
  401. background-color: #FFFFFF;
  402. .item-hd {
  403. font-size: 28rpx;
  404. line-height: 40rpx;
  405. color: #333333;
  406. .status {
  407. font-weight: 500;
  408. }
  409. }
  410. .item-cart {
  411. margin-top: 32rpx;
  412. .image {
  413. width: 104rpx;
  414. height: 104rpx;
  415. border-radius: 16rpx;
  416. }
  417. .text {
  418. flex: 1;
  419. padding-left: 20rpx;
  420. font-size: 28rpx;
  421. line-height: 40rpx;
  422. color: #333333;
  423. }
  424. }
  425. .item-bd {
  426. padding: 24rpx;
  427. border-radius: 16rpx;
  428. margin-top: 32rpx;
  429. background-color: #F5F5F5;
  430. font-size: 26rpx;
  431. line-height: 36rpx;
  432. color: #333333;
  433. .text {
  434. flex: 1;
  435. }
  436. .info {
  437. margin-top: 8rpx;
  438. font-size: 24rpx;
  439. line-height: 34rpx;
  440. color: #999999;
  441. }
  442. }
  443. .item-ft {
  444. margin-top: 32rpx;
  445. .link {
  446. height: 56rpx;
  447. padding: 0 24rpx;
  448. border: 1rpx solid #CCCCCC;
  449. border-radius: 56rpx;
  450. font-size: 24rpx;
  451. line-height: 54rpx;
  452. color: #333333;
  453. }
  454. }
  455. }
  456. }
  457. </style>