推拿小程序前端代码仓库
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
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. position: relative;
  113. }
  114. .bg {
  115. width: 100%;
  116. height: 589rpx;
  117. }
  118. .content {
  119. position: absolute;
  120. top: 0;
  121. left: 0;
  122. width: 100%;
  123. box-sizing: border-box;
  124. }
  125. // 搜索栏
  126. .search {
  127. background-color: $uni-fg-color;
  128. border-radius: 41rpx;
  129. padding: 10rpx 0rpx;
  130. margin: 20rpx 30rpx 0 30rpx;
  131. display: flex;
  132. align-items: center;
  133. /deep/ .uv-search__action {
  134. color: $uni-text-color;
  135. padding: 10rpx 18rpx;
  136. }
  137. }
  138. // 轮播图
  139. .swipe {
  140. overflow: hidden;
  141. border-radius: 14rpx;
  142. margin: 14rpx 30rpx 0 30rpx;
  143. }
  144. .recommend {
  145. &-member {
  146. margin: 27rpx 17rpx 0 17rpx;
  147. color: $uni-color-light;
  148. font-size: 28rpx;
  149. .icon {
  150. &-member {
  151. width: 42rpx;
  152. height: 38rpx;
  153. margin-right: 5rpx;
  154. }
  155. &-arrow {
  156. width: 26rpx;
  157. height: 26rpx;
  158. }
  159. }
  160. }
  161. &-product {
  162. margin: 28rpx 17rpx 0 17rpx;
  163. .title{
  164. justify-content: flex-start;
  165. color: #000000;
  166. font-size: 32rpx;
  167. font-weight: 700;
  168. padding-left: 18rpx;
  169. }
  170. .icon {
  171. &-hot {
  172. width: 22rpx;
  173. height: 30rpx;
  174. margin-left: 2rpx;
  175. }
  176. }
  177. }
  178. }
  179. .home {
  180. // 首页-分类菜单
  181. .home-menu {
  182. margin: 20rpx;
  183. border-radius: 20rpx;
  184. padding: 20rpx 0rpx;
  185. background-color: #fff;
  186. image {
  187. width: 80rpx;
  188. height: 80rpx;
  189. margin-top: 10rpx;
  190. }
  191. .menu-text {
  192. font-size: 28rpx;
  193. margin: 10rpx 0rpx;
  194. }
  195. }
  196. // 新人专享
  197. .new-people {
  198. background: white;
  199. padding: 20rpx;
  200. margin-bottom: 20rpx;
  201. .new-perple-top {
  202. display: flex;
  203. align-items: center;
  204. justify-content: space-between;
  205. margin-bottom: 20rpx;
  206. .new-perple-top-left {
  207. display: flex;
  208. align-items: center;
  209. color: $uni-color;
  210. .title {
  211. font-size: 40rpx;
  212. font-weight: bold;
  213. }
  214. .descript {
  215. margin-left: 10rpx;
  216. }
  217. }
  218. .new-perple-top-right {
  219. image {
  220. width: 80px;
  221. height: 40rpx;
  222. }
  223. }
  224. }
  225. .new-perple-main {
  226. display: flex;
  227. .red-packet {
  228. display: flex;
  229. align-items: center;
  230. justify-content: center;
  231. width: 20%;
  232. image {
  233. width: 120rpx;
  234. height: 120rpx;
  235. }
  236. }
  237. .activity {
  238. display: flex;
  239. flex-direction: column;
  240. align-items: center;
  241. justify-content: center;
  242. width: 25%;
  243. background: white;
  244. border-radius: 10px;
  245. image {
  246. width: 140rpx;
  247. height: 140rpx;
  248. border-radius: 10rpx;
  249. }
  250. .title {
  251. background: $uni-color;
  252. color: white;
  253. border-radius: 20rpx;
  254. font-size: 24rpx;
  255. padding: 5rpx 10rpx;
  256. margin: 10rpx 0rpx;
  257. width: 90%;
  258. white-space: nowrap;
  259. overflow: hidden;
  260. text-overflow: ellipsis;
  261. box-sizing: border-box;
  262. text-align: center;
  263. }
  264. .product-price {
  265. color: $uni-color;
  266. font-size: 24rpx;
  267. }
  268. }
  269. }
  270. }
  271. // 视频
  272. .video-line {
  273. display: flex;
  274. align-items: center;
  275. padding: 20rpx;
  276. background: white;
  277. font-size: 34rpx;
  278. .line {
  279. height: 40rpx;
  280. width: 10rpx;
  281. background: $uni-color;
  282. border-radius: 5rpx;
  283. margin-right: 10rpx;
  284. }
  285. }
  286. .video-item {
  287. display: flex;
  288. justify-content: center;
  289. align-items: center;
  290. margin: 20rpx 0rpx;
  291. .product-video {
  292. border-radius: 20rpx;
  293. width: calc(710rpx);
  294. }
  295. }
  296. // 推荐
  297. .recommend {
  298. display: flex;
  299. align-items: center;
  300. justify-content: space-between;
  301. background: white;
  302. margin: 20rpx 0rpx;
  303. padding: 20rpx;
  304. .recommend-title {
  305. font-size: 36rpx;
  306. }
  307. .recommend-more {
  308. color: $uni-color;
  309. }
  310. }
  311. }
  312. </style>