cardBag.vue 8.5 KB

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