invoiceTent.vue 17 KB

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