sellerInvoice.vue 17 KB

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