detail.vue 10 KB

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