invoiceTent.vue 15 KB

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