product.vue 29 KB

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