product.vue 29 KB

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