index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522
  1. <template>
  2. <view class="memberCenter">
  3. <JHeader title="我的积分" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  4. <view class="memberBox">
  5. <view class="posBox">
  6. <view class="memberBoxTop">
  7. <view class="memberTopPos" :style="{ backgroundImage: 'url(' + common.seamingImgUrl(levelInfo.memberLevelBackground) + ')' }">
  8. <view class="memberTopBg">
  9. <view class="flex-items">
  10. <view class="avatarBox">
  11. <image :src="common.seamingImgUrl($store.getters.userInfo.headImage)"></image>
  12. </view>
  13. <view class="nameBox">
  14. <view class="name fs36">{{ $store.getters.userInfo.name }}</view>
  15. <view class="level">
  16. <image :src="common.seamingImgUrl(levelInfo.memberLevelIcon)"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="integralInfo flex-items flex-sp-between mar-top-20">
  21. <view class="itemBox">
  22. <view class="integraNum fs32 font-color-333 fs-weight-400">{{ $store.getters.userInfo.totalCredit }}</view>
  23. <view class="fs24 font-color-333 fs-weight-400">累计积分</view>
  24. </view>
  25. <view class="itemBox">
  26. <view class="integraNum fs32 font-color-333 fs-weight-400">
  27. {{ $store.getters.userInfo.totalCredit - $store.getters.userInfo.credit }}
  28. </view>
  29. <view class="fs24 font-color-333 fs-weight-400">累计消费</view>
  30. </view>
  31. <view class="itemBox">
  32. <view class="integraNum fs32 font-color-333 fs-weight-400">{{ $store.getters.userInfo.credit }}</view>
  33. <view class="fs24 font-color-333 fs-weight-400">剩余积分</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="signBox flex-items flex-sp-between mar-top-30" @click="goToSign">
  42. <view class="flex-items flex-sp-between">
  43. <tui-icon name="member-fill" :size="96" unit="upx" color="#fdbc3d" margin="0 20upx 0 0"></tui-icon>
  44. <view class="signText fs28 font-color-C5AA7B">积分签到</view>
  45. </view>
  46. <tui-icon name="arrowright" :size="48" unit="upx" color="#C5AA7B"></tui-icon>
  47. </view>
  48. <view class="signTabs mar-top-30 flex-items">
  49. <view :class="{ active: currentTab === 0 }" class="tabItem flex-items flex-center" @click="handleChangeTab(0)">
  50. <tui-icon
  51. name="order" :size="40" unit="upx" :color="currentTab === 0 ? '#ffebc4' : '#999999'"
  52. margin="0 20upx 0 0"
  53. ></tui-icon>
  54. <text>积分明细</text>
  55. </view>
  56. <view :class="{ active: currentTab === 1 }" class="tabItem flex-items flex-center" @click="handleChangeTab(1)">
  57. <tui-icon
  58. name="exchange" :size="40" unit="upx" :color="currentTab === 1 ? '#ffebc4' : '#999999'"
  59. margin="0 20upx 0 0"
  60. ></tui-icon>
  61. <text>积分兑换</text>
  62. </view>
  63. </view>
  64. <view v-if="currentTab === 0" class="signInfo mar-top-20">
  65. <view v-if="integralInfo.data && integralInfo.data.length">
  66. <view v-for="(item, index) in integralInfo.data" :key="index" class="signItem flex-items flex-sp-between">
  67. <view class="leftBox flex-items">
  68. <tui-icon name="service-fill" :size="90" unit="upx" color="#fabe69" margin="0 30upx 0 0"></tui-icon>
  69. <view class="leftInfo">
  70. <label class="fs28 font-color-333">{{ item.recordContent }}</label>
  71. <view class="fs24 font-color-999">{{ item.createTime }}</view>
  72. </view>
  73. </view>
  74. <view class="rightBtn">{{ item.recordType === 1 ? '+' : '-' }}{{ item.credit }}</view>
  75. </view>
  76. </view>
  77. <view style="padding-bottom: 45upx;">
  78. <LoadingMore
  79. :status="!integralInfo.isEmpty && !integralInfo.data.length
  80. ? 'loading' : !integralInfo.isEmpty && integralInfo.data.length && (integralInfo.data.length >= integralInfo.listTotal) ? 'no-more' : ''"
  81. >
  82. </LoadingMore>
  83. <tui-no-data v-if="integralInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无记录~</tui-no-data>
  84. </view>
  85. </view>
  86. <view v-else class="signExchange mar-top-20">
  87. <view v-if="creditCouponInfo.data && creditCouponInfo.data.length">
  88. <view v-for="(item, index) in creditCouponInfo.data" :key="index" class="exchangeItem flex-items flex-sp-between">
  89. <view class="exchangeLeft flex-items">
  90. <view class="discountBox mar-right-20">
  91. <view v-if="item.couponType === 1" class="fs24">
  92. {{ item.fullMoney === 0 ? `无门槛减${item.reduceMoney}元`
  93. : `满${item.fullMoney}元减${item.reduceMoney}元` }}
  94. </view>
  95. <view v-else class="fs24">
  96. {{ item.fullMoney === 0 ? `无门槛打${item.reduceMoney}折`
  97. : `满${item.fullMoney}元打${item.reduceMoney}折` }}
  98. </view>
  99. <view class="fs30">{{ item.couponType === 1 ? '满减券' : '折扣券' }}</view>
  100. </view>
  101. <view class="exchangeInfo">
  102. <view v-if="item.couponType === 1" class="fs28 font-color-333">
  103. {{ item.fullMoney === 0
  104. ? `无门槛减${item.reduceMoney}元` : `满${item.fullMoney}元减${item.reduceMoney}元` }}
  105. </view>
  106. <view v-else class="fs28 font-color-333">
  107. {{ item.fullMoney === 0 ? `无门槛打${item.reduceMoney}折`
  108. : `满${item.fullMoney}元打${item.reduceMoney}折` }}
  109. </view>
  110. <view v-if="item.stockNumber > 0" class="fs24 state">还剩{{ item.stockNumber }}个</view>
  111. <view v-else class="fs24 state finish">已兑完</view>
  112. <view class="integral fs32">{{ item.credit }}积分</view>
  113. </view>
  114. </view>
  115. <view class="exchangeRight">
  116. <view
  117. v-if="item.state === 0 && item.stockNumber !== 0" class="exchangeBtn fs28 font-color-FFF"
  118. @click="goExchangeDetail(item)"
  119. >
  120. 兑换
  121. </view>
  122. <view v-if="item.stockNumber === 0" class="exchangeBtn available fs28 font-color-FFF">已兑完</view>
  123. <view
  124. v-if="item.state === 1" class="exchangeBtn available fs28 font-color-FFF"
  125. @click="goExchangeDetail(item)"
  126. >
  127. 已兑换
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. <view style="padding-bottom: 45upx;">
  133. <LoadingMore
  134. :status="!creditCouponInfo.isEmpty && !creditCouponInfo.data.length
  135. ? 'loading' : !creditCouponInfo.isEmpty && creditCouponInfo.data.length && (creditCouponInfo.data.length >= creditCouponInfo.listTotal) ? 'no-more' : ''"
  136. >
  137. </LoadingMore>
  138. <tui-no-data v-if="creditCouponInfo.isEmpty" :fixed="false" style="margin-top: 60upx;">暂无优惠券~</tui-no-data>
  139. </view>
  140. </view>
  141. <tui-modal :show="isConvertible" :custom="true" :fadein="true">
  142. <view class="Put-box1">
  143. <view class="text-align fs34 fs-bold">
  144. 温馨提示
  145. </view>
  146. <view class="mar-top-40 text-align">
  147. 您的积分不够哦,请获取更多的积分!
  148. </view>
  149. <view class="flex-display flex-sp-between">
  150. <view class="btn" @click="goToSign">
  151. 去签到
  152. </view>
  153. </view>
  154. <view v-if="isConvertible" class="cancelDel" @click="isConvertible = false">
  155. <tui-icon name="close" :size="60" unit="upx" color="#f0f0f0"></tui-icon>
  156. </view>
  157. </view>
  158. </tui-modal>
  159. </view>
  160. </template>
  161. <script>
  162. import { getMemberByMemberLevelIdApi, getSelectCreditCouponListApi, getSelectCreditRecordApi } from '../../../api/anotherTFInterface'
  163. export default {
  164. name: 'Integral',
  165. data() {
  166. return {
  167. currentTab: 0,
  168. integralInfo: {
  169. query: {
  170. page: 1,
  171. pageSize: 10,
  172. session: ''
  173. },
  174. data: [],
  175. listTotal: 0,
  176. isEmpty: false
  177. },
  178. creditCouponInfo: {
  179. query: {
  180. page: 1,
  181. pageSize: 10,
  182. session: ''
  183. },
  184. data: [],
  185. listTotal: 0, // 列表数据总数
  186. isEmpty: false // 列表是否为空
  187. },
  188. levelInfo: {},
  189. isConvertible: false
  190. }
  191. },
  192. onLoad(option) {
  193. if (option.tabActive) this.currentTab = parseInt(option.tabActive)
  194. this.$store.dispatch('auth/refrshUserInfoAction', () => {
  195. this.getIntegralList()
  196. this.getMemberByMemberLevel()
  197. })
  198. },
  199. methods: {
  200. handleChangeTab(index) {
  201. this.currentTab = index
  202. // 缓存每个tab里的数据
  203. if (this.currentTab === 0) {
  204. } else if (this.currentTab === 1) {
  205. if (!this.creditCouponInfo.isEmpty && !this.creditCouponInfo.data.length) this.getCreditCouponList()
  206. }
  207. // 每点一个tab就重新进行对它的请求
  208. // if (this.currentTab === 0) {
  209. // this.integralInfo.query.page = 1
  210. // this.integralInfo.data = []
  211. // this.integralInfo.listTotal = 0
  212. // this.integralInfo.isEmpty = false
  213. // this.getIntegralList()
  214. // } else if (this.currentTab === 1) {
  215. // this.creditCouponInfo.query.page = 1
  216. // this.creditCouponInfo.data = []
  217. // this.creditCouponInfo.listTotal = 0
  218. // this.creditCouponInfo.isEmpty = false
  219. // this.getCreditCouponList()
  220. // }
  221. },
  222. getIntegralList(isLoadmore) {
  223. uni.showLoading({
  224. title: '加载中'
  225. })
  226. getSelectCreditRecordApi({ ...this.integralInfo.query })
  227. .then((res) => {
  228. this.integralInfo.listTotal = res.data.total
  229. if (isLoadmore) {
  230. this.integralInfo.data.push(...res.data.list)
  231. } else {
  232. this.integralInfo.data = res.data.list
  233. }
  234. this.integralInfo.isEmpty = this.integralInfo.data.length === 0
  235. uni.hideLoading()
  236. })
  237. .catch(() => {
  238. uni.hideLoading()
  239. })
  240. },
  241. getCreditCouponList(isLoadmore) {
  242. uni.showLoading({
  243. title: '加载中'
  244. })
  245. getSelectCreditCouponListApi({ ...this.creditCouponInfo.query })
  246. .then((res) => {
  247. this.creditCouponInfo.listTotal = res.data.total
  248. if (isLoadmore) {
  249. this.creditCouponInfo.data.push(...res.data.list)
  250. } else {
  251. this.creditCouponInfo.data = res.data.list
  252. }
  253. this.creditCouponInfo.isEmpty = this.creditCouponInfo.data.length === 0
  254. uni.hideLoading()
  255. })
  256. .catch(() => {
  257. uni.hideLoading()
  258. })
  259. },
  260. // 获取会员等级
  261. getMemberByMemberLevel() {
  262. getMemberByMemberLevelIdApi({ memberLevelId: this.$store.getters.userInfo.memberLevelId })
  263. .then((res) => {
  264. this.levelInfo = res.data
  265. })
  266. },
  267. // 签到
  268. goToSign() {
  269. uni.navigateTo({
  270. url: '/another-tf/another-serve/integral/sign'
  271. })
  272. },
  273. // 跳转到兑换优惠详情
  274. goExchangeDetail(item) {
  275. if (this.$store.getters.userInfo.credit < item.credit) {
  276. this.isConvertible = true
  277. } else {
  278. uni.navigateTo({
  279. url: `/another-tf/another-serve/exchangeDetail/index?data=${JSON.stringify(item)}`
  280. })
  281. }
  282. }
  283. },
  284. onReachBottom() {
  285. if (this.currentTab === 0) {
  286. if (this.integralInfo.data.length < this.integralInfo.listTotal) {
  287. ++this.integralInfo.query.page
  288. this.getIntegralList(true)
  289. }
  290. } else if (this.currentTab === 1) {
  291. if (this.creditCouponInfo.data.length < this.creditCouponInfo.listTotal) {
  292. ++this.creditCouponInfo.query.page
  293. this.getCreditCouponList(true)
  294. }
  295. }
  296. }
  297. }
  298. </script>
  299. <style lang="less" scoped>
  300. .memberCenter {
  301. background-color: #F8F8F8;
  302. min-height: 100vh;
  303. padding: 0 20rpx;
  304. .memberBox {
  305. min-height: 230rpx;
  306. margin-top: 120rpx;
  307. width: 100%;
  308. border-radius: 25rpx;
  309. background-size: contain;
  310. position: relative;
  311. box-sizing: border-box;
  312. .posBox {
  313. position: absolute;
  314. width: 100%;
  315. left: 0;
  316. top: -80rpx;
  317. }
  318. .memberBoxTop {
  319. position: relative;
  320. .memberTopPos {
  321. background-size: cover;
  322. height: 302rpx;
  323. border-radius: 24rpx;
  324. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  325. .memberTopBg {
  326. padding: 40rpx 30rpx;
  327. .integralInfo {
  328. padding: 0 50rpx;
  329. .itemBox {
  330. text-align: center;
  331. }
  332. }
  333. }
  334. }
  335. }
  336. .avatarBox {
  337. margin-left: 30rpx;
  338. image {
  339. width: 110rpx;
  340. height: 110rpx;
  341. border: 5rpx solid #FFFFFF;
  342. border-radius: 50%;
  343. }
  344. }
  345. .nameBox {
  346. margin-left: 20rpx;
  347. .name {
  348. color: #333333;
  349. margin-right: 30rpx;
  350. }
  351. .level {
  352. image {
  353. width: 172rpx;
  354. height: 50rpx;
  355. }
  356. }
  357. }
  358. }
  359. .signBox {
  360. background: #f9f6ed;
  361. height: 96rpx;
  362. border-radius: 24rpx;
  363. padding: 0 20rpx;
  364. }
  365. .signTabs {
  366. .tabItem {
  367. width: 50%;
  368. height: 96rpx;
  369. border-radius: 16rpx;
  370. text {
  371. color: #999999;
  372. font-size: 28rpx;
  373. }
  374. }
  375. .active {
  376. background: #333333;
  377. text {
  378. color: #FFEBC4;
  379. }
  380. }
  381. }
  382. .signInfo {
  383. background: #FFFFFF;
  384. border-radius: 16rpx;
  385. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  386. padding: 30rpx;
  387. .signItem {
  388. border-top: 2rpx solid #F3F4F5;
  389. padding: 30rpx 0;
  390. }
  391. .signItem:first-child {
  392. border-top: none;
  393. }
  394. .rightBtn {
  395. width: 160rpx;
  396. height: 58rpx;
  397. line-height: 58rpx;
  398. background: #FFF9F6;
  399. border-radius: 10rpx;
  400. color: #C83732;
  401. text-align: center;
  402. font-weight: 300;
  403. font-size: 24rpx;
  404. }
  405. }
  406. .signExchange {
  407. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  408. background: #FFFFFF;
  409. border-radius: 16rpx;
  410. padding: 40rpx 30rpx;
  411. .exchangeItem {
  412. padding-bottom: 20rpx;
  413. margin-bottom: 20rpx;
  414. border-bottom: 2rpx #F3F4F5 solid;
  415. .exchangeLeft {
  416. .discountBox {
  417. color: #FDFED6;
  418. width: 300rpx;
  419. height: 146rpx;
  420. background-color: #f3c148;
  421. background-size: contain;
  422. padding: 30rpx 25rpx;
  423. }
  424. .exchangeInfo {
  425. .state {
  426. text-align: center;
  427. background: #333333;
  428. color: #FFEBC4;
  429. font-size: 24rpx;
  430. margin: 8rpx 0 4rpx 0;
  431. padding: 8rpx 14rpx;
  432. border-radius: 8rpx;
  433. }
  434. .finish {
  435. color: #CCCCCC;
  436. border: 2rpx solid #CCCCCC;
  437. background: none;
  438. }
  439. .integral {
  440. color: #D72E2E;
  441. }
  442. }
  443. }
  444. .exchangeRight {
  445. height: 146rpx;
  446. display: flex;
  447. flex-direction: column;
  448. justify-content: flex-end;
  449. .exchangeBtn {
  450. width: 120rpx;
  451. height: 48rpx;
  452. line-height: 48rpx;
  453. text-align: center;
  454. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  455. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  456. border-radius: 24rpx;
  457. }
  458. .available {
  459. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  460. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  461. }
  462. }
  463. }
  464. .exchangeItem:last-child {
  465. border-bottom: none;
  466. }
  467. }
  468. .cancelDel {
  469. position: absolute;
  470. bottom: -100rpx;
  471. left: 45%;
  472. }
  473. .Put-box1 {
  474. .btn {
  475. margin-top: 50rpx;
  476. width: 100%;
  477. height: 84rpx;
  478. line-height: 84rpx;
  479. text-align: center;
  480. background: #333333;
  481. color: #FFEBC4;
  482. }
  483. }
  484. }
  485. </style>