index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view :style="viewColor">
  3. <view class="points-swiper">
  4. <image class="bag" :src="`${domain}/static/images/jf-head.png`" mode=""></image>
  5. <view class="swiper">
  6. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
  7. :duration="duration" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  8. <block v-for="(item, index) in imgUrls" :key="index">
  9. <swiper-item>
  10. <image :src="item.pic" class="slide-image" @click="goPages(item.url)"></image>
  11. </swiper-item>
  12. </block>
  13. </swiper>
  14. </view>
  15. </view>
  16. <view v-if="modelLength <= 10" class="model">
  17. <view class="model-list" v-for="(model,index) in modelList" :key="index" @click="goPages(model.url)">
  18. <image class="img" :src="model.pic" mode=""></image>
  19. <view class="model-name line1">{{model.name}}</view>
  20. </view>
  21. </view>
  22. <view v-else class="model">
  23. <view class="model-swiper">
  24. <swiper indicator-dots="true" :autoplay="false" :circular="circular"
  25. indicator-color="rgba(0,0,0,0.3)">
  26. <block v-for="(item,index) in modelList" :key="index">
  27. <swiper-item class="model-swiper-item">
  28. <view v-for="(model,idx) in item" class="model-list" :key="idx" @click="goPages(model.url)">
  29. <image class="img" :src="model.pic" mode=""></image>
  30. <view class="model-name line1">{{model.name}}</view>
  31. </view>
  32. </swiper-item>
  33. </block>
  34. </swiper>
  35. </view>
  36. </view>
  37. <view class="body">
  38. <view class="body-title">
  39. <view class="navTabBox">
  40. <view class="longTab">
  41. <scroll-view scroll-x="true" style="white-space: nowrap; display: flex;" scroll-with-animation
  42. show-scrollbar="true">
  43. <view class="longItem" :data-index="index" :class="index===tabClick?'click':''"
  44. v-for="(item,index) in tabTitle" :key="index" :id="'id'+index" @click="longClick(index,item)">{{item.title}}
  45. </view>
  46. </scroll-view>
  47. </view>
  48. </view>
  49. </view>
  50. <view class="product-list" v-if="goodList.length">
  51. <view class="product-item" v-for="(item, index) in goodList" @click="goGoodsDetail(item)">
  52. <view class='pictrue'>
  53. <image :src='item.image'></image>
  54. <view v-if="item.stock == 0" class="sell_out">已兑完</view>
  55. </view>
  56. <view class="info">
  57. <view class="title line1">{{ item.store_name }}</view>
  58. <view class="acea-row price-count">
  59. <image class="image" :src="`${domain}/static/images/jf-point.png`" mode="widthFix"></image>
  60. <view class="price-box">
  61. <text>{{ item.ot_price }}</text>积分
  62. </view>
  63. <view class="sales">+{{parseFloat(Number(item.price).toFixed(2))}}元</view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. <view v-else-if="!loading" class="no-goods">
  69. <image :src="`${domain}/static/images/noCart.png`"></image>
  70. <view class="fontimg">暂无商品,去看点别的吧</view>
  71. </view>
  72. <view v-if="loading" class='loadingicon acea-row row-center-wrapper'>
  73. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  74. </view>
  75. </view>
  76. </view>
  77. </template>
  78. <script>
  79. // +----------------------------------------------------------------------
  80. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  81. // +----------------------------------------------------------------------
  82. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  83. // +----------------------------------------------------------------------
  84. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  85. // +----------------------------------------------------------------------
  86. // | Author: CRMEB Team <admin@crmeb.com>
  87. // +----------------------------------------------------------------------
  88. import { mapGetters } from 'vuex';
  89. import { getIntegralHome, getIntegralScope, getIntegralGoodsList } from '@/api/points_mall.js'
  90. import {HTTP_REQUEST_URL} from '@/config/app';
  91. export default {
  92. components: {},
  93. data() {
  94. return {
  95. tabClick: 0, //导航栏被点击
  96. autoplay: true,
  97. circular: true,
  98. interval: 3000,
  99. duration: 500,
  100. imgUrls: [],
  101. goodList: [],
  102. modelList: [],
  103. modelLength: 0,
  104. tabTitle: [],
  105. domain:HTTP_REQUEST_URL,
  106. loadend: false,
  107. loading: false,
  108. loadTitle: '加载更多',
  109. where: {
  110. page: 1,
  111. limit: 10,
  112. scope: ''
  113. }
  114. }
  115. },
  116. computed: mapGetters(['isLogin','viewColor']),
  117. onLoad() {
  118. this.getIntegralHome();
  119. this.getIntegralScope();
  120. this.getIntegralGoods();
  121. },
  122. watch: {
  123. },
  124. onShow(){
  125. },
  126. methods: {
  127. getIntegralHome() {
  128. getIntegralHome().then(res => {
  129. this.imgUrls = res.data.banner
  130. this.modelList = res.data.district
  131. this.modelLength = res.data.district.length
  132. if(this.modelLength > 10){
  133. this.modelList = this.chunk(this.modelList, 10)
  134. }
  135. })
  136. },
  137. chunk(arr, num){
  138. let j = 0, o = j;
  139. let newArray = [];
  140. while (j < arr.length) {
  141. j += num;
  142. newArray.push(arr.slice(o, j));
  143. o = j;
  144. }
  145. return newArray;
  146. },
  147. // 获取积分区间
  148. getIntegralScope() {
  149. getIntegralScope().then(res => {
  150. res.data.unshift({title: '全部',group_data_id: '',min: '',max: ''})
  151. this.tabTitle = res.data
  152. }).catch(err => {
  153. this.loading = false;
  154. uni.showToast({
  155. title: err,
  156. icon: 'none'
  157. })
  158. })
  159. },
  160. longClick(index, item) {
  161. this.tabClick = index;
  162. if(!item.min&&!item.max){
  163. this.where.scope='';
  164. }else{
  165. item.min = item.min || 0;
  166. item.max = item.max || 0;
  167. this.where.scope=item.min+','+item.max;
  168. }
  169. this.where.page = 1;
  170. this.loading = false;
  171. this.loadend = false;
  172. this.goodList = [];
  173. this.getIntegralGoods();
  174. },
  175. //积分商品列表
  176. getIntegralGoods(){
  177. let that = this;
  178. if (that.loadend) return;
  179. if (that.loading) return;
  180. that.loading = true;
  181. that.loadTitle = '';
  182. getIntegralGoodsList(that.where).then(res => {
  183. let list = res.data.list;
  184. let goodList = that.$util.SplitArray(list, that.goodList);
  185. let loadend = list.length < that.where.limit;
  186. that.loadend = loadend;
  187. that.loading = false;
  188. that.loadTitle = loadend ? '已全部加载' : '加载更多';
  189. that.$set(that, 'goodList', goodList);
  190. that.$set(that.where, 'page', that.where.page + 1);
  191. }).catch(err => {
  192. that.loading = false;
  193. uni.showToast({
  194. title: err,
  195. icon: 'none'
  196. })
  197. })
  198. },
  199. // 去商品详情
  200. goGoodsDetail(item) {
  201. uni.navigateTo({
  202. url: `/pages/points_mall/integral_goods_details?id=${item.product_id}`
  203. });
  204. },
  205. goPages(url) {
  206. if (url.indexOf("http") != -1) {
  207. // #ifdef H5
  208. location.href = url
  209. // #endif
  210. } else {
  211. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart', '/pages/user/index', '/pages/index/index','/pages/plant_grass/index']
  212. .indexOf(url) == -1) {
  213. uni.navigateTo({
  214. url: url +'?delta=0'
  215. })
  216. } else {
  217. uni.switchTab({
  218. url: url
  219. })
  220. }
  221. }
  222. },
  223. },
  224. onReachBottom() {
  225. this.getIntegralGoods()
  226. },
  227. }
  228. </script>
  229. <style lang="scss" scoped>
  230. .swiper,
  231. swiper,
  232. swiper-item,
  233. .slide-image {
  234. width: 100%;
  235. height: 280rpx;
  236. border-radius: 16rpx;
  237. }
  238. /deep/ .uni-swiper-wrapper {
  239. border-radius: 16rpx;
  240. }
  241. .swiper {
  242. padding: 30rpx;
  243. }
  244. .points-swiper {
  245. position: relative;
  246. width: 100%;
  247. background-color: #fff;
  248. .bag {
  249. position: absolute;
  250. width: 100%;
  251. height: 285rpx;
  252. }
  253. .points-swiper-sty {
  254. padding: 20rpx 26rpx;
  255. }
  256. }
  257. .model-swiper{
  258. position: relative;
  259. width: 100%;
  260. swiper{
  261. height: 380rpx;
  262. }
  263. /deep/.uni-swiper-dot{
  264. width: 10rpx;
  265. height: 10rpx;
  266. border-radius: 8rpx;
  267. }
  268. /deep/.uni-swiper-dot-active{
  269. width: 36rpx;
  270. background-color: var(--view-theme);
  271. }
  272. /deep/.uni-swiper-dots-horizontal{
  273. bottom: 0;
  274. }
  275. }
  276. .model {
  277. display: flex;
  278. flex-flow: row wrap;
  279. padding: 56rpx 20rpx;
  280. background-color: #fff;
  281. }
  282. .model-swiper-item{
  283. display: flex;
  284. align-items: center;
  285. flex-flow: row wrap;
  286. height: auto!important;
  287. font-size: 24rpx;
  288. color: #282828;
  289. font-weight: 500;
  290. }
  291. .model-list {
  292. display: flex;
  293. flex-direction: column;
  294. align-items: center;
  295. justify-content: center;
  296. flex: 0 0 20%;
  297. font-size: 24rpx;
  298. color: #282828;
  299. margin-top: 27rpx;
  300. font-weight: 500;
  301. .img {
  302. width: 90rpx;
  303. height: 90rpx;
  304. margin-bottom: 19rpx;
  305. border-radius: 100%;
  306. }
  307. .model-name{
  308. width: 100%;
  309. max-width: 140rpx;
  310. text-align: center;
  311. }
  312. }
  313. .body {
  314. background-color: #fff;
  315. padding: 30rpx;
  316. margin-top: 20rpx;
  317. .body-title {
  318. .navTabBox {
  319. color: #282828;
  320. position: relative;
  321. .longTab {
  322. display: flex;
  323. .longItem {
  324. height: 50upx;
  325. display: inline-block;
  326. line-height: 50upx;
  327. text-align: center;
  328. font-size: 28rpx;
  329. color: #282828;
  330. // max-width: 160rpx;
  331. white-space: nowrap;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. // overflow-x: scroll;
  335. overflow-y: hidden;
  336. /*解决ios上滑动不流畅*/
  337. -webkit-overflow-scrolling: touch;
  338. margin-right: 50rpx;
  339. &:last-child{
  340. margin-right: 0;
  341. }
  342. &.click {
  343. font-weight: bold;
  344. color: var(--view-theme);
  345. }
  346. }
  347. }
  348. }
  349. }
  350. .product-list {
  351. display: flex;
  352. flex-wrap: wrap;
  353. justify-content: space-between;
  354. margin-top: 30rpx;
  355. .product-item {
  356. position: relative;
  357. width: 330rpx;
  358. background: #fff;
  359. border-radius: 10rpx;
  360. margin-bottom: 20rpx;
  361. .pictrue{
  362. position: relative;
  363. width: 100%;
  364. height: 330rpx;
  365. .sell_out {
  366. display: flex;
  367. width: 150rpx;
  368. height: 150rpx;
  369. align-items: center;
  370. justify-content: center;
  371. border-radius: 100%;
  372. background: rgba(0,0,0,.6);
  373. color: #fff;
  374. font-size: 30rpx;
  375. position: absolute;
  376. top: 50%;
  377. left: 50%;
  378. margin: -75rpx 0 0 -75rpx;
  379. &::before{
  380. content: "";
  381. display: block;
  382. width: 140rpx;
  383. height: 140rpx;
  384. border-radius: 100%;
  385. border: 1px dashed #fff;
  386. position: absolute;
  387. top: 5rpx;
  388. left: 5rpx;
  389. }
  390. }
  391. }
  392. image {
  393. width: 100%;
  394. height: 330rpx;
  395. border-radius: 16rpx;
  396. }
  397. .info {
  398. padding: 14rpx 10rpx;
  399. .title {
  400. font-size: 30rpx;
  401. color: #282828;
  402. }
  403. .price-count{
  404. display: flex;
  405. margin-top: 8rpx;
  406. align-items: baseline;
  407. }
  408. .image{
  409. width: 26rpx;
  410. height: 26rpx;
  411. margin-right: 10rpx;
  412. border-radius: 0;
  413. }
  414. .price-box {
  415. font-size: 22rpx;
  416. color: var(--view-theme);
  417. text{
  418. font-size: 34rpx;
  419. }
  420. }
  421. .sales {
  422. font-size: 22rpx;
  423. color: var(--view-theme);
  424. }
  425. }
  426. }
  427. }
  428. }
  429. .no-goods {
  430. display: flex;
  431. flex-direction: column;
  432. padding: 60rpx 0;
  433. image{
  434. width: 414rpx;
  435. height: 305rpx;
  436. display: block;
  437. margin: 0 auto;
  438. }
  439. .fontimg{
  440. text-align: center;
  441. color: #bebebe;
  442. }
  443. }
  444. </style>