product.vue 29 KB

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