detail.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="one">
  5. <scroll-view scroll-y="true" class="scroll-view">
  6. <view class="list-scroll-view">
  7. <view class="one_1">
  8. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
  9. indicator-active-color="#FB1438" :interval="3000" :duration="1000">
  10. <swiper-item class="list" v-for="(item,index) in info.goods.file" :key="index">
  11. <image class="image" :src="item.url" mode="aspectFit">
  12. </image>
  13. </swiper-item>
  14. </swiper>
  15. <!-- 是否关注商品 -->
  16. <view class="goodsColect">
  17. <text @tap="toGoodscolect"
  18. :class="['iconfont',goodsColect?'icon-yduishoucangshixin-copy':'icon-yduishoucangkongxin']"></text>
  19. </view>
  20. <view class="acttags" v-if="info.goods.act_tags&&info.goods.act_tags.length>0">
  21. <text v-for="i in info.goods.act_tags" :key="i">{{i.label}}</text>
  22. </view>
  23. </view>
  24. <view class="one_2">
  25. <text class="money" v-if="infospecs.price"><text>特价¥</text>{{infospecs.price||0}}</text>
  26. <text class="money" v-else><text>¥</text>{{infospecs.sell_money||0}}</text>
  27. <text class="money"><text>¥</text>{{infospecs.flow_money||0}}</text>
  28. </view>
  29. <view class="one_3" v-if="discount">
  30. <text v-if="discount.full_decrement" class="act"
  31. v-for="(item,index) in discount.full_decrement" :key="index">{{item}}</text>
  32. <text v-if="discount.full_fold" class="act" v-for="(item,index) in discount.full_fold"
  33. :key="index">{{item}}</text>
  34. </view>
  35. <view class="one_4">
  36. <view class="name">
  37. {{info.goods.name}}
  38. </view>
  39. <view class="brief">
  40. {{info.goods.shot_brief||''}}
  41. </view>
  42. <view class="money">
  43. <!-- <text>运费{{infospecs.freight||'包邮'}}元</text> -->
  44. <text>{{info.goods.send_time}}内发货</text>
  45. </view>
  46. </view>
  47. <view class="one_5" @tap="toActivity">
  48. <view class="l">
  49. <text>{{info.act.length>0?`活动`:`暂无活动`}}</text>
  50. </view>
  51. <view class="r">
  52. <text class="iconfont icon-jiantouyou"></text>
  53. </view>
  54. </view>
  55. <view class="one_5" @tap="toSpec">
  56. <view class="l">
  57. 选择规格
  58. </view>
  59. <view class="r">
  60. <text class="iconfont icon-jiantouyou"></text>
  61. </view>
  62. </view>
  63. <view class="one_6" @tap="toEvaluate">
  64. <view class="l">
  65. <text>{{evaluate_num>0?`商品评价(${evaluate_num})`:`暂无评价`}}</text>
  66. </view>
  67. <view class="r">
  68. <text class="iconfont icon-jiantouyou"></text>
  69. </view>
  70. </view>
  71. <view class="one_7">
  72. <view class="one_7_1">
  73. <view class="shop_1">
  74. <image class="image"
  75. :src="info.shop.logo&&info.shop.logo.length>0?info.shop.logo[0].url:''"
  76. mode="aspectFit"></image>
  77. </view>
  78. <view class="shop_2">
  79. <view class="name">{{info.shop.name}}</view>
  80. <view class="num"><text>宝贝数:</text>{{info.shop.goods_num||0}}</view>
  81. </view>
  82. </view>
  83. <view class="one_7_2">
  84. <view class="score_1">
  85. <text>商品:</text>
  86. <text>{{info.shop.goods_score||5}}</text>
  87. <text>|</text>
  88. </view>
  89. <view class="score_1">
  90. <text>发货:</text>
  91. <text>{{info.shop.send_score||5}}</text>
  92. <text>|</text>
  93. </view>
  94. <view class="score_1">
  95. <text>服务:</text>
  96. <text>{{info.shop.service_score||5}}</text>
  97. </view>
  98. </view>
  99. <view class="one_7_3">
  100. <view class="btn">
  101. <button size="mini" @tap="toShop">进入店铺</button>
  102. </view>
  103. <view class="btn">
  104. <button size="mini" @tap="toShopcolect">{{shopColect==true?'已关注':'关注'}}</button>
  105. </view>
  106. </view>
  107. </view>
  108. <view class="one_8">
  109. <rich-text :nodes="info.goods.brief"></rich-text>
  110. </view>
  111. </view>
  112. </scroll-view>
  113. </view>
  114. <view class="two">
  115. <uni-goods-nav :options="options" :button-group="buttonGroup" @click="toNavleft"
  116. @buttonClick="toNavright" />
  117. </view>
  118. </view>
  119. <!-- 跳转菜单 -->
  120. <view class="bar_1">
  121. <text @tap="toMenubar" class="iconfont icon-gengduo"></text>
  122. </view>
  123. <view class="bar_2" v-if="is_menu">
  124. <view class="list" v-for="(item,index) in barList" :key="index" v-if="item.is_use=='0'"
  125. @click="toPath(item)">
  126. <image class="image" :src="item.normal&&item.normal.length>0?item.normal[0].url:''"></image>
  127. <text class="name"> {{item.name}}</text>
  128. </view>
  129. </view>
  130. <!-- 规格 -->
  131. <uni-popup ref="specShow" background-color="#fff" type="bottom" :is-mask-click="false">
  132. <view class="popup">
  133. <view class="close">
  134. <text @click="toClose" class="iconfont icon-shanchu"></text>
  135. </view>
  136. <view class="info_1" v-if="popupShow=='1'">
  137. <view class="info_1">
  138. <scroll-view scroll-y="true" class="scroll-view">
  139. <view class="list-scroll-view">
  140. <view class="one">
  141. <view class="one_1">
  142. <view class="l">
  143. <image class="image"
  144. :src="specsInfo.file.length>0?specsInfo.file[0].url:info.goods.file[0].url"
  145. mode="aspectFill" @tap="diaView"></image>
  146. </view>
  147. <view class="r">
  148. <view class="money">
  149. <text v-if="specsInfo.price"
  150. class="money_1"><text>特价¥</text>{{specsInfo.price}}</text>
  151. <text v-if="!specsInfo.price"
  152. class="money_1"><text>¥</text>{{specsInfo.sell_money}}</text>
  153. <text class="money_1"><text>¥</text>{{specsInfo.flow_money}}</text>
  154. </view>
  155. <view class="other_1">
  156. <text>已选:</text>
  157. <text>{{specsInfo.name}}</text>
  158. </view>
  159. <view class="other_1">
  160. <text>运费:</text>
  161. <text>{{specsInfo.freight===0?'包邮':specsInfo.freight+'元'}}</text>
  162. </view>
  163. </view>
  164. </view>
  165. <view class="one_2">
  166. <view class="one_2_1">
  167. 规格
  168. </view>
  169. <view class="one_2_2">
  170. <view
  171. :class="['list',is_specs!=index&&item.num>0?'list':is_specs!=index&&item.num<=0?'huilist':is_specs==index&&item.num>0?'redlist':is_specs==index&&item.num<=0?'huiilist':'list']"
  172. v-for="(item,index) in info.specs" :key="index" @tap="toSpecs(item)">
  173. <text>{{item.name}}</text>
  174. </view>
  175. </view>
  176. </view>
  177. <view class="one_3">
  178. <view class="one_3_1">
  179. <text>数量</text>
  180. </view>
  181. <view class="one_3_1">
  182. <uni-number-box v-model="buy_num" @change="toCount" :min="1"
  183. :max="specsInfo.num">
  184. </uni-number-box>
  185. </view>
  186. <view class="one_3_1">
  187. <text>库存{{specsInfo.num||0}}</text>
  188. </view>
  189. </view>
  190. </view>
  191. </view>
  192. </scroll-view>
  193. </view>
  194. <view class="info_2">
  195. <view :class="[specsInfo.can_group=='0'?'btns':'btn']" v-if="btn_type=='0'">
  196. <button :disabled="is_zero" :class="[is_zero?'btncolor':'']" @tap="toMarket">加入购物车</button>
  197. </view>
  198. <view :class="[specsInfo.can_group=='0'?'btns':'btn']" v-if="btn_type=='1'">
  199. <button :disabled="is_zero" :class="[is_zero?'btncolor':'']" @tap="toBuy">立即购买</button>
  200. </view>
  201. <view :class="[specsInfo.can_group=='0'?'btns':'btn']" v-if="specsInfo.can_group=='0'">
  202. <button :disabled="is_zero" :class="[is_zero?'btncolor':'']" @tap="toGroup">参团</button>
  203. </view>
  204. </view>
  205. </view>
  206. <view class="info_3" v-else-if="popupShow=='2'">
  207. <scroll-view scroll-y="true" class="scroll-view">
  208. <view class="list" v-for="(item,index) in info.act" :key="index">
  209. <view class="list_1" @tap="toAct(item)">
  210. <view class="title_1">
  211. <view class="l">
  212. <text>{{item.tag||'暂无'}}</text>{{item.act_time.title}}
  213. </view>
  214. <view class="r">
  215. <text class="iconfont icon-jiantouyou"></text>
  216. </view>
  217. </view>
  218. <view class="title_2">
  219. <view class="text" v-if="item.type=='5'||item.type=='6'">{{item.text}}</view>
  220. <view class="time">{{item.config.time_start}}-{{item.config.time_end}}</view>
  221. </view>
  222. <view class="title_2" v-if="item.type=='2'">
  223. <view class="specList" v-for="(tag,indexx) in item.list" :key="indexx">
  224. <view class="name">规格:{{tag.spec_name}}</view>
  225. <view class="giftList" v-for="(tags,indexs) in tag.gift" :key="indexs"
  226. @tap.stop="tags.type=='0' && getDetail(tags)">
  227. <view class="left">
  228. <view class="goods">{{tags.goods_name}}{{tags.spec_name}}</view>
  229. <view class="goods">{{tags.desc}}</view>
  230. <view class="num">×{{tags.num}}</view>
  231. </view>
  232. <view class="right"><text class="iconfont icon-jiantouyou"></text>
  233. </view>
  234. </view>
  235. </view>
  236. </view>
  237. </view>
  238. </view>
  239. </scroll-view>
  240. </view>
  241. </view>
  242. </uni-popup>
  243. <view class="dialog" v-if="dialog.show==true" @tap="dialogClose">
  244. <view class="dialog_1" v-if="dialog.type=='1'">
  245. <swiper class="swiper" circular @change="diaSpecs" :current="is_specs">
  246. <swiper-item class="list" v-for="(item,index) in info.specs" :key="index">
  247. <view class="list_1">
  248. <image class="image" :src="item.file.length>0?item.file[0].url:info.goods.file[0].url"
  249. mode="aspectFit"></image>
  250. </view>
  251. <view class="name">
  252. <text>{{item.name}}</text>
  253. </view>
  254. </swiper-item>
  255. </swiper>
  256. </view>
  257. </view>
  258. </mobile-frame>
  259. </template>
  260. <script>
  261. export default {
  262. data() {
  263. return {
  264. // 系统设置
  265. config: {},
  266. // 商品id
  267. id: '',
  268. // 分享人id
  269. inviter: '',
  270. // 当前用户信息
  271. user: {},
  272. // 是否关注商品
  273. goodsColect: false,
  274. // 是否关注店铺
  275. shopColect: false,
  276. // 评价数
  277. evaluate_num: 2,
  278. // 商品详情
  279. info: {},
  280. infospecs: {},
  281. // 优惠
  282. discount: {},
  283. // 底部菜单
  284. options: [{
  285. icon: 'shop',
  286. text: '店铺',
  287. type: 'shop',
  288. route: 'pagesHome/shop/index',
  289. },
  290. {
  291. icon: 'cart',
  292. text: '购物车',
  293. type: 'market',
  294. route: 'pages/market/index',
  295. },
  296. ],
  297. buttonGroup: [{
  298. text: '加入购物车',
  299. backgroundColor: 'linear-gradient(90deg, #FFCD1E, #FF8A18)',
  300. color: '#fff',
  301. type: '0'
  302. },
  303. {
  304. text: '立即购买',
  305. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  306. color: '#fff',
  307. type: '1'
  308. }
  309. ],
  310. // 系统菜单
  311. barList: [],
  312. is_menu: false,
  313. // 规格弹框
  314. popupShow: '1',
  315. // 规格信息
  316. is_specs: 0,
  317. btn_type: '1',
  318. specsInfo: {},
  319. // 是否零库存
  320. is_zero: false,
  321. // 购买数量
  322. buy_num: 1,
  323. // 规格弹出框
  324. dialog: {
  325. show: false,
  326. type: '1'
  327. },
  328. };
  329. },
  330. onLoad: async function(e) {
  331. const that = this;
  332. that.$set(that, `id`, e.id || '');
  333. that.$set(that, `inviter`, e.inviter || '');
  334. await that.searchConfig();
  335. await that.search();
  336. await that.configShare();
  337. },
  338. onShow: async function() {
  339. const that = this;
  340. await that.watchLogin();
  341. },
  342. onUnload: function() {
  343. // 页面卸载,重新部署分享内容
  344. const that = this;
  345. if (that.config) {
  346. // 赋值默认值
  347. that.$config.share = {
  348. title: that.config.title,
  349. path: '/pages/index/index',
  350. imageUrl: that.config.config.share[0].url
  351. }
  352. }
  353. },
  354. methods: {
  355. // 查询系统设置
  356. searchConfig() {
  357. const that = this;
  358. uni.getStorage({
  359. key: 'config',
  360. success: function(res) {
  361. let data = res.data;
  362. that.$set(that, `config`, data);
  363. if (data.bottom_menu && data.bottom_menu.list.length > 0) {
  364. let list = data.bottom_menu.list.sort((a, b) => {
  365. return a.sort - b.sort
  366. });
  367. that.$set(that, `barList`, list)
  368. }
  369. }
  370. })
  371. },
  372. // 查询用户信息
  373. watchLogin() {
  374. const that = this;
  375. uni.getStorage({
  376. key: 'token',
  377. success: async function(res) {
  378. let user = that.$jwt(res.data);
  379. if (user) that.$set(that, `user`, user);
  380. await that.searchOther();
  381. },
  382. fail: function(err) {
  383. console.log('暂无用户信息');
  384. }
  385. })
  386. },
  387. // 查询其他信息
  388. async searchOther() {
  389. const that = this;
  390. let user = that.user;
  391. let res;
  392. // 是否关注商品
  393. res = await that.$api(`/storeGoods/check`, `GET`, {
  394. customer: user._id,
  395. goods: that.id
  396. });
  397. if (res.errcode == '0') that.$set(that, `goodsColect`, res.data);
  398. // 是否关注店铺
  399. res = await that.$api(`/storeShop/check`, `GET`, {
  400. customer: user._id,
  401. shop: that.info?.shop?._id
  402. });
  403. if (res.errcode == '0') that.$set(that, `shopColect`, res.data)
  404. },
  405. // 查询商品信息
  406. async search() {
  407. const that = this;
  408. let id = that.id;
  409. if (id) {
  410. let res;
  411. res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  412. id: id
  413. });
  414. if (res.errcode == '0') {
  415. let data = res.data;
  416. if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi,
  417. '<img class="rich-img"');
  418. // 特价
  419. let act;
  420. act = data.act.find(i => i.type == '3')
  421. if (act) {
  422. for (let val of act.list) {
  423. for (let [index, arr] of data.specs.entries()) {
  424. if (val.spec == arr._id) arr.price = val.price
  425. }
  426. }
  427. }
  428. // 显示最低价格的规格信息,不考虑库存问题
  429. if (data.specs && data.specs.length > 0) {
  430. // 规格排序
  431. data.specs.sort(function(a, b) {
  432. let i, j;
  433. if (a.price) i = 'price'
  434. else i = 'sell_money'
  435. if (b.price) j = 'price'
  436. else j = 'sell_money'
  437. return a[i] - b[j];
  438. })
  439. that.$set(that, `infospecs`, data.specs[0])
  440. }
  441. that.$set(that, `info`, data);
  442. // 优惠
  443. act = data.act.find(i => i.type == '5')
  444. if (act) that.$set(that.discount, `full_decrement`, act.text.split(';'));
  445. act = data.act.find(i => i.type == '6')
  446. if (act) that.$set(that.discount, `full_fold`, act.text.split(';'));
  447. // 查询规格
  448. that.searchSpecs(data.specs);
  449. // 查询评价数
  450. that.searchRate(data);
  451. }
  452. } else {
  453. uni.showToast({
  454. title: '暂无商品信息',
  455. icon: 'none'
  456. })
  457. }
  458. },
  459. // 查询规格
  460. searchSpecs(e) {
  461. const that = this;
  462. if (e.length > 0) {
  463. let data = e.find(i => i.num > 0);
  464. let dataIndex = e.findIndex(i => i._id == data._id);
  465. if (data) {
  466. that.$set(that, `specsInfo`, data);
  467. that.$set(that, `is_specs`, dataIndex);
  468. }
  469. }
  470. },
  471. // 活动说明
  472. toActivity() {
  473. const that = this;
  474. if (that.info.act.length > 0) {
  475. that.$set(that, `popupShow`, '2')
  476. that.$refs.specShow.open();
  477. }
  478. },
  479. // 查看正品详情
  480. getDetail(e) {
  481. const that = this;
  482. uni.navigateTo({
  483. url: `/pagesHome/order/detail?id=${e.goods}`
  484. })
  485. },
  486. // 选择规格
  487. toSpecs(e) {
  488. const that = this;
  489. let specs = that.info.specs;
  490. let dataIndex = specs.findIndex(i => i._id == e._id);
  491. that.$set(that, `is_specs`, dataIndex);
  492. that.$set(that, `specsInfo`, e)
  493. that.$set(that, `buy_num`, 1);
  494. if (e.num <= 0) that.$set(that, `is_zero`, true)
  495. else that.$set(that, `is_zero`, false)
  496. },
  497. // 计数器
  498. toCount(e) {
  499. const that = this;
  500. that.$set(that, `buy_num`, e)
  501. },
  502. // 查询评价数
  503. async searchRate(e) {
  504. const that = this;
  505. let res = await that.$api(`/goodsRate`, `GET`, {
  506. goods: e.goods._id
  507. })
  508. if (res.errcode == '0') that.$set(that, `evaluate_num`, res.total);
  509. },
  510. // 关注商品
  511. async toGoodscolect() {
  512. const that = this;
  513. let user = that.user;
  514. if (user && user._id) {
  515. let res = await that.$api(`/storeGoods`, `POST`, {
  516. customer: user._id,
  517. goods: that.id
  518. });
  519. if (res.errcode == '0') {
  520. uni.showToast({
  521. title: res.data.msg,
  522. icon: 'none'
  523. })
  524. that.$set(that, `goodsColect`, res.data.result)
  525. }
  526. } else {
  527. uni.showToast({
  528. title: '暂无账号,无法收藏商品',
  529. icon: 'none'
  530. })
  531. }
  532. },
  533. // 选择规格
  534. toSpec() {
  535. const that = this;
  536. this.$set(that, `popupShow`, '1')
  537. that.$refs.specShow.open();
  538. },
  539. // 加入购物车
  540. async toMarket() {
  541. const that = this;
  542. let user = that.user;
  543. let info = that.info;
  544. let specsInfo = that.specsInfo;
  545. if (user && user._id) {
  546. let obj = {
  547. customer: user._id,
  548. shop: info.shop._id,
  549. goods: info.goods._id,
  550. goodsSpec: specsInfo._id,
  551. num: that.buy_num,
  552. inviter: that.inviter
  553. }
  554. let res = await that.$api(`/cart`, 'POST', obj)
  555. if (res.errcode == '0') {
  556. uni.showToast({
  557. title: `加入购物车成功`,
  558. icon: 'none'
  559. })
  560. that.toClose();
  561. } else {
  562. uni.showToast({
  563. title: res.errmsg,
  564. icon: 'none'
  565. })
  566. }
  567. } else {
  568. uni.navigateTo({
  569. url: `/pages/login/index`
  570. })
  571. }
  572. },
  573. // 立即购买
  574. async toBuy() {
  575. const that = this;
  576. let user = that.user;
  577. let info = that.info;
  578. let specsInfo = that.specsInfo;
  579. let act = that.info.act.map(item => {
  580. return item._id
  581. })
  582. if (user && user._id) {
  583. let obj = [{
  584. customer: user._id,
  585. shop: info.shop._id,
  586. goods: info.goods._id,
  587. goodsSpec: specsInfo._id,
  588. num: that.buy_num,
  589. inviter: that.inviter,
  590. act
  591. }]
  592. let res = await that.$api(`/util/checkCanBuy`, 'POST', obj)
  593. if (res.errcode == '0') {
  594. if (res.data.result == true) {
  595. uni.navigateTo({
  596. url: `/pagesHome/order/order?key=${res.data.key}`
  597. })
  598. } else {
  599. uni.showToast({
  600. title: res.data.msg,
  601. icon: 'none'
  602. })
  603. }
  604. } else {
  605. uni.showToast({
  606. title: res.errmsg,
  607. icon: 'none'
  608. })
  609. }
  610. } else {
  611. uni.navigateTo({
  612. url: `/pages/login/index`
  613. })
  614. }
  615. },
  616. // 参团
  617. toGroup() {
  618. const that = this;
  619. let specs_id = that.specsInfo._id;
  620. let id = that.id;
  621. uni.navigateTo({
  622. url: `/pagesHome/group/index?specs_id=${specs_id}&goods_id=${id}`
  623. })
  624. },
  625. // 关闭弹框
  626. toClose() {
  627. const that = this;
  628. that.$set(that, `btn_type`, '1');
  629. that.$refs.specShow.close();
  630. },
  631. // 评价
  632. toEvaluate() {
  633. const that = this;
  634. uni.navigateTo({
  635. url: `/pagesHome/order/appraise?id=${that.info.goods._id}`
  636. })
  637. },
  638. // 进入店铺
  639. toShop() {
  640. const that = this;
  641. let info = that.info;
  642. uni.navigateTo({
  643. url: `/pagesHome/shop/index?id=${info.shop._id}`
  644. })
  645. },
  646. // 关注店铺
  647. async toShopcolect() {
  648. const that = this;
  649. let user = that.user;
  650. if (user && user._id) {
  651. let res = await that.$api(`/storeShop`, `POST`, {
  652. customer: user._id,
  653. shop: that.info.shop._id
  654. });
  655. if (res.errcode == '0') {
  656. uni.showToast({
  657. title: res.data.msg,
  658. icon: 'none'
  659. })
  660. that.$set(that, `shopColect`, res.data.result)
  661. }
  662. } else {
  663. uni.showToast({
  664. title: '暂无账号,无法关注商铺',
  665. icon: 'none'
  666. })
  667. }
  668. },
  669. // 店铺,购物车
  670. toNavleft(e) {
  671. const that = this;
  672. if (e.content.type == 'shop') {
  673. that.toShop();
  674. } else if (e.content.type == 'market') {
  675. let obj = {
  676. route: e.content.route
  677. }
  678. that.toPath(obj)
  679. }
  680. },
  681. // 加入购物车,立即购买
  682. toNavright(e) {
  683. const that = this;
  684. that.$set(that, `popupShow`, '1');
  685. that.$set(that, `btn_type`, e.content.type);
  686. that.$refs.specShow.open();
  687. },
  688. // 右侧菜单
  689. toMenubar() {
  690. const that = this;
  691. that.$set(that, `is_menu`, that.is_menu ? false : true)
  692. },
  693. toPath(e) {
  694. let url = `/${e.route}`;
  695. uni.reLaunch({
  696. url
  697. })
  698. },
  699. // 配置分享内容
  700. configShare() {
  701. const that = this;
  702. let id = that.id;
  703. let inviter = that.user && that.user._id ? that.user._id : '';
  704. let title = that.info && that.info.goods ? that.info.goods.name : '';
  705. let imageUrl = that.info && that.info.goods ? that.info.goods.file[0].url : '';
  706. that.$config.share = {
  707. title: title,
  708. path: `/pagesHome/order/detail?id=${id}&inviter=${inviter}`,
  709. imageUrl: imageUrl
  710. }
  711. },
  712. // 规格预览
  713. diaView() {
  714. const that = this;
  715. that.$set(that, `dialog`, {
  716. show: true,
  717. type: '1'
  718. })
  719. },
  720. // 查看活动
  721. toAct(item) {
  722. uni.navigateTo({
  723. url: `/pagesRest/activity/info?id=${item._id}`
  724. })
  725. },
  726. // 弹框选择规格
  727. diaSpecs(e) {
  728. const that = this;
  729. let specs = that.info.specs;
  730. let index = e.detail.current;
  731. let data = specs[index];
  732. that.$set(that, `is_specs`, index);
  733. that.$set(that, `specsInfo`, data);
  734. that.$set(that, `buy_num`, 1);
  735. if (data.num <= 0) that.$set(that, `is_zero`, true)
  736. else that.$set(that, `is_zero`, false)
  737. },
  738. // 关闭弹框
  739. dialogClose() {
  740. const that = this;
  741. that.$set(that, `dialog`, {
  742. show: false,
  743. type: '1'
  744. })
  745. }
  746. }
  747. }
  748. </script>
  749. <style lang="scss">
  750. .main {
  751. display: flex;
  752. flex-direction: column;
  753. width: 100vw;
  754. height: 100vh;
  755. .one {
  756. position: relative;
  757. flex-grow: 1;
  758. .one_1 {
  759. border-bottom: 0.5vw solid var(--f9Color);
  760. swiper {
  761. height: 44vh !important;
  762. }
  763. .list {
  764. border-radius: 5px;
  765. .image {
  766. width: 100%;
  767. height: 100%;
  768. border-radius: 5px;
  769. background-color: #fff;
  770. }
  771. }
  772. .goodsColect {
  773. position: fixed;
  774. top: 2vw;
  775. right: 3vw;
  776. z-index: 99;
  777. background-color: #858585;
  778. border-radius: 90px;
  779. text {
  780. font-size: 30px;
  781. }
  782. }
  783. .acttags {
  784. position: absolute;
  785. top: 1vw;
  786. left: 1vw;
  787. width: 97%;
  788. text {
  789. display: inline-block;
  790. background-color: #ff0000;
  791. color: #fff;
  792. border-radius: 1vw;
  793. padding: 0.5vw;
  794. font-size: 12px;
  795. margin: 0 1vw 0 0;
  796. }
  797. }
  798. }
  799. .one_2 {
  800. border-bottom: 0.5vw solid var(--f9Color);
  801. padding: 2vw;
  802. .money {
  803. font-size: 20px;
  804. padding: 0 1vw 0 0;
  805. color: #ff0000;
  806. font-weight: bold;
  807. text {
  808. font-size: 14px;
  809. }
  810. }
  811. .money:last-child {
  812. font-size: 16px;
  813. color: #858585;
  814. text-decoration: line-through;
  815. }
  816. }
  817. .one_3 {
  818. display: flex;
  819. flex-wrap: wrap;
  820. padding: 1vw;
  821. border-bottom: 0.5vw solid var(--f9Color);
  822. .act {
  823. font-size: 12px;
  824. border: 1px solid var(--fFB1Color);
  825. margin: 0 1vw 1vw 0;
  826. color: var(--fFB1Color);
  827. border-radius: 6px;
  828. padding: 0 1vw;
  829. }
  830. }
  831. .one_4 {
  832. border-bottom: 0.5vw solid var(--f9Color);
  833. padding: 2vw;
  834. .name {
  835. font-size: 17px;
  836. font-weight: bold;
  837. margin: 0 0 2vw 0;
  838. }
  839. .brief {
  840. font-size: 14px;
  841. color: #858585;
  842. margin: 0 0 1vw 0;
  843. }
  844. .money {
  845. font-size: 13px;
  846. color: #858585;
  847. text {
  848. padding: 0 2vw 0 0;
  849. }
  850. }
  851. }
  852. .one_5 {
  853. display: flex;
  854. justify-content: space-between;
  855. padding: 2vw;
  856. border-bottom: 0.5vw solid var(--f9Color);
  857. font-size: 14px;
  858. }
  859. .one_6 {
  860. display: flex;
  861. justify-content: space-between;
  862. padding: 2vw;
  863. border-bottom: 0.5vw solid var(--f9Color);
  864. font-size: 14px;
  865. }
  866. .one_7 {
  867. padding: 2vw;
  868. border-bottom: 0.5vw solid var(--f9Color);
  869. .one_7_1 {
  870. margin: 0 0 1vw 0;
  871. display: flex;
  872. .shop_1 {
  873. width: 15vw;
  874. height: 15vw;
  875. border: 1px solid #f1f1f1;
  876. .image {
  877. width: 100%;
  878. height: 100%;
  879. }
  880. }
  881. .shop_2 {
  882. width: 78vw;
  883. padding: 0 0 0 2vw;
  884. .name {
  885. font-size: 14px;
  886. margin: 0 0 1vw 0;
  887. }
  888. .num {
  889. font-size: 12px;
  890. color: #858585;
  891. text:last-child {
  892. color: #000;
  893. }
  894. }
  895. }
  896. }
  897. .one_7_2 {
  898. margin: 0 0 2vw 0;
  899. display: flex;
  900. justify-content: space-between;
  901. padding: 2vw 0;
  902. .score_1 {
  903. width: 33vw;
  904. text-align: center;
  905. font-size: 14px;
  906. color: #858585;
  907. text:nth-child(2) {
  908. color: #ff0000;
  909. }
  910. text:nth-child(3) {
  911. float: right;
  912. }
  913. }
  914. }
  915. .one_7_3 {
  916. display: flex;
  917. justify-content: space-around;
  918. .btn {
  919. width: 40vw;
  920. button {
  921. width: 100%;
  922. font-size: 15px;
  923. }
  924. }
  925. }
  926. }
  927. .one_8 {
  928. padding: 2vw;
  929. .rich-img {
  930. width: 100% !important;
  931. display: block;
  932. }
  933. }
  934. }
  935. .two {
  936. width: 100vw;
  937. height: 8vh;
  938. overflow: hidden;
  939. }
  940. }
  941. .scroll-view {
  942. position: absolute;
  943. top: 0;
  944. left: 0;
  945. right: 0;
  946. bottom: 0;
  947. .list-scroll-view {
  948. display: flex;
  949. flex-direction: column;
  950. }
  951. }
  952. .bar_1 {
  953. position: fixed;
  954. right: 2vw;
  955. bottom: 20vw;
  956. text {
  957. background-color: #858585;
  958. border-radius: 90px;
  959. font-size: 30px;
  960. }
  961. }
  962. .bar_2 {
  963. position: fixed;
  964. right: 2vw;
  965. bottom: 28vw;
  966. width: 27vw;
  967. background: #ffffff;
  968. padding: 0 2vw;
  969. box-shadow: 0 0 5px #858585;
  970. .list {
  971. display: flex;
  972. border-bottom: 1px solid #f1f1f1;
  973. padding: 1vw 0;
  974. .image {
  975. width: 8vw;
  976. height: 8vw;
  977. }
  978. .name {
  979. font-size: 14px;
  980. position: relative;
  981. top: 2vw;
  982. left: 2vw;
  983. }
  984. }
  985. .list:last-child {
  986. border-bottom: none;
  987. }
  988. }
  989. .uni-popup {
  990. z-index: 9999 !important;
  991. }
  992. .popup {
  993. display: flex;
  994. flex-direction: column;
  995. width: 100vw;
  996. height: 60vh;
  997. .close {
  998. text-align: right;
  999. padding: 2vw;
  1000. }
  1001. .info_1 {
  1002. position: relative;
  1003. display: flex;
  1004. flex-direction: column;
  1005. height: 54vh;
  1006. .info_1 {
  1007. position: relative;
  1008. flex-grow: 1;
  1009. .one {
  1010. padding: 2vw;
  1011. .one_1 {
  1012. display: flex;
  1013. margin: 0 0 2vw 0;
  1014. padding: 0 0 2vw 0;
  1015. border-bottom: 0.5vw solid var(--f9Color);
  1016. .l {
  1017. width: 25vw;
  1018. height: 25vw;
  1019. .image {
  1020. width: 100%;
  1021. height: 100%;
  1022. border-radius: 5px;
  1023. }
  1024. }
  1025. .r {
  1026. width: 70vw;
  1027. padding: 0 0 0 2vw;
  1028. .money {
  1029. margin: 0 0 2vw 0;
  1030. .money_1 {
  1031. font-size: 20px;
  1032. color: #ff0000;
  1033. padding: 0 2vw 0 0;
  1034. text {
  1035. font-size: 14px;
  1036. }
  1037. }
  1038. .money_1:last-child {
  1039. font-size: 16px;
  1040. color: #858585;
  1041. text-decoration: line-through;
  1042. }
  1043. }
  1044. .other_1 {
  1045. font-size: 15px;
  1046. color: #858585;
  1047. text:last-child {
  1048. color: #000000;
  1049. }
  1050. }
  1051. }
  1052. }
  1053. .one_2 {
  1054. margin: 0 0 2vw 0;
  1055. border-bottom: 0.5vw solid var(--f9Color);
  1056. .one_2_1 {
  1057. font-size: 14px;
  1058. margin: 0 0 2vw 0;
  1059. }
  1060. .one_2_2 {
  1061. display: flex;
  1062. flex-wrap: wrap;
  1063. .list {
  1064. background-color: #F5F5F5;
  1065. margin: 0 2vw 2vw 0;
  1066. padding: 0.5vw 1vw;
  1067. border-radius: 5px;
  1068. text {
  1069. font-size: 14px;
  1070. color: #000;
  1071. }
  1072. }
  1073. .huilist {
  1074. background-color: #DCDCDC;
  1075. text {
  1076. color: #858585;
  1077. }
  1078. }
  1079. .redlist {
  1080. background-color: #ff0000;
  1081. text {
  1082. color: #ffffff;
  1083. }
  1084. }
  1085. .huiilist {
  1086. background-color: #808080;
  1087. text {
  1088. color: #cccccc;
  1089. }
  1090. }
  1091. }
  1092. }
  1093. .one_3 {
  1094. display: flex;
  1095. .one_3_1 {
  1096. margin: 0 2vw 0 0;
  1097. text {
  1098. font-size: 14px;
  1099. color: #858585;
  1100. }
  1101. }
  1102. }
  1103. }
  1104. }
  1105. .info_2 {
  1106. display: flex;
  1107. text-align: center;
  1108. justify-content: space-between;
  1109. .btns {
  1110. width: 50vw;
  1111. }
  1112. .btn {
  1113. width: 100vw;
  1114. }
  1115. button {
  1116. width: 100%;
  1117. border-radius: 0;
  1118. background-color: var(--fFB1Color);
  1119. color: #fff;
  1120. border: 1px solid #f1f1f1;
  1121. }
  1122. .btncolor {
  1123. background: #f1f1f1;
  1124. color: #858585;
  1125. }
  1126. }
  1127. }
  1128. .info_3 {
  1129. position: relative;
  1130. flex-grow: 1;
  1131. .list {
  1132. margin: 0 2vw 2vw 2vw;
  1133. border-radius: 10px;
  1134. background-color: #FFF8DC;
  1135. .list_1 {
  1136. padding: 2vw;
  1137. font-size: 14px;
  1138. .title_1 {
  1139. display: flex;
  1140. justify-content: space-between;
  1141. margin: 1vw 0;
  1142. .l {
  1143. text {
  1144. margin: 0 1vw 0 0;
  1145. font-size: 12px;
  1146. border-radius: 5px;
  1147. border: 0.5px solid var(--fFB1Color);
  1148. color: var(--fFB1Color);
  1149. }
  1150. }
  1151. }
  1152. .title_2 {
  1153. .specList {
  1154. .name {
  1155. margin: 0 0 1vw 0;
  1156. }
  1157. .giftList {
  1158. display: flex;
  1159. justify-content: space-between;
  1160. align-items: center;
  1161. margin: 0 0 1vw 0;
  1162. border: 0.5px solid var(--f9Color);
  1163. border-radius: 10px;
  1164. .left {
  1165. width: 85vw;
  1166. }
  1167. }
  1168. }
  1169. .text {
  1170. color: var(--fFB1Color);
  1171. }
  1172. }
  1173. }
  1174. }
  1175. }
  1176. }
  1177. .dialog {
  1178. position: fixed;
  1179. width: 100vw;
  1180. height: 100vh;
  1181. background-color: #000000;
  1182. z-index: 99999;
  1183. display: flex;
  1184. flex-direction: column;
  1185. justify-content: center;
  1186. swiper {
  1187. height: 60vh;
  1188. }
  1189. .list {
  1190. .list_1 {
  1191. padding: 2vw;
  1192. margin: 0 0 5vw 0;
  1193. .image {
  1194. width: 100%;
  1195. height: 40vh;
  1196. }
  1197. }
  1198. .name {
  1199. text-align: center;
  1200. margin: 0 10vw;
  1201. background-color: #6666669f;
  1202. border-radius: 25px;
  1203. padding: 2vw;
  1204. text {
  1205. color: #fff;
  1206. font-size: 15px;
  1207. overflow: hidden;
  1208. text-overflow: ellipsis;
  1209. -webkit-line-clamp: 2;
  1210. word-break: break-all;
  1211. display: -webkit-box;
  1212. -webkit-box-orient: vertical;
  1213. }
  1214. }
  1215. }
  1216. }
  1217. </style>