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

481 lines
8.9 KiB

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
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
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 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. <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. // todo: delete test code
  104. return
  105. this.getBanner()
  106. this.getRiceNoticeList()
  107. this.getRiceIconList()
  108. this.getCategoryList()
  109. this.getRiceAdList()
  110. if(uni.getStorageSync('token')){
  111. this.$store.commit('getRiceInfo')
  112. this.$store.commit('getUserInfo')
  113. }
  114. },
  115. onPullDownRefresh() {
  116. return
  117. this.getBanner()
  118. this.getRiceNoticeList()
  119. },
  120. methods: {
  121. // 搜素
  122. search() {
  123. uni.navigateTo({
  124. url: '/pages/index/category?search=' + this.keyword
  125. })
  126. this.keyword = ''
  127. },
  128. // 查询分类接口
  129. getCategoryList() {
  130. this.$api('getPidList', res => {
  131. if (res.code == 200) {
  132. this.categoryList = res.result
  133. }
  134. })
  135. },
  136. // 获取轮播图
  137. getBanner() {
  138. this.$api('getRiceBanner', res => {
  139. if (res.code == 200) {
  140. this.bannerList = res.result
  141. }
  142. })
  143. },
  144. // 获取公告
  145. getRiceNoticeList() {
  146. this.$api('getRiceNoticeList', res => {
  147. if (res.code == 200) {
  148. this.notice = res.result.title
  149. }
  150. })
  151. },
  152. // 获取首页新闻列表
  153. getRiceNewsList() {
  154. this.$api('getRiceNewsList', res => {
  155. if (res.code == 200) {
  156. this.newList = res.result.records
  157. }
  158. })
  159. },
  160. // 获取首页菜单图标
  161. getRiceIconList() {
  162. this.$api('getRiceIconList', res => {
  163. if (res.code == 200) {
  164. this.baseList = res.result
  165. }
  166. })
  167. },
  168. //获取首页广告
  169. getRiceAdList() {
  170. this.$api('getRiceProductList', {
  171. pageNo: 1,
  172. pageSize: 4,
  173. }, res => {
  174. if (res.code == 200) {
  175. this.adList = res.result.records
  176. }
  177. })
  178. },
  179. //跳转
  180. toUrl(url) {
  181. if (!url) {
  182. uni.showToast({
  183. title: '功能暂未开放',
  184. icon: 'none'
  185. })
  186. return
  187. }
  188. if (url == '::phone') {
  189. this.$refs.customerServicePopup.open()
  190. return
  191. }
  192. uni.navigateTo({
  193. url
  194. })
  195. },
  196. //视频播放错误
  197. videoErrorCallback: function(e) {
  198. uni.showModal({
  199. content: e.target.errMsg,
  200. showCancel: false
  201. })
  202. },
  203. //左右滚动视频
  204. scroll: function(e) {
  205. },
  206. },
  207. }
  208. </script>
  209. <style scoped lang="scss">
  210. .page {
  211. width: 100vw;
  212. min-height: 100vh;
  213. background-color: $uni-bg-color;
  214. }
  215. .bg {
  216. width: 100%;
  217. height: 589rpx;
  218. }
  219. .content {
  220. position: absolute;
  221. top: 0;
  222. left: 0;
  223. width: 100%;
  224. box-sizing: border-box;
  225. }
  226. // 搜索栏
  227. .search {
  228. background-color: $uni-fg-color;
  229. border-radius: 41rpx;
  230. padding: 10rpx 0rpx;
  231. margin: 20rpx 30rpx 0 30rpx;
  232. display: flex;
  233. align-items: center;
  234. /deep/ .uv-search__action {
  235. color: $uni-text-color;
  236. padding: 10rpx 18rpx;
  237. }
  238. }
  239. // 轮播图
  240. .swipe {
  241. overflow: hidden;
  242. border-radius: 14rpx;
  243. margin: 14rpx 30rpx 0 30rpx;
  244. }
  245. .recommend {
  246. &-member {
  247. margin: 27rpx 17rpx 0 17rpx;
  248. color: $uni-color-light;
  249. font-size: 28rpx;
  250. .icon {
  251. &-member {
  252. width: 42rpx;
  253. height: 38rpx;
  254. margin-right: 5rpx;
  255. }
  256. &-arrow {
  257. width: 26rpx;
  258. height: 26rpx;
  259. }
  260. }
  261. }
  262. &-product {
  263. margin: 28rpx 17rpx 0 17rpx;
  264. .title{
  265. justify-content: flex-start;
  266. color: #000000;
  267. font-size: 32rpx;
  268. font-weight: 700;
  269. padding-left: 18rpx;
  270. }
  271. .icon {
  272. &-hot {
  273. width: 22rpx;
  274. height: 30rpx;
  275. margin-left: 2rpx;
  276. }
  277. }
  278. }
  279. }
  280. .home {
  281. // 首页-分类菜单
  282. .home-menu {
  283. margin: 20rpx;
  284. border-radius: 20rpx;
  285. padding: 20rpx 0rpx;
  286. background-color: #fff;
  287. image {
  288. width: 80rpx;
  289. height: 80rpx;
  290. margin-top: 10rpx;
  291. }
  292. .menu-text {
  293. font-size: 28rpx;
  294. margin: 10rpx 0rpx;
  295. }
  296. }
  297. // 新人专享
  298. .new-people {
  299. background: white;
  300. padding: 20rpx;
  301. margin-bottom: 20rpx;
  302. .new-perple-top {
  303. display: flex;
  304. align-items: center;
  305. justify-content: space-between;
  306. margin-bottom: 20rpx;
  307. .new-perple-top-left {
  308. display: flex;
  309. align-items: center;
  310. color: $uni-color;
  311. .title {
  312. font-size: 40rpx;
  313. font-weight: bold;
  314. }
  315. .descript {
  316. margin-left: 10rpx;
  317. }
  318. }
  319. .new-perple-top-right {
  320. image {
  321. width: 80px;
  322. height: 40rpx;
  323. }
  324. }
  325. }
  326. .new-perple-main {
  327. display: flex;
  328. .red-packet {
  329. display: flex;
  330. align-items: center;
  331. justify-content: center;
  332. width: 20%;
  333. image {
  334. width: 120rpx;
  335. height: 120rpx;
  336. }
  337. }
  338. .activity {
  339. display: flex;
  340. flex-direction: column;
  341. align-items: center;
  342. justify-content: center;
  343. width: 25%;
  344. background: white;
  345. border-radius: 10px;
  346. image {
  347. width: 140rpx;
  348. height: 140rpx;
  349. border-radius: 10rpx;
  350. }
  351. .title {
  352. background: $uni-color;
  353. color: white;
  354. border-radius: 20rpx;
  355. font-size: 24rpx;
  356. padding: 5rpx 10rpx;
  357. margin: 10rpx 0rpx;
  358. width: 90%;
  359. white-space: nowrap;
  360. overflow: hidden;
  361. text-overflow: ellipsis;
  362. box-sizing: border-box;
  363. text-align: center;
  364. }
  365. .product-price {
  366. color: $uni-color;
  367. font-size: 24rpx;
  368. }
  369. }
  370. }
  371. }
  372. // 视频
  373. .video-line {
  374. display: flex;
  375. align-items: center;
  376. padding: 20rpx;
  377. background: white;
  378. font-size: 34rpx;
  379. .line {
  380. height: 40rpx;
  381. width: 10rpx;
  382. background: $uni-color;
  383. border-radius: 5rpx;
  384. margin-right: 10rpx;
  385. }
  386. }
  387. .video-item {
  388. display: flex;
  389. justify-content: center;
  390. align-items: center;
  391. margin: 20rpx 0rpx;
  392. .product-video {
  393. border-radius: 20rpx;
  394. width: calc(710rpx);
  395. }
  396. }
  397. // 推荐
  398. .recommend {
  399. display: flex;
  400. align-items: center;
  401. justify-content: space-between;
  402. background: white;
  403. margin: 20rpx 0rpx;
  404. padding: 20rpx;
  405. .recommend-title {
  406. font-size: 36rpx;
  407. }
  408. .recommend-more {
  409. color: $uni-color;
  410. }
  411. }
  412. }
  413. </style>