Sku.js 24 KB

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