index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
  3. <scroll-view class="scrollView" scroll-with-animation :scroll-into-view="topItem" scroll-y="true" @scroll="handleScroll">
  4. <view class="main" id="top">
  5. <view class="zero one">
  6. <input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')" placeholder-class="placss">
  7. </view>
  8. <view class="zero two">
  9. <swiper class="swiper" circular :indicator-dots="true" indicator-color="#ffffff" indicator-active-color="#FB1438" :autoplay="true" :interval="3000" :duration="1000">
  10. <swiper-item class="list" v-for="(item,index) in bannerList" :key="index">
  11. <image class="image" :src="item.url" mode=""></image>
  12. </swiper-item>
  13. </swiper>
  14. </view>
  15. <view class="zero thr">
  16. <view class="list" v-for="(item,index) in btnList" :key="index" @tap="toCommon(item.route)">
  17. <image class="image" :src="item.url" mode=""></image>
  18. <view class="textOver name">
  19. {{item.name}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="zero four">
  24. <view class="recomList" v-for="(item,index) in recomList" :key="index">
  25. <view class="list" v-for="(tag,indexs) in item.list" :key="indexs">
  26. <view class="title">
  27. <text>{{tag.title||'&nbsp;'}}</text>
  28. </view>
  29. <image class="image" :src="tag.url" mode=""></image>
  30. <view class="textOver name">
  31. {{tag.name}}
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="zero five">
  37. <view class="list" v-for="(item,index) in marketList" :key="index">
  38. <image class="image" :src="item.url" mode=""></image>
  39. <view class="name">
  40. {{item.name}}
  41. </view>
  42. <view class="other">
  43. <view class="money">
  44. <text>¥</text><text>{{item.money}}</text>
  45. </view>
  46. <view class="btn">
  47. <button type="default" size="mini">购买</button>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </scroll-view>
  54. <view class="backTop" v-if="isShow==true">
  55. <text @click="backTop" class="iconfont icon-fanhuidingbu"></text>
  56. </view>
  57. </mobile-frame>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. frameStyle: {
  64. useBar: true
  65. },
  66. bannerList: [ // 轮播图
  67. {
  68. url: require('@/static/test.png')
  69. },
  70. {
  71. url: require('@/static/test.png')
  72. },
  73. {
  74. url: require('@/static/test.png')
  75. },
  76. {
  77. url: require('@/static/test.png')
  78. },
  79. ],
  80. btnList: [ //功能按钮
  81. {
  82. name: '商品分类',
  83. url: require('@/static/logo.png'),
  84. route: 'pagesHome/market/type'
  85. },
  86. {
  87. name: '首农专区',
  88. url: require('@/static/logo.png'),
  89. route: ''
  90. },
  91. {
  92. name: '地方特产',
  93. url: require('@/static/logo.png'),
  94. route: ''
  95. },
  96. {
  97. name: '进口食品',
  98. url: require('@/static/logo.png'),
  99. route: ''
  100. },
  101. {
  102. name: '扶贫专区',
  103. url: require('@/static/logo.png'),
  104. route: ''
  105. },
  106. {
  107. name: '自提门店',
  108. url: require('@/static/logo.png'),
  109. route: ''
  110. },
  111. {
  112. name: '点到优选',
  113. url: require('@/static/logo.png'),
  114. route: ''
  115. },
  116. {
  117. name: '活动专区',
  118. url: require('@/static/logo.png'),
  119. route: ''
  120. },
  121. {
  122. name: '兑换中心',
  123. url: require('@/static/logo.png'),
  124. route: ''
  125. },
  126. {
  127. name: '员工中心',
  128. url: require('@/static/logo.png'),
  129. route: ''
  130. },
  131. ],
  132. recomList: [ //推荐好物
  133. {
  134. list: [ //商品
  135. {
  136. title: '新品上架',
  137. url: require('@/static/test.png'),
  138. name: '商品名称'
  139. },
  140. {
  141. title: '',
  142. url: require('@/static/test.png'),
  143. name: '商品名称'
  144. },
  145. ]
  146. },
  147. {
  148. list: [ //商品
  149. {
  150. title: '发现好货',
  151. url: require('@/static/test.png'),
  152. name: '商品名称'
  153. },
  154. {
  155. title: '热销爆款',
  156. url: require('@/static/test.png'),
  157. name: '商品名称'
  158. },
  159. ]
  160. },
  161. {
  162. list: [ //商品
  163. {
  164. title: '首农精选',
  165. url: require('@/static/test.png'),
  166. name: '商品名称'
  167. },
  168. {
  169. title: '居家常备',
  170. url: require('@/static/test.png'),
  171. name: '商品名称'
  172. },
  173. ]
  174. },
  175. {
  176. list: [ //商品
  177. {
  178. title: '人气单品',
  179. url: require('@/static/test.png'),
  180. name: '商品名称'
  181. },
  182. {
  183. title: '夏季畅销',
  184. url: require('@/static/test.png'),
  185. name: '商品名称'
  186. },
  187. ]
  188. }
  189. ],
  190. marketList: [ //商品列表
  191. {
  192. url: require('@/static/test.png'),
  193. name: '商品名称',
  194. money: 10
  195. },
  196. {
  197. url: require('@/static/test.png'),
  198. name: '商品名称',
  199. money: 10
  200. },
  201. {
  202. url: require('@/static/test.png'),
  203. name: '商品名称',
  204. money: 10
  205. },
  206. {
  207. url: require('@/static/test.png'),
  208. name: '商品名称',
  209. money: 10
  210. },
  211. {
  212. url: require('@/static/test.png'),
  213. name: '商品名称',
  214. money: 10
  215. },
  216. ],
  217. // 是否显示返回顶部
  218. isShow: false,
  219. topItem: ''
  220. };
  221. },
  222. onShow: function() {},
  223. methods: {
  224. // 公共跳转
  225. toCommon(e) {
  226. uni.navigateTo({
  227. url: `/${e}`
  228. })
  229. },
  230. toPath(e) {
  231. if (e && e.route) uni.redirectTo({
  232. url: `/${e.route}`
  233. })
  234. },
  235. // 计算高度
  236. handleScroll(e) {
  237. const that = this;
  238. let scrollTop = e.detail.scrollTop;
  239. that.isShow = scrollTop > 500;
  240. that.topItem = '';
  241. },
  242. // 返回顶部
  243. backTop() {
  244. const that = this;
  245. that.topItem = 'top'
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss">
  251. .scrollView {
  252. height: 100vh;
  253. }
  254. .main {
  255. padding: 2vw;
  256. .zero {
  257. margin: 0 0 2vw 0;
  258. }
  259. .one {
  260. background-color: var(--fFB1Color);
  261. border-radius: 20px;
  262. padding: 0 2vw;
  263. input {
  264. font-size: var(--font15Size);
  265. color: var(--fffColor);
  266. border-radius: 14px;
  267. width: 100%;
  268. padding: 1.5vw 0;
  269. }
  270. .placss {
  271. color: var(--fffColor);
  272. }
  273. }
  274. .two {
  275. swiper {
  276. height: 50vw;
  277. border-radius: 5px;
  278. }
  279. .list {
  280. border-radius: 5px;
  281. .image {
  282. width: 100%;
  283. height: 100%;
  284. border-radius: 5px;
  285. }
  286. }
  287. }
  288. .thr {
  289. display: flex;
  290. flex-direction: row;
  291. justify-content: space-around;
  292. flex-wrap: wrap;
  293. .list {
  294. width: 17vw;
  295. text-align: center;
  296. margin: 0 0 2vw 0;
  297. .image {
  298. width: 100%;
  299. height: 16vw;
  300. margin: 0 0 1vw 0;
  301. }
  302. .name {
  303. font-size: var(--font13Size);
  304. }
  305. }
  306. }
  307. .four {
  308. display: flex;
  309. flex-direction: row;
  310. justify-content: space-around;
  311. flex-wrap: wrap;
  312. background-color: var(--f2Color);
  313. padding: 2vw 0 0 0;
  314. .recomList {
  315. display: flex;
  316. flex-direction: row;
  317. justify-content: space-around;
  318. width: 41vw;
  319. margin: 0 0 2vw 0;
  320. padding: 2vw;
  321. border-radius: 10px;
  322. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  323. .list {
  324. width: 20vw;
  325. text-align: center;
  326. .title {
  327. text-align: center;
  328. font-weight: bold;
  329. font-size: var(--font15Size);
  330. ;
  331. margin: 0 0 1vw 0;
  332. }
  333. .image {
  334. width: 18vw;
  335. height: 20vw;
  336. margin: 0 0 1vw 0;
  337. }
  338. .name {
  339. width: 17vw;
  340. font-size: var(--font12Size);
  341. ;
  342. border: 1px solid var(--fFB1Color);
  343. border-radius: 25px;
  344. padding: 0 1vw;
  345. text-align: center;
  346. }
  347. }
  348. }
  349. }
  350. .five {
  351. display: flex;
  352. flex-direction: row;
  353. flex-wrap: wrap;
  354. background-color: var(--f2Color);
  355. padding: 2vw 0 0 0;
  356. .list {
  357. width: 40vw;
  358. background-color: var(--fffColor);
  359. padding: 2vw;
  360. margin: 0 2vw 2vw 2vw;
  361. border-radius: 10px;
  362. .image {
  363. width: 100%;
  364. height: 35vw;
  365. }
  366. .name {
  367. font-size: var(--font14Size);
  368. margin: 0 0 1vw 0;
  369. }
  370. .other {
  371. display: flex;
  372. flex-direction: row;
  373. justify-content: space-between;
  374. .money {
  375. color: var(--fFB1Color);
  376. text:nth-child(1) {
  377. font-size: var(--font12Size);
  378. }
  379. }
  380. .btn {
  381. button {
  382. color: var(--fffColor);
  383. background-color: var(--fFB1Color);
  384. padding: 5px 2vw;
  385. font-size: var(--font14Size);
  386. line-height: 1;
  387. border-radius: 90px;
  388. }
  389. }
  390. }
  391. }
  392. .list:nth-child(2n) {
  393. margin: 0 0 2vw 2vw;
  394. }
  395. }
  396. }
  397. .backTop {
  398. position: fixed;
  399. bottom: 20vw;
  400. right: 5vw;
  401. text {
  402. font-size: 30px;
  403. background-color: #0000005f;
  404. border-radius: 90px;
  405. }
  406. }
  407. </style>