productInfo.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  1. <template>
  2. <view class="product-info-diy" v-if="productData">
  3. <common-wrapper :config="configData">
  4. <view class="product-info-box" :class="'style-' + specStyle">
  5. <!-- 图片区域 -->
  6. <view class="image-wrap">
  7. <swiper
  8. class="swiper"
  9. :circular="true"
  10. :autoplay="!videoPlaying"
  11. :interval="3000"
  12. :duration="500"
  13. @change="swiperChange"
  14. >
  15. <swiper-item v-for="(item, index) in sliderImage" :key="index">
  16. <!-- 视频项 -->
  17. <view v-if="item.isVideo" class="video-item">
  18. <view v-show="!videoControls" class="video-wrap">
  19. <video
  20. id="productVideo"
  21. :src="item.src"
  22. object-fit="contain"
  23. controls
  24. style="width:100%;height:100%"
  25. show-center-play-btn
  26. show-mute-btn="true"
  27. auto-pause-if-navigate
  28. :custom-cache="false"
  29. :enable-progress-gesture="false"
  30. :poster="item.poster"
  31. @play="onVideoPlay"
  32. @pause="onVideoPause"
  33. ></video>
  34. </view>
  35. <view class="poster" v-show="videoControls">
  36. <image class="image" :src="item.poster" mode="aspectFill"></image>
  37. </view>
  38. <view class="play-btn" v-show="videoControls" @click.stop="playVideo">
  39. <image class="icon" src="@/static/images/stop.png" mode="aspectFit"></image>
  40. </view>
  41. </view>
  42. <!-- 图片项 -->
  43. <image v-else :src="item" mode="aspectFill" class="slide-image"></image>
  44. </swiper-item>
  45. </swiper>
  46. <!-- 镜像效果 -->
  47. <view class="mirror-wrap">
  48. <image
  49. :src="currentSlideImage"
  50. mode="aspectFill"
  51. class="mirror-image"
  52. ></image>
  53. </view>
  54. <!-- 指示器 -->
  55. <view
  56. class="indicators"
  57. :class="'pos-' + indicatorPosition"
  58. v-if="indicatorConfig.tabVal !== undefined"
  59. >
  60. <!-- 线段样式 -->
  61. <view v-if="indicatorConfig.tabVal === 0" class="indicator-line">
  62. <view
  63. class="line-item"
  64. v-for="(item, index) in sliderImage"
  65. :key="index"
  66. :class="{ active: currentSwiper === index }"
  67. :style="{
  68. backgroundColor:
  69. currentSwiper === index ? selectColor : defaultColor,
  70. }"
  71. ></view>
  72. </view>
  73. <!-- 点线样式 -->
  74. <view v-if="indicatorConfig.tabVal === 1" class="indicator-dot">
  75. <view
  76. class="dot-item"
  77. v-for="(item, index) in sliderImage"
  78. :key="index"
  79. :class="{ active: currentSwiper === index }"
  80. :style="{
  81. backgroundColor:
  82. currentSwiper === index ? selectColor : defaultColor,
  83. }"
  84. ></view>
  85. </view>
  86. <!-- 数字样式 -->
  87. <view v-if="indicatorConfig.tabVal === 2" class="indicator-number">
  88. <view class="num-box">
  89. <text class="current">{{ currentSwiper + 1 }}</text>
  90. <text>/</text>
  91. <text class="total">{{ sliderImage.length }}</text>
  92. </view>
  93. </view>
  94. </view>
  95. <!-- 规格样式 4: 图片内部底部 -->
  96. <view
  97. v-if="specStyle === 3 && skuList.length > 0"
  98. class="spec-style-4"
  99. >
  100. <scroll-view scroll-x="true" class="spec-list">
  101. <view
  102. class="spec-item"
  103. v-for="(item, index) in skuList"
  104. :key="index"
  105. :style="{
  106. borderColor:
  107. index === selectedIndex
  108. ? specSelectedBorderColor
  109. : 'transparent',
  110. background:
  111. index === selectedIndex ? specSelectedBgColor : '#777777',
  112. }"
  113. @click="changeSpec(item, index)"
  114. >
  115. <image :src="item.image" mode="aspectFill"></image>
  116. <view class="spec-info">
  117. <view
  118. class="name line2"
  119. :style="{
  120. color:
  121. index === selectedIndex
  122. ? specSelectedTextColor
  123. : specUnselectedTextColor,
  124. }"
  125. >
  126. {{ item.suk || "规格" }}
  127. </view>
  128. </view>
  129. </view>
  130. <view
  131. class="total-count"
  132. :style="{ color: specTextColor }"
  133. @click="showSpecModal"
  134. >
  135. <view>
  136. <view>{{ skuList.length }}款</view>
  137. <view>可选</view>
  138. </view>
  139. <text class="iconfont icon-jiantou"></text>
  140. </view>
  141. </scroll-view>
  142. </view>
  143. </view>
  144. <!-- 信息区域 -->
  145. <view class="info-box">
  146. <!-- 规格样式 0 & 1: 顶部 -->
  147. <view
  148. v-if="(specStyle === 0 || specStyle === 1) && skuList.length > 0"
  149. class="spec-top-section"
  150. :class="'style-' + specStyle"
  151. >
  152. <!-- 样式 0: 小图列表 -->
  153. <scroll-view
  154. scroll-x="true"
  155. class="spec-list"
  156. v-if="specStyle === 0"
  157. >
  158. <view
  159. class="spec-item"
  160. v-for="(item, index) in skuList"
  161. :key="index"
  162. @click="changeSpec(item, index)"
  163. >
  164. <image
  165. :src="item.image"
  166. mode="aspectFill"
  167. :style="{
  168. borderColor:
  169. index === selectedIndex ? specSelectedColor : '#eee',
  170. }"
  171. ></image>
  172. </view>
  173. </scroll-view>
  174. <view
  175. v-if="specStyle === 0"
  176. class="total-count"
  177. :style="{ color: specTextColor }"
  178. @click="showSpecModal"
  179. >
  180. <view>
  181. <view>{{ skuList.length }}款</view>
  182. <view>可选</view>
  183. </view>
  184. <text class="iconfont icon-jiantou"></text>
  185. </view>
  186. <!-- 样式 1: 图文列表 -->
  187. <view class="spec-list-text-wrapper" v-if="specStyle === 1">
  188. <scroll-view scroll-x="true" class="spec-list-text">
  189. <view
  190. class="spec-item"
  191. v-for="(item, index) in skuList"
  192. :key="index"
  193. :class="{ active: index === selectedIndex }"
  194. :style="{
  195. background:
  196. index === selectedIndex ? specSelectedBgColor : '#f5f5f5',
  197. borderColor:
  198. index === selectedIndex
  199. ? specSelectedColor
  200. : 'transparent',
  201. }"
  202. @click="changeSpec(item, index)"
  203. >
  204. <image :src="item.image" mode="aspectFill"></image>
  205. <text
  206. class="name line1"
  207. :style="{ color: specSelectedTextColor }"
  208. >{{ item.suk }}</text
  209. >
  210. </view>
  211. <view class="spacer"></view>
  212. </scroll-view>
  213. <view
  214. class="total-count"
  215. :style="{ color: specTextColor }"
  216. @click="showSpecModal"
  217. >
  218. <text>共{{ skuList.length }}款</text>
  219. <text class="iconfont icon-jiantou"></text>
  220. </view>
  221. </view>
  222. </view>
  223. <!-- 信息排序列表 -->
  224. <view
  225. class="info-item"
  226. v-for="(item, index) in sortList"
  227. :key="index"
  228. >
  229. <!-- 价格区域 -->
  230. <view
  231. v-if="item.name === 'price' && item.show"
  232. class="price-section"
  233. >
  234. <view class="price-row">
  235. <view
  236. v-if="item.checkList.includes(0)"
  237. class="main-price-wrap"
  238. :style="{ color: finalPriceColor }"
  239. >
  240. <view class="label">到手价</view>
  241. <view class="symbol">¥</view>
  242. <view
  243. class="price"
  244. :style="{
  245. fontSize: priceFontSize + 'px',
  246. lineHeight: priceFontSize + 'px',
  247. }"
  248. >{{ displayInfo.real_price }}</view
  249. >
  250. </view>
  251. <view
  252. v-if="item.checkList.includes(1)"
  253. class="ot-price-wrap"
  254. :style="{ color: sellingPriceColor }"
  255. >
  256. <text class="label">售价</text>
  257. <text class="price">¥{{ displayInfo.ot_price }}</text>
  258. </view>
  259. <view
  260. v-if="item.checkList.includes(2) && displayInfo.vip_price"
  261. class="vip-price-wrap"
  262. >
  263. <text class="badge">SVIP</text>
  264. <text class="price">¥{{ displayInfo.vip_price }}</text>
  265. </view>
  266. </view>
  267. </view>
  268. <!-- 名称区域 -->
  269. <view v-if="item.name === 'name' && item.show" class="name-section">
  270. <view
  271. class="title"
  272. :style="{
  273. color: titleColor,
  274. fontSize: titleFontSize + 'px',
  275. fontWeight: 'bold',
  276. }"
  277. >{{ productData.store_name }}</view
  278. >
  279. <!-- <view class="share" @click="emitShare">
  280. <text class="iconfont icon-fenxiang"></text>
  281. </view> -->
  282. </view>
  283. <!-- 数据区域 -->
  284. <view v-if="item.name === 'data' && item.show" class="data-section">
  285. <text
  286. v-if="item.checkList.includes(0)"
  287. :style="{ color: originalPriceColor }"
  288. >原价: ¥{{ displayInfo.ot_price }}</text
  289. >
  290. <text
  291. v-if="item.checkList.includes(1)"
  292. :style="{ color: stockColor }"
  293. >库存: {{ displayInfo.stock }}</text
  294. >
  295. <text
  296. v-if="item.checkList.includes(2)"
  297. :style="{ color: salesColor }"
  298. >销量: {{ displayInfo.fsales }}{{ displayInfo.unit_name }}</text
  299. >
  300. </view>
  301. <!-- 标签区域 -->
  302. <view
  303. v-if="
  304. item.name === 'tags' &&
  305. item.show &&
  306. productData.label_list &&
  307. productData.label_list.length
  308. "
  309. class="tags-section"
  310. >
  311. <BaseTag
  312. :text="tag.name"
  313. :color="tag.font_color"
  314. :background="tag.bg_color"
  315. :borderColor="tag.border_color"
  316. :circle="tag.border_color ? true : false"
  317. :imgSrc="tag.image"
  318. size="middle"
  319. v-for="(tag, tIndex) in productData.label_list"
  320. :key="tIndex"
  321. ></BaseTag>
  322. </view>
  323. </view>
  324. <!-- 规格样式 2: 底部 -->
  325. <view
  326. v-if="specStyle === 2 && skuList.length > 0"
  327. class="spec-bottom-section"
  328. >
  329. <view class="spec-list-wrapper">
  330. <scroll-view scroll-x="true" class="spec-list">
  331. <view
  332. class="spec-item"
  333. v-for="(item, index) in skuList"
  334. :key="index"
  335. @click="changeSpec(item, index)"
  336. :style="{
  337. borderColor:
  338. index === selectedIndex
  339. ? specSelectedBorderColor
  340. : 'transparent',
  341. }"
  342. >
  343. <image :src="item.image" mode="aspectFill"></image>
  344. <view
  345. class="name line1"
  346. :style="{
  347. color:
  348. index === selectedIndex
  349. ? specSelectedTextColor
  350. : specUnselectedTextColor,
  351. background:
  352. index === selectedIndex
  353. ? specSelectedBgColor
  354. : '#f5f5f5',
  355. }"
  356. >
  357. {{ item.suk }}
  358. </view>
  359. </view>
  360. <view class="spacer"></view>
  361. </scroll-view>
  362. <view class="total-count" @click="showSpecModal">
  363. <view>
  364. <view>{{ skuList.length }}款</view>
  365. <view>可选</view>
  366. </view>
  367. <text class="iconfont icon-jiantou"></text>
  368. </view>
  369. </view>
  370. </view>
  371. </view>
  372. </view>
  373. </common-wrapper>
  374. </view>
  375. </template>
  376. <script>
  377. import commonWrapper from "./commonWrapper.vue";
  378. import BaseTag from "@/components/BaseTag.vue";
  379. export default {
  380. name: "productInfo",
  381. components: {
  382. BaseTag,
  383. commonWrapper
  384. },
  385. props: {
  386. dataConfig: {
  387. type: Object,
  388. default: () => ({}),
  389. },
  390. productData: {
  391. type: Object,
  392. default: () => ({}),
  393. },
  394. priceData: {
  395. type: Object,
  396. default: () => ({}),
  397. },
  398. skuList: {
  399. type: Array,
  400. default: () => [],
  401. },
  402. colorStyle: {
  403. type: Object,
  404. default: () => ({ theme: "#E93323" }),
  405. },
  406. },
  407. data() {
  408. return {
  409. currentSwiper: 0,
  410. selectedIndex: 0,
  411. videoControls: true,
  412. videoPlaying: false,
  413. };
  414. },
  415. computed: {
  416. displayInfo() {
  417. let price = this.priceData.price || "0.00";
  418. let real_price = this.priceData.real_price || "0.00";
  419. let ot_price = this.priceData.ot_price || "0.00";
  420. let vip_price = this.priceData.vip_price;
  421. let stock = this.productData.stock || 0;
  422. let fsales = this.productData.fsales || 0;
  423. let unit_name = this.productData.unit_name || "";
  424. if (this.skuList.length > 0 && this.selectedIndex < this.skuList.length) {
  425. let sku = this.skuList[this.selectedIndex];
  426. if (sku) {
  427. if (sku.price) price = sku.price;
  428. if (sku.real_price) price = sku.real_price;
  429. if (sku.ot_price) ot_price = sku.ot_price;
  430. if (sku.vip_price) vip_price = sku.vip_price;
  431. if (sku.stock || sku.stock === 0) stock = sku.stock;
  432. }
  433. }
  434. return { price, ot_price, vip_price, stock, fsales, unit_name, real_price };
  435. },
  436. sliderImage() {
  437. const images = this.productData.slider_image || [];
  438. const videoLink = this.productData.video_link;
  439. if (videoLink) {
  440. // 有视频时,第一项为视频对象,后面是图片(跳过第一张图片作为封面)
  441. return [
  442. {
  443. isVideo: true,
  444. src: videoLink,
  445. poster: images[0] || '',
  446. },
  447. ...images.slice(1),
  448. ];
  449. }
  450. return images;
  451. },
  452. currentSlideImage() {
  453. const currentItem = this.sliderImage[this.currentSwiper];
  454. if (currentItem) {
  455. // 如果是视频,返回 poster;否则返回图片
  456. return currentItem.isVideo ? currentItem.poster : currentItem;
  457. }
  458. return '';
  459. },
  460. configData() {
  461. return {
  462. ...this.dataConfig,
  463. paddingConfig: this.dataConfig.paddingConfig || {
  464. isAll: false,
  465. valList: [{ val: 0 }, { val: 0 }, { val: 0 }, { val: 0 }],
  466. },
  467. marginConfig: this.dataConfig.marginConfig || {
  468. isAll: false,
  469. valList: [{ val: 0 }, { val: 0 }, { val: 0 }, { val: 0 }],
  470. },
  471. };
  472. },
  473. specStyle() {
  474. return this.dataConfig.specStyle ? this.dataConfig.specStyle.tabVal : 0;
  475. },
  476. specSettings() {
  477. return this.dataConfig.specSettings || {};
  478. },
  479. isCustomSpecTone() {
  480. return (
  481. this.specSettings.colorTone && this.specSettings.colorTone.tabVal === 1
  482. );
  483. },
  484. specSelectedColor() {
  485. if (this.isCustomSpecTone) {
  486. return this.specSettings.selectedBorderColor &&
  487. this.specSettings.selectedBorderColor.color[0].item
  488. ? this.specSettings.selectedBorderColor.color[0].item
  489. : "#E93323";
  490. }
  491. return "var(--view-theme)";
  492. },
  493. specTextColor() {
  494. if (this.isCustomSpecTone) {
  495. return this.specSettings.textColor &&
  496. this.specSettings.textColor.color[0].item
  497. ? this.specSettings.textColor.color[0].item
  498. : "#666";
  499. }
  500. return "var(--view-theme)";
  501. },
  502. specSelectedBorderColor() {
  503. if (this.isCustomSpecTone) {
  504. return this.specSettings.selectedBorderColor &&
  505. this.specSettings.selectedBorderColor.color[0].item
  506. ? this.specSettings.selectedBorderColor.color[0].item
  507. : this.specSelectedColor;
  508. }
  509. return this.specSelectedColor;
  510. },
  511. specSelectedTextColor() {
  512. if (this.isCustomSpecTone) {
  513. return this.specSettings.selectedTextColor &&
  514. this.specSettings.selectedTextColor.color[0].item
  515. ? this.specSettings.selectedTextColor.color[0].item
  516. : this.specTextColor;
  517. }
  518. return this.specTextColor;
  519. },
  520. specSelectedBgColor() {
  521. if (this.isCustomSpecTone) {
  522. return this.specSettings.selectedBgColor &&
  523. this.specSettings.selectedBgColor.color[0].item
  524. ? this.specSettings.selectedBgColor.color[0].item
  525. : this.hexToRgba(this.colorStyle.theme || "#E93323", 0.1);
  526. }
  527. return this.specStyle === 3
  528. ? "#777777"
  529. : this.hexToRgba(this.colorStyle.theme || "#E93323", 0.1);
  530. },
  531. specUnselectedTextColor() {
  532. if (this.isCustomSpecTone) {
  533. return this.specSettings.unselectedTextColor &&
  534. this.specSettings.unselectedTextColor.color[0].item
  535. ? this.specSettings.unselectedTextColor.color[0].item
  536. : this.specStyle === 3
  537. ? "#ffffff"
  538. : "#333333";
  539. }
  540. return this.specStyle === 3 ? "#ffffff" : "#333333";
  541. },
  542. titleColor() {
  543. const config = this.dataConfig.titleConfig;
  544. if (!config) return "#333333";
  545. if (config.tabVal === 0) {
  546. return "var(--view-theme)";
  547. }
  548. return config.color && config.color.color[0].item
  549. ? config.color.color[0].item
  550. : "#333333";
  551. },
  552. titleFontSize() {
  553. return this.dataConfig.titleConfig && this.dataConfig.titleConfig.fontSize
  554. ? this.dataConfig.titleConfig.fontSize.val
  555. : 16;
  556. },
  557. sortList() {
  558. return this.dataConfig.sortList
  559. ? this.dataConfig.sortList.list
  560. : [
  561. { name: "price", show: true, checkList: [0, 1, 2] },
  562. { name: "name", show: true },
  563. { name: "data", show: true, checkList: [0, 1, 2] },
  564. { name: "tags", show: true },
  565. ];
  566. },
  567. indicatorConfig() {
  568. return this.dataConfig.indicatorConfig || {};
  569. },
  570. selectColor() {
  571. return this.indicatorConfig.selectColor
  572. ? this.indicatorConfig.selectColor.color[0].item
  573. : "#E93323";
  574. },
  575. defaultColor() {
  576. return this.indicatorConfig.defaultColor
  577. ? this.indicatorConfig.defaultColor.color[0].item
  578. : "#CCCCCC";
  579. },
  580. indicatorPosition() {
  581. if (this.indicatorConfig.tabVal === 0) return "center";
  582. const pos = this.indicatorConfig.positionVal;
  583. return pos === 0 ? "left" : pos === 2 ? "right" : "center";
  584. },
  585. priceSettings() {
  586. return this.dataConfig.priceSettings || {};
  587. },
  588. dataSettings() {
  589. return this.dataConfig.dataSettings || {};
  590. },
  591. isCustomPriceTone() {
  592. return (
  593. this.priceSettings.colorTone &&
  594. this.priceSettings.colorTone.tabVal === 1
  595. );
  596. },
  597. finalPriceColor() {
  598. if (this.isCustomPriceTone) {
  599. return this.priceSettings.finalPriceColor &&
  600. this.priceSettings.finalPriceColor.color[0].item
  601. ? this.priceSettings.finalPriceColor.color[0].item
  602. : "#E93323";
  603. }
  604. return "var(--view-theme)" || "#E93323";
  605. },
  606. sellingPriceColor() {
  607. if (this.isCustomPriceTone) {
  608. return this.priceSettings.sellingPriceColor &&
  609. this.priceSettings.sellingPriceColor.color[0].item
  610. ? this.priceSettings.sellingPriceColor.color[0].item
  611. : "#333333";
  612. }
  613. return "#333333";
  614. },
  615. priceFontSize() {
  616. return this.priceSettings.priceFontSize
  617. ? this.priceSettings.priceFontSize.val
  618. : 24;
  619. },
  620. originalPriceColor() {
  621. return this.dataSettings.originalPriceColor &&
  622. this.dataSettings.originalPriceColor.color[0].item
  623. ? this.dataSettings.originalPriceColor.color[0].item
  624. : "#999999";
  625. },
  626. stockColor() {
  627. return this.dataSettings.stockColor &&
  628. this.dataSettings.stockColor.color[0].item
  629. ? this.dataSettings.stockColor.color[0].item
  630. : "#999999";
  631. },
  632. salesColor() {
  633. return this.dataSettings.salesColor &&
  634. this.dataSettings.salesColor.color[0].item
  635. ? this.dataSettings.salesColor.color[0].item
  636. : "#999999";
  637. },
  638. },
  639. methods: {
  640. swiperChange(e) {
  641. this.currentSwiper = e.detail.current;
  642. // 切换到非视频页时暂停视频
  643. if (this.currentSwiper !== 0 || !this.productData.video_link) {
  644. this.videoControls = true;
  645. this.videoPlaying = false;
  646. // 暂停视频
  647. const videoContext = uni.createVideoContext('productVideo', this);
  648. videoContext && videoContext.pause();
  649. }
  650. },
  651. playVideo() {
  652. this.videoControls = false;
  653. this.videoPlaying = true;
  654. this.$nextTick(() => {
  655. const videoContext = uni.createVideoContext('productVideo', this);
  656. videoContext.play();
  657. });
  658. },
  659. onVideoPlay() {
  660. this.videoPlaying = true;
  661. },
  662. onVideoPause() {
  663. this.videoPlaying = false;
  664. },
  665. changeSpec(item, index) {
  666. if (index !== undefined) {
  667. this.selectedIndex = index;
  668. }
  669. this.$emit("changeSpec", item);
  670. },
  671. showSpecModal() {
  672. this.$emit("showSpecModal");
  673. },
  674. emitShare() {
  675. this.$emit("share");
  676. },
  677. hexToRgba(hex, opacity) {
  678. if (!hex) return "";
  679. let c;
  680. if (/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)) {
  681. c = hex.substring(1).split("");
  682. if (c.length == 3) {
  683. c = [c[0], c[0], c[1], c[1], c[2], c[2]];
  684. }
  685. c = "0x" + c.join("");
  686. return (
  687. "rgba(" +
  688. [(c >> 16) & 255, (c >> 8) & 255, c & 255].join(",") +
  689. "," +
  690. opacity +
  691. ")"
  692. );
  693. }
  694. return hex;
  695. },
  696. },
  697. watch: {
  698. skuList: {
  699. handler(val) {
  700. if (val && val.length > 0) {
  701. this.selectedIndex = 0;
  702. }
  703. },
  704. deep: true,
  705. immediate: true,
  706. },
  707. },
  708. };
  709. </script>
  710. <style scoped lang="scss">
  711. .product-info-box {
  712. &.style-3 {
  713. .image-wrap .indicators {
  714. bottom: 170rpx;
  715. }
  716. }
  717. .image-wrap {
  718. position: relative;
  719. width: 100%;
  720. height: 782rpx;
  721. .swiper {
  722. width: 100%;
  723. height: 750rpx;
  724. .slide-image {
  725. width: 100%;
  726. height: 100%;
  727. }
  728. .video-item {
  729. position: relative;
  730. width: 100%;
  731. height: 100%;
  732. .video-wrap {
  733. width: 100%;
  734. height: 100%;
  735. }
  736. .poster {
  737. position: absolute;
  738. top: 0;
  739. left: 0;
  740. width: 100%;
  741. height: 100%;
  742. z-index: 9;
  743. .image {
  744. width: 100%;
  745. height: 100%;
  746. }
  747. }
  748. .play-btn {
  749. position: absolute;
  750. top: 50%;
  751. left: 50%;
  752. width: 136rpx;
  753. height: 136rpx;
  754. margin-top: -68rpx;
  755. margin-left: -68rpx;
  756. z-index: 10;
  757. .icon {
  758. width: 100%;
  759. height: 100%;
  760. }
  761. }
  762. }
  763. }
  764. .mirror-wrap {
  765. position: absolute;
  766. bottom: 0;
  767. left: 0;
  768. width: 100%;
  769. height: 32rpx;
  770. overflow: hidden;
  771. z-index: 1;
  772. .mirror-image {
  773. width: 100%;
  774. height: 750rpx;
  775. transform: scaleY(-1);
  776. filter: blur(2rpx);
  777. }
  778. }
  779. .indicators {
  780. position: absolute;
  781. bottom: 60rpx;
  782. width: 100%;
  783. display: flex;
  784. padding: 0 20rpx;
  785. box-sizing: border-box;
  786. z-index: 10;
  787. &.pos-left {
  788. justify-content: flex-start;
  789. }
  790. &.pos-center {
  791. justify-content: center;
  792. }
  793. &.pos-right {
  794. justify-content: flex-end;
  795. }
  796. .indicator-line {
  797. display: flex;
  798. align-items: center;
  799. width: 100%;
  800. .line-item {
  801. width: 20%;
  802. height: 4rpx;
  803. margin: 0 6rpx;
  804. border-radius: 4rpx;
  805. opacity: 0.5;
  806. &.active {
  807. opacity: 1;
  808. }
  809. }
  810. }
  811. .indicator-dot {
  812. display: flex;
  813. align-items: center;
  814. .dot-item {
  815. width: 12rpx;
  816. height: 12rpx;
  817. border-radius: 50%;
  818. margin: 0 6rpx;
  819. transition: all 0.3s;
  820. opacity: 0.5;
  821. &.active {
  822. width: 24rpx;
  823. border-radius: 6rpx;
  824. opacity: 1;
  825. }
  826. }
  827. }
  828. .indicator-number {
  829. .num-box {
  830. background: rgba(0, 0, 0, 0.3);
  831. color: #fff;
  832. font-size: 24rpx;
  833. padding: 4rpx 16rpx;
  834. border-radius: 20rpx;
  835. .current {
  836. font-size: 28rpx;
  837. }
  838. }
  839. }
  840. }
  841. .spec-style-4 {
  842. position: absolute;
  843. bottom: 10rpx;
  844. width: 100%;
  845. background: rgba(153, 153, 153, 0.6);
  846. padding: 20rpx 0 30rpx 20rpx;
  847. box-sizing: border-box;
  848. z-index: 10;
  849. .spec-list {
  850. white-space: nowrap;
  851. width: 100%;
  852. display: flex;
  853. align-items: center;
  854. .spec-item {
  855. display: inline-flex;
  856. align-items: center;
  857. margin-right: 20rpx;
  858. border: 2rpx solid transparent;
  859. border-radius: 16rpx;
  860. padding: 4rpx;
  861. background: #777777;
  862. image {
  863. width: 80rpx;
  864. height: 80rpx;
  865. border-radius: 8rpx;
  866. margin-right: 16rpx;
  867. }
  868. .spec-info {
  869. padding-right: 10rpx;
  870. }
  871. .name {
  872. font-size: 24rpx;
  873. color: #fff;
  874. max-width: 120rpx;
  875. }
  876. }
  877. .total-count {
  878. display: inline-flex;
  879. justify-content: center;
  880. align-items: center;
  881. font-size: 20rpx;
  882. margin-left: 10rpx;
  883. vertical-align: top;
  884. height: 88rpx;
  885. color: #fff;
  886. background: #777777;
  887. position: sticky;
  888. right: 0;
  889. z-index: 10;
  890. padding: 0 20rpx;
  891. border-radius: 8rpx 0 0 8rpx;
  892. .iconfont {
  893. font-size: 20rpx;
  894. }
  895. }
  896. }
  897. }
  898. }
  899. .info-box {
  900. position: relative;
  901. padding: 32rpx 32rpx 8rpx 32rpx;
  902. border-radius: 32rpx 32rpx 0 0;
  903. background: #fff;
  904. margin-top: -32rpx;
  905. z-index: 11;
  906. .spec-top-section {
  907. margin-bottom: 30rpx;
  908. position: relative;
  909. .spec-list {
  910. white-space: nowrap;
  911. width: 100%;
  912. .spec-item {
  913. display: inline-block;
  914. margin-right: 16rpx;
  915. image {
  916. width: 80rpx;
  917. height: 80rpx;
  918. border-radius: 8rpx;
  919. border: 2rpx solid #eee;
  920. }
  921. }
  922. }
  923. .total-count {
  924. position: absolute;
  925. right: 0;
  926. top: 0;
  927. display: inline-flex;
  928. justify-content: center;
  929. align-items: center;
  930. font-size: 20rpx;
  931. vertical-align: top;
  932. height: 80rpx;
  933. margin-left: 10rpx;
  934. position: absolute;
  935. right: 0;
  936. background-color: #fff;
  937. z-index: 10;
  938. padding-left: 10rpx;
  939. .iconfont {
  940. font-size: 20rpx;
  941. }
  942. }
  943. .spec-list-text-wrapper {
  944. position: relative;
  945. .spec-list-text {
  946. white-space: nowrap;
  947. width: 100%;
  948. .spec-item {
  949. display: inline-flex;
  950. align-items: center;
  951. padding: 8rpx 16rpx;
  952. border-radius: 12rpx;
  953. margin-right: 16rpx;
  954. background: #f5f5f5;
  955. border: 2rpx solid transparent;
  956. image {
  957. width: 40rpx;
  958. height: 40rpx;
  959. border-radius: 50%;
  960. margin-right: 8rpx;
  961. }
  962. .name {
  963. font-size: 24rpx;
  964. color: #333;
  965. }
  966. }
  967. .spacer {
  968. display: inline-block;
  969. width: 100rpx;
  970. height: 1rpx;
  971. }
  972. }
  973. .total-count {
  974. display: flex;
  975. align-items: center;
  976. justify-content: center;
  977. font-size: 24rpx;
  978. position: absolute;
  979. right: 0;
  980. top: 0;
  981. bottom: 0;
  982. min-width: 100rpx;
  983. height: 60rpx;
  984. background-color: #fff;
  985. z-index: 10;
  986. padding-left: 10rpx;
  987. box-shadow: -10rpx 0 10rpx -5rpx rgba(0, 0, 0, 0.05);
  988. .iconfont {
  989. font-size: 20rpx;
  990. }
  991. }
  992. }
  993. }
  994. .info-item {
  995. margin-bottom: 16rpx;
  996. .price-section {
  997. .price-row {
  998. display: flex;
  999. align-items: flex-end;
  1000. .main-price-wrap {
  1001. display: flex;
  1002. align-items: baseline;
  1003. margin-right: 20rpx;
  1004. font-weight: bold;
  1005. .label {
  1006. font-size: 24rpx;
  1007. margin-right: 4rpx;
  1008. }
  1009. .symbol {
  1010. font-size: 28rpx;
  1011. line-height: 28rpx;
  1012. }
  1013. }
  1014. .ot-price-wrap {
  1015. text-decoration: line-through;
  1016. font-size: 24rpx;
  1017. color: #999;
  1018. margin-right: 20rpx;
  1019. }
  1020. .vip-price-wrap {
  1021. display: flex;
  1022. align-items: center;
  1023. background: #333;
  1024. color: #ffd700;
  1025. border-radius: 8rpx;
  1026. padding: 2rpx 8rpx;
  1027. font-size: 20rpx;
  1028. .badge {
  1029. margin-right: 4rpx;
  1030. }
  1031. }
  1032. }
  1033. }
  1034. .name-section {
  1035. display: flex;
  1036. justify-content: space-between;
  1037. align-items: flex-start;
  1038. margin-top: 20rpx;
  1039. .title {
  1040. flex: 1;
  1041. font-size: 32rpx;
  1042. font-weight: bold;
  1043. color: #333;
  1044. line-height: 1.4;
  1045. }
  1046. .share {
  1047. display: flex;
  1048. flex-direction: column;
  1049. align-items: center;
  1050. margin-left: 20rpx;
  1051. color: #666;
  1052. font-size: 20rpx;
  1053. .iconfont {
  1054. font-size: 36rpx;
  1055. margin-bottom: 4rpx;
  1056. }
  1057. }
  1058. }
  1059. .data-section {
  1060. display: flex;
  1061. justify-content: space-between;
  1062. font-size: 24rpx;
  1063. color: #999;
  1064. margin-top: 20rpx;
  1065. }
  1066. .tags-section {
  1067. display: flex;
  1068. flex-wrap: wrap;
  1069. margin-top: 20rpx;
  1070. }
  1071. }
  1072. .spec-bottom-section {
  1073. margin-top: 30rpx;
  1074. .spec-list-wrapper {
  1075. position: relative;
  1076. }
  1077. .spec-list {
  1078. white-space: nowrap;
  1079. width: 100%;
  1080. .spec-item {
  1081. display: inline-block;
  1082. margin-right: 16rpx;
  1083. text-align: center;
  1084. border: 2rpx solid transparent;
  1085. border-radius: 8rpx;
  1086. overflow: hidden;
  1087. image {
  1088. width: 116rpx;
  1089. height: 116rpx;
  1090. border-radius: 8rpx;
  1091. }
  1092. .name {
  1093. font-size: 24rpx;
  1094. color: #333;
  1095. background: #f5f5f5;
  1096. padding: 6rpx 14rpx;
  1097. font-size: 22rpx;
  1098. max-width: 116rpx;
  1099. }
  1100. }
  1101. .spacer {
  1102. display: inline-block;
  1103. width: 80rpx;
  1104. height: 1rpx;
  1105. }
  1106. }
  1107. .total-count {
  1108. display: flex;
  1109. justify-content: center;
  1110. align-items: center;
  1111. font-size: 20rpx;
  1112. position: absolute;
  1113. right: 0;
  1114. top: 0;
  1115. bottom: 0;
  1116. width: 80rpx;
  1117. background-color: #fff;
  1118. z-index: 10;
  1119. padding-left: 10rpx;
  1120. .iconfont {
  1121. font-size: 20rpx;
  1122. }
  1123. }
  1124. }
  1125. }
  1126. }
  1127. .line1 {
  1128. overflow: hidden;
  1129. text-overflow: ellipsis;
  1130. white-space: nowrap;
  1131. }
  1132. </style>