index.vue 6.7 KB

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