detail.vue 26 KB

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