index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  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&&item.url.length>0?item.url[0].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.to)">
  17. <image class="image" :src="item.url&&item.url.length>0?item.url[0].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" @tap="toCommon('pagesHome/market/detail')">
  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. btnList: [ //功能按钮
  69. ],
  70. recomList: [ //推荐好物
  71. {
  72. list: [ //商品
  73. {
  74. title: '新品上架',
  75. url: require('@/static/test.png'),
  76. name: '商品名称'
  77. },
  78. {
  79. title: '',
  80. url: require('@/static/test.png'),
  81. name: '商品名称'
  82. },
  83. ]
  84. },
  85. {
  86. list: [ //商品
  87. {
  88. title: '发现好货',
  89. url: require('@/static/test.png'),
  90. name: '商品名称'
  91. },
  92. {
  93. title: '热销爆款',
  94. url: require('@/static/test.png'),
  95. name: '商品名称'
  96. },
  97. ]
  98. },
  99. {
  100. list: [ //商品
  101. {
  102. title: '首农精选',
  103. url: require('@/static/test.png'),
  104. name: '商品名称'
  105. },
  106. {
  107. title: '居家常备',
  108. url: require('@/static/test.png'),
  109. name: '商品名称'
  110. },
  111. ]
  112. },
  113. {
  114. list: [ //商品
  115. {
  116. title: '人气单品',
  117. url: require('@/static/test.png'),
  118. name: '商品名称'
  119. },
  120. {
  121. title: '夏季畅销',
  122. url: require('@/static/test.png'),
  123. name: '商品名称'
  124. },
  125. ]
  126. }
  127. ],
  128. marketList: [ //商品列表
  129. {
  130. url: require('@/static/test.png'),
  131. name: '商品名称',
  132. money: 10
  133. },
  134. {
  135. url: require('@/static/test.png'),
  136. name: '商品名称',
  137. money: 10
  138. },
  139. {
  140. url: require('@/static/test.png'),
  141. name: '商品名称',
  142. money: 10
  143. },
  144. {
  145. url: require('@/static/test.png'),
  146. name: '商品名称',
  147. money: 10
  148. },
  149. {
  150. url: require('@/static/test.png'),
  151. name: '商品名称',
  152. money: 10
  153. },
  154. ],
  155. // 是否显示返回顶部
  156. isShow: false,
  157. topItem: ''
  158. };
  159. },
  160. onShow: function() {
  161. const that = this;
  162. that.search();
  163. },
  164. methods: {
  165. async search() {
  166. const that = this;
  167. let res;
  168. // 轮播图
  169. res = await that.$api(`/banner`, 'GET', {
  170. is_use: '0'
  171. });
  172. if (res.errcode == '0') that.$set(that, `bannerList`, res.data);
  173. // 首页模块管理
  174. res = await that.$api(`/indexModule`, 'GET', {
  175. is_use: '0'
  176. });
  177. if (res.errcode == '0') {
  178. let data = res.data.sort(function(a, b) {
  179. return a.sort - b.sort
  180. });
  181. that.$set(that, `btnList`, data);
  182. }
  183. },
  184. // 公共跳转
  185. toCommon(e) {
  186. uni.navigateTo({
  187. url: `/${e}`
  188. })
  189. },
  190. toPath(e) {
  191. if (e && e.route) uni.redirectTo({
  192. url: `/${e.route}`
  193. })
  194. },
  195. // 计算高度
  196. handleScroll(e) {
  197. const that = this;
  198. let scrollTop = e.detail.scrollTop;
  199. that.isShow = scrollTop > 500;
  200. that.topItem = '';
  201. },
  202. // 返回顶部
  203. backTop() {
  204. const that = this;
  205. that.topItem = 'top'
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss">
  211. .scrollView {
  212. height: 100vh;
  213. }
  214. .main {
  215. padding: 2vw;
  216. .zero {
  217. margin: 0 0 2vw 0;
  218. }
  219. .one {
  220. background-color: var(--fFB1Color);
  221. border-radius: 20px;
  222. padding: 0 2vw;
  223. input {
  224. font-size: var(--font15Size);
  225. color: var(--fffColor);
  226. border-radius: 14px;
  227. width: 100%;
  228. padding: 1.5vw 0;
  229. }
  230. .placss {
  231. color: var(--fffColor);
  232. }
  233. }
  234. .two {
  235. swiper {
  236. height: 50vw;
  237. border-radius: 5px;
  238. }
  239. .list {
  240. border-radius: 5px;
  241. .image {
  242. width: 100%;
  243. height: 100%;
  244. border-radius: 5px;
  245. }
  246. }
  247. }
  248. .thr {
  249. display: flex;
  250. flex-direction: row;
  251. justify-content: space-around;
  252. flex-wrap: wrap;
  253. .list {
  254. width: 17vw;
  255. text-align: center;
  256. margin: 0 0 2vw 0;
  257. .image {
  258. width: 100%;
  259. height: 16vw;
  260. margin: 0 0 1vw 0;
  261. }
  262. .name {
  263. font-size: var(--font13Size);
  264. }
  265. }
  266. }
  267. .four {
  268. display: flex;
  269. flex-direction: row;
  270. justify-content: space-around;
  271. flex-wrap: wrap;
  272. background-color: var(--f2Color);
  273. padding: 2vw 0 0 0;
  274. .recomList {
  275. display: flex;
  276. flex-direction: row;
  277. justify-content: space-around;
  278. width: 41vw;
  279. margin: 0 0 2vw 0;
  280. padding: 2vw;
  281. border-radius: 10px;
  282. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  283. .list {
  284. width: 20vw;
  285. text-align: center;
  286. .title {
  287. text-align: center;
  288. font-weight: bold;
  289. font-size: var(--font15Size);
  290. ;
  291. margin: 0 0 1vw 0;
  292. }
  293. .image {
  294. width: 18vw;
  295. height: 20vw;
  296. margin: 0 0 1vw 0;
  297. }
  298. .name {
  299. width: 17vw;
  300. font-size: var(--font12Size);
  301. ;
  302. border: 1px solid var(--fFB1Color);
  303. border-radius: 25px;
  304. padding: 0 1vw;
  305. text-align: center;
  306. }
  307. }
  308. }
  309. }
  310. .five {
  311. display: flex;
  312. flex-direction: row;
  313. flex-wrap: wrap;
  314. background-color: var(--f2Color);
  315. padding: 2vw 0 0 0;
  316. .list {
  317. width: 40vw;
  318. background-color: var(--fffColor);
  319. padding: 2vw;
  320. margin: 0 2vw 2vw 2vw;
  321. border-radius: 10px;
  322. .image {
  323. width: 100%;
  324. height: 35vw;
  325. }
  326. .name {
  327. font-size: var(--font14Size);
  328. margin: 0 0 1vw 0;
  329. }
  330. .other {
  331. display: flex;
  332. flex-direction: row;
  333. justify-content: space-between;
  334. .money {
  335. color: var(--fFB1Color);
  336. text:nth-child(1) {
  337. font-size: var(--font12Size);
  338. }
  339. }
  340. .btn {
  341. button {
  342. color: var(--fffColor);
  343. background-color: var(--fFB1Color);
  344. padding: 5px 2vw;
  345. font-size: var(--font14Size);
  346. line-height: 1;
  347. border-radius: 90px;
  348. }
  349. }
  350. }
  351. }
  352. .list:nth-child(2n) {
  353. margin: 0 0 2vw 2vw;
  354. }
  355. }
  356. }
  357. .backTop {
  358. position: fixed;
  359. bottom: 20vw;
  360. right: 5vw;
  361. text {
  362. font-size: 30px;
  363. background-color: #0000005f;
  364. border-radius: 90px;
  365. }
  366. }
  367. </style>