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

450 lines
8.9 KiB

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