product.vue 28 KB

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