shop.vue 29 KB

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