shop.vue 28 KB

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