推拿小程序前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

368 lines
6.6 KiB

3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
2 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
3 months ago
2 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
  1. <template>
  2. <view class="page">
  3. <image class="bg" src="@/static/image/home/bg.png"></image>
  4. <view class="content">
  5. <!-- 导航栏 -->
  6. <navbar title="首页" bgColor="transparent" color="#FFFFFF" />
  7. <!-- 搜索栏 -->
  8. <view class="search">
  9. <uv-search placeholder="搜你喜欢的产品" bgColor="#fff" @custom="search" @search="search"
  10. v-model="keyword"></uv-search>
  11. </view>
  12. <!-- 轮播图 -->
  13. <view class="swipe">
  14. <uv-swiper :list="bannerList" indicator indicatorMode="dot" height="340rpx" keyName="image"></uv-swiper>
  15. </view>
  16. <!-- 推荐 -> 会员 -->
  17. <view v-if="!role" class="card flex recommend-member" @click="$utils.navigateTo('/pages/index/memberCenter')" >
  18. <view class="flex" style="flex: 1;">
  19. <image class="icon-member" style="" src="@/static/image/home/icon-member.png"></image>
  20. <!-- todo: check -->
  21. <text>会员享受专属折扣和优惠活动会员下单更优惠</text>
  22. </view>
  23. <image class="icon-arrow" src="@/static/image/home/icon-arrow.png"></image>
  24. </view>
  25. <!-- 商品列表 -->
  26. <view class="recommend-product">
  27. <view class="flex title">
  28. <text>热销套餐</text>
  29. <image class="icon-hot" style="" src="@/static/image/home/icon-hot.png"></image>
  30. </view>
  31. <productCard v-for="item in list" :data="item" :key="item.id"></productCard>
  32. </view>
  33. <!-- 优惠券弹窗 -->
  34. <couponPopup v-if="riceInfo.isGetCoupon"></couponPopup>
  35. <!-- tabbar -->
  36. <tabber select="home" />
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import tabber from '@/components/base/tabbar.vue'
  42. import couponPopup from "@/components/couponPopup/couponPopup.vue"
  43. import { mapState, mapGetters } from 'vuex'
  44. import productCard from '@/components/product/productCard.vue'
  45. import mixinsList from '@/mixins/list.js'
  46. export default {
  47. mixins: [mixinsList],
  48. components: {
  49. productCard,
  50. couponPopup,
  51. tabber,
  52. },
  53. data() {
  54. return {
  55. keyword: '',
  56. bannerList: [],
  57. notice: '',
  58. mixinsListApi: 'queryProductList',
  59. }
  60. },
  61. computed: {
  62. ...mapGetters(['role']),
  63. ...mapState(['riceInfo', 'category'])
  64. },
  65. onLoad(query) {
  66. if (query.shareId) {
  67. uni.setStorageSync('shareId', query.shareId)
  68. }
  69. },
  70. onShow() {
  71. this.fetchBanner()
  72. this.fetchNotice()
  73. this.getData()
  74. if(uni.getStorageSync('token')){
  75. this.$store.commit('getUserInfo')
  76. this.$store.commit('getUserCenterInfo')
  77. }
  78. },
  79. onPullDownRefresh() {
  80. this.fetchBanner()
  81. this.getData()
  82. },
  83. methods: {
  84. // 搜素
  85. search() {
  86. uni.navigateTo({
  87. url: '/pages/index/category?search=' + this.keyword
  88. })
  89. this.keyword = ''
  90. },
  91. // 获取轮播图
  92. async fetchBanner() {
  93. try {
  94. this.bannerList = (await this.$fetch('queryBannerList'))?.records
  95. } catch (err) {
  96. }
  97. },
  98. // 获取轮播图
  99. async fetchNotice() {
  100. try {
  101. this.notice = (await this.$fetch('queryNoticeList'))?.records
  102. } catch (err) {
  103. }
  104. },
  105. },
  106. }
  107. </script>
  108. <style scoped lang="scss">
  109. .page {
  110. width: 100vw;
  111. min-height: 100vh;
  112. background-color: $uni-bg-color;
  113. position: relative;
  114. }
  115. .bg {
  116. width: 100%;
  117. height: 589rpx;
  118. }
  119. .content {
  120. position: absolute;
  121. top: 0;
  122. left: 0;
  123. width: 100%;
  124. box-sizing: border-box;
  125. }
  126. // 搜索栏
  127. .search {
  128. background-color: $uni-fg-color;
  129. border-radius: 41rpx;
  130. padding: 10rpx 0rpx;
  131. margin: 20rpx 30rpx 0 30rpx;
  132. display: flex;
  133. align-items: center;
  134. /deep/ .uv-search__action {
  135. color: $uni-text-color;
  136. padding: 10rpx 18rpx;
  137. }
  138. }
  139. // 轮播图
  140. .swipe {
  141. overflow: hidden;
  142. border-radius: 14rpx;
  143. margin: 14rpx 30rpx 0 30rpx;
  144. }
  145. .recommend {
  146. &-member {
  147. margin: 27rpx 17rpx 0 17rpx;
  148. color: $uni-color-light;
  149. font-size: 28rpx;
  150. .icon {
  151. &-member {
  152. width: 42rpx;
  153. height: 38rpx;
  154. margin-right: 5rpx;
  155. }
  156. &-arrow {
  157. width: 26rpx;
  158. height: 26rpx;
  159. }
  160. }
  161. }
  162. &-product {
  163. margin: 28rpx 17rpx 0 17rpx;
  164. .title{
  165. justify-content: flex-start;
  166. color: #000000;
  167. font-size: 32rpx;
  168. font-weight: 700;
  169. padding-left: 18rpx;
  170. }
  171. .icon {
  172. &-hot {
  173. width: 22rpx;
  174. height: 30rpx;
  175. margin-left: 2rpx;
  176. }
  177. }
  178. }
  179. }
  180. .home {
  181. // 首页-分类菜单
  182. .home-menu {
  183. margin: 20rpx;
  184. border-radius: 20rpx;
  185. padding: 20rpx 0rpx;
  186. background-color: #fff;
  187. image {
  188. width: 80rpx;
  189. height: 80rpx;
  190. margin-top: 10rpx;
  191. }
  192. .menu-text {
  193. font-size: 28rpx;
  194. margin: 10rpx 0rpx;
  195. }
  196. }
  197. // 新人专享
  198. .new-people {
  199. background: white;
  200. padding: 20rpx;
  201. margin-bottom: 20rpx;
  202. .new-perple-top {
  203. display: flex;
  204. align-items: center;
  205. justify-content: space-between;
  206. margin-bottom: 20rpx;
  207. .new-perple-top-left {
  208. display: flex;
  209. align-items: center;
  210. color: $uni-color;
  211. .title {
  212. font-size: 40rpx;
  213. font-weight: bold;
  214. }
  215. .descript {
  216. margin-left: 10rpx;
  217. }
  218. }
  219. .new-perple-top-right {
  220. image {
  221. width: 80px;
  222. height: 40rpx;
  223. }
  224. }
  225. }
  226. .new-perple-main {
  227. display: flex;
  228. .red-packet {
  229. display: flex;
  230. align-items: center;
  231. justify-content: center;
  232. width: 20%;
  233. image {
  234. width: 120rpx;
  235. height: 120rpx;
  236. }
  237. }
  238. .activity {
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. justify-content: center;
  243. width: 25%;
  244. background: white;
  245. border-radius: 10px;
  246. image {
  247. width: 140rpx;
  248. height: 140rpx;
  249. border-radius: 10rpx;
  250. }
  251. .title {
  252. background: $uni-color;
  253. color: white;
  254. border-radius: 20rpx;
  255. font-size: 24rpx;
  256. padding: 5rpx 10rpx;
  257. margin: 10rpx 0rpx;
  258. width: 90%;
  259. white-space: nowrap;
  260. overflow: hidden;
  261. text-overflow: ellipsis;
  262. box-sizing: border-box;
  263. text-align: center;
  264. }
  265. .product-price {
  266. color: $uni-color;
  267. font-size: 24rpx;
  268. }
  269. }
  270. }
  271. }
  272. // 视频
  273. .video-line {
  274. display: flex;
  275. align-items: center;
  276. padding: 20rpx;
  277. background: white;
  278. font-size: 34rpx;
  279. .line {
  280. height: 40rpx;
  281. width: 10rpx;
  282. background: $uni-color;
  283. border-radius: 5rpx;
  284. margin-right: 10rpx;
  285. }
  286. }
  287. .video-item {
  288. display: flex;
  289. justify-content: center;
  290. align-items: center;
  291. margin: 20rpx 0rpx;
  292. .product-video {
  293. border-radius: 20rpx;
  294. width: calc(710rpx);
  295. }
  296. }
  297. // 推荐
  298. .recommend {
  299. display: flex;
  300. align-items: center;
  301. justify-content: space-between;
  302. background: white;
  303. margin: 20rpx 0rpx;
  304. padding: 20rpx;
  305. .recommend-title {
  306. font-size: 36rpx;
  307. }
  308. .recommend-more {
  309. color: $uni-color;
  310. }
  311. }
  312. }
  313. </style>