index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <view v-if="ifShow" class="memberCenter">
  3. <global-loading />
  4. <view class="memberBox">
  5. <view class="posBox">
  6. <view class="memberBoxTop">
  7. <view class="memberTopPos" :style="{ backgroundImage: 'url(' + levelInfo.memberLevelBackground + ')' }">
  8. <view class="memberTopBg">
  9. <view class="flex-items">
  10. <view class="avatarBox">
  11. <image :src="memberData.headImage"></image>
  12. </view>
  13. <view class="nameBox">
  14. <view class="name fs36">{{ memberData.name }}</view>
  15. <view class="level">
  16. <image :src="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">{{ memberData.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. {{ memberData.totalCredit - memberData.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">{{ memberData.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="signLeft flex-items flex-sp-between">
  43. <view class="signIcon"></view>
  44. <view class="signText fs28 font-color-C5AA7B">积分签到</view>
  45. </view>
  46. <view class="u-arrow u-arrow-right"></view>
  47. </view>
  48. <view class="signTabs mar-top-30 flex-items">
  49. <view :class="{ active: tabActive === 1 }" class="tabItem flex-items flex-center" @click="changeTab(1)">
  50. <view class="icon detailIcon"></view>
  51. <text>积分明细</text>
  52. </view>
  53. <view :class="{ active: tabActive === 2 }" class="tabItem flex-items flex-center" @click="changeTab(2)">
  54. <view class="icon exchangeIcon"></view>
  55. <text>积分兑换</text>
  56. </view>
  57. </view>
  58. <view v-if="tabActive === 1" class="signInfo mar-top-20">
  59. <view class="signInBox">
  60. <view v-for="(item, index) in integralRecord" :key="index" class="signItem flex-items flex-sp-between">
  61. <view class="leftBox flex-items">
  62. <image src="../../static/images/origin/signIcon1.png"></image>
  63. <view class="leftInfo">
  64. <label class="fs28 font-color-333">{{ item.recordContent }}</label>
  65. <view class="fs24 font-color-999">{{ item.createTime }}</view>
  66. </view>
  67. </view>
  68. <view class="rightBtn">{{ item.recordType === 1 ? '+' : '-' }}{{ item.credit }}</view>
  69. </view>
  70. <view v-if="integralRecord.length === 0" class="emptyCart-box flex-items-plus flex-column">
  71. <image class="emptyCart-img" src="../../static/images/origin/searchEmpty.png"></image>
  72. <label class="font-color-999 fs26 mar-top-30">暂无记录~</label>
  73. </view>
  74. </view>
  75. </view>
  76. <view v-else class="signExchange mar-top-20">
  77. <view class="exchangeInfoBox">
  78. <view v-for="(item, index) in creditCouponList" :key="index" class="exchangeItem flex-items flex-sp-between">
  79. <view class="exchangeLeft flex-items">
  80. <view class="discountBox mar-right-20">
  81. <view v-if="item.couponType === 1" class="fs24">
  82. {{ item.fullMoney === 0 ? `无门槛减${item.reduceMoney}元`
  83. : `满${item.fullMoney}元减${item.reduceMoney}元` }}
  84. </view>
  85. <view v-else class="fs24">
  86. {{ item.fullMoney === 0 ? `无门槛打${item.reduceMoney}折`
  87. : `满${item.fullMoney}元打${item.reduceMoney}折` }}
  88. </view>
  89. <view class="fs30">{{ item.couponType === 1 ? '满减券' : '折扣券' }}</view>
  90. </view>
  91. <view class="exchangeInfo">
  92. <view v-if="item.couponType === 1" class="fs28 font-color-333">
  93. {{ item.fullMoney === 0
  94. ? `无门槛减${item.reduceMoney}元` : `满${item.fullMoney}元减${item.reduceMoney}元` }}
  95. </view>
  96. <view v-else class="fs28 font-color-333">
  97. {{ item.fullMoney === 0 ? `无门槛打${item.reduceMoney}折`
  98. : `满${item.fullMoney}元打${item.reduceMoney}折` }}
  99. </view>
  100. <view v-if="item.stockNumber > 0" class="fs24 state">还剩{{ item.stockNumber }}个</view>
  101. <view v-else class="fs24 state finish">已兑完</view>
  102. <view class="integral fs32">{{ item.credit }}积分</view>
  103. </view>
  104. </view>
  105. <view class="exchangeRight">
  106. <view
  107. v-if="item.state === 0 && item.stockNumber !== 0" class="exchangeBtn fs28 font-color-FFF"
  108. @click="goExchangeDetail(item)"
  109. >
  110. 兑换
  111. </view>
  112. <view v-if="item.stockNumber === 0" class="exchangeBtn available fs28 font-color-FFF">已兑完</view>
  113. <view
  114. v-if="item.state === 1" class="exchangeBtn available fs28 font-color-FFF"
  115. @click="goExchangeDetail(item)"
  116. >
  117. 已兑换
  118. </view>
  119. </view>
  120. </view>
  121. <view v-if="creditCouponList.length === 0" class="emptyCart-box flex-items-plus flex-column">
  122. <image class="emptyCart-img" src="../../static/images/origin/searchEmpty.png"></image>
  123. <label class="font-color-999 fs26 mar-top-30">暂无优惠券~</label>
  124. </view>
  125. </view>
  126. </view>
  127. <TuiModal :show="isConvertible" :custom="true" :fadein="true">
  128. <view class="Put-box1">
  129. <view class="text-align fs34 fs-bold">
  130. 温馨提示
  131. </view>
  132. <view class="mar-top-40 text-align">
  133. 您的积分不够哦,请获取更多的积分!
  134. </view>
  135. <view class="flex-display flex-sp-between">
  136. <view class="btn" @click="goToSign">
  137. 去签到
  138. </view>
  139. </view>
  140. <view v-if="isConvertible" class="cancelDel" @click="isConvertible = false">
  141. <image src="../../static/images/origin/cancelClose.png" mode=""></image>
  142. </view>
  143. </view>
  144. </TuiModal>
  145. </view>
  146. </template>
  147. <script>
  148. import tuiModal from '@/components/modal/modal'
  149. const NET = require('../../utils/request')
  150. const API = require('../../config/api')
  151. export default {
  152. name: 'Index',
  153. components: {
  154. TuiModal: tuiModal
  155. },
  156. data() {
  157. return {
  158. memberData: {},
  159. equityList: [],
  160. integralRecord: [],
  161. creditCouponList: [],
  162. levelInfo: {},
  163. tabActive: 1,
  164. isConvertible: false,
  165. integralInfo: {
  166. page: 1,
  167. pageSize: 10,
  168. session: ''
  169. },
  170. couponListInfo: {
  171. page: 1,
  172. pageSize: 10,
  173. session: ''
  174. },
  175. ifShow: false
  176. }
  177. },
  178. onLoad(option) {
  179. this.memberData = uni.getStorageSync('storage_userInfo')
  180. this.GetUser()
  181. if (option.tabActive) {
  182. this.tabActive = parseInt(option.tabActive)
  183. }
  184. this.getIntegralList()
  185. this.getCreditCouponList()
  186. this.getMemberByMemberLevel()
  187. },
  188. methods: {
  189. GetUser() {
  190. NET.request(API.GetUser, {}, 'GET').then((res) => {
  191. this.memberData = res.data
  192. uni.setStorageSync('storage_userInfo', this.memberData)
  193. })
  194. .catch((res) => {
  195. })
  196. },
  197. getIntegralList() {
  198. // 获取签到信息
  199. // uni.showLoading({
  200. // mask: true,
  201. // title: '加载中...',
  202. // })
  203. NET.request(API.selectCreditRecord, this.integralInfo, 'POST').then((res) => {
  204. // uni.hideLoading()
  205. this.ifShow = true
  206. this.integralRecord = res.data.list
  207. })
  208. .catch((res) => {
  209. })
  210. },
  211. // 获取可兑换优惠券列表
  212. getCreditCouponList() {
  213. NET.request(API.selectCreditCouponList, this.couponListInfo, 'POST').then((res) => {
  214. this.creditCouponList = res.data.list
  215. })
  216. .catch((res) => {
  217. })
  218. },
  219. // 去首页
  220. goToShopping() {
  221. this.$switchTab('/pages/tabbar/index/index')
  222. },
  223. getPercent(num, total) {
  224. num = parseFloat(num)
  225. total = parseFloat(total)
  226. if (isNaN(num) || isNaN(total)) {
  227. return '-'
  228. }
  229. return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0
  230. },
  231. // 获取会员等级
  232. getMemberByMemberLevel() {
  233. NET.request(`${API.getMemberByMemberLevel}/${this.memberData.memberLevelId}`, {}, 'GET').then((res) => {
  234. this.levelInfo = res.data
  235. uni.setStorageSync('storage_levelInfo', this.levelInfo)
  236. })
  237. .catch((res) => {
  238. })
  239. },
  240. // 签到
  241. goToSign() {
  242. uni.navigateTo({
  243. url: '../../pages_category_page1/integral/sign'
  244. })
  245. },
  246. // 跳转到兑换优惠详情
  247. goExchangeDetail(item) {
  248. if (this.memberData.credit < item.credit) {
  249. this.isConvertible = true
  250. } else {
  251. uni.navigateTo({
  252. url: `../integral/exchangeDetail?data=${JSON.stringify(item)}`
  253. })
  254. }
  255. },
  256. // 切换tab
  257. changeTab(type) {
  258. this.tabActive = type
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. page {
  265. background: #F8F8F8;
  266. }
  267. .memberCenter {
  268. border-top: 2rpx solid #4b4b4b;
  269. background: url("../../static/images/origin/addBankBg.png") no-repeat left top;
  270. background-size: contain;
  271. min-height: 800rpx;
  272. padding: 0 20rpx;
  273. .memberBox {
  274. min-height: 230rpx;
  275. margin-top: 120rpx;
  276. width: 100%;
  277. border-radius: 25rpx;
  278. background-size: contain;
  279. position: relative;
  280. box-sizing: border-box;
  281. .posBox {
  282. position: absolute;
  283. width: 100%;
  284. left: 0;
  285. top: -80rpx;
  286. }
  287. .memberBoxTop {
  288. position: relative;
  289. .memberTopPos {
  290. //background: url("../../static/images/origin/integralBg.png") no-repeat left top;
  291. background-size: cover;
  292. height: 302rpx;
  293. border-radius: 24rpx;
  294. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  295. .memberTopBg {
  296. padding: 40rpx 30rpx;
  297. .integralInfo {
  298. padding: 0 50rpx;
  299. .itemBox {
  300. text-align: center;
  301. }
  302. }
  303. }
  304. }
  305. }
  306. .avatarBox {
  307. margin-left: 30rpx;
  308. image {
  309. width: 110rpx;
  310. height: 110rpx;
  311. border: 5rpx solid #FFFFFF;
  312. border-radius: 50%;
  313. }
  314. }
  315. .nameBox {
  316. margin-left: 20rpx;
  317. .name {
  318. color: #333333;
  319. margin-right: 30rpx;
  320. }
  321. .level {
  322. image {
  323. width: 172rpx;
  324. height: 50rpx;
  325. }
  326. }
  327. }
  328. }
  329. .signBox {
  330. background: #f9f6ed;
  331. height: 96rpx;
  332. border-radius: 24rpx;
  333. padding: 0 20rpx;
  334. .signLeft {
  335. .signIcon {
  336. background: url("../../static/images/origin/signIcon.png") no-repeat center left;
  337. background-size: contain;
  338. height: 120rpx;
  339. width: 96rpx;
  340. margin-right: 20rpx;
  341. }
  342. }
  343. .u-arrow {
  344. width: 24rpx;
  345. height: 24rpx;
  346. border-top: 3rpx solid #C5AA7B;
  347. border-right: 3rpx solid #C5AA7B;
  348. }
  349. }
  350. .signTabs {
  351. .tabItem {
  352. width: 50%;
  353. height: 96rpx;
  354. border-radius: 16rpx;
  355. text {
  356. color: #999999;
  357. font-size: 28rpx;
  358. }
  359. .icon {
  360. width: 40rpx;
  361. height: 40rpx;
  362. margin-right: 15rpx;
  363. }
  364. .detailIcon {
  365. background: url("../../static/images/origin/detailIcon.png") no-repeat center center;
  366. background-size: contain;
  367. }
  368. .exchangeIcon {
  369. background: url("../../static/images/origin/exchangeIcon.png") no-repeat center center;
  370. background-size: contain;
  371. }
  372. }
  373. .active {
  374. background: #333333;
  375. .detailIcon {
  376. background: url("../../static/images/origin/detailIcon1.png") no-repeat center center;
  377. background-size: contain;
  378. }
  379. .exchangeIcon {
  380. background: url("../../static/images/origin/exchangeIcon1.png") no-repeat center center;
  381. background-size: contain;
  382. }
  383. text {
  384. color: #FFEBC4;
  385. }
  386. }
  387. }
  388. .signInfo {
  389. background: #FFFFFF;
  390. border-radius: 16rpx;
  391. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  392. padding: 30rpx;
  393. .signInBox {
  394. .signItem {
  395. border-top: 2rpx solid #F3F4F5;
  396. padding: 30rpx 0;
  397. .leftBox {
  398. image {
  399. width: 90rpx;
  400. height: 90rpx;
  401. margin-right: 30rpx;
  402. }
  403. }
  404. }
  405. .signItem:first-child {
  406. border-top: none;
  407. }
  408. .rightBtn {
  409. width: 160rpx;
  410. height: 58rpx;
  411. line-height: 58rpx;
  412. background: #FFF9F6;
  413. border-radius: 10rpx;
  414. color: #C83732;
  415. text-align: center;
  416. font-weight: 300;
  417. font-size: 24rpx;
  418. }
  419. }
  420. }
  421. .signExchange {
  422. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  423. background: #FFFFFF;
  424. border-radius: 16rpx;
  425. padding: 40rpx 30rpx;
  426. .exchangeInfoBox {
  427. .exchangeItem {
  428. padding-bottom: 20rpx;
  429. margin-bottom: 20rpx;
  430. border-bottom: 2rpx #F3F4F5 solid;
  431. .exchangeLeft {
  432. .discountBox {
  433. color: #FDFED6;
  434. width: 300rpx;
  435. height: 146rpx;
  436. background: url('../../static/images/origin/exchangeItem.png') no-repeat left top;
  437. background-size: contain;
  438. padding: 30rpx 25rpx;
  439. }
  440. .exchangeInfo {
  441. .state {
  442. text-align: center;
  443. background: #333333;
  444. color: #FFEBC4;
  445. font-size: 24rpx;
  446. margin: 8rpx 0 4rpx 0;
  447. padding: 8rpx 14rpx;
  448. border-radius: 8rpx;
  449. }
  450. .finish {
  451. color: #CCCCCC;
  452. border: 2rpx solid #CCCCCC;
  453. background: none;
  454. }
  455. .integral {
  456. color: #D72E2E;
  457. }
  458. }
  459. }
  460. .exchangeRight {
  461. height: 146rpx;
  462. display: flex;
  463. flex-direction: column;
  464. justify-content: flex-end;
  465. .exchangeBtn {
  466. width: 120rpx;
  467. height: 48rpx;
  468. line-height: 48rpx;
  469. text-align: center;
  470. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  471. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  472. border-radius: 24rpx;
  473. }
  474. .available {
  475. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  476. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  477. }
  478. }
  479. }
  480. .exchangeItem:last-child {
  481. border-bottom: none;
  482. }
  483. }
  484. }
  485. .cancelDel {
  486. position: absolute;
  487. bottom: -100rpx;
  488. left: 45%;
  489. image {
  490. width: 60upx;
  491. height: 60upx;
  492. }
  493. }
  494. .Put-box1 {
  495. .btn {
  496. margin-top: 50rpx;
  497. width: 100%;
  498. height: 84rpx;
  499. line-height: 84rpx;
  500. text-align: center;
  501. background: #333333;
  502. color: #FFEBC4;
  503. }
  504. }
  505. .emptyCart-box {
  506. margin: 60upx 0;
  507. .emptyCart-img {
  508. width: 113upx;
  509. height: 98upx;
  510. }
  511. }
  512. }
  513. </style>