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

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