推拿小程序前端代码仓库
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.

367 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
2 months ago
3 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. }
  77. },
  78. onPullDownRefresh() {
  79. this.fetchBanner()
  80. this.getData()
  81. },
  82. methods: {
  83. // 搜素
  84. search() {
  85. uni.navigateTo({
  86. url: '/pages/index/category?search=' + this.keyword
  87. })
  88. this.keyword = ''
  89. },
  90. // 获取轮播图
  91. async fetchBanner() {
  92. try {
  93. this.bannerList = (await this.$fetch('queryBannerList'))?.records
  94. } catch (err) {
  95. }
  96. },
  97. // 获取轮播图
  98. async fetchNotice() {
  99. try {
  100. this.notice = (await this.$fetch('queryNoticeList'))?.records
  101. } catch (err) {
  102. }
  103. },
  104. },
  105. }
  106. </script>
  107. <style scoped lang="scss">
  108. .page {
  109. width: 100vw;
  110. min-height: 100vh;
  111. background-color: $uni-bg-color;
  112. }
  113. .bg {
  114. width: 100%;
  115. height: 589rpx;
  116. }
  117. .content {
  118. position: absolute;
  119. top: 0;
  120. left: 0;
  121. width: 100%;
  122. box-sizing: border-box;
  123. }
  124. // 搜索栏
  125. .search {
  126. background-color: $uni-fg-color;
  127. border-radius: 41rpx;
  128. padding: 10rpx 0rpx;
  129. margin: 20rpx 30rpx 0 30rpx;
  130. display: flex;
  131. align-items: center;
  132. /deep/ .uv-search__action {
  133. color: $uni-text-color;
  134. padding: 10rpx 18rpx;
  135. }
  136. }
  137. // 轮播图
  138. .swipe {
  139. overflow: hidden;
  140. border-radius: 14rpx;
  141. margin: 14rpx 30rpx 0 30rpx;
  142. }
  143. .recommend {
  144. &-member {
  145. margin: 27rpx 17rpx 0 17rpx;
  146. color: $uni-color-light;
  147. font-size: 28rpx;
  148. .icon {
  149. &-member {
  150. width: 42rpx;
  151. height: 38rpx;
  152. margin-right: 5rpx;
  153. }
  154. &-arrow {
  155. width: 26rpx;
  156. height: 26rpx;
  157. }
  158. }
  159. }
  160. &-product {
  161. margin: 28rpx 17rpx 0 17rpx;
  162. .title{
  163. justify-content: flex-start;
  164. color: #000000;
  165. font-size: 32rpx;
  166. font-weight: 700;
  167. padding-left: 18rpx;
  168. }
  169. .icon {
  170. &-hot {
  171. width: 22rpx;
  172. height: 30rpx;
  173. margin-left: 2rpx;
  174. }
  175. }
  176. }
  177. }
  178. .home {
  179. // 首页-分类菜单
  180. .home-menu {
  181. margin: 20rpx;
  182. border-radius: 20rpx;
  183. padding: 20rpx 0rpx;
  184. background-color: #fff;
  185. image {
  186. width: 80rpx;
  187. height: 80rpx;
  188. margin-top: 10rpx;
  189. }
  190. .menu-text {
  191. font-size: 28rpx;
  192. margin: 10rpx 0rpx;
  193. }
  194. }
  195. // 新人专享
  196. .new-people {
  197. background: white;
  198. padding: 20rpx;
  199. margin-bottom: 20rpx;
  200. .new-perple-top {
  201. display: flex;
  202. align-items: center;
  203. justify-content: space-between;
  204. margin-bottom: 20rpx;
  205. .new-perple-top-left {
  206. display: flex;
  207. align-items: center;
  208. color: $uni-color;
  209. .title {
  210. font-size: 40rpx;
  211. font-weight: bold;
  212. }
  213. .descript {
  214. margin-left: 10rpx;
  215. }
  216. }
  217. .new-perple-top-right {
  218. image {
  219. width: 80px;
  220. height: 40rpx;
  221. }
  222. }
  223. }
  224. .new-perple-main {
  225. display: flex;
  226. .red-packet {
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. width: 20%;
  231. image {
  232. width: 120rpx;
  233. height: 120rpx;
  234. }
  235. }
  236. .activity {
  237. display: flex;
  238. flex-direction: column;
  239. align-items: center;
  240. justify-content: center;
  241. width: 25%;
  242. background: white;
  243. border-radius: 10px;
  244. image {
  245. width: 140rpx;
  246. height: 140rpx;
  247. border-radius: 10rpx;
  248. }
  249. .title {
  250. background: $uni-color;
  251. color: white;
  252. border-radius: 20rpx;
  253. font-size: 24rpx;
  254. padding: 5rpx 10rpx;
  255. margin: 10rpx 0rpx;
  256. width: 90%;
  257. white-space: nowrap;
  258. overflow: hidden;
  259. text-overflow: ellipsis;
  260. box-sizing: border-box;
  261. text-align: center;
  262. }
  263. .product-price {
  264. color: $uni-color;
  265. font-size: 24rpx;
  266. }
  267. }
  268. }
  269. }
  270. // 视频
  271. .video-line {
  272. display: flex;
  273. align-items: center;
  274. padding: 20rpx;
  275. background: white;
  276. font-size: 34rpx;
  277. .line {
  278. height: 40rpx;
  279. width: 10rpx;
  280. background: $uni-color;
  281. border-radius: 5rpx;
  282. margin-right: 10rpx;
  283. }
  284. }
  285. .video-item {
  286. display: flex;
  287. justify-content: center;
  288. align-items: center;
  289. margin: 20rpx 0rpx;
  290. .product-video {
  291. border-radius: 20rpx;
  292. width: calc(710rpx);
  293. }
  294. }
  295. // 推荐
  296. .recommend {
  297. display: flex;
  298. align-items: center;
  299. justify-content: space-between;
  300. background: white;
  301. margin: 20rpx 0rpx;
  302. padding: 20rpx;
  303. .recommend-title {
  304. font-size: 36rpx;
  305. }
  306. .recommend-more {
  307. color: $uni-color;
  308. }
  309. }
  310. }
  311. </style>