exchangeDetail.vue 29 KB

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