product.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. <template>
  2. <view class="container">
  3. <!-- 轮播图 -->
  4. <top-swiper :imgList="imgList"></top-swiper>
  5. <view class="sckill-top" v-if="isSckill">
  6. <view class="top-left">
  7. <view class="left-top">限时秒杀价</view>
  8. <view class="left-btm">
  9. <text class="now-pri">{{ sckillGoodInfo.price }}</text>
  10. <text class="old-pri">¥{{ sckillGoodInfo.ot_price }}</text>
  11. </view>
  12. </view>
  13. <view class="top-right">
  14. <view class="right-top">距离本场结束还剩</view>
  15. <uni-countdown
  16. class="timeBox"
  17. color="#901b21"
  18. background-color="#fff"
  19. splitor-color="#fff"
  20. :show-day="false"
  21. :hour="stopTimes.hours"
  22. :minute="stopTimes.minutes"
  23. :second="stopTimes.seconds"
  24. ></uni-countdown>
  25. </view>
  26. </view>
  27. <!-- 标题 -->
  28. <view class="introduce-section" v-if="!isSckill">
  29. <button open-type="share" class="shareDate" style="border: none;">
  30. <image class="share-img" src="../../static/icon/share.png"></image>
  31. </button>
  32. <view class="price-box">
  33. <text class="price-tip">¥</text>
  34. <view class="price">
  35. {{ goodInfo.price }}
  36. <text class="m-price" v-if="goodInfo.ot_price*1 > goodInfo.price*1">¥{{ goodInfo.ot_price }}</text>
  37. </view>
  38. </view>
  39. <text class="title clamp2" v-if="goodInfo.title">{{ goodInfo.title }}</text>
  40. <text class="title clamp2" v-else>{{ goodInfo.store_name }}</text>
  41. </view>
  42. <product-content :goodsObjact="goodInfo"</product-content>
  43. <view class="good-title clamp2" v-if="isSckill">{{ sckillGoodInfo.title }}</view>
  44. <!-- 选择数量 -->
  45. <!-- <view class="row b-b">
  46. <text class="tit">选择</text>
  47. <picker mode="selector" :range="choNum" @change="bindChange">
  48. <view class="refund" v-if="goodsNumber !== 1">{{ goodsNumber || '请选择' }}</view>
  49. <view class="noRefund" v-else>请选择购买数量</view>
  50. </picker>
  51. </view> -->
  52. <!-- 拼货时间及优惠 -->
  53. <!-- <discounts @clickCoupon="Getcoupon" :Info="goodsObjact.store_info" :showCoupon="true"></discounts> -->
  54. <!-- 猜你喜欢 -->
  55. <!-- <guess-like @Addcar='Addcar' @clickNavTo='navToDetailPage' :goodList = 'good_list||[]'></guess-like> -->
  56. <!-- 店铺信息 -->
  57. <view class="shop-info">
  58. <view class="shop-logo"><image :src="shopInfo.mer_avatar" mode=""></image></view>
  59. <view class="shop-base">
  60. <view class="base-name">{{ shopInfo.mer_name }}</view>
  61. <view class="base-addr clamp">{{ shopInfo.mer_address }}</view>
  62. </view>
  63. <view class="shop-dis">
  64. <image src="../../static/icon/base_addr.png" mode="aspectFill"></image>
  65. 距离200m
  66. </view>
  67. </view>
  68. <!-- 评价 -->
  69. <estimate @navTo="navTo('/pages/product/reply?id=' + product_id)" v-if="reply" :reply="reply" :list="list"></estimate>
  70. <!-- 规格信息 -->
  71. <!-- <fresh-detail :goodsObjact="goodsObjact"></fresh-detail> -->
  72. <!-- 图文详情 -->
  73. <content-text :description="description"></content-text>
  74. <!-- 底部高度撑开 -->
  75. <view class="contentBottomHeight"></view>
  76. <!-- 底部操作菜单 -->
  77. <product-bottom @buy="buy" :goodsid="goodsid" @specOPne="specOPne"></product-bottom>
  78. <!-- 规格-模态层弹窗 -->
  79. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="stopPrevent" @click="toggleSpec">
  80. <!-- 遮罩层 -->
  81. <view class="mask"></view>
  82. <view class="layer attr-content" @click.stop="stopPrevent">
  83. <view class="a-t">
  84. <image :src="actionImage"></image>
  85. <view class="right">
  86. <text class="name">{{ sckillGoodInfo.title }}</text>
  87. <text class="price">¥{{ actionPrice * goodsNumber }}</text>
  88. <text class="stock">库存:{{ goodsStore }}件</text>
  89. <view class="selected" v-if="specList != ''">
  90. 已选:
  91. <text class="selected-text" v-for="(sItem, sIndex) in specSelected" :key="sIndex">{{ sItem }}</text>
  92. </view>
  93. </view>
  94. </view>
  95. <view v-for="(item, index) in specList" :key="index" class="attr-list">
  96. <text>{{ item.attr_name }}</text>
  97. <view class="item-list">
  98. <text
  99. v-for="(childItem, childIndex) in item.attr_value"
  100. :key="childIndex"
  101. class="tit"
  102. :class="{ selected: childItem.check }"
  103. @click="selectSpec(childItem, item, index)"
  104. >
  105. {{ childItem.attr }}
  106. </text>
  107. </view>
  108. </view>
  109. <view class="attr-list">
  110. <text>购买数量</text>
  111. <view class="item-list">
  112. <uni-number-box class="step" :isMin="true" :value="goodsNumber" :min="1" :max="goodsNumberMax" @eventChange="numberChange"></uni-number-box>
  113. </view>
  114. </view>
  115. <button class="btn" @click.stop="buy" v-show="buys_show">完成</button>
  116. <button class="btn" style="background-color: #999999;" v-show="buys_shows">售罄</button>
  117. </view>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import { goodsDetail, cartAdd, seckillGoods, getSeckillProductDetail, getStoreDetail ,getProductDetail} from '@/api/product.js';
  123. import { mapState } from 'vuex';
  124. import store from '@/store/index.js';
  125. import { saveUrl } from '@/utils/loginUtils.js';
  126. // #ifdef H5
  127. import { weixindata } from '@/utils/wxAuthorized';
  128. // #endif
  129. // 头部轮播图
  130. import topSwiper from './common/topSwiper.vue';
  131. // 标题
  132. import productContent from './common/productContent.vue';
  133. // 到货时间及优惠
  134. import discounts from './common/discounts.vue';
  135. // 规格信息
  136. import freshDetail from './common/freshDetail.vue';
  137. // 图文详情
  138. import contentText from './common/contentText.vue';
  139. // 底部按钮
  140. import productBottom from './common/productBottom.vue';
  141. // 猜你喜欢
  142. import guessLike from './common/guessLike.vue';
  143. // 评价
  144. import estimate from './common/estimate.vue';
  145. import uniNumberBox from '@/components/uni-number-box.vue';
  146. import { timeComputed } from '@/utils/rocessor.js';
  147. export default {
  148. components: {
  149. guessLike,
  150. topSwiper,
  151. productContent,
  152. discounts,
  153. freshDetail,
  154. contentText,
  155. productBottom,
  156. estimate,
  157. uniNumberBox
  158. },
  159. data() {
  160. return {
  161. goodsStore: 0, //选中库存
  162. specList: [],
  163. buys_show: true,
  164. buys_shows: false,
  165. specSelected: [], //选中的分类
  166. specClass: 'none', //显示隐藏弹窗
  167. many: 1, //1是单规格 2是多规格
  168. reply: '', //评论
  169. list: '', //商品详情的数据
  170. type: 1, //默认支付方式add为
  171. goodsType: 0,
  172. goodsNumber: 1, //购买数量
  173. goodsid: '', //商品id
  174. description: '', //商品描述
  175. goodsObjact: {
  176. percent: 1
  177. }, //保存商品数据
  178. //图片循环
  179. imgList: [], //顶部轮播图
  180. // 对比对象
  181. actionPrice: 0, //默认选中商品价格
  182. actionImage: '', //默认选中图片
  183. good_list: '', //猜你喜欢列表
  184. goodsNumberMax: 1, //最大可购买数量
  185. // 倒计时数据保存
  186. seckillObj: {
  187. stopTime: 0, //结束时间
  188. stop: false, //是否结束
  189. stopTimeH: 0, //小时
  190. stopTimeM: 0, //分钟
  191. stopTimeS: 0, //秒钟
  192. stopTimeD: 0, //天
  193. upTime: 0 //更新组件内部组件用
  194. },
  195. // 拼团数据保存
  196. pink: {
  197. id: '', //拼团编号
  198. uid: '', //用户编号
  199. people: '', //拼团人数
  200. price: '', //拼团价格
  201. stop_time: '', //拼团结束时间
  202. nickname: '', //团长昵称
  203. avatar: '', //团长头像
  204. count: '', //拼团剩余人数
  205. h: '', //时
  206. i: '', //分
  207. s: '' //秒
  208. },
  209. userInfo: '',
  210. isSckill: false,
  211. stopTimes: {
  212. hours: 0,
  213. minutes: 0,
  214. seconds: 0,
  215. day: 0,
  216. tpye: false
  217. },
  218. product_id: 0,
  219. sckillGoodInfo: {}, //秒杀商品信息
  220. shopInfo: {}, //店铺信息
  221. product_type: 0,
  222. goodInfo: {}
  223. };
  224. },
  225. filters: {
  226. parseIntTo(percent) {
  227. percent = +percent * 100;
  228. if (percent % 1 === 0) {
  229. return percent;
  230. } else {
  231. percent = percent.toFixed(1);
  232. return percent;
  233. }
  234. }
  235. },
  236. async onLoad(options) {
  237. console.log(options);
  238. let obj = this;
  239. obj.userInfo = uni.getStorageSync('userInfo');
  240. //保存商品id
  241. this.goodsid = options.id;
  242. this.product_id = options.id;
  243. this.goodsType = options.type;
  244. // 判断有无人邀请
  245. if (options.spread) {
  246. // 存储邀请人
  247. uni.setStorageSync('spread', options.spread);
  248. }
  249. saveUrl();
  250. // if(options.type === '1') {
  251. // obj.getGoodInfo()
  252. // // obj.getTime()
  253. // this.product_id = options.product_id
  254. // console.log('this.product_id',this.product_id)
  255. // obj.isSckill = true
  256. // }else {
  257. // this.goodsDetail();
  258. // }
  259. if (options.type === '1') {
  260. obj.isSckill = true;
  261. this.getGoodsDetails();
  262. }else if(options.type === '0' ){
  263. this.getProductDetail()
  264. }
  265. // 注册邀请信息
  266. // #ifdef H5
  267. let bool = uni.getStorageSync('weichatBrowser') || '';
  268. if (bool) {
  269. weixindata();
  270. }
  271. // #endif
  272. },
  273. computed: {
  274. ...mapState(['weichatObj', 'baseURL', 'urlFile'])
  275. },
  276. // 分享
  277. onShareAppMessage(options) {
  278. // 设置菜单中的转发按钮触发转发事件时的转发内容
  279. let pages = getCurrentPages(); //获取加载的页面
  280. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  281. let url = currentPage.route; //当前页面url
  282. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  283. let shareObj = {
  284. title: this.goodsObjact.store_name + ' 价格:' + this.goodsObjact.price, // 默认是小程序的名称(可以写slogan等)
  285. path: url + '?id=' + item.id + '&spread=' + this.userInfo.uid, // 默认是当前页面,必须是以‘/’开头的完整路径
  286. imageUrl: this.goodsObjact.image,
  287. success: function(res) {
  288. // 转发成功之后的回调
  289. if (res.errMsg == 'shareAppMessage:ok') {
  290. }
  291. },
  292. fail: function() {
  293. // 转发失败之后的回调
  294. if (res.errMsg == 'shareAppMessage:fail cancel') {
  295. // 用户取消转发
  296. } else if (res.errMsg == 'shareAppMessage:fail') {
  297. // 转发失败,其中 detail message 为详细失败信息
  298. }
  299. }
  300. };
  301. return shareObj;
  302. },
  303. methods: {
  304. //选择规格
  305. selectSpec(item, arr, ind) {
  306. arr.attr_value.forEach(function(e) {
  307. e.check = false;
  308. });
  309. item.check = true;
  310. let obj = this;
  311. obj.specSelected[ind] = item.attr;
  312. let str = obj.specSelected.join(',');
  313. // 获取当前选中的对象
  314. if (obj.productValue[str]) {
  315. obj.buys_show = true;
  316. obj.buys_shows = false;
  317. obj.actionPrice = obj.productValue[str].price;
  318. obj.goodsNumberMax = obj.productValue[str].stock;
  319. obj.actionImage = obj.productValue[str].image;
  320. obj.uniqueId = obj.productValue[str].unique;
  321. obj.goodsStore = obj.productValue[str].stock;
  322. console.log(obj.uniqueId, '++++++++obj.uniqueId');
  323. } else {
  324. obj.buys_show = false
  325. obj.buys_shows = true
  326. }
  327. if (obj.goodsStore == 0) {
  328. obj.buys_show = false;
  329. obj.buys_shows = true;
  330. }
  331. obj.specSelected[ind] = item.attr;
  332. },
  333. // 打開彈窗
  334. specOPne(type = 1) {
  335. let obj = this;
  336. obj.specClass = 'show';
  337. obj.type = type;
  338. },
  339. //规格弹窗开关
  340. toggleSpec(str) {
  341. if (this.specClass === 'show') {
  342. this.specClass = 'hide';
  343. setTimeout(() => {
  344. this.specClass = 'none';
  345. }, 250);
  346. } else if (this.specClass === 'none') {
  347. this.specClass = 'show';
  348. }
  349. // 保存当前购买类型
  350. this.type = str;
  351. },
  352. //领取优惠券
  353. Getcoupon() {
  354. uni.navigateTo({
  355. url: '/pages/coupon/getcoupon'
  356. });
  357. },
  358. //详情页
  359. navToDetailPage(item) {
  360. let id = item.id;
  361. uni.navigateTo({
  362. url: '/pages/product/product?id=' + id
  363. });
  364. },
  365. // 跳转页面
  366. navTo(url) {
  367. uni.navigateTo({
  368. url
  369. });
  370. },
  371. //加入购物车
  372. Addcar(item) {
  373. let obj = this;
  374. console.log('加入购物车', obj.goodsNumber);
  375. cartAdd({
  376. // cartNum: '1', //商品数量
  377. cartNum: obj.goodsNumber,
  378. uniqueId: '', //商品标签
  379. new: 0, //商品是否新增加到购物车1为不加入0为加入
  380. mer_id: '',
  381. productId: item.id //商品编号
  382. })
  383. .then(function(e) {
  384. uni.showToast({
  385. title: '成功加入购物车',
  386. type: 'top',
  387. duration: 500,
  388. icon: 'none'
  389. });
  390. obj.goodsDetail();
  391. })
  392. .catch(e => {
  393. console.log(e);
  394. });
  395. },
  396. goodsDetail() {
  397. let obj = this;
  398. // 获取普通商品信息
  399. goodsDetail({}, this.goodsid).then(function({ data }) {
  400. obj.list = data;
  401. console.log(data);
  402. obj.good_list = data.good_list; //保存猜你喜欢列表
  403. obj.reply = data.reply; //保存评论列表
  404. let goods = data.storeInfo;
  405. obj.goodsObjact = goods;
  406. console.log(obj.goodsObjact, '++++++++++++++');
  407. if (obj.goodsObjact.description != null) {
  408. obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
  409. } //小程序商品详情图超出屏幕问题
  410. obj.imgList = goods.slider_image; //保存轮播图
  411. obj.specList = data.productAttr; //保存分类列表
  412. if (Array.isArray(data.productValue) != true) {
  413. obj.many = 2;
  414. obj.specList = data.productAttr; //保存产品属性
  415. obj.productValue = data.productValue; //保存属性值
  416. obj.specSelected = []; //初始化默认选择对象
  417. for (let i = 0; i < obj.specList.length; i++) {
  418. // 设置默认数据
  419. let attrValue = obj.specList[i].attr_value[0];
  420. attrValue.check = true;
  421. obj.specSelected.push(attrValue.attr);
  422. }
  423. let str = obj.specSelected.join(',');
  424. console.log(str, 'str');
  425. // 设置默认值
  426. obj.actionPrice = obj.productValue[str].price;
  427. obj.goodsNumberMax = obj.productValue[str].stock;
  428. obj.actionImage = obj.productValue[str].image;
  429. obj.uniqueId = obj.productValue[str].unique;
  430. obj.goodsStore = obj.productValue[str].quota;
  431. } else {
  432. obj.many = 1;
  433. }
  434. obj.productValue = data.productValue; //保存分类查询数据
  435. obj.actionPrice = goods.price; //保存默认选中商品价格
  436. obj.actionImage = goods.image_base; //保存默认选中商品图片
  437. obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
  438. obj.shopId = data.mer_id; //保存商店id
  439. });
  440. },
  441. getGoodInfo() {
  442. let obj = this;
  443. // 获取秒杀商品信息
  444. seckillGoods({}, this.goodsid).then(function({ data }) {
  445. console.log(data);
  446. obj.list = data;
  447. obj.good_list = data.good_list; //保存猜你喜欢列表
  448. obj.reply = data.reply; //保存评论列表
  449. let goods = data.storeInfo;
  450. obj.goodsObjact = goods;
  451. obj.goodsObjact.title = goods.title;
  452. obj.stopTimes = timeComputed(obj.list.isSeckillEnd.stop * 1000);
  453. console.log(obj.stopTimes, 'dddddddddd');
  454. if (obj.goodsObjact.description != null) {
  455. obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
  456. } //小程序商品详情图超出屏幕问题
  457. obj.imgList = goods.images; //保存轮播图
  458. obj.specList = data.productAttr; //保存分类列表
  459. if (Array.isArray(data.productValue) != true) {
  460. obj.many = 2;
  461. obj.specList = data.productAttr; //保存产品属性
  462. obj.productValue = data.productValue; //保存属性值
  463. console.log(obj.productValue, 'obj.productValue++++++++');
  464. obj.specSelected = []; //初始化默认选择对象
  465. for (let i = 0; i < obj.specList.length; i++) {
  466. // 设置默认数据
  467. let attrValue = obj.specList[i].attr_value[0];
  468. attrValue.check = true;
  469. obj.specSelected.push(attrValue.attr);
  470. }
  471. let str = obj.specSelected.join(',');
  472. console.log(str, 'str');
  473. // 设置默认值
  474. obj.actionPrice = obj.productValue[str].price;
  475. obj.goodsNumberMax = obj.productValue[str].stock;
  476. obj.actionImage = obj.productValue[str].image;
  477. obj.uniqueId = obj.productValue[str].unique;
  478. console.log(obj.uniqueId, 'obj.uniqueId+++默认');
  479. obj.goodsStore = obj.productValue[str].quota;
  480. } else {
  481. obj.many = 1;
  482. }
  483. obj.productValue = data.productValue; //保存分类查询数据
  484. obj.actionPrice = goods.price; //保存默认选中商品价格
  485. obj.actionImage = goods.image_base; //保存默认选中商品图片
  486. obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
  487. obj.shopId = data.mer_id; //保存商店id
  488. });
  489. },
  490. // 立即购买
  491. buy() {
  492. let obj = this;
  493. // 创建传值对象
  494. let goodId = obj.goodsid;
  495. console.log('添加的数量', obj.goodsNumber);
  496. // let data = {
  497. // cartNum: obj.goodsNumber, //商品数量
  498. // new: 1,
  499. // productId: goodId, //商品编号
  500. // uniqueId: obj.uniqueId
  501. // };
  502. let is_new = 0
  503. if(obj.type == 1){
  504. is_new = 0
  505. }
  506. let data = {
  507. product_id: goodId,
  508. product_attr_unique: obj.uniqueId,
  509. cart_num: obj.goodsNumber,
  510. product_type: obj.product_type,
  511. is_new: is_new
  512. }
  513. console.log("立即购买++++++",data);
  514. cartAdd(data)
  515. .then(function(e) {
  516. console.log(e,"立即购买++++++fanhui")
  517. let da = e.data;
  518. if (obj.type == 1) {
  519. // 跳转到支付页
  520. uni.navigateTo({
  521. url: '/pages/order/createOrder?id=' + da.cart_id
  522. });
  523. }
  524. if (obj.type == 2) {
  525. uni.showToast({
  526. title: '成功加入购物车',
  527. type: 'top',
  528. duration: 2000,
  529. icon: 'none'
  530. });
  531. obj.getProductDetail();
  532. }
  533. obj.toggleSpec();
  534. })
  535. .catch(e => {
  536. console.log(e);
  537. });
  538. },
  539. // 阻止触发上级事件
  540. stopPrevent() {},
  541. bindChange(e) {
  542. this.goodsNumber = this.choNum[e.detail.value] * 1;
  543. console.log(this.goodsNumber);
  544. },
  545. numberChange(e) {
  546. //购买数量
  547. this.chooseGoodsNumber = e.number;
  548. this.goodsNumber = e.number;
  549. },
  550. // getTime() {
  551. // let start = new data()
  552. // }
  553. // 获取秒杀商品信息
  554. getGoodsDetails() {
  555. let obj = this;
  556. getSeckillProductDetail({}, this.goodsid).then(({ data }) => {
  557. console.log(data, 'goodInfo6666666666666');
  558. obj.imgList = data.slider_image; //保存轮播图
  559. obj.sckillGoodInfo.title = data.store_name; //保存商品名称
  560. obj.sckillGoodInfo.price = data.price; //保存商品展示价格
  561. obj.sckillGoodInfo.ot_price = data.ot_price; //保存商品市场价
  562. obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
  563. obj.product_type = data.product_type//保存商品类型
  564. //小程序商品详情图超出屏幕问题
  565. if (data.content.content !== null) {
  566. obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
  567. }
  568. //获取保存店铺详细信息
  569. getStoreDetail(data.mer_id).then(({ data }) => {
  570. console.log(data, 'shop data');
  571. obj.shopInfo = data;
  572. });
  573. // 获取商品属性
  574. obj.specList = data.attr; //保存分类列表
  575. if (data.attr.length != 0) {
  576. console.log("有好多属性")
  577. obj.many = 2;
  578. obj.specList = data.attr; //保存产品属性
  579. obj.productValue = data.sku; //保存属性值
  580. obj.specSelected = []; //初始化默认选择对象
  581. for (let i = 0; i < obj.specList.length; i++) {
  582. // 设置默认数据
  583. let attrValue = obj.specList[i].attr_value[0];
  584. attrValue.check = true;
  585. obj.specSelected.push(attrValue.attr);
  586. }
  587. let str = obj.specSelected.join(',');
  588. console.log(str, 'str');
  589. // 设置默认值
  590. obj.actionPrice = obj.productValue[str].price;
  591. obj.goodsNumberMax = obj.productValue[str].stock;
  592. obj.actionImage = obj.productValue[str].image;
  593. obj.uniqueId = obj.productValue[str].unique;
  594. obj.goodsStore = obj.productValue[str].stock;
  595. } else {
  596. console.log("zhiyou yige shuxing")
  597. obj.many = 1;
  598. obj.productValue = data.sku[''];
  599. console.log(obj.productValue,'obj.productValue11111111111')//保存分类查询数据
  600. obj.actionPrice =obj.productValue.price; //保存默认选中商品价格
  601. obj.actionImage = obj.productValue.image; //保存默认选中商品图片
  602. obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
  603. // obj.shopId = data.mer_id; //保存商店id
  604. obj.goodsStore = data.stock
  605. obj.uniqueId = obj.productValue.unique
  606. console.log(obj.uniqueId)
  607. }
  608. });
  609. },
  610. getProductDetail() {
  611. let obj = this
  612. getProductDetail(this.goodsid,{}).then(({data})=> {
  613. console.log(data,"putong+++++++++++++++")
  614. // console.log(data, 'goodInfo6666666666666');
  615. obj.imgList = data.slider_image; //保存轮播图
  616. obj.goodInfo.title = data.store_name; //保存商品名称
  617. obj.goodInfo.price = data.price; //保存商品展示价格
  618. obj.goodInfo.ot_price = data.ot_price; //保存商品市场价
  619. console.log(obj.goodInfo,'goodInfo++++++++++++++')
  620. // this.$forceUpdate()
  621. obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
  622. obj.product_type = data.product_type//保存商品类型
  623. //小程序商品详情图超出屏幕问题
  624. if (data.content.content !== null) {
  625. obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
  626. }
  627. //获取保存店铺详细信息
  628. getStoreDetail(data.mer_id).then(({ data }) => {
  629. console.log(data, 'shop data');
  630. obj.shopInfo = data;
  631. });
  632. // 获取商品属性
  633. obj.specList = data.attr; //保存分类列表
  634. if (data.attr.length != 0) {
  635. console.log("有好多属性")
  636. obj.many = 2;
  637. obj.specList = data.attr; //保存产品属性
  638. obj.productValue = data.sku; //保存属性值
  639. obj.specSelected = []; //初始化默认选择对象
  640. for (let i = 0; i < obj.specList.length; i++) {
  641. // 设置默认数据
  642. let attrValue = obj.specList[i].attr_value[0];
  643. attrValue.check = true;
  644. obj.specSelected.push(attrValue.attr);
  645. }
  646. let str = obj.specSelected.join(',');
  647. console.log(str, 'str');
  648. // 设置默认值
  649. obj.actionPrice = obj.productValue[str].price;
  650. obj.goodsNumberMax = obj.productValue[str].stock;
  651. obj.actionImage = obj.productValue[str].image;
  652. obj.uniqueId = obj.productValue[str].unique;
  653. obj.goodsStore = obj.productValue[str].stock;
  654. } else {
  655. console.log("zhiyou yige shuxing")
  656. obj.many = 1;
  657. obj.productValue = data.sku[''];
  658. console.log(obj.productValue,'obj.productValue11111111111')//保存分类查询数据
  659. obj.actionPrice =obj.productValue.price; //保存默认选中商品价格
  660. obj.actionImage = obj.productValue.image; //保存默认选中商品图片
  661. obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
  662. // obj.shopId = data.mer_id; //保存商店id
  663. obj.goodsStore = data.stock
  664. obj.uniqueId = obj.productValue.unique
  665. console.log(obj.uniqueId)
  666. }
  667. })
  668. }
  669. }
  670. };
  671. </script>
  672. <style lang="scss">
  673. /* 弹出层 */
  674. .popup {
  675. position: fixed;
  676. left: 0;
  677. top: 0;
  678. right: 0;
  679. bottom: 0;
  680. z-index: 99;
  681. &.show {
  682. display: block;
  683. .mask {
  684. animation: showPopup 0.2s linear both;
  685. }
  686. .layer {
  687. animation: showLayer 0.2s linear both;
  688. }
  689. }
  690. &.hide {
  691. .mask {
  692. animation: hidePopup 0.2s linear both;
  693. }
  694. .layer {
  695. animation: hideLayer 0.2s linear both;
  696. }
  697. }
  698. &.none {
  699. display: none;
  700. }
  701. .mask {
  702. position: fixed;
  703. top: 0;
  704. width: 100%;
  705. height: 100%;
  706. z-index: 1;
  707. background-color: rgba(0, 0, 0, 0.4);
  708. }
  709. .layer {
  710. position: fixed;
  711. z-index: 99;
  712. bottom: 0;
  713. width: 100%;
  714. min-height: 35vh;
  715. border-radius: 10rpx 10rpx 0 0;
  716. background-color: #fff;
  717. .btn {
  718. height: 66rpx;
  719. line-height: 66rpx;
  720. border-radius: 100rpx;
  721. background: #901b21;
  722. font-size: $font-base + 2rpx;
  723. color: #fff;
  724. margin: 30rpx auto 20rpx;
  725. }
  726. }
  727. @keyframes showPopup {
  728. 0% {
  729. opacity: 0;
  730. }
  731. 100% {
  732. opacity: 1;
  733. }
  734. }
  735. @keyframes hidePopup {
  736. 0% {
  737. opacity: 1;
  738. }
  739. 100% {
  740. opacity: 0;
  741. }
  742. }
  743. @keyframes showLayer {
  744. 0% {
  745. transform: translateY(120%);
  746. }
  747. 100% {
  748. transform: translateY(0%);
  749. }
  750. }
  751. @keyframes hideLayer {
  752. 0% {
  753. transform: translateY(0);
  754. }
  755. 100% {
  756. transform: translateY(120%);
  757. }
  758. }
  759. }
  760. /* 规格选择弹窗 */
  761. .attr-content {
  762. padding: 25rpx 30rpx;
  763. .a-t {
  764. display: flex;
  765. image {
  766. width: 170rpx;
  767. height: 170rpx;
  768. flex-shrink: 0;
  769. border-radius: 8rpx;
  770. }
  771. .right {
  772. display: flex;
  773. flex-direction: column;
  774. padding-left: 24rpx;
  775. font-size: $font-sm + 2rpx;
  776. color: $font-color-base;
  777. line-height: 42rpx;
  778. width: 75%;
  779. .price {
  780. font-size: $font-lg;
  781. color: #901b21;
  782. margin: 10rpx 0rpx;
  783. }
  784. .name {
  785. font-size: 32rpx;
  786. color: $font-color-dark;
  787. height: 50rpx;
  788. overflow: hidden;
  789. text-overflow: ellipsis;
  790. white-space: nowrap;
  791. display: block;
  792. }
  793. .selected-text {
  794. margin-right: 10rpx;
  795. }
  796. }
  797. }
  798. .attr-list {
  799. display: flex;
  800. flex-direction: column;
  801. font-size: $font-base + 2rpx;
  802. color: $font-color-base;
  803. padding-top: 30rpx;
  804. padding-left: 10rpx;
  805. }
  806. .item-list {
  807. padding: 20rpx 0 0;
  808. display: flex;
  809. flex-wrap: wrap;
  810. text {
  811. display: flex;
  812. align-items: center;
  813. justify-content: center;
  814. background: #eee;
  815. margin-right: 20rpx;
  816. margin-bottom: 20rpx;
  817. border-radius: 100rpx;
  818. min-width: 60rpx;
  819. height: 60rpx;
  820. padding: 0 20rpx;
  821. font-size: $font-base;
  822. color: $font-color-dark;
  823. }
  824. .selected {
  825. background: #ddffdf;
  826. color: $uni-color-primary;
  827. }
  828. }
  829. }
  830. //默认商品底部高度
  831. .goodsBottom {
  832. height: 160rpx;
  833. }
  834. page {
  835. background: #f0f0f0;
  836. }
  837. //秒杀、拼团底部高度
  838. .contentBottomHeight {
  839. height: 130rpx;
  840. }
  841. //默认商品底部高度
  842. .goodsBottom {
  843. height: 160rpx;
  844. }
  845. /deep/ .iconenter {
  846. font-size: $font-base + 2rpx;
  847. color: #888;
  848. }
  849. /deep/ .con_image {
  850. width: 130rpx;
  851. height: 130rpx;
  852. display: inline-block;
  853. padding: 15rpx;
  854. image {
  855. width: 100%;
  856. height: 100%;
  857. }
  858. }
  859. /* 商品详情中限制图片大小 */
  860. /deep/ .rich-img {
  861. width: 100% !important;
  862. height: auto;
  863. }
  864. .cho-num {
  865. margin: 20rpx 0;
  866. width: 750rpx;
  867. height: 83rpx;
  868. background: #ffffff;
  869. padding: 29rpx 24rpx 30rpx 25rpx;
  870. font-size: 26rpx;
  871. font-weight: 500;
  872. color: #606972;
  873. }
  874. .row {
  875. display: flex;
  876. align-items: center;
  877. position: relative;
  878. padding: 0 30rpx;
  879. height: 110rpx;
  880. background: #fff;
  881. .refund {
  882. font-size: 30rpx;
  883. color: $font-color-dark;
  884. padding-left: 128rpx;
  885. }
  886. .noRefund {
  887. font-size: 30rpx;
  888. color: $font-color-light;
  889. padding-left: 128rpx;
  890. }
  891. .tit {
  892. flex-shrink: 0;
  893. width: 120rpx;
  894. font-size: 30rpx;
  895. color: $font-color-dark;
  896. }
  897. .input {
  898. flex: 1;
  899. font-size: 30rpx;
  900. color: $font-color-dark;
  901. padding-left: 128rpx;
  902. &.payColor {
  903. color: $color-red;
  904. }
  905. }
  906. .iconlocation {
  907. font-size: 36rpx;
  908. color: $font-color-light;
  909. }
  910. }
  911. .shop-info {
  912. width: 750rpx;
  913. height: 140rpx;
  914. margin: 20rpx 0;
  915. padding: 28rpx 24rpx 22rpx 16rpx;
  916. background-color: #fff;
  917. display: flex;
  918. position: relative;
  919. .shop-logo {
  920. width: 90rpx;
  921. height: 90rpx;
  922. border-radius: 50%;
  923. // background-color: red;
  924. // overflow: hidden;
  925. image {
  926. width: 90rpx;
  927. height: 90rpx;
  928. }
  929. }
  930. .shop-base {
  931. padding-left: 15rpx;
  932. // width: 376rpx;
  933. width: 100%;
  934. font-size: 24rpx;
  935. font-weight: 500;
  936. color: #999999;
  937. line-height: 1;
  938. .base-name {
  939. padding-top: 14rpx;
  940. font-size: 30rpx;
  941. padding-bottom: 16rpx;
  942. font-weight: 500;
  943. color: #333333;
  944. }
  945. }
  946. .shop-dis {
  947. padding-top: 31rpx;
  948. position: absolute;
  949. font-size: 24rpx;
  950. font-weight: 500;
  951. color: #901b21;
  952. // line-height: 140rpx;
  953. right: 24rpx;
  954. image {
  955. padding-right: 5rpx;
  956. width: 21rpx;
  957. height: 21rpx;
  958. }
  959. }
  960. }
  961. .sckill-top {
  962. width: 750rpx;
  963. height: 165rpx;
  964. background-image: url(../../static/img/base-sckill.png);
  965. background-size: 100% 100%;
  966. position: relative;
  967. top: -40rpx;
  968. margin-bottom: -40rpx;
  969. display: flex;
  970. justify-content: space-between;
  971. .top-left {
  972. line-height: 1;
  973. .left-top {
  974. padding: 35rpx 0 23rpx 22rpx;
  975. font-size: 44rpx;
  976. font-weight: 500;
  977. color: #ffffff;
  978. line-height: 1;
  979. }
  980. .left-btm {
  981. line-height: 1;
  982. font-size: 30rpx;
  983. font-weight: 500;
  984. // text-decoration: line-through;
  985. color: #ffffff;
  986. .now-pri {
  987. display: inline-block;
  988. padding-right: 8rpx;
  989. font-size: 44rpx;
  990. font-weight: 800;
  991. color: #ffffff;
  992. }
  993. .old-pri {
  994. text-decoration: line-through;
  995. }
  996. }
  997. }
  998. .top-right {
  999. padding: 67rpx 20rpx 18rpx 0;
  1000. .right-top {
  1001. font-size: 22rpx;
  1002. font-weight: 400;
  1003. color: #ffffff;
  1004. line-height: 1;
  1005. padding-bottom: 8rpx;
  1006. }
  1007. }
  1008. }
  1009. .good-title {
  1010. background-color: #fff;
  1011. // height: 142rpx;
  1012. padding: 24rpx 19rpx 24rpx 34rpx;
  1013. line-height: 1.5;
  1014. font-size: 36rpx;
  1015. font-weight: 800;
  1016. color: #333333;
  1017. }
  1018. .introduce-section {
  1019. position: relative;
  1020. background: #fff;
  1021. padding: 35rpx 0rpx;
  1022. padding-left: 20rpx;
  1023. .title {
  1024. font-size: 32rpx;
  1025. color: $font-color-dark;
  1026. padding-right: 34rpx;
  1027. .tip-o {
  1028. color: #ff3334;
  1029. padding-left: 15rpx;
  1030. }
  1031. }
  1032. .shareDate {
  1033. position: absolute;
  1034. top: 25rpx;
  1035. right: 10rpx;
  1036. font-size: 26rpx;
  1037. color: #3d3f46;
  1038. border-radius: 15rpx;
  1039. background-color: #ffffff;
  1040. height: 60rpx;
  1041. line-height: 60rpx;
  1042. &::after {
  1043. border: none;
  1044. }
  1045. }
  1046. .share-img {
  1047. width: 30rpx;
  1048. height: 30rpx;
  1049. position: relative;
  1050. top: 5rpx;
  1051. left: 0;
  1052. margin-right: 10rpx;
  1053. }
  1054. .info {
  1055. color: #999999;
  1056. font-size: 26rpx;
  1057. padding-bottom: 15rpx;
  1058. }
  1059. .progress-box {
  1060. width: 260rpx;
  1061. position: relative;
  1062. margin-top: 15rpx;
  1063. line-height: 10px;
  1064. .number {
  1065. font-size: 17rpx;
  1066. position: absolute;
  1067. z-index: 999;
  1068. top: 3rpx;
  1069. left: 15rpx;
  1070. color: #ffffff;
  1071. }
  1072. }
  1073. .price-box {
  1074. display: flex;
  1075. align-items: baseline;
  1076. height: 64rpx;
  1077. padding: 10rpx 0;
  1078. font-size: 27rpx;
  1079. color: #EF041F;
  1080. }
  1081. .price {
  1082. font-size: $font-lg + 6rpx;
  1083. .text {
  1084. padding-left: 5rpx;
  1085. color: #b0b0b0;
  1086. font-size: 22rpx !important;
  1087. }
  1088. }
  1089. .price-green {
  1090. color: #2dbd59;
  1091. font-size: 28rpx !important;
  1092. text {
  1093. background: #2dbd59;
  1094. color: #ffffff;
  1095. padding: 0rpx 10rpx;
  1096. border-radius: 5rpx;
  1097. font-size: 22rpx !important;
  1098. margin-left: 15rpx;
  1099. }
  1100. }
  1101. .m-price {
  1102. margin: 0 12rpx;
  1103. color: $font-color-light;
  1104. text-decoration: line-through;
  1105. margin-left: 25rpx;
  1106. font-size: 24rpx;
  1107. }
  1108. }
  1109. </style>