product.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239
  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. };
  537. if (obj.type == 2) {
  538. data.new = 0;
  539. }
  540. if (obj.goodsType == 0) {
  541. data.productId = obj.goodsid; //商品编号
  542. }
  543. // 判断是否为秒杀商品
  544. if (obj.goodsType == 1) {
  545. data.secKillId = obj.goodsid; //秒杀商品编号
  546. data.productId = obj.goodsObjact.product_id; //商品编号
  547. // 判断是否秒杀已经结束
  548. if (obj.seckillObj.stop) {
  549. uni.showModal({
  550. title: '提示',
  551. content: '当前活动已经结束',
  552. showCancel: false
  553. });
  554. return;
  555. }
  556. }
  557. // 判断是否为拼团商品
  558. if (obj.goodsType == 2) {
  559. data.combinationId = obj.goodsid; //拼团编号
  560. data.productId = obj.goodsObjact.product_id; //商品编号
  561. }
  562. cartAdd(data)
  563. .then(function({ data }) {
  564. if (obj.type == 1) {
  565. // 跳转到支付页
  566. uni.navigateTo({
  567. url: '/pages/order/createOrder?id=' + data.cartId + '&goodsType=' + obj.goodsType
  568. });
  569. }
  570. if (obj.type == 2) {
  571. uni.showToast({
  572. title: '成功加入购物车',
  573. type: 'top',
  574. duration: 2000
  575. });
  576. obj.toggleSpec();
  577. }
  578. })
  579. .catch(e => {
  580. console.log(e);
  581. });
  582. },
  583. stopPrevent() {}
  584. }
  585. };
  586. </script>
  587. <style lang="scss">
  588. page {
  589. background: $page-color-base;
  590. }
  591. //秒杀底部高度
  592. .seckillBottom {
  593. height: 110rpx;
  594. }
  595. // 文章页底部高度撑开
  596. .contentBottomHeight {
  597. height: 110rpx;
  598. }
  599. //默认商品底部高度
  600. .goodsBottom {
  601. height: 160rpx;
  602. }
  603. .iconenter {
  604. font-size: $font-base + 2rpx;
  605. color: #888;
  606. }
  607. .carousel {
  608. /* #ifdef APP-PLUS */
  609. padding-top: var(--status-bar-height);
  610. /* #endif */
  611. height: 722rpx;
  612. position: relative;
  613. swiper {
  614. height: 100%;
  615. }
  616. .image-wrapper {
  617. width: 100%;
  618. height: 100%;
  619. }
  620. .swiper-item {
  621. display: flex;
  622. justify-content: center;
  623. align-content: center;
  624. // height: 750rpx;
  625. height: 710rpx;
  626. overflow: hidden;
  627. image {
  628. width: 100%;
  629. height: 100%;
  630. }
  631. }
  632. }
  633. // 秒杀
  634. .seckill-box-title {
  635. background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%) !important;
  636. .price,
  637. .price-tip,
  638. .timeStop,
  639. .m-price {
  640. color: #ffffff !important;
  641. }
  642. .price-tip {
  643. font-size: $font-base;
  644. }
  645. .price {
  646. font-size: 45rpx !important;
  647. font-weight: bold;
  648. }
  649. .timeStop {
  650. }
  651. }
  652. // 底部拼团、秒杀支付按钮
  653. .goods-pay-box {
  654. position: fixed;
  655. left: 0;
  656. bottom: 0;
  657. z-index: 95;
  658. width: 750rpx;
  659. height: 100rpx;
  660. line-height: 1;
  661. color: #ffffff;
  662. text-align: center;
  663. font-size: $font-lg;
  664. .bgLine {
  665. background: linear-gradient(90deg, rgba(239, 78, 81, 1) 0%, rgba(244, 113, 59, 1) 100%);
  666. }
  667. // 拼团支付按钮
  668. .goods-pay {
  669. display: flex;
  670. align-content: center;
  671. flex-wrap: wrap;
  672. justify-content: center;
  673. .goods-buttom,
  674. .goods-buttom-money {
  675. width: 100%;
  676. }
  677. .goods-buttom-money {
  678. font-size: $font-base;
  679. }
  680. }
  681. .goods-pay-stop,
  682. .goods-pay {
  683. padding: 15rpx 0;
  684. height: 100%;
  685. width: 100%;
  686. }
  687. .goods-pay-stop {
  688. background: $color-gray;
  689. line-height: 70rpx;
  690. }
  691. }
  692. /* 标题简介 */
  693. .introduce-section {
  694. background: #fff;
  695. padding: 20rpx 30rpx;
  696. .title {
  697. font-size: 32rpx;
  698. color: $font-color-dark;
  699. height: 50rpx;
  700. line-height: 50rpx;
  701. }
  702. .price-box {
  703. display: flex;
  704. align-items: baseline;
  705. height: 64rpx;
  706. padding: 10rpx 0;
  707. font-size: 26rpx;
  708. color: $uni-color-primary;
  709. }
  710. .price {
  711. font-size: $font-lg + 2rpx;
  712. }
  713. .m-price {
  714. margin: 0 12rpx;
  715. color: $font-color-light;
  716. text-decoration: line-through;
  717. }
  718. .coupon-tip {
  719. align-items: center;
  720. padding: 4rpx 10rpx;
  721. background: $uni-color-primary;
  722. font-size: $font-sm;
  723. color: #fff;
  724. border-radius: 6rpx;
  725. line-height: 1;
  726. transform: translateY(-4rpx);
  727. }
  728. .bot-row {
  729. display: flex;
  730. align-items: center;
  731. height: 50rpx;
  732. font-size: $font-sm;
  733. color: $font-color-light;
  734. text {
  735. flex: 1;
  736. }
  737. }
  738. }
  739. /* 分享 */
  740. .share-section {
  741. display: flex;
  742. align-items: center;
  743. color: $font-color-base;
  744. background: linear-gradient(left, #fdf5f6, #fbebf6);
  745. padding: 12rpx 30rpx;
  746. .share-icon {
  747. display: flex;
  748. align-items: center;
  749. width: 70rpx;
  750. height: 30rpx;
  751. line-height: 1;
  752. border: 1px solid $uni-color-primary;
  753. border-radius: 4rpx;
  754. position: relative;
  755. overflow: hidden;
  756. font-size: 22rpx;
  757. color: $uni-color-primary;
  758. &:after {
  759. content: '';
  760. width: 50rpx;
  761. height: 50rpx;
  762. border-radius: 50%;
  763. left: -20rpx;
  764. top: -12rpx;
  765. position: absolute;
  766. background: $uni-color-primary;
  767. }
  768. }
  769. .iconfavorfill {
  770. position: relative;
  771. z-index: 1;
  772. font-size: 24rpx;
  773. margin-left: 2rpx;
  774. margin-right: 10rpx;
  775. color: #fff;
  776. line-height: 1;
  777. }
  778. .tit {
  779. font-size: $font-base;
  780. margin-left: 10rpx;
  781. }
  782. .iconprompt {
  783. padding: 10rpx;
  784. font-size: 30rpx;
  785. line-height: 1;
  786. }
  787. .share-btn {
  788. flex: 1;
  789. text-align: right;
  790. font-size: $font-sm;
  791. color: $uni-color-primary;
  792. }
  793. .iconenter {
  794. font-size: $font-sm;
  795. margin-left: 4rpx;
  796. color: $uni-color-primary;
  797. }
  798. }
  799. .c-list {
  800. margin-top: 20rpx;
  801. font-size: $font-sm + 2rpx;
  802. color: $font-color-base;
  803. background: #fff;
  804. .c-row {
  805. display: flex;
  806. align-items: center;
  807. padding: 20rpx 30rpx;
  808. position: relative;
  809. }
  810. .tit {
  811. width: 140rpx;
  812. }
  813. .con {
  814. flex: 1;
  815. color: $font-color-dark;
  816. .selected-text {
  817. margin-right: 10rpx;
  818. }
  819. }
  820. .bz-list {
  821. height: 40rpx;
  822. font-size: $font-sm + 2rpx;
  823. color: $font-color-dark;
  824. text {
  825. display: inline-block;
  826. margin-right: 30rpx;
  827. }
  828. }
  829. .con-list {
  830. flex: 1;
  831. display: flex;
  832. flex-direction: column;
  833. color: $font-color-dark;
  834. line-height: 40rpx;
  835. }
  836. .red {
  837. color: $uni-color-primary;
  838. }
  839. }
  840. /* 评价 */
  841. .eva-section {
  842. display: flex;
  843. flex-direction: column;
  844. padding: 20rpx 30rpx;
  845. background: #fff;
  846. margin-top: 16rpx;
  847. .e-header {
  848. display: flex;
  849. align-items: center;
  850. height: 70rpx;
  851. font-size: $font-sm + 2rpx;
  852. color: $font-color-light;
  853. .tit {
  854. font-size: $font-base + 2rpx;
  855. color: $font-color-dark;
  856. margin-right: 4rpx;
  857. }
  858. .tip {
  859. flex: 1;
  860. text-align: right;
  861. }
  862. .iconenter {
  863. margin-left: 10rpx;
  864. }
  865. }
  866. }
  867. .eva-box {
  868. display: flex;
  869. padding: 20rpx 0;
  870. .portrait {
  871. flex-shrink: 0;
  872. width: 80rpx;
  873. height: 80rpx;
  874. border-radius: 100px;
  875. }
  876. .right {
  877. flex: 1;
  878. display: flex;
  879. flex-direction: column;
  880. font-size: $font-base;
  881. color: $font-color-base;
  882. padding-left: 26rpx;
  883. .con {
  884. font-size: $font-base;
  885. color: $font-color-dark;
  886. padding: 20rpx 0;
  887. }
  888. .bot {
  889. display: flex;
  890. justify-content: space-between;
  891. font-size: $font-sm;
  892. color: $font-color-light;
  893. }
  894. }
  895. }
  896. .eva-boxs {
  897. width: 100%;
  898. overflow: hidden;
  899. padding: 10px 28rpx;
  900. background: #f4f4f4;
  901. border-radius: 12rpx;
  902. font-size: $font-sm + 2rpx;
  903. color: #333;
  904. .portrait {
  905. flex-shrink: 0;
  906. width: 80rpx;
  907. height: 80rpx;
  908. border-radius: 100px;
  909. }
  910. .right {
  911. flex: 1;
  912. display: flex;
  913. flex-direction: column;
  914. font-size: $font-base;
  915. color: $font-color-base;
  916. .con {
  917. font-size: $font-base;
  918. color: $font-color-dark;
  919. }
  920. .bot {
  921. display: flex;
  922. justify-content: space-between;
  923. font-size: $font-sm;
  924. color: $font-color-light;
  925. }
  926. }
  927. }
  928. /* 详情 */
  929. .detail-desc {
  930. background: #fff;
  931. margin-top: 16rpx;
  932. /deep/ img {
  933. max-width: 100% !important;
  934. display: inline !important;
  935. }
  936. /deep/ div {
  937. max-width: 100% !important;
  938. }
  939. .d-header {
  940. display: flex;
  941. justify-content: center;
  942. align-items: center;
  943. height: 80rpx;
  944. font-size: $font-base + 2rpx;
  945. color: $font-color-dark;
  946. position: relative;
  947. text {
  948. padding: 0 20rpx;
  949. background: #fff;
  950. position: relative;
  951. z-index: 1;
  952. }
  953. &:after {
  954. position: absolute;
  955. left: 50%;
  956. top: 50%;
  957. transform: translateX(-50%);
  958. width: 300rpx;
  959. height: 0;
  960. content: '';
  961. border-bottom: 1px solid #ccc;
  962. }
  963. }
  964. }
  965. /* 规格选择弹窗 */
  966. .attr-content {
  967. padding: 10rpx 30rpx;
  968. .a-t {
  969. display: flex;
  970. image {
  971. width: 170rpx;
  972. height: 170rpx;
  973. flex-shrink: 0;
  974. margin-top: -40rpx;
  975. border-radius: 8rpx;
  976. }
  977. .right {
  978. display: flex;
  979. flex-direction: column;
  980. padding-left: 24rpx;
  981. font-size: $font-sm + 2rpx;
  982. color: $font-color-base;
  983. line-height: 42rpx;
  984. .good-name {
  985. padding-top: 20rpx;
  986. max-width: 320rpx;
  987. font-size: 30rpx;
  988. font-family: PingFang SC;
  989. font-weight: bold;
  990. color: #1D2023;
  991. line-height: 42rpx;
  992. margin-bottom: 15rpx;
  993. }
  994. .price {
  995. font-size: 60rpx;
  996. font-family: PingFang SC;
  997. font-weight: bold;
  998. color: #FF6F0F;
  999. // font-size: $font-lg;
  1000. // color: $uni-color-primary;
  1001. // margin-bottom: 10rpx;
  1002. }
  1003. .selected-text {
  1004. margin-right: 10rpx;
  1005. }
  1006. }
  1007. }
  1008. .attr-list {
  1009. display: flex;
  1010. flex-direction: column;
  1011. font-size: $font-base + 2rpx;
  1012. color: $font-color-base;
  1013. padding-top: 30rpx;
  1014. padding-left: 10rpx;
  1015. }
  1016. .item-list {
  1017. padding: 20rpx 0 0;
  1018. display: flex;
  1019. flex-wrap: wrap;
  1020. text {
  1021. display: flex;
  1022. align-items: center;
  1023. justify-content: center;
  1024. background: #eee;
  1025. margin-right: 20rpx;
  1026. margin-bottom: 20rpx;
  1027. border-radius: 100rpx;
  1028. min-width: 60rpx;
  1029. height: 60rpx;
  1030. padding: 0 20rpx;
  1031. font-size: $font-base;
  1032. color: $font-color-dark;
  1033. }
  1034. .selected {
  1035. background: #fbebee;
  1036. color: $uni-color-primary;
  1037. }
  1038. }
  1039. }
  1040. /* 弹出层 */
  1041. .popup {
  1042. position: fixed;
  1043. left: 0;
  1044. top: 0;
  1045. right: 0;
  1046. bottom: 0;
  1047. z-index: 99;
  1048. &.show {
  1049. display: block;
  1050. .mask {
  1051. animation: showPopup 0.2s linear both;
  1052. }
  1053. .layer {
  1054. animation: showLayer 0.2s linear both;
  1055. }
  1056. }
  1057. &.hide {
  1058. .mask {
  1059. animation: hidePopup 0.2s linear both;
  1060. }
  1061. .layer {
  1062. animation: hideLayer 0.2s linear both;
  1063. }
  1064. }
  1065. &.none {
  1066. display: none;
  1067. }
  1068. .mask {
  1069. position: fixed;
  1070. top: 0;
  1071. width: 100%;
  1072. height: 100%;
  1073. z-index: 1;
  1074. background-color: rgba(0, 0, 0, 0.4);
  1075. }
  1076. .layer {
  1077. position: fixed;
  1078. z-index: 99;
  1079. bottom: 0;
  1080. width: 100%;
  1081. min-height: 30vh;
  1082. border-radius: 10rpx 10rpx 0 0;
  1083. background-color: #fff;
  1084. .btn {
  1085. height: 66rpx;
  1086. line-height: 66rpx;
  1087. border-radius: 100rpx;
  1088. // background: $uni-color-primary;
  1089. background: $base-color;
  1090. font-size: $font-base + 2rpx;
  1091. color: #fff;
  1092. margin: 30rpx auto 20rpx;
  1093. }
  1094. }
  1095. @keyframes showPopup {
  1096. 0% {
  1097. opacity: 0;
  1098. }
  1099. 100% {
  1100. opacity: 1;
  1101. }
  1102. }
  1103. @keyframes hidePopup {
  1104. 0% {
  1105. opacity: 1;
  1106. }
  1107. 100% {
  1108. opacity: 0;
  1109. }
  1110. }
  1111. @keyframes showLayer {
  1112. 0% {
  1113. transform: translateY(120%);
  1114. }
  1115. 100% {
  1116. transform: translateY(0%);
  1117. }
  1118. }
  1119. @keyframes hideLayer {
  1120. 0% {
  1121. transform: translateY(0);
  1122. }
  1123. 100% {
  1124. transform: translateY(120%);
  1125. }
  1126. }
  1127. }
  1128. /* 底部操作菜单 */
  1129. .page-bottom {
  1130. position: fixed;
  1131. left: 0rpx;
  1132. bottom: 0rpx;
  1133. z-index: 95;
  1134. display: flex;
  1135. justify-content: center;
  1136. align-items: center;
  1137. width: 750rpx;
  1138. height: 98rpx;
  1139. background: rgba(255, 255, 255, 0.9);
  1140. box-shadow: 0 0 20rpx 0 rgba(0, 0, 0, 0.5);
  1141. // border-radius: 16rpx;
  1142. .p-b-btn {
  1143. display: flex;
  1144. flex-direction: column;
  1145. align-items: center;
  1146. justify-content: center;
  1147. font-size: $font-sm;
  1148. color: $font-color-base;
  1149. width: 100rpx;
  1150. height: 98rpx;
  1151. .iconfont {
  1152. font-size: 40rpx;
  1153. line-height: 48rpx;
  1154. color: $font-color-light;
  1155. }
  1156. &.active,
  1157. &.active .iconfont {
  1158. color: $uni-color-primary;
  1159. }
  1160. .icon-fenxiang2 {
  1161. font-size: 42rpx;
  1162. transform: translateY(-2rpx);
  1163. }
  1164. .iconlikefill {
  1165. font-size: 46rpx;
  1166. }
  1167. }
  1168. .action-btn-group {
  1169. display: flex;
  1170. height: 98rpx;
  1171. // border-radius: 100px;
  1172. overflow: hidden;
  1173. // margin-left: 20rpx;
  1174. position: relative;
  1175. // &:after {
  1176. // content: '';
  1177. // position: absolute;
  1178. // top: 50%;
  1179. // right: 50%;
  1180. // transform: translateY(-50%);
  1181. // height: 28rpx;
  1182. // width: 0;
  1183. // border-right: 1px solid rgba(255, 255, 255, 0.5);
  1184. // }
  1185. .action-btn {
  1186. display: flex;
  1187. align-items: center;
  1188. justify-content: center;
  1189. width: 350rpx;
  1190. height: 100%;
  1191. font-size: $font-base;
  1192. padding: 0;
  1193. border-radius: 0;
  1194. // background: transparent;
  1195. background: #31332D;
  1196. &.buy-now-btn {
  1197. background-color: #303e49;
  1198. }
  1199. &.add-cart-btn {
  1200. background-color: $base-color;
  1201. }
  1202. }
  1203. }
  1204. }
  1205. // 商店头
  1206. .shop-box {
  1207. background-color: #ffffff;
  1208. margin-top: 20rpx;
  1209. margin-bottom: 10rpx;
  1210. padding: 20rpx;
  1211. .shop-img {
  1212. border-radius: 300rpx;
  1213. height: 80rpx;
  1214. width: 80rpx;
  1215. margin-right: 20rpx;
  1216. }
  1217. .shop-button {
  1218. border-radius: 100rpx;
  1219. padding: 10rpx 20rpx;
  1220. color: $color-red;
  1221. border: 1px solid $color-red;
  1222. font-size: $font-lg;
  1223. line-height: 1;
  1224. }
  1225. }
  1226. </style>