珠宝小程序前端代码
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.

454 lines
8.9 KiB

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