invoiceTent.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template name="invoice">
  2. <view class="invoice-template">
  3. <!-- 发票信息 -->
  4. <view class="invoice-title" @tap.stop="hanldOperationConfim">
  5. <text class="text">发票信息:</text>
  6. <text class="iconfont icon-xiayibu"></text>
  7. </view>
  8. <view class="invoice-text">
  9. <text>{{invoiceText}}</text>
  10. </view>
  11. <!--底部选择模态层弹窗组件 -->
  12. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="choiceaInvoiceConfim">
  13. <!-- 遮罩层 -->
  14. <view class="mask"></view>
  15. <view class="layer" @tap.stop="discard">
  16. <view class="content clearfix">
  17. <view class="invoice-ltitle">发票类型</view>
  18. <view class="invoice-radio">
  19. <radio-group class="row-group" @change="radioChange">
  20. <label class="row-input" v-for="(item, index) in invoiceTypeList" :key="item.value">
  21. <radio class="row-radio" :value="item.value" :checked="index === current" color="#E15616"/>
  22. <view class="row-text">{{item.name}}</view>
  23. </label>
  24. </radio-group>
  25. </view>
  26. <view class="invoice-main from" v-if="invoiceType == '3'">
  27. <view class="invoice-from">
  28. <view class="label">单位名称:</view>
  29. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写单位信息(必填)" maxlength="20">
  30. </view>
  31. <view class="invoice-from">
  32. <view class="label">纳税人识别号:</view>
  33. <input class="form-input" type="text" v-model="invoiceData.corporationTaxNum" placeholder="请填写纳税人识别号(必填)" maxlength="20">
  34. </view>
  35. <view class="invoice-from">
  36. <view class="label">注册地址:</view>
  37. <input class="form-input" type="text" v-model="invoiceData.registeredAddress" placeholder="请填写单位注册地址(必填)" maxlength="30">
  38. </view>
  39. <view class="invoice-from">
  40. <view class="label">注册电话:</view>
  41. <input class="form-input" type="text" v-model="invoiceData.registeredPhone" placeholder="请填写注册电话(必填)" maxlength="15">
  42. </view>
  43. <view class="invoice-from">
  44. <view class="label">开户银行:</view>
  45. <input class="form-input" type="text" v-model="invoiceData.openBank" placeholder="请填写开户银行(必填)" maxlength="10">
  46. </view>
  47. <view class="invoice-from">
  48. <view class="label">银行账号:</view>
  49. <input class="form-input"
  50. type="text"
  51. v-model="invoiceData.bankAccountNo"
  52. placeholder="请填写银行账号(必填)"
  53. maxlength="19">
  54. </view>
  55. </view>
  56. <view class="invoice-main" v-if="invoiceType == '2'">
  57. <view class="invoice-ltitle">发票内容</view>
  58. <view class="invoice-group tit">
  59. <checkbox-group class="row-group" @change="checkboxChange">
  60. <view class="text">商品明细</view>
  61. <checkbox class="row-radio" value="明细" :checked="inventoryChecked ? true : false" color="#E15616"></checkbox>
  62. </checkbox-group>
  63. </view>
  64. <view class="invoice-ltitle">发票抬头</view>
  65. <view class="invoice-group tit">
  66. <radio-group class="row-group radio" @change="radioChangeTitle">
  67. <label class="row-input" v-for="(item, index) in invoiceTitleList" :key="item.value">
  68. <radio class="row-radio" :value="item.value" :checked="index === titleCurrent" color="#E15616"/>
  69. <view class="row-text">{{item.name}}</view>
  70. </label>
  71. </radio-group>
  72. </view>
  73. <view class="invoice-group from">
  74. <view class="group-from" v-if="invoiceData.invoiceTitleType == '0'">
  75. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写个人抬头" maxlength="20">
  76. </view>
  77. <view class="group-from" v-if="invoiceData.invoiceTitleType == '1'">
  78. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写公司抬头" maxlength="20">
  79. </view>
  80. <view class="group-from" v-if="invoiceData.invoiceTitleType == '1'">
  81. <input class="form-input" type="text" v-model="invoiceData.corporationTaxNum" placeholder="请填写纳税人识别号" maxlength="20">
  82. </view>
  83. </view>
  84. </view>
  85. <view class="invoice-main" v-if="invoiceType == '1'">
  86. <view class="invoice-none">不开具发票信息</view>
  87. </view>
  88. </view>
  89. <view class="btn">
  90. <view class="button add" @click="choiceaInvoiceConfim">完成</view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. import { getFindInvoice,updateInvoice } from "@/api/order.js"
  98. export default{
  99. name:"invoice",
  100. data() {
  101. return{
  102. invoiceText:'不开发票',
  103. specClass: '',//规格弹窗css类,控制开关动画
  104. invoiceType:'1',//发票类型
  105. current:0,
  106. titleCurrent:0,
  107. inventoryChecked:false,
  108. invoiceTypeList:[
  109. {value:'1',name:'不开发票'},
  110. {value:'2',name:'普通发票'},
  111. {value:'3',name:'增值税发票'},
  112. ],
  113. invoiceTitleList:[
  114. {value:'0',name:'个人'},
  115. {value:'1',name:'公司'},
  116. ],
  117. invoiceData:{
  118. id:'',
  119. invoiceContent:'', //商品明细
  120. invoiceTitle:'', //单位名称
  121. corporationTaxNum:'',//纳税人识别号
  122. registeredAddress: '',//单位地址
  123. registeredPhone:'', //注册电话
  124. openBank:'', //开户银行
  125. bankAccountNo: '' ,//银行账号
  126. invoiceTitleType:'0',//发票抬头类型 1企业 0个人
  127. },
  128. }
  129. },
  130. created(){
  131. // this.initData(this.invoiceDatas)
  132. },
  133. computed: {
  134. },
  135. methods:{
  136. getUseFindInvoice(){//获取发票信息
  137. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  138. getFindInvoice({userId:resolve.userID}).then(response =>{
  139. if(response.data == null){
  140. this.invoiceData = Object.assign(this.invoiceData,'',{type:0})
  141. }else{
  142. this.invoiceData = response.data
  143. }
  144. })
  145. })
  146. },
  147. updateInvoiceFn(){//保存发票信息
  148. this.$api.getComStorage('orderUserInfo').then((resolve) =>{
  149. let params =Object.assign(this.invoiceData,'',{userId:resolve.userID})
  150. updateInvoice(params).then(response =>{})
  151. })
  152. },
  153. choiceaInvoiceConfim(){
  154. switch(this.invoiceType){
  155. case '1':
  156. this.choiceaInvoiceThree()
  157. this.invoiceText = '不开发票'
  158. break;
  159. case '2':
  160. this.choiceaInvoiceTwo()
  161. this.invoiceText = this.invoiceData.invoiceTitle
  162. break;
  163. case '3':
  164. this.choiceaInvoiceFirst()
  165. this.invoiceText = this.invoiceData.invoiceTitle
  166. break;
  167. default:
  168. this.choiceaInvoiceThree()
  169. this.invoiceText = '不开发票'
  170. }
  171. },
  172. choiceaInvoiceFirst(){//增值税发票
  173. if(this.invoiceData.invoiceTitle == ""){
  174. this.$util.msg('请输入单位名称',2000)
  175. return
  176. }
  177. if(this.invoiceData.corporationTaxNum == ""){
  178. this.$util.msg('请输入纳税人识别号',2000)
  179. return
  180. }
  181. if(this.invoiceData.registeredAddress == ""){
  182. this.$util.msg('请输入单位地址',2000)
  183. return
  184. }
  185. if(this.invoiceData.registeredPhone == ""){
  186. this.$util.msg('请输入注册电话',2000)
  187. return
  188. }
  189. if(this.invoiceData.openBank == ""){
  190. this.$util.msg('请输入开户银行',2000)
  191. return
  192. }
  193. if(this.invoiceData.bankAccountNo == ""){
  194. this.$util.msg('请输入银行账号',2000)
  195. return
  196. }
  197. this.updateInvoiceFn()
  198. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:2}))
  199. this.hideSpec()
  200. },
  201. choiceaInvoiceTwo(){//普通发票
  202. if(this.invoiceData.invoiceContent == ''){
  203. this.$util.msg('请选择商品明细',2000)
  204. return
  205. }
  206. switch(this.invoiceData.invoiceTitleType){
  207. case '0':
  208. if(this.invoiceData.invoiceTitle == ""){
  209. this.$util.msg('请输入个人抬头',2000)
  210. return
  211. }
  212. break;
  213. case '1':
  214. if(this.invoiceData.invoiceTitle == ""){
  215. this.$util.msg('请输入公司抬头',2000)
  216. return
  217. }
  218. if(this.invoiceData.corporationTaxNum == ""){
  219. this.$util.msg('请输入纳税人识别号',2000)
  220. return
  221. }
  222. break;
  223. }
  224. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:1}))
  225. this.hideSpec()
  226. },
  227. choiceaInvoiceThree(){//不开发票
  228. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:0}))
  229. this.hideSpec()
  230. },
  231. hideSpec() {//关闭弹窗
  232. this.specClass = 'hide';
  233. setTimeout(() => {
  234. this.specClass = 'none';
  235. }, 200);
  236. },
  237. hanldOperationConfim(){//显示发票弹窗
  238. this.specClass = 'show';
  239. },
  240. radioChange(e) {
  241. this.invoiceType = e.target.value;
  242. for (let i = 0; i < this.invoiceTypeList.length; i++) {
  243. if (this.invoiceTypeList[i].value === this.invoiceType) {
  244. this.current = i;
  245. break;
  246. }
  247. }
  248. if(this.invoiceType == '3'){
  249. this.getUseFindInvoice()
  250. }
  251. },
  252. radioChangeTitle(e) {
  253. this.invoiceData.invoiceTitleType = e.target.value;
  254. for (let i = 0; i < this.invoiceTitleList.length; i++) {
  255. if (this.invoiceTitleList[i].value === this.invoiceData.invoiceTitleType) {
  256. this.titleCurrent = i;
  257. break;
  258. }
  259. }
  260. },
  261. checkboxChange(e){
  262. this.invoiceData.invoiceContent = e.detail.value[0]
  263. },
  264. inputBankNum(val) {
  265. if (/\S{5}/.test(val)) {
  266. this.invoiceData.bankAccountNo = val.replace(/\s/g, '').replace(/(.{4})/g, "$1 ");
  267. }
  268. },
  269. discard(){
  270. //丢弃
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="scss">
  276. .invoice-template{
  277. width: 100%;
  278. height: auto;
  279. background: #FFFFFF;
  280. float: left;
  281. margin-top: 24rpx;
  282. .invoice-title{
  283. width: 702rpx;
  284. padding: 0 24rpx;
  285. height: 88rpx;
  286. line-height: 88rpx;
  287. position: relative;
  288. border-bottom: 1px solid #EBEBEB;
  289. .text{
  290. font-size: $font-size-28;
  291. color: $text-color;
  292. }
  293. .iconfont{
  294. width: 50rpx;
  295. height: 88rpx;
  296. line-height: 88rpx;
  297. color: #999999;
  298. display: block;
  299. position: absolute;
  300. right: 0;
  301. top: 0;
  302. }
  303. }
  304. .invoice-text{
  305. width: 702rpx;
  306. padding: 0 24rpx;
  307. font-size: $font-size-24;
  308. color: #666666;
  309. line-height: 60rpx;
  310. }
  311. .invoice-ltitle{
  312. width: 100%;
  313. line-height: 60rpx;
  314. height: 60rpx;
  315. font-size: $font-size-28;
  316. color: #333333;
  317. }
  318. .invoice-radio{
  319. width: 100%;
  320. height: 88rpx;
  321. line-height: 88rpx;
  322. display: flex;
  323. border-bottom: 1px solid #EBEBEB;
  324. .row-group{
  325. flex:1;
  326. display: flex;
  327. }
  328. .row-input{
  329. flex: 1;
  330. height: 88rpx;
  331. line-height: 88rpx;
  332. }
  333. .row-radio{
  334. float: left;
  335. transform: scale(0.6);
  336. }
  337. .row-text{
  338. font-size: $font-size-24;
  339. color: $text-color;
  340. }
  341. }
  342. .invoice-main{
  343. width: 100%;
  344. height: auto;
  345. margin-top: 30rpx;
  346. &.from{
  347. padding-bottom: 40rpx;
  348. }
  349. .invoice-none{
  350. line-height: 60rpx;
  351. height: 60rpx;
  352. font-size: $font-size-24;
  353. color: #666666;
  354. text-align: center;
  355. }
  356. .invoice-from{
  357. width: 662rpx;
  358. height: 40rpx;
  359. padding: 20rpx;
  360. line-height: 40rpx;
  361. align-items: flex-start;
  362. font-size: $font-size-28;
  363. color: $text-color;
  364. background: #F7F7F7;
  365. border-radius: 14rpx;
  366. margin-bottom: 20rpx;
  367. .label{
  368. height: 40rpx;
  369. line-height: 40rpx;
  370. float: left;
  371. }
  372. .form-input{
  373. height: 40rpx;
  374. line-height: 40rpx;
  375. flex-grow: 1;
  376. padding-left: 20rpx;
  377. }
  378. }
  379. .invoice-group{
  380. width: 100%;
  381. height: 88rpx;
  382. display: flex;
  383. border-bottom: 1px solid #EBEBEB;
  384. &.tit{
  385. margin-bottom: 30rpx;
  386. }
  387. &.from{
  388. margin-bottom: 30rpx;
  389. border-bottom: 1px solid #FFFFFF;
  390. flex-direction: row;
  391. display: block;
  392. .group-from{
  393. flex: 1;
  394. height: 40rpx;
  395. padding: 20rpx;
  396. line-height: 40rpx;
  397. align-items: flex-start;
  398. font-size: $font-size-24;
  399. color: $text-color;
  400. background: #F7F7F7;
  401. border-radius: 14rpx;
  402. margin-bottom: 20rpx;
  403. .form-input{
  404. height: 40rpx;
  405. line-height: 40rpx;
  406. flex-grow: 1;
  407. }
  408. }
  409. }
  410. .row-group{
  411. line-height: 88rpx;
  412. flex: 1;
  413. .text{
  414. font-size: $font-size-24;
  415. color: $text-color;
  416. line-height: 88rpx;
  417. float: left;
  418. }
  419. .row-radio{
  420. float: right;
  421. transform: scale(0.8);
  422. border-radius: 50%;
  423. }
  424. &.radio{
  425. display: flex;
  426. .row-input{
  427. flex: 1;
  428. height: 88rpx;
  429. line-height: 88rpx;
  430. }
  431. .row-radio{
  432. float: left;
  433. transform: scale(0.6);
  434. }
  435. .row-text{
  436. font-size: $font-size-24;
  437. color: $text-color;
  438. }
  439. }
  440. }
  441. }
  442. }
  443. }
  444. /* 加入购物模态层*/
  445. @keyframes showPopup {
  446. 0% {
  447. opacity: 0;
  448. }
  449. 100% {
  450. opacity: 1;
  451. }
  452. }
  453. @keyframes hidePopup {
  454. 0% {
  455. opacity: 1;
  456. }
  457. 100% {
  458. opacity: 0;
  459. }
  460. }
  461. @keyframes showLayer {
  462. 0% {
  463. transform: translateY(0);
  464. }
  465. 100% {
  466. transform: translateY(-100%);
  467. }
  468. }
  469. @keyframes hideLayer {
  470. 0% {
  471. transform: translateY(-100%);
  472. }
  473. 100% {
  474. transform: translateY(0);
  475. }
  476. }
  477. @keyframes showAmnation {
  478. 0% {
  479. top: -12rpx;
  480. opacity: 0;
  481. }
  482. 50% {
  483. top: -60rpx;
  484. opacity: 1;
  485. }
  486. 100% {
  487. top: -100rpx;
  488. opacity: 0;
  489. }
  490. }
  491. @keyframes hideAmnation {
  492. 0% {
  493. top: -100rpx;
  494. opacity: 0;
  495. }
  496. 100% {
  497. top: -12rpx;
  498. opacity: 0;
  499. }
  500. }
  501. .popup {
  502. position: fixed;
  503. top: 0;
  504. width: 100%;
  505. height: 100%;
  506. z-index: 999;
  507. display: none;
  508. .mask{
  509. position: fixed;
  510. top: 0;
  511. width: 100%;
  512. height: 100%;
  513. z-index: 21;
  514. background-color: rgba(0, 0, 0, 0.6);
  515. }
  516. .layer {
  517. position: absolute;
  518. z-index: 22;
  519. bottom: -1010rpx;
  520. width: 702rpx;
  521. padding: 24rpx 24rpx 65rpx 24rpx;
  522. height: 920rpx;
  523. border-radius: 40rpx 40rpx 0 0;
  524. background-color: #fff;
  525. display: flex;
  526. flex-wrap: wrap;
  527. align-content: space-between;
  528. .content {
  529. width: 100%;
  530. }
  531. .btn {
  532. width: 100%;
  533. height: 88rpx;
  534. display: flex;
  535. .button {
  536. width: 702rpx;
  537. height: 88rpx;
  538. color: #fff;
  539. display: flex;
  540. align-items: center;
  541. justify-content: center;
  542. font-size: $font-size-28;
  543. border-radius: 14rpx;
  544. background: $btn-confirm;
  545. }
  546. }
  547. }
  548. &.show {
  549. display: block;
  550. .mask{
  551. animation: showPopup 0.2s linear both;
  552. }
  553. .layer {
  554. animation: showLayer 0.2s linear both;
  555. }
  556. }
  557. &.hide {
  558. display: block;
  559. .mask{
  560. animation: hidePopup 0.2s linear both;
  561. }
  562. .layer {
  563. animation: hideLayer 0.2s linear both;
  564. }
  565. }
  566. &.none {
  567. display: none;
  568. }
  569. &.service {
  570. .row {
  571. margin: 30upx 0;
  572. .title {
  573. font-size: 30upx;
  574. margin: 10upx 0;
  575. }
  576. .description {
  577. font-size: 28upx;
  578. color: #999;
  579. }
  580. }
  581. }
  582. .layer-smimg{
  583. width: 114rpx;
  584. height: 114rpx;
  585. float: left;
  586. border-radius: 10rpx;
  587. margin-right: 24rpx;
  588. image{
  589. width: 114rpx;
  590. height: 114rpx;
  591. border-radius: 10rpx;
  592. }
  593. }
  594. .layer-nunbox{
  595. justify-content: space-between;
  596. align-items: center;
  597. width: 536rpx;
  598. height: 88rpx;
  599. padding: 13rpx 0 0 0;
  600. float: left;
  601. .layer-nunbox-t{
  602. width: 100%;
  603. height:44rpx;
  604. position:relative;
  605. display: flex;
  606. .layer-nunbox-text{
  607. line-height: 44rpx;
  608. font-size: $font-size-28;
  609. }
  610. .number-box{
  611. display: flex;
  612. justify-content: center;
  613. align-items: center;
  614. .iconfont{
  615. font-size: $font-size-32;
  616. padding:0 20rpx;
  617. font-size: $text-color;
  618. }
  619. .btn-input{
  620. width: 62rpx;
  621. height: 48rpx;
  622. line-height: 48rpx;
  623. background: #F8F8F8;
  624. border-radius: 4rpx;
  625. text-align: center;
  626. font-size: $font-size-28;
  627. }
  628. }
  629. .product-step{
  630. position: absolute;
  631. left: 45rpx;
  632. bottom: 0;
  633. height: 44rpx;
  634. background: #FFFFFF;
  635. }
  636. }
  637. .layer-nunbox-b{
  638. width: 100%;
  639. height:44rpx;
  640. margin-top: 13rpx;
  641. }
  642. .text{
  643. line-height: 44rpx;
  644. font-size: $font-size-28;
  645. .p{
  646. color: #FF2A2A;
  647. }
  648. .p:first-child{
  649. margin-left: 30rpx;
  650. }
  651. .p.sm{
  652. font-size: $font-size-24;
  653. }
  654. }
  655. }
  656. }
  657. </style>