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

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