index.vue 9.8 KB

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