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

384 lines
7.1 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
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
2 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
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. <!-- todo: jump to member page -->
  18. <view v-if="!role" class="card flex recommend-member" @click="$utils.navigateTo('/pages/index/category')" >
  19. <view class="flex" style="flex: 1;">
  20. <image class="icon-member" style="" src="@/static/image/home/icon-member.png"></image>
  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. <!-- todo: delete -->
  33. <productCard></productCard>
  34. </view>
  35. <!-- 优惠券弹窗 -->
  36. <couponPopup v-if="riceInfo.isGetCoupon"></couponPopup>
  37. <!-- tabbar -->
  38. <tabber select="home" />
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import tabber from '@/components/base/tabbar.vue'
  44. import couponPopup from "@/components/couponPopup/couponPopup.vue"
  45. import {
  46. mapState
  47. } from 'vuex'
  48. import productCard from '@/components/product/productCard.vue'
  49. import mixinsList from '@/mixins/list.js'
  50. export default {
  51. mixins: [mixinsList],
  52. components: {
  53. productCard,
  54. couponPopup,
  55. tabber,
  56. },
  57. data() {
  58. return {
  59. role: '',
  60. notice: '',
  61. bannerList: [
  62. {
  63. image: 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280',
  64. },
  65. {
  66. image: 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280',
  67. },
  68. {
  69. image: 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280',
  70. },
  71. ],
  72. baseList: [],
  73. keyword: '',
  74. mixinsListApi: 'getClassShopPageList',
  75. }
  76. },
  77. computed: {
  78. ...mapState(['riceInfo', 'category'])
  79. },
  80. onLoad(query) {
  81. if (query.shareId) {
  82. uni.setStorageSync('shareId', query.shareId)
  83. }
  84. },
  85. onShow() {
  86. // todo: delete test code
  87. return
  88. this.getBanner()
  89. this.getRiceIconList()
  90. if(uni.getStorageSync('token')){
  91. this.$store.commit('getRiceInfo')
  92. this.$store.commit('getUserInfo')
  93. }
  94. },
  95. onPullDownRefresh() {
  96. return
  97. this.getBanner()
  98. },
  99. methods: {
  100. // 搜素
  101. search() {
  102. uni.navigateTo({
  103. url: '/pages/index/category?search=' + this.keyword
  104. })
  105. this.keyword = ''
  106. },
  107. // 获取轮播图
  108. getBanner() {
  109. this.$api('getRiceBanner', res => {
  110. if (res.code == 200) {
  111. this.bannerList = res.result
  112. }
  113. })
  114. },
  115. // 获取首页菜单图标
  116. getRiceIconList() {
  117. this.$api('getRiceIconList', res => {
  118. if (res.code == 200) {
  119. this.baseList = res.result
  120. }
  121. })
  122. },
  123. },
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .page {
  128. width: 100vw;
  129. min-height: 100vh;
  130. background-color: $uni-bg-color;
  131. }
  132. .bg {
  133. width: 100%;
  134. height: 589rpx;
  135. }
  136. .content {
  137. position: absolute;
  138. top: 0;
  139. left: 0;
  140. width: 100%;
  141. box-sizing: border-box;
  142. }
  143. // 搜索栏
  144. .search {
  145. background-color: $uni-fg-color;
  146. border-radius: 41rpx;
  147. padding: 10rpx 0rpx;
  148. margin: 20rpx 30rpx 0 30rpx;
  149. display: flex;
  150. align-items: center;
  151. /deep/ .uv-search__action {
  152. color: $uni-text-color;
  153. padding: 10rpx 18rpx;
  154. }
  155. }
  156. // 轮播图
  157. .swipe {
  158. overflow: hidden;
  159. border-radius: 14rpx;
  160. margin: 14rpx 30rpx 0 30rpx;
  161. }
  162. .recommend {
  163. &-member {
  164. margin: 27rpx 17rpx 0 17rpx;
  165. color: $uni-color-light;
  166. font-size: 28rpx;
  167. .icon {
  168. &-member {
  169. width: 42rpx;
  170. height: 38rpx;
  171. margin-right: 5rpx;
  172. }
  173. &-arrow {
  174. width: 26rpx;
  175. height: 26rpx;
  176. }
  177. }
  178. }
  179. &-product {
  180. margin: 28rpx 17rpx 0 17rpx;
  181. .title{
  182. justify-content: flex-start;
  183. color: #000000;
  184. font-size: 32rpx;
  185. font-weight: 700;
  186. padding-left: 18rpx;
  187. }
  188. .icon {
  189. &-hot {
  190. width: 22rpx;
  191. height: 30rpx;
  192. margin-left: 2rpx;
  193. }
  194. }
  195. }
  196. }
  197. .home {
  198. // 首页-分类菜单
  199. .home-menu {
  200. margin: 20rpx;
  201. border-radius: 20rpx;
  202. padding: 20rpx 0rpx;
  203. background-color: #fff;
  204. image {
  205. width: 80rpx;
  206. height: 80rpx;
  207. margin-top: 10rpx;
  208. }
  209. .menu-text {
  210. font-size: 28rpx;
  211. margin: 10rpx 0rpx;
  212. }
  213. }
  214. // 新人专享
  215. .new-people {
  216. background: white;
  217. padding: 20rpx;
  218. margin-bottom: 20rpx;
  219. .new-perple-top {
  220. display: flex;
  221. align-items: center;
  222. justify-content: space-between;
  223. margin-bottom: 20rpx;
  224. .new-perple-top-left {
  225. display: flex;
  226. align-items: center;
  227. color: $uni-color;
  228. .title {
  229. font-size: 40rpx;
  230. font-weight: bold;
  231. }
  232. .descript {
  233. margin-left: 10rpx;
  234. }
  235. }
  236. .new-perple-top-right {
  237. image {
  238. width: 80px;
  239. height: 40rpx;
  240. }
  241. }
  242. }
  243. .new-perple-main {
  244. display: flex;
  245. .red-packet {
  246. display: flex;
  247. align-items: center;
  248. justify-content: center;
  249. width: 20%;
  250. image {
  251. width: 120rpx;
  252. height: 120rpx;
  253. }
  254. }
  255. .activity {
  256. display: flex;
  257. flex-direction: column;
  258. align-items: center;
  259. justify-content: center;
  260. width: 25%;
  261. background: white;
  262. border-radius: 10px;
  263. image {
  264. width: 140rpx;
  265. height: 140rpx;
  266. border-radius: 10rpx;
  267. }
  268. .title {
  269. background: $uni-color;
  270. color: white;
  271. border-radius: 20rpx;
  272. font-size: 24rpx;
  273. padding: 5rpx 10rpx;
  274. margin: 10rpx 0rpx;
  275. width: 90%;
  276. white-space: nowrap;
  277. overflow: hidden;
  278. text-overflow: ellipsis;
  279. box-sizing: border-box;
  280. text-align: center;
  281. }
  282. .product-price {
  283. color: $uni-color;
  284. font-size: 24rpx;
  285. }
  286. }
  287. }
  288. }
  289. // 视频
  290. .video-line {
  291. display: flex;
  292. align-items: center;
  293. padding: 20rpx;
  294. background: white;
  295. font-size: 34rpx;
  296. .line {
  297. height: 40rpx;
  298. width: 10rpx;
  299. background: $uni-color;
  300. border-radius: 5rpx;
  301. margin-right: 10rpx;
  302. }
  303. }
  304. .video-item {
  305. display: flex;
  306. justify-content: center;
  307. align-items: center;
  308. margin: 20rpx 0rpx;
  309. .product-video {
  310. border-radius: 20rpx;
  311. width: calc(710rpx);
  312. }
  313. }
  314. // 推荐
  315. .recommend {
  316. display: flex;
  317. align-items: center;
  318. justify-content: space-between;
  319. background: white;
  320. margin: 20rpx 0rpx;
  321. padding: 20rpx;
  322. .recommend-title {
  323. font-size: 36rpx;
  324. }
  325. .recommend-more {
  326. color: $uni-color;
  327. }
  328. }
  329. }
  330. </style>