mang.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. <template>
  2. <view class="page">
  3. <navbar-line :bgColor="bgColor" :hasPlacer="false">
  4. <view class="header-loc align-center" @tap="navTo('/pages/address/address')">
  5. <image src="/static/mang-loc.png" class="image_19" mode="aspectFill" />
  6. <text class="text_43">沂蒙云谷·创意孵化中心</text>
  7. </view>
  8. </navbar-line>
  9. <view class="p-header"><image src="/static/mang-bg.png" mode="aspectFill" class="img"></image></view>
  10. <view class="align-center p-ads">
  11. <image src="/static/mang-sear.png" class="image_20" mode="aspectFill" />
  12. <view class="group_20"><zetank-notice colors="#55aaff" :noticeList="ads" :interval="3000"></zetank-notice></view>
  13. </view>
  14. <view class="p-entry">
  15. <view class="flex-col items-center grid-item" v-for="(item,i) in cats" :key="i">
  16. <image
  17. :src="item.cate_logo"
  18. class="image"
  19. mode="aspectFill"
  20. />
  21. <text class="text">{{item.cate_name}}</text>
  22. </view>
  23. </view>
  24. <view class="p-tabs align-center justify-between">
  25. <view class="flex-col text-wrapper" :class="{active: i === tabCurrentIndex}"
  26. v-for="(item,i) in tabs" :key="i" @tap="tapTab(i)"
  27. >
  28. <image
  29. src="/static/mang-tabbg.png"
  30. class="image_8"
  31. />
  32. <text class="text_9">{{item.name}}</text>
  33. </view>
  34. </view>
  35. <view class="p-list">
  36. <view class="flex-row section_2 view_6" v-for="(item,idx) in tabs[tabCurrentIndex].list" :key="idx" @tap="navTo('/pages/mang/detail')">
  37. <image
  38. :src="item.goods_img"
  39. class="group_11"
  40. mode="aspectFill"
  41. />
  42. <view class="flex-col text_21 view_7">
  43. <text class="text_25 clamp">{{item.goods_name}}</text>
  44. <view class="stars align-center">
  45. <image
  46. src="/static/mang_star.png"
  47. class="image_14"
  48. v-for="(item,idx) in item.rank"
  49. :key="idx"
  50. />
  51. </view>
  52. <text class="text_26">随机搭配</text>
  53. <view class="flex-row group_16">
  54. <view class="group_17">
  55. <text class="text_27">¥</text>
  56. <text class="text_28">{{item.shop_price}}</text>
  57. </view>
  58. <text class="text_29">¥{{item.market_price}}</text>
  59. </view>
  60. </view>
  61. <text class="text_30" v-if="item.distance">{{item.distance}}</text>
  62. <view class="flex-col text-wrapper_2"><text class="text_23 text_31 clamp">仅剩{{item.num}}份</text></view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import navbarLine from '@/components/navbar-line.vue';
  69. import zetankNotice from './components/zetank-notice.vue';
  70. export default {
  71. components: {
  72. navbarLine,
  73. zetankNotice
  74. },
  75. data() {
  76. return {
  77. ads: [],
  78. bgColor:'transparent',
  79. cats:[
  80. {img:'/static/mang-all.png',name:'全部'},
  81. ],
  82. tabCurrentIndex: 0,
  83. tabs:[
  84. {name:'智能排序',type:1,loadingType: 'more', list: [], page: 1,loaded:false},
  85. {name:'距离最近',type:2,loadingType: 'more', list: [], page: 1,loaded:false},
  86. {name:'评分最高',type:3,loadingType: 'more', list: [], page: 1,loaded:false},
  87. ],
  88. pageSize: 20,
  89. };
  90. },
  91. onPageScroll(e) {
  92. // console.log('---',e);
  93. let scrollTop = e.scrollTop;
  94. if(scrollTop > this.CustomBar - 10){
  95. this.bgColor = "#ffffff";
  96. }else{
  97. this.bgColor = "transparent";
  98. }
  99. },
  100. onShow() {
  101. this.getList('refresh')
  102. this.getCats();
  103. this.getAds();
  104. },
  105. onPullDownRefresh() {
  106. this.getList('refresh')
  107. this.getCats();
  108. this.getAds();
  109. },
  110. onReachBottom() {
  111. this.getList()
  112. },
  113. methods:{
  114. getAds(){
  115. this.ads=[{ title: '1已帮助减少2486g数量的食品浪费' }, { title: '2已帮助减少2486g数量的食品浪费' }]
  116. },
  117. async getCats(){
  118. let res = await this.$request('goods.catelist')
  119. let cats =res.data || [];
  120. this.cats = cats.slice(0,7);
  121. this.cats.push({cate_logo:'/static/mang-all.png',cate_name:'全部'})
  122. },
  123. async getList(source){
  124. //这里是将订单挂载到tab列表下
  125. let index = this.tabCurrentIndex;
  126. let navItem = this.tabs[index];
  127. if (source === 'refresh') {
  128. if(navItem.loadingType == 'loading'){
  129. return;
  130. }
  131. navItem.loadingType = 'more';
  132. navItem.page=1;
  133. navItem.list=[];
  134. navItem.loaded=false;
  135. }
  136. if (navItem.loadingType === 'loading' || navItem.loadingType == 'noMore') {
  137. //防止重复加载
  138. return;
  139. }
  140. navItem.loadingType = 'loading';
  141. let res = await this.$request('goods.list',{
  142. sort_type:navItem.type,
  143. page: navItem.page,
  144. limit: this.pageSize
  145. });
  146. uni.stopPullDownRefresh();
  147. let result = res.data.row || [];
  148. if ( this.pageSize > result.length) {
  149. navItem.loadingType = 'noMore';
  150. } else {
  151. navItem.loadingType = 'more';
  152. }
  153. // 页数加一
  154. navItem.page++;
  155. navItem.loaded = true;
  156. if(source === 'refresh'){
  157. navItem.page=2;
  158. navItem.list = result;
  159. return;
  160. }
  161. result.forEach(item => {
  162. navItem.list.push(item);
  163. });
  164. },
  165. tapTab(idx){
  166. if(idx === this.tabCurrentIndex){
  167. return;
  168. }
  169. this.tabCurrentIndex = idx;
  170. this.getList('refresh');
  171. },
  172. }
  173. };
  174. </script>
  175. <style lang="scss">
  176. page {
  177. background-color: #F7FEFA;
  178. }
  179. .header-loc {
  180. position: absolute;
  181. width: 100%;
  182. padding: 0 30rpx;
  183. top: 50%;
  184. transform: translateY(-50%);
  185. .image_19 {
  186. width: 26rpx;
  187. height: 28rpx;
  188. }
  189. .text_43 {
  190. margin-left: 12rpx;
  191. color: #333333;
  192. font-size: 28rpx;
  193. font-family: PingFang;
  194. letter-spacing: 1.12rpx;
  195. }
  196. }
  197. .p-header {
  198. .img {
  199. width: 750rpx;
  200. height: 532rpx;
  201. }
  202. }
  203. .p-ads {
  204. margin: -32rpx auto 0;
  205. width: 690rpx;
  206. height: 72rpx;
  207. padding: 0 22rpx;
  208. background-image: url('/static/mang-ads.png');
  209. background-size: 100% 100%;
  210. background-repeat: no-repeat;
  211. position: relative;
  212. z-index: 2;
  213. .image_20 {
  214. width: 35rpx;
  215. height: 35rpx;
  216. }
  217. .group_20 {
  218. width: 100%;
  219. }
  220. }
  221. .p-entry {
  222. width: 690rpx;
  223. background: #FFFFFF;
  224. box-shadow: 0rpx 6rpx 10rpx 0rpx rgba(42,42,42,0.08);
  225. margin: 30rpx auto 0;
  226. padding: 9.5rpx 12rpx 20.5rpx;
  227. background-color: #ffffff;
  228. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  229. border-radius: 20rpx;
  230. height: 350rpx;
  231. display: grid;
  232. grid-template-columns: repeat(4, 1fr);
  233. .grid-item {
  234. padding: 17rpx 4rpx;
  235. }
  236. .image {
  237. width: 96rpx;
  238. height: 96rpx;
  239. }
  240. .text {
  241. margin-top: 7rpx;
  242. color: #333333;
  243. font-size: 24rpx;
  244. font-family: PingFang;
  245. line-height: 23rpx;
  246. letter-spacing: 1.44rpx;
  247. }
  248. }
  249. .p-tabs{
  250. margin-left: 30rpx;
  251. width: 530rpx;
  252. .text-wrapper {
  253. height: 85rpx;
  254. position: relative;
  255. &.active{
  256. .image_8{
  257. display: block;
  258. }
  259. .text_9{
  260. color: #333333;
  261. }
  262. }
  263. .image_8{
  264. width: 36rpx;
  265. height: 36rpx;
  266. display: none;
  267. position: absolute;
  268. z-index: 2;
  269. right: -14rpx;
  270. top:40%;
  271. transform: translateY(-50%);
  272. }
  273. .text_9 {
  274. color: #999999;
  275. font-size: 30rpx;
  276. font-family: PingFang;
  277. letter-spacing: 1.2rpx;
  278. line-height: 85rpx;
  279. }
  280. }
  281. }
  282. .p-list{
  283. .section_2 {
  284. width: 690rpx;
  285. margin:0 auto 24rpx;
  286. padding: 24rpx 14rpx 24rpx 24rpx;
  287. background-color: #ffffff;
  288. box-shadow: 0px 6rpx 10rpx #2a2a2a14;
  289. border-radius: 20rpx;
  290. position: relative;
  291. .text-wrapper_2 {
  292. padding: 8rpx 0 16rpx;
  293. background-image: url('/static/mang-listbg.png');
  294. background-size: 100% 100%;
  295. background-repeat: no-repeat;
  296. position: absolute;
  297. right: -10rpx;
  298. top: 26rpx;
  299. width: 120rpx;
  300. }
  301. .text_23 {
  302. margin-left: 12rpx;
  303. margin-right: 6rpx;
  304. color: #ffffff;
  305. font-size: 24rpx;
  306. font-family: PingFang;
  307. max-width: 120rpx;
  308. }
  309. // .text_31 {
  310. // margin-left: 12rpx;
  311. // margin-right: 6rpx;
  312. // }
  313. }
  314. .view_6 {
  315. padding: 24rpx 18rpx 24rpx 24rpx;
  316. }
  317. .group_11 {
  318. flex-shrink: 0;
  319. width: 200rpx;
  320. height: 200rpx;
  321. border-radius: 20rpx;
  322. }
  323. .text_21 {
  324. margin-top: 100rpx;
  325. color: #999999;
  326. font-size: 24rpx;
  327. font-family: PingFang;
  328. line-height: 18rpx;
  329. }
  330. .view_7 {
  331. margin-top: initial;
  332. color: initial;
  333. font-size: initial;
  334. font-family: initial;
  335. line-height: initial;
  336. margin-left: 19rpx;
  337. flex: 1 1 auto;
  338. align-self: center;
  339. }
  340. .text_25 {
  341. color: #333333;
  342. font-size: 30rpx;
  343. font-family: PingFang;
  344. max-width: 360rpx;
  345. }
  346. .stars{
  347. margin-top: 12rpx;
  348. .image_14 {
  349. width: 28rpx;
  350. height: 28rpx;
  351. margin-right: 4rpx;
  352. }
  353. }
  354. .text_26 {
  355. margin-top: 20rpx;
  356. align-self: flex-start;
  357. color: #999999;
  358. font-size: 24rpx;
  359. font-family: PingFang;
  360. line-height: 23rpx;
  361. }
  362. .group_16 {
  363. margin-top: 37rpx;
  364. padding: 0 2rpx;
  365. }
  366. .group_17 {
  367. line-height: 28rpx;
  368. height: 29rpx;
  369. }
  370. .text_27 {
  371. color: #ff3e3e;
  372. font-size: 24rpx;
  373. font-family: PingFang;
  374. line-height: 19rpx;
  375. }
  376. .text_28 {
  377. color: #ff3e3e;
  378. font-size: 36rpx;
  379. font-family: PingFang;
  380. line-height: 28rpx;
  381. }
  382. .text_29 {
  383. margin-left: 10rpx;
  384. margin-top: 9rpx;
  385. color: #999999;
  386. font-size: 24rpx;
  387. font-family: PingFang;
  388. line-height: 20rpx;
  389. text-decoration: line-through;
  390. }
  391. .text_30 {
  392. z-index: 2;
  393. position: absolute;
  394. top: 130rpx;
  395. right: 20rpx;
  396. color: #999999;
  397. font-size: 24rpx;
  398. font-family: PingFang;
  399. }
  400. }
  401. </style>