product-details.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974
  1. <!-- 商品详情 -->
  2. <template>
  3. <view class="wrap">
  4. <HeaderViewBar ref='HeaderViewBar' title='商品详情' :titleOpacity="scrollTop / 100" :opacity="scrollTop / 100"
  5. :hideBack="true" backgroundColor='linear-gradient(180deg, #E63D23, #F58711)'
  6. style="position: fixed; top: 0; z-index: 999999999;">
  7. <view class="header-btn-box" :style="{width: headerContainerWidth + 'px', paddingRight: 36}">
  8. <button type="default" class="back" @tap="back()">
  9. <image src="../../../static/return-2.png" mode="widthFix"></image>
  10. </button>
  11. <view class="header-right-box">
  12. <button type="default">
  13. <image src="../../../static/circle-1.png" mode="widthFix"></image>
  14. </button>
  15. <button type="default">
  16. <image src="../../../static/circle-2.png" mode="widthFix"></image>
  17. </button>
  18. </view>
  19. </view>
  20. </HeaderViewBar>
  21. <view class="swiper-box">
  22. <swiper class="swiper" @change="swiperChange" :circular="true" autoplay="true" interval="3000"
  23. duration="500">
  24. <!-- <swiper-item v-for="(item,index) in swiperList" :key="index">
  25. <view class="swiper-item">
  26. <image :src="item" class="banner-img" mode="aspectFill" />
  27. </view>
  28. </swiper-item> -->
  29. <swiper-item>
  30. <view class="swiper-item">
  31. <image :src="info.cover" class="banner-img" mode="aspectFill" />
  32. </view>
  33. </swiper-item>
  34. </swiper>
  35. <view class="diandian">
  36. <!-- <view class="diandiandian" :class="(swiperCurrent == index ? 'diandiandian_active' : '')"
  37. v-for="(item, index) in swiperList">
  38. </view> -->
  39. </view>
  40. </view>
  41. <view class="spike-module-box">
  42. <image src="../../../static/bg-17.png" class="spike-bg" mode=""></image>
  43. <view class="spike-module-content">
  44. <view class="spike-module-content-left">
  45. 秒杀价:
  46. <view class="spike-price">
  47. ¥39.00
  48. </view>
  49. <text class="del-price-white">¥56.00</text>
  50. </view>
  51. <view class="spike-module-content-right">
  52. <view class="spike-module-content-right-label">距秒杀截止时间</view>
  53. <view class="bottom-label">
  54. <text class="bottom-label-text">14天</text>
  55. <u-count-down :time="30 * 60 * 60 * 1000" format="HH:mm:ss" autoStart millisecond
  56. @change="onChange">
  57. <view class="time">
  58. <view class="time__custom">
  59. <text
  60. class="time__custom__item">{{ timeData.hours>10?timeData.hours:'0'+timeData.hours}}</text>
  61. </view>
  62. <text class="time__doc">:</text>
  63. <view class="time__custom">
  64. <text class="time__custom__item">{{ timeData.minutes }}</text>
  65. </view>
  66. <text class="time__doc">:</text>
  67. <view class="time__custom">
  68. <text class="time__custom__item">{{ timeData.seconds }}</text>
  69. </view>
  70. </view>
  71. </u-count-down>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="padding-box">
  77. <view class="module">
  78. <view class="price-row">
  79. ¥394.00 <text class="del-price">¥34.00</text>
  80. </view>
  81. <view class="product-name">
  82. {{info.name}}
  83. </view>
  84. <view class="row-between">
  85. <view class="tag">
  86. 1罐50g
  87. </view>
  88. <view class="box">
  89. <image src="../../../static/bg-8.png" class="bg" mode="aspectFill" />
  90. <view class="fan">
  91. </view>
  92. <view class="fan-prirce">
  93. ¥<text>8.00</text>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="type-list">
  98. <view class="type-item">
  99. 菊花决明子茶
  100. </view>
  101. <view class="type-item pink-border">
  102. 藕粉桂花坚果羹
  103. </view>
  104. <view class="type-item">
  105. 黑芝麻羹
  106. </view>
  107. </view>
  108. </view>
  109. <view class="module">
  110. <view class="module-row">
  111. <view class="module-label">
  112. 产品功效
  113. </view>
  114. <view class="module-right-row">
  115. <text class="child">强身益智</text>
  116. <text class="child">健胃润肠</text>
  117. <button type="default" class="module-btn">健胃润肠</button>
  118. </view>
  119. </view>
  120. <view class="module-row">
  121. <view class="module-label">
  122. 适合人群
  123. </view>
  124. <view class="module-right-row">
  125. <text class="child">亚健康</text>
  126. <text class="child">心血管患者</text>
  127. <text class="child">糖尿病患者</text>
  128. <text class="child">体弱多病</text>
  129. <text class="child">消化不良</text>
  130. <text class="child">心血管患者</text>
  131. <text class="child">糖尿病患者</text>
  132. <text class="child">体弱多病</text>
  133. </view>
  134. </view>
  135. <view class="module-row">
  136. <view class="module-label">
  137. 有效搭配
  138. </view>
  139. <view class="module-right-row-between">
  140. <view class="module-right-row-tab">
  141. <view class="tab-child">
  142. 乌鸡
  143. </view>
  144. <view class="tab-child">
  145. 木耳
  146. </view>
  147. <view class="tab-child">
  148. 枸杞
  149. </view>
  150. </view>
  151. <image src="../../../static/back-icon2.png" mode="widthFix" class="back-icon"></image>
  152. </view>
  153. </view>
  154. </view>
  155. <view class="module">
  156. <view class="module-row" v-for="(item, index) in info.goods_param || []">
  157. <view class="module-label">
  158. {{item.title}}
  159. </view>
  160. <view class="module-right-row">
  161. <view class="msg">
  162. {{item.value}}
  163. </view>
  164. </view>
  165. </view>
  166. <!-- <view class="module-row">
  167. <view class="module-label">
  168. 配送
  169. </view>
  170. <view class="module-right-row">
  171. <view class="msg">
  172. 嘉兴南湖区旭辉广场2号楼
  173. </view>
  174. </view>
  175. </view> -->
  176. <view class="module-row">
  177. <view class="module-label">
  178. 发货
  179. </view>
  180. <view class="module-right-row">
  181. <view class="msg">
  182. 北京携手熊猫总部
  183. </view>
  184. <text class="express-shipping">快递:{{info.postage > 0 ? info.postage + '元' : '免运费'}}</text>
  185. </view>
  186. </view>
  187. <!-- <view class="module-row">
  188. <view class="module-label">
  189. 源头
  190. </view>
  191. <view class="module-right-row">
  192. <view class="msg">
  193. 宁夏中宁县
  194. </view>
  195. <button class="border-orange">产品可溯源</button>
  196. </view>
  197. </view>
  198. <view class="module-row">
  199. <view class="module-label">
  200. 时令
  201. </view>
  202. <view class="module-right-row">
  203. <view class="msg">
  204. 6月/7月/8月
  205. </view>
  206. </view>
  207. </view> -->
  208. <view class="module-row">
  209. <view class="module-label">
  210. 时令
  211. </view>
  212. <view class="module-right-row-between">
  213. <view class="module-right-row-tab">
  214. <text class="assure">产品可溯源</text>
  215. <text class="assure">七天无理由退换</text>
  216. </view>
  217. <image src="../../../static/back-icon2.png" mode="widthFix" class="back-icon"></image>
  218. </view>
  219. </view>
  220. <view class="module-row">
  221. <view class="module-label">
  222. 参数
  223. </view>
  224. <view class="module-right-row-between">
  225. <view class="module-right-row-tab">
  226. <text class="assure">生产日期</text>
  227. <text class="assure">产地</text>
  228. <text class="assure">净含量…</text>
  229. </view>
  230. </view>
  231. </view>
  232. </view>
  233. <view class="comment-module">
  234. <view class="comment-module-label">
  235. 商品评价(600)
  236. </view>
  237. <view class="comment-box">
  238. <view class="comment-tab-list">
  239. <view class="comment-tab-item">
  240. 口味鲜美多汁
  241. </view>
  242. <view class="comment-tab-item">
  243. 很好吃
  244. </view>
  245. <view class="comment-tab-item">
  246. 还会再买
  247. </view>
  248. </view>
  249. <view class="comment-list">
  250. <!-- <view class="comment-item" v-for="(item, index) in 3">
  251. <view class="comment-item-top">
  252. <image src="../../../static/avatar.png" class="avatar" mode="aspectFill"></image>
  253. <view class="comment-item-top-sidebar">
  254. <view class="comment-item-top-column">
  255. <view class="user-name">
  256. 乔治的晚餐
  257. </view>
  258. <view class="stars-wrapper">
  259. <block v-for="(val, index) in 5">
  260. <image class="star-img"
  261. :src="star > index ? '../../../static/star-active.png' : '../../../static/star.png'"
  262. mode="aspectFill"></image>
  263. </block>
  264. </view>
  265. </view>
  266. <text class="time">2020-9-15</text>
  267. </view>
  268. </view>
  269. <view class="comment-item-content">
  270. 香肠精选不同部位的猪肉,按照一定的肥瘦比列进行搭。香肠精选不同部位的猪肉,按照一定的肥瘦比列进行搭。
  271. </view>
  272. </view> -->
  273. <view class="comment-item" v-for="(item, index) in commentList" :key="index">
  274. <view class="comment-item-top">
  275. <image src="../../../static/avatar.png" class="avatar" mode="aspectFill"></image>
  276. <view class="comment-item-top-sidebar">
  277. <view class="comment-item-top-column">
  278. <view class="user-name">
  279. 乔治的晚餐
  280. </view>
  281. <view class="stars-wrapper">
  282. <block v-for="(val, index) in 5">
  283. <image class="star-img"
  284. :src="star > index ? '../../../static/star-active.png' : '../../../static/star.png'"
  285. mode="aspectFill"></image>
  286. </block>
  287. </view>
  288. </view>
  289. <text class="time">2020-9-15</text>
  290. </view>
  291. </view>
  292. <view class="comment-item-content">
  293. 香肠精选不同部位的猪肉,按照一定的肥瘦比列进行搭。香肠精选不同部位的猪肉,按照一定的肥瘦比列进行搭。
  294. </view>
  295. </view>
  296. </view>
  297. <view class="buyers-show-module">
  298. <view class="buyers-show-label">
  299. 买家秀(14)
  300. </view>
  301. <scroll-view scroll-x="true" class="buyers-show-list">
  302. <image src="../../../static/img-4.png" class="buyers-show-img" v-for="(item, index) in 7"
  303. mode="aspectFill"></image>
  304. </scroll-view>
  305. </view>
  306. </view>
  307. </view>
  308. <view class="details-module">
  309. <view class="details-module-label">
  310. 商品详情
  311. </view>
  312. <view class="details-box">
  313. <image src="../../../static/img-4.png" mode="widthFix" class="img"></image>
  314. </view>
  315. </view>
  316. </view>
  317. <view class="footer">
  318. <view class="footer-leftsidebar">
  319. <button type="default" @tap="shoppingCart">
  320. <image src="../../../static/foot-tab2.png" mode="heightFix"></image>
  321. 购物车
  322. <view class="num">
  323. 99
  324. </view>
  325. </button>
  326. <button type="default">
  327. <image src="../../../static/foot-tab1.png" mode="heightFix"></image>
  328. 客服
  329. </button>
  330. <!-- @tap="userCollect(info.id)" -->
  331. <button type="default" @tap="userCollect(info.id, info.first_classify)">
  332. <image :src="select ? '../../../static/foot-tab3active.png' : '../../../static/foot-tab3.png'"
  333. mode="heightFix"></image>
  334. {{select ? '已收藏' : '收藏'}}
  335. </button>
  336. </view>
  337. <view class="footer-rightsidebar">
  338. <button type="default" class="footer-rightsidebar-btn" @tap="showPreSaleSelectSpecification('addCart')">
  339. <image src="../../../static/btn-bg1.png" mode=""></image>
  340. <view class="footer-rightsidebar-btn-container">
  341. 加入购物车
  342. </view>
  343. </button>
  344. <button type="default" class="footer-rightsidebar-btn2" @tap="showPreSaleSelectSpecification('buy')">
  345. <image src="../../../static/btn-bg2.png" mode=""></image>
  346. <view class="footer-rightsidebar-btn-container2">
  347. 立即购买
  348. </view>
  349. </button>
  350. </view>
  351. </view>
  352. <!-- 保障-弹窗 -->
  353. <view v-show="isShowAssure">
  354. <view class="mask" @tap="closeAssure"></view>
  355. <view class="window-box">
  356. <view class="window-title">保障</view>
  357. <view class="window-top">
  358. <view class="window-row">
  359. <view class="window-label">产品可溯源</view>
  360. </view>
  361. <view class="window-row">
  362. <view class="window-label">七天无理由退换</view>
  363. <view class="window-msg">满足相应条件(吊牌缺失、洗涤后不支持)时,消费者可以申请“七天无理由退换货”</view>
  364. </view>
  365. </view>
  366. <view class="window-bottom">
  367. <button type="default">确定</button>
  368. </view>
  369. </view>
  370. </view>
  371. <!-- 保障-弹窗 -->
  372. <!-- 选择规格-弹窗 -->
  373. <view v-show="isShowSelectSpecification">
  374. <view class="mask" @tap="closeSelectSpecification"></view>
  375. <view class="selectSpecification-box">
  376. <view class="product-module">
  377. <image src="../../../static/img-4.png" class="product-img" mode="aspectFill"></image>
  378. <view class="product-module-sidebar">
  379. <view class="price-row">
  380. ¥394.00
  381. <text class="del-price">¥34.00</text>
  382. </view>
  383. <view class="product-module-title">藕粉桂花坚果藕粉羹营养早代餐 坚果羹营养早餐懒人冲饮食品</view>
  384. </view>
  385. </view>
  386. <view class="delivery-address-box">
  387. <view class="delivery-address-label">配送地址</view>
  388. <view class="location-row">
  389. <image src="../../../static/location-1.png" class="location-icon" mode=""></image>
  390. <view class="row-location-between">
  391. <text class="location-msg">山东省 临沂市 兰山区 柳青街道 </text>
  392. <image src="../../../static/back-icon2.png" class="back-icon" mode="widthFix"></image>
  393. </view>
  394. </view>
  395. </view>
  396. <view class="taste-row">
  397. <view class="taste-label">
  398. 口味
  399. </view>
  400. <view v-for="(item, index) in list" :key="index">
  401. <view :class="'type ' + [id == index ? 'active' : '']" @click="choseItem(index)">
  402. {{ item.name }}
  403. </view>
  404. </view>
  405. </view>
  406. <view class="number-box-between">
  407. <view class="number-label">购买数量<text>(限购10件)库存1899件</text></view>
  408. <view class="calc_box">
  409. <view class="calc_btn">
  410. <image src="../../../static/less.png" mode="widthFix" />
  411. </view>
  412. <input type="number" value="1" class="calc_number" />
  413. <view class="calc_btn">
  414. <image src="../../../static/add.png" mode="widthFix" />
  415. </view>
  416. </view>
  417. </view>
  418. <view class="window-bottom">
  419. <button type="default">确定</button>
  420. </view>
  421. </view>
  422. </view>
  423. <!-- 选择规格-弹窗 -->
  424. <!-- 限源预售-参数-弹窗 -->
  425. <view v-show="isShowParameter">
  426. <view class="mask" @tap="closeParameter"></view>
  427. <view class="window-box">
  428. <view class="window-title">参数</view>
  429. <view class="window-top">
  430. <view class="parameter-row">
  431. <view class="parameter-row-label">品牌</view>
  432. <view class="parameter-row-msg">程老伯</view>
  433. </view>
  434. <view class="parameter-row">
  435. <view class="parameter-row-label">价格</view>
  436. <view class="parameter-row-msg">0-50元</view>
  437. </view>
  438. <view class="parameter-row">
  439. <view class="parameter-row-label">产地</view>
  440. <view class="parameter-row-msg">中国大陆</view>
  441. </view>
  442. <view class="parameter-row">
  443. <view class="parameter-row-label">省份</view>
  444. <view class="parameter-row-msg">山东省</view>
  445. </view>
  446. <view class="parameter-row">
  447. <view class="parameter-row-label">同城服务</view>
  448. <view class="parameter-row-msg">同城24小时物流送货上门</view>
  449. </view>
  450. <view class="parameter-row">
  451. <view class="parameter-row-label">包装方式</view>
  452. <view class="parameter-row-msg">包装</view>
  453. </view>
  454. <view class="parameter-row">
  455. <view class="parameter-row-label">售卖方式</view>
  456. <view class="parameter-row-msg">单品</view>
  457. </view>
  458. <view class="parameter-row">
  459. <view class="parameter-row-label">套餐份量</view>
  460. <view class="parameter-row-msg">5人份</view>
  461. </view>
  462. <view class="parameter-row">
  463. <view class="parameter-row-label">套餐周期</view>
  464. <view class="parameter-row-msg">1周</view>
  465. </view>
  466. <view class="parameter-row">
  467. <view class="parameter-row-label">配送频次</view>
  468. <view class="parameter-row-msg">1周2次</view>
  469. </view>
  470. <view class="parameter-row">
  471. <view class="parameter-row-label">净含量</view>
  472. <view class="parameter-row-msg">500g 1500g 2500g</view>
  473. </view>
  474. <view class="parameter-row">
  475. <view class="parameter-row-label">厂址</view>
  476. <view class="parameter-row-msg">山东烟台</view>
  477. </view>
  478. <view class="parameter-row">
  479. <view class="parameter-row-label">厂家联系方式</view>
  480. <view class="parameter-row-msg">05358585333</view>
  481. </view>
  482. <view class="parameter-row">
  483. <view class="parameter-row-label">厂名</view>
  484. <view class="parameter-row-msg">程老伯旗舰店</view>
  485. </view>
  486. <view class="parameter-row">
  487. <view class="parameter-row-label">保质期</view>
  488. <view class="parameter-row-msg">7</view>
  489. </view>
  490. </view>
  491. <view class="window-bottom">
  492. <button type="default">确定</button>
  493. </view>
  494. </view>
  495. </view>
  496. <!-- 限源预售-参数-弹窗 -->
  497. <!-- 限源预售-选择规格-弹窗 -->
  498. <view v-show="isShowPreSaleSelectSpecification">
  499. <view class="mask" @tap="closePreSaleSelectSpecification"></view>
  500. <view class="selectSpecification-box">
  501. <view class="product-module">
  502. <image :src="itemSelect.cover || info.cover" class="product-img" mode="aspectFill"></image>
  503. <view class="product-module-sidebar">
  504. <view class="price-row">
  505. ¥{{itemSelect.sell_price}}
  506. <text class="del-price">¥{{itemSelect.original_price}}</text>
  507. </view>
  508. <view class="product-module-title">{{itemSelect.goods_title || info.name}}</view>
  509. </view>
  510. </view>
  511. <view class="delivery-address-box">
  512. <view class="delivery-address-label">配送地址</view>
  513. <view class="location-row">
  514. <image src="../../../static/location-1.png" class="location-icon" mode=""></image>
  515. <view class="row-location-between">
  516. <text class="location-msg">山东省 临沂市 兰山区 柳青街道 </text>
  517. <image src="../../../static/back-icon2.png" class="back-icon" mode="widthFix"></image>
  518. </view>
  519. </view>
  520. </view>
  521. <view class="taste-row" v-for="(item, index) in itemList.list">
  522. <view class="taste-label">
  523. {{item[0]}}
  524. </view>
  525. <view class="specification-list">
  526. <view v-for="(item2, index2) in item[1]" :key="index2">
  527. <view :class="'type2 ' + [itemListSelect[item[0]] == item2 ? 'active' : '']" @click="chooseItem(item[0], item2)">
  528. {{ item2 }}
  529. </view>
  530. </view>
  531. </view>
  532. </view>
  533. <view class="number-box-between">
  534. <view class="number-label">
  535. 购买数量
  536. <text>
  537. <!-- (限购10件) -->
  538. 库存{{itemSelect.stock}}件
  539. </text>
  540. </view>
  541. <view class="calc_box">
  542. <view class="calc_btn">
  543. <image src="../../../static/less.png" mode="widthFix" />
  544. </view>
  545. <input type="number" value="1" class="calc_number" />
  546. <view class="calc_btn">
  547. <image src="../../../static/add.png" mode="widthFix" />
  548. </view>
  549. </view>
  550. </view>
  551. <view class="window-bottom">
  552. <button type="default" @tap="addCartOrBuy()">确定</button>
  553. </view>
  554. </view>
  555. </view>
  556. <!-- 限源预售-选择规格-弹窗 -->
  557. </view>
  558. </template>
  559. <script>
  560. import {
  561. expediteGetGoodsDetail,
  562. expediteGetGoodsComment,
  563. collectUserCollect,
  564. trolleyGetTrolleyByGoodsId,
  565. trolleyAddTrolley,
  566. } from '../../../common/service.js';
  567. import HeaderViewBar from '../../../components/header-view-bar/header-view-bar.vue';
  568. import popupMessage from '../../../components/addSuccess.vue';
  569. export default {
  570. components: {
  571. HeaderViewBar,
  572. popupMessage
  573. },
  574. data() {
  575. return {
  576. headerHeight: 0,
  577. headerContainerWidth: 0,
  578. scrollTop: 0,
  579. //轮播
  580. swiperList: [
  581. '../../../static/img-4.png',
  582. '../../../static/img-4.png',
  583. '../../../static/img-4.png'
  584. ],
  585. swiperCurrent: 0,
  586. star: 3, //评价,默认3星
  587. select: false, //收藏
  588. isShowAssure: false, //保障弹窗
  589. isShowSelectSpecification: false, //选择规格-弹窗
  590. //口味-单选
  591. list: [{
  592. name: '桂花坚果藕粉羹【实发1罐500g】'
  593. },
  594. {
  595. name: '坚果水果藕粉羹【实发1罐500g】'
  596. },
  597. {
  598. name: '桂花坚果藕粉羹【拍1份发两罐 拍2份发5罐同款】'
  599. },
  600. {
  601. name: '坚果水果藕粉羹【拍1份发两罐 拍2份发5罐同款】'
  602. },
  603. {
  604. name: '坚果水果+桂花坚果[(拍1份发2罐)(拍2份发5罐,2罐坚果水果+3罐…'
  605. }
  606. ],
  607. id: '0', //单选 初始化第一个高亮
  608. isShowParameter: false, //限源预售-参数-弹窗
  609. isShowPreSaleSelectSpecification: false, //限源预售-选择规格-弹窗
  610. list2: [{
  611. name: '小果55-60mm【个头偏小】'
  612. },
  613. {
  614. name: '中果55-60mm【实惠装】'
  615. },
  616. {
  617. name: '大果60-65mm【性价比】'
  618. },
  619. {
  620. name: '精选大果65mm+【超值人气爆款】'
  621. }
  622. ],
  623. selected: '3', //单选 初始化第一个高亮
  624. list3: [{
  625. name: '3斤'
  626. },
  627. {
  628. name: '5斤'
  629. },
  630. {
  631. name: '9斤'
  632. }
  633. ],
  634. choose: '2', //单选 初始化第一个高亮
  635. //倒计时
  636. timeData: {},
  637. info: {
  638. id: 0,
  639. },
  640. commentList: [],
  641. page: 1,
  642. page_num: 20,
  643. trolley: [],
  644. // 规格
  645. itemList: {
  646. itemMap: {},
  647. itemIdMap: {},
  648. list: [],
  649. },
  650. // 每个规格选中的
  651. itemListSelect: {},
  652. // 当前选择的规格
  653. itemSelect: {},
  654. // 规格选择类型 addCart 加购物车 buy 购买
  655. selectType: '',
  656. }
  657. },
  658. onLoad(option) {
  659. const id = parseInt(option.id || 0);
  660. if (id > 0) {
  661. this.info.id = id;
  662. this.getGoodsDetail();
  663. this.getGoodsComment();
  664. this.getTrolleyByGoodsId();
  665. }
  666. },
  667. onShow() {
  668. setTimeout(() => {
  669. this.headerHeight = this.$refs['HeaderViewBar'].getHeaderStyle().headerHeight;
  670. this.headerContainerWidth = this.$refs['HeaderViewBar'].getHeaderStyle().headerContainerWidth;
  671. }, 20);
  672. },
  673. methods: {
  674. addCartOrBuy() {
  675. const selectType = this.selectType;
  676. if (selectType == 'addCart') {
  677. this.addCart();
  678. } else if (selectType == 'buy') {
  679. this.buy();
  680. }
  681. },
  682. addCart() {
  683. const data = {
  684. goods_id: this.info.id, // 商品id
  685. spec_id: this.itemSelect.id, // 规格id
  686. }
  687. trolleyAddTrolley({
  688. data,
  689. success: ({code, msg, data}) => {
  690. if (code == 1) {
  691. this.getTrolleyByGoodsId();
  692. }
  693. console.log(msg);
  694. uni.showToast({
  695. icon: 'none',
  696. title: msg,
  697. });
  698. },
  699. });
  700. },
  701. buy() {
  702. },
  703. getTrolleyByGoodsId() {
  704. trolleyGetTrolleyByGoodsId({
  705. data: {
  706. goods_id: this.info.id
  707. },
  708. success: ({code, msg, data}) => {
  709. if (code == 1) {
  710. this.trolley = data.list;
  711. } else {
  712. uni.showToast({
  713. icon: 'none',
  714. title: msg,
  715. });
  716. }
  717. }
  718. });
  719. },
  720. userCollect(id, first_classify) {
  721. const params = {
  722. coll_type: 1, // 类型(1商品2资讯3视频)
  723. coll_id: id, // 收藏id
  724. cate_id: first_classify, // 收藏分类id(多个分类传顶级分类id)
  725. }
  726. collectUserCollect({
  727. data: params,
  728. success: ({code, msg, data}) => {
  729. if (code == 1) {
  730. console.log(data);
  731. }
  732. uni.showToast({
  733. icon: 'none',
  734. title: msg,
  735. });
  736. }
  737. });
  738. },
  739. getGoodsDetail() {
  740. expediteGetGoodsDetail({
  741. data: {
  742. goods_id: this.info.id,
  743. },
  744. success: ({code, msg, data}) => {
  745. if (code == 1) {
  746. const info = data.goods_info;
  747. const itemList = info.item_list.reduce((a, b, index) => {
  748. const item = b.goods_spec.split(';;').map(i => i.split('::'));
  749. let idKey = '';
  750. if (index == 0) {
  751. item.forEach(([key, val]) => {
  752. this.itemListSelect[key] = val;
  753. });
  754. this.itemSelect = b;
  755. }
  756. item.forEach(([key, val]) => {
  757. a.itemMap[key] = [...(new Set([...(a.itemMap[key] || []), val]))];
  758. idKey += val;
  759. });
  760. a.itemIdMap[idKey] = b;
  761. return a;
  762. }, {
  763. itemMap: {},
  764. itemIdMap: {},
  765. });
  766. itemList['list'] = Object.entries(itemList.itemMap);
  767. this.info = data.goods_info;
  768. this.itemList = itemList;
  769. } else {
  770. uni.showToast({
  771. icon: 'none',
  772. title: msg,
  773. });
  774. }
  775. }
  776. });
  777. },
  778. getGoodsComment() {
  779. const params = {
  780. page: this.page,
  781. page_num: this.page_num,
  782. goods_id: this.info.id,
  783. };
  784. expediteGetGoodsComment({
  785. data: params,
  786. success: ({code, msg, data}) => {
  787. if (code == 1) {
  788. this.commentList == data.list;
  789. } else {
  790. uni.showToast({
  791. icon: 'none',
  792. title: msg,
  793. });
  794. }
  795. }
  796. });
  797. },
  798. // 返回顶部
  799. toTop() {
  800. uni.pageScrollTo({
  801. scrollTop: 0,
  802. duration: 100,
  803. });
  804. },
  805. //返回上一页
  806. back() {
  807. uni.navigateBack({
  808. delta: 1,
  809. })
  810. },
  811. //轮播
  812. swiperChange(e) {
  813. const {
  814. current
  815. } = e.detail;
  816. this.swiperCurrent = current;
  817. },
  818. //加入购物车成功-弹窗
  819. addCartSuccess(){
  820. uni.showToast({
  821. title: '加入购物车成功',
  822. duration: 2000
  823. });
  824. },
  825. //收藏
  826. collect: function() {
  827. this.select = !this.select;
  828. },
  829. //保障-弹窗
  830. showAssure() {
  831. this.isShowAssure = true;
  832. },
  833. closeAssure() {
  834. this.isShowAssure = false;
  835. },
  836. //选择规格-弹窗
  837. showSelectSpecification() {
  838. this.isShowSelectSpecification = true;
  839. },
  840. closeSelectSpecification() {
  841. this.isShowSelectSpecification = false;
  842. },
  843. //口味-单选
  844. choseItem: function(index) {
  845. // console.log(index)
  846. this.id = index;
  847. },
  848. //限源预售-参数-弹窗
  849. showParameter() {
  850. this.isShowParameter = true;
  851. },
  852. closeParameter() {
  853. this.isShowParameter = false;
  854. },
  855. //限源预售-选择规格-弹窗
  856. showPreSaleSelectSpecification(type) {
  857. this.selectType = type;
  858. this.isShowPreSaleSelectSpecification = true;
  859. },
  860. closePreSaleSelectSpecification() {
  861. this.isShowPreSaleSelectSpecification = false;
  862. },
  863. //限源预售-规格-单选
  864. selectedItem: function(index) {
  865. // console.log(index)
  866. this.selected = index;
  867. },
  868. //限源预售-净含量-单选
  869. chooseItem(key, val) {
  870. this.itemListSelect[key] = val;
  871. const key2 = Object.values(this.itemListSelect).join('');
  872. this.itemSelect = this.itemList.itemIdMap[key2];
  873. },
  874. //倒计时
  875. onChange(e) {
  876. this.timeData = e
  877. },
  878. //跳转购物车
  879. shoppingCart(){
  880. uni.navigateTo({
  881. url:'../../shopping-cart/shopping-cart'
  882. })
  883. },
  884. },
  885. onPageScroll(e) {
  886. this.scrollTop = e.scrollTop;
  887. }
  888. }
  889. </script>
  890. <style scoped lang="scss">
  891. @import "./product-details.css";
  892. .time {
  893. @include flex;
  894. align-items: center;
  895. &__custom {
  896. margin-top: 4px;
  897. width: 19px;
  898. height: 20px;
  899. line-height: 20px;
  900. background-color: #FC4A04 !important;
  901. border-radius: 4px;
  902. /* #ifndef APP-NVUE */
  903. display: flex;
  904. /* #endif */
  905. justify-content: center;
  906. align-items: center;
  907. &__item {
  908. color: #fff !important;
  909. font-size: 24rpx !important;
  910. text-align: center;
  911. font-weight: bold;
  912. margin: 0 !important;
  913. }
  914. }
  915. &__doc {
  916. color: #F2501A !important;
  917. padding: 0 6rpx !important;
  918. font-size: 36rpx !important;
  919. margin: 0 !important;
  920. }
  921. }
  922. </style>