index.vue 7.1 KB

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