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

424 lines
8.3 KiB

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