detail.vue 30 KB

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