detail.vue 10 KB

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