product.vue 29 KB

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