parkingFeeDiscounts.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. import { Toast } from "vant";
  2. import { mapState } from 'vuex';
  3. import uniNumberBox from '@/components/uni-number-box/uni-number-box.vue';
  4. import { cloneDeep } from 'lodash'
  5. // import uni from '@/utils/uniHooks';
  6. // const app = getApp()
  7. export default {
  8. components: { uniNumberBox },
  9. created() {
  10. // 超限提示
  11. // this.crossMessage();
  12. },
  13. // beforeRouteLeave(to, from, next) {
  14. // console.log(251251251251251251, to, from,);
  15. // // 设置下一个路由的 meta
  16. // to.meta.keepAlive = true; // 让 A 不缓存,即刷新
  17. // next();
  18. // },
  19. data() {
  20. return {
  21. checkedList: [], // 已选优惠列表
  22. oldCheckedList: [], // 已选优惠列表备份
  23. isMember: true, // member
  24. isReduces: true, // reduces
  25. memberLevelReduce: [],
  26. memberGrade: {},
  27. consume: {},
  28. // todayReduceDiscountMessage: '',
  29. isMemberDiscountDisabled: false,
  30. maxDiscountTime: 0,
  31. enableConsumeSplit: false,
  32. maxReduceDiscount: 0,
  33. reduceHours: 0,
  34. remainPrice: 0,
  35. isInit: 1,
  36. };
  37. },
  38. computed: {
  39. ...mapState({
  40. orderDetail: (state) => state.order.orderDetail,
  41. custTypeId: (state) => state.custTypeId,
  42. groupId: (state) => state.groupId,
  43. enableConsume: (state) => state.order.enableConsume,
  44. actualPayFee: (state) => state.order.actualPayFee,
  45. usingTotalDiscount: (state) => state.order.usingTotalDiscount,
  46. memberLevelDiscount: (state) => state.order.memberLevelDiscount,
  47. checkedTotal: (state) => state.order.checkedTotal,
  48. parkMallCode: (state) => state.order.parkMallCode,
  49. paperDiscountTime: (state) => state.order.paperDiscountTime,
  50. paperDiscountFee: (state) => state.order.paperDiscountTime,
  51. availableDiscountFee: (state) => state.order.availableDiscountFee,
  52. }),
  53. enableConsumeNonSplit() {
  54. return this.orderDetail.parkingRule.enableConsumeNonSplit
  55. },
  56. stepperMin() {
  57. // 如果是合集车场,不存在拆分,默认返回用户可使用的消费抵扣时间
  58. if (this.parkMallCode === 7 || this.enableConsumeNonSplit) {
  59. return this.reduceHours || 0
  60. }
  61. // 如果不存消费减免,默认展示0
  62. if (JSON.stringify(this.consume) === '{}') {
  63. return 0
  64. }
  65. // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
  66. return 1
  67. },
  68. stepperMax() {
  69. if (this.parkMallCode === 4 || this.parkMallCode === 6) {
  70. // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
  71. return this.maxReduceDiscount
  72. }
  73. // 如果是合集车场,不存在拆分,默认返回用户可使用的消费抵扣时间
  74. if (this.parkMallCode === 7 || this.enableConsumeNonSplit) {
  75. return this.reduceHours || 0
  76. }
  77. // 如果不存消费减免,默认展示0
  78. if (JSON.stringify(this.consume) === '{}') {
  79. return 0
  80. }
  81. // 如果存在消费减免并且是可拆分的,则设置最低拆分单位是 1
  82. return this.maxReduceDiscount
  83. },
  84. // maxReduceDiscount() {
  85. // const {maxOneDayCoupons,maxConsumeTime,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
  86. // let newMaxConsumeTime = maxConsumeTime
  87. // const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice
  88. // console.log(52, this.remainPrice)
  89. // if ( this.remainPrice + (newMaxConsumeTime * hourPrice) > maxOneTimeDiscountFee ) {
  90. // newMaxConsumeTime = (maxOneTimeDiscountFee - this.remainPrice) / hourPrice
  91. // }
  92. // return maxConsumeTime
  93. // },
  94. // remainPrice() {
  95. // let remainPrice = this.usingTotalDiscount
  96. // const {maxOneDayCoupons,maxConsumeTime,maxonedaydiscountFee,maxOneTimeDiscountTime,remainConsumeTime,hourPrice,availableDiscountFee,oneTimeLimitation,oneDayLimitation,maxOneDayDiscountFee} = this.orderDetail.parkingRule;
  97. // let newMaxConsumeTime = maxConsumeTime
  98. // if ( this.checkedList.indexOf('member') > -1) {
  99. // remainPrice = remainPrice + this.memberGrade.discountFee
  100. // }
  101. // if ( this.checkedList.indexOf('reduces') > -1) {
  102. //
  103. // }
  104. //
  105. //
  106. //
  107. //
  108. // return remainPrice
  109. // }
  110. // 消费减免(拆分部分)提示文本
  111. reduceSplitMessage() {
  112. // console.log(106, this.reduceHours);
  113. if (!this.enableConsumeNonSplit) {
  114. return `选择${this.reduceHours}小时,`;
  115. }
  116. return '';
  117. },
  118. // 消费减免金额
  119. reducesDiscountFee() {
  120. return this.reduceHours * this.orderDetail.parkingRule.hourPrice;
  121. },
  122. // 消费减免说明文案
  123. todayReduceDiscountMessage() {
  124. // 静安浦东没有内容
  125. if (this.parkMallCode === 0 || this.parkMallCode === 1) {
  126. return ''
  127. }
  128. // 消费减免余额为 0 时
  129. if (!this.orderDetail.parkingRule.remainConsumeTime || !this.consume.hasOwnProperty('redeemSalesAmount')) {
  130. return `您暂无可用的消费减免`
  131. // return `您今日消费减免已达${this.orderDetail.parkingRule.maxConsumeTime}小时上限`
  132. }
  133. // 消费减免不存在时
  134. if (JSON.stringify(this.consume) === '{}') {
  135. return '消费金额未达到最低优惠要求'
  136. }
  137. // 静安存在消费减免时
  138. if (this.parkMallCode === 0) {
  139. return `今日可减免${this.consume.defaultDiscountTime}小时`;
  140. }
  141. // 沈阳提示信息
  142. if (this.parkMallCode === 4 || this.parkMallCode === 6) {
  143. return `未达上限时今日可减免${this.stepperMax}小时`;
  144. }
  145. if (this.consume.defaultDiscountTime > this.orderDetail.parkingRule.remainConsumeTime) {
  146. return `消费已满${this.consume.redeemSalesAmount}元,减免${this.consume.defaultDiscountTime}小时。超出优惠上限,可减免${this.maxReduceDiscount}小时,${this.reduceSplitMessage}可优惠${this.reducesDiscountFee}元`
  147. }
  148. return `消费已满${this.consume.redeemSalesAmount}元,减免${this.consume.defaultDiscountTime}小时。${this.reduceSplitMessage}可优惠${this.reducesDiscountFee}元`
  149. }
  150. },
  151. mounted() {
  152. try {
  153. this.isCheck(() => this.pageInit()); // 验证是否可选
  154. } catch (err) {
  155. // console.log(err);
  156. this.$router.back();
  157. }
  158. },
  159. watch: {
  160. remainPrice() {
  161. const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
  162. const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
  163. // console.log('hourPrice + this.remainPrice',this.remainPrice)
  164. // 单日上限
  165. // if ( oneDayLimitation && this.remainPrice >= maxOneDayDiscountFee ) {
  166. // return Toast({
  167. // message: `每日最高可抵扣${ maxOneDayDiscountFee }元`,
  168. // icon: 'none',
  169. // });
  170. //
  171. // }
  172. // 单次上限限制
  173. if (oneTimeLimitation) {
  174. if (this.remainPrice <= maxOneTimeDiscountFee) {
  175. if (this.isMember) {
  176. this.isMember = !this.isMember;
  177. }
  178. if (this.isReduces) {
  179. this.isReduces = false;
  180. // console.log(109);
  181. }
  182. } else {
  183. this.isMember = this.checkedList.indexOf('member') < 0;
  184. this.isReduces = this.checkedList.indexOf('reduces') < 0;
  185. }
  186. }
  187. },
  188. checkedList(newVal, oldVal) {
  189. // console.log(190, { newVal, oldVal });
  190. if ((this.parkMallCode === 4 || this.parkMallCode === 6) && this.isInit > 1) {
  191. const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
  192. // 会员等级选中了
  193. if (newVal.indexOf('member') > -1 && oldVal.indexOf('member') < 0) {
  194. // console.log(193, '会员等级选中了');
  195. // this.remainPrice = this.remainPrice + this.memberGrade.discountFee;
  196. // this.maxReduceDiscountInit();
  197. }
  198. if (oldVal.indexOf('member') > -1 && newVal.indexOf('member') < 0) {
  199. // 会员等级未选中了
  200. // console.log(193, '会员等级未选中了');
  201. // this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
  202. // this.maxReduceDiscountInit();
  203. }
  204. // 消费减免选中了
  205. if (newVal.indexOf('reduces') > -1 && oldVal.indexOf('reduces') < 0) {
  206. // console.log(193, '消费减免选中了');
  207. this.consume.discountFee = this.reduceHours * hourPrice
  208. this.remainPrice = this.remainPrice + this.consume.discountFee;
  209. }
  210. if (oldVal.indexOf('reduces') > -1 && newVal.indexOf('reduces') < 0) {
  211. // 消费减免未选中了
  212. // console.log(193, '消费减免未选中了');
  213. this.consume.discountFee = this.reduceHours * hourPrice
  214. this.remainPrice = this.remainPrice - this.consume.discountFee;
  215. }
  216. }
  217. // const {hourPrice} = this.orderDetail.parkingRule;
  218. // if ( this.checkedList.indexOf('reduces') > -1 ) {
  219. // this.remainPrice = this.reduceHours * hourPrice + this.remainPrice
  220. // } else {
  221. // this.remainPrice = this.remainPrice - this.reduceHours * hourPrice
  222. // }
  223. },
  224. },
  225. methods: {
  226. pageInit() {
  227. if (this.orderDetail?.parkingRule?.enableConsumeSplit) {
  228. this.enableConsumeSplit = this.orderDetail.parkingRule.enableConsumeSplit;
  229. }
  230. this.checkedList = [];
  231. const { memberGrade = [{}], consume = [], memberLevelDiscount, points = [{}] } = this.orderDetail.discountInfo;
  232. const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
  233. // 如果积分存在的话,则移除积分的优惠
  234. if (JSON.stringify(points) !== {}) {
  235. this.remainPrice = this.parkMallCode !== 1 ? this.usingTotalDiscount - points[0].discountFee : this.usingTotalDiscount;
  236. }
  237. this.memberGrade = { ...memberGrade[0] };
  238. this.consume = { ...consume[0] };
  239. if (JSON.stringify(this.memberGrade) !== '{}' && this.memberGrade && this.memberGrade.hasOwnProperty('selected') ? this.memberGrade.selected : this.memberGrade.defaultSelected) {
  240. this.checkedList.push('member');
  241. }
  242. this.isMember = JSON.stringify(this.memberGrade) === '{}';
  243. // console.log(140, this.consume, this.consume.hasOwnProperty('selected'), JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected, this.consume.defaultSelected)
  244. // console.log(143, JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected !== undefined : this.consume.defaultSelected !== undefined);
  245. if (JSON.stringify(this.consume) !== '{}' && this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected !== undefined) {
  246. this.checkedList.push('reduces');
  247. // this.isReduces = false;
  248. // 如果存在拆分逻辑的话
  249. // this.consume.
  250. }
  251. this.isReduces = this.consume.hasOwnProperty('selected') || this.consume.hasOwnProperty('defaultSelected') ? false : true;
  252. this.reduceHours = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / this.orderDetail.parkingRule.hourPrice : this.consume.defaultDiscountTime;
  253. if (JSON.stringify(this.consume) !== '{}') {
  254. const isSelected = this.consume.hasOwnProperty('selected') ? this.consume.selected : this.consume.defaultSelected;
  255. this.maxReduceDiscount = this.consume.hasOwnProperty('discountFee') ? this.consume.discountFee / hourPrice : this.consume.defaultDiscountTime;
  256. // const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
  257. // if (remainingLimitToIncrease) {
  258. // this.maxReduceDiscountInit();
  259. // }
  260. this.maxReduceDiscountInit();
  261. }
  262. this.oldCheckedList = [...this.checkedList];
  263. // 如果是杭州、沈阳可以选择
  264. // if (this.parkMallCode === 2 || this.parkMallCode === 4 || this.parkMallCode === 7) {
  265. // this.isReduces = JSON.stringify(this.consume) === '{}';
  266. // }
  267. // https://kerryprops.atlassian.net/browse/SCRM-4016?focusedCommentId=117842: 只要存在消费减免情况,都允许用户进行操作
  268. this.isReduces = JSON.stringify(this.consume) === '{}';
  269. this.discountInit()
  270. setTimeout(() => {
  271. this.isInit = this.isInit + 1
  272. }, 300)
  273. },
  274. discountInit() {
  275. if(this.parkMallCode === 4 || this.parkMallCode === 6 ) {
  276. const { maxConsumeTime, remainConsumeTime, hourPrice } = this.orderDetail.parkingRule;
  277. const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee) / hourPrice
  278. if(!remainingLimitToIncrease) {
  279. this.isMember = this.memberGrade.hasOwnProperty('selected')? !this.memberGrade.selected : !this.memberGrade.defaultSelected
  280. this.isReduces = this.consume.hasOwnProperty('selected')? !this.consume.selected : !this.consume.defaultSelected
  281. }
  282. }
  283. },
  284. maxReduceDiscountInit() {
  285. const {maxDiscountTime} = this.consume
  286. if(JSON.stringify(this.consume) === '{}' || !this.consume.hasOwnProperty('redeemSalesAmount')) {
  287. return
  288. }
  289. const { maxConsumeTime, remainConsumeTime, hourPrice, maxOneTimeDiscountTime } = this.orderDetail.parkingRule;
  290. const remainingLimitToIncrease = Math.abs(this.remainPrice - this.availableDiscountFee || 0) / hourPrice;
  291. // 如果是浦东的话, 重新计算优惠
  292. if (this.parkMallCode === 1) {
  293. /*if(this.checkedList.indexOf('reduces') < 0) {
  294. this.maxReduceDiscount = this.maxReduceDiscount > maxDiscountTime ? maxDiscountTime: this.maxReduceDiscount
  295. return
  296. }*/
  297. this.maxReduceDiscount = this.remainPrice / hourPrice < remainConsumeTime ? remainConsumeTime : this.maxReduceDiscount
  298. return;
  299. }
  300. if (!remainingLimitToIncrease) {
  301. // if(!this.consume.selected) {
  302. // this.isReduces = true
  303. // }
  304. return
  305. }
  306. this.isReduces = false
  307. if (this.remainPrice >= this.availableDiscountFee) {
  308. // console.log('过大', this.maxReduceDiscount, remainingLimitToIncrease);
  309. this.maxReduceDiscount = this.maxReduceDiscount - remainingLimitToIncrease > maxDiscountTime ? maxDiscountTime : this.maxReduceDiscount - remainingLimitToIncrease
  310. this.consume.discountFee = this.consume.discountFee - (remainingLimitToIncrease * hourPrice)
  311. this.remainPrice = this.remainPrice - (remainingLimitToIncrease * hourPrice);
  312. this.reduceHours = this.maxReduceDiscount
  313. }
  314. if(this.checkedList.indexOf('reduces') < 0) {
  315. // 如果没被选中
  316. this.maxReduceDiscount = remainingLimitToIncrease > maxDiscountTime ? maxDiscountTime : remainingLimitToIncrease
  317. this.reduceHours = this.maxReduceDiscount
  318. this.consume.discountFee = remainingLimitToIncrease * hourPrice
  319. return
  320. }
  321. // 如果被选中
  322. // console.log('过小?', this.consume.discountFee, remainingLimitToIncrease);
  323. const maxReduceDiscount = this.consume.discountFee / hourPrice + remainingLimitToIncrease
  324. // console.log('过小', maxReduceDiscount);
  325. this.maxReduceDiscount = maxReduceDiscount <= remainConsumeTime ? maxReduceDiscount : remainConsumeTime
  326. this.maxReduceDiscount = this.maxReduceDiscount > maxDiscountTime ? maxDiscountTime: this.maxReduceDiscount
  327. },
  328. setIsMemberDiscountDisabled() {
  329. this.todayReduceDiscountMessage = '当日';
  330. },
  331. checkboxChange() { },
  332. onReduceHoursChange(type) {
  333. if (this.checkedList.indexOf('reduces') < 0) {
  334. return;
  335. }
  336. const { maxOneDayCoupons, maxonedaydiscountFee, maxOneTimeDiscountTime, remainConsumeTime, hourPrice, availableDiscountFee, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
  337. // console.log(133,this.reduceHours)
  338. // console.log(166, this.maxReduceDiscount);
  339. if (type === 'plus') {
  340. const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage('onReduceHoursChange');
  341. if (isCrossMessage) {
  342. // this.remainPrice = this.remainPrice - hourPrice;
  343. // this.reduceHours = this.reduceHours - 1;
  344. return
  345. }
  346. this.remainPrice = this.remainPrice + hourPrice;
  347. this.reduceHours = this.reduceHours + 1;
  348. this.consume.discountFee = this.reduceHours * hourPrice
  349. return;
  350. }
  351. if (type === 'minus' && this.reduceHours > 1) {
  352. this.reduceHours = this.reduceHours - 1;
  353. this.remainPrice = this.remainPrice - hourPrice;
  354. this.consume.discountFee = this.reduceHours * hourPrice
  355. return;
  356. }
  357. },
  358. memberClick() {
  359. // debugger
  360. const { maxConsumeTime, remainConsumeTime, availableDiscountFee, hourPrice } = this.orderDetail.parkingRule;
  361. if (this.checkedList.indexOf('member') > -1) {
  362. this.remainPrice = this.memberGrade.discountFee + this.remainPrice;
  363. // console.log(331, this.remainPrice);
  364. // 沈阳
  365. if (this.parkMallCode === 4 || this.parkMallCode === 6) {
  366. // console.log(322);
  367. this.maxReduceDiscountInit();
  368. }
  369. } else if (!this.isMember) {
  370. this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
  371. // 如果不是沈阳,重新计算优惠
  372. if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
  373. this.maxReduceDiscount = remainConsumeTime;
  374. }
  375. // 如果不是沈阳,重新计算优惠
  376. if (this.parkMallCode === 4 || this.parkMallCode === 6) {
  377. this.maxReduceDiscountInit();
  378. }
  379. }
  380. // 如果不是沈阳
  381. if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
  382. const [isCrossMessage = false, maxReduceDiscount = this.maxReduceDiscount] = this.crossMessage();
  383. if (isCrossMessage) {
  384. this.checkedList = this.checkedList.filter((elm) => elm !== 'member');
  385. this.remainPrice = this.remainPrice - this.memberGrade.discountFee;
  386. this.isMember = false;
  387. }
  388. }
  389. },
  390. reducesClick() {
  391. const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, maxConsumeTime, remainConsumeTime, oneDayLimitation, maxOneDayDiscountFee, availableDiscountFee } = this.orderDetail.parkingRule;
  392. const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
  393. if (this.checkedList.indexOf('reduces') > -1) {
  394. // this.remainPrice = hourPrice + this.remainPrice;
  395. // 如果不是沈阳,重新计算计算最大上限
  396. if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
  397. this.remainPrice = hourPrice + this.remainPrice;
  398. this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
  399. }
  400. } else {
  401. // this.remainPrice = this.remainPrice - hourPrice;
  402. // 如果不是沈阳,重新计算计算最大上限
  403. if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
  404. this.remainPrice = this.remainPrice - hourPrice;
  405. this.maxReduceDiscount = remainConsumeTime > maxOneTimeDiscountFee / hourPrice ? maxOneTimeDiscountFee / hourPrice : remainConsumeTime;
  406. }
  407. }
  408. if (this.parkMallCode !== 4 && this.parkMallCode !== 6) {
  409. const [isCrossMessage = false, maxReduceDiscount = 0] = this.crossMessage();
  410. if (isCrossMessage) {
  411. this.remainPrice = this.remainPrice - maxReduceDiscount * hourPrice;
  412. }
  413. }
  414. },
  415. // 超限提示
  416. crossMessage(type) {
  417. const { maxOneTimeDiscountTime, hourPrice, oneTimeLimitation, oneDayLimitation, maxOneDayDiscountFee } = this.orderDetail.parkingRule;
  418. const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
  419. // console.log(373, this.remainPrice, this.availableDiscountFee);
  420. // 单日上限
  421. if (oneDayLimitation && this.remainPrice >= this.availableDiscountFee) {
  422. Toast({
  423. message: `每日最高可抵扣${maxOneDayDiscountFee}元`,
  424. icon: 'none',
  425. });
  426. return [true, (maxOneDayDiscountFee - (this.reduceHours - 1) * hourPrice) / hourPrice];
  427. }
  428. // 单次上限限制
  429. if (oneTimeLimitation && this.remainPrice >= maxOneTimeDiscountFee) {
  430. Toast({
  431. message: `超出抵扣上限,每次最高可抵扣${maxOneTimeDiscountTime}小时`,
  432. icon: 'none',
  433. });
  434. // return [true,( maxOneTimeDiscountFee - (this.reduceHours - 1) * hourPrice ) / hourPrice]
  435. return [true, (this.remainPrice - maxOneTimeDiscountFee) / hourPrice];
  436. }
  437. return [false, 0];
  438. },
  439. // 验证当前的选项是否可选择
  440. isCheck(callback) {
  441. if (!this?.orderDetail?.parkingRule) {
  442. return;
  443. }
  444. // const {parkInfo,parkingRule,discountInfo} = this.orderDetail
  445. const { maxOneTimeDiscountTime, maxOneDayDiscountFee, oneTimeLimitation, oneDayLimitation, hourPrice, remainConsumeTime } = this.orderDetail.parkingRule;
  446. // 浦东
  447. if (this.parkMallCode === 1) {
  448. const maxOneTimeDiscountFee = maxOneTimeDiscountTime * hourPrice;
  449. const remainConsumeTimeFee = remainConsumeTime * hourPrice;
  450. // TODO: 统计纸质优惠券的总金额, usingTotalDiscount,才是用户当前订单使用的优惠总数
  451. this.isMember = !(this.usingTotalDiscount < (oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee) && this.memberLevelDiscount);
  452. this.isReduces = !(this.usingTotalDiscount < (oneTimeLimitation ? maxOneTimeDiscountFee : maxOneDayDiscountFee) && this.enableConsume);
  453. }
  454. if (callback) callback();
  455. },
  456. reducesChange(value) {
  457. // console.log(149,value)
  458. },
  459. async confirm() {
  460. let orderDetail = cloneDeep(this.orderDetail);
  461. // 如果初次进来操作的跟原来的不一样则重新计算优惠
  462. if (this.checkedList.length !== this.checkedTotal || true) {
  463. ['member', 'reduces'].forEach((key) => {
  464. if (key === 'member') {
  465. this.memberGrade = {
  466. ...this.memberGrade,
  467. selected: this.checkedList.indexOf(key) > -1,
  468. };
  469. orderDetail.discountInfo.memberGrade = [this.memberGrade];
  470. }
  471. if (key === 'reduces') {
  472. this.consume = {
  473. ...this.consume,
  474. discountTime: this.reduceHours,
  475. discountFee: this.reduceHours * this.orderDetail.parkingRule.hourPrice,
  476. selected: this.checkedList.indexOf(key) > -1,
  477. };
  478. orderDetail.discountInfo.consume = [this.consume];
  479. }
  480. });
  481. await this.$store.dispatch('order/saveDiscounts', { orderDetail, callback: () => this.$router.back() });
  482. } else {
  483. this.$router.back();
  484. }
  485. },
  486. },
  487. };