userCenterIntegralExchange.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. <template>
  2. <div class="userCenterIntegralExchange">
  3. <div class="user">
  4. <div class="head">
  5. <div class="headPortrait">
  6. <img
  7. v-if="!booleanFlag.headPortraitDefaultImg"
  8. :src="'api/file/pub/' + user.umsUser.userPic"
  9. alt=""
  10. style="width: 100%; height: 100%"
  11. @error="booleanFlag.headPortraitDefaultImg = true"
  12. />
  13. <img
  14. v-if="booleanFlag.headPortraitDefaultImg"
  15. :src="require('@/assets/img/userCenter/user.png')"
  16. alt=""
  17. style="width: 100%; height: 100%"
  18. />
  19. </div>
  20. <!-- 白银用户 -->
  21. <div v-if="userLevel1 == 2" class="level">
  22. <div v-if="isZh">
  23. <img
  24. v-if="!booleanFlag.levelDefaultImg"
  25. :src="require('@/assets/img/userCenter/白银用户.png')"
  26. alt=""
  27. style="width: 100%; height: 100%"
  28. />
  29. </div>
  30. <div v-else>
  31. <img
  32. v-if="!booleanFlag.levelDefaultImg"
  33. :src="require('@/assets/img/userCenter/@1白银用户.png')"
  34. alt=""
  35. style="width: 100%; height: 100%"
  36. />
  37. </div>
  38. </div>
  39. <!-- 黄金用户 -->
  40. <div v-if="userLevel1 == 3" class="level">
  41. <div v-if="isZh">
  42. <img
  43. v-if="!booleanFlag.levelDefaultImg"
  44. :src="require('@/assets/img/userCenter/level02.png')"
  45. alt=""
  46. style="width: 100%; height: 100%"
  47. />
  48. </div>
  49. <div v-else>
  50. <img
  51. v-if="!booleanFlag.levelDefaultImg"
  52. :src="require('@/assets/img/userCenter/黄金用户e.png')"
  53. alt=""
  54. style="width: 100%; height: 100%"
  55. />
  56. </div>
  57. </div>
  58. <!-- 白金用户 -->
  59. <div v-if="userLevel1 == 4" class="level">
  60. <div v-if="isZh">
  61. <img
  62. v-if="!booleanFlag.levelDefaultImg"
  63. :src="require('@/assets/img/userCenter/白金用户.png')"
  64. alt=""
  65. style="width: 100%; height: 100%"
  66. />
  67. </div>
  68. <div v-else>
  69. <img
  70. v-if="!booleanFlag.levelDefaultImg"
  71. :src="require('@/assets/img/userCenter/白金用户e.png')"
  72. alt=""
  73. style="width: 100%; height: 100%"
  74. />
  75. </div>
  76. </div>
  77. <!-- 钻石用户 -->
  78. <div v-if="userLevel1 == 5" class="level">
  79. <div v-if="isZh">
  80. <img
  81. v-if="!booleanFlag.levelDefaultImg"
  82. :src="require('@/assets/img/userCenter/白金用户.png')"
  83. alt=""
  84. style="width: 100%; height: 100%"
  85. />
  86. </div>
  87. <div v-else>
  88. <img
  89. v-if="!booleanFlag.levelDefaultImg"
  90. :src="require('@/assets/img/userCenter/白金用户e.png')"
  91. alt=""
  92. style="width: 100%; height: 100%"
  93. />
  94. </div>
  95. </div>
  96. </div>
  97. <div class="content">
  98. <div class="con1">
  99. <div class="name">
  100. <span style="font-size: 20px; font-weight: 600">{{
  101. realName
  102. }}</span>
  103. </div>
  104. <div class="integral">
  105. <span style="font-size: 18px"
  106. >{{ $i18n.locale == 'zh' ? '可用积分' : 'Integral' }}:
  107. </span>
  108. <span style="font-size: 22px; font-weight: 600; color: #f37003">{{
  109. integral
  110. }}</span>
  111. </div>
  112. </div>
  113. <div class="con2">
  114. <div style="margin-top: 54px" @click="toRank">
  115. <span
  116. v-if="userLevel1 == 2"
  117. style="font-size: 22px; font-weight: 600; color: #eaedf0"
  118. >V1</span
  119. >
  120. <span
  121. v-if="userLevel1 == 3"
  122. style="font-size: 22px; font-weight: 600; color: #be8e60"
  123. >V2</span
  124. >
  125. <span
  126. v-if="userLevel1 == 4"
  127. style="font-size: 22px; font-weight: 600; color: #eaedf0"
  128. >V3</span
  129. >
  130. </div>
  131. <div style="margin-top: 50px">
  132. <span style="font-size: 18px"
  133. >{{ $i18n.locale == 'zh' ? '当前等级' : 'Current Level' }}
  134. </span>
  135. </div>
  136. </div>
  137. <div class="con3">
  138. <div style="margin-top: 54px">
  139. <span style="font-size: 22px; font-weight: 600; color: #a8a8a8">{{
  140. growth
  141. }}</span>
  142. </div>
  143. <div style="margin-top: 50px">
  144. <span style="font-size: 18px"
  145. >{{
  146. $i18n.locale == 'zh' ? '当前成长值' : 'Current Growth Value'
  147. }}
  148. </span>
  149. </div>
  150. </div>
  151. <div class="con4">
  152. <div style="margin-top: 54px">
  153. <span style="font-size: 22px; font-weight: 600; color: #a8a8a8">{{
  154. byScore
  155. }}</span>
  156. </div>
  157. <div style="margin-top: 50px">
  158. <span style="font-size: 18px"
  159. >{{
  160. $i18n.locale == 'zh' ? '距下一等级还差' : 'From The Next Level '
  161. }}
  162. </span>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. <div style="max-height: 1200px; overflow-y: auto; padding-bottom: 20px">
  168. <!-- 热门兑换 -->
  169. <div class="commodity">
  170. <div class="title">
  171. <span
  172. style="
  173. width: 7px;
  174. height: 19px;
  175. background-color: #265186;
  176. margin-left: 4px;
  177. "
  178. ></span>
  179. <span style="margin-left: 8px; color: #265186">{{
  180. $i18n.locale == 'zh' ? '热门兑换' : 'Hot For'
  181. }}</span>
  182. </div>
  183. <div class="list">
  184. <div
  185. class="item"
  186. v-for="(item, index) in popularExchange"
  187. :key="index"
  188. >
  189. <div class="pic">
  190. <img :src="'api/file/pub/' + item.picture" alt="" />
  191. </div>
  192. <div class="text">
  193. <div class="texttitle">
  194. <span>{{
  195. $i18n.locale == 'zh'
  196. ? item.commodityName
  197. : item.commodityNameEn
  198. }}</span>
  199. </div>
  200. <div class="integral">
  201. <span
  202. >{{ item.point
  203. }}{{ $i18n.locale == 'zh' ? '积分' : 'Integral' }}</span
  204. >
  205. <span v-if="item.price !== 0" style="color: red">
  206. {{ item.price }}{{ $i18n.locale == 'zh' ? '元' : 'RMB' }}
  207. </span>
  208. </div>
  209. <div>
  210. <span
  211. >{{ $i18n.locale == 'zh' ? '累计兑换量' : 'Exchanged' }}:{{
  212. item.exchangeQuantity ? item.exchangeQuantity : '0'
  213. }}</span
  214. >
  215. <span v-html="'&nbsp;&nbsp;&nbsp;&nbsp;'"></span>
  216. <span v-if="isZh">{{
  217. item.usageQuantity > 100
  218. ? '库存充足'
  219. : '仅剩' + item.usageQuantity
  220. }}</span>
  221. <span v-if="!isZh">{{
  222. item.usageQuantity > 100
  223. ? 'Adequate Inventory'
  224. : 'Remain' + item.usageQuantity
  225. }}</span>
  226. </div>
  227. <div v-if="item.commodityStatus==2">
  228. <el-button
  229. :disabled="whetherFreez"
  230. v-if="isChecked"
  231. type="info"
  232. style="color: #fff;"
  233. @click="exchange(item)"
  234. >{{ $i18n.locale == 'zh' ? '立即兑换' : 'Exchange' }}
  235. </el-button>
  236. </div>
  237. <div v-else>
  238. <el-button
  239. :disabled="whetherFreez"
  240. v-if="isChecked"
  241. type="primary"
  242. style="color: #409eff; background-color: #fff"
  243. @click="exchange(item)"
  244. >{{ $i18n.locale == 'zh' ? '立即兑换' : 'Exchange' }}
  245. </el-button>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <!-- 资源兑换 -->
  252. <div class="commodity">
  253. <div class="title">
  254. <span
  255. style="
  256. width: 7px;
  257. height: 19px;
  258. background-color: #265186;
  259. margin-left: 4px;
  260. "
  261. ></span>
  262. <span style="margin-left: 8px; color: #265186">{{
  263. $i18n.locale == 'zh' ? '资源兑换' : 'Resources For'
  264. }}</span>
  265. <div style="display: inline-block; font-weight: 500; color: #128ded">
  266. <!-- <span style="margin-left: 40px">{{
  267. $i18n.locale == "zh" ? "积分范围" : "Integral Range"
  268. }}</span>
  269. <span
  270. style="
  271. margin-left: 16px;
  272. border: 1px solid #128ded;
  273. padding: 0 16px;
  274. border-radius: 16px;
  275. "
  276. v-for="(item, index) in list"
  277. :class="{ active: active == index }"
  278. @click="change(index)"
  279. >{{ item }}</span
  280. > -->
  281. </div>
  282. </div>
  283. <div class="list">
  284. <div
  285. class="item"
  286. v-for="(item, index) in pointCommoditys"
  287. :key="index"
  288. >
  289. <div class="pic">
  290. <img :src="'api/file/pub/' + item.picture" alt="" />
  291. </div>
  292. <div class="text">
  293. <div class="texttitle">
  294. <span>{{
  295. $i18n.locale == 'zh'
  296. ? item.commodityName
  297. : item.commodityNameEn
  298. }}</span>
  299. </div>
  300. <div class="integral">
  301. <span
  302. >{{ item.point
  303. }}{{ $i18n.locale == 'zh' ? '积分' : 'Integral' }}</span
  304. >
  305. <span v-if="item.price !== 0" style="color: red">
  306. {{ item.price }}{{ $i18n.locale == 'zh' ? '元' : 'RMB' }}
  307. </span>
  308. </div>
  309. <div>
  310. <span
  311. >{{ $i18n.locale == 'zh' ? '累计兑换量' : 'Exchanged' }}:{{
  312. item.exchangeQuantity ? item.exchangeQuantity : '0'
  313. }}</span
  314. >
  315. <span v-html="'&nbsp;&nbsp;&nbsp;&nbsp;'"></span>
  316. <span v-if="isZh">{{
  317. item.usageQuantity > 100
  318. ? '库存充足'
  319. : '仅剩' + item.usageQuantity
  320. }}</span>
  321. <span v-if="!isZh">{{
  322. item.usageQuantity > 100
  323. ? 'Adequate Inventory'
  324. : 'Remain' + item.usageQuantity
  325. }}</span>
  326. </div>
  327. <div v-if="item.commodityStatus==2">
  328. <el-button
  329. :disabled="whetherFreez"
  330. v-if="isChecked"
  331. type="info"
  332. style="color: #fff;"
  333. @click="exchange(item)"
  334. >{{ $i18n.locale == 'zh' ? '立即兑换' : 'Exchange' }}
  335. </el-button>
  336. </div>
  337. <div v-else>
  338. <el-button
  339. :disabled="whetherFreez"
  340. v-if="isChecked"
  341. type="primary"
  342. style="color: #409eff; background-color: #fff"
  343. @click="exchange(item)"
  344. >{{ $i18n.locale == 'zh' ? '立即兑换' : 'Exchange' }}
  345. </el-button>
  346. </div>
  347. </div>
  348. </div>
  349. </div>
  350. </div>
  351. </div>
  352. </div>
  353. </template>
  354. <script>
  355. import {
  356. exchangeUserPoints,
  357. getUserPointPage,
  358. umsPointCommoditys,
  359. } from '@/api/user'
  360. export default {
  361. name: 'userCenterIntegralExchange',
  362. data() {
  363. return {
  364. booleanFlag: {
  365. headPortraitDefaultImg: false,
  366. levelDefaultImg: false,
  367. checkInsFlag: false,
  368. },
  369. orderForm: {
  370. address: '江苏省南京市雨花台区南京大数据产业基地5栋一层',
  371. num: '',
  372. },
  373. user: {},
  374. integral: '',
  375. growth: '',
  376. page: {
  377. pageNo: 1,
  378. pageSize: 10,
  379. total: 3,
  380. },
  381. popularExchange: [],
  382. pointCommoditys: [],
  383. active: 0,
  384. list: ['0-1000', '1000-2000', '2000以上'],
  385. userUsertypeDict: '',
  386. isChecked: null,
  387. isZh: true,
  388. hotFor: null,
  389. resourcesFor: null,
  390. whetherFreez: null,
  391. }
  392. },
  393. watch: {
  394. '$i18n.locale': {
  395. handler: function () {
  396. if (this.$i18n.locale == 'zh') {
  397. this.isZh = true
  398. } else {
  399. this.isZh = false
  400. }
  401. this.getUmsPointCommoditys()
  402. },
  403. deep: true,
  404. },
  405. },
  406. mounted() {
  407. let language = window.localStorage.getItem('locale')
  408. if (language == 'zh') {
  409. this.isZh = true
  410. } else {
  411. this.isZh = false
  412. }
  413. this.init()
  414. },
  415. methods: {
  416. toRank() {
  417. this.$router.push('userCenterRightsRank')
  418. },
  419. change(index) {
  420. this.active = index
  421. console.log(this.active)
  422. },
  423. init() {
  424. this.user = JSON.parse(window.localStorage.getItem('user'))
  425. if (this.user.umsUser.userPic == undefined) {
  426. this.user.umsUser.userPic = ''
  427. }
  428. this.userUsertypeDict = this.user.umsUser.userUsertypeDict
  429. // console.log(this.userUsertypeDict);
  430. if (this.userUsertypeDict !== 2) {
  431. this.isChecked = true
  432. } else {
  433. this.isChecked = false
  434. }
  435. this.getUmsPointCommoditys()
  436. this.getUmsUserPoints()
  437. },
  438. // 积分兑换商品列表
  439. getUmsPointCommoditys() {
  440. let params = {
  441. pageSize: 10,
  442. pageNo: 1,
  443. }
  444. umsPointCommoditys(params).then((res) => {
  445. if (res) {
  446. // 热门兑换
  447. this.popularExchange = res.data.popularExchange
  448. // 资源兑换
  449. this.pointCommoditys = res.data.pointCommoditys
  450. }
  451. })
  452. },
  453. // 个人积分
  454. getUmsUserPoints() {
  455. getUserPointPage().then((res) => {
  456. if (res) {
  457. this.integral = res.data.umsUserPoints[0].point
  458. if (JSON.stringify(res.data) !== '{}') {
  459. this.growth = res.data.umsUserPoints[0].growthValue
  460. } else {
  461. this.growth = 6000
  462. }
  463. if (res.data.umsUserPoints[0].pointStatus == 'n') {
  464. this.$message({
  465. message:
  466. this.$i18n.locale == 'zh'
  467. ? '该用户积分已冻结,请联系客服'
  468. : "The user's points have been frozen, please contact customer service",
  469. type: 'error',
  470. })
  471. this.whetherFreez = true
  472. } else {
  473. this.whetherFreez = false
  474. }
  475. }
  476. })
  477. },
  478. // 兑换商品详情页
  479. exchange(item) {
  480. console.log(item)
  481. window.localStorage.setItem('detailID', item.id)
  482. this.$router.push({
  483. path: `/userCenterIntegralExchangeDetail`,
  484. })
  485. },
  486. },
  487. computed: {
  488. // 判断有无真名
  489. realName() {
  490. if (this.user.umsUser.userNickName) {
  491. return this.user.umsUser.userNickName
  492. } else {
  493. return this.user.username
  494. }
  495. },
  496. // 判断差多少分
  497. byScore() {
  498. if (this.growth >= 0 && this.growth < 1000) {
  499. return parseInt(1000 - this.growth)
  500. } else if (this.growth >= 1000 && this.growth < 3000) {
  501. return parseInt(3000 - this.growth)
  502. } else if (this.growth >= 3000) {
  503. return 999999
  504. }
  505. },
  506. // 判断会员等级
  507. userLevel1() {
  508. if (this.growth >= 0 && this.growth < 1000) {
  509. return 2
  510. } else if (this.growth >= 1000 && this.growth < 3000) {
  511. return 3
  512. } else if (this.growth >= 3000) {
  513. return 4
  514. }
  515. },
  516. },
  517. }
  518. </script>
  519. <style scoped lang="less">
  520. .active {
  521. background-color: #ebf7ff;
  522. }
  523. .userCenterIntegralExchange {
  524. width: 100%;
  525. background: #fff;
  526. min-height: 700px;
  527. .user {
  528. display: flex;
  529. height: 200px;
  530. border: 1px solid #eeeff3;
  531. .head {
  532. width: 162px;
  533. padding: 0 0 0 22px;
  534. box-sizing: border-box;
  535. .headPortrait {
  536. width: 82px;
  537. height: 82px;
  538. border-radius: 50%;
  539. margin: 43px auto 0;
  540. }
  541. .level {
  542. width: 108px;
  543. height: 28px;
  544. border-radius: 14px;
  545. margin: 8px auto 0;
  546. }
  547. }
  548. .content {
  549. flex: 1;
  550. display: flex;
  551. .con1 {
  552. padding: 0 30px 0 15px;
  553. .name {
  554. margin-top: 56px;
  555. }
  556. .integral {
  557. margin-top: 50px;
  558. }
  559. }
  560. .con2,
  561. .con3,
  562. .con4 {
  563. padding: 0 30px;
  564. text-align: center;
  565. position: relative;
  566. &:before {
  567. content: '';
  568. width: 1px;
  569. height: 100px;
  570. background-color: #f0f0f2;
  571. display: inline-block;
  572. position: absolute;
  573. top: 60px;
  574. left: 0;
  575. }
  576. }
  577. }
  578. }
  579. .commodity {
  580. padding: 0 15px;
  581. .title {
  582. width: 100%;
  583. border-bottom: 1px solid #eeeff3;
  584. > span {
  585. display: inline-block;
  586. font-size: 18px;
  587. font-weight: 600;
  588. line-height: 66px;
  589. vertical-align: middle;
  590. }
  591. }
  592. .list {
  593. display: flex;
  594. flex-wrap: wrap;
  595. .item {
  596. width: 33%;
  597. height: 450px;
  598. padding: 0 45px;
  599. box-sizing: border-box;
  600. margin-top: 45px;
  601. .pic {
  602. width: 222px;
  603. height: 269px;
  604. img {
  605. width: 100%;
  606. height: 100%;
  607. }
  608. }
  609. .text {
  610. font-size: 16px;
  611. line-height: 32px;
  612. .texttitle {
  613. font-size: 18px;
  614. margin-top: 35px;
  615. /* 隐藏溢出元素 */
  616. overflow: hidden;
  617. /* 单行显示 */
  618. white-space: nowrap;
  619. /* 溢出显示省略号 */
  620. text-overflow: ellipsis;
  621. }
  622. .integral {
  623. font-size: 18px;
  624. color: #c96e6a;
  625. }
  626. }
  627. }
  628. }
  629. }
  630. /deep/ .el-dialog__wrapper {
  631. background-color: transparent !important;
  632. }
  633. }
  634. </style>