parkingReceipt.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. // const app = getApp()
  2. const app = {};
  3. import moment from 'moment';
  4. import arrowIcon from '@/pages/parkingFee/static/images/arrows.png';
  5. import noData from '@/pages/parkingFee/static/images/no-invoice.svg';
  6. import { mapState } from 'vuex';
  7. import LoginDom from '@/components/Login/Login.vue';
  8. // import authorize from '@/components/authorize/authorize.vue'
  9. import MemberCacheTool from '@/utils/member-cache-tool.js';
  10. import { REG_SOURCE } from '@/constants.js';
  11. import uni from '@/utils/uniHooks';
  12. import { myNotInvoicedList } from '@/pages/parkingFee/list';
  13. import { wxToLoginCallback } from '@/utils';
  14. import CacheTool from '@/utils/cache-tool'
  15. import { invoicesCompleted, invoicesNotapplied } from '@/api/parking';
  16. import { Dialog } from 'vant';
  17. export default {
  18. data() {
  19. return {
  20. globalData: app.globalData,
  21. picUrl: this.$picUrl,
  22. baseUrl: this.$baseURL,
  23. arrowIcon: arrowIcon,
  24. noData: noData,
  25. tabIndex: 0,
  26. invoiceList: ['未开票', '已开票'],
  27. list: [],
  28. isCheckTickets: [],
  29. total: 0,
  30. isLoadMore: false,
  31. loadStatus: 'loading',
  32. pagesize: 10,
  33. page: 0,
  34. current: -1,
  35. isCheckAll: 0,
  36. ids: [],
  37. totalNum: 0.0,
  38. options: null,
  39. preUrl: '',
  40. invoiceDetailList: [],
  41. boxids: [],
  42. choosekMax: 200,
  43. statusObj:{
  44. 'COMPLETE': {
  45. name: '开票完成'
  46. },
  47. 'SUBMITTED': {
  48. name: '开票中'
  49. },
  50. 'FAILED': {
  51. name:'开票失败'
  52. },
  53. 3: {
  54. name:'开票失败'
  55. },
  56. 2: {
  57. name:'开票中'
  58. }
  59. },
  60. // 用户拒绝登录
  61. userStopLogin: false
  62. };
  63. },
  64. components: {
  65. // authorize,
  66. LoginDom,
  67. },
  68. computed: {
  69. height() {
  70. return this.list.length ? 'auto' : '100%';
  71. },
  72. isJingAn () {
  73. let mallid = this.mallId;
  74. if (!mallid) {
  75. mallid = uni.getStorageSync('mallId');
  76. }
  77. return CacheTool.isJingAnMallid(mallid);
  78. },
  79. ...mapState({
  80. custTypeId: (state) => state.custTypeId,
  81. groupId: (state) => state.groupId,
  82. openid: (state) => state.openid,
  83. mallId: (state) => state.mallId,
  84. kipUserId: (state) => state.kipUserId,
  85. userInfo: (state) => state.userInfo,
  86. member: (state) => state.member,
  87. mobile: (state) => state.mobile,
  88. source: (state) => state.source,
  89. isLogin: (state) => state.isLogin,
  90. }),
  91. },
  92. created() {
  93. if(window.history?.scrollRestoration) {
  94. window.history.scrollRestoration = 'manual';
  95. }
  96. // 埋点本地化
  97. this.preUrl = uni.getStorageSync('previousUrl');
  98. this.$store.dispatch('invoice/init')
  99. uni.setStorageSync(
  100. 'previousUrl',
  101. '/pages/parkingFee/parkingReceipt/parkingReceipt.vue'
  102. );
  103. window.addEventListener('scroll', this.choice_card_scroll)
  104. },
  105. destroyed() {
  106. window.removeEventListener('scroll', this.choice_card_scroll)
  107. },
  108. mounted() {
  109. // // const member = uni.getStorageSync('member')
  110. // setTimeout(() => {
  111. // uni.setNavigationBarTitle({
  112. // title: '停车发票',
  113. // });
  114. // }, 300);
  115. // setTimeout(() => {
  116. // window?.toWXSendMsg({
  117. // type: 'uni_func',
  118. // funcName: 'setNavigationBarColor',
  119. // options: {
  120. // frontColor: '#000000',
  121. // backgroundColor: '#FBFCFF',
  122. // },
  123. // });
  124. // }, 500)
  125. const invoiceindex = Number.parseInt(uni.getStorageSync('invoiceindex') || 1)
  126. this.$store.dispatch('clearUnlicensed');
  127. // 如果是公众号访问的话,并且未登录, 除浦东静安之外,都不加载数据
  128. if (this.$route.query.parkingFeeIsLogin === 'loginDenied' && this.$route.query?.loginCount) {
  129. this.userStopLogin = ['JINGAN', 'PUDONG'].indexOf(this.source) < 0
  130. this.isLoadMore = this.userStopLogin
  131. this.invoice(invoiceindex)
  132. return
  133. }
  134. // 如果用户登录时 或者 是浦东和静安访问的话,展示开票内容
  135. if (this.isLogin === 'haveLoggedIn' || ['JINGAN', 'PUDONG'].indexOf(this.source) > -1) {
  136. this.invoice(invoiceindex);
  137. } else if ((this.isLogin === 'notLoggedIn' || this.isLogin === 'loginDenied') && !this.$route.query?.loginCount) {
  138. wx.miniProgram.redirectTo({
  139. "url": "/pages/package-parkingFee/parkingFeeWebViewLogin?needLogin=1&fromPage=parkingReceipt" // 去 login 页面 1 去登录
  140. })
  141. // 跳转登录
  142. // return
  143. } else {
  144. this.$router.back();
  145. // return
  146. }
  147. },
  148. watch: {},
  149. filters: {
  150. parkingTime(val) {
  151. const days = parseInt(val / 60 / 24);
  152. const hours = parseInt((val / 60) % 24);
  153. const minutes = parseInt(val % 60);
  154. if (days > 0) {
  155. return `${days}天 ${hours}小时 ${minutes}分钟`;
  156. }
  157. if (hours > 0) {
  158. return `${hours}小时 ${minutes}分钟`;
  159. }
  160. return `${minutes}分钟`;
  161. },
  162. },
  163. methods: {
  164. checkboxchange2 (e, index) {
  165. if (this.boxids.length > this.choosekMax) {
  166. console.log(2222222222)
  167. this.$refs.checkboxes[index].toggle();
  168. }
  169. console.log('eeeeeeee:::', e, index)
  170. },
  171. invoice(e) {
  172. if(this.tabIndex === e) return;
  173. uni.setStorageSync('invoiceindex', e);
  174. this.tabIndex = e;
  175. this.current = -1;
  176. this.ids = [];
  177. this.totalNum = 0.00;
  178. this.page = 0;
  179. this.list = [];
  180. if (this.userStopLogin) return
  181. this.getInvoiceList();
  182. },
  183. goToDeatil(item) {
  184. if (this.tabIndex === 2 && item.status === 'COMPLETE') {
  185. this.$router.push({
  186. path: 'parkingInvoice',
  187. query:{
  188. ...this.$route.query,
  189. id: item.id
  190. }
  191. });
  192. }
  193. },
  194. goToInvoicing() {
  195. if (this.ids.length <= 0) {
  196. uni.showToast({
  197. title: '请选择您要开票的记录',
  198. icon: 'none',
  199. });
  200. return false;
  201. }
  202. if (this.totalNum <= 0) {
  203. uni.showToast({
  204. title: '请选择金额大于0的缴费记录',
  205. icon: 'none',
  206. });
  207. return false;
  208. }
  209. this.$router.push({
  210. path: 'parkingApplication',
  211. query: {
  212. ...this.$route.query,
  213. ids: this.ids,
  214. invoiceDetailList: JSON.stringify(this.invoiceDetailList),
  215. money: this.totalNum
  216. }
  217. });
  218. },
  219. radioChange: function (evt) {
  220. for (let i = 0; i < this.list.length; i++) {
  221. if (this.list[i].id === evt.detail.value) {
  222. this.current = i;
  223. this.ids = [this.list[i].id];
  224. this.totalNum = this.list[i].totalPaidAmount;
  225. if (this.ids > 2) {
  226. Dialog.confirm({
  227. message: '确认要删除该发票抬头吗?',
  228. confirmButtonColor: this.$theme[this.theme].primaryColor,
  229. })
  230. .then(() => {
  231. })
  232. .catch(() => {
  233. // on cancel
  234. });
  235. }
  236. break;
  237. }
  238. }
  239. },
  240. scrollLower() {
  241. console.log('到底了........');
  242. if (!this.isLoadMore) {
  243. this.isLoadMore = true;
  244. this.page += 1;
  245. this.getInvoiceList();
  246. }
  247. },
  248. choice_card_scroll(e) {
  249. const scrollable = e.srcElement.scrollingElement;
  250. const isAtBottom = scrollable.scrollHeight - scrollable.scrollTop <= scrollable.clientHeight + 200;
  251. if (isAtBottom) {
  252. // 已经滑动到底部
  253. // console.log('滑动到底部');
  254. this.scrollLower()
  255. }
  256. },
  257. getInvoiceList: async function (){
  258. const self = this;
  259. // const openId = MemberCacheTool.getOpenId(app)
  260. var params = {
  261. // openId: this.openid,
  262. // mallid: this.mallId,
  263. // vipcode: this.member?.vipcode,
  264. page: this.page,
  265. size: this.pagesize,
  266. };
  267. try {
  268. let res = null;
  269. if (this.tabIndex === 1) {
  270. res = await invoicesNotapplied(params)
  271. } else {
  272. res = await invoicesCompleted(params)
  273. }
  274. console.log('99', res)
  275. if (res) {
  276. this.total = res.size;
  277. const listarr = res.content
  278. if (listarr.length > 0) {
  279. this.list = this.list.concat(res.content)
  280. }
  281. // 返回数据量小于pagesize,则表示此为最后一页
  282. if (res.content.length < this.pagesize) {
  283. this.isLoadMore = true;
  284. this.loadStatus = 'nomore';
  285. } else {
  286. this.isLoadMore = false;
  287. }
  288. } else {
  289. this.isLoadMore = true;
  290. this.loadStatus = 'nomore';
  291. }
  292. } catch(err) {
  293. this.isLoadMore = false;
  294. if (this.page > 1) {
  295. this.page -= 1;
  296. }
  297. }
  298. // mock数据
  299. // this.list = [{
  300. // orderNo: 'qqqqqqq',
  301. // id: 'qqqqqqq',
  302. // totalPaidAmount: 111,
  303. // taxNo: 'qqqqqqq',
  304. // status: 'FAILED',
  305. // errorMessage: 'errorMessage',
  306. // vehicleNo: 'qqqqqqq',
  307. // enterTime: '2023-09-89',
  308. // parkName: '111',
  309. // serviceMin: '111',
  310. // }]
  311. },
  312. checkboxChange(ids) {
  313. this.boxids = ids
  314. console.log(423, ids);
  315. if (ids.length > this.choosekMax) {
  316. Dialog.alert({
  317. title: '选择上限提示',
  318. message: '合并开票订单数量上限为200条,超出的部分请多次开具',
  319. confirmButtonText: '关闭',
  320. confirmButtonColor: this.$theme[this.theme].primaryColor,
  321. }).then(() => {
  322. // on close
  323. });
  324. return;
  325. }
  326. this.calculatePrice(ids);
  327. return;
  328. const itemId = e.detail.value;
  329. let list = this.list;
  330. for (let i = 0; i < list.length; i++) {
  331. let item = list[i];
  332. if (itemId.includes(item.id)) {
  333. this.$set(item, 'checked', true);
  334. } else {
  335. this.$set(item, 'checked', false);
  336. }
  337. }
  338. this.calculatePrice(list);
  339. },
  340. calculatePrice(list) {
  341. this.invoiceDetailList = []
  342. this.totalNum = 0
  343. if (list && list.length > 0) {
  344. this.list.forEach(element => {
  345. if (list.includes(element.id)) {
  346. const totalPaidAmount = element.totalPaidAmount;
  347. this.totalNum = this.totalNum + totalPaidAmount;
  348. this.invoiceDetailList.push(element)
  349. }
  350. });
  351. console.log('this.totalNum', this.totalNum)
  352. } else {
  353. this.totalNum = 0;
  354. }
  355. },
  356. showFailureReason(reson) {
  357. console.log('12345')
  358. this.$dialog({
  359. title: '开票失败原因',
  360. message: reson,
  361. confirmButtonText: '关闭',
  362. confirmButtonColor: this.$theme[this.theme].primaryColor,
  363. }).then(() => {
  364. // on confirm
  365. console.log('confirm');
  366. });
  367. },
  368. // 重新开票
  369. tryGoToInvoicing(item) {
  370. console.log(item, 'chooseHeaderchooseHeaderchooseHeader')
  371. this.$router.push({
  372. path: 'parkingApplication',
  373. query: {
  374. ...this.$route.query,
  375. ids: item.ids,
  376. invoiceId: item.id,
  377. againInvoiceFlag: true
  378. },
  379. });
  380. },
  381. },
  382. };