shop.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  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. console.log(e)
  315. console.log(this.goods_storage);
  316. if(e == this.goods_storage) {
  317. this.$msg("您选择的数量已超过最大库存数");
  318. return;
  319. }
  320. this.shopnumber = e;
  321. let firstprice = this.firstprice;
  322. this.totalprice = firstprice*this.shopnumber;
  323. },
  324. // 获取商品详情
  325. getshopdetail() {
  326. let params = {};
  327. params.goods_commonid =this.goodId;
  328. params.store_id = this.store_id;
  329. this.request({
  330. url:'/v2/goods/detail',
  331. method:'POST',
  332. data: params,
  333. success: (res)=> {
  334. let { data } = res.data;
  335. this.cartnumber = data.cart;
  336. this.has_collected = data.has_collected;
  337. let array = data;
  338. array.images.forEach(item => {
  339. this.firstImg = this.pictureUrl+'/uploads/home/store/goods/'+item.goodsimage_url.substr(0, item.goodsimage_url.indexOf('\_')) + '/' + item.goodsimage_url
  340. })
  341. if(array.spec_list.length == 0) {
  342. this.datalist = data;
  343. this.goods_id = data.goods_list[0].goods_id;
  344. this.goods_storage = data.goods_storage;
  345. //this.specSelected = data.goods_list;
  346. }else {
  347. array.spec_list[0].value_list.forEach( (item,idx) => {
  348. item.goods_storage = data.goods_list[idx].goods_storage;
  349. })
  350. this.datalist = array;
  351. }
  352. const regex1 = new RegExp('stlye="" ', 'gi');
  353. this.datalist.goods_body = this.datalist.goods_body.replace(/\(<img\)/ig, '');
  354. const regex = new RegExp('<img', 'gi');
  355. this.datalist.goods_body = this.datalist.goods_body.replace(regex,
  356. `<img class="changeimg"`);
  357. }
  358. })
  359. },
  360. shopDetail() {
  361. // url: `/pages/index/shop?id=${id}&store_id=${store_id}`
  362. let goodId = this.goodId; // 商品Id
  363. let store_id = this.store_id;
  364. uni.navigateTo({
  365. url: `/pages/index/commemt?goodId=${goodId}&store_id=${store_id}`
  366. });
  367. },
  368. onChange(event) {
  369. this.active = event.detail.name;
  370. console.log(this.active)
  371. },
  372. //规格弹窗开关
  373. toggleSpec() {
  374. this.specClass = 'show';
  375. //this.specSelected = [];
  376. // if(this.specClass === 'show'){
  377. // this.specClass = 'hide';
  378. // setTimeout(() => {
  379. // this.specClass = 'none';
  380. // }, 250);
  381. // }else if(this.specClass === 'none'){
  382. // this.specClass = 'show';
  383. // }
  384. },
  385. // 关闭弹窗
  386. // cancelDiaolog() {
  387. // this.showdialog = false;
  388. // },
  389. // // 确定
  390. // confirmDiaolog() {
  391. // this.showdialog = false;
  392. // uni.navigateTo({
  393. // url: '../myCenter/information' // 我的收藏
  394. // })
  395. // },
  396. openCar() {
  397. if(this.hasLogin && this.successlogion) {
  398. let store_id = this.store_id;
  399. uni.navigateTo({
  400. url:`/pages/index/cart?store_id=${store_id}`
  401. })
  402. }else {
  403. //this.showdialog = true;
  404. uni.navigateTo({
  405. url:'/pages/myCenter/logion'
  406. })
  407. }
  408. },
  409. // 立即购买
  410. buynow() {
  411. if(this.hasLogin && this.successlogion) {
  412. if(this.datalist.store_id == 1 || this.datalist.goods_state != 1 || this.datalist.goods_storage < 1) {
  413. this.$msg("商品已下架");
  414. return;
  415. }
  416. if(this.specSelected.length == 0&&this.datalist.spec_list.length != 0 ) {
  417. this.$msg("请选择规格数量");
  418. this.specClass = 'show';
  419. return;
  420. }
  421. if(this.specSelected.length == 0&&this.datalist.spec_list.length == 0) {
  422. this.specClass = 'show';
  423. this.specSelected = this.datalist.goods_list;
  424. return;
  425. }
  426. let goods = [];
  427. goods.push({});
  428. goods[0].goods_id = this.goods_id;
  429. goods[0].buy_num = this.shopnumber;
  430. this.request({
  431. url:'/v1/order/save_og',
  432. method: 'post',
  433. data: {
  434. store_id: this.store_id,
  435. goods: JSON.stringify(goods)
  436. },
  437. success:(res) => {
  438. let store = this.store_id;
  439. let order_id = res.data.data.order_id;
  440. this.specClass = 'none';
  441. this.specSelected = [];
  442. this.chosename = [];
  443. uni.navigateTo({
  444. url: `/pages/index/sureBuy?store=${store}&order_id=${order_id}`
  445. });
  446. }
  447. })
  448. }else {
  449. uni.navigateTo({
  450. url:'/pages/myCenter/logion'
  451. })
  452. }
  453. },
  454. // 加入购物车
  455. addCar() {
  456. if(this.hasLogin && this.successlogion) {
  457. if(this.datalist.store_id == 1 || this.datalist.goods_state != 1 || this.datalist.goods_storage < 1) {
  458. this.$msg("商品已下架");
  459. return;
  460. }
  461. if(this.specSelected.length == 0&&this.datalist.spec_list.length == 0) {
  462. this.specClass = 'show';
  463. this.specSelected = this.datalist.goods_list;
  464. return;
  465. }
  466. if(this.chosename.length == 0&&this.datalist.spec_list.length != 0) {
  467. this.specClass = 'show';
  468. return;
  469. }
  470. if(this.specSelected.length == 0&&this.datalist.spec_list.length != 0 ) {
  471. this.specClass = 'show';
  472. this.$msg("请选择规格数量");
  473. return;
  474. }else {
  475. this.request({
  476. url:'/v2/order/add_cart',
  477. method:'POST',
  478. data: {
  479. goods_id: this.goods_id,
  480. goods_num: this.shopnumber
  481. },
  482. success: () => {
  483. this.specSelected = [];
  484. this.chosename = [];
  485. this.$msg("商品添加成功");
  486. this.specClass = 'none';
  487. this.getshopdetail();
  488. }
  489. })
  490. }
  491. }else {
  492. uni.navigateTo({
  493. url:'/pages/myCenter/logion'
  494. })
  495. }
  496. },
  497. closeCar() {
  498. this.specClass = 'none';
  499. },
  500. //选择规格
  501. selectSpec(index, pid,chose,first,goods_storage){
  502. if(goods_storage == 0) {
  503. this.$msg("商品没库存啦");
  504. return;
  505. }
  506. let obj = {};
  507. obj.spec_id = first.spec_id;
  508. obj.value_name = chose.value_name;
  509. if(this.datalist.spec_list.length == this.chosename.length) {
  510. }else {
  511. this.chosename.push(obj);
  512. }
  513. this.specSelected = [];
  514. let list = this.datalist.spec_list[index].value_list;
  515. this.datalist.spec_list[index].value_list.forEach(item=>{
  516. if(item.value_id === pid){
  517. this.$set(item, 'selected', true);
  518. }else {
  519. this.$set(item, 'selected', false);
  520. }
  521. })
  522. this.chosename.forEach(items => {
  523. if(items.spec_id == first.spec_id) {
  524. items.value_name = chose.value_name
  525. };
  526. })
  527. let array = [];
  528. for(let i = 0; i < this.datalist.spec_list.length; i++) {
  529. for(let j = 0; j<this.datalist.spec_list[i].value_list.length;j++) {
  530. if(this.datalist.spec_list[i].value_list[j].selected) {
  531. array.push(this.datalist.spec_list[i].value_list[j].value_id);
  532. }
  533. }
  534. }
  535. this.arrayId = array;
  536. if(this.arrayId.length == this.datalist.spec_list.length) {
  537. this.scopemapId = array.join("_");
  538. let goodId = this.datalist.spec_map[this.scopemapId]; //
  539. let items = this.datalist.goods_list[goodId]
  540. items.value_name = chose.value_name;
  541. this.nuberImg = items.spec_img;
  542. this.specSelected.push(items)
  543. this.goods_storage = items.goods_storage;
  544. this.goods_id = items.goods_id;
  545. this.firstprice = items.goods_price;
  546. this.totalprice = items.goods_price*this.shopnumber;
  547. }
  548. // if(this.arrayId.length == this.datalist.spec_list.length) {
  549. // }
  550. // let obj = {};
  551. // obj.firstId = index;
  552. // obj.pid = pid;
  553. // this.arrayId.push(obj);
  554. // console.log(this.arrayId)
  555. // let arr = this.arrayId;
  556. // for(var i=0; i<arr.length; i++){
  557. // for(var j=i+1; j<arr.length; j++){
  558. // if(arr[i].firstId==arr[j].firstId){
  559. // arr.splice(j,1);
  560. // j--;
  561. // }
  562. // }
  563. // }
  564. // let newarray = []
  565. // arr.forEach(item => {
  566. // newarray.push(item.pid);
  567. // })
  568. // this.arrayId = arr;
  569. // if(this.arrayId.length == 0) {
  570. // this.scopemapId = newarray.toString(); ;
  571. // }else {
  572. // this.scopemapId = newarray.join("_");
  573. // }
  574. // console.log(this.scopemapId);
  575. //this.datalist.spec_list[index].value_list = list;
  576. },
  577. // 滚动到顶部
  578. upper(e) {
  579. },
  580. // 滚到底部
  581. lower(e) {
  582. console.log("底部")
  583. },
  584. // 滚动时触发
  585. scroll(e) {
  586. this.old.scrollTop = e.detail.scrollTop
  587. if(e.detail.scrollTop > this.windowHeight) {
  588. this.iScrolltop = 2;
  589. }else {
  590. this.iScrolltop = 1;
  591. }
  592. if(e.detail.scrollTop > 400) {
  593. this.isTop = true;
  594. }else{ //当距离小于500时显示回到顶部按钮
  595. this.isTop = false;
  596. }
  597. },
  598. //收藏
  599. toFavorite(){
  600. if(this.hasLogin && this.successlogion) {
  601. this.request({
  602. url: '/v1/favorites/collect',
  603. method: 'post',
  604. data: {
  605. type:'goods',
  606. fav_id: this.goodId
  607. },
  608. success: () => {
  609. this.getshopdetail()
  610. }
  611. })
  612. }else {
  613. uni.navigateTo({
  614. url:'/pages/myCenter/logion'
  615. })
  616. }
  617. //this.favorite = !this.favorite;
  618. },
  619. buy(){
  620. uni.navigateTo({
  621. url: './sureBuy'
  622. })
  623. },
  624. stopPrevent(){}
  625. },
  626. }
  627. </script>
  628. <style lang='scss'>
  629. page{
  630. /* background: $page-color-base; */
  631. /* padding-bottom: 160upx; */
  632. position: relative;
  633. }
  634. .icon-you{
  635. font-size: 28upx + 2upx;
  636. color: #888;
  637. }
  638. .carousel {
  639. height: 722upx;
  640. position:relative;
  641. swiper{
  642. height: 100%;
  643. }
  644. .image-wrapper{
  645. width: 100%;
  646. height: 100%;
  647. }
  648. .swiper-item {
  649. display: flex;
  650. justify-content: center;
  651. align-content: center;
  652. height: 750upx;
  653. overflow: hidden;
  654. image {
  655. width: 100%;
  656. height: 100%;
  657. }
  658. }
  659. }
  660. .titleLayout {
  661. display: flex;
  662. justify-content: space-between;
  663. padding-bottom: 20upx;
  664. }
  665. /* 标题简介 */
  666. .introduce-section{
  667. background: #fff;
  668. padding: 20upx 30upx;
  669. .title{
  670. font-size: 36upx;
  671. color: #303133;
  672. height: 50upx;
  673. line-height: 50upx;
  674. width: 70%;
  675. white-space:nowrap;
  676. overflow:hidden;
  677. text-overflow:ellipsis;
  678. }
  679. .titleRight {
  680. border-left: 1px solid #F5F5F5;
  681. padding-left: 32upx;
  682. }
  683. .price-box{
  684. display:flex;
  685. align-items:baseline;
  686. height: 64upx;
  687. padding: 10upx 0;
  688. font-size: 26upx;
  689. color:#fa436a;
  690. }
  691. .price{
  692. font-size: $font-lg + 2upx;
  693. }
  694. .m-price{
  695. margin:0 12upx;
  696. color: #909399;
  697. text-decoration: line-through;
  698. }
  699. .coupon-tip{
  700. align-items: center;
  701. padding: 4upx 10upx;
  702. background: #fa436a;
  703. font-size: 24upx;
  704. color: #fff;
  705. border-radius: 6upx;
  706. line-height: 1;
  707. transform: translateY(-4upx);
  708. }
  709. .bot-row{
  710. display:flex;
  711. align-items:center;
  712. height: 50upx;
  713. font-size: 24upx;
  714. color: #909399;
  715. text{
  716. flex: 1;
  717. }
  718. }
  719. }
  720. /* 分享 */
  721. .share-section{
  722. display:flex;
  723. align-items:center;
  724. color: #606266;
  725. background: linear-gradient(left, #fdf5f6, #fbebf6);
  726. padding: 12upx 30upx;
  727. .share-icon{
  728. display:flex;
  729. align-items:center;
  730. width: 70upx;
  731. height: 30upx;
  732. line-height: 1;
  733. border: 1px solid #fa436a;
  734. border-radius: 4upx;
  735. position:relative;
  736. overflow: hidden;
  737. font-size: 22upx;
  738. color: #fa436a;
  739. &:after{
  740. content: '';
  741. width: 50upx;
  742. height: 50upx;
  743. border-radius: 50%;
  744. left: -20upx;
  745. top: -12upx;
  746. position:absolute;
  747. background: #fa436a;
  748. }
  749. }
  750. .icon-xingxing{
  751. position:relative;
  752. z-index: 1;
  753. font-size: 24upx;
  754. margin-left: 2upx;
  755. margin-right: 10upx;
  756. color: #fff;
  757. line-height: 1;
  758. }
  759. .tit{
  760. font-size: 28upx;
  761. margin-left:10upx;
  762. }
  763. .icon-bangzhu1{
  764. padding: 10upx;
  765. font-size: 30upx;
  766. line-height: 1;
  767. }
  768. .share-btn{
  769. flex: 1;
  770. text-align:right;
  771. font-size: 24upx;
  772. color: #fa436a;
  773. }
  774. .icon-you{
  775. font-size: 24upx;
  776. margin-left: 4upx;
  777. color: #fa436a;
  778. }
  779. }
  780. .c-list{
  781. font-size: 24upx + 2upx;
  782. color: #606266;
  783. background: #fff;
  784. border-top: 20upx solid #F5F5F5;
  785. border-bottom: 20upx solid #F5F5F5;
  786. .c-row{
  787. display:flex;
  788. align-items:center;
  789. padding: 20upx 30upx;
  790. position:relative;
  791. }
  792. .tit{
  793. width: 140upx;
  794. }
  795. .con{
  796. flex: 1;
  797. color: #303133;
  798. .selected-text{
  799. margin-right: 10upx;
  800. }
  801. }
  802. .bz-list{
  803. height: 40upx;
  804. font-size: 24upx+2upx;
  805. color: #303133;
  806. text{
  807. display: inline-block;
  808. margin-right: 30upx;
  809. }
  810. }
  811. .con-list{
  812. flex: 1;
  813. display:flex;
  814. flex-direction: column;
  815. color: #303133;
  816. line-height: 40upx;
  817. }
  818. .red{
  819. color: #fa436a;
  820. }
  821. }
  822. /* 评价 */
  823. .eva-section{
  824. display: flex;
  825. flex-direction: column;
  826. padding: 20upx 30upx;
  827. background: #fff;
  828. margin-top: 16upx;
  829. .e-header{
  830. display: flex;
  831. align-items: center;
  832. height: 70upx;
  833. font-size: 24upx + 2upx;
  834. color: #909399;
  835. .tit{
  836. font-size: 28upx + 2upx;
  837. color: #303133;
  838. margin-right: 4upx;
  839. }
  840. .tip{
  841. flex: 1;
  842. text-align: right;
  843. }
  844. .icon-you{
  845. margin-left: 10upx;
  846. }
  847. }
  848. }
  849. .eva-box{
  850. display: flex;
  851. padding: 20upx 0;
  852. .portrait{
  853. flex-shrink: 0;
  854. width: 80upx;
  855. height: 80upx;
  856. border-radius: 100px;
  857. }
  858. .right{
  859. flex: 1;
  860. display: flex;
  861. flex-direction: column;
  862. font-size: 28upx;
  863. color: #606266;
  864. padding-left: 26upx;
  865. .con{
  866. font-size: 28upx;
  867. color: #303133;
  868. padding: 20upx 0;
  869. }
  870. .bot{
  871. display: flex;
  872. justify-content: space-between;
  873. font-size: 24upx;
  874. color:#909399;
  875. }
  876. }
  877. }
  878. /* 详情 */
  879. .detail-desc{
  880. background: #fff;
  881. margin-top: 16upx;
  882. margin-bottom: 135rpx;
  883. width: 100%;
  884. .d-header{
  885. display: flex;
  886. justify-content: center;
  887. align-items: center;
  888. height: 80upx;
  889. font-size: 28upx + 2upx;
  890. color: #303133;
  891. position: relative;
  892. text{
  893. padding: 0 20upx;
  894. background: #fff;
  895. position: relative;
  896. z-index: 1;
  897. }
  898. &:after{
  899. position: absolute;
  900. left: 50%;
  901. top: 50%;
  902. transform: translateX(-50%);
  903. width: 300upx;
  904. height: 0;
  905. content: '';
  906. border-bottom: 1px solid #ccc;
  907. }
  908. }
  909. }
  910. /* 规格选择弹窗 */
  911. .attr-content{
  912. padding: 10upx 30upx;
  913. .a-t{
  914. display: flex;
  915. image{
  916. width: 170upx;
  917. height: 170upx;
  918. flex-shrink: 0;
  919. margin-top: -40upx;
  920. border-radius: 8upx;;
  921. }
  922. .right{
  923. display: flex;
  924. flex-direction: column;
  925. padding-left: 24upx;
  926. font-size: 24upx + 2upx;
  927. color: #606266;
  928. line-height: 42upx;
  929. justify-content: space-around;
  930. .price{
  931. font-size: $font-lg;
  932. color: #fa436a;
  933. margin-bottom: 10upx;
  934. }
  935. .selected-text{
  936. margin-right: 10upx;
  937. }
  938. }
  939. }
  940. .attr-list{
  941. display: flex;
  942. flex-direction: column;
  943. font-size: 28upx + 2upx;
  944. color: #606266;
  945. padding-top: 30upx;
  946. padding-left: 10upx;
  947. }
  948. .item-list{
  949. padding: 20upx 0 0;
  950. display: flex;
  951. flex-wrap: wrap;
  952. text{
  953. display: flex;
  954. align-items: center;
  955. justify-content: center;
  956. background: #eee;
  957. margin-right: 20upx;
  958. margin-bottom: 20upx;
  959. border-radius: 100upx;
  960. min-width: 60upx;
  961. height: 60upx;
  962. padding: 0 20upx;
  963. font-size: 28upx;
  964. color: #303133;
  965. }
  966. .selected{
  967. background: #fbebee;
  968. color: #fa436a;
  969. }
  970. .disabled {
  971. color:#999;
  972. background: rgba(245,245,245, 0.5);
  973. }
  974. }
  975. }
  976. /* 弹出层 */
  977. .popup {
  978. position: fixed;
  979. left: 0;
  980. top: 0;
  981. right: 0;
  982. bottom: 100upx;
  983. z-index: 99;
  984. &.show {
  985. display: block;
  986. .mask{
  987. animation: showPopup 0.2s linear both;
  988. }
  989. .layer {
  990. animation: showLayer 0.2s linear both;
  991. }
  992. }
  993. &.hide {
  994. .mask{
  995. animation: hidePopup 0.2s linear both;
  996. }
  997. .layer {
  998. animation: hideLayer 0.2s linear both;
  999. }
  1000. }
  1001. &.none {
  1002. display: none;
  1003. }
  1004. .mask{
  1005. position: fixed;
  1006. top: 0;
  1007. width: 100%;
  1008. height: 90%;
  1009. z-index: 1;
  1010. background-color: rgba(0, 0, 0, 0.4);
  1011. }
  1012. .layer {
  1013. position: fixed;
  1014. z-index: 99;
  1015. bottom: 100upx;
  1016. width: 100%;
  1017. min-height: 40vh;
  1018. border-radius: 10upx 10upx 0 0;
  1019. background-color: #fff;
  1020. .btn{
  1021. height: 66upx;
  1022. line-height: 66upx;
  1023. border-radius: 100upx;
  1024. background: #fa436a;
  1025. font-size: 28upx + 2upx;
  1026. color: #fff;
  1027. margin: 30upx auto 20upx;
  1028. }
  1029. }
  1030. @keyframes showPopup {
  1031. 0% {
  1032. opacity: 0;
  1033. }
  1034. 100% {
  1035. opacity: 1;
  1036. }
  1037. }
  1038. @keyframes hidePopup {
  1039. 0% {
  1040. opacity: 1;
  1041. }
  1042. 90% {
  1043. opacity: 0;
  1044. }
  1045. }
  1046. @keyframes showLayer {
  1047. 0% {
  1048. transform: translateY(120%);
  1049. }
  1050. 100% {
  1051. transform: translateY(0%);
  1052. }
  1053. }
  1054. @keyframes hideLayer {
  1055. 0% {
  1056. transform: translateY(0);
  1057. }
  1058. 100% {
  1059. transform: translateY(120%);
  1060. }
  1061. }
  1062. }
  1063. .colored {
  1064. color: red;
  1065. }
  1066. .van-sticky {
  1067. /* z-index: 0!important; */
  1068. }
  1069. /* 详情固定 */
  1070. .activeColor {
  1071. /* background: #fff!important; */
  1072. position: fixed;
  1073. background-color: #fff;
  1074. top: 0upx;
  1075. z-index: 99;
  1076. margin-top: 0;
  1077. }
  1078. .numberchange {
  1079. padding-top: 48px;
  1080. overflow: hidden;
  1081. clear: both;
  1082. padding-right: 59rpx;
  1083. }
  1084. .uni-numbox {
  1085. float: right;
  1086. }
  1087. /* 底部操作菜单 */
  1088. .page-bottom{
  1089. position: fixed;
  1090. left: 0;
  1091. bottom: 0;
  1092. display: flex;
  1093. justify-content: center;
  1094. align-items: center;
  1095. width: 100vw;
  1096. height: 100upx;
  1097. z-index: 99;
  1098. background: rgba(255,255,255,.9);
  1099. .p-b-btn{
  1100. display:flex;
  1101. flex-direction: column;
  1102. align-items: center;
  1103. justify-content: center;
  1104. font-size: 24upx;
  1105. color: #606266;
  1106. width: 96upx;
  1107. height: 80upx;
  1108. .yticon{
  1109. font-size: 40upx;
  1110. line-height: 48upx;
  1111. color: #909399;
  1112. }
  1113. &.active, &.active .yticon{
  1114. color: #fa436a;
  1115. }
  1116. .icon-fenxiang2{
  1117. font-size: 42upx;
  1118. transform: translateY(-2upx);
  1119. }
  1120. .icon-shoucang{
  1121. font-size: 46upx;
  1122. }
  1123. }
  1124. .action-btn-group{
  1125. display: flex;
  1126. height: 76upx;
  1127. border-radius: 100px;
  1128. overflow: hidden;
  1129. box-shadow: 0 20upx 40upx -16upx #fa436a;
  1130. box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  1131. background: linear-gradient(to right, #ffac30,#fa436a,#F56C6C);
  1132. margin-left: 20upx;
  1133. position:relative;
  1134. &:after{
  1135. content: '';
  1136. position:absolute;
  1137. top: 50%;
  1138. right: 50%;
  1139. transform: translateY(-50%);
  1140. height: 28upx;
  1141. width: 0;
  1142. border-right: 1px solid rgba(255,255,255,.5);
  1143. }
  1144. .action-btn{
  1145. display:flex;
  1146. align-items: center;
  1147. justify-content: center;
  1148. width: 180upx;
  1149. height: 100%;
  1150. font-size: 28upx ;
  1151. padding: 0;
  1152. border-radius: 0;
  1153. background: transparent;
  1154. }
  1155. }
  1156. }
  1157. .changeimg {
  1158. width: 100%;
  1159. height: auto!important;
  1160. display: block;
  1161. text-align: center;
  1162. }
  1163. </style>