cardBag.vue 8.3 KB

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