product.vue 29 KB

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