detail.vue 10 KB

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