index.vue 6.8 KB

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