invoiceTent.vue 16 KB

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