product.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  1. <template>
  2. <view class="container">
  3. <view class="carousel">
  4. <swiper indicator-dots :circular="true" duration="400">
  5. <swiper-item class="swiper-item" v-for="(item, index) in imgList" :key="index">
  6. <view class="image-wrapper"><image :src="item" class="loaded" mode="aspectFill"></image></view>
  7. </swiper-item>
  8. </swiper>
  9. </view>
  10. <view class="introduce-section seckill-box-title" v-if="goodsType == 1">
  11. <view class="title flex">
  12. <view class="title-box">
  13. <text class="price-tip">¥</text>
  14. <text class="price">{{ goodsObjact.price }}</text>
  15. <!-- <text class="m-price" v-if="goodsObjact.ot_price > goodsObjact.price">¥{{ goodsObjact.ot_price }}</text> -->
  16. <!-- <text class="coupon-tip">7折</text> -->
  17. </view>
  18. <view class="flex timeStop">
  19. <view>距离结束</view>
  20. <uni-countdown
  21. color="#ffffff"
  22. background-color="#D65B3F"
  23. splitor-color="#FFFFFF"
  24. :show-day="false"
  25. :hour="seckillObj.stopTimeH"
  26. :minute="seckillObj.stopTimeM"
  27. :second="seckillObj.stopTimeS"
  28. ></uni-countdown>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="introduce-section">
  33. <text class="title" v-if="goodsType == 1">{{ goodsObjact.title }}</text>
  34. <view class="price-box" v-if="goodsType == 0">
  35. <text class="price-tip">¥</text>
  36. <text class="price">{{ goodsObjact.price }}</text>
  37. <text class="m-price" v-if="goodsObjact.ot_price > goodsObjact.price">¥{{ goodsObjact.ot_price }}</text>
  38. <!-- <text class="coupon-tip">7折</text> -->
  39. </view>
  40. <text class="title" v-if="goodsType == 0">{{ goodsObjact.store_name }}</text>
  41. <view class="bot-row">
  42. <text>快递: {{ goodsObjact.postage }}</text>
  43. <text style="text-align: center;">销量: {{ goodsObjact.sales }}</text>
  44. <text style="text-align: right;">{{ storeObjact.address | address}}</text>
  45. </view>
  46. </view>
  47. <!-- 评价 -->
  48. <view class="eva-section" v-if="reply" @click="navTo('/pages/product/reply?id=' + goodsid)">
  49. <view class="e-header">
  50. <text class="tit">评价</text>
  51. <text>({{ details.replyCount }})</text>
  52. <text class="tip">好评率 {{ details.replyChance }}%</text>
  53. <text class="iconfont iconenter"></text>
  54. </view>
  55. <view class="eva-box">
  56. <image class="portrait" :src="reply.avatar" mode="aspectFill"></image>
  57. <view class="right">
  58. <text class="name">{{ reply.nickname }}</text>
  59. <text class="con">{{ reply.comment }}</text>
  60. <view class="con_box">
  61. <view class="con_image" v-for="item in reply.pics"><image :src="item"></image></view>
  62. </view>
  63. <view class="bot">
  64. <text class="attr"></text>
  65. <text class="time">{{ reply.add_time }}</text>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="eva-boxs" v-if="reply.merchant_reply_content">
  70. <view class="right">
  71. <text class="con">
  72. <text style="color: #FD5B23;margin-right: 8rpx;">商家回复 :</text>
  73. {{ reply.merchant_reply_content }}
  74. </text>
  75. <view class="bot">
  76. <text class="attr"></text>
  77. <text class="time">{{ reply.merchant_reply_time }}</text>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="c-list">
  83. <view class="c-row b-b" @click="toggleSpec">
  84. <text class="tit">购买数量</text>
  85. <view class="con">
  86. <text class="selected-text">{{ goodsNumber }}</text>
  87. </view>
  88. <text class="iconfont iconenter"></text>
  89. </view>
  90. <view class="c-row b-b" v-if="goodsType == 1">
  91. <text class="tit">限购数量</text>
  92. <view class="con">
  93. <text class="selected-text">{{ goodsObjact.num + goodsObjact.unit_name }}</text>
  94. </view>
  95. </view>
  96. <!-- <view class="c-row b-b">
  97. <text class="tit">优惠券</text>
  98. <text class="con t-r red">领取优惠券</text>
  99. <text class="iconfont iconenter"></text>
  100. </view> -->
  101. <view class="c-row b-b" v-if="goodsObjact.is_integral == 1 && goodsType == 0">
  102. <text class="tit">积分</text>
  103. <view class="bz-list con">
  104. <text>最高抵扣¥{{ moneyNum(goodsObjact.use_max_integral) == 0 ? moneyNum(goodsObjact.price) : moneyNum(goodsObjact.use_max_integral) }}</text>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="shop-box flex" v-if="goodsType == 0 && shopId > 0">
  109. <view class="flex">
  110. <image :src="shopInfo.logo" mode=" aspectFit" class="shop-img"></image>
  111. <text class="font-size-lg">{{ shopInfo.title }}</text>
  112. </view>
  113. <navigator :url="'/pages/shoping/index?merid=' + shopId"><view class="shop-button">进店逛逛</view></navigator>
  114. </view>
  115. <view class="detail-desc">
  116. <view class="d-header"><text>图文详情</text></view>
  117. <rich-text class="detail-centent" :nodes="goodsObjact.description"></rich-text>
  118. <view :class="{ contentBottomHeight: goodsType == 1 || goodsType == 2, goodsBottom: goodsType == 0 }"></view>
  119. </view>
  120. <!-- 底部操作菜单 -->
  121. <view class="page-bottom" v-if="goodsType == 0">
  122. <!-- <navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
  123. <text class="iconfont iconhome"></text>
  124. <text>首页</text>
  125. </navigator>
  126. <navigator url="/pages/cart/cart" open-type="switchTab" class="p-b-btn">
  127. <text class="iconfont iconcart"></text>
  128. <text>购物车</text>
  129. </navigator> -->
  130. <view class="p-b-btn" :class="{ active: goodsObjact.userCollect }" @click="toFavorite(goodsObjact)">
  131. <text class="iconfont " :class="{ iconlike: !goodsObjact.userCollect, iconlikefill: goodsObjact.userCollect }"></text>
  132. <text>收藏</text>
  133. </view>
  134. <view class="action-btn-group">
  135. <button type="primary" class=" action-btn no-border buy-now-btn" @click="toggleSpec(2)">加入购物车</button>
  136. <button type="primary" class=" action-btn no-border add-cart-btn" @click="toggleSpec(1)">立即购买</button>
  137. </view>
  138. </view>
  139. <!-- 秒杀商品购买 -->
  140. <view class="goods-pay-box flex" :class="{ stop: seckillObj.stop }" v-if="goodsType == 1">
  141. <view class="goods-pay bgLine" v-if="!seckillObj.stop" @click="toggleSpec(1)"><text>立即购买</text></view>
  142. <view class="goods-pay-stop" v-else>活动已结束</view>
  143. </view>
  144. <!-- 拼团商品购买 -->
  145. <view class="goods-pay-box flex" v-if="goodsType == 2">
  146. <view class="goods-pay bg-warning" @click="navToProductGoods">
  147. <view class="goods-buttom-money">¥{{ goodsObjact.product_price }}</view>
  148. <view class="goods-buttom">单独购买</view>
  149. </view>
  150. <view class="goods-pay bg-danger" @click="toggleSpec(1)">
  151. <view class="goods-buttom-money">¥{{ goodsObjact.price }}</view>
  152. <view class="goods-buttom">我要拼团</view>
  153. </view>
  154. </view>
  155. <!-- 规格-模态层弹窗 -->
  156. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="stopPrevent" @click="toggleSpec">
  157. <!-- 遮罩层 -->
  158. <view class="mask"></view>
  159. <view class="layer attr-content" @click.stop="stopPrevent">
  160. <view class="a-t">
  161. <image :src="actionImage"></image>
  162. <view class="right">
  163. <view class="good-name clamp">{{goodsObjact.store_name}}</view>
  164. <text class="price">¥{{ actionPrice }}</text>
  165. <!-- <text class="stock">库存:{{ goodsObjact.stock }}件</text> -->
  166. <!-- <view class="selected" v-if="goodsType == 0">
  167. 已选:
  168. <text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">{{ sItem }}</text>
  169. </view> -->
  170. </view>
  171. </view>
  172. <view v-for="(item, index) in specList" :key="index" class="attr-list">
  173. <text>{{ item.attr_name }}</text>
  174. <view class="item-list">
  175. <text
  176. v-for="(childItem, childIndex) in item.attr_value"
  177. :key="childIndex"
  178. class="tit"
  179. :class="{ selected: childItem.check }"
  180. @click="selectSpec(childItem, item, index)"
  181. >
  182. {{ childItem.attr }}
  183. </text>
  184. </view>
  185. </view>
  186. <view class="attr-list">
  187. <text>购买数量</text>
  188. <view class="item-list">
  189. <uni-number-box class="step" :isMin="true" :value="goodsNumber" :min="1" :max="goodsNumberMax" @eventChange="numberChange"></uni-number-box>
  190. </view>
  191. </view>
  192. <button class="btn" @click.stop="buy">完成</button>
  193. </view>
  194. </view>
  195. <view :class="{ seckillBottom: goodsType == 1, goodsBottom: goodsType == 0 }"></view>
  196. <!-- 分享 -->
  197. <!-- <share ref="share" :contentHeight="580" :shareList="shareList"></share> -->
  198. </view>
  199. </template>
  200. <script>
  201. import share from '@/components/share';
  202. import uniNumberBox from '@/components/uni-number-box.vue';
  203. import uniCountdown from '@/components/uni-countdown/uni-countdown.vue';
  204. import { goodsDetail, cartAdd, collectAdd, collectDel, seckillGoods, groupGoods } from '@/api/product.js';
  205. import { getShoping } from '@/api/shoping.js';
  206. // #ifdef H5
  207. import { weixindata } from '@/utils/wxAuthorized';
  208. import { mapState } from 'vuex';
  209. // #endif
  210. export default {
  211. components: {
  212. share,
  213. uniNumberBox,
  214. uniCountdown
  215. },
  216. filters: {
  217. address(val) {
  218. let str = ''
  219. if(val) {
  220. str = val[0] + ' ' + val[1]
  221. }
  222. return str
  223. }
  224. },
  225. data() {
  226. return {
  227. details: '',
  228. reply: '', //评论
  229. type: 1, //默认支付方式add为
  230. goodsNumber: 1, //购买数量
  231. goodsid: '', //商品id
  232. specClass: 'none', //显示隐藏弹窗
  233. shareList: [], //分享列表
  234. goodsObjact: {}, //保存商品数据
  235. storeObjact: {},//保存店铺数据
  236. //图片循环
  237. imgList: [],
  238. specList: [],
  239. // 对比对象
  240. productValue: [],
  241. actionPrice: 0, //默认选中商品价格
  242. actionImage: '', //默认选中图片
  243. uniqueId: '', //选中的商品分类
  244. specSelected: [], //选中的分类
  245. specSelectedName: '', //选中分类名称
  246. goodsNumberMax: 0, //最大可购买数量
  247. shopId: '', //商店id
  248. //商店信息
  249. shopInfo: {
  250. logo: '',
  251. title: ''
  252. }, //商店信息
  253. goodsType: 0, //商品类型1秒杀商品0为普通商品2为拼团商品
  254. // 秒杀数据保存
  255. seckillObj: {
  256. stopTime: 0, //结束时间
  257. stop: false, //是否结束
  258. stopTimeH: 0, //小时
  259. stopTimeM: 0, //分钟
  260. stopTimeS: 0 //秒钟
  261. },
  262. // 拼团数据保存
  263. pink: {
  264. id: '', //拼团编号
  265. uid: '', //用户编号
  266. people: '', //拼团人数
  267. price: '', //拼团价格
  268. stop_time: '', //拼团结束时间
  269. nickname: '', //团长昵称
  270. avatar: '', //团长头像
  271. count: '', //拼团剩余人数
  272. h: '', //时
  273. i: '', //分
  274. s: '' //秒
  275. }
  276. };
  277. },
  278. async onLoad(options) {
  279. let obj = this;
  280. //保存商品id
  281. this.goodsid = options.id;
  282. // 判断有无人邀请
  283. if (options.spread) {
  284. // 存储邀请人
  285. uni.setStorageSync('spread', options.spread);
  286. }
  287. // 判断是否为秒杀商品
  288. if (options.type == 1) {
  289. // 保存商品类型
  290. this.goodsType = 1;
  291. // 保存结束时间
  292. this.seckillObj.stopTime = options.stoptime;
  293. // 获取当前时间毫秒数
  294. let stoptime = options.stoptime * 1000;
  295. // 获取当前时间
  296. let acitonTime = new Date();
  297. // 判断当前时间是否大于结束时间
  298. if (acitonTime.getTime() > stoptime) {
  299. // 当前秒杀时间已经结束
  300. this.seckillObj.stop = true;
  301. } else {
  302. // 计算倒计时
  303. this.timeComputed(stoptime, this.seckillObj);
  304. }
  305. this.seckillGoods();
  306. return;
  307. }
  308. if (options.type == 2) {
  309. // 保存当前拼团商品类型
  310. this.goodsType = 2;
  311. // 家在数据
  312. this.groupGoods();
  313. return;
  314. }
  315. if (this.goodsType == 0) {
  316. // 加载普通商品详情
  317. this.goodsDetail();
  318. }
  319. },
  320. computed: {
  321. // #ifdef H5
  322. ...mapState(['weichatObj', 'baseURL', 'urlFile']),
  323. ...mapState('user', ['userInfo'])
  324. // #endif
  325. },
  326. methods: {
  327. navTo(url) {
  328. uni.navigateTo({
  329. url
  330. });
  331. },
  332. //获取商店信息
  333. getShoping() {
  334. let obj = this;
  335. getShoping({
  336. mer_id: this.shopId
  337. })
  338. .then(function({ data }) {
  339. console.log(data);
  340. obj.shopInfo = data;
  341. })
  342. .catch(e => {
  343. console.log(e);
  344. });
  345. },
  346. // 转换字符串为数字
  347. moneyNum: function(value) {
  348. return +value;
  349. },
  350. navToProductGoods() {
  351. uni.redirectTo({
  352. url: '/pages/product/product?id=' + this.goodsObjact.product_id
  353. });
  354. },
  355. // 获取拼团商品详情
  356. groupGoods() {
  357. let obj = this;
  358. groupGoods({}, this.goodsid).then(function({ data }) {
  359. obj.pink = data.pink[0]; //保存拼团信息
  360. let goods = data.storeInfo;
  361. obj.goodsObjact = goods;
  362. obj.imgList = goods.images; //保存轮播图
  363. obj.specList = data.productAttr; //保存分类列表
  364. obj.productValue = data.productValue; //保存分类查询数据
  365. obj.actionPrice = goods.price; //保存默认选中商品价格
  366. obj.actionImage = goods.image_base; //保存默认选中商品图片
  367. obj.goodsNumberMax = 1; //保存默认选中最大可购买商品数量
  368. obj.shopId = data.mer_id; //保存商店id
  369. if (obj.shopId > 0) {
  370. obj.getShoping();
  371. }
  372. // #ifdef H5
  373. obj.shareDate();
  374. // #endif
  375. });
  376. },
  377. // 获取秒杀商品详情
  378. seckillGoods() {
  379. let obj = this;
  380. seckillGoods({}, this.goodsid).then(function({ data }) {
  381. let goods = data.storeInfo;
  382. obj.goodsObjact = goods;
  383. obj.imgList = goods.images; //保存轮播图
  384. obj.specList = data.productAttr; //保存分类列表
  385. obj.productValue = data.productValue; //保存分类查询数据
  386. obj.actionPrice = goods.price; //保存默认选中商品价格
  387. obj.actionImage = goods.image_base; //保存默认选中商品价格
  388. obj.goodsNumberMax = goods.num; //保存默认选中最大可购买商品数量
  389. obj.shopId = data.mer_id; //保存商店id
  390. if (obj.shopId > 0) {
  391. obj.getShoping();
  392. }
  393. // #ifdef H5
  394. obj.shareDate();
  395. // #endif
  396. });
  397. },
  398. // 计算倒计时时间
  399. timeComputed(da, ar) {
  400. let obj = ar;
  401. // 设置到期时间
  402. let time = new Date(da);
  403. // 获取当前时间
  404. let actTime = new Date();
  405. // 获取到期时间具体值
  406. let tH = time.getHours();
  407. let tM = time.getMinutes();
  408. let tS = time.getSeconds();
  409. // 获取当前时间具体值
  410. let aH = actTime.getHours();
  411. let aM = actTime.getMinutes();
  412. let aS = actTime.getSeconds();
  413. // 计算时间,保存需要多少时间到期
  414. obj.stopTimeH = tH - aH;
  415. obj.stopTimeM = tM - aM;
  416. obj.stopTimeS = tS - aS;
  417. },
  418. // 获取商品信息
  419. goodsDetail() {
  420. let obj = this;
  421. goodsDetail({}, this.goodsid).then(function({ data }) {
  422. obj.details = data;
  423. let goods = data.storeInfo;
  424. let store_info = data.system_store// 保存店铺信息
  425. console.log(store_info)
  426. obj.storeObjact = store_info
  427. obj.goodsObjact = goods;
  428. obj.reply = data.reply; //保存评论列表
  429. obj.imgList = goods.slider_image; //保存轮播图
  430. obj.specList = data.productAttr; //保存分类列表
  431. obj.productValue = data.productValue; //保存分类查询数据
  432. obj.actionPrice = goods.price; //保存默认选中商品价格
  433. obj.actionImage = goods.image_base; //保存默认选中商品价格
  434. obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
  435. obj.shopId = data.mer_id; //保存商店id
  436. if (obj.shopId > 0) {
  437. obj.getShoping();
  438. }
  439. // #ifdef H5
  440. obj.shareDate();
  441. // #endif
  442. });
  443. },
  444. // #ifdef H5
  445. // 加载微信html5页面分享方法
  446. shareDate() {
  447. let obj = this;
  448. // 保存分享人id链接
  449. let url = window.location.href + '&spread=' + this.userInfo.uid;
  450. // 判断是否微信浏览器
  451. let bool = uni.getStorageSync('weichatBrowser') || '';
  452. if (bool) {
  453. // 过滤微信强制添加的链接地址
  454. url = url.replace(/[\?,&]from=singlemessage/g, '');
  455. let data = {
  456. link: url, // 分享链接
  457. imgUrl: obj.goodsObjact.image, // 分享图标
  458. desc: obj.goodsObjact.store_info,
  459. title: obj.goodsObjact.store_name,
  460. success: function(e) {
  461. console.log(e);
  462. }
  463. };
  464. weixindata(data);
  465. }
  466. },
  467. // #endif
  468. // 购买数量变化
  469. numberChange(e) {
  470. this.goodsNumber = e.number;
  471. },
  472. //规格弹窗开关
  473. toggleSpec(str) {
  474. if (this.specClass === 'show') {
  475. this.specClass = 'hide';
  476. setTimeout(() => {
  477. this.specClass = 'none';
  478. }, 250);
  479. } else if (this.specClass === 'none') {
  480. this.specClass = 'show';
  481. }
  482. // 保存当前购买类型
  483. this.type = str;
  484. },
  485. //选择规格
  486. selectSpec(item, arr, ind) {
  487. arr.attr_value.forEach(function(e) {
  488. e.check = false;
  489. });
  490. item.check = true;
  491. this.specSelected[ind] = item.attr;
  492. let str = this.specSelected.join(',');
  493. this.specSelectedName = this.specSelected.join(' ');
  494. if (this.productValue[str]) {
  495. let data = this.productValue[str];
  496. this.actionPrice = data.price;
  497. this.goodsNumberMax = data.stock;
  498. this.actionImage = data.image;
  499. this.uniqueId = data.unique;
  500. }
  501. },
  502. //分享
  503. share() {
  504. this.$refs.share.toggleMask();
  505. },
  506. //收藏
  507. toFavorite(item) {
  508. let obj = this;
  509. item.userCollect = !item.userCollect;
  510. if (!item.userCollect) {
  511. collectDel({ id: obj.goodsid, category: 'product' }).then(function(e) {
  512. uni.showToast({
  513. title: '成功取消收藏',
  514. type: 'top',
  515. duration: 1500
  516. });
  517. });
  518. } else {
  519. collectAdd({ id: obj.goodsid, category: 'product' }).then(function(e) {
  520. uni.showToast({
  521. title: '成功加入收藏',
  522. type: 'top',
  523. duration: 1500
  524. });
  525. });
  526. }
  527. },
  528. // 立即购买
  529. buy() {
  530. let obj = this;
  531. let data = {
  532. cartNum: obj.goodsNumber, //商品数量
  533. uniqueId: obj.uniqueId, //商品标签
  534. new: '1', //商品是否新增加到购物车1为不加入0为加入
  535. mer_id: obj.shopId,
  536. // type: 0,//0为余额支付 1为消费券支付 2为积分支付
  537. };
  538. if (obj.type == 2) {
  539. data.new = 0;
  540. }
  541. if (obj.goodsType == 0) {
  542. data.productId = obj.goodsid; //商品编号
  543. }
  544. // 判断是否为秒杀商品
  545. if (obj.goodsType == 1) {
  546. data.secKillId = obj.goodsid; //秒杀商品编号
  547. data.productId = obj.goodsObjact.product_id; //商品编号
  548. // 判断是否秒杀已经结束
  549. if (obj.seckillObj.stop) {
  550. uni.showModal({
  551. title: '提示',
  552. content: '当前活动已经结束',
  553. showCancel: false
  554. });
  555. return;
  556. }
  557. }
  558. // 判断是否为拼团商品
  559. if (obj.goodsType == 2) {
  560. data.combinationId = obj.goodsid; //拼团编号
  561. data.productId = obj.goodsObjact.product_id; //商品编号
  562. }
  563. cartAdd(data)
  564. .then(function({ data }) {
  565. if (obj.type == 1) {
  566. // 跳转到支付页
  567. uni.navigateTo({
  568. url: '/pages/order/createOrder?id=' + data.cartId + '&goodsType=' + obj.goodsType
  569. });
  570. }
  571. if (obj.type == 2) {
  572. uni.showToast({
  573. title: '成功加入购物车',
  574. type: 'top',
  575. duration: 2000
  576. });
  577. obj.toggleSpec();
  578. }
  579. })
  580. .catch(e => {
  581. console.log(e);
  582. });
  583. },
  584. stopPrevent() {}
  585. }
  586. };
  587. </script>
  588. <style lang="scss">
  589. page {
  590. background: $page-color-base;
  591. }
  592. //秒杀底部高度
  593. .seckillBottom {
  594. height: 110rpx;
  595. }
  596. // 文章页底部高度撑开
  597. .contentBottomHeight {
  598. height: 110rpx;
  599. }
  600. //默认商品底部高度
  601. .goodsBottom {
  602. height: 160rpx;
  603. }
  604. .iconenter {
  605. font-size: $font-base + 2rpx;
  606. color: #888;
  607. }
  608. .carousel {
  609. /* #ifdef APP-PLUS */
  610. padding-top: var(--status-bar-height);
  611. /* #endif */
  612. height: 722rpx;
  613. position: relative;
  614. swiper {
  615. height: 100%;
  616. }
  617. .image-wrapper {
  618. width: 100%;
  619. height: 100%;
  620. }
  621. .swiper-item {
  622. display: flex;
  623. justify-content: center;
  624. align-content: center;
  625. // height: 750rpx;
  626. height: 710rpx;
  627. overflow: hidden;
  628. image {
  629. width: 100%;
  630. height: 100%;
  631. }
  632. }
  633. }
  634. // 秒杀
  635. .seckill-box-title {
  636. background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%) !important;
  637. .price,
  638. .price-tip,
  639. .timeStop,
  640. .m-price {
  641. color: #ffffff !important;
  642. }
  643. .price-tip {
  644. font-size: $font-base;
  645. }
  646. .price {
  647. font-size: 45rpx !important;
  648. font-weight: bold;
  649. }
  650. .timeStop {
  651. }
  652. }
  653. // 底部拼团、秒杀支付按钮
  654. .goods-pay-box {
  655. position: fixed;
  656. left: 0;
  657. bottom: 0;
  658. z-index: 95;
  659. width: 750rpx;
  660. height: 100rpx;
  661. line-height: 1;
  662. color: #ffffff;
  663. text-align: center;
  664. font-size: $font-lg;
  665. .bgLine {
  666. background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%);
  667. }
  668. // 拼团支付按钮
  669. .goods-pay {
  670. display: flex;
  671. align-content: center;
  672. flex-wrap: wrap;
  673. justify-content: center;
  674. .goods-buttom,
  675. .goods-buttom-money {
  676. width: 100%;
  677. }
  678. .goods-buttom-money {
  679. font-size: $font-base;
  680. }
  681. }
  682. .goods-pay-stop,
  683. .goods-pay {
  684. padding: 15rpx 0;
  685. height: 100%;
  686. width: 100%;
  687. }
  688. .goods-pay-stop {
  689. background: $color-gray;
  690. line-height: 70rpx;
  691. }
  692. }
  693. /* 标题简介 */
  694. .introduce-section {
  695. background: #fff;
  696. padding: 20rpx 30rpx;
  697. .title {
  698. font-size: 32rpx;
  699. color: $font-color-dark;
  700. height: 50rpx;
  701. line-height: 50rpx;
  702. }
  703. .price-box {
  704. display: flex;
  705. align-items: baseline;
  706. height: 64rpx;
  707. padding: 10rpx 0;
  708. font-size: 26rpx;
  709. color: $uni-color-primary;
  710. }
  711. .price {
  712. font-size: $font-lg + 2rpx;
  713. }
  714. .m-price {
  715. margin: 0 12rpx;
  716. color: $font-color-light;
  717. text-decoration: line-through;
  718. }
  719. .coupon-tip {
  720. align-items: center;
  721. padding: 4rpx 10rpx;
  722. background: $uni-color-primary;
  723. font-size: $font-sm;
  724. color: #fff;
  725. border-radius: 6rpx;
  726. line-height: 1;
  727. transform: translateY(-4rpx);
  728. }
  729. .bot-row {
  730. display: flex;
  731. align-items: center;
  732. height: 50rpx;
  733. font-size: $font-sm;
  734. color: $font-color-light;
  735. text {
  736. flex: 1;
  737. }
  738. }
  739. }
  740. /* 分享 */
  741. .share-section {
  742. display: flex;
  743. align-items: center;
  744. color: $font-color-base;
  745. background: linear-gradient(left, #fdf5f6, #fbebf6);
  746. padding: 12rpx 30rpx;
  747. .share-icon {
  748. display: flex;
  749. align-items: center;
  750. width: 70rpx;
  751. height: 30rpx;
  752. line-height: 1;
  753. border: 1px solid $uni-color-primary;
  754. border-radius: 4rpx;
  755. position: relative;
  756. overflow: hidden;
  757. font-size: 22rpx;
  758. color: $uni-color-primary;
  759. &:after {
  760. content: '';
  761. width: 50rpx;
  762. height: 50rpx;
  763. border-radius: 50%;
  764. left: -20rpx;
  765. top: -12rpx;
  766. position: absolute;
  767. background: $uni-color-primary;
  768. }
  769. }
  770. .iconfavorfill {
  771. position: relative;
  772. z-index: 1;
  773. font-size: 24rpx;
  774. margin-left: 2rpx;
  775. margin-right: 10rpx;
  776. color: #fff;
  777. line-height: 1;
  778. }
  779. .tit {
  780. font-size: $font-base;
  781. margin-left: 10rpx;
  782. }
  783. .iconprompt {
  784. padding: 10rpx;
  785. font-size: 30rpx;
  786. line-height: 1;
  787. }
  788. .share-btn {
  789. flex: 1;
  790. text-align: right;
  791. font-size: $font-sm;
  792. color: $uni-color-primary;
  793. }
  794. .iconenter {
  795. font-size: $font-sm;
  796. margin-left: 4rpx;
  797. color: $uni-color-primary;
  798. }
  799. }
  800. .c-list {
  801. margin-top: 20rpx;
  802. font-size: $font-sm + 2rpx;
  803. color: $font-color-base;
  804. background: #fff;
  805. .c-row {
  806. display: flex;
  807. align-items: center;
  808. padding: 20rpx 30rpx;
  809. position: relative;
  810. }
  811. .tit {
  812. width: 140rpx;
  813. }
  814. .con {
  815. flex: 1;
  816. color: $font-color-dark;
  817. .selected-text {
  818. margin-right: 10rpx;
  819. }
  820. }
  821. .bz-list {
  822. height: 40rpx;
  823. font-size: $font-sm + 2rpx;
  824. color: $font-color-dark;
  825. text {
  826. display: inline-block;
  827. margin-right: 30rpx;
  828. }
  829. }
  830. .con-list {
  831. flex: 1;
  832. display: flex;
  833. flex-direction: column;
  834. color: $font-color-dark;
  835. line-height: 40rpx;
  836. }
  837. .red {
  838. color: $uni-color-primary;
  839. }
  840. }
  841. /* 评价 */
  842. .eva-section {
  843. display: flex;
  844. flex-direction: column;
  845. padding: 20rpx 30rpx;
  846. background: #fff;
  847. margin-top: 16rpx;
  848. .e-header {
  849. display: flex;
  850. align-items: center;
  851. height: 70rpx;
  852. font-size: $font-sm + 2rpx;
  853. color: $font-color-light;
  854. .tit {
  855. font-size: $font-base + 2rpx;
  856. color: $font-color-dark;
  857. margin-right: 4rpx;
  858. }
  859. .tip {
  860. flex: 1;
  861. text-align: right;
  862. }
  863. .iconenter {
  864. margin-left: 10rpx;
  865. }
  866. }
  867. }
  868. .eva-box {
  869. display: flex;
  870. padding: 20rpx 0;
  871. .portrait {
  872. flex-shrink: 0;
  873. width: 80rpx;
  874. height: 80rpx;
  875. border-radius: 100px;
  876. }
  877. .right {
  878. flex: 1;
  879. display: flex;
  880. flex-direction: column;
  881. font-size: $font-base;
  882. color: $font-color-base;
  883. padding-left: 26rpx;
  884. .con {
  885. font-size: $font-base;
  886. color: $font-color-dark;
  887. padding: 20rpx 0;
  888. }
  889. .bot {
  890. display: flex;
  891. justify-content: space-between;
  892. font-size: $font-sm;
  893. color: $font-color-light;
  894. }
  895. }
  896. }
  897. .eva-boxs {
  898. width: 100%;
  899. overflow: hidden;
  900. padding: 10px 28rpx;
  901. background: #f4f4f4;
  902. border-radius: 12rpx;
  903. font-size: $font-sm + 2rpx;
  904. color: #333;
  905. .portrait {
  906. flex-shrink: 0;
  907. width: 80rpx;
  908. height: 80rpx;
  909. border-radius: 100px;
  910. }
  911. .right {
  912. flex: 1;
  913. display: flex;
  914. flex-direction: column;
  915. font-size: $font-base;
  916. color: $font-color-base;
  917. .con {
  918. font-size: $font-base;
  919. color: $font-color-dark;
  920. }
  921. .bot {
  922. display: flex;
  923. justify-content: space-between;
  924. font-size: $font-sm;
  925. color: $font-color-light;
  926. }
  927. }
  928. }
  929. /* 详情 */
  930. .detail-desc {
  931. background: #fff;
  932. margin-top: 16rpx;
  933. /deep/ img {
  934. max-width: 100% !important;
  935. display: inline !important;
  936. }
  937. /deep/ div {
  938. max-width: 100% !important;
  939. }
  940. .d-header {
  941. display: flex;
  942. justify-content: center;
  943. align-items: center;
  944. height: 80rpx;
  945. font-size: $font-base + 2rpx;
  946. color: $font-color-dark;
  947. position: relative;
  948. text {
  949. padding: 0 20rpx;
  950. background: #fff;
  951. position: relative;
  952. z-index: 1;
  953. }
  954. &:after {
  955. position: absolute;
  956. left: 50%;
  957. top: 50%;
  958. transform: translateX(-50%);
  959. width: 300rpx;
  960. height: 0;
  961. content: '';
  962. border-bottom: 1px solid #ccc;
  963. }
  964. }
  965. }
  966. /* 规格选择弹窗 */
  967. .attr-content {
  968. padding: 10rpx 30rpx;
  969. .a-t {
  970. display: flex;
  971. image {
  972. width: 170rpx;
  973. height: 170rpx;
  974. flex-shrink: 0;
  975. margin-top: -40rpx;
  976. border-radius: 8rpx;
  977. }
  978. .right {
  979. display: flex;
  980. flex-direction: column;
  981. padding-left: 24rpx;
  982. font-size: $font-sm + 2rpx;
  983. color: $font-color-base;
  984. line-height: 42rpx;
  985. .good-name {
  986. padding-top: 20rpx;
  987. max-width: 320rpx;
  988. font-size: 30rpx;
  989. font-family: PingFang SC;
  990. font-weight: bold;
  991. color: #1D2023;
  992. line-height: 42rpx;
  993. margin-bottom: 15rpx;
  994. }
  995. .price {
  996. font-size: 60rpx;
  997. font-family: PingFang SC;
  998. font-weight: bold;
  999. color: #FF6F0F;
  1000. // font-size: $font-lg;
  1001. // color: $uni-color-primary;
  1002. // margin-bottom: 10rpx;
  1003. }
  1004. .selected-text {
  1005. margin-right: 10rpx;
  1006. }
  1007. }
  1008. }
  1009. .attr-list {
  1010. display: flex;
  1011. flex-direction: column;
  1012. font-size: $font-base + 2rpx;
  1013. color: $font-color-base;
  1014. padding-top: 30rpx;
  1015. padding-left: 10rpx;
  1016. }
  1017. .item-list {
  1018. padding: 20rpx 0 0;
  1019. display: flex;
  1020. flex-wrap: wrap;
  1021. text {
  1022. display: flex;
  1023. align-items: center;
  1024. justify-content: center;
  1025. background: #eee;
  1026. margin-right: 20rpx;
  1027. margin-bottom: 20rpx;
  1028. border-radius: 100rpx;
  1029. min-width: 60rpx;
  1030. height: 60rpx;
  1031. padding: 0 20rpx;
  1032. font-size: $font-base;
  1033. color: $font-color-dark;
  1034. }
  1035. .selected {
  1036. background: #fbebee;
  1037. color: $uni-color-primary;
  1038. }
  1039. }
  1040. }
  1041. /* 弹出层 */
  1042. .popup {
  1043. position: fixed;
  1044. left: 0;
  1045. top: 0;
  1046. right: 0;
  1047. bottom: 0;
  1048. z-index: 99;
  1049. &.show {
  1050. display: block;
  1051. .mask {
  1052. animation: showPopup 0.2s linear both;
  1053. }
  1054. .layer {
  1055. animation: showLayer 0.2s linear both;
  1056. }
  1057. }
  1058. &.hide {
  1059. .mask {
  1060. animation: hidePopup 0.2s linear both;
  1061. }
  1062. .layer {
  1063. animation: hideLayer 0.2s linear both;
  1064. }
  1065. }
  1066. &.none {
  1067. display: none;
  1068. }
  1069. .mask {
  1070. position: fixed;
  1071. top: 0;
  1072. width: 100%;
  1073. height: 100%;
  1074. z-index: 1;
  1075. background-color: rgba(0, 0, 0, 0.4);
  1076. }
  1077. .layer {
  1078. position: fixed;
  1079. z-index: 99;
  1080. bottom: 0;
  1081. width: 100%;
  1082. min-height: 30vh;
  1083. border-radius: 10rpx 10rpx 0 0;
  1084. background-color: #fff;
  1085. .btn {
  1086. height: 66rpx;
  1087. line-height: 66rpx;
  1088. border-radius: 100rpx;
  1089. // background: $uni-color-primary;
  1090. background: $base-color;
  1091. font-size: $font-base + 2rpx;
  1092. color: #fff;
  1093. margin: 30rpx auto 20rpx;
  1094. }
  1095. }
  1096. @keyframes showPopup {
  1097. 0% {
  1098. opacity: 0;
  1099. }
  1100. 100% {
  1101. opacity: 1;
  1102. }
  1103. }
  1104. @keyframes hidePopup {
  1105. 0% {
  1106. opacity: 1;
  1107. }
  1108. 100% {
  1109. opacity: 0;
  1110. }
  1111. }
  1112. @keyframes showLayer {
  1113. 0% {
  1114. transform: translateY(120%);
  1115. }
  1116. 100% {
  1117. transform: translateY(0%);
  1118. }
  1119. }
  1120. @keyframes hideLayer {
  1121. 0% {
  1122. transform: translateY(0);
  1123. }
  1124. 100% {
  1125. transform: translateY(120%);
  1126. }
  1127. }
  1128. }
  1129. /* 底部操作菜单 */
  1130. .page-bottom {
  1131. position: fixed;
  1132. left: 0rpx;
  1133. bottom: 0rpx;
  1134. z-index: 95;
  1135. display: flex;
  1136. justify-content: center;
  1137. align-items: center;
  1138. width: 750rpx;
  1139. height: 98rpx;
  1140. background: rgba(255, 255, 255, 0.9);
  1141. box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.5);
  1142. // border-radius: 16rpx;
  1143. .p-b-btn {
  1144. display: flex;
  1145. flex-direction: column;
  1146. align-items: center;
  1147. justify-content: center;
  1148. font-size: $font-sm;
  1149. color: $font-color-base;
  1150. width: 100rpx;
  1151. height: 98rpx;
  1152. .iconfont {
  1153. font-size: 40rpx;
  1154. line-height: 48rpx;
  1155. color: $font-color-light;
  1156. }
  1157. &.active,
  1158. &.active .iconfont {
  1159. color: $uni-color-primary;
  1160. }
  1161. .icon-fenxiang2 {
  1162. font-size: 42rpx;
  1163. transform: translateY(-2rpx);
  1164. }
  1165. .iconlikefill {
  1166. font-size: 46rpx;
  1167. }
  1168. }
  1169. .action-btn-group {
  1170. display: flex;
  1171. height: 98rpx;
  1172. // border-radius: 100px;
  1173. overflow: hidden;
  1174. // margin-left: 20rpx;
  1175. position: relative;
  1176. // &:after {
  1177. // content: '';
  1178. // position: absolute;
  1179. // top: 50%;
  1180. // right: 50%;
  1181. // transform: translateY(-50%);
  1182. // height: 28rpx;
  1183. // width: 0;
  1184. // border-right: 1px solid rgba(255, 255, 255, 0.5);
  1185. // }
  1186. .action-btn {
  1187. display: flex;
  1188. align-items: center;
  1189. justify-content: center;
  1190. width: 350rpx;
  1191. height: 100%;
  1192. font-size: $font-base;
  1193. padding: 0;
  1194. border-radius: 0;
  1195. // background: transparent;
  1196. background: #31332D;
  1197. &.buy-now-btn {
  1198. background-color: #303e49;
  1199. }
  1200. &.add-cart-btn {
  1201. background-color: $base-color;
  1202. }
  1203. }
  1204. }
  1205. }
  1206. // 商店头
  1207. .shop-box {
  1208. background-color: #ffffff;
  1209. margin-top: 20rpx;
  1210. margin-bottom: 10rpx;
  1211. padding: 20rpx;
  1212. .shop-img {
  1213. border-radius: 300rpx;
  1214. height: 80rpx;
  1215. width: 80rpx;
  1216. margin-right: 20rpx;
  1217. }
  1218. .shop-button {
  1219. border-radius: 100rpx;
  1220. padding: 10rpx 20rpx;
  1221. color: $color-red;
  1222. border: 1px solid $color-red;
  1223. font-size: $font-lg;
  1224. line-height: 1;
  1225. }
  1226. }
  1227. </style>