detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. <template>
  2. <mobile-frame>
  3. <view class="main">
  4. <view class="onemain">
  5. <scroll-view scroll-y="true" class="scroll-view" scroll-with-animation :scroll-into-view="topItem"
  6. @scroll="handleScroll">
  7. <view class="list-scroll-view" id="top">
  8. <view class="one">
  9. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff"
  10. indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
  11. <swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
  12. <image class="image" :src="item.url" mode="aspectFit">
  13. </image>
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. <view class="two">
  18. <view class="two_1">
  19. <view class="money_1">
  20. <text>{{info.cost||0}}</text>
  21. </view>
  22. </view>
  23. <view class="two_2">{{info.name}}</view>
  24. <view class="two_3">{{info.shot_brief}}</view>
  25. <view class="two_4">
  26. <text>{{info.send_time}}内发货</text>
  27. </view>
  28. </view>
  29. <view class="thr">
  30. <view class="thr_1">
  31. <image class="image" :src="shop.logo&&shop.logo.length>0?shop.logo[0].url:''"></image>
  32. <view class="other">
  33. <view class="name">{{shop.name}}</view>
  34. </view>
  35. </view>
  36. <view class="thr_2">
  37. <view class="grade">商品:<text>{{shop.goods_score||5}}</text></view>|
  38. <view class="grade">发货:<text>{{shop.send_score||5}}</text></view>|
  39. <view class="grade">服务:<text>{{shop.service_score||5}}</text></view>
  40. </view>
  41. </view>
  42. <view class="four">
  43. <view class="four_1">
  44. <rich-text :nodes="info.brief"></rich-text>
  45. </view>
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. <view class="foot">
  51. <uni-goods-nav :options="options" :buttonGroup="buttonGroup" @click="onClick"
  52. @buttonClick="buttonClick" />
  53. </view>
  54. </view>
  55. <view class="menu">
  56. <text @click="toMenu" class="iconfont icon-gengduo"></text>
  57. </view>
  58. <view class="menu_1" v-if="menu">
  59. <view class="title" v-for="(item,index) in barList" :key="index" @click="toPath(item)">
  60. <image class="image" :src="item.normal"></image>
  61. <view class="name">{{item.name}}</view>
  62. </view>
  63. </view>
  64. <view class="backTop" v-if="isShow==true">
  65. <text @click="backTop" class="iconfont icon-fanhuidingbu"></text>
  66. </view>
  67. <uni-popup ref="popup" background-color="#fff" type="bottom">
  68. <view class="content">
  69. <view class="one">
  70. <text>数量</text>
  71. <view class="count">
  72. <uni-number-box :min="1" :max="info.num" v-model="num" @change="toCount">
  73. </uni-number-box>
  74. </view>
  75. <text>库存{{info.num||0}}</text>
  76. </view>
  77. <view class="btn">
  78. <text @click="toExchange" class="button">立即兑换</text>
  79. </view>
  80. </view>
  81. </uni-popup>
  82. </mobile-frame>
  83. </template>
  84. <script>
  85. export default {
  86. components: {},
  87. data() {
  88. return {
  89. barList: [{
  90. name: '首页',
  91. route: 'pages/home/index',
  92. normal: require('@/static/shouye.png'),
  93. },
  94. {
  95. name: '微店',
  96. route: 'pages/store/index',
  97. normal: require('@/static/store.png'),
  98. },
  99. {
  100. name: '购物车',
  101. route: 'pages/market/index',
  102. normal: require('@/static/market.png'),
  103. },
  104. {
  105. name: '我的',
  106. route: 'pages/my/index',
  107. normal: require('@/static/my.png'),
  108. },
  109. ],
  110. buttonGroup: [{
  111. text: '兑换',
  112. backgroundColor: 'linear-gradient(90deg, #6A5ACD, #6A5ACD)',
  113. color: '#fff',
  114. }],
  115. options: [],
  116. // 商品id
  117. id: '',
  118. user: {},
  119. // 轮播图
  120. bannerList: [],
  121. // 商品详情
  122. info: {},
  123. // 商店详情
  124. shop: {},
  125. // 是否显示返回顶部
  126. isShow: false,
  127. topItem: '',
  128. // 店铺收藏
  129. shop_collect: false,
  130. // 菜单显示
  131. menu: false,
  132. disabled: true,
  133. // 数量
  134. num: 1,
  135. };
  136. },
  137. onLoad: async function(e) {
  138. const that = this;
  139. that.$set(that, `id`, e.id || '');
  140. },
  141. onShow: async function() {
  142. const that = this;
  143. // 监听用户是否登录
  144. await that.watchLogin();
  145. await that.search();
  146. await that.configShare();
  147. },
  148. methods: {
  149. //主菜单跳转
  150. toPath(e) {
  151. if (e && e.route) uni.reLaunch({
  152. url: `/${e.route}`
  153. })
  154. },
  155. // 菜单展开
  156. toMenu() {
  157. const that = this;
  158. that.menu = !that.menu
  159. },
  160. // 计算高度
  161. handleScroll(e) {
  162. const that = this;
  163. let scrollTop = e.detail.scrollTop;
  164. that.isShow = scrollTop > 500;
  165. that.topItem = '';
  166. },
  167. // 返回顶部
  168. backTop() {
  169. const that = this;
  170. that.topItem = 'top'
  171. },
  172. //立即兑换
  173. buttonClick(e) {
  174. const that = this;
  175. that.$refs.popup.open();
  176. },
  177. // 计数器
  178. toCount(e) {
  179. const that = this;
  180. that.num = e;
  181. },
  182. // 立即兑换
  183. async toExchange() {
  184. const that = this;
  185. let user = that.user;
  186. if (user._id) {
  187. let data = {
  188. shop: that.shop._id,
  189. goods: that.id,
  190. num: that.num
  191. };
  192. let arr = await that.$api(`/zrOrder/checkCanBuy`, `POST`, data, `integral`)
  193. if (arr.errcode == '0') {
  194. if (arr.data.result == true) {
  195. uni.navigateTo({
  196. url: `/pagesIntegral/order/index?key=${arr.data.key}`
  197. })
  198. } else {
  199. uni.showToast({
  200. title: arr.data.msg,
  201. icon: 'none'
  202. })
  203. }
  204. } else {
  205. uni.showToast({
  206. title: arr.errmsg,
  207. icon: 'none'
  208. })
  209. }
  210. } else {
  211. uni.navigateTo({
  212. url: `/pages/login/index`
  213. })
  214. }
  215. },
  216. // 监听用户是否登录
  217. watchLogin() {
  218. const that = this;
  219. uni.getStorage({
  220. key: 'token',
  221. success: function(res) {
  222. let user = that.$jwt(res.data);
  223. if (user) that.$set(that, `user`, user);
  224. },
  225. fail: function(err) {}
  226. });
  227. },
  228. // 详情数据
  229. async search() {
  230. const that = this;
  231. let arr = await that.$api(`/zrGoods/${that.id}`, `POST`, {}, `integral`)
  232. if (arr.errcode == '0') {
  233. if (arr.data.brief) arr.data.brief = arr.data.brief.replace(/\<img/gi,
  234. '<img class="rich-img"');
  235. that.$set(that, `info`, arr.data)
  236. that.$set(that, `bannerList`, arr.data.file)
  237. let shop = await that.$api(`/shop/${arr.data.shop}`, `GET`)
  238. if (shop.errcode == '0') {
  239. that.$set(that, `shop`, shop.data)
  240. }
  241. }
  242. },
  243. // 配置分享内容
  244. configShare() {
  245. const that = this;
  246. let user_id = that.user && that.user._id ? that.user._id : '';
  247. let id = that.info && that.info._id ? that.info._id : '';
  248. that.$config.share = {
  249. title: that.info.name,
  250. path: `/pagesHome/order/detail?id=${id}&user_id=${user_id}`,
  251. imageUrl: that.info.file[0].url
  252. }
  253. }
  254. }
  255. }
  256. </script>
  257. <style lang="scss">
  258. .scrollView {
  259. height: 100vh;
  260. }
  261. .main {
  262. display: flex;
  263. flex-direction: column;
  264. width: 100vw;
  265. height: 100vh;
  266. .onemain {
  267. position: relative;
  268. flex-grow: 1;
  269. background-color: var(--f1Color);
  270. .one {
  271. swiper {
  272. height: 70vw;
  273. }
  274. .list {
  275. border-radius: 5px;
  276. .image {
  277. width: 100%;
  278. height: 100%;
  279. border-radius: 5px;
  280. background-color: #fff;
  281. }
  282. }
  283. }
  284. .two {
  285. padding: 0 0 2vw 0;
  286. background-color: var(--mainColor);
  287. .two_1 {
  288. display: flex;
  289. align-items: center;
  290. border-bottom: 0.5vw solid var(--f9Color);
  291. padding: 2vw;
  292. .money_1 {
  293. color: var(--ff0Color);
  294. text {
  295. margin: 0 1vw 0 0;
  296. }
  297. text:last-child {
  298. font-size: var(--font20Szie);
  299. font-weight: bold;
  300. }
  301. }
  302. .money_2 {
  303. text-decoration: line-through;
  304. color: var(--f99Color);
  305. text {
  306. margin: 0 1vw 0 0;
  307. }
  308. text:last-child {
  309. font-size: var(--font16Size);
  310. }
  311. }
  312. }
  313. .two_2 {
  314. font-size: var(--font18Szie);
  315. font-weight: bold;
  316. padding: 1vw 2vw;
  317. }
  318. .two_3 {
  319. font-size: var(--font16Szie);
  320. color: var(--f85Color);
  321. padding: 1vw 2vw;
  322. }
  323. .two_4 {
  324. font-size: var(--font12Size);
  325. color: var(--fcColor);
  326. padding: 1vw 2vw;
  327. text {
  328. margin: 0 2vw 0 0;
  329. }
  330. }
  331. }
  332. .thr {
  333. margin: 2vw 0 0 0;
  334. padding: 2vw;
  335. background-color: var(--mainColor);
  336. .thr_1 {
  337. display: flex;
  338. justify-content: space-between;
  339. align-items: center;
  340. .image {
  341. width: 15vw;
  342. height: 15vw;
  343. border: 0.1vw solid var(--fcColor);
  344. }
  345. .other {
  346. flex-grow: 1;
  347. margin: 0 0 0 2vw;
  348. .name {
  349. font-size: var(--font16Szie);
  350. }
  351. .other_1 {
  352. font-size: var(--font12Size);
  353. text {
  354. color: var(--fcColor);
  355. margin: 0 2vw 0 0;
  356. }
  357. }
  358. }
  359. }
  360. .thr_2 {
  361. display: flex;
  362. flex-direction: row;
  363. justify-content: space-evenly;
  364. padding: 2vw 0;
  365. color: var(--f99Color);
  366. .grade {
  367. font-size: var(--font14Size);
  368. color: var(--f85Color);
  369. text {
  370. color: var(--ff0Color);
  371. }
  372. }
  373. .btn {
  374. border: 0.1vw solid var(--fcColor);
  375. padding: 1vw 6vw;
  376. border-radius: 1vw;
  377. color: var(--f00Color);
  378. }
  379. .btn:last-child {
  380. padding: 1vw 10vw;
  381. }
  382. }
  383. }
  384. .four {
  385. margin: 2vw 0 0 0;
  386. .four_1 {
  387. background-color: var(--mainColor);
  388. padding: 2vw;
  389. .rich-img {
  390. width: 100% !important;
  391. display: block;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. .scroll-view {
  398. position: absolute;
  399. top: 0;
  400. left: 0;
  401. right: 0;
  402. bottom: 0;
  403. .list-scroll-view {
  404. display: flex;
  405. flex-direction: column;
  406. }
  407. }
  408. .scrollView {
  409. height: 100vh;
  410. }
  411. .menu {
  412. position: fixed;
  413. bottom: 30vw;
  414. right: 5vw;
  415. text {
  416. font-size: 30px;
  417. background-color: #0000005f;
  418. border-radius: 90px;
  419. }
  420. }
  421. .menu_1 {
  422. position: fixed;
  423. bottom: 40vw;
  424. right: 5vw;
  425. background-color: var(--mainColor);
  426. padding: 2vw;
  427. .title {
  428. display: flex;
  429. padding: 2vw;
  430. border-bottom: 0.1vw solid var(--fcColor);
  431. .image {
  432. width: 7vw;
  433. height: 6vw;
  434. }
  435. .name {
  436. margin: 0 0 0 1vw;
  437. font-size: var(--font14Size);
  438. }
  439. }
  440. }
  441. .backTop {
  442. position: fixed;
  443. bottom: 20vw;
  444. right: 5vw;
  445. text {
  446. font-size: 30px;
  447. background-color: #0000005f;
  448. border-radius: 90px;
  449. }
  450. }
  451. .uni-tab__cart-sub-left {
  452. padding: 0 !important;
  453. }
  454. uni-popup {
  455. z-index: 999999 !important;
  456. }
  457. .content {
  458. height: 60vw;
  459. .one {
  460. display: flex;
  461. justify-content: flex-start;
  462. align-items: center;
  463. margin: 0 2vw;
  464. padding: 2vw 0;
  465. text {
  466. margin: 0 2vw 0 0;
  467. }
  468. text:last-child {
  469. margin: 0 0 0 2vw;
  470. font-size: var(--font12Size);
  471. color: var(--f85Color);
  472. }
  473. }
  474. .btn {
  475. display: flex;
  476. justify-content: space-between;
  477. position: fixed;
  478. bottom: 0;
  479. .button {
  480. width: 100vw;
  481. padding: 4vw 0;
  482. background-color: #6A5ACD;
  483. text-align: center;
  484. font-size: var(--font18Szie);
  485. color: var(--mainColor);
  486. }
  487. }
  488. }
  489. </style>