product.vue 32 KB

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