index.vue 6.8 KB

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