detail.vue 31 KB

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