index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  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="搜索商品">
  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">
  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: ''
  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. toPath(e) {
  225. if (e && e.route) uni.redirectTo({
  226. url: `/${e.route}`
  227. })
  228. },
  229. // 计算高度
  230. handleScroll(e) {
  231. const that = this;
  232. let scrollTop = e.detail.scrollTop;
  233. that.isShow = scrollTop > 500;
  234. that.topItem = '';
  235. },
  236. // 返回顶部
  237. backTop() {
  238. const that = this;
  239. that.topItem = 'top'
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss">
  245. .scrollView {
  246. height: 100vh;
  247. }
  248. .main {
  249. padding: 2vw;
  250. .zero {
  251. margin: 0 0 2vw 0;
  252. }
  253. .one {
  254. background-color: var(--fFB1Color);
  255. border-radius: 20px;
  256. padding: 0 2vw;
  257. input {
  258. font-size: var(--font15Size);
  259. color: var(--f85Color);
  260. border-radius: 14px;
  261. width: 100%;
  262. padding: 1.5vw 0;
  263. }
  264. }
  265. .two {
  266. swiper {
  267. height: 50vw;
  268. border-radius: 5px;
  269. }
  270. .list {
  271. border-radius: 5px;
  272. .image {
  273. width: 100%;
  274. height: 100%;
  275. border-radius: 5px;
  276. }
  277. }
  278. }
  279. .thr {
  280. display: flex;
  281. flex-direction: row;
  282. justify-content: space-around;
  283. flex-wrap: wrap;
  284. .list {
  285. width: 17vw;
  286. text-align: center;
  287. margin: 0 0 2vw 0;
  288. .image {
  289. width: 100%;
  290. height: 16vw;
  291. margin: 0 0 1vw 0;
  292. }
  293. .name {
  294. font-size: var(--font13Size);
  295. }
  296. }
  297. }
  298. .four {
  299. display: flex;
  300. flex-direction: row;
  301. justify-content: space-around;
  302. flex-wrap: wrap;
  303. background-color: var(--f2Color);
  304. padding: 2vw 0 0 0;
  305. .recomList {
  306. display: flex;
  307. flex-direction: row;
  308. justify-content: space-around;
  309. width: 41vw;
  310. margin: 0 0 2vw 0;
  311. padding: 2vw;
  312. border-radius: 10px;
  313. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  314. .list {
  315. width: 20vw;
  316. text-align: center;
  317. .title {
  318. text-align: center;
  319. font-weight: bold;
  320. font-size: var(--font15Size);
  321. ;
  322. margin: 0 0 1vw 0;
  323. }
  324. .image {
  325. width: 18vw;
  326. height: 20vw;
  327. margin: 0 0 1vw 0;
  328. }
  329. .name {
  330. width: 17vw;
  331. font-size: var(--font12Size);
  332. ;
  333. border: 1px solid var(--fFB1Color);
  334. border-radius: 25px;
  335. padding: 0 1vw;
  336. text-align: center;
  337. }
  338. }
  339. }
  340. }
  341. .five {
  342. display: flex;
  343. flex-direction: row;
  344. flex-wrap: wrap;
  345. background-color: var(--f2Color);
  346. padding: 2vw 0 0 0;
  347. .list {
  348. width: 40vw;
  349. background-color: var(--fffColor);
  350. padding: 2vw;
  351. margin: 0 2vw 2vw 2vw;
  352. border-radius: 10px;
  353. .image {
  354. width: 100%;
  355. height: 35vw;
  356. }
  357. .name {
  358. font-size: var(--font14Size);
  359. margin: 0 0 1vw 0;
  360. }
  361. .other {
  362. display: flex;
  363. flex-direction: row;
  364. justify-content: space-between;
  365. .money {
  366. color: var(--fFB1Color);
  367. text:nth-child(1) {
  368. font-size: var(--font12Size);
  369. }
  370. }
  371. .btn {
  372. button {
  373. color: var(--fffColor);
  374. background-color: var(--fFB1Color);
  375. padding: 5px 2vw;
  376. font-size: var(--font14Size);
  377. line-height: 1;
  378. border-radius: 90px;
  379. }
  380. }
  381. }
  382. }
  383. .list:nth-child(2n) {
  384. margin: 0 0 2vw 2vw;
  385. }
  386. }
  387. }
  388. .backTop {
  389. position: fixed;
  390. bottom: 20vw;
  391. right: 5vw;
  392. text {
  393. font-size: 30px;
  394. background-color: #0000005f;
  395. border-radius: 90px;
  396. }
  397. }
  398. </style>