detail.vue 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103
  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, #FFCD1E, #FF8A18)',
  214. color: '#fff',
  215. type: '0'
  216. },
  217. {
  218. text: '立即购买',
  219. backgroundColor: 'linear-gradient(90deg, #FE6035, #EF1224)',
  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. // 规格排序
  359. let indexSpecs = data.specs.sort(function(a, b) {
  360. let i, j;
  361. if (a.price) i = 'price'
  362. else i = 'sell_money'
  363. if (b.price) j = 'price'
  364. else j = 'sell_money'
  365. return a[i] - b[j];
  366. })
  367. that.$set(that, `infospecs`, indexSpecs[0])
  368. }
  369. that.$set(that, `info`, data);
  370. // 优惠
  371. act = data.act.find(i => i.type == '5')
  372. if (act) that.$set(that.discount, `full_decrement`, act.text.split(';'));
  373. act = data.act.find(i => i.type == '6')
  374. if (act) that.$set(that.discount, `full_fold`, act.text.split(';'));
  375. await that.searchOther();
  376. // 查询规格
  377. await that.searchSpecs(data.specs);
  378. // 查询评价数
  379. await that.searchRate(data);
  380. }
  381. } else {
  382. uni.showToast({
  383. title: '暂无商品信息',
  384. icon: 'none'
  385. })
  386. }
  387. },
  388. // 查询规格
  389. searchSpecs(e) {
  390. const that = this;
  391. if (e.length > 0) {
  392. let data = e.find(i => i.num > 0);
  393. let dataIndex = e.findIndex(i => i._id == data._id);
  394. if (data) {
  395. let specsInfo = that.group_config.find(i => i.spec._id == data._id)
  396. if (specsInfo?._id && that.user.is_leader == '0') data.can_group = '0'
  397. else data.can_group = '1'
  398. let limit = that.buyList.find((i) => i.value == data.buy_limit);
  399. if (limit) data.buy_name = limit.label
  400. that.$set(that, `specsInfo`, data);
  401. that.$set(that, `is_specs`, dataIndex);
  402. }
  403. }
  404. },
  405. // 查询评价数
  406. async searchRate(e) {
  407. const that = this;
  408. let res = await that.$api(`/goodsRate`, `GET`, {
  409. limit: 1,
  410. goods: e.goods._id
  411. })
  412. if (res.errcode == '0') that.$set(that, `evaluate_num`, res.total);
  413. },
  414. // 关注商品
  415. async toGoodscolect() {
  416. const that = this;
  417. let user = that.user;
  418. if (user && user._id) {
  419. let res = await that.$api(`/storeGoods`, `POST`, {
  420. customer: user._id,
  421. goods: that.id
  422. });
  423. if (res.errcode == '0') {
  424. uni.showToast({
  425. title: res.data.msg,
  426. icon: 'none'
  427. })
  428. that.$set(that, `goodsColect`, res.data.result)
  429. }
  430. } else {
  431. uni.showToast({
  432. title: '暂无账号,无法收藏商品',
  433. icon: 'none'
  434. })
  435. }
  436. },
  437. // 活动说明
  438. toActivity() {
  439. const that = this;
  440. if (that.info.act.length > 0) {
  441. that.$set(that, `popupShow`, '2')
  442. that.$refs.specShow.open();
  443. }
  444. },
  445. // 活动说明
  446. toActivity() {
  447. const that = this;
  448. if (that.info.act.length > 0) {
  449. that.$set(that, `popupShow`, '2')
  450. that.$refs.specShow.open();
  451. }
  452. },
  453. // 选择规格
  454. toSpec() {
  455. const that = this;
  456. this.$set(that, `popupShow`, '1')
  457. that.$refs.specShow.open();
  458. },
  459. // 选择规格
  460. toSpecs(e) {
  461. const that = this;
  462. let specs = that.info.specs;
  463. let dataIndex = specs.findIndex(i => i._id == e._id);
  464. that.$set(that, `is_specs`, dataIndex);
  465. let specsInfo = that.group_config.find(i => i.spec._id == e._id)
  466. if (specsInfo?._id && that.user.is_leader == '0') e.can_group = '0'
  467. else e.can_group = '1'
  468. let limit = that.buyList.find((i) => i.value == e.buy_limit);
  469. if (limit) e.buy_name = limit.label
  470. that.$set(that, `specsInfo`, e)
  471. that.$set(that, `buy_num`, 1);
  472. if (e.num <= 0) that.$set(that, `is_zero`, true)
  473. else that.$set(that, `is_zero`, false)
  474. },
  475. // 评价
  476. toEvaluate() {
  477. const that = this;
  478. uni.navigateTo({
  479. url: `/pagesHome/order/appraise?id=${that.info.goods._id}`
  480. })
  481. },
  482. // 查看套装
  483. toSets() {
  484. const that = this;
  485. if (that.info.sets.length > 0) {
  486. that.$set(that, `popupShow`, '3')
  487. that.$refs.specShow.open();
  488. }
  489. },
  490. // 套装详情
  491. toDeatil(e) {
  492. const that = this;
  493. uni.navigateTo({
  494. url: `/pagesHome/order/detail?id=${e.goods}`
  495. })
  496. },
  497. // 进入店铺
  498. toShop() {
  499. const that = this;
  500. let info = that.info;
  501. uni.navigateTo({
  502. url: `/pagesHome/shop/index?id=${info.shop._id}`
  503. })
  504. },
  505. // 关注店铺
  506. async toShopcolect() {
  507. const that = this;
  508. let user = that.user;
  509. if (user && user._id) {
  510. let res = await that.$api(`/storeShop`, `POST`, {
  511. customer: user._id,
  512. shop: that.info.shop._id
  513. });
  514. if (res.errcode == '0') {
  515. uni.showToast({
  516. title: res.data.msg,
  517. icon: 'none'
  518. })
  519. that.$set(that, `shopColect`, res.data.result)
  520. }
  521. } else {
  522. uni.showToast({
  523. title: '暂无账号,无法关注商铺',
  524. icon: 'none'
  525. })
  526. }
  527. },
  528. // 关闭弹框
  529. toClose() {
  530. const that = this;
  531. that.$set(that, `btn_type`, '1');
  532. that.$refs.specShow.close();
  533. },
  534. // 规格预览
  535. diaView() {
  536. const that = this;
  537. that.$set(that, `dialog`, {
  538. show: true,
  539. type: '1'
  540. })
  541. },
  542. // 计数器
  543. toCount(e) {
  544. const that = this;
  545. that.$set(that, `buy_num`, e)
  546. },
  547. // 立即购买
  548. async toBuy() {
  549. const that = this;
  550. let user = that.user;
  551. let info = that.info;
  552. let specsInfo = that.specsInfo;
  553. let act = that.info.act.map(item => {
  554. return item._id
  555. })
  556. if (user && user._id) {
  557. let obj = [{
  558. customer: user._id,
  559. shop: info.shop._id,
  560. goods: info.goods._id,
  561. goodsSpec: specsInfo._id,
  562. num: that.buy_num,
  563. inviter: that.inviter,
  564. act
  565. }]
  566. let res = await that.$api(`/util/checkCanBuy`, 'POST', obj)
  567. if (res.errcode == '0') {
  568. if (res.data.result == true) {
  569. uni.navigateTo({
  570. url: `/pagesHome/order/order?key=${res.data.key}`
  571. })
  572. } else {
  573. uni.showToast({
  574. title: res.data.msg,
  575. icon: 'none',
  576. duration: 5000
  577. })
  578. }
  579. } else {
  580. uni.showToast({
  581. title: res.errmsg,
  582. icon: 'none'
  583. })
  584. }
  585. } else {
  586. uni.navigateTo({
  587. url: `/pages/login/index`
  588. })
  589. }
  590. },
  591. // 加入购物车
  592. async toMarket() {
  593. const that = this;
  594. let user = that.user;
  595. let info = that.info;
  596. let specsInfo = that.specsInfo;
  597. if (user && user._id) {
  598. let obj = {
  599. customer: user._id,
  600. shop: info.shop._id,
  601. goods: info.goods._id,
  602. goodsSpec: specsInfo._id,
  603. num: that.buy_num,
  604. inviter: that.inviter
  605. }
  606. let res = await that.$api(`/cart`, 'POST', obj)
  607. if (res.errcode == '0') {
  608. uni.showToast({
  609. title: `加入购物车成功`,
  610. icon: 'none'
  611. })
  612. that.toClose();
  613. } else {
  614. uni.showToast({
  615. title: res.errmsg,
  616. icon: 'none'
  617. })
  618. }
  619. } else {
  620. uni.navigateTo({
  621. url: `/pages/login/index`
  622. })
  623. }
  624. },
  625. // 开团
  626. toGroup() {
  627. const that = this;
  628. uni.navigateTo({
  629. url: `/pagesHome/group/index?shop=${that.info?.shop?._id}&goods=${that.id}`
  630. })
  631. },
  632. // 查看活动
  633. toAct(item) {
  634. uni.navigateTo({
  635. url: `/pagesRest/activity/info?id=${item._id}`
  636. })
  637. },
  638. // 店铺,购物车,客服
  639. async toNavleft(e) {
  640. const that = this;
  641. if (e.content.type == 'shop') {
  642. that.toShop();
  643. } else if (e.content.type == 'market') {
  644. let obj = {
  645. route: e.content.route
  646. }
  647. that.toPath(obj)
  648. } else { //客服
  649. if (that.user) {
  650. let form = {
  651. "customer": that.user && that.user._id,
  652. "shop": that.info && that.info.shop && that.info.shop._id
  653. }
  654. // 查询该用户与该店铺是否有房间
  655. let arr = await that.$api(`/room`, `GET`, form, 'chat');
  656. if (arr.errcode == '0' && arr.total > 0) { //有直接进入
  657. if (arr.data) {
  658. uni.navigateTo({
  659. url: `/pagesMessage/message/info?id=${arr.data[0]._id}`
  660. })
  661. }
  662. } else { //没有创建进入
  663. uni.navigateTo({
  664. url: `/pagesMessage/message/info?shop=${form.shop}`
  665. })
  666. }
  667. } else {
  668. uni.showToast({
  669. title: '未登录账号,无法联系客服',
  670. icon: 'none'
  671. })
  672. }
  673. }
  674. },
  675. // 关闭弹框
  676. dialogClose() {
  677. const that = this;
  678. that.$set(that, `dialog`, {
  679. show: false,
  680. type: '1'
  681. })
  682. },
  683. // 弹框选择规格
  684. diaSpecs(e) {
  685. const that = this;
  686. let specs = that.info.specs;
  687. let index = e.detail.current;
  688. let data = specs[index];
  689. that.$set(that, `is_specs`, index);
  690. that.$set(that, `specsInfo`, data);
  691. that.$set(that, `buy_num`, 1);
  692. if (data.num <= 0) that.$set(that, `is_zero`, true)
  693. else that.$set(that, `is_zero`, false)
  694. },
  695. // 套装加入购物车
  696. async toSetMarket(e) {
  697. const that = this;
  698. let user = that.user;
  699. if (user && user._id) {
  700. let obj = {
  701. customer: user._id,
  702. set_id: e._id,
  703. is_set: '0',
  704. num: 1,
  705. }
  706. let res = await that.$api(`/cart`, 'POST', obj)
  707. if (res.errcode == '0') {
  708. uni.showToast({
  709. title: `加入购物车成功`,
  710. icon: 'none'
  711. })
  712. that.toClose();
  713. } else {
  714. uni.showToast({
  715. title: res.errmsg,
  716. icon: 'none'
  717. })
  718. }
  719. } else {
  720. uni.navigateTo({
  721. url: `/pages/login/index`
  722. })
  723. }
  724. },
  725. // 加入购物车,立即购买
  726. toNavright(e) {
  727. const that = this;
  728. that.$set(that, `popupShow`, '1');
  729. that.$set(that, `btn_type`, e.content.type);
  730. that.$refs.specShow.open();
  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. toMenubar() {
  747. const that = this;
  748. that.$set(that, `is_menu`, that.is_menu ? false : true)
  749. },
  750. toPath(e) {
  751. let url = `/${e.route}`;
  752. uni.reLaunch({
  753. url
  754. })
  755. },
  756. }
  757. }
  758. </script>
  759. <style lang="scss">
  760. .main {
  761. display: flex;
  762. flex-direction: column;
  763. width: 100vw;
  764. height: 100vh;
  765. .one {
  766. position: relative;
  767. flex-grow: 1;
  768. .one_2 {
  769. border-bottom: 0.5vw solid var(--f9Color);
  770. padding: 2vw;
  771. .money_1 {
  772. color: #23B67A;
  773. font-size: 20px;
  774. padding: 0 1vw 0 0;
  775. font-weight: bold;
  776. text {
  777. font-size: 14px;
  778. }
  779. }
  780. .money {
  781. font-size: 20px;
  782. padding: 0 1vw 0 0;
  783. color: #ff0000;
  784. font-weight: bold;
  785. text {
  786. font-size: 14px;
  787. }
  788. }
  789. .money:last-child {
  790. font-size: 16px;
  791. color: #858585;
  792. text-decoration: line-through;
  793. }
  794. }
  795. .one_3 {
  796. display: flex;
  797. flex-wrap: wrap;
  798. padding: 1vw;
  799. border-bottom: 0.5vw solid var(--f9Color);
  800. .act {
  801. font-size: 12px;
  802. border: 1px solid var(--fFB1Color);
  803. margin: 0 1vw 1vw 0;
  804. color: var(--fFB1Color);
  805. border-radius: 6px;
  806. padding: 0 1vw;
  807. }
  808. .num {
  809. font-size: 12px;
  810. color: #858585;
  811. }
  812. }
  813. .one_4 {
  814. display: flex;
  815. flex-wrap: wrap;
  816. padding: 1vw;
  817. border-bottom: 0.5vw solid var(--f9Color);
  818. .num {
  819. font-size: 12px;
  820. color: #858585;
  821. }
  822. }
  823. .one_5 {
  824. border-bottom: 0.5vw solid var(--f9Color);
  825. padding: 2vw;
  826. .name {
  827. font-size: 17px;
  828. font-weight: bold;
  829. margin: 0 0 2vw 0;
  830. }
  831. .brief {
  832. font-size: 14px;
  833. color: #858585;
  834. margin: 0 0 1vw 0;
  835. }
  836. .money {
  837. font-size: 13px;
  838. color: #858585;
  839. text {
  840. padding: 0 2vw 0 0;
  841. }
  842. }
  843. }
  844. .one_6 {
  845. display: flex;
  846. justify-content: space-between;
  847. padding: 2vw;
  848. border-bottom: 0.5vw solid var(--f9Color);
  849. font-size: 14px;
  850. }
  851. .one_7 {
  852. padding: 2vw;
  853. border-bottom: 2vw solid var(--f9Color);
  854. border-top: 1vw solid var(--f9Color);
  855. .one_7_1 {
  856. padding: 2vw 0;
  857. font-size: 14px;
  858. text {
  859. padding: 0 0 0 1vw;
  860. font-size: 12px;
  861. color: #858585;
  862. }
  863. }
  864. .one_7_2 {
  865. display: flex;
  866. justify-content: space-between;
  867. align-items: center;
  868. padding: 2vw;
  869. border-radius: 5px;
  870. background-color: var(--f9Color);
  871. .image {
  872. width: 20vw;
  873. height: 20vw;
  874. .image {
  875. width: 100%;
  876. height: 100%;
  877. border-radius: 5px;
  878. background-color: #fff;
  879. }
  880. }
  881. .money {
  882. text-align: center;
  883. .money_1 {
  884. font-size: 12px;
  885. color: #858585;
  886. }
  887. .money_2 {
  888. font-size: 12px;
  889. color: #ff0000;
  890. }
  891. }
  892. }
  893. }
  894. .one_8 {
  895. padding: 2vw;
  896. border-bottom: 0.5vw solid var(--f9Color);
  897. .one_8_1 {
  898. margin: 0 0 1vw 0;
  899. display: flex;
  900. .shop_1 {
  901. width: 15vw;
  902. height: 15vw;
  903. border: 1px solid #f1f1f1;
  904. .image {
  905. width: 100%;
  906. height: 100%;
  907. }
  908. }
  909. .shop_2 {
  910. width: 78vw;
  911. padding: 0 0 0 2vw;
  912. .name {
  913. font-size: 14px;
  914. margin: 0 0 1vw 0;
  915. }
  916. .num {
  917. font-size: 12px;
  918. color: #858585;
  919. text:last-child {
  920. color: #000;
  921. }
  922. }
  923. }
  924. }
  925. .one_8_2 {
  926. margin: 0 0 2vw 0;
  927. display: flex;
  928. justify-content: space-between;
  929. padding: 2vw 0;
  930. .score_1 {
  931. width: 33vw;
  932. text-align: center;
  933. font-size: 14px;
  934. color: #858585;
  935. text:nth-child(2) {
  936. color: #ff0000;
  937. }
  938. text:nth-child(3) {
  939. float: right;
  940. }
  941. }
  942. }
  943. .one_8_3 {
  944. display: flex;
  945. justify-content: space-around;
  946. .btn {
  947. width: 40vw;
  948. button {
  949. width: 100%;
  950. font-size: 15px;
  951. }
  952. }
  953. }
  954. }
  955. .one_9 {
  956. padding: 2vw;
  957. .rich-img {
  958. width: 100% !important;
  959. display: block;
  960. }
  961. }
  962. }
  963. .two {
  964. width: 100vw;
  965. height: 8vh;
  966. overflow: hidden;
  967. }
  968. }
  969. .scroll-view {
  970. position: absolute;
  971. top: 0;
  972. left: 0;
  973. right: 0;
  974. bottom: 0;
  975. .list-scroll-view {
  976. display: flex;
  977. flex-direction: column;
  978. }
  979. }
  980. .bar_1 {
  981. position: fixed;
  982. right: 2vw;
  983. bottom: 20vw;
  984. text {
  985. background-color: #858585;
  986. border-radius: 90px;
  987. font-size: 30px;
  988. }
  989. }
  990. .bar_2 {
  991. position: fixed;
  992. right: 2vw;
  993. bottom: 28vw;
  994. width: 27vw;
  995. background: #ffffff;
  996. padding: 0 2vw;
  997. box-shadow: 0 0 5px #858585;
  998. .list {
  999. display: flex;
  1000. border-bottom: 1px solid #f1f1f1;
  1001. padding: 1vw 0;
  1002. .image {
  1003. width: 8vw;
  1004. height: 8vw;
  1005. }
  1006. .name {
  1007. font-size: 14px;
  1008. position: relative;
  1009. top: 2vw;
  1010. left: 2vw;
  1011. }
  1012. }
  1013. .list:last-child {
  1014. border-bottom: none;
  1015. }
  1016. }
  1017. .uni-popup {
  1018. z-index: 9999 !important;
  1019. }
  1020. .popup {
  1021. display: flex;
  1022. flex-direction: column;
  1023. width: 100vw;
  1024. height: 60vh;
  1025. .close {
  1026. text-align: right;
  1027. padding: 2vw;
  1028. }
  1029. }
  1030. .dialog {
  1031. position: fixed;
  1032. width: 100vw;
  1033. height: 100vh;
  1034. background-color: #000000;
  1035. z-index: 99999;
  1036. display: flex;
  1037. flex-direction: column;
  1038. justify-content: center;
  1039. }
  1040. </style>