detail.vue 32 KB

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