detail.vue 10.0 KB

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