cardBag.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view>
  3. <ujp-navbar title="我的卡包" bkUrl="/pages/user/index" ></ujp-navbar>
  4. <view class="tabs">
  5. <u-tabs bar-width="80" active-color="#333333" inactive-color="#999999" :list="list" :is-scroll="false"
  6. :current="current" @change="change"></u-tabs>
  7. </view>
  8. <view class="main" :class="{
  9. opacityClass:show
  10. }">
  11. <view class="discount-card" v-if="current==1" v-for="(item,i) in businessVipList"
  12. @click="gotoUrl('pages/user/company-vip?id='+item.vipUser.platform)" :key="i">
  13. <view class="name">
  14. <img src="../../assets/img/corporateMember.png" alt="">
  15. </view>
  16. <view class="progress">
  17. <view class="time">
  18. {{item.vipUser.platformN}}
  19. </view>
  20. <view class="electric-quantity" v-if="item.vipUser.entAccountEnabled&&item.enterpriseAccount" >
  21. 企业账户余额:{{item.enterpriseAccount.totalAmount?item.enterpriseAccount.totalAmount.toFixed(2):'0.00'}}元
  22. </view>
  23. </view>
  24. </view>
  25. <template v-for="(item,i) in showList">
  26. <view class="discount-card" :class="{
  27. 'card-type-4':item.cardType==4
  28. }"
  29. @click="gotocardDetails(item)" :key="i+'b'">
  30. <view class="name" v-if="item.classify==1">
  31. <img src="@/assets/img/monthCard.png" alt="">
  32. </view>
  33. <view class="name" v-else-if="item.cardType==4">
  34. {{projectName}}{{item.cardName}}
  35. </view>
  36. <view class="name icon_crown" v-else-if="item.classify==2">
  37. <!-- <img v-if="item.serviceFeeDiscountRate==60" src="@/assets/img/0.6off.png" alt="">
  38. <img v-else-if="item.serviceFeeDiscountRate==50" src="@/assets/img/halfoff.png" alt="">
  39. <img v-else src="@/assets/img/monthCard.png" alt=""> -->
  40. <img src="@/assets/img/icon_crown.png" alt="">
  41. {{item.cardName}}
  42. </view>
  43. <view class="progress">
  44. <template v-if="current==0">
  45. <view class="time">
  46. <span v-if="item.classify==1">服务费全免</span>
  47. <span
  48. v-if="item.classify==2">可用{{item.chargeDegreeLimit}}度</span>(有效期{{setValidity(item.periodOfValidity)}})
  49. </view>
  50. <view class="electric-quantity">
  51. 发卡日期:{{item.createTime.substring(0,10)}}
  52. </view>
  53. </template>
  54. <template v-else>
  55. <view class="time">
  56. {{thisendTime(item.endTime)}}到期 剩余{{setValidity(thisdaysDistance(item.endTime))}}
  57. </view>
  58. <view class="electric-quantity" v-if="item.classify==2&&(item.chargeDegreeLimit!=0)">
  59. 已用{{item.chargedDegree?item.chargedDegree.toFixed(0):0.00}}度 /
  60. 共{{item.chargeDegreeLimit}}度
  61. </view>
  62. <view class="electric-quantity" v-if="item.classify==2&&(item.chargeDegreeLimit==0)">
  63. 已用{{item.saveInformation.num}}次 /
  64. 共省{{item.saveInformation.saveMoney}}元
  65. </view>
  66. </template>
  67. </view>
  68. <ujp-line-progress v-if="current!=0" active-color="#2979ff"
  69. :percent="thispercent(item)"></ujp-line-progress>
  70. <img class="corner-mark" v-if="current==0" src="@/assets/img/nonactivated.png" alt="">
  71. </view>
  72. </template>
  73. <view class="carNone" v-if="current==1&&businessVipList.length==0&&showList.length==0">
  74. <img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
  75. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无数据</p>
  76. </view>
  77. <view class="carNone" v-if="current==2&&expireUserCardList.length==0">
  78. <img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
  79. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无数据</p>
  80. </view>
  81. <view class="carNone" v-if="current==0&&notActiveCardList.length==0">
  82. <img src="@/assets/static/img/暂无数据-缺省页.png" alt="">
  83. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无数据</p>
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import * as API from '@/apis/index.js'
  90. import {
  91. newDate,
  92. daysDistance
  93. } from '@/utils'
  94. export default {
  95. data() {
  96. return {
  97. show:false,
  98. list: [ {
  99. name: '未激活',
  100. count: 0
  101. },
  102. {
  103. name: '生效中'
  104. }, {
  105. name: '已过期'
  106. }],
  107. expireUserCardList: [],
  108. cardList: [],
  109. pageIndex: 1,
  110. recordsTotal: 0,
  111. current: 0,
  112. businessVipList: [],
  113. userCard: null,
  114. notActiveCardList: [],
  115. }
  116. },
  117. computed: {
  118. showList() {
  119. if (this.current == 1) {
  120. return this.cardList
  121. }
  122. if (this.current == 2) {
  123. return this.expireUserCardList
  124. }
  125. if (this.current == 0) {
  126. return this.notActiveCardList
  127. }
  128. return []
  129. },
  130. userCardBool() {
  131. if (this.userCard) {
  132. var date = new Date().getTime()
  133. //var reg=new RegExp('-','gi')
  134. var str = this.userCard.endTime;
  135. //console.log(str.replace(reg,'/'))
  136. var date2 = newDate(str).getTime();
  137. if (date < date2) {
  138. return true;
  139. }
  140. }
  141. return false
  142. }
  143. },
  144. onReady() {
  145. },onShow() {
  146. this.getChargeList();
  147. },
  148. onLoad() {
  149. },
  150. methods: {
  151. gotocardDetails(item) {
  152. this.carhelp.set("cardDetails-info", item)
  153. uni.navigateTo({
  154. url: '/pages/cardBag/cardDetail?id=' + item.id
  155. })
  156. },
  157. thisdaysDistance(endTime) {
  158. var date = new Date()
  159. var date2 = newDate(endTime);
  160. return daysDistance(date, date2)
  161. },
  162. getChargeList() {
  163. uni.showLoading({
  164. title: "加载中",
  165. mask: true,
  166. })
  167. API.personCardList({
  168. }).then((res) => {
  169. uni.hideLoading();
  170. this.cardList = res.data.cardList;
  171. this.notActiveCardList = res.data.notActiveCardList;
  172. this.list[0].count = this.notActiveCardList.length;
  173. if(this.notActiveCardList.length==0){
  174. this.current=1
  175. }
  176. this.expireUserCardList = res.data.expireUserCardList;
  177. //this.recordsTotal = res.data.recordsTotal;
  178. this.businessVipList = res.data.memberCardList;
  179. }).catch(error => {
  180. uni.showToast({
  181. title: error,
  182. icon: "none"
  183. })
  184. })
  185. },
  186. thisendTime(endTime) {
  187. if (endTime) {
  188. var reg = new RegExp('-', 'gi')
  189. var str = endTime.substring(0, 10).replace(reg, '.')
  190. return str
  191. }
  192. return ''
  193. },
  194. thispercent(userCard) {
  195. if(userCard.classify==1||(userCard.classify==2&&userCard.chargeDegreeLimit==0)){
  196. var k1=daysDistance(userCard.startTime, userCard.endTime)
  197. var k2=this.thisdaysDistance(userCard.endTime)
  198. var p=(k1-k2)/k2* 100
  199. if (p > 100) {
  200. p = 100
  201. }
  202. return p.toFixed(0)
  203. }else if(userCard.classify==2){
  204. var p = 0
  205. if (userCard && userCard.chargeDegreeLimit) {
  206. p = userCard.chargedDegree / userCard.chargeDegreeLimit * 100
  207. }
  208. if (p > 100) {
  209. p = 100
  210. }
  211. return p.toFixed(0)
  212. }else{
  213. return 0
  214. }
  215. },
  216. change(index) {
  217. this.current = index;
  218. }
  219. }
  220. }
  221. </script>
  222. <style scoped lang="scss">
  223. .opacityClass {
  224. opacity: 0.2;
  225. }
  226. .carNone {
  227. display: flex;
  228. flex-direction: column;
  229. justify-content: center;
  230. align-items: center;
  231. img {
  232. width: 100%;
  233. height: 100%;
  234. }
  235. p {
  236. margin-top: -60px;
  237. }
  238. }
  239. ::v-deep .u-tab-bar {
  240. background-color: #00B962 !important;
  241. }
  242. .main {
  243. padding: 0 32rpx;
  244. .monthly-payment,
  245. .mcorporate-member {
  246. height: 160rpx;
  247. border-radius: 8px;
  248. background-color: rgba(55, 59, 80, 1);
  249. padding-left: 24rpx;
  250. margin-top: 24rpx;
  251. display: flex;
  252. align-items: center;
  253. .icon {
  254. width: 80rpx;
  255. height: 80rpx;
  256. img {
  257. width: 100%;
  258. }
  259. }
  260. .infos {
  261. margin-left: 16rpx;
  262. .name {
  263. color: rgba(225, 192, 130, 1);
  264. font-size: 32rpx;
  265. }
  266. .date {
  267. color: rgba(211, 185, 134, 1);
  268. font-size: 24rpx;
  269. }
  270. .company {
  271. color: rgba(204, 204, 204, 1);
  272. font-size: 24rpx;
  273. }
  274. .balance {
  275. color: rgba(219, 219, 219, 1);
  276. font-size: 24rpx;
  277. }
  278. }
  279. }
  280. .discount-card {
  281. position: relative;
  282. .corner-mark {
  283. width: 112rpx;
  284. height: 112rpx;
  285. position: absolute;
  286. top: 0;
  287. right: 0;
  288. }
  289. border-radius: 8px;
  290. background-color: rgba(55, 59, 80, 1);
  291. padding: 24rpx;
  292. margin-top: 24rpx;
  293. .name {
  294. color: rgba(255, 255, 255, 1);
  295. font-size: 32rpx;
  296. img {
  297. //width: 262rpx;
  298. height: 56rpx;
  299. }
  300. }
  301. .icon_crown{
  302. display: flex;
  303. align-items: center;
  304. color: rgba(225, 192, 130, 1);
  305. }
  306. .progress {
  307. display: flex;
  308. justify-content: space-between;
  309. color: rgba(219, 219, 219, 1);
  310. font-size: 24rpx;
  311. margin-bottom: 16rpx;
  312. }
  313. ::v-deep .u-active {
  314. background: linear-gradient(84.49deg, rgba(59, 182, 254, 1) 4.25%, rgba(0, 185, 98, 1) 95.02%);
  315. }
  316. }
  317. .discount-card.card-type-4{
  318. background-color: rgba(218, 36, 30, 1);
  319. .name{
  320. color: rgba(255, 214, 149, 1);
  321. font-size: 36rpx;
  322. font-family: "SimSun", Arial, sans-serif;
  323. font-weight: 400;
  324. text-shadow: 2px 1px 0px #800400 ;
  325. }
  326. .u-progress{
  327. background-color: rgb(207, 76, 66) !important;
  328. color: #fff;
  329. }
  330. }
  331. }
  332. </style>