shop.vue 30 KB

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