Sku.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _extends5 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  6. var _vue = _interopRequireDefault(require("vue"));
  7. var _popup = _interopRequireDefault(require("../popup"));
  8. var _toast = _interopRequireDefault(require("../toast"));
  9. var _imagePreview = _interopRequireDefault(require("../image-preview"));
  10. var _SkuHeader = _interopRequireDefault(require("./components/SkuHeader"));
  11. var _SkuHeaderItem = _interopRequireDefault(require("./components/SkuHeaderItem"));
  12. var _SkuRow = _interopRequireDefault(require("./components/SkuRow"));
  13. var _SkuRowItem = _interopRequireDefault(require("./components/SkuRowItem"));
  14. var _SkuRowPropItem = _interopRequireDefault(require("./components/SkuRowPropItem"));
  15. var _SkuStepper = _interopRequireDefault(require("./components/SkuStepper"));
  16. var _SkuMessages = _interopRequireDefault(require("./components/SkuMessages"));
  17. var _SkuActions = _interopRequireDefault(require("./components/SkuActions"));
  18. var _utils = require("../utils");
  19. var _skuHelper = require("./utils/sku-helper");
  20. var _constants = require("./constants");
  21. var namespace = (0, _utils.createNamespace)('sku');
  22. var createComponent = namespace[0],
  23. bem = namespace[1],
  24. t = namespace[2];
  25. var QUOTA_LIMIT = _constants.LIMIT_TYPE.QUOTA_LIMIT;
  26. var _default2 = createComponent({
  27. props: {
  28. sku: Object,
  29. goods: Object,
  30. value: Boolean,
  31. buyText: String,
  32. goodsId: [Number, String],
  33. priceTag: String,
  34. lazyLoad: Boolean,
  35. hideStock: Boolean,
  36. properties: Array,
  37. addCartText: String,
  38. stepperTitle: String,
  39. getContainer: [String, Function],
  40. hideQuotaText: Boolean,
  41. hideSelectedText: Boolean,
  42. resetStepperOnHide: Boolean,
  43. customSkuValidator: Function,
  44. disableStepperInput: Boolean,
  45. resetSelectedSkuOnHide: Boolean,
  46. quota: {
  47. type: Number,
  48. default: 0
  49. },
  50. quotaUsed: {
  51. type: Number,
  52. default: 0
  53. },
  54. startSaleNum: {
  55. type: Number,
  56. default: 1
  57. },
  58. initialSku: {
  59. type: Object,
  60. default: function _default() {
  61. return {};
  62. }
  63. },
  64. stockThreshold: {
  65. type: Number,
  66. default: 50
  67. },
  68. showSoldoutSku: {
  69. type: Boolean,
  70. default: true
  71. },
  72. showAddCartBtn: {
  73. type: Boolean,
  74. default: true
  75. },
  76. disableSoldoutSku: {
  77. type: Boolean,
  78. default: true
  79. },
  80. customStepperConfig: {
  81. type: Object,
  82. default: function _default() {
  83. return {};
  84. }
  85. },
  86. showHeaderImage: {
  87. type: Boolean,
  88. default: true
  89. },
  90. previewOnClickImage: {
  91. type: Boolean,
  92. default: true
  93. },
  94. safeAreaInsetBottom: {
  95. type: Boolean,
  96. default: true
  97. },
  98. closeOnClickOverlay: {
  99. type: Boolean,
  100. default: true
  101. },
  102. bodyOffsetTop: {
  103. type: Number,
  104. default: 200
  105. },
  106. messageConfig: {
  107. type: Object,
  108. default: function _default() {
  109. return {
  110. initialMessages: {},
  111. placeholderMap: {},
  112. uploadImg: function uploadImg() {
  113. return Promise.resolve();
  114. },
  115. uploadMaxSize: 5
  116. };
  117. }
  118. }
  119. },
  120. data: function data() {
  121. return {
  122. selectedSku: {},
  123. selectedProp: {},
  124. selectedNum: 1,
  125. show: this.value
  126. };
  127. },
  128. watch: {
  129. show: function show(val) {
  130. this.$emit('input', val);
  131. if (!val) {
  132. this.$emit('sku-close', {
  133. selectedSkuValues: this.selectedSkuValues,
  134. selectedNum: this.selectedNum,
  135. selectedSkuComb: this.selectedSkuComb
  136. });
  137. if (this.resetStepperOnHide) {
  138. this.resetStepper();
  139. }
  140. if (this.resetSelectedSkuOnHide) {
  141. this.resetSelectedSku();
  142. }
  143. }
  144. },
  145. value: function value(val) {
  146. this.show = val;
  147. },
  148. skuTree: 'resetSelectedSku',
  149. initialSku: function initialSku() {
  150. this.resetStepper();
  151. this.resetSelectedSku();
  152. }
  153. },
  154. computed: {
  155. skuGroupClass: function skuGroupClass() {
  156. return ['van-sku-group-container', {
  157. 'van-sku-group-container--hide-soldout': !this.showSoldoutSku
  158. }];
  159. },
  160. bodyStyle: function bodyStyle() {
  161. if (this.$isServer) {
  162. return;
  163. }
  164. var maxHeight = window.innerHeight - this.bodyOffsetTop;
  165. return {
  166. maxHeight: maxHeight + 'px'
  167. };
  168. },
  169. isSkuCombSelected: function isSkuCombSelected() {
  170. var _this = this;
  171. // SKU 未选完
  172. if (this.hasSku && !(0, _skuHelper.isAllSelected)(this.skuTree, this.selectedSku)) {
  173. return false;
  174. } // 属性未全选
  175. return !this.propList.filter(function (i) {
  176. return i.is_necessary !== false;
  177. }).some(function (i) {
  178. return (_this.selectedProp[i.k_id] || []).length === 0;
  179. });
  180. },
  181. isSkuEmpty: function isSkuEmpty() {
  182. return Object.keys(this.sku).length === 0;
  183. },
  184. hasSku: function hasSku() {
  185. return !this.sku.none_sku;
  186. },
  187. hasSkuOrAttr: function hasSkuOrAttr() {
  188. return this.hasSku || this.propList.length > 0;
  189. },
  190. selectedSkuComb: function selectedSkuComb() {
  191. var skuComb = null;
  192. if (this.isSkuCombSelected) {
  193. if (this.hasSku) {
  194. skuComb = (0, _skuHelper.getSkuComb)(this.skuList, this.selectedSku);
  195. } else {
  196. skuComb = {
  197. id: this.sku.collection_id,
  198. price: Math.round(this.sku.price * 100),
  199. stock_num: this.sku.stock_num
  200. };
  201. }
  202. if (skuComb) {
  203. skuComb.properties = (0, _skuHelper.getSelectedProperties)(this.propList, this.selectedProp);
  204. skuComb.property_price = this.selectedPropValues.reduce(function (acc, cur) {
  205. return acc + (cur.price || 0);
  206. }, 0);
  207. }
  208. }
  209. return skuComb;
  210. },
  211. selectedSkuValues: function selectedSkuValues() {
  212. return (0, _skuHelper.getSelectedSkuValues)(this.skuTree, this.selectedSku);
  213. },
  214. selectedPropValues: function selectedPropValues() {
  215. return (0, _skuHelper.getSelectedPropValues)(this.propList, this.selectedProp);
  216. },
  217. price: function price() {
  218. if (this.selectedSkuComb) {
  219. return ((this.selectedSkuComb.price + this.selectedSkuComb.property_price) / 100).toFixed(2);
  220. } // sku.price是一个格式化好的价格区间
  221. return this.sku.price;
  222. },
  223. originPrice: function originPrice() {
  224. if (this.selectedSkuComb && this.selectedSkuComb.origin_price) {
  225. return ((this.selectedSkuComb.origin_price + this.selectedSkuComb.property_price) / 100).toFixed(2);
  226. }
  227. return this.sku.origin_price;
  228. },
  229. skuTree: function skuTree() {
  230. return this.sku.tree || [];
  231. },
  232. skuList: function skuList() {
  233. return this.sku.list || [];
  234. },
  235. propList: function propList() {
  236. return this.properties || [];
  237. },
  238. imageList: function imageList() {
  239. var imageList = [this.goods.picture];
  240. if (this.skuTree.length > 0) {
  241. this.skuTree.forEach(function (treeItem) {
  242. if (!treeItem.v) {
  243. return;
  244. }
  245. treeItem.v.forEach(function (vItem) {
  246. var imgUrl = vItem.previewImgUrl || vItem.imgUrl || vItem.img_url;
  247. if (imgUrl && imageList.indexOf(imgUrl) === -1) {
  248. imageList.push(imgUrl);
  249. }
  250. });
  251. });
  252. }
  253. return imageList;
  254. },
  255. stock: function stock() {
  256. var stockNum = this.customStepperConfig.stockNum;
  257. if (stockNum !== undefined) {
  258. return stockNum;
  259. }
  260. if (this.selectedSkuComb) {
  261. return this.selectedSkuComb.stock_num;
  262. }
  263. return this.sku.stock_num;
  264. },
  265. stockText: function stockText() {
  266. var h = this.$createElement;
  267. var stockFormatter = this.customStepperConfig.stockFormatter;
  268. if (stockFormatter) {
  269. return stockFormatter(this.stock);
  270. }
  271. return [t('stock') + " ", h("span", {
  272. "class": bem('stock-num', {
  273. highlight: this.stock < this.stockThreshold
  274. })
  275. }, [this.stock]), " " + t('stockUnit')];
  276. },
  277. selectedText: function selectedText() {
  278. var _this2 = this;
  279. if (this.selectedSkuComb) {
  280. var values = this.selectedSkuValues.concat(this.selectedPropValues);
  281. return t('selected') + " " + values.map(function (item) {
  282. return item.name;
  283. }).join(' ');
  284. }
  285. var unselectedSku = this.skuTree.filter(function (item) {
  286. return _this2.selectedSku[item.k_s] === _constants.UNSELECTED_SKU_VALUE_ID;
  287. }).map(function (item) {
  288. return item.k;
  289. });
  290. var unselectedProp = this.propList.filter(function (item) {
  291. return (_this2.selectedProp[item.k_id] || []).length < 1;
  292. }).map(function (item) {
  293. return item.k;
  294. });
  295. return t('select') + " " + unselectedSku.concat(unselectedProp).join(' ');
  296. }
  297. },
  298. created: function created() {
  299. var skuEventBus = new _vue.default();
  300. this.skuEventBus = skuEventBus;
  301. skuEventBus.$on('sku:select', this.onSelect);
  302. skuEventBus.$on('sku:propSelect', this.onPropSelect);
  303. skuEventBus.$on('sku:numChange', this.onNumChange);
  304. skuEventBus.$on('sku:previewImage', this.onPreviewImage);
  305. skuEventBus.$on('sku:overLimit', this.onOverLimit);
  306. skuEventBus.$on('sku:stepperState', this.onStepperState);
  307. skuEventBus.$on('sku:addCart', this.onAddCart);
  308. skuEventBus.$on('sku:buy', this.onBuy);
  309. this.resetStepper();
  310. this.resetSelectedSku(); // 组件初始化后的钩子,抛出skuEventBus
  311. this.$emit('after-sku-create', skuEventBus);
  312. },
  313. methods: {
  314. resetStepper: function resetStepper() {
  315. var skuStepper = this.$refs.skuStepper;
  316. var selectedNum = this.initialSku.selectedNum;
  317. var num = selectedNum != null ? selectedNum : this.startSaleNum; // 用来缓存不合法的情况
  318. this.stepperError = null;
  319. if (skuStepper) {
  320. skuStepper.setCurrentNum(num);
  321. } else {
  322. // 当首次加载(skuStepper 为空)时,传入数量如果不合法,可能会存在问题
  323. this.selectedNum = num;
  324. }
  325. },
  326. // @exposed-api
  327. resetSelectedSku: function resetSelectedSku() {
  328. var _this3 = this;
  329. this.selectedSku = {}; // 重置 selectedSku
  330. this.skuTree.forEach(function (item) {
  331. _this3.selectedSku[item.k_s] = _constants.UNSELECTED_SKU_VALUE_ID;
  332. });
  333. this.skuTree.forEach(function (item) {
  334. var key = item.k_s; // 规格值只有1个时,优先判断
  335. var valueId = item.v.length === 1 ? item.v[0].id : _this3.initialSku[key];
  336. if (valueId && (0, _skuHelper.isSkuChoosable)(_this3.skuList, _this3.selectedSku, {
  337. key: key,
  338. valueId: valueId
  339. })) {
  340. _this3.selectedSku[key] = valueId;
  341. }
  342. });
  343. var skuValues = this.selectedSkuValues;
  344. if (skuValues.length > 0) {
  345. this.$nextTick(function () {
  346. _this3.$emit('sku-selected', {
  347. skuValue: skuValues[skuValues.length - 1],
  348. selectedSku: _this3.selectedSku,
  349. selectedSkuComb: _this3.selectedSkuComb
  350. });
  351. });
  352. } // 重置商品属性
  353. this.selectedProp = {};
  354. var _this$initialSku$sele = this.initialSku.selectedProp,
  355. selectedProp = _this$initialSku$sele === void 0 ? {} : _this$initialSku$sele; // 选中外部传入信息
  356. this.propList.forEach(function (item) {
  357. if (selectedProp[item.k_id]) {
  358. _this3.selectedProp[item.k_id] = selectedProp[item.k_id];
  359. }
  360. });
  361. if ((0, _utils.isEmpty)(this.selectedProp)) {
  362. this.propList.forEach(function (item) {
  363. var _item$v;
  364. // 没有加价的属性,默认选中第一个
  365. if ((item == null ? void 0 : (_item$v = item.v) == null ? void 0 : _item$v.length) > 0) {
  366. var v = item.v,
  367. k_id = item.k_id;
  368. var isHasConfigPrice = v.some(function (i) {
  369. return +i.price !== 0;
  370. }); // 没有加价属性
  371. if (!isHasConfigPrice) {
  372. // 找到第一个不被禁用的属性
  373. // 历史如果没有 text_status 字段的,就相当于沿用直接原来的逻辑取第一个属性
  374. var firstEnableProp = v.find(function (prop) {
  375. return prop.text_status !== 0;
  376. });
  377. if (firstEnableProp) {
  378. _this3.selectedProp[k_id] = [firstEnableProp.id];
  379. }
  380. }
  381. }
  382. });
  383. }
  384. var propValues = this.selectedPropValues;
  385. if (propValues.length > 0) {
  386. this.$emit('sku-prop-selected', {
  387. propValue: propValues[propValues.length - 1],
  388. selectedProp: this.selectedProp,
  389. selectedSkuComb: this.selectedSkuComb
  390. });
  391. } // 抛出重置事件
  392. this.$emit('sku-reset', {
  393. selectedSku: this.selectedSku,
  394. selectedProp: this.selectedProp,
  395. selectedSkuComb: this.selectedSkuComb
  396. });
  397. this.centerInitialSku();
  398. },
  399. getSkuMessages: function getSkuMessages() {
  400. return this.$refs.skuMessages ? this.$refs.skuMessages.getMessages() : {};
  401. },
  402. getSkuCartMessages: function getSkuCartMessages() {
  403. return this.$refs.skuMessages ? this.$refs.skuMessages.getCartMessages() : {};
  404. },
  405. validateSkuMessages: function validateSkuMessages() {
  406. return this.$refs.skuMessages ? this.$refs.skuMessages.validateMessages() : '';
  407. },
  408. validateSku: function validateSku() {
  409. if (this.selectedNum === 0) {
  410. return t('unavailable');
  411. }
  412. if (this.isSkuCombSelected) {
  413. return this.validateSkuMessages();
  414. } // 自定义sku校验
  415. if (this.customSkuValidator) {
  416. var err = this.customSkuValidator(this);
  417. if (err) return err;
  418. }
  419. return t('selectSku');
  420. },
  421. onSelect: function onSelect(skuValue) {
  422. var _extends2, _extends3;
  423. // 点击已选中的sku时则取消选中
  424. this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? (0, _extends5.default)({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = _constants.UNSELECTED_SKU_VALUE_ID, _extends2)) : (0, _extends5.default)({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3));
  425. this.$emit('sku-selected', {
  426. skuValue: skuValue,
  427. selectedSku: this.selectedSku,
  428. selectedSkuComb: this.selectedSkuComb
  429. });
  430. },
  431. onPropSelect: function onPropSelect(propValue) {
  432. var _extends4;
  433. var arr = this.selectedProp[propValue.skuKeyStr] || [];
  434. var pos = arr.indexOf(propValue.id);
  435. if (pos > -1) {
  436. arr.splice(pos, 1);
  437. } else if (propValue.multiple) {
  438. arr.push(propValue.id);
  439. } else {
  440. arr.splice(0, 1, propValue.id);
  441. }
  442. this.selectedProp = (0, _extends5.default)({}, this.selectedProp, (_extends4 = {}, _extends4[propValue.skuKeyStr] = arr, _extends4));
  443. this.$emit('sku-prop-selected', {
  444. propValue: propValue,
  445. selectedProp: this.selectedProp,
  446. selectedSkuComb: this.selectedSkuComb
  447. });
  448. },
  449. onNumChange: function onNumChange(num) {
  450. this.selectedNum = num;
  451. },
  452. onPreviewImage: function onPreviewImage(selectedValue) {
  453. var _this4 = this;
  454. var imageList = this.imageList;
  455. var index = 0;
  456. var indexImage = imageList[0];
  457. if (selectedValue && selectedValue.imgUrl) {
  458. this.imageList.some(function (image, pos) {
  459. if (image === selectedValue.imgUrl) {
  460. index = pos;
  461. return true;
  462. }
  463. return false;
  464. });
  465. indexImage = selectedValue.imgUrl;
  466. }
  467. var params = (0, _extends5.default)({}, selectedValue, {
  468. index: index,
  469. imageList: this.imageList,
  470. indexImage: indexImage
  471. });
  472. this.$emit('open-preview', params);
  473. if (!this.previewOnClickImage) {
  474. return;
  475. }
  476. (0, _imagePreview.default)({
  477. images: this.imageList,
  478. startPosition: index,
  479. onClose: function onClose() {
  480. _this4.$emit('close-preview', params);
  481. }
  482. });
  483. },
  484. onOverLimit: function onOverLimit(data) {
  485. var action = data.action,
  486. limitType = data.limitType,
  487. quota = data.quota,
  488. quotaUsed = data.quotaUsed;
  489. var handleOverLimit = this.customStepperConfig.handleOverLimit;
  490. if (handleOverLimit) {
  491. handleOverLimit(data);
  492. return;
  493. }
  494. if (action === 'minus') {
  495. if (this.startSaleNum > 1) {
  496. (0, _toast.default)(t('minusStartTip', this.startSaleNum));
  497. } else {
  498. (0, _toast.default)(t('minusTip'));
  499. }
  500. } else if (action === 'plus') {
  501. if (limitType === QUOTA_LIMIT) {
  502. if (quotaUsed > 0) {
  503. (0, _toast.default)(t('quotaUsedTip', quota, quotaUsed));
  504. } else {
  505. (0, _toast.default)(t('quotaTip', quota));
  506. }
  507. } else {
  508. (0, _toast.default)(t('soldout'));
  509. }
  510. }
  511. },
  512. onStepperState: function onStepperState(data) {
  513. this.stepperError = data.valid ? null : (0, _extends5.default)({}, data, {
  514. action: 'plus'
  515. });
  516. },
  517. onAddCart: function onAddCart() {
  518. this.onBuyOrAddCart('add-cart');
  519. },
  520. onBuy: function onBuy() {
  521. this.onBuyOrAddCart('buy-clicked');
  522. },
  523. onBuyOrAddCart: function onBuyOrAddCart(type) {
  524. // sku 不符合购买条件
  525. if (this.stepperError) {
  526. return this.onOverLimit(this.stepperError);
  527. }
  528. var error = this.validateSku();
  529. if (error) {
  530. (0, _toast.default)(error);
  531. } else {
  532. this.$emit(type, this.getSkuData());
  533. }
  534. },
  535. // @exposed-api
  536. getSkuData: function getSkuData() {
  537. return {
  538. goodsId: this.goodsId,
  539. messages: this.getSkuMessages(),
  540. selectedNum: this.selectedNum,
  541. cartMessages: this.getSkuCartMessages(),
  542. selectedSkuComb: this.selectedSkuComb
  543. };
  544. },
  545. // 当 popup 完全打开后执行
  546. onOpened: function onOpened() {
  547. this.centerInitialSku();
  548. },
  549. centerInitialSku: function centerInitialSku() {
  550. var _this5 = this;
  551. (this.$refs.skuRows || []).forEach(function (it) {
  552. var _ref = it.skuRow || {},
  553. k_s = _ref.k_s;
  554. it.centerItem(_this5.initialSku[k_s]);
  555. });
  556. }
  557. },
  558. render: function render() {
  559. var _this6 = this;
  560. var h = arguments[0];
  561. if (this.isSkuEmpty) {
  562. return;
  563. }
  564. var sku = this.sku,
  565. skuList = this.skuList,
  566. goods = this.goods,
  567. price = this.price,
  568. lazyLoad = this.lazyLoad,
  569. originPrice = this.originPrice,
  570. skuEventBus = this.skuEventBus,
  571. selectedSku = this.selectedSku,
  572. selectedProp = this.selectedProp,
  573. selectedNum = this.selectedNum,
  574. stepperTitle = this.stepperTitle,
  575. selectedSkuComb = this.selectedSkuComb,
  576. showHeaderImage = this.showHeaderImage,
  577. disableSoldoutSku = this.disableSoldoutSku;
  578. var slotsProps = {
  579. price: price,
  580. originPrice: originPrice,
  581. selectedNum: selectedNum,
  582. skuEventBus: skuEventBus,
  583. selectedSku: selectedSku,
  584. selectedSkuComb: selectedSkuComb
  585. };
  586. var slots = function slots(name) {
  587. return _this6.slots(name, slotsProps);
  588. };
  589. var Header = slots('sku-header') || h(_SkuHeader.default, {
  590. "attrs": {
  591. "sku": sku,
  592. "goods": goods,
  593. "skuEventBus": skuEventBus,
  594. "selectedSku": selectedSku,
  595. "showHeaderImage": showHeaderImage
  596. }
  597. }, [h("template", {
  598. "slot": "sku-header-image-extra"
  599. }, [slots('sku-header-image-extra')]), slots('sku-header-price') || h("div", {
  600. "class": "van-sku__goods-price"
  601. }, [h("span", {
  602. "class": "van-sku__price-symbol"
  603. }, ["\uFFE5"]), h("span", {
  604. "class": "van-sku__price-num"
  605. }, [price]), this.priceTag && h("span", {
  606. "class": "van-sku__price-tag"
  607. }, [this.priceTag])]), slots('sku-header-origin-price') || originPrice && h(_SkuHeaderItem.default, [t('originPrice'), " \uFFE5", originPrice]), !this.hideStock && h(_SkuHeaderItem.default, [h("span", {
  608. "class": "van-sku__stock"
  609. }, [this.stockText])]), this.hasSkuOrAttr && !this.hideSelectedText && h(_SkuHeaderItem.default, [this.selectedText]), slots('sku-header-extra')]);
  610. var Group = slots('sku-group') || this.hasSkuOrAttr && h("div", {
  611. "class": this.skuGroupClass
  612. }, [this.skuTree.map(function (skuTreeItem) {
  613. return h(_SkuRow.default, {
  614. "attrs": {
  615. "skuRow": skuTreeItem
  616. },
  617. "ref": "skuRows",
  618. "refInFor": true
  619. }, [skuTreeItem.v.map(function (skuValue) {
  620. return h(_SkuRowItem.default, {
  621. "attrs": {
  622. "skuList": skuList,
  623. "lazyLoad": lazyLoad,
  624. "skuValue": skuValue,
  625. "skuKeyStr": skuTreeItem.k_s,
  626. "selectedSku": selectedSku,
  627. "skuEventBus": skuEventBus,
  628. "disableSoldoutSku": disableSoldoutSku,
  629. "largeImageMode": skuTreeItem.largeImageMode
  630. }
  631. });
  632. })]);
  633. }), this.propList.map(function (skuTreeItem) {
  634. return h(_SkuRow.default, {
  635. "attrs": {
  636. "skuRow": skuTreeItem
  637. }
  638. }, [skuTreeItem.v.map(function (skuValue) {
  639. return h(_SkuRowPropItem.default, {
  640. "attrs": {
  641. "skuValue": skuValue,
  642. "skuKeyStr": skuTreeItem.k_id + '',
  643. "selectedProp": selectedProp,
  644. "skuEventBus": skuEventBus,
  645. "multiple": skuTreeItem.is_multiple,
  646. "disabled": skuValue.text_status === 0
  647. }
  648. });
  649. })]);
  650. })]);
  651. var Stepper = slots('sku-stepper') || h(_SkuStepper.default, {
  652. "ref": "skuStepper",
  653. "attrs": {
  654. "stock": this.stock,
  655. "quota": this.quota,
  656. "quotaUsed": this.quotaUsed,
  657. "startSaleNum": this.startSaleNum,
  658. "skuEventBus": skuEventBus,
  659. "selectedNum": selectedNum,
  660. "stepperTitle": stepperTitle,
  661. "skuStockNum": sku.stock_num,
  662. "disableStepperInput": this.disableStepperInput,
  663. "customStepperConfig": this.customStepperConfig,
  664. "hideQuotaText": this.hideQuotaText
  665. },
  666. "on": {
  667. "change": function change(event) {
  668. _this6.$emit('stepper-change', event);
  669. }
  670. }
  671. });
  672. var Messages = slots('sku-messages') || h(_SkuMessages.default, {
  673. "ref": "skuMessages",
  674. "attrs": {
  675. "goodsId": this.goodsId,
  676. "messageConfig": this.messageConfig,
  677. "messages": sku.messages
  678. }
  679. });
  680. var Actions = slots('sku-actions') || h(_SkuActions.default, {
  681. "attrs": {
  682. "buyText": this.buyText,
  683. "skuEventBus": skuEventBus,
  684. "addCartText": this.addCartText,
  685. "showAddCartBtn": this.showAddCartBtn
  686. }
  687. });
  688. return h(_popup.default, {
  689. "attrs": {
  690. "round": true,
  691. "closeable": true,
  692. "position": "bottom",
  693. "getContainer": this.getContainer,
  694. "closeOnClickOverlay": this.closeOnClickOverlay,
  695. "safeAreaInsetBottom": this.safeAreaInsetBottom
  696. },
  697. "class": "van-sku-container",
  698. "on": {
  699. "opened": this.onOpened
  700. },
  701. "model": {
  702. value: _this6.show,
  703. callback: function callback($$v) {
  704. _this6.show = $$v;
  705. }
  706. }
  707. }, [Header, h("div", {
  708. "class": "van-sku-body",
  709. "style": this.bodyStyle
  710. }, [slots('sku-body-top'), Group, slots('extra-sku-group'), Stepper, slots('before-sku-messages'), Messages, slots('after-sku-messages')]), slots('sku-actions-top'), Actions]);
  711. }
  712. });
  713. exports.default = _default2;