product.vue 27 KB

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