index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <view>
  3. <form @submit="formSubmit" report-submit="true">
  4. <view class="panel">
  5. <view v-if="receipt_title_type == '1'" class="acea-row row-middle">
  6. <view>发票类型</view>
  7. <input name="receipt_type" :value="typeName" disabled="true" />
  8. </view>
  9. <view v-if="receipt_title_type == '2'" class="acea-row row-middle">
  10. <view>发票类型</view>
  11. <input name="receipt_type" :value="typeName" disabled="true" />
  12. <text class="iconfont icon-xiangyou" @click="callType"></text>
  13. </view>
  14. <view class="acea-row row-middle">
  15. <view>抬头类型</view>
  16. <radio-group name="receipt_title_type" @change="changeHeader">
  17. <label>
  18. <radio value="1" :checked="receipt_title_type == '1' ? true : false" /><text>个人</text>
  19. </label>
  20. <label>
  21. <radio value="2" :checked="receipt_title_type == '2' ? true : false" /><text>企业</text>
  22. </label>
  23. </radio-group>
  24. </view>
  25. <view class="acea-row row-middle">
  26. <view>发票抬头</view>
  27. <input name="receipt_title" :value="receipt_title" placeholder="需要开具发票的企业名称" disabled="true" @click="callTitle" />
  28. <text class="iconfont icon-xiangyou"></text>
  29. </view>
  30. <view v-show="receipt_title_type == '2'" class="acea-row row-middle">
  31. <view>税号</view>
  32. <input name="duty_paragraph" :value="duty_paragraph" disabled="true" placeholder="纳税人识别号" />
  33. </view>
  34. <view class="acea-row row-middle">
  35. <view>手机号</view>
  36. <input name="drawer_phone" :value="drawer_phone" disabled="true" placeholder="您的手机号" />
  37. </view>
  38. <view class="acea-row row-middle">
  39. <view>邮箱</view>
  40. <input name="email" :value="email" disabled="true" placeholder="您的联系邮箱" />
  41. </view>
  42. </view>
  43. <view v-show="receipt_title_type == '2' && receipt_type == '2'" class="panel">
  44. <view class="acea-row row-middle">
  45. <view>开户银行</view>
  46. <input name="bank_name" :value="bank_name" disabled="true" placeholder="您的开户银行" />
  47. </view>
  48. <view class="acea-row row-middle">
  49. <view>银行账号</view>
  50. <input name="bank_code" :value="bank_code" disabled="true" placeholder="您的银行账号" />
  51. </view>
  52. <view class="acea-row row-middle">
  53. <view>企业地址</view>
  54. <input name="address" :value="address" disabled="true" placeholder="您所在的企业地址" />
  55. </view>
  56. <view class="acea-row row-middle">
  57. <view>企业电话</view>
  58. <input name="tel" :value="tel" disabled="true" placeholder="您的企业电话" />
  59. </view>
  60. </view>
  61. <view class="btn-wrap">
  62. <button form-type="submit">提交申请</button>
  63. <button class="back" @tap="goBack">不开发票</button>
  64. </view>
  65. </form>
  66. <view :class="{ mask: popupType || popupTitle }"></view>
  67. <view class="popup" :class="{ on: popupType }">
  68. <view class="title">发票类型选择<text class="iconfont icon-guanbi" @click="closeType"></text></view>
  69. <scroll-view scroll-y="true">
  70. <radio-group name="invoice-type" @change="changeType">
  71. <label v-for="item in invoiceTypeList" :key="item.type" class="acea-row row-middle">
  72. <view class="text">
  73. <view>{{ item.name }}</view>
  74. <view class="info">{{ item.info }}</view>
  75. </view>
  76. <radio :value="item.type" :checked="receipt_type == item.type ? true : false" />
  77. </label>
  78. </radio-group>
  79. </scroll-view>
  80. <button @tap="closeType">确定</button>
  81. </view>
  82. <view class="popup" :class="{ on: popupTitle }">
  83. <view class="title">抬头选择<text class="iconfont icon-guanbi" @click="closeTitle"></text></view>
  84. <scroll-view scroll-y="true">
  85. <radio-group name="invoice-title" @change="changeTitle">
  86. <template v-for="item in invoiceList">
  87. <label v-if="receipt_title_type == item.receipt_title_type" :key="item.user_receipt_id" class="acea-row row-middle">
  88. <view class="text">
  89. <view class="acea-row row-middle">
  90. <view class="name">{{ item.receipt_title }}</view>
  91. <view v-if="item.is_default" class="label">默认</view>
  92. </view>
  93. <view class="type" :class="{ special: item.receipt_type == '2'}">{{ item.receipt_type == 1 ? '普通发票' : '专用发票'}}</view>
  94. </view>
  95. <radio :value="item.user_receipt_id" :checked="item.user_receipt_id == invoice_id ? true : false" />
  96. </label>
  97. </template>
  98. </radio-group>
  99. </scroll-view>
  100. <button @tap="addTitle">添加新的抬头</button>
  101. </view>
  102. <home></home>
  103. </view>
  104. </template>
  105. <script>
  106. // +----------------------------------------------------------------------
  107. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  108. // +----------------------------------------------------------------------
  109. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  110. // +----------------------------------------------------------------------
  111. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  112. // +----------------------------------------------------------------------
  113. // | Author: CRMEB Team <admin@crmeb.com>
  114. // +----------------------------------------------------------------------
  115. import home from '@/components/home';
  116. import { invoiceDefault, invoice, invoiceDetail } from '@/api/user.js';
  117. export default {
  118. components: {
  119. home
  120. },
  121. data() {
  122. return {
  123. id: '',
  124. receipt_title_type: '1',
  125. receipt_type: '1',
  126. drawer_phone: '',
  127. receipt_title: '',
  128. duty_paragraph: '',
  129. tel: '',
  130. address: '',
  131. bank_name: '',
  132. bank_code: '',
  133. is_default: 0,
  134. email: '',
  135. isDefault: [],
  136. typeName: '增值税电子普通发票',
  137. popupType: false,
  138. popupTitle: false,
  139. invoiceTypeList: [{
  140. type: '1',
  141. name: '增值税电子普通发票',
  142. info: '纸质发票开出后将以邮寄形式交付'
  143. },
  144. {
  145. type: '2',
  146. name: '增值税专用发票',
  147. info: '纸质发票开出后将以邮寄形式交付'
  148. }
  149. ],
  150. special_invoice: true,
  151. invoice_func: true,
  152. invoiceList: [],
  153. invoice_checked: '',
  154. invoice_id: '',
  155. order_id: '',
  156. news: '',
  157. cartId: '',
  158. pinkId: '',
  159. couponId: '',
  160. addressId: '',
  161. }
  162. },
  163. watch: {},
  164. onLoad(option) {
  165. this.news = option.news;
  166. this.cartId = option.cartId;
  167. this.pinkId = option.pinkId;
  168. this.couponId = option.couponId;
  169. this.addressId = option.addressId;
  170. if (option.special_invoice == 'false') {
  171. this.$set(this, 'special_invoice', false);
  172. }
  173. this.getInvoiceDefault();
  174. this.getInvoiceList();
  175. },
  176. methods: {
  177. getInvoiceList() {
  178. let params = {
  179. receipt_title_type: this.receipt_title_type,
  180. receipt_type: this.receipt_type
  181. }
  182. invoice(params).then(res => {
  183. for (let i = 0; i < res.data.length; i++) {
  184. res.data[i].user_receipt_id = res.data[i].user_receipt_id.toString();
  185. if (res.data[i].is_default) {
  186. this.invoice_id = res.data[i].user_receipt_id;
  187. }
  188. }
  189. this.$set(this, 'invoiceList', res.data);
  190. }).catch(err => {
  191. this.$util.Tips({
  192. title: err
  193. });
  194. });
  195. },
  196. getInvoiceDefault() {
  197. let params = {
  198. is_default: 1,
  199. receipt_title_type: this.receipt_title_type,
  200. receipt_type: this.receipt_type
  201. }
  202. invoice(params).then(res => {
  203. let data = res.data[0];
  204. this.receipt_title_type = data.receipt_title_type;
  205. this.receipt_type = data.receipt_type ;
  206. this.receipt_title = data.receipt_title;
  207. // this.drawer_phone = res.data.drawer_phone;
  208. this.email = data.email;
  209. this.duty_paragraph = data.duty_paragraph;
  210. this.bank_name = data.bank_name;
  211. this.bank_code = data.bank_code;
  212. this.address = data.address;
  213. this.tel = data.tel;
  214. // this.is_default = data.is_default;
  215. this.invoice_id = data.user_receipt_id.toString();
  216. }).catch(err => {});
  217. },
  218. getInvoiceDetail(id){
  219. invoiceDetail(id).then(res => {
  220. uni.hideLoading();
  221. this.receipt_title_type = res.data.receipt_title_type;
  222. this.receipt_type = res.data.receipt_type;
  223. this.typeName = this.receipt_type == '1' ? '增值税电子普通发票' : '增值税专用发票'
  224. this.receipt_title = res.data.receipt_title;
  225. // this.drawer_phone = res.data.drawer_phone;
  226. this.email = res.data.email;
  227. this.duty_paragraph = res.data.duty_paragraph;
  228. this.bank_name = res.data.bank_name;
  229. this.bank_code = res.data.bank_code;
  230. this.address = res.data.address;
  231. this.tel = res.data.tel;
  232. this.is_default = res.data.is_default;
  233. }).catch(err => {
  234. uni.hideLoading();
  235. this.$util.Tips({
  236. title: err
  237. });
  238. });
  239. },
  240. callType() {
  241. this.popupType = true;
  242. },
  243. changeType(e) {
  244. this.receipt_type = e.detail.value;
  245. this.typeName = this.invoiceTypeList.find(value => {
  246. return value.type == this.receipt_type;
  247. }).name;
  248. this.getInvoiceList();
  249. },
  250. closeType() {
  251. this.popupType = false;
  252. },
  253. callTitle() {
  254. this.popupTitle = true;
  255. },
  256. changeTitle(e) {
  257. this.invoice_id = e.detail.value.toString();
  258. this.getInvoiceDetail(e.detail.value)
  259. this.popupTitle = false;
  260. },
  261. addTitle() {
  262. uni.navigateTo({
  263. url: '/pages/users/user_invoice_list/index'
  264. });
  265. },
  266. closeTitle() {
  267. this.popupTitle = false;
  268. },
  269. changeHeader(e) {
  270. this.receipt_title_type = e.detail.value;
  271. if(e.detail.value == 1){
  272. this.receipt_type = 1;
  273. this.typeName = '增值税电子普通发票'
  274. }
  275. this.receipt_type
  276. this.getInvoiceDefault();
  277. this.getInvoiceList();
  278. },
  279. changeDefault(e) {
  280. this.is_default = e.detail.value.length ? 1 : 0;
  281. },
  282. // 提交发票数据
  283. formSubmit(e) {
  284. uni.navigateTo({
  285. url: '/pages/users/order_confirm/index?new=' + this.news + '&cartId=' + this.cartId + '&addressId=' + this.addressId +
  286. '&pinkId=' + this.pinkId + '&couponId=' + this.couponId + '&invoice_id=' + this.invoice_id + '&invoice_type=' +
  287. this.receipt_type
  288. });
  289. },
  290. goBack() {
  291. uni.navigateTo({
  292. url: '/pages/users/order_confirm/index?new=' + this.news + '&cartId=' + this.cartId + '&addressId=' + this.addressId +
  293. '&pinkId=' + this.pinkId + '&couponId=' + this.couponId
  294. });
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="scss" scoped>
  300. form {
  301. font-size: 28rpx;
  302. color: #282828;
  303. }
  304. form input,
  305. form radio-group {
  306. flex: 1;
  307. text-align: right;
  308. }
  309. form input {
  310. font-size: 26rpx;
  311. }
  312. form label {
  313. margin-right: 50rpx;
  314. }
  315. form radio {
  316. margin-right: 8rpx;
  317. }
  318. form checkbox-group {
  319. height: 90rpx;
  320. }
  321. form checkbox {
  322. margin-right: 20rpx;
  323. }
  324. form button {
  325. height: 86rpx;
  326. border-radius: 43rpx;
  327. margin: 26rpx 30rpx;
  328. background-color: #E93323;
  329. font-size: 30rpx;
  330. line-height: 86rpx;
  331. color: #FFFFFF;
  332. }
  333. .panel {
  334. padding-right: 30rpx;
  335. padding-left: 30rpx;
  336. background-color: #FFFFFF;
  337. }
  338. .panel~.panel {
  339. margin-top: 14rpx;
  340. }
  341. .panel .acea-row {
  342. height: 90rpx;
  343. }
  344. .panel .acea-row~.acea-row {
  345. border-top: 1px solid #EEEEEE;
  346. }
  347. .input-placeholder {
  348. font-size: 26rpx;
  349. color: #BBBBBB;
  350. }
  351. .icon-xiangyou {
  352. margin-left: 25rpx;
  353. font-size: 18rpx;
  354. color: #BFBFBF;
  355. cursor: pointer;
  356. }
  357. .btn-wrap {
  358. position: fixed;
  359. bottom: 58rpx;
  360. left: 0;
  361. width: 100%;
  362. }
  363. .btn-wrap .back {
  364. border: 1px solid #E93323;
  365. background: none;
  366. color: #E93323;
  367. }
  368. .popup {
  369. position: fixed;
  370. bottom: 0;
  371. left: 0;
  372. z-index: 99;
  373. width: 100%;
  374. padding-bottom: 100rpx;
  375. border-top-left-radius: 16rpx;
  376. border-top-right-radius: 16rpx;
  377. background-color: #F5F5F5;
  378. overflow: hidden;
  379. transform: translateY(100%);
  380. transition: 0.3s;
  381. }
  382. .popup.on {
  383. transform: translateY(0);
  384. }
  385. .popup .title {
  386. position: relative;
  387. height: 137rpx;
  388. font-size: 32rpx;
  389. line-height: 137rpx;
  390. text-align: center;
  391. }
  392. .popup scroll-view {
  393. height: 466rpx;
  394. padding-right: 30rpx;
  395. padding-left: 30rpx;
  396. box-sizing: border-box;
  397. }
  398. .popup label {
  399. padding: 35rpx 30rpx;
  400. border-radius: 16rpx;
  401. margin-bottom: 20rpx;
  402. background-color: #FFFFFF;
  403. }
  404. .popup .text {
  405. flex: 1;
  406. min-width: 0;
  407. font-size: 28rpx;
  408. color: #282828;
  409. }
  410. .popup .info {
  411. margin-top: 10rpx;
  412. font-size: 22rpx;
  413. color: #909090;
  414. }
  415. .popup .icon-guanbi {
  416. position: absolute;
  417. top: 50%;
  418. right: 30rpx;
  419. z-index: 2;
  420. transform: translateY(-50%);
  421. font-size: 30rpx;
  422. color: #707070;
  423. cursor: pointer;
  424. }
  425. .popup button {
  426. height: 86rpx;
  427. border-radius: 43rpx;
  428. margin-right: 30rpx;
  429. margin-left: 30rpx;
  430. background-color: #E93323;
  431. font-size: 30rpx;
  432. line-height: 86rpx;
  433. color: #FFFFFF;
  434. }
  435. .popup .text .acea-row {
  436. display: inline-flex;
  437. max-width: 100%;
  438. }
  439. .popup .name {
  440. flex: 1;
  441. overflow: hidden;
  442. white-space: nowrap;
  443. text-overflow: ellipsis;
  444. font-size: 30rpx;
  445. }
  446. .popup .label {
  447. width: 56rpx;
  448. height: 28rpx;
  449. border: 1px solid #E93323;
  450. margin-left: 18rpx;
  451. font-size: 20rpx;
  452. line-height: 26rpx;
  453. text-align: center;
  454. color: #E93323;
  455. }
  456. .popup .type {
  457. width: 124rpx;
  458. height: 42rpx;
  459. margin-top: 14rpx;
  460. background-color: #FCF0E0;
  461. font-size: 24rpx;
  462. line-height: 42rpx;
  463. text-align: center;
  464. color: #D67300;
  465. }
  466. .popup .type.special {
  467. background-color: #FDE9E7;
  468. color: #E93323;
  469. }
  470. </style>