shop.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  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. if(this.datalist.store_id == 1 || this.datalist.goods_state != 1 || this.datalist.goods_storage < 1) {
  600. this.$msg("商品已下架");
  601. return;
  602. }
  603. this.request({
  604. url: '/v1/favorites/collect',
  605. method: 'post',
  606. data: {
  607. type:'goods',
  608. fav_id: this.goodId
  609. },
  610. success: () => {
  611. this.getshopdetail()
  612. }
  613. })
  614. }else {
  615. uni.navigateTo({
  616. url:'/pages/myCenter/logion'
  617. })
  618. }
  619. //this.favorite = !this.favorite;
  620. },
  621. buy(){
  622. uni.navigateTo({
  623. url: './sureBuy'
  624. })
  625. },
  626. stopPrevent(){}
  627. },
  628. }
  629. </script>
  630. <style lang='scss'>
  631. page{
  632. /* background: $page-color-base; */
  633. /* padding-bottom: 160upx; */
  634. position: relative;
  635. }
  636. .icon-you{
  637. font-size: 28upx + 2upx;
  638. color: #888;
  639. }
  640. .carousel {
  641. height: 722upx;
  642. position:relative;
  643. swiper{
  644. height: 100%;
  645. }
  646. .image-wrapper{
  647. width: 100%;
  648. height: 100%;
  649. }
  650. .swiper-item {
  651. display: flex;
  652. justify-content: center;
  653. align-content: center;
  654. height: 750upx;
  655. overflow: hidden;
  656. image {
  657. width: 100%;
  658. height: 100%;
  659. }
  660. }
  661. }
  662. .titleLayout {
  663. display: flex;
  664. justify-content: space-between;
  665. padding-bottom: 20upx;
  666. }
  667. /* 标题简介 */
  668. .introduce-section{
  669. background: #fff;
  670. padding: 20upx 30upx;
  671. .title{
  672. font-size: 36upx;
  673. color: #303133;
  674. height: 50upx;
  675. line-height: 50upx;
  676. width: 70%;
  677. white-space:nowrap;
  678. overflow:hidden;
  679. text-overflow:ellipsis;
  680. }
  681. .titleRight {
  682. border-left: 1px solid #F5F5F5;
  683. padding-left: 32upx;
  684. }
  685. .price-box{
  686. display:flex;
  687. align-items:baseline;
  688. height: 64upx;
  689. padding: 10upx 0;
  690. font-size: 26upx;
  691. color:#fa436a;
  692. }
  693. .price{
  694. font-size: $font-lg + 2upx;
  695. }
  696. .m-price{
  697. margin:0 12upx;
  698. color: #909399;
  699. text-decoration: line-through;
  700. }
  701. .coupon-tip{
  702. align-items: center;
  703. padding: 4upx 10upx;
  704. background: #fa436a;
  705. font-size: 24upx;
  706. color: #fff;
  707. border-radius: 6upx;
  708. line-height: 1;
  709. transform: translateY(-4upx);
  710. }
  711. .bot-row{
  712. display:flex;
  713. align-items:center;
  714. height: 50upx;
  715. font-size: 24upx;
  716. color: #909399;
  717. text{
  718. flex: 1;
  719. }
  720. }
  721. }
  722. /* 分享 */
  723. .share-section{
  724. display:flex;
  725. align-items:center;
  726. color: #606266;
  727. background: linear-gradient(left, #fdf5f6, #fbebf6);
  728. padding: 12upx 30upx;
  729. .share-icon{
  730. display:flex;
  731. align-items:center;
  732. width: 70upx;
  733. height: 30upx;
  734. line-height: 1;
  735. border: 1px solid #fa436a;
  736. border-radius: 4upx;
  737. position:relative;
  738. overflow: hidden;
  739. font-size: 22upx;
  740. color: #fa436a;
  741. &:after{
  742. content: '';
  743. width: 50upx;
  744. height: 50upx;
  745. border-radius: 50%;
  746. left: -20upx;
  747. top: -12upx;
  748. position:absolute;
  749. background: #fa436a;
  750. }
  751. }
  752. .icon-xingxing{
  753. position:relative;
  754. z-index: 1;
  755. font-size: 24upx;
  756. margin-left: 2upx;
  757. margin-right: 10upx;
  758. color: #fff;
  759. line-height: 1;
  760. }
  761. .tit{
  762. font-size: 28upx;
  763. margin-left:10upx;
  764. }
  765. .icon-bangzhu1{
  766. padding: 10upx;
  767. font-size: 30upx;
  768. line-height: 1;
  769. }
  770. .share-btn{
  771. flex: 1;
  772. text-align:right;
  773. font-size: 24upx;
  774. color: #fa436a;
  775. }
  776. .icon-you{
  777. font-size: 24upx;
  778. margin-left: 4upx;
  779. color: #fa436a;
  780. }
  781. }
  782. .c-list{
  783. font-size: 24upx + 2upx;
  784. color: #606266;
  785. background: #fff;
  786. border-top: 20upx solid #F5F5F5;
  787. border-bottom: 20upx solid #F5F5F5;
  788. .c-row{
  789. display:flex;
  790. align-items:center;
  791. padding: 20upx 30upx;
  792. position:relative;
  793. }
  794. .tit{
  795. width: 140upx;
  796. }
  797. .con{
  798. flex: 1;
  799. color: #303133;
  800. .selected-text{
  801. margin-right: 10upx;
  802. }
  803. }
  804. .bz-list{
  805. height: 40upx;
  806. font-size: 24upx+2upx;
  807. color: #303133;
  808. text{
  809. display: inline-block;
  810. margin-right: 30upx;
  811. }
  812. }
  813. .con-list{
  814. flex: 1;
  815. display:flex;
  816. flex-direction: column;
  817. color: #303133;
  818. line-height: 40upx;
  819. }
  820. .red{
  821. color: #fa436a;
  822. }
  823. }
  824. /* 评价 */
  825. .eva-section{
  826. display: flex;
  827. flex-direction: column;
  828. padding: 20upx 30upx;
  829. background: #fff;
  830. margin-top: 16upx;
  831. .e-header{
  832. display: flex;
  833. align-items: center;
  834. height: 70upx;
  835. font-size: 24upx + 2upx;
  836. color: #909399;
  837. .tit{
  838. font-size: 28upx + 2upx;
  839. color: #303133;
  840. margin-right: 4upx;
  841. }
  842. .tip{
  843. flex: 1;
  844. text-align: right;
  845. }
  846. .icon-you{
  847. margin-left: 10upx;
  848. }
  849. }
  850. }
  851. .eva-box{
  852. display: flex;
  853. padding: 20upx 0;
  854. .portrait{
  855. flex-shrink: 0;
  856. width: 80upx;
  857. height: 80upx;
  858. border-radius: 100px;
  859. }
  860. .right{
  861. flex: 1;
  862. display: flex;
  863. flex-direction: column;
  864. font-size: 28upx;
  865. color: #606266;
  866. padding-left: 26upx;
  867. .con{
  868. font-size: 28upx;
  869. color: #303133;
  870. padding: 20upx 0;
  871. }
  872. .bot{
  873. display: flex;
  874. justify-content: space-between;
  875. font-size: 24upx;
  876. color:#909399;
  877. }
  878. }
  879. }
  880. /* 详情 */
  881. .detail-desc{
  882. background: #fff;
  883. margin-top: 16upx;
  884. margin-bottom: 135rpx;
  885. width: 100%;
  886. .d-header{
  887. display: flex;
  888. justify-content: center;
  889. align-items: center;
  890. height: 80upx;
  891. font-size: 28upx + 2upx;
  892. color: #303133;
  893. position: relative;
  894. text{
  895. padding: 0 20upx;
  896. background: #fff;
  897. position: relative;
  898. z-index: 1;
  899. }
  900. &:after{
  901. position: absolute;
  902. left: 50%;
  903. top: 50%;
  904. transform: translateX(-50%);
  905. width: 300upx;
  906. height: 0;
  907. content: '';
  908. border-bottom: 1px solid #ccc;
  909. }
  910. }
  911. }
  912. /* 规格选择弹窗 */
  913. .attr-content{
  914. padding: 10upx 30upx;
  915. .a-t{
  916. display: flex;
  917. image{
  918. width: 170upx;
  919. height: 170upx;
  920. flex-shrink: 0;
  921. margin-top: -40upx;
  922. border-radius: 8upx;;
  923. }
  924. .right{
  925. display: flex;
  926. flex-direction: column;
  927. padding-left: 24upx;
  928. font-size: 24upx + 2upx;
  929. color: #606266;
  930. line-height: 42upx;
  931. justify-content: space-around;
  932. .price{
  933. font-size: $font-lg;
  934. color: #fa436a;
  935. margin-bottom: 10upx;
  936. }
  937. .selected-text{
  938. margin-right: 10upx;
  939. }
  940. }
  941. }
  942. .attr-list{
  943. display: flex;
  944. flex-direction: column;
  945. font-size: 28upx + 2upx;
  946. color: #606266;
  947. padding-top: 30upx;
  948. padding-left: 10upx;
  949. }
  950. .item-list{
  951. padding: 20upx 0 0;
  952. display: flex;
  953. flex-wrap: wrap;
  954. text{
  955. display: flex;
  956. align-items: center;
  957. justify-content: center;
  958. background: #eee;
  959. margin-right: 20upx;
  960. margin-bottom: 20upx;
  961. border-radius: 100upx;
  962. min-width: 60upx;
  963. height: 60upx;
  964. padding: 0 20upx;
  965. font-size: 28upx;
  966. color: #303133;
  967. }
  968. .selected{
  969. background: #fbebee;
  970. color: #fa436a;
  971. }
  972. .disabled {
  973. color:#999;
  974. background: rgba(245,245,245, 0.5);
  975. }
  976. }
  977. }
  978. /* 弹出层 */
  979. .popup {
  980. position: fixed;
  981. left: 0;
  982. top: 0;
  983. right: 0;
  984. bottom: 100upx;
  985. z-index: 99;
  986. &.show {
  987. display: block;
  988. .mask{
  989. animation: showPopup 0.2s linear both;
  990. }
  991. .layer {
  992. animation: showLayer 0.2s linear both;
  993. }
  994. }
  995. &.hide {
  996. .mask{
  997. animation: hidePopup 0.2s linear both;
  998. }
  999. .layer {
  1000. animation: hideLayer 0.2s linear both;
  1001. }
  1002. }
  1003. &.none {
  1004. display: none;
  1005. }
  1006. .mask{
  1007. position: fixed;
  1008. top: 0;
  1009. width: 100%;
  1010. height: 90%;
  1011. z-index: 1;
  1012. background-color: rgba(0, 0, 0, 0.4);
  1013. }
  1014. .layer {
  1015. position: fixed;
  1016. z-index: 99;
  1017. bottom: 100upx;
  1018. width: 100%;
  1019. min-height: 40vh;
  1020. border-radius: 10upx 10upx 0 0;
  1021. background-color: #fff;
  1022. .btn{
  1023. height: 66upx;
  1024. line-height: 66upx;
  1025. border-radius: 100upx;
  1026. background: #fa436a;
  1027. font-size: 28upx + 2upx;
  1028. color: #fff;
  1029. margin: 30upx auto 20upx;
  1030. }
  1031. }
  1032. @keyframes showPopup {
  1033. 0% {
  1034. opacity: 0;
  1035. }
  1036. 100% {
  1037. opacity: 1;
  1038. }
  1039. }
  1040. @keyframes hidePopup {
  1041. 0% {
  1042. opacity: 1;
  1043. }
  1044. 90% {
  1045. opacity: 0;
  1046. }
  1047. }
  1048. @keyframes showLayer {
  1049. 0% {
  1050. transform: translateY(120%);
  1051. }
  1052. 100% {
  1053. transform: translateY(0%);
  1054. }
  1055. }
  1056. @keyframes hideLayer {
  1057. 0% {
  1058. transform: translateY(0);
  1059. }
  1060. 100% {
  1061. transform: translateY(120%);
  1062. }
  1063. }
  1064. }
  1065. .colored {
  1066. color: red;
  1067. }
  1068. .van-sticky {
  1069. /* z-index: 0!important; */
  1070. }
  1071. /* 详情固定 */
  1072. .activeColor {
  1073. /* background: #fff!important; */
  1074. position: fixed;
  1075. background-color: #fff;
  1076. top: 0upx;
  1077. z-index: 99;
  1078. margin-top: 0;
  1079. }
  1080. .numberchange {
  1081. padding-top: 48px;
  1082. overflow: hidden;
  1083. clear: both;
  1084. padding-right: 59rpx;
  1085. }
  1086. .uni-numbox {
  1087. float: right;
  1088. }
  1089. /* 底部操作菜单 */
  1090. .page-bottom{
  1091. position: fixed;
  1092. left: 0;
  1093. bottom: 0;
  1094. display: flex;
  1095. justify-content: center;
  1096. align-items: center;
  1097. width: 100vw;
  1098. height: 100upx;
  1099. z-index: 99;
  1100. background: rgba(255,255,255,.9);
  1101. .p-b-btn{
  1102. display:flex;
  1103. flex-direction: column;
  1104. align-items: center;
  1105. justify-content: center;
  1106. font-size: 24upx;
  1107. color: #606266;
  1108. width: 96upx;
  1109. height: 80upx;
  1110. .yticon{
  1111. font-size: 40upx;
  1112. line-height: 48upx;
  1113. color: #909399;
  1114. }
  1115. &.active, &.active .yticon{
  1116. color: #fa436a;
  1117. }
  1118. .icon-fenxiang2{
  1119. font-size: 42upx;
  1120. transform: translateY(-2upx);
  1121. }
  1122. .icon-shoucang{
  1123. font-size: 46upx;
  1124. }
  1125. }
  1126. .action-btn-group{
  1127. display: flex;
  1128. height: 76upx;
  1129. border-radius: 100px;
  1130. overflow: hidden;
  1131. box-shadow: 0 20upx 40upx -16upx #fa436a;
  1132. box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  1133. background: linear-gradient(to right, #ffac30,#fa436a,#F56C6C);
  1134. margin-left: 20upx;
  1135. position:relative;
  1136. &:after{
  1137. content: '';
  1138. position:absolute;
  1139. top: 50%;
  1140. right: 50%;
  1141. transform: translateY(-50%);
  1142. height: 28upx;
  1143. width: 0;
  1144. border-right: 1px solid rgba(255,255,255,.5);
  1145. }
  1146. .action-btn{
  1147. display:flex;
  1148. align-items: center;
  1149. justify-content: center;
  1150. width: 180upx;
  1151. height: 100%;
  1152. font-size: 28upx ;
  1153. padding: 0;
  1154. border-radius: 0;
  1155. background: transparent;
  1156. }
  1157. }
  1158. }
  1159. .changeimg {
  1160. width: 100%;
  1161. height: auto!important;
  1162. display: block;
  1163. text-align: center;
  1164. }
  1165. </style>