index.vue 8.7 KB

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