detail.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
  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. group_config: [],
  323. // 购买数量
  324. buy_num: 1,
  325. // 规格弹出框
  326. dialog: {
  327. show: false,
  328. type: '1'
  329. },
  330. };
  331. },
  332. onLoad: async function(e) {
  333. const that = this;
  334. that.$set(that, `id`, e.id || '');
  335. that.$set(that, `inviter`, e.inviter || '');
  336. await that.searchConfig();
  337. await that.search();
  338. await that.configShare();
  339. },
  340. onShow: async function() {
  341. const that = this;
  342. await that.watchLogin();
  343. },
  344. onUnload: function() {
  345. // 页面卸载,重新部署分享内容
  346. const that = this;
  347. if (that.config) {
  348. // 赋值默认值
  349. that.$config.share = {
  350. title: that.config.title,
  351. path: '/pages/index/index',
  352. imageUrl: that.config.config.share[0].url
  353. }
  354. }
  355. },
  356. methods: {
  357. // 查询系统设置
  358. searchConfig() {
  359. const that = this;
  360. uni.getStorage({
  361. key: 'config',
  362. success: function(res) {
  363. let data = res.data;
  364. that.$set(that, `config`, data);
  365. if (data.bottom_menu && data.bottom_menu.list.length > 0) {
  366. let list = data.bottom_menu.list.sort((a, b) => {
  367. return a.sort - b.sort
  368. });
  369. that.$set(that, `barList`, list)
  370. }
  371. }
  372. })
  373. },
  374. // 查询用户信息
  375. watchLogin() {
  376. const that = this;
  377. uni.getStorage({
  378. key: 'token',
  379. success: async function(res) {
  380. let user = that.$jwt(res.data);
  381. if (user) that.$set(that, `user`, user);
  382. await that.searchOther();
  383. },
  384. fail: function(err) {
  385. console.log('暂无用户信息');
  386. }
  387. })
  388. },
  389. // 查询其他信息
  390. async searchOther() {
  391. const that = this;
  392. let user = that.user;
  393. let res;
  394. // 是否关注商品
  395. res = await that.$api(`/storeGoods/check`, `GET`, {
  396. customer: user._id,
  397. goods: that.id
  398. });
  399. if (res.errcode == '0') that.$set(that, `goodsColect`, res.data);
  400. // 是否关注店铺
  401. res = await that.$api(`/storeShop/check`, `GET`, {
  402. customer: user._id,
  403. shop: that.info?.shop?._id
  404. });
  405. if (res.errcode == '0') that.$set(that, `shopColect`, res.data);
  406. // 商品设置
  407. res = await that.$api(`/goodsConfig`, `GET`, {
  408. goods: that.id,
  409. shop: that.info?.shop?._id
  410. }, 'group');
  411. if (res.errcode == '0' && res.total > 0) that.$set(that, `group_config`, res.data);
  412. },
  413. // 查询商品信息
  414. async search() {
  415. const that = this;
  416. let id = that.id;
  417. if (id) {
  418. let res;
  419. res = await that.$api(`/viewGoods/goodsDetail`, `POST`, {
  420. id: id
  421. });
  422. if (res.errcode == '0') {
  423. let data = res.data;
  424. if (data.goods.brief) data.goods.brief = data.goods.brief.replace(/\<img/gi,
  425. '<img class="rich-img"');
  426. // 特价
  427. let act;
  428. act = data.act.find(i => i.type == '3')
  429. if (act) {
  430. for (let val of act.list) {
  431. for (let [index, arr] of data.specs.entries()) {
  432. if (val.spec == arr._id) arr.price = val.price
  433. }
  434. }
  435. }
  436. // 显示最低价格的规格信息,不考虑库存问题
  437. if (data.specs && data.specs.length > 0) {
  438. // 规格排序
  439. let indexSpecs = data.specs.sort(function(a, b) {
  440. let i, j;
  441. if (a.price) i = 'price'
  442. else i = 'sell_money'
  443. if (b.price) j = 'price'
  444. else j = 'sell_money'
  445. return a[i] - b[j];
  446. })
  447. that.$set(that, `infospecs`, indexSpecs[0])
  448. }
  449. that.$set(that, `info`, data);
  450. // 优惠
  451. act = data.act.find(i => i.type == '5')
  452. if (act) that.$set(that.discount, `full_decrement`, act.text.split(';'));
  453. act = data.act.find(i => i.type == '6')
  454. if (act) that.$set(that.discount, `full_fold`, act.text.split(';'));
  455. // 查询规格
  456. that.searchSpecs(data.specs);
  457. // 查询评价数
  458. that.searchRate(data);
  459. }
  460. } else {
  461. uni.showToast({
  462. title: '暂无商品信息',
  463. icon: 'none'
  464. })
  465. }
  466. },
  467. // 查询规格
  468. searchSpecs(e) {
  469. const that = this;
  470. if (e.length > 0) {
  471. let data = e.find(i => i.num > 0);
  472. let dataIndex = e.findIndex(i => i._id == data._id);
  473. if (data) {
  474. that.$set(that, `specsInfo`, data);
  475. that.$set(that, `is_specs`, dataIndex);
  476. }
  477. }
  478. },
  479. // 活动说明
  480. toActivity() {
  481. const that = this;
  482. if (that.info.act.length > 0) {
  483. that.$set(that, `popupShow`, '2')
  484. that.$refs.specShow.open();
  485. }
  486. },
  487. // 查看正品详情
  488. getDetail(e) {
  489. const that = this;
  490. uni.navigateTo({
  491. url: `/pagesHome/order/detail?id=${e.goods}`
  492. })
  493. },
  494. // 选择规格
  495. toSpecs(e) {
  496. const that = this;
  497. let specs = that.info.specs;
  498. let dataIndex = specs.findIndex(i => i._id == e._id);
  499. that.$set(that, `is_specs`, dataIndex);
  500. let specsInfo = that.group_config.find(i => i.spec == e._id)
  501. if (specsInfo?._id && that.user.is_leader == '0') e.can_group = '0'
  502. else e.can_group = '1'
  503. that.$set(that, `specsInfo`, e)
  504. that.$set(that, `buy_num`, 1);
  505. if (e.num <= 0) that.$set(that, `is_zero`, true)
  506. else that.$set(that, `is_zero`, false)
  507. },
  508. // 计数器
  509. toCount(e) {
  510. const that = this;
  511. that.$set(that, `buy_num`, e)
  512. },
  513. // 查询评价数
  514. async searchRate(e) {
  515. const that = this;
  516. let res = await that.$api(`/goodsRate`, `GET`, {
  517. goods: e.goods._id
  518. })
  519. if (res.errcode == '0') that.$set(that, `evaluate_num`, res.total);
  520. },
  521. // 关注商品
  522. async toGoodscolect() {
  523. const that = this;
  524. let user = that.user;
  525. if (user && user._id) {
  526. let res = await that.$api(`/storeGoods`, `POST`, {
  527. customer: user._id,
  528. goods: that.id
  529. });
  530. if (res.errcode == '0') {
  531. uni.showToast({
  532. title: res.data.msg,
  533. icon: 'none'
  534. })
  535. that.$set(that, `goodsColect`, res.data.result)
  536. }
  537. } else {
  538. uni.showToast({
  539. title: '暂无账号,无法收藏商品',
  540. icon: 'none'
  541. })
  542. }
  543. },
  544. // 选择规格
  545. toSpec() {
  546. const that = this;
  547. this.$set(that, `popupShow`, '1')
  548. that.$refs.specShow.open();
  549. },
  550. // 加入购物车
  551. async toMarket() {
  552. const that = this;
  553. let user = that.user;
  554. let info = that.info;
  555. let specsInfo = that.specsInfo;
  556. if (user && user._id) {
  557. let obj = {
  558. customer: user._id,
  559. shop: info.shop._id,
  560. goods: info.goods._id,
  561. goodsSpec: specsInfo._id,
  562. num: that.buy_num,
  563. inviter: that.inviter
  564. }
  565. let res = await that.$api(`/cart`, 'POST', obj)
  566. if (res.errcode == '0') {
  567. uni.showToast({
  568. title: `加入购物车成功`,
  569. icon: 'none'
  570. })
  571. that.toClose();
  572. } else {
  573. uni.showToast({
  574. title: res.errmsg,
  575. icon: 'none'
  576. })
  577. }
  578. } else {
  579. uni.navigateTo({
  580. url: `/pages/login/index`
  581. })
  582. }
  583. },
  584. // 立即购买
  585. async toBuy() {
  586. const that = this;
  587. let user = that.user;
  588. let info = that.info;
  589. let specsInfo = that.specsInfo;
  590. let act = that.info.act.map(item => {
  591. return item._id
  592. })
  593. if (user && user._id) {
  594. let obj = [{
  595. customer: user._id,
  596. shop: info.shop._id,
  597. goods: info.goods._id,
  598. goodsSpec: specsInfo._id,
  599. num: that.buy_num,
  600. inviter: that.inviter,
  601. act
  602. }]
  603. let res = await that.$api(`/util/checkCanBuy`, 'POST', obj)
  604. if (res.errcode == '0') {
  605. if (res.data.result == true) {
  606. uni.navigateTo({
  607. url: `/pagesHome/order/order?key=${res.data.key}`
  608. })
  609. } else {
  610. uni.showToast({
  611. title: res.data.msg,
  612. icon: 'none'
  613. })
  614. }
  615. } else {
  616. uni.showToast({
  617. title: res.errmsg,
  618. icon: 'none'
  619. })
  620. }
  621. } else {
  622. uni.navigateTo({
  623. url: `/pages/login/index`
  624. })
  625. }
  626. },
  627. // 开团
  628. toGroup() {
  629. const that = this;
  630. uni.navigateTo({
  631. url: `/pagesHome/group/index?shop=${that.info.shop._id}&goods=${that.id}`
  632. })
  633. },
  634. // 关闭弹框
  635. toClose() {
  636. const that = this;
  637. that.$set(that, `btn_type`, '1');
  638. that.$refs.specShow.close();
  639. },
  640. // 评价
  641. toEvaluate() {
  642. const that = this;
  643. uni.navigateTo({
  644. url: `/pagesHome/order/appraise?id=${that.info.goods._id}`
  645. })
  646. },
  647. // 进入店铺
  648. toShop() {
  649. const that = this;
  650. let info = that.info;
  651. uni.navigateTo({
  652. url: `/pagesHome/shop/index?id=${info.shop._id}`
  653. })
  654. },
  655. // 关注店铺
  656. async toShopcolect() {
  657. const that = this;
  658. let user = that.user;
  659. if (user && user._id) {
  660. let res = await that.$api(`/storeShop`, `POST`, {
  661. customer: user._id,
  662. shop: that.info.shop._id
  663. });
  664. if (res.errcode == '0') {
  665. uni.showToast({
  666. title: res.data.msg,
  667. icon: 'none'
  668. })
  669. that.$set(that, `shopColect`, res.data.result)
  670. }
  671. } else {
  672. uni.showToast({
  673. title: '暂无账号,无法关注商铺',
  674. icon: 'none'
  675. })
  676. }
  677. },
  678. // 店铺,购物车
  679. toNavleft(e) {
  680. const that = this;
  681. if (e.content.type == 'shop') {
  682. that.toShop();
  683. } else if (e.content.type == 'market') {
  684. let obj = {
  685. route: e.content.route
  686. }
  687. that.toPath(obj)
  688. }
  689. },
  690. // 加入购物车,立即购买
  691. toNavright(e) {
  692. const that = this;
  693. that.$set(that, `popupShow`, '1');
  694. that.$set(that, `btn_type`, e.content.type);
  695. that.$refs.specShow.open();
  696. },
  697. // 右侧菜单
  698. toMenubar() {
  699. const that = this;
  700. that.$set(that, `is_menu`, that.is_menu ? false : true)
  701. },
  702. toPath(e) {
  703. let url = `/${e.route}`;
  704. uni.reLaunch({
  705. url
  706. })
  707. },
  708. // 配置分享内容
  709. configShare() {
  710. const that = this;
  711. let id = that.id;
  712. let inviter = that.user && that.user._id ? that.user._id : '';
  713. let title = that.info && that.info.goods ? that.info.goods.name : '';
  714. let imageUrl = that.info && that.info.goods ? that.info.goods.file[0].url : '';
  715. that.$config.share = {
  716. title: title,
  717. path: `/pagesHome/order/detail?id=${id}&inviter=${inviter}`,
  718. imageUrl: imageUrl
  719. }
  720. },
  721. // 规格预览
  722. diaView() {
  723. const that = this;
  724. that.$set(that, `dialog`, {
  725. show: true,
  726. type: '1'
  727. })
  728. },
  729. // 查看活动
  730. toAct(item) {
  731. uni.navigateTo({
  732. url: `/pagesRest/activity/info?id=${item._id}`
  733. })
  734. },
  735. // 弹框选择规格
  736. diaSpecs(e) {
  737. const that = this;
  738. let specs = that.info.specs;
  739. let index = e.detail.current;
  740. let data = specs[index];
  741. that.$set(that, `is_specs`, index);
  742. that.$set(that, `specsInfo`, data);
  743. that.$set(that, `buy_num`, 1);
  744. if (data.num <= 0) that.$set(that, `is_zero`, true)
  745. else that.$set(that, `is_zero`, false)
  746. },
  747. // 关闭弹框
  748. dialogClose() {
  749. const that = this;
  750. that.$set(that, `dialog`, {
  751. show: false,
  752. type: '1'
  753. })
  754. }
  755. }
  756. }
  757. </script>
  758. <style lang="scss">
  759. .main {
  760. display: flex;
  761. flex-direction: column;
  762. width: 100vw;
  763. height: 100vh;
  764. .one {
  765. position: relative;
  766. flex-grow: 1;
  767. .one_1 {
  768. border-bottom: 0.5vw solid var(--f9Color);
  769. swiper {
  770. height: 44vh !important;
  771. }
  772. .list {
  773. border-radius: 5px;
  774. .image {
  775. width: 100%;
  776. height: 100%;
  777. border-radius: 5px;
  778. background-color: #fff;
  779. }
  780. }
  781. .goodsColect {
  782. position: fixed;
  783. top: 2vw;
  784. right: 3vw;
  785. z-index: 99;
  786. background-color: #858585;
  787. border-radius: 90px;
  788. text {
  789. font-size: 30px;
  790. }
  791. }
  792. .acttags {
  793. position: absolute;
  794. top: 1vw;
  795. left: 1vw;
  796. width: 97%;
  797. text {
  798. display: inline-block;
  799. background-color: #ff0000;
  800. color: #fff;
  801. border-radius: 1vw;
  802. padding: 0.5vw;
  803. font-size: 12px;
  804. margin: 0 1vw 0 0;
  805. }
  806. }
  807. }
  808. .one_2 {
  809. border-bottom: 0.5vw solid var(--f9Color);
  810. padding: 2vw;
  811. .money {
  812. font-size: 20px;
  813. padding: 0 1vw 0 0;
  814. color: #ff0000;
  815. font-weight: bold;
  816. text {
  817. font-size: 14px;
  818. }
  819. }
  820. .money:last-child {
  821. font-size: 16px;
  822. color: #858585;
  823. text-decoration: line-through;
  824. }
  825. }
  826. .one_3 {
  827. display: flex;
  828. flex-wrap: wrap;
  829. padding: 1vw;
  830. border-bottom: 0.5vw solid var(--f9Color);
  831. .act {
  832. font-size: 12px;
  833. border: 1px solid var(--fFB1Color);
  834. margin: 0 1vw 1vw 0;
  835. color: var(--fFB1Color);
  836. border-radius: 6px;
  837. padding: 0 1vw;
  838. }
  839. }
  840. .one_4 {
  841. border-bottom: 0.5vw solid var(--f9Color);
  842. padding: 2vw;
  843. .name {
  844. font-size: 17px;
  845. font-weight: bold;
  846. margin: 0 0 2vw 0;
  847. }
  848. .brief {
  849. font-size: 14px;
  850. color: #858585;
  851. margin: 0 0 1vw 0;
  852. }
  853. .money {
  854. font-size: 13px;
  855. color: #858585;
  856. text {
  857. padding: 0 2vw 0 0;
  858. }
  859. }
  860. }
  861. .one_5 {
  862. display: flex;
  863. justify-content: space-between;
  864. padding: 2vw;
  865. border-bottom: 0.5vw solid var(--f9Color);
  866. font-size: 14px;
  867. }
  868. .one_6 {
  869. display: flex;
  870. justify-content: space-between;
  871. padding: 2vw;
  872. border-bottom: 0.5vw solid var(--f9Color);
  873. font-size: 14px;
  874. }
  875. .one_7 {
  876. padding: 2vw;
  877. border-bottom: 0.5vw solid var(--f9Color);
  878. .one_7_1 {
  879. margin: 0 0 1vw 0;
  880. display: flex;
  881. .shop_1 {
  882. width: 15vw;
  883. height: 15vw;
  884. border: 1px solid #f1f1f1;
  885. .image {
  886. width: 100%;
  887. height: 100%;
  888. }
  889. }
  890. .shop_2 {
  891. width: 78vw;
  892. padding: 0 0 0 2vw;
  893. .name {
  894. font-size: 14px;
  895. margin: 0 0 1vw 0;
  896. }
  897. .num {
  898. font-size: 12px;
  899. color: #858585;
  900. text:last-child {
  901. color: #000;
  902. }
  903. }
  904. }
  905. }
  906. .one_7_2 {
  907. margin: 0 0 2vw 0;
  908. display: flex;
  909. justify-content: space-between;
  910. padding: 2vw 0;
  911. .score_1 {
  912. width: 33vw;
  913. text-align: center;
  914. font-size: 14px;
  915. color: #858585;
  916. text:nth-child(2) {
  917. color: #ff0000;
  918. }
  919. text:nth-child(3) {
  920. float: right;
  921. }
  922. }
  923. }
  924. .one_7_3 {
  925. display: flex;
  926. justify-content: space-around;
  927. .btn {
  928. width: 40vw;
  929. button {
  930. width: 100%;
  931. font-size: 15px;
  932. }
  933. }
  934. }
  935. }
  936. .one_8 {
  937. padding: 2vw;
  938. .rich-img {
  939. width: 100% !important;
  940. display: block;
  941. }
  942. }
  943. }
  944. .two {
  945. width: 100vw;
  946. height: 8vh;
  947. overflow: hidden;
  948. }
  949. }
  950. .scroll-view {
  951. position: absolute;
  952. top: 0;
  953. left: 0;
  954. right: 0;
  955. bottom: 0;
  956. .list-scroll-view {
  957. display: flex;
  958. flex-direction: column;
  959. }
  960. }
  961. .bar_1 {
  962. position: fixed;
  963. right: 2vw;
  964. bottom: 20vw;
  965. text {
  966. background-color: #858585;
  967. border-radius: 90px;
  968. font-size: 30px;
  969. }
  970. }
  971. .bar_2 {
  972. position: fixed;
  973. right: 2vw;
  974. bottom: 28vw;
  975. width: 27vw;
  976. background: #ffffff;
  977. padding: 0 2vw;
  978. box-shadow: 0 0 5px #858585;
  979. .list {
  980. display: flex;
  981. border-bottom: 1px solid #f1f1f1;
  982. padding: 1vw 0;
  983. .image {
  984. width: 8vw;
  985. height: 8vw;
  986. }
  987. .name {
  988. font-size: 14px;
  989. position: relative;
  990. top: 2vw;
  991. left: 2vw;
  992. }
  993. }
  994. .list:last-child {
  995. border-bottom: none;
  996. }
  997. }
  998. .uni-popup {
  999. z-index: 9999 !important;
  1000. }
  1001. .popup {
  1002. display: flex;
  1003. flex-direction: column;
  1004. width: 100vw;
  1005. height: 60vh;
  1006. .close {
  1007. text-align: right;
  1008. padding: 2vw;
  1009. }
  1010. .info_1 {
  1011. position: relative;
  1012. display: flex;
  1013. flex-direction: column;
  1014. height: 54vh;
  1015. .info_1 {
  1016. position: relative;
  1017. flex-grow: 1;
  1018. .one {
  1019. padding: 2vw;
  1020. .one_1 {
  1021. display: flex;
  1022. margin: 0 0 2vw 0;
  1023. padding: 0 0 2vw 0;
  1024. border-bottom: 0.5vw solid var(--f9Color);
  1025. .l {
  1026. width: 25vw;
  1027. height: 25vw;
  1028. .image {
  1029. width: 100%;
  1030. height: 100%;
  1031. border-radius: 5px;
  1032. }
  1033. }
  1034. .r {
  1035. width: 70vw;
  1036. padding: 0 0 0 2vw;
  1037. .money {
  1038. margin: 0 0 2vw 0;
  1039. .money_1 {
  1040. font-size: 20px;
  1041. color: #ff0000;
  1042. padding: 0 2vw 0 0;
  1043. text {
  1044. font-size: 14px;
  1045. }
  1046. }
  1047. .money_1:last-child {
  1048. font-size: 16px;
  1049. color: #858585;
  1050. text-decoration: line-through;
  1051. }
  1052. }
  1053. .other_1 {
  1054. font-size: 15px;
  1055. color: #858585;
  1056. text:last-child {
  1057. color: #000000;
  1058. }
  1059. }
  1060. }
  1061. }
  1062. .one_2 {
  1063. margin: 0 0 2vw 0;
  1064. border-bottom: 0.5vw solid var(--f9Color);
  1065. .one_2_1 {
  1066. font-size: 14px;
  1067. margin: 0 0 2vw 0;
  1068. }
  1069. .one_2_2 {
  1070. display: flex;
  1071. flex-wrap: wrap;
  1072. .list {
  1073. background-color: #F5F5F5;
  1074. margin: 0 2vw 2vw 0;
  1075. padding: 0.5vw 1vw;
  1076. border-radius: 5px;
  1077. text {
  1078. font-size: 14px;
  1079. color: #000;
  1080. }
  1081. }
  1082. .huilist {
  1083. background-color: #DCDCDC;
  1084. text {
  1085. color: #858585;
  1086. }
  1087. }
  1088. .redlist {
  1089. background-color: #ff0000;
  1090. text {
  1091. color: #ffffff;
  1092. }
  1093. }
  1094. .huiilist {
  1095. background-color: #808080;
  1096. text {
  1097. color: #cccccc;
  1098. }
  1099. }
  1100. }
  1101. }
  1102. .one_3 {
  1103. display: flex;
  1104. .one_3_1 {
  1105. margin: 0 2vw 0 0;
  1106. text {
  1107. font-size: 14px;
  1108. color: #858585;
  1109. }
  1110. }
  1111. }
  1112. }
  1113. }
  1114. .info_2 {
  1115. display: flex;
  1116. text-align: center;
  1117. justify-content: space-between;
  1118. .btns {
  1119. width: 50vw;
  1120. }
  1121. .btn {
  1122. width: 100vw;
  1123. }
  1124. button {
  1125. width: 100%;
  1126. border-radius: 0;
  1127. background-color: var(--fFB1Color);
  1128. color: #fff;
  1129. border: 1px solid #f1f1f1;
  1130. }
  1131. .btncolor {
  1132. background: #f1f1f1;
  1133. color: #858585;
  1134. }
  1135. }
  1136. }
  1137. .info_3 {
  1138. position: relative;
  1139. flex-grow: 1;
  1140. .list {
  1141. margin: 0 2vw 2vw 2vw;
  1142. border-radius: 10px;
  1143. background-color: #FFF8DC;
  1144. .list_1 {
  1145. padding: 2vw;
  1146. font-size: 14px;
  1147. .title_1 {
  1148. display: flex;
  1149. justify-content: space-between;
  1150. margin: 1vw 0;
  1151. .l {
  1152. text {
  1153. margin: 0 1vw 0 0;
  1154. font-size: 12px;
  1155. border-radius: 5px;
  1156. border: 0.5px solid var(--fFB1Color);
  1157. color: var(--fFB1Color);
  1158. }
  1159. }
  1160. }
  1161. .title_2 {
  1162. .specList {
  1163. .name {
  1164. margin: 0 0 1vw 0;
  1165. }
  1166. .giftList {
  1167. display: flex;
  1168. justify-content: space-between;
  1169. align-items: center;
  1170. margin: 0 0 1vw 0;
  1171. border: 0.5px solid var(--f9Color);
  1172. border-radius: 10px;
  1173. .left {
  1174. width: 85vw;
  1175. }
  1176. }
  1177. }
  1178. .text {
  1179. color: var(--fFB1Color);
  1180. }
  1181. }
  1182. }
  1183. }
  1184. }
  1185. }
  1186. .dialog {
  1187. position: fixed;
  1188. width: 100vw;
  1189. height: 100vh;
  1190. background-color: #000000;
  1191. z-index: 99999;
  1192. display: flex;
  1193. flex-direction: column;
  1194. justify-content: center;
  1195. swiper {
  1196. height: 60vh;
  1197. }
  1198. .list {
  1199. .list_1 {
  1200. padding: 2vw;
  1201. margin: 0 0 5vw 0;
  1202. .image {
  1203. width: 100%;
  1204. height: 40vh;
  1205. }
  1206. }
  1207. .name {
  1208. text-align: center;
  1209. margin: 0 10vw;
  1210. background-color: #6666669f;
  1211. border-radius: 25px;
  1212. padding: 2vw;
  1213. text {
  1214. color: #fff;
  1215. font-size: 15px;
  1216. overflow: hidden;
  1217. text-overflow: ellipsis;
  1218. -webkit-line-clamp: 2;
  1219. word-break: break-all;
  1220. display: -webkit-box;
  1221. -webkit-box-orient: vertical;
  1222. }
  1223. }
  1224. }
  1225. }
  1226. </style>