index.vue 7.3 KB

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