index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  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. uni.switchTab({
  222. url: '../../pages/tabbar/index/index'
  223. })
  224. },
  225. getPercent(num, total) {
  226. num = parseFloat(num)
  227. total = parseFloat(total)
  228. if (isNaN(num) || isNaN(total)) {
  229. return '-'
  230. }
  231. return total <= 0 ? '0%' : Math.round((num / total) * 10000) / 100.0
  232. },
  233. // 获取会员等级
  234. getMemberByMemberLevel() {
  235. NET.request(`${API.getMemberByMemberLevel}/${this.memberData.memberLevelId}`, {}, 'GET').then((res) => {
  236. this.levelInfo = res.data
  237. uni.setStorageSync('storage_levelInfo', this.levelInfo)
  238. })
  239. .catch((res) => {
  240. })
  241. },
  242. // 签到
  243. goToSign() {
  244. uni.navigateTo({
  245. url: '../../pages_category_page1/integral/sign'
  246. })
  247. },
  248. // 跳转到兑换优惠详情
  249. goExchangeDetail(item) {
  250. if (this.memberData.credit < item.credit) {
  251. this.isConvertible = true
  252. } else {
  253. uni.navigateTo({
  254. url: `../integral/exchangeDetail?data=${JSON.stringify(item)}`
  255. })
  256. }
  257. },
  258. // 切换tab
  259. changeTab(type) {
  260. this.tabActive = type
  261. }
  262. }
  263. }
  264. </script>
  265. <style lang="scss" scoped>
  266. page {
  267. background: #F8F8F8;
  268. }
  269. .memberCenter {
  270. border-top: 2rpx solid #4b4b4b;
  271. background: url("../../static/images/origin/addBankBg.png") no-repeat left top;
  272. background-size: contain;
  273. min-height: 800rpx;
  274. padding: 0 20rpx;
  275. .memberBox {
  276. min-height: 230rpx;
  277. margin-top: 120rpx;
  278. width: 100%;
  279. border-radius: 25rpx;
  280. background-size: contain;
  281. position: relative;
  282. box-sizing: border-box;
  283. .posBox {
  284. position: absolute;
  285. width: 100%;
  286. left: 0;
  287. top: -80rpx;
  288. }
  289. .memberBoxTop {
  290. position: relative;
  291. .memberTopPos {
  292. //background: url("../../static/images/origin/integralBg.png") no-repeat left top;
  293. background-size: cover;
  294. height: 302rpx;
  295. border-radius: 24rpx;
  296. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  297. .memberTopBg {
  298. padding: 40rpx 30rpx;
  299. .integralInfo {
  300. padding: 0 50rpx;
  301. .itemBox {
  302. text-align: center;
  303. }
  304. }
  305. }
  306. }
  307. }
  308. .avatarBox {
  309. margin-left: 30rpx;
  310. image {
  311. width: 110rpx;
  312. height: 110rpx;
  313. border: 5rpx solid #FFFFFF;
  314. border-radius: 50%;
  315. }
  316. }
  317. .nameBox {
  318. margin-left: 20rpx;
  319. .name {
  320. color: #333333;
  321. margin-right: 30rpx;
  322. }
  323. .level {
  324. image {
  325. width: 172rpx;
  326. height: 50rpx;
  327. }
  328. }
  329. }
  330. }
  331. .signBox {
  332. background: #f9f6ed;
  333. height: 96rpx;
  334. border-radius: 24rpx;
  335. padding: 0 20rpx;
  336. .signLeft {
  337. .signIcon {
  338. background: url("../../static/images/origin/signIcon.png") no-repeat center left;
  339. background-size: contain;
  340. height: 120rpx;
  341. width: 96rpx;
  342. margin-right: 20rpx;
  343. }
  344. }
  345. .u-arrow {
  346. width: 24rpx;
  347. height: 24rpx;
  348. border-top: 3rpx solid #C5AA7B;
  349. border-right: 3rpx solid #C5AA7B;
  350. }
  351. }
  352. .signTabs {
  353. .tabItem {
  354. width: 50%;
  355. height: 96rpx;
  356. border-radius: 16rpx;
  357. text {
  358. color: #999999;
  359. font-size: 28rpx;
  360. }
  361. .icon {
  362. width: 40rpx;
  363. height: 40rpx;
  364. margin-right: 15rpx;
  365. }
  366. .detailIcon {
  367. background: url("../../static/images/origin/detailIcon.png") no-repeat center center;
  368. background-size: contain;
  369. }
  370. .exchangeIcon {
  371. background: url("../../static/images/origin/exchangeIcon.png") no-repeat center center;
  372. background-size: contain;
  373. }
  374. }
  375. .active {
  376. background: #333333;
  377. .detailIcon {
  378. background: url("../../static/images/origin/detailIcon1.png") no-repeat center center;
  379. background-size: contain;
  380. }
  381. .exchangeIcon {
  382. background: url("../../static/images/origin/exchangeIcon1.png") no-repeat center center;
  383. background-size: contain;
  384. }
  385. text {
  386. color: #FFEBC4;
  387. }
  388. }
  389. }
  390. .signInfo {
  391. background: #FFFFFF;
  392. border-radius: 16rpx;
  393. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  394. padding: 30rpx;
  395. .signInBox {
  396. .signItem {
  397. border-top: 2rpx solid #F3F4F5;
  398. padding: 30rpx 0;
  399. .leftBox {
  400. image {
  401. width: 90rpx;
  402. height: 90rpx;
  403. margin-right: 30rpx;
  404. }
  405. }
  406. }
  407. .signItem:first-child {
  408. border-top: none;
  409. }
  410. .rightBtn {
  411. width: 160rpx;
  412. height: 58rpx;
  413. line-height: 58rpx;
  414. background: #FFF9F6;
  415. border-radius: 10rpx;
  416. color: #C83732;
  417. text-align: center;
  418. font-weight: 300;
  419. font-size: 24rpx;
  420. }
  421. }
  422. }
  423. .signExchange {
  424. box-shadow: 0 0 20rpx rgba(0, 0, 0, 0.05);
  425. background: #FFFFFF;
  426. border-radius: 16rpx;
  427. padding: 40rpx 30rpx;
  428. .exchangeInfoBox {
  429. .exchangeItem {
  430. padding-bottom: 20rpx;
  431. margin-bottom: 20rpx;
  432. border-bottom: 2rpx #F3F4F5 solid;
  433. .exchangeLeft {
  434. .discountBox {
  435. color: #FDFED6;
  436. width: 300rpx;
  437. height: 146rpx;
  438. background: url('../../static/images/origin/exchangeItem.png') no-repeat left top;
  439. background-size: contain;
  440. padding: 30rpx 25rpx;
  441. }
  442. .exchangeInfo {
  443. .state {
  444. text-align: center;
  445. background: #333333;
  446. color: #FFEBC4;
  447. font-size: 24rpx;
  448. margin: 8rpx 0 4rpx 0;
  449. padding: 8rpx 14rpx;
  450. border-radius: 8rpx;
  451. }
  452. .finish {
  453. color: #CCCCCC;
  454. border: 2rpx solid #CCCCCC;
  455. background: none;
  456. }
  457. .integral {
  458. color: #D72E2E;
  459. }
  460. }
  461. }
  462. .exchangeRight {
  463. height: 146rpx;
  464. display: flex;
  465. flex-direction: column;
  466. justify-content: flex-end;
  467. .exchangeBtn {
  468. width: 120rpx;
  469. height: 48rpx;
  470. line-height: 48rpx;
  471. text-align: center;
  472. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  473. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  474. border-radius: 24rpx;
  475. }
  476. .available {
  477. background: linear-gradient(90deg, #C83732 0%, #E25C44 100%);
  478. box-shadow: 0 6rpx 12rpx rgba(233, 0, 0, 0.3);
  479. }
  480. }
  481. }
  482. .exchangeItem:last-child {
  483. border-bottom: none;
  484. }
  485. }
  486. }
  487. .cancelDel {
  488. position: absolute;
  489. bottom: -100rpx;
  490. left: 45%;
  491. image {
  492. width: 60upx;
  493. height: 60upx;
  494. }
  495. }
  496. .Put-box1 {
  497. .btn {
  498. margin-top: 50rpx;
  499. width: 100%;
  500. height: 84rpx;
  501. line-height: 84rpx;
  502. text-align: center;
  503. background: #333333;
  504. color: #FFEBC4;
  505. }
  506. }
  507. .emptyCart-box {
  508. margin: 60upx 0;
  509. .emptyCart-img {
  510. width: 113upx;
  511. height: 98upx;
  512. }
  513. }
  514. }
  515. </style>