invoiceTent.vue 17 KB

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