shop.vue 31 KB

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