shop.vue 28 KB

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