index.vue 6.8 KB

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