shop.vue 31 KB

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