index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <view @touchstart="touchStart">
  3. <!-- #ifdef MP || APP-->
  4. <nav-bar ref="navBarRef" navTitle="积分商城" iconColor="#ffffff" :isBackgroundColor="false"
  5. backgroundColor="linear-gradient( 90deg, #E93323 0%, #FF7931 100%)"></nav-bar>
  6. <!-- #endif -->
  7. <view class="header">
  8. <view class="headerBg" :style="{'background-image': `url(${urlDomain}crmebimage/presets/points_bg.png)`}">
  9. <view class="pictrue"></view>
  10. <view class="num">当前积分{{integral}}</view>
  11. </view>
  12. <navigator hover-class='none' url='/pages/goods/order_list/index?secondType=1'
  13. class="record acea-row row-center-wrapper">兑换记录</navigator>
  14. </view>
  15. <view class="points-nav">
  16. <view class="nav acea-row row-middle row-around borRadius14">
  17. <navigator hover-class='none' url='/pages/merchant/user_integral/index' class="item">
  18. <view class="pictrue">
  19. <image :src="`${urlDomain}crmebimage/presets/points_my.png`"></image>
  20. </view>
  21. <view>我的积分</view>
  22. </navigator>
  23. <view class="line"></view>
  24. <navigator hover-class='none' url='/pages/merchant/user_sgin/index' class="item">
  25. <view class="pictrue">
  26. <image :src="`${urlDomain}crmebimage/presets/points_qiandao.png`"></image>
  27. </view>
  28. <view>每日签到</view>
  29. </navigator>
  30. <view class="line"></view>
  31. <navigator hover-class='none' open-type='switchTab' url='/pages/index/index' class="item">
  32. <view class="pictrue">
  33. <image :src="`${urlDomain}crmebimage/presets/points_goods.png`"></image>
  34. </view>
  35. <view>购买商品</view>
  36. </navigator>
  37. </view>
  38. </view>
  39. <view class="hot borRadius14" v-if="goodList.length">
  40. <view class="flex-between-center">
  41. <view class="title">热门推荐</view>
  42. <navigator v-show="goodList.length > 10 " hover-class='none' url='/pages/activity/goods_points/index'
  43. class="item">
  44. <view class="text-666 f-s-26 mr28 flex-center">
  45. 更多
  46. <text class="iconfont icon-xiangyou"></text>
  47. </view>
  48. </navigator>
  49. </view>
  50. <scroll-view scroll-x="true" class="scroll">
  51. <PointsGoods :integralGood="goodList" :pointsGoodsStyle="hotPointsStyle" :isShowSamll="true">
  52. </PointsGoods>
  53. </scroll-view>
  54. </view>
  55. <view class="body">
  56. <view class="body-title flex">
  57. <view class="scroll" @click="navTap(0,0)"><text class="item" :class="0 == current?'on':''">全部</text>
  58. </view>
  59. <scroll-view scroll-x="true" class="scroll" style="width: 81%;">
  60. <view class="item" :class="index+1 == current ?'on':''" v-for="(item, index) in navList"
  61. :key="index" @click="navTap(item.id,index+1)">{{item.value}}{{index+1?'积分':''}}</view>
  62. </scroll-view>
  63. </view>
  64. <view class="product-list" v-if="integralGood.length">
  65. <PointsGoods :integralGood="integralGood" :pointsGoodsStyle="pointsStyle"></PointsGoods>
  66. </view>
  67. <view v-else-if="!loading" class="empty-box">
  68. <emptyPage title="暂无商品,去看看别的吧~" mTop="0" :imgSrc="urlDomain+'crmebimage/presets/noShopper.png'">
  69. </emptyPage>
  70. </view>
  71. <view v-if="loading" class='loadingicon acea-row row-center-wrapper' :hidden='loading==false'>
  72. <text class='loading iconfont icon-jiazai'></text>
  73. </view>
  74. </view>
  75. </view>
  76. </template>
  77. <script>
  78. import {
  79. pointsStyle,
  80. hotPointsStyle
  81. } from "./default";
  82. let sysHeight = uni.getSystemInfoSync().statusBarHeight;
  83. import {
  84. silenceBindingSpread,
  85. getUserSpread
  86. } from '@/utils/index.js';
  87. import {
  88. toLogin
  89. } from '@/libs/login.js';
  90. import {
  91. mapGetters
  92. } from 'vuex';
  93. import {
  94. integralProductHotApi,
  95. integralCategoryApi,
  96. integralListApi
  97. } from '@/api/activity.js'
  98. import emptyPage from '@/components/emptyPage.vue';
  99. import NavBar from "@/components/navBar.vue"
  100. import useActivity from "@/mixins/useActivity";
  101. import PointsGoods from "../components/PointsGoods.vue"
  102. import {
  103. userIntegralApi
  104. } from "../../../api/activity";
  105. export default {
  106. mixins: [useActivity],
  107. components: {
  108. emptyPage,
  109. NavBar,
  110. PointsGoods
  111. },
  112. data() {
  113. return {
  114. urlDomain: this.$Cache.get("imgHost"),
  115. sysHeight,
  116. goodList: [],
  117. navList: [],
  118. current: 0,
  119. where: {
  120. intervalId: 0,
  121. page: 1,
  122. limit: 10,
  123. },
  124. integralGood: [],
  125. loadend: false,
  126. loading: false,
  127. loadTitle: '加载更多',
  128. pageScrollStatus: false,
  129. pointsStyle: pointsStyle, //列表商品样式
  130. hotPointsStyle: hotPointsStyle //推荐商品样式
  131. }
  132. },
  133. computed: mapGetters(['isLogin', 'uid', 'globalData']),
  134. onShow() {
  135. //分销绑定
  136. silenceBindingSpread(this.isLogin, this.globalData.spread);
  137. this.integralCategory();
  138. this.getIntegralList();
  139. if (this.isLogin) {
  140. this.getStoreIntegral();
  141. this.getUserIntegral(); //获取我的积分
  142. } else {
  143. toLogin();
  144. }
  145. },
  146. onLoad(options) {
  147. //分销码
  148. getUserSpread(options);
  149. if (!this.isLogin) {
  150. toLogin();
  151. }
  152. },
  153. watch: {
  154. isLogin: {
  155. handler: function(newV, oldV) {
  156. if (newV == true) {
  157. this.getStoreIntegral();
  158. this.getUserIntegral(); //获取我的积分
  159. }
  160. },
  161. deep: true
  162. },
  163. },
  164. onPageScroll(object) {
  165. if (object.scrollTop > 130) {
  166. this.pageScrollStatus = true;
  167. } else if (object.scrollTop < 130) {
  168. this.pageScrollStatus = false;
  169. }
  170. uni.$emit('scroll');
  171. },
  172. // #ifdef MP
  173. /**
  174. * 用户点击右上角分享
  175. */
  176. onShareAppMessage() {
  177. return {
  178. title: '积分兑好物',
  179. path: `/pages/activity/points_mall/index?sd=${this.uid}`
  180. };
  181. },
  182. // #endif
  183. methods: {
  184. //滚动
  185. touchStart() {
  186. this.$refs.navBarRef.currentPage = false;
  187. },
  188. //分享
  189. getShareInfo() {
  190. return {
  191. path: `/pages/activity/points_mall/index?sd=${this.uid}`
  192. };
  193. },
  194. //区间列表
  195. integralCategory() {
  196. integralCategoryApi().then(res => {
  197. let data = res.data;
  198. this.navList = data;
  199. }).catch(err => {
  200. return this.$util.Tips({
  201. title: err
  202. });
  203. })
  204. },
  205. navTap(id, index) {
  206. if (this.current === index) return;
  207. this.current = index;
  208. this.where.intervalId = id;
  209. this.where.page = 1;
  210. this.loadend = false;
  211. this.$set(this, 'integralGood', []);
  212. this.getIntegralList();
  213. },
  214. //积分商品列表
  215. getIntegralList() {
  216. if (this.loadend) return;
  217. if (this.loading) return;
  218. this.loading = true;
  219. integralListApi(this.where).then(res => {
  220. let list = res.data.list;
  221. let limit = this.where.limit;
  222. this.where.page++;
  223. this.loadend = limit > list.length;
  224. this.integralGood = this.integralGood.concat(list);
  225. this.loading = false;
  226. this.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  227. }).catch(err => {
  228. this.loading = false;
  229. this.loadTitle = '加载更多';
  230. return this.$util.Tips({
  231. title: err
  232. });
  233. })
  234. },
  235. goarrow() {
  236. uni.navigateBack()
  237. },
  238. //热门推荐
  239. getStoreIntegral() {
  240. integralProductHotApi({
  241. page: 1,
  242. limit: 20,
  243. }).then(res => {
  244. this.goodList = res.data.list;
  245. })
  246. },
  247. // 去商品详情
  248. goGoodsDetail(item) {
  249. uni.navigateTo({
  250. url: `/pages/activity/goods_details/index?id=${item.id}&type=4`
  251. });
  252. }
  253. },
  254. onReachBottom() {
  255. this.getIntegralList();
  256. }
  257. }
  258. </script>
  259. <style lang="scss" scoped>
  260. .points-nav {
  261. position: relative;
  262. width: 100%;
  263. height: 154rpx;
  264. margin-bottom: 46rpx;
  265. background: linear-gradient(0deg, #F5F5F5 0%, rgba(255, 255, 255, 0) 100%);
  266. }
  267. page {
  268. padding-bottom: 40rpx;
  269. }
  270. .accountTitle {
  271. background: linear-gradient(90deg, var(--view-theme) 0%, var(--view-gradient) 100%);
  272. position: fixed;
  273. left: 0;
  274. top: 0;
  275. width: 100%;
  276. z-index: 99;
  277. .sysTitle {
  278. width: 100%;
  279. position: relative;
  280. font-weight: 500;
  281. color: #fff;
  282. font-size: 30rpx;
  283. .iconfont {
  284. position: absolute;
  285. font-size: 36rpx;
  286. left: 11rpx;
  287. width: 60rpx;
  288. }
  289. }
  290. }
  291. .header {
  292. width: 100%;
  293. height: 400rpx;
  294. background: linear-gradient(90deg, #E93323 0%, #FF7931 100%);
  295. position: relative;
  296. .record {
  297. width: 124rpx;
  298. height: 48rpx;
  299. background-color: rgba(51, 51, 51, 0.2);
  300. border-radius: 50rpx 0 0 50rpx;
  301. font-weight: 400;
  302. color: #FFFFFF;
  303. font-size: 24rpx;
  304. position: absolute;
  305. right: 0;
  306. top: 36rpx;
  307. }
  308. &::after {
  309. position: absolute;
  310. content: '';
  311. width: 100%;
  312. height: 105rpx;
  313. background: linear-gradient(180deg, rgba(233, 51, 35, 0) 0%, var(--view-minorColorT) 50%, #F5F5F5 100%);
  314. }
  315. .headerBg {
  316. background-repeat: no-repeat;
  317. background-size: 100% 100%;
  318. width: 689rpx;
  319. height: 298rpx;
  320. margin: 0 auto;
  321. padding-top: 88rpx;
  322. .pictrue {
  323. width: 345rpx;
  324. height: 76rpx;
  325. image {
  326. width: 100%;
  327. height: 100%;
  328. }
  329. }
  330. .num {
  331. font-size: 26rpx;
  332. font-weight: 400;
  333. color: rgba(255, 255, 255, 0.6);
  334. margin: 4rpx 0 0 12rpx;
  335. }
  336. }
  337. }
  338. .hot {
  339. background-color: #fff;
  340. width: 710rpx;
  341. margin: 20rpx auto 0 auto;
  342. padding: 24rpx 0 24rpx 28rpx;
  343. .title {
  344. font-weight: 600;
  345. color: #333333;
  346. font-size: 32rpx;
  347. }
  348. .scroll {
  349. white-space: nowrap;
  350. margin-top: 26rpx;
  351. .scroll-item {
  352. display: inline-block;
  353. width: 224rpx;
  354. margin-right: 20rpx;
  355. vertical-align: top;
  356. .pictrue {
  357. width: 100%;
  358. height: 224rpx;
  359. image {
  360. width: 100%;
  361. height: 100%;
  362. border-radius: 20rpx;
  363. }
  364. }
  365. .name {
  366. font-weight: 400;
  367. color: #333333;
  368. font-size: 26rpx;
  369. margin-top: 16rpx;
  370. }
  371. .info {
  372. color: #999999;
  373. font-size: 22rpx;
  374. margin-top: 8rpx;
  375. }
  376. .price-box {
  377. font-size: 24rpx;
  378. font-weight: 500;
  379. margin-top: 10rpx;
  380. color: #666;
  381. image {
  382. width: 31rpx;
  383. height: 31rpx;
  384. margin-right: 8rpx;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .nav {
  391. width: 710rpx;
  392. height: 184rpx;
  393. background-color: #fff;
  394. margin: -150rpx auto 0 auto;
  395. position: relative;
  396. .item {
  397. font-size: 26rpx;
  398. font-weight: 400;
  399. color: #333333;
  400. text-align: center;
  401. width: 30%;
  402. .pictrue {
  403. width: 61rpx;
  404. height: 61rpx;
  405. margin: 0 auto 16rpx auto;
  406. image {
  407. width: 100%;
  408. height: 100%;
  409. }
  410. }
  411. }
  412. .line {
  413. width: 1px;
  414. height: 70rpx;
  415. background-color: #F3F3F3;
  416. }
  417. }
  418. .body {
  419. background-color: #fff;
  420. width: 710rpx;
  421. margin: 20rpx auto 0 auto;
  422. border-radius: 24rpx;
  423. padding-bottom: 20rpx;
  424. overflow: hidden;
  425. .body-title {
  426. padding-left: 32rpx;
  427. overflow: auto;
  428. .scroll {
  429. white-space: nowrap;
  430. .item {
  431. display: inline-block;
  432. margin-right: 60rpx;
  433. padding: 34rpx 0 38rpx 0;
  434. font-size: 28rpx;
  435. font-weight: 400;
  436. &.on {
  437. font-weight: 500;
  438. color: #E93323;
  439. position: relative;
  440. font-size: 30rpx;
  441. &::after {
  442. position: absolute;
  443. content: '';
  444. width: 36rpx;
  445. height: 30rpx;
  446. border: 2px solid #E93323;
  447. border-left: 2px solid transparent !important;
  448. border-top: 2px solid transparent !important;
  449. border-right: 2px solid transparent !important;
  450. border-radius: 50%;
  451. left: 50%;
  452. bottom: 22rpx;
  453. margin-left: -24rpx;
  454. }
  455. }
  456. }
  457. }
  458. }
  459. .product-list {
  460. display: flex;
  461. flex-wrap: wrap;
  462. justify-content: space-between;
  463. padding: 0 32rpx;
  464. margin-right: -24px;
  465. }
  466. }
  467. </style>