product.vue 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  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. console.log(type,'type+++++++++++++++++++++')
  336. let obj = this;
  337. obj.specClass = 'show';
  338. obj.type = type;
  339. },
  340. //规格弹窗开关
  341. toggleSpec(str) {
  342. if (this.specClass === 'show') {
  343. this.specClass = 'hide';
  344. setTimeout(() => {
  345. this.specClass = 'none';
  346. }, 250);
  347. } else if (this.specClass === 'none') {
  348. this.specClass = 'show';
  349. }
  350. // 保存当前购买类型
  351. this.type = str;
  352. },
  353. //领取优惠券
  354. Getcoupon() {
  355. uni.navigateTo({
  356. url: '/pages/coupon/getcoupon'
  357. });
  358. },
  359. //详情页
  360. navToDetailPage(item) {
  361. let id = item.id;
  362. uni.navigateTo({
  363. url: '/pages/product/product?id=' + id
  364. });
  365. },
  366. // 跳转页面
  367. navTo(url) {
  368. uni.navigateTo({
  369. url
  370. });
  371. },
  372. //加入购物车
  373. Addcar(item) {
  374. let obj = this;
  375. console.log('加入购物车', obj.goodsNumber);
  376. cartAdd({
  377. // cartNum: '1', //商品数量
  378. cartNum: obj.goodsNumber,
  379. uniqueId: '', //商品标签
  380. new: 0, //商品是否新增加到购物车1为不加入0为加入
  381. mer_id: '',
  382. productId: item.id //商品编号
  383. })
  384. .then(function(e) {
  385. uni.showToast({
  386. title: '成功加入购物车',
  387. type: 'top',
  388. duration: 500,
  389. icon: 'none'
  390. });
  391. obj.goodsDetail();
  392. })
  393. .catch(e => {
  394. console.log(e);
  395. });
  396. },
  397. goodsDetail() {
  398. let obj = this;
  399. // 获取普通商品信息
  400. goodsDetail({}, this.goodsid).then(function({ data }) {
  401. obj.list = data;
  402. console.log(data);
  403. obj.good_list = data.good_list; //保存猜你喜欢列表
  404. obj.reply = data.reply; //保存评论列表
  405. let goods = data.storeInfo;
  406. obj.goodsObjact = goods;
  407. console.log(obj.goodsObjact, '++++++++++++++');
  408. if (obj.goodsObjact.description != null) {
  409. obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
  410. } //小程序商品详情图超出屏幕问题
  411. obj.imgList = goods.slider_image; //保存轮播图
  412. obj.specList = data.productAttr; //保存分类列表
  413. if (Array.isArray(data.productValue) != true) {
  414. obj.many = 2;
  415. obj.specList = data.productAttr; //保存产品属性
  416. obj.productValue = data.productValue; //保存属性值
  417. obj.specSelected = []; //初始化默认选择对象
  418. for (let i = 0; i < obj.specList.length; i++) {
  419. // 设置默认数据
  420. let attrValue = obj.specList[i].attr_value[0];
  421. attrValue.check = true;
  422. obj.specSelected.push(attrValue.attr);
  423. }
  424. let str = obj.specSelected.join(',');
  425. console.log(str, 'str');
  426. // 设置默认值
  427. obj.actionPrice = obj.productValue[str].price;
  428. obj.goodsNumberMax = obj.productValue[str].stock;
  429. obj.actionImage = obj.productValue[str].image;
  430. obj.uniqueId = obj.productValue[str].unique;
  431. obj.goodsStore = obj.productValue[str].quota;
  432. } else {
  433. obj.many = 1;
  434. }
  435. obj.productValue = data.productValue; //保存分类查询数据
  436. obj.actionPrice = goods.price; //保存默认选中商品价格
  437. obj.actionImage = goods.image_base; //保存默认选中商品图片
  438. obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
  439. obj.shopId = data.mer_id; //保存商店id
  440. });
  441. },
  442. getGoodInfo() {
  443. let obj = this;
  444. // 获取秒杀商品信息
  445. seckillGoods({}, this.goodsid).then(function({ data }) {
  446. console.log(data);
  447. obj.list = data;
  448. obj.good_list = data.good_list; //保存猜你喜欢列表
  449. obj.reply = data.reply; //保存评论列表
  450. let goods = data.storeInfo;
  451. obj.goodsObjact = goods;
  452. obj.goodsObjact.title = goods.title;
  453. obj.stopTimes = timeComputed(obj.list.isSeckillEnd.stop * 1000);
  454. console.log(obj.stopTimes, 'dddddddddd');
  455. if (obj.goodsObjact.description != null) {
  456. obj.description = obj.goodsObjact.description.replace(/\<img/gi, '<img class="rich-img"');
  457. } //小程序商品详情图超出屏幕问题
  458. obj.imgList = goods.images; //保存轮播图
  459. obj.specList = data.productAttr; //保存分类列表
  460. if (Array.isArray(data.productValue) != true) {
  461. obj.many = 2;
  462. obj.specList = data.productAttr; //保存产品属性
  463. obj.productValue = data.productValue; //保存属性值
  464. console.log(obj.productValue, 'obj.productValue++++++++');
  465. obj.specSelected = []; //初始化默认选择对象
  466. for (let i = 0; i < obj.specList.length; i++) {
  467. // 设置默认数据
  468. let attrValue = obj.specList[i].attr_value[0];
  469. attrValue.check = true;
  470. obj.specSelected.push(attrValue.attr);
  471. }
  472. let str = obj.specSelected.join(',');
  473. console.log(str, 'str');
  474. // 设置默认值
  475. obj.actionPrice = obj.productValue[str].price;
  476. obj.goodsNumberMax = obj.productValue[str].stock;
  477. obj.actionImage = obj.productValue[str].image;
  478. obj.uniqueId = obj.productValue[str].unique;
  479. console.log(obj.uniqueId, 'obj.uniqueId+++默认');
  480. obj.goodsStore = obj.productValue[str].quota;
  481. } else {
  482. obj.many = 1;
  483. }
  484. obj.productValue = data.productValue; //保存分类查询数据
  485. obj.actionPrice = goods.price; //保存默认选中商品价格
  486. obj.actionImage = goods.image_base; //保存默认选中商品图片
  487. obj.goodsNumberMax = goods.stock; //保存默认选中最大可购买商品数量
  488. obj.shopId = data.mer_id; //保存商店id
  489. });
  490. },
  491. // 立即购买
  492. buy() {
  493. let obj = this;
  494. // 创建传值对象
  495. let goodId = obj.goodsid;
  496. console.log('添加的数量', obj.goodsNumber);
  497. // let data = {
  498. // cartNum: obj.goodsNumber, //商品数量
  499. // new: 1,
  500. // productId: goodId, //商品编号
  501. // uniqueId: obj.uniqueId
  502. // };
  503. let is_new = 0
  504. if(obj.type == 1){
  505. is_new = 1
  506. }
  507. let data = {
  508. product_id: goodId,
  509. product_attr_unique: obj.uniqueId,
  510. cart_num: obj.goodsNumber,
  511. product_type: obj.product_type,
  512. is_new: is_new
  513. }
  514. console.log("立即购买++++++",data);
  515. cartAdd(data)
  516. .then(function(e) {
  517. console.log(e,"立即购买++++++fanhui")
  518. let da = e.data;
  519. if (obj.type == 1) {
  520. // 跳转到支付页
  521. uni.navigateTo({
  522. url: '/pages/order/createOrder?id=' + da.cart_id
  523. });
  524. }
  525. if (obj.type == 2) {
  526. uni.showToast({
  527. title: '成功加入购物车',
  528. type: 'top',
  529. duration: 2000,
  530. icon: 'none'
  531. });
  532. obj.getProductDetail();
  533. }
  534. obj.toggleSpec();
  535. })
  536. .catch(e => {
  537. console.log(e);
  538. });
  539. },
  540. // 阻止触发上级事件
  541. stopPrevent() {},
  542. bindChange(e) {
  543. this.goodsNumber = this.choNum[e.detail.value] * 1;
  544. console.log(this.goodsNumber);
  545. },
  546. numberChange(e) {
  547. //购买数量
  548. this.chooseGoodsNumber = e.number;
  549. this.goodsNumber = e.number;
  550. },
  551. // getTime() {
  552. // let start = new data()
  553. // }
  554. // 获取秒杀商品信息
  555. getGoodsDetails() {
  556. let obj = this;
  557. getSeckillProductDetail({}, this.goodsid).then(({ data }) => {
  558. console.log(data, 'goodInfo6666666666666');
  559. obj.imgList = data.slider_image; //保存轮播图
  560. obj.sckillGoodInfo.title = data.store_name; //保存商品名称
  561. obj.sckillGoodInfo.price = data.price; //保存商品展示价格
  562. obj.sckillGoodInfo.ot_price = data.ot_price; //保存商品市场价
  563. obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
  564. obj.product_type = data.product_type//保存商品类型
  565. //小程序商品详情图超出屏幕问题
  566. if (data.content.content !== null) {
  567. obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
  568. }
  569. //获取保存店铺详细信息
  570. getStoreDetail(data.mer_id).then(({ data }) => {
  571. console.log(data, 'shop data');
  572. obj.shopInfo = data;
  573. });
  574. // 获取商品属性
  575. obj.specList = data.attr; //保存分类列表
  576. if (data.attr.length != 0) {
  577. console.log("有好多属性")
  578. obj.many = 2;
  579. obj.specList = data.attr; //保存产品属性
  580. obj.productValue = data.sku; //保存属性值
  581. obj.specSelected = []; //初始化默认选择对象
  582. for (let i = 0; i < obj.specList.length; i++) {
  583. // 设置默认数据
  584. let attrValue = obj.specList[i].attr_value[0];
  585. attrValue.check = true;
  586. obj.specSelected.push(attrValue.attr);
  587. }
  588. let str = obj.specSelected.join(',');
  589. console.log(str, 'str');
  590. // 设置默认值
  591. obj.actionPrice = obj.productValue[str].price;
  592. obj.goodsNumberMax = obj.productValue[str].stock;
  593. obj.actionImage = obj.productValue[str].image;
  594. obj.uniqueId = obj.productValue[str].unique;
  595. obj.goodsStore = obj.productValue[str].stock;
  596. } else {
  597. console.log("zhiyou yige shuxing")
  598. obj.many = 1;
  599. obj.productValue = data.sku[''];
  600. console.log(obj.productValue,'obj.productValue11111111111')//保存分类查询数据
  601. obj.actionPrice =obj.productValue.price; //保存默认选中商品价格
  602. obj.actionImage = obj.productValue.image; //保存默认选中商品图片
  603. obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
  604. // obj.shopId = data.mer_id; //保存商店id
  605. obj.goodsStore = data.stock
  606. obj.uniqueId = obj.productValue.unique
  607. console.log(obj.uniqueId)
  608. }
  609. });
  610. },
  611. getProductDetail() {
  612. let obj = this
  613. getProductDetail(this.goodsid,{}).then(({data})=> {
  614. console.log(data,"putong+++++++++++++++")
  615. // console.log(data, 'goodInfo6666666666666');
  616. obj.imgList = data.slider_image; //保存轮播图
  617. obj.goodInfo.title = data.store_name; //保存商品名称
  618. obj.goodInfo.price = data.price; //保存商品展示价格
  619. obj.goodInfo.ot_price = data.ot_price; //保存商品市场价
  620. console.log(obj.goodInfo,'goodInfo++++++++++++++')
  621. // this.$forceUpdate()
  622. obj.stopTimes = timeComputed(data.stop * 1000); //设置结束时间
  623. obj.product_type = data.product_type//保存商品类型
  624. //小程序商品详情图超出屏幕问题
  625. if (data.content.content !== null) {
  626. obj.description = data.content.content.replace(/\<img/gi, '<img class="rich-img"');
  627. }
  628. //获取保存店铺详细信息
  629. getStoreDetail(data.mer_id).then(({ data }) => {
  630. console.log(data, 'shop data');
  631. obj.shopInfo = data;
  632. });
  633. // 获取商品属性
  634. obj.specList = data.attr; //保存分类列表
  635. if (data.attr.length != 0) {
  636. console.log("有好多属性")
  637. obj.many = 2;
  638. obj.specList = data.attr; //保存产品属性
  639. obj.productValue = data.sku; //保存属性值
  640. obj.specSelected = []; //初始化默认选择对象
  641. for (let i = 0; i < obj.specList.length; i++) {
  642. // 设置默认数据
  643. let attrValue = obj.specList[i].attr_value[0];
  644. attrValue.check = true;
  645. obj.specSelected.push(attrValue.attr);
  646. }
  647. let str = obj.specSelected.join(',');
  648. console.log(str, 'str');
  649. // 设置默认值
  650. obj.actionPrice = obj.productValue[str].price;
  651. obj.goodsNumberMax = obj.productValue[str].stock;
  652. obj.actionImage = obj.productValue[str].image;
  653. obj.uniqueId = obj.productValue[str].unique;
  654. obj.goodsStore = obj.productValue[str].stock;
  655. } else {
  656. console.log("zhiyou yige shuxing")
  657. obj.many = 1;
  658. obj.productValue = data.sku[''];
  659. console.log(obj.productValue,'obj.productValue11111111111')//保存分类查询数据
  660. obj.actionPrice =obj.productValue.price; //保存默认选中商品价格
  661. obj.actionImage = obj.productValue.image; //保存默认选中商品图片
  662. obj.goodsNumberMax = data.stock; //保存默认选中最大可购买商品数量
  663. // obj.shopId = data.mer_id; //保存商店id
  664. obj.goodsStore = data.stock
  665. obj.uniqueId = obj.productValue.unique
  666. console.log(obj.uniqueId)
  667. }
  668. })
  669. }
  670. }
  671. };
  672. </script>
  673. <style lang="scss">
  674. /* 弹出层 */
  675. .popup {
  676. position: fixed;
  677. left: 0;
  678. top: 0;
  679. right: 0;
  680. bottom: 0;
  681. z-index: 99;
  682. &.show {
  683. display: block;
  684. .mask {
  685. animation: showPopup 0.2s linear both;
  686. }
  687. .layer {
  688. animation: showLayer 0.2s linear both;
  689. }
  690. }
  691. &.hide {
  692. .mask {
  693. animation: hidePopup 0.2s linear both;
  694. }
  695. .layer {
  696. animation: hideLayer 0.2s linear both;
  697. }
  698. }
  699. &.none {
  700. display: none;
  701. }
  702. .mask {
  703. position: fixed;
  704. top: 0;
  705. width: 100%;
  706. height: 100%;
  707. z-index: 1;
  708. background-color: rgba(0, 0, 0, 0.4);
  709. }
  710. .layer {
  711. position: fixed;
  712. z-index: 99;
  713. bottom: 0;
  714. width: 100%;
  715. min-height: 35vh;
  716. border-radius: 10rpx 10rpx 0 0;
  717. background-color: #fff;
  718. .btn {
  719. height: 66rpx;
  720. line-height: 66rpx;
  721. border-radius: 100rpx;
  722. background: #901b21;
  723. font-size: $font-base + 2rpx;
  724. color: #fff;
  725. margin: 30rpx auto 20rpx;
  726. }
  727. }
  728. @keyframes showPopup {
  729. 0% {
  730. opacity: 0;
  731. }
  732. 100% {
  733. opacity: 1;
  734. }
  735. }
  736. @keyframes hidePopup {
  737. 0% {
  738. opacity: 1;
  739. }
  740. 100% {
  741. opacity: 0;
  742. }
  743. }
  744. @keyframes showLayer {
  745. 0% {
  746. transform: translateY(120%);
  747. }
  748. 100% {
  749. transform: translateY(0%);
  750. }
  751. }
  752. @keyframes hideLayer {
  753. 0% {
  754. transform: translateY(0);
  755. }
  756. 100% {
  757. transform: translateY(120%);
  758. }
  759. }
  760. }
  761. /* 规格选择弹窗 */
  762. .attr-content {
  763. padding: 25rpx 30rpx;
  764. .a-t {
  765. display: flex;
  766. image {
  767. width: 170rpx;
  768. height: 170rpx;
  769. flex-shrink: 0;
  770. border-radius: 8rpx;
  771. }
  772. .right {
  773. display: flex;
  774. flex-direction: column;
  775. padding-left: 24rpx;
  776. font-size: $font-sm + 2rpx;
  777. color: $font-color-base;
  778. line-height: 42rpx;
  779. width: 75%;
  780. .price {
  781. font-size: $font-lg;
  782. color: #901b21;
  783. margin: 10rpx 0rpx;
  784. }
  785. .name {
  786. font-size: 32rpx;
  787. color: $font-color-dark;
  788. height: 50rpx;
  789. overflow: hidden;
  790. text-overflow: ellipsis;
  791. white-space: nowrap;
  792. display: block;
  793. }
  794. .selected-text {
  795. margin-right: 10rpx;
  796. }
  797. }
  798. }
  799. .attr-list {
  800. display: flex;
  801. flex-direction: column;
  802. font-size: $font-base + 2rpx;
  803. color: $font-color-base;
  804. padding-top: 30rpx;
  805. padding-left: 10rpx;
  806. }
  807. .item-list {
  808. padding: 20rpx 0 0;
  809. display: flex;
  810. flex-wrap: wrap;
  811. text {
  812. display: flex;
  813. align-items: center;
  814. justify-content: center;
  815. background: #eee;
  816. margin-right: 20rpx;
  817. margin-bottom: 20rpx;
  818. border-radius: 100rpx;
  819. min-width: 60rpx;
  820. height: 60rpx;
  821. padding: 0 20rpx;
  822. font-size: $font-base;
  823. color: $font-color-dark;
  824. }
  825. .selected {
  826. background: #ddffdf;
  827. color: $uni-color-primary;
  828. }
  829. }
  830. }
  831. //默认商品底部高度
  832. .goodsBottom {
  833. height: 160rpx;
  834. }
  835. page {
  836. background: #f0f0f0;
  837. }
  838. //秒杀、拼团底部高度
  839. .contentBottomHeight {
  840. height: 130rpx;
  841. }
  842. //默认商品底部高度
  843. .goodsBottom {
  844. height: 160rpx;
  845. }
  846. /deep/ .iconenter {
  847. font-size: $font-base + 2rpx;
  848. color: #888;
  849. }
  850. /deep/ .con_image {
  851. width: 130rpx;
  852. height: 130rpx;
  853. display: inline-block;
  854. padding: 15rpx;
  855. image {
  856. width: 100%;
  857. height: 100%;
  858. }
  859. }
  860. /* 商品详情中限制图片大小 */
  861. /deep/ .rich-img {
  862. width: 100% !important;
  863. height: auto;
  864. }
  865. .cho-num {
  866. margin: 20rpx 0;
  867. width: 750rpx;
  868. height: 83rpx;
  869. background: #ffffff;
  870. padding: 29rpx 24rpx 30rpx 25rpx;
  871. font-size: 26rpx;
  872. font-weight: 500;
  873. color: #606972;
  874. }
  875. .row {
  876. display: flex;
  877. align-items: center;
  878. position: relative;
  879. padding: 0 30rpx;
  880. height: 110rpx;
  881. background: #fff;
  882. .refund {
  883. font-size: 30rpx;
  884. color: $font-color-dark;
  885. padding-left: 128rpx;
  886. }
  887. .noRefund {
  888. font-size: 30rpx;
  889. color: $font-color-light;
  890. padding-left: 128rpx;
  891. }
  892. .tit {
  893. flex-shrink: 0;
  894. width: 120rpx;
  895. font-size: 30rpx;
  896. color: $font-color-dark;
  897. }
  898. .input {
  899. flex: 1;
  900. font-size: 30rpx;
  901. color: $font-color-dark;
  902. padding-left: 128rpx;
  903. &.payColor {
  904. color: $color-red;
  905. }
  906. }
  907. .iconlocation {
  908. font-size: 36rpx;
  909. color: $font-color-light;
  910. }
  911. }
  912. .shop-info {
  913. width: 750rpx;
  914. height: 140rpx;
  915. margin: 20rpx 0;
  916. padding: 28rpx 24rpx 22rpx 16rpx;
  917. background-color: #fff;
  918. display: flex;
  919. position: relative;
  920. .shop-logo {
  921. width: 90rpx;
  922. height: 90rpx;
  923. border-radius: 50%;
  924. // background-color: red;
  925. // overflow: hidden;
  926. image {
  927. width: 90rpx;
  928. height: 90rpx;
  929. }
  930. }
  931. .shop-base {
  932. padding-left: 15rpx;
  933. // width: 376rpx;
  934. width: 100%;
  935. font-size: 24rpx;
  936. font-weight: 500;
  937. color: #999999;
  938. line-height: 1;
  939. .base-name {
  940. padding-top: 14rpx;
  941. font-size: 30rpx;
  942. padding-bottom: 16rpx;
  943. font-weight: 500;
  944. color: #333333;
  945. }
  946. }
  947. .shop-dis {
  948. padding-top: 31rpx;
  949. position: absolute;
  950. font-size: 24rpx;
  951. font-weight: 500;
  952. color: #901b21;
  953. // line-height: 140rpx;
  954. right: 24rpx;
  955. image {
  956. padding-right: 5rpx;
  957. width: 21rpx;
  958. height: 21rpx;
  959. }
  960. }
  961. }
  962. .sckill-top {
  963. width: 750rpx;
  964. height: 165rpx;
  965. background-image: url(../../static/img/base-sckill.png);
  966. background-size: 100% 100%;
  967. position: relative;
  968. top: -40rpx;
  969. margin-bottom: -40rpx;
  970. display: flex;
  971. justify-content: space-between;
  972. .top-left {
  973. line-height: 1;
  974. .left-top {
  975. padding: 35rpx 0 23rpx 22rpx;
  976. font-size: 44rpx;
  977. font-weight: 500;
  978. color: #ffffff;
  979. line-height: 1;
  980. }
  981. .left-btm {
  982. line-height: 1;
  983. font-size: 30rpx;
  984. font-weight: 500;
  985. // text-decoration: line-through;
  986. color: #ffffff;
  987. .now-pri {
  988. display: inline-block;
  989. padding-right: 8rpx;
  990. font-size: 44rpx;
  991. font-weight: 800;
  992. color: #ffffff;
  993. }
  994. .old-pri {
  995. text-decoration: line-through;
  996. }
  997. }
  998. }
  999. .top-right {
  1000. padding: 67rpx 20rpx 18rpx 0;
  1001. .right-top {
  1002. font-size: 22rpx;
  1003. font-weight: 400;
  1004. color: #ffffff;
  1005. line-height: 1;
  1006. padding-bottom: 8rpx;
  1007. }
  1008. }
  1009. }
  1010. .good-title {
  1011. background-color: #fff;
  1012. // height: 142rpx;
  1013. padding: 24rpx 19rpx 24rpx 34rpx;
  1014. line-height: 1.5;
  1015. font-size: 36rpx;
  1016. font-weight: 800;
  1017. color: #333333;
  1018. }
  1019. .introduce-section {
  1020. position: relative;
  1021. background: #fff;
  1022. padding: 35rpx 0rpx;
  1023. padding-left: 20rpx;
  1024. .title {
  1025. font-size: 32rpx;
  1026. color: $font-color-dark;
  1027. padding-right: 34rpx;
  1028. .tip-o {
  1029. color: #ff3334;
  1030. padding-left: 15rpx;
  1031. }
  1032. }
  1033. .shareDate {
  1034. position: absolute;
  1035. top: 25rpx;
  1036. right: 10rpx;
  1037. font-size: 26rpx;
  1038. color: #3d3f46;
  1039. border-radius: 15rpx;
  1040. background-color: #ffffff;
  1041. height: 60rpx;
  1042. line-height: 60rpx;
  1043. &::after {
  1044. border: none;
  1045. }
  1046. }
  1047. .share-img {
  1048. width: 30rpx;
  1049. height: 30rpx;
  1050. position: relative;
  1051. top: 5rpx;
  1052. left: 0;
  1053. margin-right: 10rpx;
  1054. }
  1055. .info {
  1056. color: #999999;
  1057. font-size: 26rpx;
  1058. padding-bottom: 15rpx;
  1059. }
  1060. .progress-box {
  1061. width: 260rpx;
  1062. position: relative;
  1063. margin-top: 15rpx;
  1064. line-height: 10px;
  1065. .number {
  1066. font-size: 17rpx;
  1067. position: absolute;
  1068. z-index: 999;
  1069. top: 3rpx;
  1070. left: 15rpx;
  1071. color: #ffffff;
  1072. }
  1073. }
  1074. .price-box {
  1075. display: flex;
  1076. align-items: baseline;
  1077. height: 64rpx;
  1078. padding: 10rpx 0;
  1079. font-size: 27rpx;
  1080. color: #EF041F;
  1081. }
  1082. .price {
  1083. font-size: $font-lg + 6rpx;
  1084. .text {
  1085. padding-left: 5rpx;
  1086. color: #b0b0b0;
  1087. font-size: 22rpx !important;
  1088. }
  1089. }
  1090. .price-green {
  1091. color: #2dbd59;
  1092. font-size: 28rpx !important;
  1093. text {
  1094. background: #2dbd59;
  1095. color: #ffffff;
  1096. padding: 0rpx 10rpx;
  1097. border-radius: 5rpx;
  1098. font-size: 22rpx !important;
  1099. margin-left: 15rpx;
  1100. }
  1101. }
  1102. .m-price {
  1103. margin: 0 12rpx;
  1104. color: $font-color-light;
  1105. text-decoration: line-through;
  1106. margin-left: 25rpx;
  1107. font-size: 24rpx;
  1108. }
  1109. }
  1110. </style>