index.vue 9.7 KB

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