detail.vue 10 KB

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