invoiceAdmin.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="curpage">
  3. <view class="list" v-for="item,index in list" :key="index">
  4. <view class="title">
  5. <view class="">
  6. {{item.name}}
  7. </view>
  8. <view class="" style="margin: 10rpx 0;">
  9. <text style="color: #666666;">类型:</text>
  10. {{item.type}}
  11. </view>
  12. <view class="" v-if="item.type=='企业'">
  13. <text style="color: #666666;">税号:</text>
  14. {{item.tax_no}}
  15. </view>
  16. </view>
  17. <view class="icon">
  18. <text @click="goendit(item)">
  19. 编辑
  20. </text>
  21. <text class="line"></text>
  22. <text class="dele" @click="dele(item.id)">
  23. 删除
  24. </text>
  25. </view>
  26. </view>
  27. <u-loadmore v-if="list.length==0" :status="nomore" fontSize="30" :line="true" nomoreText="暂无发票"/>
  28. <view class="" style="height: 1rpx;margin-bottom: 144rpx;"></view>
  29. <view class="navbar" @click="add">
  30. + 新增常用发票
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data(){
  37. return{
  38. showSex: false,
  39. id:1,
  40. list:[]
  41. }
  42. },
  43. onLoad() {
  44. this.init()
  45. },
  46. onShow() {
  47. let token=uni.getStorageSync("token")
  48. if (!token) {
  49. //未登录
  50. uni.showToast({
  51. title: "请先登录",
  52. icon: 'none'
  53. })
  54. setTimeout(()=>{
  55. uni.navigateBack({
  56. delta:1
  57. })
  58. },1500)
  59. return false
  60. }
  61. uni.showLoading({
  62. title: '加载中'
  63. });
  64. this.init()
  65. },
  66. methods:{
  67. init(){
  68. uni.$u.http.post('/api/invoice/list',{
  69. custom: {
  70. auth: true
  71. }
  72. }).then((res) => {
  73. console.log(res)
  74. res.forEach(item=>{
  75. if(item.type==1){
  76. item.type="个人"
  77. }else if(item.type==2){
  78. item.type="企业"
  79. }
  80. })
  81. this.list=res
  82. uni.hideLoading();
  83. }).catch((err) => {
  84. console.log(err)
  85. })
  86. },
  87. // 编辑发票
  88. goendit(item){
  89. uni.navigateTo({
  90. url:`/pages/invoice/invoiceEndit?state=0&info=${JSON.stringify(item)}`
  91. })
  92. },
  93. // 增加发票
  94. add(){
  95. uni.navigateTo({
  96. url:"/pages/invoice/invoiceEndit?state=1"
  97. })
  98. },
  99. // 删除发票
  100. dele(id){
  101. uni.$u.http.post('/api/invoice/delete',{id},{
  102. custom: {
  103. auth: true
  104. }
  105. }).then((res) => {
  106. console.log(res)
  107. this.init()
  108. }).catch((err) => {
  109. console.log( err)
  110. uni.showToast({
  111. icon:"error",
  112. title:err.message,
  113. })
  114. })
  115. }
  116. }
  117. }
  118. </script>
  119. <style lang="less">
  120. page{
  121. background-color: #F4F4F4 ;
  122. font-size: 28rpx;
  123. }
  124. .curpage{
  125. .list{
  126. background: #FFFFFF;
  127. box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.02);
  128. border-radius: 16rpx 16rpx 16rpx 32rpx;
  129. margin: 30rpx;
  130. .title{
  131. padding: 30rpx;
  132. border-bottom: 1rpx solid #E3E3E3;
  133. }
  134. .dele{
  135. // border-left: 1rpx solid #1E9F6A;
  136. // padding-left: 40rpx;
  137. margin-right: 40rpx;
  138. }
  139. .icon{
  140. text-align: right;
  141. padding: 40rpx 0rpx;
  142. color: #1E9F6A;
  143. .line{
  144. display: inline-block;
  145. width: 1px;height: 30rpx;
  146. background-color: #1E9F6A;
  147. margin:0 40rpx -4rpx;
  148. }
  149. }
  150. }
  151. }
  152. .navbar{
  153. padding: 30rpx 0;
  154. text-align: center;
  155. background: #fff;
  156. color: #1E9F6A;
  157. bottom: 0;
  158. margin: 0 auto;
  159. left: 0;
  160. position: fixed;
  161. width: 100%;
  162. // margin-top: 144rpx;
  163. }
  164. </style>