detail.vue 10 KB

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