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

480 lines
8.8 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
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 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="true || riceInfo.isGetCoupon"></couponPopup>
  37. <!-- tabbar -->
  38. <tabber select="home" />
  39. </view>
  40. <template v-if="false">
  41. <!-- 商品列表 -->
  42. <view style="position: 20rpx;">
  43. <productList :list="list" />
  44. </view>
  45. <!-- 全局弹框 -->
  46. <PrivacyAgreementPoup />
  47. <!-- 联系客服 -->
  48. <customerServicePopup ref="customerServicePopup" />
  49. </template>
  50. </view>
  51. </template>
  52. <script>
  53. import PrivacyAgreementPoup from '@/components/config/PrivacyAgreementPoup.vue'
  54. import Position from '@/utils/position.js'
  55. import tabber from '@/components/base/tabbar.vue'
  56. import couponPopup from "@/components/couponPopup/couponPopup.vue"
  57. import {
  58. mapState
  59. } from 'vuex'
  60. import customerServicePopup from '@/components/config/customerServicePopup.vue'
  61. import productList from '@/components/user/productList.vue'
  62. import productCard from '@/components/product/productCard.vue'
  63. import mixinsList from '@/mixins/list.js'
  64. export default {
  65. mixins: [mixinsList],
  66. components: {
  67. tabber,
  68. productCard,
  69. PrivacyAgreementPoup,
  70. customerServicePopup,
  71. productList,
  72. couponPopup
  73. },
  74. data() {
  75. return {
  76. role: '',
  77. notice: '',
  78. bannerList: [
  79. {
  80. image: 'http://gips3.baidu.com/it/u=70459541,3412285454&fm=3028&app=3028&f=JPEG&fmt=auto?w=960&h=1280',
  81. }
  82. ],
  83. baseList: [],
  84. productList: [],
  85. keyword: '',
  86. commonProductList: [], //常规产品
  87. riceProductList: [], //体验产品
  88. newList: [], //新闻列表
  89. mixinsListApi: 'getClassShopPageList',
  90. adList: [],
  91. categoryList : [],
  92. }
  93. },
  94. computed: {
  95. ...mapState(['riceInfo', 'category'])
  96. },
  97. onLoad(query) {
  98. if (query.shareId) {
  99. uni.setStorageSync('shareId', query.shareId)
  100. }
  101. },
  102. onShow() {
  103. return
  104. this.getBanner()
  105. this.getRiceNoticeList()
  106. this.getRiceIconList()
  107. this.getCategoryList()
  108. this.getRiceAdList()
  109. if(uni.getStorageSync('token')){
  110. this.$store.commit('getRiceInfo')
  111. this.$store.commit('getUserInfo')
  112. }
  113. },
  114. onPullDownRefresh() {
  115. return
  116. this.getBanner()
  117. this.getRiceNoticeList()
  118. },
  119. methods: {
  120. // 搜素
  121. search() {
  122. uni.navigateTo({
  123. url: '/pages/index/category?search=' + this.keyword
  124. })
  125. this.keyword = ''
  126. },
  127. // 查询分类接口
  128. getCategoryList() {
  129. this.$api('getPidList', res => {
  130. if (res.code == 200) {
  131. this.categoryList = res.result
  132. }
  133. })
  134. },
  135. // 获取轮播图
  136. getBanner() {
  137. this.$api('getRiceBanner', res => {
  138. if (res.code == 200) {
  139. this.bannerList = res.result
  140. }
  141. })
  142. },
  143. // 获取公告
  144. getRiceNoticeList() {
  145. this.$api('getRiceNoticeList', res => {
  146. if (res.code == 200) {
  147. this.notice = res.result.title
  148. }
  149. })
  150. },
  151. // 获取首页新闻列表
  152. getRiceNewsList() {
  153. this.$api('getRiceNewsList', res => {
  154. if (res.code == 200) {
  155. this.newList = res.result.records
  156. }
  157. })
  158. },
  159. // 获取首页菜单图标
  160. getRiceIconList() {
  161. this.$api('getRiceIconList', res => {
  162. if (res.code == 200) {
  163. this.baseList = res.result
  164. }
  165. })
  166. },
  167. //获取首页广告
  168. getRiceAdList() {
  169. this.$api('getRiceProductList', {
  170. pageNo: 1,
  171. pageSize: 4,
  172. }, res => {
  173. if (res.code == 200) {
  174. this.adList = res.result.records
  175. }
  176. })
  177. },
  178. //跳转
  179. toUrl(url) {
  180. if (!url) {
  181. uni.showToast({
  182. title: '功能暂未开放',
  183. icon: 'none'
  184. })
  185. return
  186. }
  187. if (url == '::phone') {
  188. this.$refs.customerServicePopup.open()
  189. return
  190. }
  191. uni.navigateTo({
  192. url
  193. })
  194. },
  195. //视频播放错误
  196. videoErrorCallback: function(e) {
  197. uni.showModal({
  198. content: e.target.errMsg,
  199. showCancel: false
  200. })
  201. },
  202. //左右滚动视频
  203. scroll: function(e) {
  204. },
  205. },
  206. }
  207. </script>
  208. <style scoped lang="scss">
  209. .page {
  210. width: 100vw;
  211. min-height: 100vh;
  212. background-color: $uni-bg-color;
  213. }
  214. .bg {
  215. width: 100%;
  216. height: 589rpx;
  217. }
  218. .content {
  219. position: absolute;
  220. top: 0;
  221. left: 0;
  222. width: 100%;
  223. box-sizing: border-box;
  224. }
  225. // 搜索栏
  226. .search {
  227. background-color: $uni-fg-color;
  228. border-radius: 41rpx;
  229. padding: 10rpx 0rpx;
  230. margin: 20rpx 30rpx 0 30rpx;
  231. display: flex;
  232. align-items: center;
  233. /deep/ .uv-search__action {
  234. color: $uni-text-color;
  235. padding: 10rpx 18rpx;
  236. }
  237. }
  238. // 轮播图
  239. .swipe {
  240. overflow: hidden;
  241. border-radius: 14rpx;
  242. margin: 14rpx 30rpx 0 30rpx;
  243. }
  244. .recommend {
  245. &-member {
  246. margin: 27rpx 17rpx 0 17rpx;
  247. color: $uni-color-light;
  248. font-size: 28rpx;
  249. .icon {
  250. &-member {
  251. width: 42rpx;
  252. height: 38rpx;
  253. margin-right: 5rpx;
  254. }
  255. &-arrow {
  256. width: 26rpx;
  257. height: 26rpx;
  258. }
  259. }
  260. }
  261. &-product {
  262. margin: 28rpx 17rpx 0 17rpx;
  263. .title{
  264. justify-content: flex-start;
  265. color: #000000;
  266. font-size: 32rpx;
  267. font-weight: 700;
  268. padding-left: 18rpx;
  269. }
  270. .icon {
  271. &-hot {
  272. width: 22rpx;
  273. height: 30rpx;
  274. margin-left: 2rpx;
  275. }
  276. }
  277. }
  278. }
  279. .home {
  280. // 首页-分类菜单
  281. .home-menu {
  282. margin: 20rpx;
  283. border-radius: 20rpx;
  284. padding: 20rpx 0rpx;
  285. background-color: #fff;
  286. image {
  287. width: 80rpx;
  288. height: 80rpx;
  289. margin-top: 10rpx;
  290. }
  291. .menu-text {
  292. font-size: 28rpx;
  293. margin: 10rpx 0rpx;
  294. }
  295. }
  296. // 新人专享
  297. .new-people {
  298. background: white;
  299. padding: 20rpx;
  300. margin-bottom: 20rpx;
  301. .new-perple-top {
  302. display: flex;
  303. align-items: center;
  304. justify-content: space-between;
  305. margin-bottom: 20rpx;
  306. .new-perple-top-left {
  307. display: flex;
  308. align-items: center;
  309. color: $uni-color;
  310. .title {
  311. font-size: 40rpx;
  312. font-weight: bold;
  313. }
  314. .descript {
  315. margin-left: 10rpx;
  316. }
  317. }
  318. .new-perple-top-right {
  319. image {
  320. width: 80px;
  321. height: 40rpx;
  322. }
  323. }
  324. }
  325. .new-perple-main {
  326. display: flex;
  327. .red-packet {
  328. display: flex;
  329. align-items: center;
  330. justify-content: center;
  331. width: 20%;
  332. image {
  333. width: 120rpx;
  334. height: 120rpx;
  335. }
  336. }
  337. .activity {
  338. display: flex;
  339. flex-direction: column;
  340. align-items: center;
  341. justify-content: center;
  342. width: 25%;
  343. background: white;
  344. border-radius: 10px;
  345. image {
  346. width: 140rpx;
  347. height: 140rpx;
  348. border-radius: 10rpx;
  349. }
  350. .title {
  351. background: $uni-color;
  352. color: white;
  353. border-radius: 20rpx;
  354. font-size: 24rpx;
  355. padding: 5rpx 10rpx;
  356. margin: 10rpx 0rpx;
  357. width: 90%;
  358. white-space: nowrap;
  359. overflow: hidden;
  360. text-overflow: ellipsis;
  361. box-sizing: border-box;
  362. text-align: center;
  363. }
  364. .product-price {
  365. color: $uni-color;
  366. font-size: 24rpx;
  367. }
  368. }
  369. }
  370. }
  371. // 视频
  372. .video-line {
  373. display: flex;
  374. align-items: center;
  375. padding: 20rpx;
  376. background: white;
  377. font-size: 34rpx;
  378. .line {
  379. height: 40rpx;
  380. width: 10rpx;
  381. background: $uni-color;
  382. border-radius: 5rpx;
  383. margin-right: 10rpx;
  384. }
  385. }
  386. .video-item {
  387. display: flex;
  388. justify-content: center;
  389. align-items: center;
  390. margin: 20rpx 0rpx;
  391. .product-video {
  392. border-radius: 20rpx;
  393. width: calc(710rpx);
  394. }
  395. }
  396. // 推荐
  397. .recommend {
  398. display: flex;
  399. align-items: center;
  400. justify-content: space-between;
  401. background: white;
  402. margin: 20rpx 0rpx;
  403. padding: 20rpx;
  404. .recommend-title {
  405. font-size: 36rpx;
  406. }
  407. .recommend-more {
  408. color: $uni-color;
  409. }
  410. }
  411. }
  412. </style>