index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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="toBuy(item)">
  38. <image class="image" :src="item.file&&item.file.length>0?item.file[0].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. marketList: [ //商品列表
  73. ],
  74. // 是否显示返回顶部
  75. isShow: false,
  76. topItem: ''
  77. };
  78. },
  79. onShow: function() {
  80. const that = this;
  81. that.search();
  82. },
  83. methods: {
  84. async search() {
  85. const that = this;
  86. let res;
  87. // 轮播图
  88. res = await that.$api(`/banner`, 'GET', {
  89. status: '0'
  90. });
  91. if (res.errcode == '0') that.$set(that, `bannerList`, res.data);
  92. // 首页模块管理
  93. res = await that.$api(`/indexModule`, 'GET', {
  94. status: '0'
  95. });
  96. if (res.errcode == '0') {
  97. let data = res.data.sort(function(a, b) {
  98. return a.sort - b.sort
  99. });
  100. that.$set(that, `btnList`, data);
  101. }
  102. res = await that.$api(`/goods`, `GET`, {});
  103. if (res.errcode == '0') {
  104. that.$set(that, `marketList`, res.data)
  105. }
  106. },
  107. // 公共跳转
  108. toCommon(e) {
  109. uni.navigateTo({
  110. url: `/${e}`
  111. })
  112. },
  113. toBuy(e) {
  114. uni.navigateTo({
  115. url: `/pagesHome/order/detail?id=${e.id}`
  116. })
  117. },
  118. // 计算高度
  119. handleScroll(e) {
  120. const that = this;
  121. let scrollTop = e.detail.scrollTop;
  122. that.isShow = scrollTop > 500;
  123. that.topItem = '';
  124. },
  125. // 返回顶部
  126. backTop() {
  127. const that = this;
  128. that.topItem = 'top'
  129. },
  130. toPath(e) {
  131. if (e && e.route) uni.redirectTo({
  132. url: `/${e.route}`
  133. })
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .scrollView {
  140. height: 100vh;
  141. }
  142. .main {
  143. padding: 2vw;
  144. .zero {
  145. margin: 0 0 2vw 0;
  146. }
  147. .one {
  148. background-color: var(--fFB1Color);
  149. border-radius: 20px;
  150. padding: 0 2vw;
  151. input {
  152. font-size: var(--font15Size);
  153. color: var(--fffColor);
  154. border-radius: 14px;
  155. width: 100%;
  156. padding: 1.5vw 0;
  157. }
  158. .placss {
  159. color: var(--fffColor);
  160. }
  161. }
  162. .two {
  163. swiper {
  164. height: 50vw;
  165. border-radius: 5px;
  166. }
  167. .list {
  168. border-radius: 5px;
  169. .image {
  170. width: 100%;
  171. height: 100%;
  172. border-radius: 5px;
  173. }
  174. }
  175. }
  176. .thr {
  177. display: flex;
  178. flex-direction: row;
  179. justify-content: space-around;
  180. flex-wrap: wrap;
  181. .list {
  182. width: 17vw;
  183. text-align: center;
  184. margin: 0 0 2vw 0;
  185. .image {
  186. width: 80%;
  187. height: 13vw;
  188. margin: 1.5vw 0 1.5vw 0;
  189. }
  190. .name {
  191. font-size: var(--font13Size);
  192. }
  193. }
  194. }
  195. .four {
  196. display: flex;
  197. flex-direction: row;
  198. justify-content: space-around;
  199. flex-wrap: wrap;
  200. background-color: var(--f2Color);
  201. padding: 2vw 0 0 0;
  202. .recomList {
  203. display: flex;
  204. flex-direction: row;
  205. justify-content: space-around;
  206. width: 41vw;
  207. margin: 0 0 2vw 0;
  208. padding: 2vw;
  209. border-radius: 10px;
  210. background-image: linear-gradient(to bottom, rgba(250, 216, 213, 1) 5%, rgba(255, 255, 255, 1) 22%);
  211. .list {
  212. width: 20vw;
  213. text-align: center;
  214. .title {
  215. text-align: center;
  216. font-weight: bold;
  217. font-size: var(--font15Size);
  218. ;
  219. margin: 0 0 1vw 0;
  220. }
  221. .image {
  222. width: 18vw;
  223. height: 20vw;
  224. margin: 0 0 1vw 0;
  225. }
  226. .name {
  227. width: 17vw;
  228. font-size: var(--font12Size);
  229. ;
  230. border: 1px solid var(--fFB1Color);
  231. border-radius: 25px;
  232. padding: 0 1vw;
  233. text-align: center;
  234. }
  235. }
  236. }
  237. }
  238. .five {
  239. display: flex;
  240. flex-direction: row;
  241. flex-wrap: wrap;
  242. background-color: var(--f2Color);
  243. padding: 2vw 0 0 0;
  244. .list {
  245. width: 40vw;
  246. background-color: var(--fffColor);
  247. padding: 2vw;
  248. margin: 0 2vw 2vw 2vw;
  249. border-radius: 10px;
  250. .image {
  251. width: 100%;
  252. height: 35vw;
  253. }
  254. .name {
  255. font-size: var(--font14Size);
  256. margin: 0 0 1vw 0;
  257. }
  258. .other {
  259. display: flex;
  260. flex-direction: row;
  261. justify-content: space-between;
  262. .money {
  263. color: var(--fFB1Color);
  264. text:nth-child(1) {
  265. font-size: var(--font12Size);
  266. }
  267. }
  268. .btn {
  269. button {
  270. color: var(--fffColor);
  271. background-color: var(--fFB1Color);
  272. padding: 5px 2vw;
  273. font-size: var(--font14Size);
  274. line-height: 1;
  275. border-radius: 90px;
  276. }
  277. }
  278. }
  279. }
  280. .list:nth-child(2n) {
  281. margin: 0 0 2vw 2vw;
  282. }
  283. }
  284. }
  285. .backTop {
  286. position: fixed;
  287. bottom: 20vw;
  288. right: 5vw;
  289. text {
  290. font-size: 30px;
  291. background-color: #0000005f;
  292. border-radius: 90px;
  293. }
  294. }
  295. </style>