product.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169
  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. if(obj.userInfo) {
  535. if(obj.userInfo.store_order == 0) {
  536. uni.showModal({
  537. title: '提示',
  538. content:'您未报单,请前往报单页面',
  539. success() {
  540. uni.switchTab({
  541. url:'/pages/index/index'
  542. })
  543. }
  544. })
  545. return
  546. }
  547. }
  548. let data = {
  549. productId: obj.goodsid, //商品编号
  550. cartNum: obj.goodsNumber, //商品数量
  551. uniqueId: obj.uniqueId, //分类编号
  552. new: 1,
  553. secKillId: '',
  554. integralId: '',
  555. };
  556. console.log(obj.goodsType, 'obj.goodsType77777777777777777777')
  557. if(obj.type == 2) {
  558. data.new = 0
  559. }
  560. cartAdd(data)
  561. .then(function(e) {
  562. let da = e.data;
  563. if (obj.type == 1) {
  564. // 跳转到支付页
  565. console.log(obj.goodsType, 'this.goodsType456444444444444444')
  566. uni.navigateTo({
  567. url: '/pages/order/createOrder?id=' + da.cartId + '&goodsType=' + obj.goodsType
  568. });
  569. }
  570. if (obj.type == 2) {
  571. uni.showToast({
  572. title: '成功加入购物车',
  573. type: 'top',
  574. duration: 2000,
  575. icon: 'none'
  576. });
  577. obj.goodsDetail();
  578. }
  579. obj.toggleSpec()
  580. })
  581. .catch(e => {
  582. console.log(e);
  583. });
  584. },
  585. // 阻止触发上级事件
  586. stopPrevent() {},
  587. //选择数量
  588. numberChange(e) {
  589. console.log(e)
  590. this.goodsNumber = e.number
  591. },
  592. callf() {
  593. this.show = true;
  594. },
  595. onTap() {
  596. console.log(this.callf);
  597. if (!this.callf) return;
  598. this.close();
  599. },
  600. close() {
  601. this.show = false;
  602. },
  603. closes() {
  604. this.specClass = 'none';
  605. },
  606. }
  607. };
  608. </script>
  609. <style lang="scss" scoped>
  610. /* 弹出层 */
  611. .popup {
  612. position: fixed;
  613. left: 0;
  614. top: 0;
  615. right: 0;
  616. bottom: 0;
  617. z-index: 99;
  618. &.show {
  619. display: block;
  620. .mask {
  621. animation: showPopup 0.2s linear both;
  622. }
  623. .layer {
  624. animation: showLayer 0.2s linear both;
  625. }
  626. }
  627. &.hide {
  628. .mask {
  629. animation: hidePopup 0.2s linear both;
  630. }
  631. .layer {
  632. animation: hideLayer 0.2s linear both;
  633. }
  634. }
  635. &.none {
  636. display: none;
  637. }
  638. .mask {
  639. position: fixed;
  640. top: 0;
  641. width: 100%;
  642. height: 100%;
  643. z-index: 1;
  644. background-color: rgba(0, 0, 0, 0.4);
  645. }
  646. .layer {
  647. position: fixed;
  648. z-index: 99;
  649. bottom: 0;
  650. width: 100%;
  651. min-height: 20vh;
  652. border-radius: 10rpx 10rpx 0 0;
  653. background-color: #fff;
  654. .btn {
  655. height: 66rpx;
  656. line-height: 66rpx;
  657. border-radius: 100rpx;
  658. background: #6EAB4E;
  659. font-size: $font-base + 2rpx;
  660. color: #fff;
  661. margin: 30rpx auto 20rpx;
  662. }
  663. }
  664. @keyframes showPopup {
  665. 0% {
  666. opacity: 0;
  667. }
  668. 100% {
  669. opacity: 1;
  670. }
  671. }
  672. @keyframes hidePopup {
  673. 0% {
  674. opacity: 1;
  675. }
  676. 100% {
  677. opacity: 0;
  678. }
  679. }
  680. @keyframes showLayer {
  681. 0% {
  682. transform: translateY(120%);
  683. }
  684. 100% {
  685. transform: translateY(0%);
  686. }
  687. }
  688. @keyframes hideLayer {
  689. 0% {
  690. transform: translateY(0);
  691. }
  692. 100% {
  693. transform: translateY(120%);
  694. }
  695. }
  696. }
  697. /* 规格选择弹窗 */
  698. .attr-content {
  699. padding: 25rpx 30rpx;
  700. .a-t {
  701. display: flex;
  702. image {
  703. width: 170rpx;
  704. height: 170rpx;
  705. flex-shrink: 0;
  706. border-radius: 8rpx;
  707. background-color: #eee;
  708. }
  709. .right {
  710. display: flex;
  711. flex-direction: column;
  712. padding-left: 24rpx;
  713. font-size: $font-sm + 2rpx;
  714. color: $font-color-base;
  715. line-height: 42rpx;
  716. width: 75%;
  717. position: relative;
  718. .right-img {
  719. width: 37rpx;
  720. height: 37rpx;
  721. position: absolute;
  722. right: 0;
  723. top: 20rpx;
  724. // background-color: red;
  725. }
  726. .price {
  727. position: absolute;
  728. bottom: 0;
  729. font-size: $font-lg;
  730. color: $uni-color-primary;
  731. margin: 10rpx 0rpx;
  732. font-size: 60rpx;
  733. font-family: PingFang SC;
  734. font-weight: bold;
  735. color: #ef041f;
  736. text {
  737. font-size: 30rpx;
  738. }
  739. }
  740. .name {
  741. width: 350rpx;
  742. font-size: 32rpx;
  743. color: $font-color-dark;
  744. height: 50rpx;
  745. overflow: hidden;
  746. text-overflow: ellipsis;
  747. white-space: nowrap;
  748. display: block;
  749. font-size: 30rpx;
  750. font-family: PingFang SC;
  751. font-weight: bold;
  752. color: #1d2023;
  753. }
  754. .selected-text {
  755. margin-right: 10rpx;
  756. }
  757. }
  758. }
  759. .attr-list {
  760. display: flex;
  761. flex-direction: column;
  762. font-size: $font-base + 2rpx;
  763. color: $font-color-base;
  764. padding-top: 30rpx;
  765. padding-left: 10rpx;
  766. }
  767. .item-list {
  768. padding: 20rpx 0 0;
  769. display: flex;
  770. flex-wrap: wrap;
  771. text {
  772. display: flex;
  773. align-items: center;
  774. justify-content: center;
  775. background: #eee;
  776. margin-right: 20rpx;
  777. margin-bottom: 20rpx;
  778. border-radius: 10rpx;
  779. min-width: 60rpx;
  780. height: 60rpx;
  781. padding: 0 20rpx;
  782. font-size: $font-base;
  783. color: $font-color-dark;
  784. }
  785. .selected {
  786. background: #fceff1;
  787. color: #f35768;
  788. border: 1px solid #f35768;
  789. }
  790. }
  791. }
  792. //默认商品底部高度
  793. .goodsBottom {
  794. height: 160rpx;
  795. }
  796. page {
  797. background: #f0f0f0;
  798. }
  799. //秒杀、拼团底部高度
  800. .contentBottomHeight {
  801. height: 120rpx;
  802. }
  803. //默认商品底部高度
  804. .goodsBottom {
  805. height: 160rpx;
  806. }
  807. /deep/ .iconenter {
  808. font-size: $font-base + 2rpx;
  809. color: #888;
  810. }
  811. /deep/ .con_image {
  812. width: 130rpx;
  813. height: 130rpx;
  814. display: inline-block;
  815. padding: 15rpx;
  816. image {
  817. width: 100%;
  818. height: 100%;
  819. }
  820. }
  821. /* 商品详情中限制图片大小 */
  822. /deep/ .rich-img {
  823. width: 100% !important;
  824. height: auto;
  825. }
  826. .cho-num {
  827. margin: 20rpx 0;
  828. width: 750rpx;
  829. height: 83rpx;
  830. background: #ffffff;
  831. padding: 29rpx 24rpx 30rpx 25rpx;
  832. font-size: 26rpx;
  833. font-weight: 500;
  834. color: #606972;
  835. }
  836. .row {
  837. display: flex;
  838. align-items: center;
  839. position: relative;
  840. padding: 0 30rpx;
  841. height: 110rpx;
  842. background: #fff;
  843. .refund {
  844. font-size: 30rpx;
  845. color: $font-color-dark;
  846. padding-left: 128rpx;
  847. }
  848. .noRefund {
  849. font-size: 30rpx;
  850. color: $font-color-light;
  851. padding-left: 128rpx;
  852. }
  853. .tit {
  854. flex-shrink: 0;
  855. width: 120rpx;
  856. font-size: 30rpx;
  857. color: $font-color-dark;
  858. }
  859. .input {
  860. flex: 1;
  861. font-size: 30rpx;
  862. color: $font-color-dark;
  863. padding-left: 128rpx;
  864. &.payColor {
  865. color: $color-red;
  866. }
  867. }
  868. .iconlocation {
  869. font-size: 36rpx;
  870. color: $font-color-light;
  871. }
  872. }
  873. .shop-info {
  874. width: 750rpx;
  875. height: 140rpx;
  876. margin: 20rpx 0;
  877. padding: 28rpx 24rpx 22rpx 16rpx;
  878. background-color: #fff;
  879. display: flex;
  880. position: relative;
  881. .shop-logo {
  882. width: 90rpx;
  883. height: 90rpx;
  884. border-radius: 50%;
  885. // background-color: red;
  886. // overflow: hidden;
  887. image {
  888. width: 90rpx;
  889. height: 90rpx;
  890. }
  891. }
  892. .shop-base {
  893. padding-left: 15rpx;
  894. // width: 376rpx;
  895. width: 100%;
  896. font-size: 24rpx;
  897. font-weight: 500;
  898. color: #999999;
  899. line-height: 1;
  900. .base-name {
  901. padding-top: 14rpx;
  902. font-size: 30rpx;
  903. padding-bottom: 16rpx;
  904. font-weight: 500;
  905. color: #333333;
  906. }
  907. }
  908. .shop-dis {
  909. padding-top: 31rpx;
  910. position: absolute;
  911. font-size: 24rpx;
  912. font-weight: 500;
  913. color: #901b21;
  914. // line-height: 140rpx;
  915. right: 24rpx;
  916. image {
  917. padding-right: 5rpx;
  918. width: 21rpx;
  919. height: 21rpx;
  920. }
  921. }
  922. }
  923. .good-title {
  924. background-color: #fff;
  925. // height: 142rpx;
  926. padding: 24rpx 19rpx 24rpx 34rpx;
  927. line-height: 1.5;
  928. font-size: 36rpx;
  929. font-weight: 800;
  930. color: #333333;
  931. }
  932. .introduce-section {
  933. position: relative;
  934. background: #fff;
  935. padding: 35rpx 0rpx;
  936. padding-left: 20rpx;
  937. .title {
  938. font-size: 32rpx;
  939. color: $font-color-dark;
  940. padding-right: 34rpx;
  941. .tip-o {
  942. color: #ff3334;
  943. padding-left: 15rpx;
  944. }
  945. }
  946. .shareDate {
  947. position: absolute;
  948. top: 25rpx;
  949. right: 10rpx;
  950. font-size: 26rpx;
  951. color: #3d3f46;
  952. border-radius: 15rpx;
  953. background-color: #ffffff;
  954. height: 60rpx;
  955. line-height: 60rpx;
  956. &::after {
  957. border: none;
  958. }
  959. }
  960. .share-img {
  961. width: 30rpx;
  962. height: 30rpx;
  963. position: relative;
  964. top: 5rpx;
  965. left: 0;
  966. margin-right: 10rpx;
  967. }
  968. .info {
  969. color: #999999;
  970. font-size: 26rpx;
  971. padding-bottom: 15rpx;
  972. }
  973. .progress-box {
  974. width: 260rpx;
  975. position: relative;
  976. margin-top: 15rpx;
  977. line-height: 10px;
  978. .number {
  979. font-size: 17rpx;
  980. position: absolute;
  981. z-index: 999;
  982. top: 3rpx;
  983. left: 15rpx;
  984. color: #ffffff;
  985. }
  986. }
  987. .price-box {
  988. display: flex;
  989. align-items: baseline;
  990. height: 64rpx;
  991. padding: 10rpx 0;
  992. font-size: 27rpx;
  993. color: #FF0000;
  994. }
  995. .price {
  996. font-size: $font-lg + 6rpx;
  997. .text {
  998. padding-left: 5rpx;
  999. color: #b0b0b0;
  1000. font-size: 22rpx !important;
  1001. }
  1002. }
  1003. .price-green {
  1004. color: #2dbd59;
  1005. font-size: 28rpx !important;
  1006. text {
  1007. background: #2dbd59;
  1008. color: #ffffff;
  1009. padding: 0rpx 10rpx;
  1010. border-radius: 5rpx;
  1011. font-size: 22rpx !important;
  1012. margin-left: 15rpx;
  1013. }
  1014. }
  1015. .m-price {
  1016. margin: 0 12rpx;
  1017. color: $font-color-light;
  1018. text-decoration: line-through;
  1019. margin-left: 25rpx;
  1020. font-size: 24rpx;
  1021. }
  1022. }
  1023. .dhsm {
  1024. display: flex;
  1025. margin: 20rpx 0;
  1026. background-color: #fff;
  1027. padding: 34rpx 104rpx 30rpx 24rpx;
  1028. .title {
  1029. font-size: 32rpx;
  1030. font-family: PingFang SC;
  1031. font-weight: bold;
  1032. color: #333333;
  1033. margin-right: 32rpx;
  1034. flex-shrink: 0;
  1035. }
  1036. .info {
  1037. font-size: 26rpx;
  1038. font-family: PingFang SC;
  1039. font-weight: 500;
  1040. color: #8A8A8A;
  1041. line-height: 38rpx;
  1042. }
  1043. }
  1044. .price-box-jf {
  1045. color: #901b21;
  1046. display: flex;
  1047. align-items: baseline;
  1048. height: 64rpx;
  1049. font-size: 50rpx;
  1050. font-family: PingFang SC;
  1051. font-weight: 800;
  1052. color: #FF0000;
  1053. .price {
  1054. font-size: 50rpx;
  1055. }
  1056. image {
  1057. height: 30rpx;
  1058. width: 30rpx;
  1059. }
  1060. .jf {
  1061. font-size: 30rpx;
  1062. }
  1063. }
  1064. .mun-box {
  1065. display: flex;
  1066. justify-content: space-between;
  1067. align-items: center;
  1068. }
  1069. .mask {
  1070. position: fixed;
  1071. top: 0;
  1072. left: 0;
  1073. width: 100%;
  1074. height: 100%;
  1075. z-index: 999;
  1076. background-color: rgba(0, 0, 0, 0.4);
  1077. image {
  1078. width: 100%;
  1079. height: 100%;
  1080. opacity: 0.8;
  1081. }
  1082. }
  1083. </style>