index-legacy.49899e4e.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. ;(function () {
  2. function _toConsumableArray(arr) {
  3. return (
  4. _arrayWithoutHoles(arr) ||
  5. _iterableToArray(arr) ||
  6. _unsupportedIterableToArray(arr) ||
  7. _nonIterableSpread()
  8. )
  9. }
  10. function _nonIterableSpread() {
  11. throw new TypeError(
  12. 'Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
  13. )
  14. }
  15. function _unsupportedIterableToArray(o, minLen) {
  16. if (!o) return
  17. if (typeof o === 'string') return _arrayLikeToArray(o, minLen)
  18. var n = Object.prototype.toString.call(o).slice(8, -1)
  19. if (n === 'Object' && o.constructor) n = o.constructor.name
  20. if (n === 'Map' || n === 'Set') return Array.from(o)
  21. if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
  22. return _arrayLikeToArray(o, minLen)
  23. }
  24. function _iterableToArray(iter) {
  25. if (
  26. (typeof Symbol !== 'undefined' && iter[Symbol.iterator] != null) ||
  27. iter['@@iterator'] != null
  28. )
  29. return Array.from(iter)
  30. }
  31. function _arrayWithoutHoles(arr) {
  32. if (Array.isArray(arr)) return _arrayLikeToArray(arr)
  33. }
  34. function _arrayLikeToArray(arr, len) {
  35. if (len == null || len > arr.length) len = arr.length
  36. for (var i = 0, arr2 = new Array(len); i < len; i++) {
  37. arr2[i] = arr[i]
  38. }
  39. return arr2
  40. }
  41. function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
  42. try {
  43. var info = gen[key](arg)
  44. var value = info.value
  45. } catch (error) {
  46. reject(error)
  47. return
  48. }
  49. if (info.done) {
  50. resolve(value)
  51. } else {
  52. Promise.resolve(value).then(_next, _throw)
  53. }
  54. }
  55. function _asyncToGenerator(fn) {
  56. return function () {
  57. var self = this,
  58. args = arguments
  59. return new Promise(function (resolve, reject) {
  60. var gen = fn.apply(self, args)
  61. function _next(value) {
  62. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'next', value)
  63. }
  64. function _throw(err) {
  65. asyncGeneratorStep(gen, resolve, reject, _next, _throw, 'throw', err)
  66. }
  67. _next(undefined)
  68. })
  69. }
  70. }
  71. var __vite_style__ = document.createElement('style')
  72. __vite_style__.innerHTML =
  73. '._useCoupon_dzp2v_1{padding-top:.42667rem;padding-bottom:.42667rem}._useCoupon_dzp2v_1 ._couponCount_dzp2v_5{color:#ff3535;font-size:.42667rem;font-weight:600}._useCoupon_dzp2v_1 ._couponCount_dzp2v_5 i{font-style:normal;font-size:.37333rem}._choiceCoupon_dzp2v_14{display:flex;flex-direction:column;overflow:hidden;height:100%}._couponTitle_dzp2v_20{display:flex;align-items:center;justify-content:space-between;flex-shrink:0;padding:0 .45333rem;height:1.6rem;line-height:1.6rem;font-size:.48rem;font-weight:600;color:#1a1a1a}._couponTitle_dzp2v_20 ._iconClose_dzp2v_32{display:inline-block;width:.64rem;height:.64rem;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAAAXNSR0IArs4c6QAAAG9QTFRFAAAAzMzM8fHx8/Pz6+vr8fHx6urq7Ozs6urq6+vr7Ozs6+vr6+vr6+vr6+vr7Ozs6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr6+vr7OzsZmZma2trbGxsgYGBj4+PysrKy8vLzMzMz8/P39/f6+vrszxq/gAAABp0Uk5TAAUSFhkkJVBXZmt1jY+2yM7b6/Hz9Pj8/v60zef/AAABRUlEQVRIx61W2baCMAyMIIvsm6ChgGD+/xvvA4gta+O580TITE+bpEkBljDdMEqzsszSKHRNOIHhxQ+S8Ig944B+De60wj247tAvfkGbKPzLFt9KaBeJteY7OR0gd5b8W0WHqG4L/pNO8FQUTkWnqKRd2TlpILfneCakheQTXZ804U/5LXQFxZjzgLQRAAAYcv28W9EMX3NoRPuW68oAAE9eokXEuvtYXY2Irez3ACCWfwhERPEajddoyf4YwFTqv8GvYuRjo9wPE1zlVEM9KyZ+PSgEF0I1Dt1IE30/fXSqP4RoEblpYSFQPs6MCFLaVmzzKYWM9hVrPmVQrvM5bR9Fv/aVfAF7S+xDs8PKThy7NNjFxy5v/gViX1F2E+C3GXYj47dK3WZs/d7u+QOFP7L4QxHAPhq79n8Mdv7T4YfHic7z5w+yIe8epvSUygAAAABJRU5ErkJggg==) no-repeat center;background-size:contain}._couponContent_dzp2v_39{flex:1 auto;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:.32rem .37333rem;--coupon-point: #fff}._couponFooter_dzp2v_46{display:flex;align-items:center;justify-content:space-between;line-height:1.49333rem;padding:0 .42667rem}._couponFooter_dzp2v_46 ._couponSelectText_dzp2v_53{font-size:.42667rem;color:#1a1a1a}._couponFooter_dzp2v_46 ._couponSelectText_dzp2v_53 span{padding:0 .24rem;font-weight:600;color:#fc1a19}\n'
  74. document.head.appendChild(__vite_style__)
  75. System.register(
  76. [
  77. './index-legacy.595c24c3.js',
  78. './vendor-legacy.09f20d09.js',
  79. './index-legacy.f25f109a.js',
  80. './item-legacy.bddec109.js'
  81. ],
  82. function (exports) {
  83. 'use strict'
  84. var ColResult,
  85. request,
  86. state,
  87. defineComponent,
  88. createVNode,
  89. createTextVNode,
  90. Fragment,
  91. Loading,
  92. Button,
  93. Cell,
  94. Popup,
  95. Item
  96. return {
  97. setters: [
  98. function (module) {
  99. ColResult = module.C
  100. request = module.r
  101. state = module.s
  102. },
  103. function (module) {
  104. defineComponent = module.d
  105. createVNode = module.a
  106. createTextVNode = module.j
  107. Fragment = module.F
  108. Loading = module.L
  109. Button = module.B
  110. Cell = module.C
  111. Popup = module.P
  112. },
  113. function () {},
  114. function (module) {
  115. Item = module.I
  116. }
  117. ],
  118. execute: function execute() {
  119. var useCoupon = '_useCoupon_dzp2v_1'
  120. var couponCount = '_couponCount_dzp2v_5'
  121. var choiceCoupon = '_choiceCoupon_dzp2v_14'
  122. var couponTitle = '_couponTitle_dzp2v_20'
  123. var iconClose = '_iconClose_dzp2v_32'
  124. var couponContent = '_couponContent_dzp2v_39'
  125. var couponFooter = '_couponFooter_dzp2v_46'
  126. var couponSelectText = '_couponSelectText_dzp2v_53'
  127. var styles = {
  128. useCoupon: useCoupon,
  129. couponCount: couponCount,
  130. choiceCoupon: choiceCoupon,
  131. couponTitle: couponTitle,
  132. iconClose: iconClose,
  133. couponContent: couponContent,
  134. couponFooter: couponFooter,
  135. couponSelectText: couponSelectText
  136. }
  137. var ChoiceCoupon = defineComponent({
  138. name: 'choice-coupon',
  139. props: {
  140. orderAmount: { type: Number, default: 0 },
  141. useCoupon: {
  142. type: Array,
  143. default: function _default() {
  144. return []
  145. }
  146. },
  147. couponCategory: { type: String, default: 'UNIVERSAL' },
  148. couponList: {
  149. type: Array,
  150. default: function _default() {
  151. return []
  152. }
  153. }
  154. },
  155. emits: ['close', 'submit'],
  156. data: function data() {
  157. return {
  158. list: [], // consumeAmount: 0 // 消耗金额
  159. dataLoading: false
  160. }
  161. },
  162. computed: {
  163. // 使用优惠券的数量
  164. useLength: function useLength() {
  165. return (
  166. this.list.filter(function (list) {
  167. return list.checked
  168. }).length || 0
  169. )
  170. }
  171. },
  172. mounted: function mounted() {
  173. var _this = this
  174. return _asyncToGenerator(
  175. /*#__PURE__*/ regeneratorRuntime.mark(function _callee() {
  176. var canUsable, canUsed
  177. return regeneratorRuntime.wrap(function _callee$(_context) {
  178. while (1) {
  179. switch ((_context.prev = _context.next)) {
  180. case 0: // this.getList()
  181. // 处理显示已选择的优惠券
  182. // 处理可用优惠券是否支付使用
  183. _this.couponList.forEach(function (item) {
  184. _this.useCoupon.forEach(function (coupon) {
  185. if (item.couponIssueId === coupon.couponIssueId) {
  186. item.checked = true
  187. }
  188. })
  189. })
  190. canUsable = _this.couponList.filter(function (list) {
  191. return !list.disabled
  192. })
  193. canUsed = _this.couponList.filter(function (list) {
  194. return list.disabled
  195. })
  196. _this.list = [].concat(
  197. _toConsumableArray(canUsable),
  198. _toConsumableArray(canUsed)
  199. )
  200. _this.calcCoupon()
  201. case 5:
  202. case 'end':
  203. return _context.stop()
  204. }
  205. }
  206. }, _callee)
  207. })
  208. )()
  209. },
  210. methods: {
  211. // async getList() {
  212. // if (this.dataLoading) return
  213. // this.dataLoading = true
  214. // try {
  215. // const res = await request.post(`${state.platformApi}/couponInfo/page`, {
  216. // data: {
  217. // couponCategory: this.couponCategory,
  218. // couponType: 'FULL_DISCOUNT',
  219. // useState: 'USABLE',
  220. // page: 1,
  221. // rows: 100
  222. // }
  223. // })
  224. // this.dataLoading = false
  225. // const result = res.data || {}
  226. // // 处理重复请求数据
  227. // if (this.list.length > 0 && result.pageNo === 1) return
  228. // this.list = result.rows || []
  229. // // 处理可用优惠券是否支付使用
  230. // this.list.forEach((item: any) => {
  231. // item.checked = false
  232. // // 如果使用金额大于订单金额则优惠券不可用
  233. // if (item.useLimit > this.orderAmount) {
  234. // item.disabled = true
  235. // } else {
  236. // item.disabled = false
  237. // }
  238. // // 处理显示已选择的优惠券
  239. // this.useCoupon.forEach((coupon: any) => {
  240. // if (item.couponIssueId === coupon.couponIssueId) {
  241. // item.checked = true
  242. // }
  243. // })
  244. // })
  245. // // 初始化排序
  246. // const canUsable = this.list.filter((list: any) => !list.disabled)
  247. // const canUsed = this.list.filter((list: any) => list.disabled)
  248. // this.list = [...canUsable, ...canUsed]
  249. // this.calcCoupon()
  250. // } catch {
  251. // //
  252. // }
  253. // },
  254. onSubmit: function onSubmit() {
  255. // 返回选中的优惠券
  256. this.$emit(
  257. 'submit',
  258. this.list.filter(function (list) {
  259. return list.checked
  260. })
  261. )
  262. this.list.forEach(function (item) {
  263. item.checked = false
  264. })
  265. },
  266. onSelect: function onSelect(item) {
  267. item.checked = !item.checked
  268. this.calcCoupon()
  269. },
  270. calcCoupon: function calcCoupon() {
  271. // 计算优惠券
  272. // 已使用的优惠券
  273. var useList = this.list.filter(function (list) {
  274. return list.checked
  275. })
  276. var limitCount = useList.map(function (list) {
  277. return Number(list.useLimit || 0)
  278. })
  279. var usePrice =
  280. limitCount.length > 0
  281. ? limitCount.reduce(function (sum, list) {
  282. return sum + list
  283. })
  284. : 0 // 使用优惠券后,可判断的金额
  285. var useLastAmount = this.orderAmount - usePrice // 判断使用优惠券之后还有没有其它优惠券可用
  286. this.list.forEach(function (item) {
  287. if (Number(item.useLimit) > useLastAmount && !item.checked) {
  288. item.disabled = true
  289. } else {
  290. item.disabled = false
  291. }
  292. })
  293. }
  294. },
  295. render: function render() {
  296. var _this2 = this
  297. return createVNode('div', { class: styles.choiceCoupon }, [
  298. createVNode('div', { class: styles.couponTitle }, [
  299. createVNode('span', null, [
  300. createTextVNode('\u4F18\u60E0\u5238')
  301. ]),
  302. createVNode(
  303. 'i',
  304. {
  305. class: styles.iconClose,
  306. onClick: function onClick() {
  307. return _this2.$emit('close')
  308. }
  309. },
  310. null
  311. )
  312. ]),
  313. createVNode('div', { class: styles.couponContent }, [
  314. !this.dataLoading
  315. ? createVNode(Fragment, null, [
  316. this.list.length > 0
  317. ? createVNode(Fragment, null, [
  318. this.list.map(function (item) {
  319. return createVNode(
  320. Item,
  321. {
  322. item: item,
  323. isSelect: true,
  324. onClick: _this2.onSelect
  325. },
  326. null
  327. )
  328. })
  329. ])
  330. : createVNode(
  331. ColResult,
  332. {
  333. btnStatus: false,
  334. tips: '暂无优惠券',
  335. classImgSize: 'SMALL'
  336. },
  337. null
  338. )
  339. ])
  340. : createVNode(
  341. Loading,
  342. {
  343. size: 48,
  344. color: '#01C1B5',
  345. vertical: true,
  346. style: { height: '100%', justifyContent: 'center' }
  347. },
  348. {
  349. default: function _default() {
  350. return [createTextVNode('\u52A0\u8F7D\u4E2D...')]
  351. }
  352. }
  353. )
  354. ]),
  355. createVNode(
  356. 'div',
  357. { class: [styles.couponFooter, 'van-hairline--top'] },
  358. [
  359. createVNode('div', { class: styles.couponSelectText }, [
  360. createTextVNode('\u5DF2\u9009'),
  361. createVNode('span', null, [this.useLength]),
  362. createTextVNode('\u5F20')
  363. ]),
  364. createVNode(
  365. Button,
  366. {
  367. type: 'primary',
  368. round: true,
  369. style: { minWidth: '105px', fontSize: '16px' },
  370. onClick: this.onSubmit
  371. },
  372. {
  373. default: function _default() {
  374. return [createTextVNode('\u786E\u5B9A')]
  375. }
  376. }
  377. )
  378. ]
  379. )
  380. ])
  381. }
  382. })
  383. /*
  384. * 订单类型对应优惠券类型
  385. */ var couponEnum = {
  386. UNIVERSAL: 'UNIVERSAL',
  387. VIP: 'VIP',
  388. PINAO_ROOM: 'PIANO',
  389. GOODS: 'MALL',
  390. MUSIC: 'MUSIC',
  391. PRACTICE: 'SPARRING',
  392. LIVE: 'LIVE',
  393. VIDEO: 'VIDEO'
  394. }
  395. var UseCoupons = exports(
  396. 'U',
  397. defineComponent({
  398. name: 'use-conpon',
  399. props: {
  400. disabled: { type: Boolean, default: false },
  401. orderAmount: { type: Number, default: 0 },
  402. orderType: { type: String, default: '' },
  403. discountPrice: {
  404. // 优惠券使用金额
  405. type: Number,
  406. default: 0
  407. }
  408. },
  409. emits: ['couponSelect'],
  410. data: function data() {
  411. return {
  412. popupStatus: false,
  413. popupLoading: false,
  414. useCouponList: [],
  415. useCouponLoading: false,
  416. useCouponCount: 0,
  417. dataLoading: false,
  418. list: []
  419. }
  420. },
  421. computed: {
  422. couponCount: function couponCount() {
  423. var limitCount = this.useCouponList.map(function (list) {
  424. return Number(list.discountPrice || 0)
  425. })
  426. var count = 0
  427. if (this.disabled) {
  428. count = this.discountPrice
  429. } else {
  430. count =
  431. limitCount.length > 0
  432. ? limitCount.reduce(function (sum, list) {
  433. return sum + list
  434. })
  435. : 0
  436. }
  437. return count
  438. },
  439. couponCategory: function couponCategory() {
  440. // 如果订单类型不在优惠券类型里面,则默认查询通用券
  441. return couponEnum[this.orderType] || 'UNIVERSAL'
  442. }
  443. },
  444. mounted: function mounted() {
  445. // this.getUseableCoupon()
  446. this.getList()
  447. },
  448. methods: {
  449. getList: function getList() {
  450. var _this3 = this
  451. return _asyncToGenerator(
  452. /*#__PURE__*/ regeneratorRuntime.mark(function _callee2() {
  453. var res, result, count
  454. return regeneratorRuntime.wrap(
  455. function _callee2$(_context2) {
  456. while (1) {
  457. switch ((_context2.prev = _context2.next)) {
  458. case 0:
  459. if (!_this3.dataLoading) {
  460. _context2.next = 2
  461. break
  462. }
  463. return _context2.abrupt('return')
  464. case 2:
  465. _this3.dataLoading = true
  466. _context2.prev = 3
  467. _context2.next = 6
  468. return request.post(
  469. ''.concat(
  470. state.platformApi,
  471. '/couponInfo/page'
  472. ),
  473. {
  474. data: {
  475. couponCategory: _this3.couponCategory,
  476. couponType: 'FULL_DISCOUNT',
  477. useState: 'USABLE',
  478. orderUse: 1,
  479. page: 1,
  480. rows: 100
  481. }
  482. }
  483. )
  484. case 6:
  485. res = _context2.sent
  486. _this3.dataLoading = false
  487. result = res.data || {} // 处理重复请求数据
  488. if (
  489. !(
  490. _this3.list.length > 0 &&
  491. result.pageNo === 1
  492. )
  493. ) {
  494. _context2.next = 11
  495. break
  496. }
  497. return _context2.abrupt('return')
  498. case 11:
  499. _this3.list = result.rows || [] // 处理可用优惠券是否支付使用
  500. _this3.list.forEach(function (item) {
  501. item.checked = false // 如果使用金额大于订单金额则优惠券不可用
  502. if (item.useLimit > _this3.orderAmount) {
  503. item.disabled = true
  504. } else {
  505. item.disabled = false
  506. }
  507. })
  508. count = 0
  509. _this3.list.forEach(function (item) {
  510. if (!item.disabled) {
  511. count++
  512. }
  513. })
  514. console.log(_this3.list, 'list')
  515. _this3.useCouponCount = count
  516. _context2.next = 21
  517. break
  518. case 19:
  519. _context2.prev = 19
  520. _context2.t0 = _context2['catch'](3)
  521. case 21:
  522. case 'end':
  523. return _context2.stop()
  524. }
  525. }
  526. },
  527. _callee2,
  528. null,
  529. [[3, 19]]
  530. )
  531. })
  532. )()
  533. }, // async getUseableCoupon() {
  534. // try {
  535. // this.useCouponLoading = true
  536. // // 判断是哪个端
  537. // const url =
  538. // state.platformType === 'STUDENT' ? '/api-student' : '/api-teacher'
  539. // const res = await request.get(`${url}/couponInfo/statInfo`)
  540. // this.useCouponLoading = false
  541. // const result = (res.data || []).find(
  542. // result => result.useState === 'USABLE'
  543. // )
  544. // this.useCouponCount = result.total || 0
  545. // } catch {
  546. // // TODO: handle
  547. // }
  548. // },
  549. onSubmit: function onSubmit(item) {
  550. // useCouponList
  551. this.useCouponList = item
  552. this.$emit('couponSelect', item)
  553. this.popupStatus = false
  554. this.popupLoading = false
  555. }
  556. },
  557. render: function render() {
  558. var _this4 = this
  559. return createVNode(Fragment, null, [
  560. createVNode(
  561. Cell,
  562. {
  563. title: '优惠券',
  564. class: styles.useCoupon,
  565. style: { borderRadius: '8px' },
  566. isLink: !this.disabled,
  567. clickable: false,
  568. onClick: function onClick() {
  569. if (_this4.disabled) return
  570. _this4.popupStatus = true
  571. _this4.popupLoading = true
  572. }
  573. },
  574. {
  575. value: function value() {
  576. return (
  577. !_this4.useCouponLoading &&
  578. createVNode(Fragment, null, [
  579. _this4.couponCount > 0
  580. ? createVNode(
  581. 'span',
  582. { class: styles.couponCount },
  583. [
  584. createVNode('i', null, [
  585. createTextVNode('-\uFFE5')
  586. ]),
  587. _this4.couponCount
  588. ]
  589. )
  590. : createVNode(Fragment, null, [
  591. _this4.useCouponCount > 0
  592. ? ''.concat(
  593. _this4.useCouponCount,
  594. '\u5F20\u53EF\u4F7F\u7528'
  595. )
  596. : '暂无可使用优惠券'
  597. ])
  598. ])
  599. )
  600. }
  601. }
  602. ),
  603. createVNode(
  604. Popup,
  605. {
  606. show: this.popupStatus,
  607. 'onUpdate:show': function onUpdateShow($event) {
  608. return (_this4.popupStatus = $event)
  609. },
  610. position: 'bottom',
  611. round: true,
  612. safeAreaInsetBottom: true,
  613. style: { height: '75%' },
  614. onClosed: function onClosed() {
  615. _this4.popupLoading = false
  616. }
  617. },
  618. {
  619. default: function _default() {
  620. return [
  621. _this4.popupLoading &&
  622. createVNode(
  623. ChoiceCoupon,
  624. {
  625. couponCategory: _this4.couponCategory,
  626. useCoupon: _this4.useCouponList,
  627. orderAmount: _this4.orderAmount,
  628. couponList: _this4.list,
  629. onClose: function onClose() {
  630. return (_this4.popupStatus = false)
  631. },
  632. onSubmit: function onSubmit(item) {
  633. return _this4.onSubmit(item)
  634. }
  635. },
  636. null
  637. )
  638. ]
  639. }
  640. }
  641. )
  642. ])
  643. }
  644. })
  645. )
  646. }
  647. }
  648. }
  649. )
  650. })()