shop.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208
  1. <template>
  2. <view class="container">
  3. <scroll-view style="height: 100vh;" class="floor-list"
  4. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  5. :refresher-enabled="false">
  6. <view class="carousel">
  7. <swiper indicator-dots circular=true duration="400">
  8. <swiper-item class="swiper-item" v-for="(item,index) in datalist.images" :key="index">
  9. <view class="image-wrapper">
  10. <image
  11. :src="pictureUrl+'/uploads/home/store/goods/'+item.goodsimage_url.substr(0, item.goodsimage_url.indexOf('\_')) + '/' + item.goodsimage_url"
  12. class="loaded"
  13. mode="aspectFill"
  14. ></image>
  15. </view>
  16. </swiper-item>
  17. </swiper>
  18. </view>
  19. <view class="introduce-section">
  20. <view class="titleLayout" >
  21. <view class="title">{{datalist.goods_name}}</view>
  22. <view @tap="shopDetail" style="display: flex;flex-direction: row;">
  23. <view class="titleRight">
  24. <view style="font-size: 36upx;color: #D9332E;text-align: right;">{{datalist.praise}}%</view>
  25. <view style="color: #606266;font-size: 28upx;">好评率</view>
  26. </view>
  27. <view style="display: flex;align-items: center;">
  28. <uni-icon size="18" type="arrowright"></uni-icon>
  29. </view>
  30. </view>
  31. </view>
  32. <view style="color: #909399;padding: 10upx 0 15upx 0;" v-if="datalist.points>0">购买得{{datalist.points}}圈币</view>
  33. <view class="titleLayout price-box">
  34. <view>
  35. <text class="price-tip">¥</text>
  36. <text class="price">{{datalist.goods_price}}</text>
  37. <text class="m-price">¥{{datalist.goods_marketprice}}</text>
  38. <text class="price-tip" v-if="datalist.goods_storage == 0">已下架</text>
  39. </view>
  40. <view>
  41. <text style="color: #909399">月销售{{datalist.sale_number}}</text>
  42. </view>
  43. </view>
  44. </view>
  45. <view class="c-list">
  46. <view style="display: flex;justify-content: space-between;" class="c-row b-b" @click="toggleSpec">
  47. <view style="font-size: 32upx;color: #909399;">规则数量选择</view>
  48. <view>
  49. <uni-icon size="20" type="arrowright"></uni-icon>
  50. </view>
  51. </view>
  52. </view>
  53. <!-- 评价 -->
  54. <view @tap="shopDetail" style="border-bottom: 20rpx solid #F5F5F5;" class="eva-section">
  55. <view style="display: flex;justify-content: space-between;" class="c-row b-b">
  56. <view style="font-size: 32upx;color: #909399;">评价</view>
  57. <view>
  58. <uni-icon size="20" type="arrowright"></uni-icon>
  59. </view>
  60. </view>
  61. <assess />
  62. </view>
  63. <!-- :class="iScrolltop == 2?'activeColor' : ''" -->
  64. <view class="detail-desc" >
  65. <van-tabs v-model="active" @click="onChange">
  66. <van-tab :name="0" title="详情">
  67. <view style="padding: 0 32upx;">
  68. <rich-text :nodes="datalist.goods_body"></rich-text>
  69. </view>
  70. </van-tab>
  71. <van-tab :name="1" title="常见问题">
  72. <view style="padding: 0 32upx;">
  73. <rich-text :nodes="datalist.issue"></rich-text>
  74. </view>
  75. </van-tab>
  76. </van-tabs>
  77. </view>
  78. </scroll-view>
  79. <!-- 底部操作菜单 -->
  80. <!-- <view class="page-bottom">
  81. <navigator url="/pages/index/index" open-type="switchTab" class="p-b-btn">
  82. <text class="yticon icon-xiatubiao--copy"></text>
  83. <text>首页</text>
  84. </navigator>
  85. <navigator url="/pages/index/cart" open-type="navigate" class="p-b-btn">
  86. <text class="yticon icon-gouwuche"></text>
  87. <text>购物车</text>
  88. </navigator>
  89. <view class="p-b-btn" :class="{active: favorite}" @click="toFavorite">
  90. <text class="yticon icon-shoucang"></text>
  91. <text>收藏</text>
  92. </view>
  93. <view class="action-btn-group">
  94. <button type="primary" @click="openCar" class=" action-btn no-border add-cart-btn">加入购物车</button>
  95. <button type="primary" class=" action-btn no-border buy-now-btn" @click="buy">立即购买</button>
  96. </view>
  97. </view> -->
  98. <!-- 规格-模态层弹窗 -->
  99. <view
  100. class="popup spec"
  101. :class="specClass"
  102. @touchmove.stop.prevent="stopPrevent"
  103. @click="toggleSpec"
  104. >
  105. <!-- 遮罩层 -->
  106. <view class="mask"></view>
  107. <view class="layer attr-content" @click.stop="stopPrevent">
  108. <view class="a-t">
  109. <image :src="nuberImg==''?firstImg:nuberImg"></image>
  110. <view class="right">
  111. <text class="price" style="font-size: 36upx;color: #303133">¥{{totalprice==0?datalist.goods_price:totalprice}}</text>
  112. <view v-if="datalist.spec_list.length > 0 ">
  113. <view class="selected" v-if="chosename.length > 0 ">
  114. <text class="selected-text" v-for="(sItem, sIndex) in chosename" :key="sIndex">
  115. {{sItem.value_name}}
  116. </text>
  117. X {{shopnumber}}
  118. </view>
  119. <view class="selected" v-else>
  120. <text class="selected-text">
  121. 请选择规格数量
  122. </text>
  123. </view>
  124. </view>
  125. <view v-else>
  126. X {{shopnumber}}
  127. </view>
  128. </view>
  129. <view @click="closeCar" style="position: absolute;right: 10%;">
  130. <uni-icon size="20" type="close"></uni-icon>
  131. </view>
  132. </view>
  133. <view v-for="(item,index) in datalist.spec_list" :key="index" class="attr-list">
  134. <text>{{item.spec_name}}</text>
  135. <view class="item-list">
  136. <!-- v-if="childItem.pid === item.id" , disabled: childItem.goods_storage==0-->
  137. <text
  138. v-for="(childItem, childIndex) in item.value_list"
  139. :key="childIndex" class="tit"
  140. :class="{selected: childItem.selected, disabled: childItem.goods_storage==0}"
  141. @click="selectSpec(index, childItem.value_id, childItem, item,childItem.goods_storage)"
  142. >
  143. {{childItem.value_name}}
  144. </text>
  145. </view>
  146. </view>
  147. <!-- :max="goods_storage" -->
  148. <view class="numberchange">
  149. <span>数量</span>
  150. <uninumberbox :max="goods_storage" :min="1" @change="changestorage"/>
  151. </view>
  152. </view>
  153. </view>
  154. <!-- 分享 -->
  155. <!-- <share
  156. ref="share"
  157. :contentHeight="580"
  158. :shareList="shareList"
  159. ></share> -->
  160. <View class="page-bottom">
  161. <van-goods-action>
  162. <!-- <van-goods-action-icon @click="goIndex" icon="bag-o" /> -->
  163. <van-goods-action-icon @click="goIndex">
  164. <template slot="icon" style="width: 40upx;height: 40upx;">
  165. <image style="width: 100%;height: 100%;" src='/static/bottombtn0101.png'>
  166. </image>
  167. </template>
  168. </van-goods-action-icon>
  169. <van-goods-action-icon icon="cart-o" @click="openCar" :info="cartnumber" />
  170. <van-goods-action-icon icon="star-o" v-if="has_collected == 0" @click="toFavorite"/>
  171. <van-goods-action-icon icon="star" v-if="has_collected == 1" icon-class="colored" @click="toFavorite"/>
  172. <van-goods-action-button @click="addCar" text="加入购物车" type="warning" />
  173. <van-goods-action-button text="立即购买" @click="buynow" />
  174. </van-goods-action>
  175. </View>
  176. <Gobacktop @getop="getop" :bottomtop="2" v-if="isTop" />
  177. </view>
  178. </template>
  179. <script>
  180. import {
  181. mapMutations,mapState
  182. } from 'vuex'
  183. // import logionDialog from '@/component/loginDialog.vue'
  184. import Gobacktop from '@/component/Gobacktop.vue'
  185. import uninumberbox from '@/component/uinNumber.vue'
  186. import assess from '@/component/assess.vue' // 评价列表
  187. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  188. export default{
  189. components: {
  190. uniIcon,
  191. assess,
  192. uninumberbox,
  193. Gobacktop
  194. },
  195. data() {
  196. return {
  197. isTop: false,
  198. chosename: [],
  199. arrayId:[],
  200. bottomtop: '55upx',
  201. scopemapId: 0,
  202. showdialog: false,
  203. has_collected: false, // 是否收藏
  204. cartnumber: 0, // 购物车数量
  205. changnumber: 100,
  206. ismax: false, // 输入狂禁止数量
  207. goods_storage: '', // 规格商品参数
  208. nuberImg:'',
  209. firstImg:'',
  210. shopnumber: 1,
  211. pictureUrl: this.pictureUrl,
  212. datalist: {},
  213. store_id: 0, // 酒店id
  214. goodId: 0, // 商品公共id
  215. goods_id: 0, // 商品规格id
  216. windowHeight: 0, // 窗口高度
  217. iScrolltop: 1,
  218. active: 0,
  219. scrollTop: 0,
  220. old: {
  221. scrollTop: 0
  222. },
  223. specClass: 'none',
  224. specSelected:[],
  225. totalprice:0,
  226. firstprice: 0,
  227. favorite: true,
  228. shareList: [],
  229. imgList: [
  230. ],
  231. desc: `
  232. `,
  233. specList: [
  234. ]
  235. };
  236. },
  237. onLaunch: function(){
  238. this.active = 1;
  239. },
  240. computed:{
  241. ...mapState([
  242. 'hasLogin',
  243. 'userInfo',
  244. 'successlogion'
  245. ]),
  246. },
  247. onShow: function() {
  248. let _this = this;
  249. uni.getSystemInfo({
  250. success: function (res) {
  251. _this.windowHeight = res.screenHeight;
  252. // console.log("屏幕宽度:"+res.screenWidth);
  253. // console.log("屏幕高度:"+res.screenHeight);
  254. // console.log("可使用窗口宽度:"+res.windowWidth);
  255. // console.log("可使用窗口高度:"+res.windowHeight);
  256. }
  257. });
  258. },
  259. async onLoad(options){
  260. this.goodId = options.id; // 商品Id
  261. this.store_id = options.store_id;
  262. this.getshopdetail(); // 获取商品详情
  263. //规格 默认选中第一条
  264. // this.datalist.spec_list[0].value_list.forEach(item=>{
  265. // for(let cItem of this.specChildList){
  266. // if(cItem.pid === item.id){
  267. // this.$set(cItem, 'selected', true);
  268. // this.specSelected.push(cItem);
  269. // break; //forEach不能使用break
  270. // }
  271. // }
  272. // })
  273. //this.shareList = await this.$api.json('shareList');
  274. },
  275. onShareAppMessage(res) {
  276. uni.showShareMenu({
  277. withShareTicket: true
  278. });
  279. let that = this;
  280. let id = this.goodId; // 商品Id
  281. let store_id = this.store_id;
  282. if (res.from === 'button') {
  283. // 来自页面内分享按钮
  284. }
  285. return {
  286. title: that.datalist.goods_name,
  287. path: `/pages/index/shop?id=${id}&store_id=${store_id}`,
  288. imageUrl:that.nuberImg
  289. }
  290. },
  291. onReady: function() {
  292. },
  293. methods:{
  294. getop() {
  295. this.scrollTop = this.old.scrollTop
  296. this.$nextTick(function(){
  297. this.scrollTop=0;
  298. });
  299. this.isTop = false;
  300. },
  301. // 跳转到首页
  302. goIndex() {
  303. let id = this.store_id;
  304. uni.redirectTo({
  305. url: `/pages/index/hotel?id=${id}`
  306. })
  307. // uni.switchTab({
  308. // url:'./index'
  309. // })
  310. // uni.navigateBack();
  311. },
  312. // 更改商品数量
  313. changestorage(e) {
  314. if(e == this.goods_storage) {
  315. this.$msg("您选择的数量已超过最大库存数");
  316. return;
  317. }
  318. this.shopnumber = e;
  319. let firstprice = this.firstprice;
  320. this.totalprice = firstprice*this.shopnumber;
  321. },
  322. // 获取商品详情
  323. getshopdetail() {
  324. let params = {};
  325. params.goods_commonid =this.goodId;
  326. params.store_id = this.store_id;
  327. this.request({
  328. url:'/v2/goods/detail',
  329. method:'POST',
  330. data: params,
  331. success: (res)=> {
  332. let { data } = res.data;
  333. this.cartnumber = data.cart;
  334. this.has_collected = data.has_collected;
  335. let array = data;
  336. array.images.forEach(item => {
  337. this.firstImg = this.pictureUrl+'/uploads/home/store/goods/'+item.goodsimage_url.substr(0, item.goodsimage_url.indexOf('\_')) + '/' + item.goodsimage_url
  338. })
  339. if(array.spec_list.length == 0) {
  340. this.datalist = data;
  341. this.goods_id = data.goods_list[0].goods_id;
  342. this.goods_storage = data.goods_storage;
  343. //this.specSelected = data.goods_list;
  344. }else {
  345. array.spec_list[0].value_list.forEach( (item,idx) => {
  346. item.goods_storage = data.goods_list[idx].goods_storage;
  347. })
  348. this.datalist = array;
  349. }
  350. const regex1 = new RegExp('stlye="" ', 'gi');
  351. this.datalist.goods_body = this.datalist.goods_body.replace(/\(<img\)/ig, '');
  352. const regex = new RegExp('<img', 'gi');
  353. this.datalist.goods_body = this.datalist.goods_body.replace(regex,
  354. `<img class="changeimg"`);
  355. }
  356. })
  357. },
  358. shopDetail() {
  359. // url: `/pages/index/shop?id=${id}&store_id=${store_id}`
  360. let goodId = this.goodId; // 商品Id
  361. let store_id = this.store_id;
  362. uni.navigateTo({
  363. url: `/pages/index/commemt?goodId=${goodId}&store_id=${store_id}`
  364. });
  365. },
  366. onChange(event) {
  367. this.active = event.detail.name;
  368. console.log(this.active)
  369. },
  370. //规格弹窗开关
  371. toggleSpec() {
  372. this.specClass = 'show';
  373. //this.specSelected = [];
  374. // if(this.specClass === 'show'){
  375. // this.specClass = 'hide';
  376. // setTimeout(() => {
  377. // this.specClass = 'none';
  378. // }, 250);
  379. // }else if(this.specClass === 'none'){
  380. // this.specClass = 'show';
  381. // }
  382. },
  383. // 关闭弹窗
  384. // cancelDiaolog() {
  385. // this.showdialog = false;
  386. // },
  387. // // 确定
  388. // confirmDiaolog() {
  389. // this.showdialog = false;
  390. // uni.navigateTo({
  391. // url: '../myCenter/information' // 我的收藏
  392. // })
  393. // },
  394. openCar() {
  395. if(this.hasLogin && this.successlogion) {
  396. let store_id = this.store_id;
  397. uni.navigateTo({
  398. url:`/pages/index/cart?store_id=${store_id}`
  399. })
  400. }else {
  401. //this.showdialog = true;
  402. uni.navigateTo({
  403. url:'/pages/myCenter/logion'
  404. })
  405. }
  406. },
  407. // 立即购买
  408. buynow() {
  409. if(this.hasLogin && this.successlogion) {
  410. if(this.datalist.store_id == 1 || this.datalist.goods_state != 1 || this.datalist.goods_storage < 1) {
  411. this.$msg("商品已下架");
  412. return;
  413. }
  414. if(this.specSelected.length == 0&&this.datalist.spec_list.length != 0 ) {
  415. this.$msg("请选择规格数量");
  416. this.specClass = 'show';
  417. return;
  418. }
  419. if(this.specSelected.length == 0&&this.datalist.spec_list.length == 0) {
  420. this.specClass = 'show';
  421. this.specSelected = this.datalist.goods_list;
  422. return;
  423. }
  424. let goods = [];
  425. goods.push({});
  426. goods[0].goods_id = this.goods_id;
  427. goods[0].buy_num = this.shopnumber;
  428. this.request({
  429. url:'/v1/order/save_og',
  430. method: 'post',
  431. data: {
  432. store_id: this.store_id,
  433. goods: JSON.stringify(goods)
  434. },
  435. success:(res) => {
  436. let store = this.store_id;
  437. let order_id = res.data.data.order_id;
  438. this.specClass = 'none';
  439. this.specSelected = [];
  440. this.chosename = [];
  441. uni.navigateTo({
  442. url: `/pages/index/sureBuy?store=${store}&order_id=${order_id}`
  443. });
  444. }
  445. })
  446. }else {
  447. uni.navigateTo({
  448. url:'/pages/myCenter/logion'
  449. })
  450. }
  451. },
  452. // 加入购物车
  453. addCar() {
  454. if(this.hasLogin && this.successlogion) {
  455. if(this.datalist.store_id == 1 || this.datalist.goods_state != 1 || this.datalist.goods_storage < 1) {
  456. this.$msg("商品已下架");
  457. return;
  458. }
  459. if(this.specSelected.length == 0&&this.datalist.spec_list.length == 0) {
  460. this.specClass = 'show';
  461. this.specSelected = this.datalist.goods_list;
  462. return;
  463. }
  464. // if(this.chosename.length == 0&&this.datalist.spec_list.length != 0) {
  465. // this.specClass = 'show';
  466. // return;
  467. // }
  468. if(this.specSelected.length == 0&&this.datalist.spec_list.length != 0 ) {
  469. this.specClass = 'show';
  470. this.$msg("请选择规格数量");
  471. return;
  472. }else {
  473. this.request({
  474. url:'/v2/order/add_cart',
  475. method:'POST',
  476. data: {
  477. goods_id: this.goods_id,
  478. goods_num: this.shopnumber
  479. },
  480. success: () => {
  481. this.specSelected = [];
  482. this.chosename = [];
  483. this.$msg("商品添加成功");
  484. this.specClass = 'none';
  485. this.getshopdetail();
  486. }
  487. })
  488. }
  489. }else {
  490. uni.navigateTo({
  491. url:'/pages/myCenter/logion'
  492. })
  493. }
  494. },
  495. closeCar() {
  496. this.specClass = 'none';
  497. },
  498. //选择规格
  499. selectSpec(index, pid,chose,first,goods_storage){
  500. if(goods_storage == 0) {
  501. this.$msg("商品没库存啦");
  502. return;
  503. }
  504. let obj = {};
  505. obj.spec_id = first.spec_id;
  506. obj.value_name = chose.value_name;
  507. if(this.datalist.spec_list.length == this.chosename.length) {
  508. }else {
  509. this.chosename.push(obj);
  510. }
  511. this.specSelected = [];
  512. let list = this.datalist.spec_list[index].value_list;
  513. this.datalist.spec_list[index].value_list.forEach(item=>{
  514. if(item.value_id === pid){
  515. this.$set(item, 'selected', true);
  516. }else {
  517. this.$set(item, 'selected', false);
  518. }
  519. })
  520. this.chosename.forEach(items => {
  521. if(items.spec_id == first.spec_id) {
  522. items.value_name = chose.value_name
  523. };
  524. })
  525. let array = [];
  526. for(let i = 0; i < this.datalist.spec_list.length; i++) {
  527. for(let j = 0; j<this.datalist.spec_list[i].value_list.length;j++) {
  528. if(this.datalist.spec_list[i].value_list[j].selected) {
  529. array.push(this.datalist.spec_list[i].value_list[j].value_id);
  530. }
  531. }
  532. }
  533. this.arrayId = array;
  534. if(this.arrayId.length == this.datalist.spec_list.length) {
  535. this.scopemapId = array.join("_");
  536. let goodId = this.datalist.spec_map[this.scopemapId]; //
  537. let items = this.datalist.goods_list[goodId]
  538. items.value_name = chose.value_name;
  539. this.nuberImg = items.spec_img;
  540. this.specSelected.push(items)
  541. this.goods_storage = items.goods_storage;
  542. this.goods_id = items.goods_id;
  543. this.firstprice = items.goods_price;
  544. this.totalprice = items.goods_price*this.shopnumber;
  545. }
  546. // if(this.arrayId.length == this.datalist.spec_list.length) {
  547. // }
  548. // let obj = {};
  549. // obj.firstId = index;
  550. // obj.pid = pid;
  551. // this.arrayId.push(obj);
  552. // console.log(this.arrayId)
  553. // let arr = this.arrayId;
  554. // for(var i=0; i<arr.length; i++){
  555. // for(var j=i+1; j<arr.length; j++){
  556. // if(arr[i].firstId==arr[j].firstId){
  557. // arr.splice(j,1);
  558. // j--;
  559. // }
  560. // }
  561. // }
  562. // let newarray = []
  563. // arr.forEach(item => {
  564. // newarray.push(item.pid);
  565. // })
  566. // this.arrayId = arr;
  567. // if(this.arrayId.length == 0) {
  568. // this.scopemapId = newarray.toString(); ;
  569. // }else {
  570. // this.scopemapId = newarray.join("_");
  571. // }
  572. // console.log(this.scopemapId);
  573. //this.datalist.spec_list[index].value_list = list;
  574. },
  575. // 滚动到顶部
  576. upper(e) {
  577. },
  578. // 滚到底部
  579. lower(e) {
  580. console.log("底部")
  581. },
  582. // 滚动时触发
  583. scroll(e) {
  584. this.old.scrollTop = e.detail.scrollTop
  585. if(e.detail.scrollTop > this.windowHeight) {
  586. this.iScrolltop = 2;
  587. }else {
  588. this.iScrolltop = 1;
  589. }
  590. if(e.detail.scrollTop > 400) {
  591. this.isTop = true;
  592. }else{ //当距离小于500时显示回到顶部按钮
  593. this.isTop = false;
  594. }
  595. },
  596. //收藏
  597. toFavorite(){
  598. if(this.hasLogin && this.successlogion) {
  599. this.request({
  600. url: '/v1/favorites/collect',
  601. method: 'post',
  602. data: {
  603. type:'goods',
  604. fav_id: this.goodId
  605. },
  606. success: () => {
  607. this.getshopdetail()
  608. }
  609. })
  610. }else {
  611. uni.navigateTo({
  612. url:'/pages/myCenter/logion'
  613. })
  614. }
  615. //this.favorite = !this.favorite;
  616. },
  617. buy(){
  618. uni.navigateTo({
  619. url: './sureBuy'
  620. })
  621. },
  622. stopPrevent(){}
  623. },
  624. }
  625. </script>
  626. <style lang='scss'>
  627. page{
  628. /* background: $page-color-base; */
  629. /* padding-bottom: 160upx; */
  630. position: relative;
  631. }
  632. .icon-you{
  633. font-size: 28upx + 2upx;
  634. color: #888;
  635. }
  636. .carousel {
  637. height: 722upx;
  638. position:relative;
  639. swiper{
  640. height: 100%;
  641. }
  642. .image-wrapper{
  643. width: 100%;
  644. height: 100%;
  645. }
  646. .swiper-item {
  647. display: flex;
  648. justify-content: center;
  649. align-content: center;
  650. height: 750upx;
  651. overflow: hidden;
  652. image {
  653. width: 100%;
  654. height: 100%;
  655. }
  656. }
  657. }
  658. .titleLayout {
  659. display: flex;
  660. justify-content: space-between;
  661. padding-bottom: 20upx;
  662. }
  663. /* 标题简介 */
  664. .introduce-section{
  665. background: #fff;
  666. padding: 20upx 30upx;
  667. .title{
  668. font-size: 36upx;
  669. color: #303133;
  670. height: 50upx;
  671. line-height: 50upx;
  672. width: 70%;
  673. white-space:nowrap;
  674. overflow:hidden;
  675. text-overflow:ellipsis;
  676. }
  677. .titleRight {
  678. border-left: 1px solid #F5F5F5;
  679. padding-left: 32upx;
  680. }
  681. .price-box{
  682. display:flex;
  683. align-items:baseline;
  684. height: 64upx;
  685. padding: 10upx 0;
  686. font-size: 26upx;
  687. color:#fa436a;
  688. }
  689. .price{
  690. font-size: $font-lg + 2upx;
  691. }
  692. .m-price{
  693. margin:0 12upx;
  694. color: #909399;
  695. text-decoration: line-through;
  696. }
  697. .coupon-tip{
  698. align-items: center;
  699. padding: 4upx 10upx;
  700. background: #fa436a;
  701. font-size: 24upx;
  702. color: #fff;
  703. border-radius: 6upx;
  704. line-height: 1;
  705. transform: translateY(-4upx);
  706. }
  707. .bot-row{
  708. display:flex;
  709. align-items:center;
  710. height: 50upx;
  711. font-size: 24upx;
  712. color: #909399;
  713. text{
  714. flex: 1;
  715. }
  716. }
  717. }
  718. /* 分享 */
  719. .share-section{
  720. display:flex;
  721. align-items:center;
  722. color: #606266;
  723. background: linear-gradient(left, #fdf5f6, #fbebf6);
  724. padding: 12upx 30upx;
  725. .share-icon{
  726. display:flex;
  727. align-items:center;
  728. width: 70upx;
  729. height: 30upx;
  730. line-height: 1;
  731. border: 1px solid #fa436a;
  732. border-radius: 4upx;
  733. position:relative;
  734. overflow: hidden;
  735. font-size: 22upx;
  736. color: #fa436a;
  737. &:after{
  738. content: '';
  739. width: 50upx;
  740. height: 50upx;
  741. border-radius: 50%;
  742. left: -20upx;
  743. top: -12upx;
  744. position:absolute;
  745. background: #fa436a;
  746. }
  747. }
  748. .icon-xingxing{
  749. position:relative;
  750. z-index: 1;
  751. font-size: 24upx;
  752. margin-left: 2upx;
  753. margin-right: 10upx;
  754. color: #fff;
  755. line-height: 1;
  756. }
  757. .tit{
  758. font-size: 28upx;
  759. margin-left:10upx;
  760. }
  761. .icon-bangzhu1{
  762. padding: 10upx;
  763. font-size: 30upx;
  764. line-height: 1;
  765. }
  766. .share-btn{
  767. flex: 1;
  768. text-align:right;
  769. font-size: 24upx;
  770. color: #fa436a;
  771. }
  772. .icon-you{
  773. font-size: 24upx;
  774. margin-left: 4upx;
  775. color: #fa436a;
  776. }
  777. }
  778. .c-list{
  779. font-size: 24upx + 2upx;
  780. color: #606266;
  781. background: #fff;
  782. border-top: 20upx solid #F5F5F5;
  783. border-bottom: 20upx solid #F5F5F5;
  784. .c-row{
  785. display:flex;
  786. align-items:center;
  787. padding: 20upx 30upx;
  788. position:relative;
  789. }
  790. .tit{
  791. width: 140upx;
  792. }
  793. .con{
  794. flex: 1;
  795. color: #303133;
  796. .selected-text{
  797. margin-right: 10upx;
  798. }
  799. }
  800. .bz-list{
  801. height: 40upx;
  802. font-size: 24upx+2upx;
  803. color: #303133;
  804. text{
  805. display: inline-block;
  806. margin-right: 30upx;
  807. }
  808. }
  809. .con-list{
  810. flex: 1;
  811. display:flex;
  812. flex-direction: column;
  813. color: #303133;
  814. line-height: 40upx;
  815. }
  816. .red{
  817. color: #fa436a;
  818. }
  819. }
  820. /* 评价 */
  821. .eva-section{
  822. display: flex;
  823. flex-direction: column;
  824. padding: 20upx 30upx;
  825. background: #fff;
  826. margin-top: 16upx;
  827. .e-header{
  828. display: flex;
  829. align-items: center;
  830. height: 70upx;
  831. font-size: 24upx + 2upx;
  832. color: #909399;
  833. .tit{
  834. font-size: 28upx + 2upx;
  835. color: #303133;
  836. margin-right: 4upx;
  837. }
  838. .tip{
  839. flex: 1;
  840. text-align: right;
  841. }
  842. .icon-you{
  843. margin-left: 10upx;
  844. }
  845. }
  846. }
  847. .eva-box{
  848. display: flex;
  849. padding: 20upx 0;
  850. .portrait{
  851. flex-shrink: 0;
  852. width: 80upx;
  853. height: 80upx;
  854. border-radius: 100px;
  855. }
  856. .right{
  857. flex: 1;
  858. display: flex;
  859. flex-direction: column;
  860. font-size: 28upx;
  861. color: #606266;
  862. padding-left: 26upx;
  863. .con{
  864. font-size: 28upx;
  865. color: #303133;
  866. padding: 20upx 0;
  867. }
  868. .bot{
  869. display: flex;
  870. justify-content: space-between;
  871. font-size: 24upx;
  872. color:#909399;
  873. }
  874. }
  875. }
  876. /* 详情 */
  877. .detail-desc{
  878. background: #fff;
  879. margin-top: 16upx;
  880. margin-bottom: 135rpx;
  881. width: 100%;
  882. .d-header{
  883. display: flex;
  884. justify-content: center;
  885. align-items: center;
  886. height: 80upx;
  887. font-size: 28upx + 2upx;
  888. color: #303133;
  889. position: relative;
  890. text{
  891. padding: 0 20upx;
  892. background: #fff;
  893. position: relative;
  894. z-index: 1;
  895. }
  896. &:after{
  897. position: absolute;
  898. left: 50%;
  899. top: 50%;
  900. transform: translateX(-50%);
  901. width: 300upx;
  902. height: 0;
  903. content: '';
  904. border-bottom: 1px solid #ccc;
  905. }
  906. }
  907. }
  908. /* 规格选择弹窗 */
  909. .attr-content{
  910. padding: 10upx 30upx;
  911. .a-t{
  912. display: flex;
  913. image{
  914. width: 170upx;
  915. height: 170upx;
  916. flex-shrink: 0;
  917. margin-top: -40upx;
  918. border-radius: 8upx;;
  919. }
  920. .right{
  921. display: flex;
  922. flex-direction: column;
  923. padding-left: 24upx;
  924. font-size: 24upx + 2upx;
  925. color: #606266;
  926. line-height: 42upx;
  927. justify-content: space-around;
  928. .price{
  929. font-size: $font-lg;
  930. color: #fa436a;
  931. margin-bottom: 10upx;
  932. }
  933. .selected-text{
  934. margin-right: 10upx;
  935. }
  936. }
  937. }
  938. .attr-list{
  939. display: flex;
  940. flex-direction: column;
  941. font-size: 28upx + 2upx;
  942. color: #606266;
  943. padding-top: 30upx;
  944. padding-left: 10upx;
  945. }
  946. .item-list{
  947. padding: 20upx 0 0;
  948. display: flex;
  949. flex-wrap: wrap;
  950. text{
  951. display: flex;
  952. align-items: center;
  953. justify-content: center;
  954. background: #eee;
  955. margin-right: 20upx;
  956. margin-bottom: 20upx;
  957. border-radius: 100upx;
  958. min-width: 60upx;
  959. height: 60upx;
  960. padding: 0 20upx;
  961. font-size: 28upx;
  962. color: #303133;
  963. }
  964. .selected{
  965. background: #fbebee;
  966. color: #fa436a;
  967. }
  968. .disabled {
  969. color:#999;
  970. background: rgba(245,245,245, 0.5);
  971. }
  972. }
  973. }
  974. /* 弹出层 */
  975. .popup {
  976. position: fixed;
  977. left: 0;
  978. top: 0;
  979. right: 0;
  980. bottom: 100upx;
  981. z-index: 99;
  982. &.show {
  983. display: block;
  984. .mask{
  985. animation: showPopup 0.2s linear both;
  986. }
  987. .layer {
  988. animation: showLayer 0.2s linear both;
  989. }
  990. }
  991. &.hide {
  992. .mask{
  993. animation: hidePopup 0.2s linear both;
  994. }
  995. .layer {
  996. animation: hideLayer 0.2s linear both;
  997. }
  998. }
  999. &.none {
  1000. display: none;
  1001. }
  1002. .mask{
  1003. position: fixed;
  1004. top: 0;
  1005. width: 100%;
  1006. height: 90%;
  1007. z-index: 1;
  1008. background-color: rgba(0, 0, 0, 0.4);
  1009. }
  1010. .layer {
  1011. position: fixed;
  1012. z-index: 99;
  1013. bottom: 100upx;
  1014. width: 100%;
  1015. min-height: 40vh;
  1016. border-radius: 10upx 10upx 0 0;
  1017. background-color: #fff;
  1018. .btn{
  1019. height: 66upx;
  1020. line-height: 66upx;
  1021. border-radius: 100upx;
  1022. background: #fa436a;
  1023. font-size: 28upx + 2upx;
  1024. color: #fff;
  1025. margin: 30upx auto 20upx;
  1026. }
  1027. }
  1028. @keyframes showPopup {
  1029. 0% {
  1030. opacity: 0;
  1031. }
  1032. 100% {
  1033. opacity: 1;
  1034. }
  1035. }
  1036. @keyframes hidePopup {
  1037. 0% {
  1038. opacity: 1;
  1039. }
  1040. 90% {
  1041. opacity: 0;
  1042. }
  1043. }
  1044. @keyframes showLayer {
  1045. 0% {
  1046. transform: translateY(120%);
  1047. }
  1048. 100% {
  1049. transform: translateY(0%);
  1050. }
  1051. }
  1052. @keyframes hideLayer {
  1053. 0% {
  1054. transform: translateY(0);
  1055. }
  1056. 100% {
  1057. transform: translateY(120%);
  1058. }
  1059. }
  1060. }
  1061. .colored {
  1062. color: red;
  1063. }
  1064. .van-sticky {
  1065. /* z-index: 0!important; */
  1066. }
  1067. /* 详情固定 */
  1068. .activeColor {
  1069. /* background: #fff!important; */
  1070. position: fixed;
  1071. background-color: #fff;
  1072. top: 0upx;
  1073. z-index: 99;
  1074. margin-top: 0;
  1075. }
  1076. .numberchange {
  1077. padding-top: 48px;
  1078. overflow: hidden;
  1079. clear: both;
  1080. padding-right: 59rpx;
  1081. }
  1082. .uni-numbox {
  1083. float: right;
  1084. }
  1085. /* 底部操作菜单 */
  1086. .page-bottom{
  1087. position: fixed;
  1088. left: 0;
  1089. bottom: 0;
  1090. display: flex;
  1091. justify-content: center;
  1092. align-items: center;
  1093. width: 100vw;
  1094. height: 100upx;
  1095. z-index: 99;
  1096. background: rgba(255,255,255,.9);
  1097. .p-b-btn{
  1098. display:flex;
  1099. flex-direction: column;
  1100. align-items: center;
  1101. justify-content: center;
  1102. font-size: 24upx;
  1103. color: #606266;
  1104. width: 96upx;
  1105. height: 80upx;
  1106. .yticon{
  1107. font-size: 40upx;
  1108. line-height: 48upx;
  1109. color: #909399;
  1110. }
  1111. &.active, &.active .yticon{
  1112. color: #fa436a;
  1113. }
  1114. .icon-fenxiang2{
  1115. font-size: 42upx;
  1116. transform: translateY(-2upx);
  1117. }
  1118. .icon-shoucang{
  1119. font-size: 46upx;
  1120. }
  1121. }
  1122. .action-btn-group{
  1123. display: flex;
  1124. height: 76upx;
  1125. border-radius: 100px;
  1126. overflow: hidden;
  1127. box-shadow: 0 20upx 40upx -16upx #fa436a;
  1128. box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  1129. background: linear-gradient(to right, #ffac30,#fa436a,#F56C6C);
  1130. margin-left: 20upx;
  1131. position:relative;
  1132. &:after{
  1133. content: '';
  1134. position:absolute;
  1135. top: 50%;
  1136. right: 50%;
  1137. transform: translateY(-50%);
  1138. height: 28upx;
  1139. width: 0;
  1140. border-right: 1px solid rgba(255,255,255,.5);
  1141. }
  1142. .action-btn{
  1143. display:flex;
  1144. align-items: center;
  1145. justify-content: center;
  1146. width: 180upx;
  1147. height: 100%;
  1148. font-size: 28upx ;
  1149. padding: 0;
  1150. border-radius: 0;
  1151. background: transparent;
  1152. }
  1153. }
  1154. }
  1155. .changeimg {
  1156. width: 100%;
  1157. height: auto!important;
  1158. display: block;
  1159. text-align: center;
  1160. }
  1161. </style>