shop.vue 30 KB

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