index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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" @click="callType" />
  12. <text class="iconfont icon-xiangyou"></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. <!-- <checkbox-group class="acea-row row-middle panel" name="isDefault" @change="changeDefault">
  62. <label>
  63. <checkbox :checked="is_default ? true : false" /><text>设置为默认抬头</text>
  64. </label>
  65. </checkbox-group> -->
  66. <view class="btn-wrap">
  67. <button form-type="submit">提交申请</button>
  68. <button class="back" @tap="goBack">不开发票</button>
  69. </view>
  70. </form>
  71. <view :class="{ mask: popupType || popupTitle }"></view>
  72. <view class="popup" :class="{ on: popupType }">
  73. <view class="title">发票类型选择<text class="iconfont icon-guanbi" @click="closeType"></text></view>
  74. <scroll-view scroll-y="true">
  75. <radio-group name="invoice-type" @change="changeType">
  76. <label v-for="item in invoiceTypeList" :key="item.type" class="acea-row row-middle">
  77. <view class="text">
  78. <view>{{ item.name }}</view>
  79. <view class="info">{{ item.info }}</view>
  80. </view>
  81. <radio :value="item.type" :checked="receipt_type == item.type ? true : false" />
  82. </label>
  83. </radio-group>
  84. </scroll-view>
  85. <button @tap="closeType">确定</button>
  86. </view>
  87. <view class="popup" :class="{ on: popupTitle }">
  88. <view class="title">抬头选择<text class="iconfont icon-guanbi" @click="closeTitle"></text></view>
  89. <scroll-view scroll-y="true">
  90. <radio-group name="invoice-title" @change="changeTitle">
  91. <template v-for="item in invoiceList">
  92. <label v-if="receipt_title_type == item.receipt_title_type" :key="item.user_receipt_id" class="acea-row row-middle">
  93. <view class="text">
  94. <view class="acea-row row-middle">
  95. <view class="name">{{ item.receipt_title }}</view>
  96. <view v-if="item.is_default" class="label">默认</view>
  97. </view>
  98. <view class="type" :class="{ special: item.receipt_type == '2'}">{{ item.receipt_type == 1 ? '普通发票' : '专用发票'}}</view>
  99. </view>
  100. <radio :value="item.user_receipt_id" :checked="item.user_receipt_id == invoice_id ? true : false" />
  101. </label>
  102. </template>
  103. </radio-group>
  104. </scroll-view>
  105. <button @tap="addTitle">添加新的抬头</button>
  106. </view>
  107. <home></home>
  108. </view>
  109. </template>
  110. <script>
  111. import home from '@/components/home';
  112. import {
  113. invoiceDefault,
  114. invoice,
  115. invoiceDetail
  116. } 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. // receipt_title_type(value) {
  165. // this.receipt_title = '';
  166. // },
  167. // invoice_id(value) {
  168. // let result = this.invoiceList.find(item => {
  169. // return item.user_receipt_id == value;
  170. // });
  171. // this.receipt_title = result.receipt_title;
  172. // }
  173. },
  174. onLoad(option) {
  175. this.news = option.news;
  176. this.cartId = option.cartId;
  177. this.pinkId = option.pinkId;
  178. this.couponId = option.couponId;
  179. this.addressId = option.addressId;
  180. if (option.special_invoice == 'false') {
  181. this.$set(this, 'special_invoice', false);
  182. }
  183. this.getInvoiceDefault();
  184. this.getInvoiceList();
  185. },
  186. methods: {
  187. getInvoiceList() {
  188. let params = {
  189. receipt_title_type: this.receipt_title_type,
  190. receipt_type: this.receipt_type
  191. }
  192. console.log(params)
  193. invoice(params).then(res => {
  194. for (let i = 0; i < res.data.length; i++) {
  195. res.data[i].user_receipt_id = res.data[i].user_receipt_id.toString();
  196. if (res.data[i].is_default) {
  197. this.invoice_id = res.data[i].user_receipt_id;
  198. }
  199. }
  200. this.$set(this, 'invoiceList', res.data);
  201. console.log(this.invoice_id)
  202. }).catch(err => {
  203. this.$util.Tips({
  204. title: err
  205. });
  206. });
  207. },
  208. getInvoiceDefault() {
  209. let params = {
  210. is_default: 1,
  211. receipt_title_type: this.receipt_title_type,
  212. receipt_type: this.receipt_type
  213. }
  214. console.log(params)
  215. invoice(params).then(res => {
  216. let data = res.data[0];
  217. this.receipt_title_type = data.receipt_title_type;
  218. this.receipt_type = data.receipt_type ;
  219. this.receipt_title = data.receipt_title;
  220. // this.drawer_phone = res.data.drawer_phone;
  221. this.email = data.email;
  222. this.duty_paragraph = data.duty_paragraph;
  223. this.bank_name = data.bank_name;
  224. this.bank_code = data.bank_code;
  225. this.address = data.address;
  226. this.tel = data.tel;
  227. // this.is_default = data.is_default;
  228. this.invoice_id = data.user_receipt_id.toString();
  229. }).catch(err => {});
  230. },
  231. getInvoiceDetail(id){
  232. invoiceDetail(id).then(res => {
  233. uni.hideLoading();
  234. this.receipt_title_type = res.data.receipt_title_type;
  235. this.receipt_type = res.data.receipt_type;
  236. this.typeName = this.receipt_type == '1' ? '增值税电子普通发票' : '增值税专用发票'
  237. this.receipt_title = res.data.receipt_title;
  238. // this.drawer_phone = res.data.drawer_phone;
  239. this.email = res.data.email;
  240. this.duty_paragraph = res.data.duty_paragraph;
  241. this.bank_name = res.data.bank_name;
  242. this.bank_code = res.data.bank_code;
  243. this.address = res.data.address;
  244. this.tel = res.data.tel;
  245. this.is_default = res.data.is_default;
  246. }).catch(err => {
  247. uni.hideLoading();
  248. this.$util.Tips({
  249. title: err
  250. });
  251. });
  252. },
  253. callType() {
  254. this.popupType = true;
  255. },
  256. changeType(e) {
  257. this.receipt_type = e.detail.value;
  258. this.typeName = this.invoiceTypeList.find(value => {
  259. return value.type == this.receipt_type;
  260. }).name;
  261. this.getInvoiceList();
  262. },
  263. closeType() {
  264. this.popupType = false;
  265. },
  266. callTitle() {
  267. this.popupTitle = true;
  268. },
  269. changeTitle(e) {
  270. console.log(e)
  271. this.invoice_id = e.detail.value.toString();
  272. this.getInvoiceDetail(e.detail.value)
  273. this.popupTitle = false;
  274. },
  275. addTitle() {
  276. uni.navigateTo({
  277. url: '/pages/users/user_invoice_list/index'
  278. });
  279. },
  280. closeTitle() {
  281. this.popupTitle = false;
  282. },
  283. changeHeader(e) {
  284. this.receipt_title_type = e.detail.value;
  285. if(e.detail.value == 1){
  286. this.receipt_type = 1;
  287. this.typeName = '增值税电子普通发票'
  288. }
  289. this.receipt_type
  290. this.getInvoiceDefault();
  291. this.getInvoiceList();
  292. },
  293. changeDefault(e) {
  294. this.is_default = e.detail.value.length ? 1 : 0;
  295. },
  296. // 提交发票数据
  297. formSubmit(e) {
  298. uni.navigateTo({
  299. url: '/pages/users/order_confirm/index?new=' + this.news + '&cartId=' + this.cartId + '&addressId=' + this.addressId +
  300. '&pinkId=' + this.pinkId + '&couponId=' + this.couponId + '&invoice_id=' + this.invoice_id + '&invoice_type=' +
  301. this.receipt_type
  302. });
  303. },
  304. goBack() {
  305. uni.navigateTo({
  306. url: '/pages/users/order_confirm/index?new=' + this.news + '&cartId=' + this.cartId + '&addressId=' + this.addressId +
  307. '&pinkId=' + this.pinkId + '&couponId=' + this.couponId
  308. });
  309. }
  310. }
  311. }
  312. </script>
  313. <style scoped>
  314. form {
  315. font-size: 28rpx;
  316. color: #282828;
  317. }
  318. form input,
  319. form radio-group {
  320. flex: 1;
  321. text-align: right;
  322. }
  323. form input {
  324. font-size: 26rpx;
  325. }
  326. form label {
  327. margin-right: 50rpx;
  328. }
  329. form radio {
  330. margin-right: 8rpx;
  331. }
  332. form checkbox-group {
  333. height: 90rpx;
  334. }
  335. form checkbox {
  336. margin-right: 20rpx;
  337. }
  338. form button {
  339. height: 86rpx;
  340. border-radius: 43rpx;
  341. margin: 26rpx 30rpx;
  342. background-color: #E93323;
  343. font-size: 30rpx;
  344. line-height: 86rpx;
  345. color: #FFFFFF;
  346. }
  347. .panel {
  348. padding-right: 30rpx;
  349. padding-left: 30rpx;
  350. background-color: #FFFFFF;
  351. }
  352. .panel~.panel {
  353. margin-top: 14rpx;
  354. }
  355. .panel .acea-row {
  356. height: 90rpx;
  357. }
  358. .panel .acea-row~.acea-row {
  359. border-top: 1rpx solid #EEEEEE;
  360. }
  361. .input-placeholder {
  362. font-size: 26rpx;
  363. color: #BBBBBB;
  364. }
  365. .icon-xiangyou {
  366. margin-left: 25rpx;
  367. font-size: 18rpx;
  368. color: #BFBFBF;
  369. }
  370. .btn-wrap {
  371. position: fixed;
  372. bottom: 58rpx;
  373. left: 0;
  374. width: 100%;
  375. }
  376. .btn-wrap .back {
  377. border: 1rpx solid #E93323;
  378. background: none;
  379. color: #E93323;
  380. }
  381. .popup {
  382. position: fixed;
  383. bottom: 0;
  384. left: 0;
  385. z-index: 99;
  386. width: 100%;
  387. padding-bottom: 100rpx;
  388. border-top-left-radius: 16rpx;
  389. border-top-right-radius: 16rpx;
  390. background-color: #F5F5F5;
  391. overflow: hidden;
  392. transform: translateY(100%);
  393. transition: 0.3s;
  394. }
  395. .popup.on {
  396. transform: translateY(0);
  397. }
  398. .popup .title {
  399. position: relative;
  400. height: 137rpx;
  401. font-size: 32rpx;
  402. line-height: 137rpx;
  403. text-align: center;
  404. }
  405. .popup scroll-view {
  406. height: 466rpx;
  407. padding-right: 30rpx;
  408. padding-left: 30rpx;
  409. box-sizing: border-box;
  410. }
  411. .popup label {
  412. padding: 35rpx 30rpx;
  413. border-radius: 16rpx;
  414. margin-bottom: 20rpx;
  415. background-color: #FFFFFF;
  416. }
  417. .popup .text {
  418. flex: 1;
  419. min-width: 0;
  420. font-size: 28rpx;
  421. color: #282828;
  422. }
  423. .popup .info {
  424. margin-top: 10rpx;
  425. font-size: 22rpx;
  426. color: #909090;
  427. }
  428. .popup .icon-guanbi {
  429. position: absolute;
  430. top: 50%;
  431. right: 30rpx;
  432. z-index: 2;
  433. transform: translateY(-50%);
  434. font-size: 30rpx;
  435. color: #707070;
  436. cursor: pointer;
  437. }
  438. .popup button {
  439. height: 86rpx;
  440. border-radius: 43rpx;
  441. margin-right: 30rpx;
  442. margin-left: 30rpx;
  443. background-color: #E93323;
  444. font-size: 30rpx;
  445. line-height: 86rpx;
  446. color: #FFFFFF;
  447. }
  448. .popup .text .acea-row {
  449. display: inline-flex;
  450. max-width: 100%;
  451. }
  452. .popup .name {
  453. flex: 1;
  454. overflow: hidden;
  455. white-space: nowrap;
  456. text-overflow: ellipsis;
  457. font-size: 30rpx;
  458. }
  459. .popup .label {
  460. width: 56rpx;
  461. height: 28rpx;
  462. border: 1rpx solid #E93323;
  463. margin-left: 18rpx;
  464. font-size: 20rpx;
  465. line-height: 26rpx;
  466. text-align: center;
  467. color: #E93323;
  468. }
  469. .popup .type {
  470. width: 124rpx;
  471. height: 42rpx;
  472. margin-top: 14rpx;
  473. background-color: #FCF0E0;
  474. font-size: 24rpx;
  475. line-height: 42rpx;
  476. text-align: center;
  477. color: #D67300;
  478. }
  479. .popup .type.special {
  480. background-color: #FDE9E7;
  481. color: #E93323;
  482. }
  483. </style>