index copy.vue 9.8 KB

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