index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <view :style="viewColor">
  3. <view class="add_invoicing" :class="invoice.invoice==true?'on':''">
  4. <view class='title'>选择发票<text class='iconfont icon-guanbi' @tap='close'></text></view>
  5. <form @submit="formSubmit" report-submit="true">
  6. <view class="panel">
  7. <view v-if="receipt_title_type == '1'" class="acea-row row-middle">
  8. <view>发票类型</view>
  9. <input name="receipt_type" :value="typeName" disabled="true" />
  10. </view>
  11. <view v-if="receipt_title_type == '2'" class="acea-row row-middle">
  12. <view>发票类型</view>
  13. <input name="receipt_type" :value="typeName" disabled="true" />
  14. <text class="iconfont icon-xiangyou" @click.stop="callType"></text>
  15. </view>
  16. <view class="acea-row row-middle">
  17. <view>抬头类型</view>
  18. <radio-group name="receipt_title_type" @change="changeHeader">
  19. <label>
  20. <radio value="1" :checked="receipt_title_type == '1' ? true : false" /><text>个人</text>
  21. </label>
  22. <label>
  23. <radio value="2" :checked="receipt_title_type == '2' ? true : false" /><text>企业</text>
  24. </label>
  25. </radio-group>
  26. </view>
  27. <view class="acea-row row-middle">
  28. <view>发票抬头</view>
  29. <input name="receipt_title" :value="receipt_title" :maxlength="20" placeholder="需要开具发票的企业名称"/>
  30. <text class="iconfont icon-xiangyou" @click="callTitle" ></text>
  31. </view>
  32. <view v-show="receipt_title_type == '2'" class="acea-row row-middle">
  33. <view>税号</view>
  34. <input name="duty_paragraph" :value="duty_paragraph" placeholder="纳税人识别号" />
  35. </view>
  36. <view class="acea-row row-middle">
  37. <view>邮箱</view>
  38. <input name="email" :value="email" placeholder="您的联系邮箱" />
  39. </view>
  40. </view>
  41. <view v-show="receipt_title_type == '2' && receipt_type == '2'" class="panel">
  42. <view class="acea-row row-middle" style="border-top: 1px solid #EEEEEE;">
  43. <view>开户银行</view>
  44. <input name="bank_name" :value="bank_name" placeholder="您的开户银行" />
  45. </view>
  46. <view class="acea-row row-middle">
  47. <view>银行账号</view>
  48. <input name="bank_code" :value="bank_code" placeholder="您的银行账号" />
  49. </view>
  50. <view class="acea-row row-middle">
  51. <view>企业地址</view>
  52. <input name="address" :value="address" placeholder="您所在的企业地址" />
  53. </view>
  54. <view class="acea-row row-middle">
  55. <view>企业电话</view>
  56. <input name="tel" :value="tel" placeholder="您的企业电话" />
  57. </view>
  58. </view>
  59. <view class="btn-wrap">
  60. <button class="button" form-type="submit">提交申请</button>
  61. <button class="back" @tap="noInvoice">不开发票</button>
  62. </view>
  63. </form>
  64. <view :class="{ mask: popupType || popupTitle }"></view>
  65. <view class="popup" :class="{ on: popupType }">
  66. <view class="title">发票类型选择<text class="iconfont icon-guanbi" @click="closeType"></text></view>
  67. <scroll-view scroll-y="true">
  68. <radio-group name="invoice-type" @change="changeType">
  69. <label v-for="item in invoiceTypeList" :key="item.type" class="acea-row row-middle">
  70. <view class="text">
  71. <view>{{ item.name }}</view>
  72. <view class="info">{{ item.info }}</view>
  73. </view>
  74. <radio :value="item.type" :checked="receipt_type == item.type ? true : false" />
  75. </label>
  76. </radio-group>
  77. </scroll-view>
  78. <button @tap="closeType">确定</button>
  79. </view>
  80. <view class="popup" :class="{ on: popupTitle }">
  81. <view class="title">抬头选择<text class="iconfont icon-guanbi" @click="closeTitle"></text></view>
  82. <scroll-view v-if="invoiceList.length > 0" scroll-y="true">
  83. <radio-group name="invoice-title" @change="changeTitle">
  84. <template v-for="item in invoiceList">
  85. <label :key="item.user_receipt_id" class="acea-row row-middle">
  86. <view class="text">
  87. <view class="acea-row row-middle">
  88. <view class="name">{{ item.receipt_title }}</view>
  89. <view v-if="item.is_default" class="label">默认</view>
  90. </view>
  91. <view class="type" :class="{ special: item.receipt_type == '2'}">{{ item.receipt_type == 1 ? '普通发票' : '专用发票'}}</view>
  92. </view>
  93. <radio :value="item.user_receipt_id" :checked="item.user_receipt_id == invoice_id ? true : false" />
  94. </label>
  95. </template>
  96. </radio-group>
  97. </scroll-view>
  98. <view v-else class="nothing">
  99. <image :src="`${domain}/static/images/noInvoice.png`"></image>
  100. <view class="nothing_text">您还没有添加发票信息哟~</view>
  101. </view>
  102. <button v-if="invoice.add" @tap="addTitle">添加新的抬头</button>
  103. <button v-else @tap="close" class="btn-default">不开发票</button>
  104. </view>
  105. </view>
  106. <view class='mask' catchtouchmove="true" :hidden='invoice.invoice==false' @tap='close'></view>
  107. </view>
  108. </template>
  109. <script>
  110. // +----------------------------------------------------------------------
  111. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  112. // +----------------------------------------------------------------------
  113. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  114. // +----------------------------------------------------------------------
  115. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  116. // +----------------------------------------------------------------------
  117. // | Author: CRMEB Team <admin@crmeb.com>
  118. // +----------------------------------------------------------------------
  119. import { invoiceDefault, invoice, invoiceDetail } from '@/api/user.js';
  120. import { mapGetters } from "vuex";
  121. import { HTTP_REQUEST_URL } from '@/config/app';
  122. export default {
  123. props: {
  124. invoice: {
  125. type: Object,
  126. default: function() {
  127. return {
  128. invoice: false,
  129. mer_id: 0,
  130. };
  131. }
  132. }
  133. },
  134. computed: { ...mapGetters(['viewColor'])},
  135. data() {
  136. return {
  137. domain: HTTP_REQUEST_URL,
  138. id: '',
  139. receipt_title_type: '1',
  140. receipt_type: '1',
  141. drawer_phone: '',
  142. receipt_title: '',
  143. duty_paragraph: '',
  144. tel: '',
  145. address: '',
  146. bank_name: '',
  147. bank_code: '',
  148. is_default: 0,
  149. email: '',
  150. isDefault: [],
  151. typeName: '增值税电子普通发票',
  152. popupType: false,
  153. popupTitle: false,
  154. invoiceTypeList: [{
  155. type: '1',
  156. name: '增值税电子普通发票',
  157. info: '默认发送至所提供的电子邮件'
  158. },
  159. {
  160. type: '2',
  161. name: '增值税专用发票',
  162. info: '纸质发票开出后将以邮寄形式交付'
  163. }
  164. ],
  165. special_invoice: true,
  166. invoice_func: true,
  167. invoiceList: [],
  168. invoice_checked: '',
  169. invoice_id: '',
  170. order_id: '',
  171. news: '',
  172. cartId: '',
  173. pinkId: '',
  174. couponId: '',
  175. addressId: '',
  176. invoiceData: {},
  177. formvalidate: false
  178. }
  179. },
  180. watch: {
  181. },
  182. onLoad(option) {
  183. this.news = option.news;
  184. this.cartId = option.cartId;
  185. this.pinkId = option.pinkId;
  186. this.couponId = option.couponId;
  187. this.addressId = option.addressId;
  188. if (option.special_invoice == 'false') {
  189. this.$set(this, 'special_invoice', false);
  190. }
  191. },
  192. onShow(){
  193. this.getInvoiceDefault();
  194. this.popupTitle = false;
  195. },
  196. methods: {
  197. getInvoiceList() {
  198. let params = {
  199. // receipt_title_type: this.receipt_title_type,
  200. // receipt_type: this.receipt_type
  201. }
  202. invoice().then(res => {
  203. for (let i = 0; i < res.data.length; i++) {
  204. res.data[i].user_receipt_id = res.data[i].user_receipt_id.toString();
  205. if (res.data[i].is_default) {
  206. this.invoice_id = res.data[i].user_receipt_id;
  207. }
  208. }
  209. this.$set(this, 'invoiceList', res.data);
  210. }).catch(err => {
  211. this.$util.Tips({
  212. title: err
  213. });
  214. });
  215. },
  216. getInvoiceDefault() {
  217. let params = {
  218. is_default: 1,
  219. // receipt_title_type: this.receipt_title_type,
  220. // receipt_type: this.receipt_type
  221. }
  222. invoice(params).then(res => {
  223. let data = res.data[0];
  224. this.typeName = data.receipt_type == '1' ? '增值税电子普通发票' : '增值税专用发票'
  225. this.receipt_title_type = data.receipt_title_type;
  226. this.receipt_type = data.receipt_type ;
  227. this.receipt_title = data.receipt_title;
  228. // this.drawer_phone = res.data.drawer_phone;
  229. this.email = data.email;
  230. this.duty_paragraph = data.duty_paragraph;
  231. this.bank_name = data.bank_name;
  232. this.bank_code = data.bank_code;
  233. this.address = data.address;
  234. this.tel = data.tel;
  235. this.invoice_id = data.user_receipt_id.toString();
  236. this.popupTitle = false;
  237. }).catch(err => {});
  238. },
  239. getInvoiceDetail(id){
  240. invoiceDetail(id).then(res => {
  241. uni.hideLoading();
  242. this.receipt_title_type = res.data.receipt_title_type;
  243. this.receipt_type = res.data.receipt_type;
  244. this.typeName = this.receipt_type == '1' ? '增值税电子普通发票' : '增值税专用发票'
  245. this.receipt_title = res.data.receipt_title;
  246. this.email = res.data.email;
  247. this.duty_paragraph = res.data.duty_paragraph;
  248. this.bank_name = res.data.bank_name;
  249. this.bank_code = res.data.bank_code;
  250. this.address = res.data.address;
  251. this.tel = res.data.tel;
  252. this.is_default = res.data.is_default;
  253. }).catch(err => {
  254. uni.hideLoading();
  255. this.$util.Tips({
  256. title: err
  257. });
  258. });
  259. },
  260. close: function() {
  261. if(this.formvalidate){
  262. this.$emit('changeInvoiceClose',this.invoiceData)
  263. }else{
  264. this.$emit('changeInvoiceClose','');
  265. }
  266. },
  267. noInvoice: function(){
  268. uni.setStorage({
  269. key:'invoice_Data',
  270. data:{},
  271. success: function(){}
  272. })
  273. this.$emit('changeInvoiceClose','');
  274. },
  275. callType() {
  276. this.popupType = true;
  277. },
  278. changeType(e) {
  279. this.receipt_type = e.detail.value;
  280. this.typeName = this.invoiceTypeList.find(value => {
  281. return value.type == this.receipt_type;
  282. }).name;
  283. },
  284. closeType() {
  285. this.popupType = false;
  286. },
  287. callTitle() {
  288. this.popupTitle = true;
  289. },
  290. changeTitle(e) {
  291. this.invoice_id = e.detail.value.toString();
  292. this.getInvoiceDetail(e.detail.value)
  293. this.popupTitle = false;
  294. },
  295. addTitle() {
  296. this.popupType = false;
  297. this.popupTitle = false;
  298. uni.navigateTo({
  299. url: '/pages/users/user_invoice_form/index?mer_id='+this.invoice.mer_id
  300. });
  301. },
  302. closeTitle() {
  303. this.popupTitle = false;
  304. },
  305. changeHeader(e) {
  306. this.receipt_title_type = e.detail.value;
  307. if(e.detail.value == 1){
  308. this.receipt_type = 1;
  309. this.typeName = '增值税电子普通发票'
  310. }
  311. this.receipt_type
  312. },
  313. changeDefault(e) {
  314. this.is_default = e.detail.value.length ? 1 : 0;
  315. },
  316. // 提交发票数据
  317. formSubmit(e) {
  318. let that = this,
  319. value = e.detail.value;
  320. if (!value.receipt_title_type) return that.$util.Tips({
  321. title: '请填写发票抬头'
  322. });
  323. if (!value.email) return that.$util.Tips({
  324. title: '请填写邮箱'
  325. });
  326. if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(value.email)) return that.$util.Tips({
  327. title: '请输入正确的邮箱'
  328. });
  329. if(value.receipt_title_type == 2){
  330. if (!value.duty_paragraph) return that.$util.Tips({
  331. title: '请填写税号'
  332. });
  333. if(value.receipt_type == '增值税专用发票'){
  334. if (!value.bank_name) return that.$util.Tips({
  335. title: '请填写开户行'
  336. });
  337. if (!value.bank_code) return that.$util.Tips({
  338. title: '请填写银行账号'
  339. });
  340. if (!value.address) return that.$util.Tips({
  341. title: '请填写企业地址'
  342. });
  343. if (!value.tel) return that.$util.Tips({
  344. title: '请填写企业电话'
  345. });
  346. if(!/^(\d{9}|\d{14}|\d{18})$/.test(value.bank_code)){
  347. return this.$util.Tips({
  348. title: '请输入正确的银行账号'
  349. });
  350. }
  351. if(!/(^(\d{3,4})?\d{7,8})$|(13[0-9]{9})/.test(value.tel)){
  352. return this.$util.Tips({
  353. title: '请输入正确的电话号码'
  354. });
  355. }
  356. }
  357. }
  358. that.formvalidate = true;
  359. value.mer_id = that.invoice.mer_id;
  360. value.receipt_type = that.receipt_type;
  361. that.invoiceData = value
  362. uni.setStorage({
  363. key:'invoice_Data',
  364. data: [that.invoiceData],
  365. success: function(){
  366. }
  367. })
  368. that.$emit('changeInvoiceClose',that.invoiceData)
  369. }
  370. }
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .add_invoicing{
  375. position: fixed;
  376. bottom: 0;
  377. width: 100%;
  378. left: 0;
  379. background-color: #fff;
  380. z-index: 77;
  381. border-radius: 16rpx 16rpx 0 0;
  382. padding-bottom: 20rpx;
  383. transform: translate3d(0, 100%, 0);
  384. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  385. }
  386. .add_invoicing.on {
  387. transform: translate3d(0, 0, 0);
  388. }
  389. .add_invoicing .title {
  390. font-size: 32rpx;
  391. font-weight: bold;
  392. text-align: center;
  393. height: 123rpx;
  394. line-height: 123rpx;
  395. position: relative;
  396. }
  397. .add_invoicing .title .iconfont {
  398. position: absolute;
  399. right: 30rpx;
  400. color: #8a8a8a;
  401. font-size: 35rpx;
  402. }
  403. form {
  404. font-size: 28rpx;
  405. color: #282828;
  406. }
  407. form input, form radio-group {
  408. flex: 1;
  409. text-align: right;
  410. }
  411. form input {
  412. font-size: 26rpx;
  413. }
  414. form label {
  415. margin-right: 50rpx;
  416. }
  417. form radio {
  418. margin-right: 8rpx;
  419. }
  420. form checkbox-group {
  421. height: 90rpx;
  422. }
  423. form checkbox {
  424. margin-right: 20rpx;
  425. }
  426. /deep/radio .uni-radio-input.uni-radio-input-checked,
  427. /deep/radio .wx-radio-input.wx-radio-input-checked{
  428. border: 1px solid var(--view-theme) !important;
  429. background-color: var(--view-theme) !important
  430. }
  431. form button {
  432. height: 76rpx;
  433. border-radius: 38rpx;
  434. margin: 16rpx 30rpx;
  435. background-color: var(--view-theme);
  436. font-size: 30rpx;
  437. line-height: 76rpx;
  438. color: #FFFFFF;
  439. }
  440. .panel {
  441. padding-right: 30rpx;
  442. padding-left: 30rpx;
  443. background-color: #FFFFFF;
  444. }
  445. .panel~.panel {
  446. margin-top: 14rpx;
  447. }
  448. .panel .acea-row {
  449. height: 90rpx;
  450. }
  451. .panel .acea-row~.acea-row {
  452. border-top: 1px solid #EEEEEE;
  453. }
  454. .input-placeholder {
  455. font-size: 26rpx;
  456. color: #BBBBBB;
  457. }
  458. .icon-xiangyou {
  459. margin-left: 25rpx;
  460. font-size: 18rpx;
  461. color: #BFBFBF;
  462. cursor: pointer;
  463. }
  464. .btn-wrap {
  465. width: 100%;
  466. border-top: 1px solid #F5F5F5;
  467. }
  468. .btn-wrap .button{
  469. height: 86rpx;
  470. line-height: 86rpx;
  471. border-radius: 50rpx;
  472. }
  473. .btn-wrap .back {
  474. border-radius: 50rpx;
  475. height: 86rpx;
  476. line-height: 86rpx;
  477. border: 1rpx solid var(--view-theme);
  478. background: none;
  479. color: var(--view-theme);
  480. }
  481. .popup {
  482. position: fixed;
  483. bottom: 0;
  484. left: 0;
  485. z-index: 99;
  486. width: 100%;
  487. padding-bottom: 30rpx;
  488. border-top-left-radius: 16rpx;
  489. border-top-right-radius: 16rpx;
  490. background-color: #F5F5F5;
  491. overflow: hidden;
  492. transform: translateY(100%);
  493. transition: 0.3s;
  494. }
  495. .popup.on {
  496. transform: translateY(0);
  497. }
  498. .popup .title {
  499. position: relative;
  500. height: 137rpx;
  501. font-size: 32rpx;
  502. line-height: 137rpx;
  503. text-align: center;
  504. }
  505. .popup scroll-view {
  506. height: 466rpx;
  507. padding-right: 30rpx;
  508. padding-left: 30rpx;
  509. box-sizing: border-box;
  510. }
  511. .popup label {
  512. padding: 35rpx 30rpx;
  513. border-radius: 16rpx;
  514. margin-bottom: 20rpx;
  515. background-color: #FFFFFF;
  516. }
  517. .popup .text {
  518. flex: 1;
  519. min-width: 0;
  520. font-size: 28rpx;
  521. color: #282828;
  522. }
  523. .popup .info {
  524. margin-top: 10rpx;
  525. font-size: 22rpx;
  526. color: #909090;
  527. }
  528. .popup .icon-guanbi {
  529. position: absolute;
  530. top: 50%;
  531. right: 30rpx;
  532. z-index: 2;
  533. transform: translateY(-50%);
  534. font-size: 30rpx;
  535. color: #707070;
  536. cursor: pointer;
  537. }
  538. .popup button {
  539. height: 86rpx;
  540. border-radius: 43rpx;
  541. margin-right: 30rpx;
  542. margin-left: 30rpx;
  543. background-color: var(--view-theme);
  544. font-size: 30rpx;
  545. line-height: 86rpx;
  546. color: #FFFFFF;
  547. }
  548. button{
  549. margin-top: 30rpx;
  550. }
  551. button.btn-default{
  552. background-color: transparent;
  553. color: var(--view-theme);
  554. border: 1px solid var(--view-theme);
  555. }
  556. .popup .text .acea-row {
  557. display: inline-flex;
  558. max-width: 100%;
  559. }
  560. .popup .name {
  561. flex: 1;
  562. overflow: hidden;
  563. white-space: nowrap;
  564. text-overflow: ellipsis;
  565. font-size: 30rpx;
  566. }
  567. .popup .label {
  568. width: 70rpx;
  569. height: 28rpx;
  570. border: 1px solid #E93323;
  571. margin-left: 18rpx;
  572. font-size: 16rpx;
  573. line-height: 26rpx;
  574. text-align: center;
  575. color: #E93323;
  576. }
  577. .popup .type {
  578. width: 124rpx;
  579. height: 42rpx;
  580. margin-top: 14rpx;
  581. background-color: #FCF0E0;
  582. font-size: 24rpx;
  583. line-height: 42rpx;
  584. text-align: center;
  585. color: #D67300;
  586. }
  587. .popup .type.special {
  588. background-color: #FDE9E7;
  589. color: #E93323;
  590. }
  591. .nothing {
  592. margin: 50rpx 0;
  593. text-align: center;
  594. image, uni-image{
  595. width: 400rpx;
  596. height: 260rpx;
  597. }
  598. }
  599. .nothing_text{
  600. margin-top: 20rpx;
  601. color: #999999;
  602. }
  603. </style>