detail.vue 9.9 KB

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