123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <template>
- <view class="curpage">
- <view class="list" v-for="item,index in list" :key="index">
- <view class="title">
- <view class="">
- {{item.name}}
- </view>
- <view class="" style="margin: 10rpx 0;">
- <text style="color: #666666;">类型:</text>
- {{item.type}}
- </view>
- <view class="" v-if="item.type=='企业'">
- <text style="color: #666666;">税号:</text>
- {{item.tax_no}}
- </view>
- </view>
- <view class="icon">
- <text @click="goendit(item)">
- 编辑
- </text>
- <text class="line"></text>
- <text class="dele" @click="dele(item.id)">
- 删除
- </text>
- </view>
- </view>
- <view class="" style="height: 1rpx;margin-bottom: 144rpx;"></view>
- <view class="navbar" @click="add">
- + 新增常用发票
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- showSex: false,
- id: 1,
- list: []
- }
- },
- onLoad() {
- this.init()
- },
- onShow() {
- let token = uni.getStorageSync("token")
- if (!token) {
- //未登录
- uni.showToast({
- title: "请先登录",
- icon: 'none'
- })
- setTimeout(() => {
- uni.navigateBack({
- delta: 1
- })
- }, 1500)
- return false
- }
- this.init()
- },
- methods: {
- init() {
- uni.$u.http.post('/api/invoice/list', {
- custom: {
- auth: true
- }
- }).then((res) => {
- console.log(res)
- res.forEach(item => {
- if (item.type == 1) {
- item.type = "个人"
- } else if (item.type == 2) {
- item.type = "企业"
- }
- })
- this.list = res
- }).catch((err) => {
- console.log(err)
- })
- },
- // 编辑发票
- goendit(item) {
- uni.navigateTo({
- url: `/pages/invoice/invoiceEndit?state=0&info=${JSON.stringify(item)}`
- })
- },
- // 增加发票
- add() {
- uni.navigateTo({
- url: "/pages/invoice/invoiceEndit?state=1"
- })
- },
- // 删除发票
- dele(id) {
- uni.showModal({
- title: "提示",
- content: "确认删除吗?",
- success: (res) => {
- if (res.confirm) {
- this.$showLoadding("删除中")
- uni.$u.http.post('/api/invoice/delete', {
- id
- }, {
- custom: {
- auth: true
- }
- }).then((res) => {
- uni.hideLoading()
- this.$toast("删除成功")
- this.init()
- }).catch((err) => {
- console.log(err)
- uni.showToast({
- icon: "error",
- title: err.message,
- })
- })
- }
- }
- })
- }
- }
- }
- </script>
- <style lang="less">
- page {
- background-color: #F4F4F4;
- font-size: 28rpx;
- }
- .curpage {
- .list {
- background: #FFFFFF;
- box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.02);
- border-radius: 16rpx 16rpx 16rpx 32rpx;
- margin: 30rpx;
- .title {
- padding: 30rpx;
- border-bottom: 1rpx solid #E3E3E3;
- }
- .dele {
- // border-left: 1rpx solid #1E9F6A;
- // padding-left: 40rpx;
- margin-right: 40rpx;
- }
- .icon {
- text-align: right;
- padding: 40rpx 0rpx;
- color: #1E9F6A;
- .line {
- display: inline-block;
- width: 1px;
- height: 30rpx;
- background-color: #1E9F6A;
- margin: 0 40rpx -4rpx;
- }
- }
- }
- }
- .navbar {
- padding: 30rpx 0;
- text-align: center;
- background: #fff;
- color: #1E9F6A;
- bottom: 0;
- margin: 0 auto;
- left: 0;
- position: fixed;
- width: 100%;
- // margin-top: 144rpx;
- }
- </style>
|