invoiceTent.vue 15 KB

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