detail.vue 11 KB

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