cardBag.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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">
  9. <view class="mcorporate-member" v-if="current==0" v-for="(item,i) in businessVipList"
  10. @click="gotoUrl('pages/user/company-vip?id='+item.platform)" :key="i" >
  11. <view class="icon">
  12. <img src="../../assets/img/corporateMember.png" alt="">
  13. </view>
  14. <view class="infos">
  15. <view class="name">
  16. 企业会员
  17. </view>
  18. <view class="company">
  19. {{item.platformN}}
  20. </view>
  21. <view class="balance" v-if="item.entAccountEnabled&&item.enterpriseAccount!=null">
  22. 企业账户余额:{{item.enterpriseAccount.totalAmount?item.enterpriseAccount.totalAmount.toFixed(2):'0.00'}}元
  23. </view>
  24. </view>
  25. </view>
  26. <template v-for="(item,i) in showList">
  27. <view class="monthly-payment" @click="gotoUrl('pages/monthlyCardActivity/monthlyCardBuy')"
  28. :key="i" v-if="item.classify==1" >
  29. <view class="icon">
  30. <img src="../../assets/img/monthlyPayment.png" alt="">
  31. </view>
  32. <view class="infos">
  33. <view class="name">
  34. 服务费包月会员
  35. </view>
  36. <view class="date">
  37. {{item.endTime.substring(0,10)}}到期
  38. </view>
  39. </view>
  40. </view>
  41. <view class="discount-card" @click="gotocardDetails(item)"
  42. :key="i" v-if="item.classify==2">
  43. <view class="name">
  44. 自营站充电服务费6折卡
  45. </view>
  46. <view class="progress">
  47. <view class="time">
  48. {{thisendTime(item.endTime)}}到期 剩余{{thisdaysDistance(item.endTime)}}天
  49. </view>
  50. <view class="electric-quantity">
  51. 已用{{item.chargedDegree?item.chargedDegree.toFixed(0):0.00}}度 / 共{{item.chargeDegreeLimit}}度
  52. </view>
  53. </view>
  54. <ujp-line-progress active-color="#2979ff" :percent="thispercent(item)"></ujp-line-progress>
  55. </view>
  56. </template>
  57. <view class="carNone" v-if="current==0&&businessVipList.length==0&&!userCardBool">
  58. <img src="static/img/暂无数据-缺省页.png" alt="">
  59. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无数据</p>
  60. </view>
  61. <view class="carNone" v-if="current==1&&expireUserCardList.length==0">
  62. <img src="static/img/暂无数据-缺省页.png" alt="">
  63. <p class="oldTextjp2" oldstyle="font-size: 18px;">暂无数据</p>
  64. </view>
  65. </view>
  66. </view>
  67. </template>
  68. <script>
  69. import * as API from '@/apis/index.js'
  70. import {
  71. newDate,daysDistance
  72. } from '@/utils'
  73. export default {
  74. data() {
  75. return {
  76. list: [{
  77. name: '生效中'
  78. }, {
  79. name: '已过期'
  80. }],
  81. expireUserCardList:[],
  82. pageIndex: 1,
  83. recordsTotal: 0,
  84. current: 0,
  85. businessVipList:[],
  86. userCard:null,
  87. }
  88. },
  89. computed:{
  90. showList(){
  91. if(this.current==0&&this.userCardBool){
  92. return [this.userCard]
  93. }
  94. if(this.current==1){
  95. return this.expireUserCardList
  96. }
  97. return []
  98. },
  99. userCardBool(){
  100. if(this.userCard){
  101. var date=new Date().getTime()
  102. //var reg=new RegExp('-','gi')
  103. var str=this.userCard.endTime;
  104. //console.log(str.replace(reg,'/'))
  105. var date2=newDate(str).getTime();
  106. if(date<date2){
  107. return true;
  108. }
  109. }
  110. return false
  111. }
  112. },
  113. onReady() {
  114. this.userCard=this.carhelp.getPersonInfoPlus().userCard
  115. this.businessVipList=this.carhelp.getPersonInfoPlus().businessVipList
  116. if(this.businessVipList.length){
  117. var b=false;
  118. for(var i in this.businessVipList){
  119. var item=this.businessVipList[i];
  120. if(item.entAccountEnabled){
  121. b=true
  122. }
  123. }
  124. if(b){
  125. this.personalCenter()
  126. }
  127. }
  128. this.getChargeList();
  129. },
  130. methods: {
  131. gotocardDetails(item){
  132. this.carhelp.set("cardDetails-info",item)
  133. uni.navigateTo({
  134. url:'/pages/cardBag/cardDetails?id='+item.id
  135. })
  136. },
  137. thisdaysDistance(endTime){
  138. var date=new Date()
  139. var date2=newDate(endTime);
  140. return daysDistance(date,date2)
  141. },
  142. getChargeList() {
  143. uni.showLoading({
  144. title: "加载中",
  145. mask: true,
  146. })
  147. API.personCardList({
  148. }).then((res) => {
  149. uni.hideLoading();
  150. this.expireUserCardList = res.data.expireUserCardList;
  151. //this.recordsTotal = res.data.recordsTotal;
  152. }).catch(error => {
  153. uni.showToast({
  154. title: error,
  155. icon: "none"
  156. })
  157. })
  158. },
  159. thisendTime(endTime){
  160. if(endTime){
  161. var reg=new RegExp('-','gi')
  162. var str=endTime.substring(0,10).replace(reg,'.')
  163. return str
  164. }
  165. return ''
  166. },
  167. thispercent(userCard){
  168. var p=0
  169. if(userCard&&userCard.chargeDegreeLimit){
  170. p=userCard.chargedDegree/userCard.chargeDegreeLimit*100
  171. }
  172. if(p>100){
  173. p=100
  174. }
  175. return p.toFixed(0)
  176. },
  177. personalCenter(){
  178. API.personalCenter().then((res2) => {
  179. var entRegList=res2.data.entRegList;
  180. for(var i in this.businessVipList){
  181. var item1=this.businessVipList[i]
  182. for(var j in entRegList){
  183. var item2=entRegList[j].vipUser;
  184. if(item1.id==item2.id){
  185. item1.enterpriseAccount=entRegList[j].enterpriseAccount
  186. }
  187. }
  188. }
  189. this.$forceUpdate()
  190. }).catch(error => {
  191. uni.showToast({
  192. title: error
  193. })
  194. })
  195. },
  196. change(index) {
  197. this.current = index;
  198. }
  199. }
  200. }
  201. </script>
  202. <style scoped lang="scss">
  203. .carNone{
  204. display: flex;
  205. flex-direction: column;
  206. justify-content: center;
  207. align-items: center;
  208. img{
  209. width: 100%;
  210. height: 100%;
  211. }
  212. p{
  213. margin-top: -60px;
  214. }
  215. }
  216. /deep/.u-tab-bar {
  217. background-color: #00B962 !important;
  218. }
  219. .main {
  220. padding: 0 32rpx;
  221. .monthly-payment,.mcorporate-member{
  222. height: 160rpx;
  223. border-radius: 8px;
  224. background-color: rgba(55, 59, 80, 1);
  225. padding-left: 24rpx;
  226. margin-top: 24rpx;
  227. display: flex;
  228. align-items: center;
  229. .icon{
  230. width: 80rpx;
  231. height: 80rpx;
  232. img{
  233. width: 100%;
  234. }
  235. }
  236. .infos{
  237. margin-left: 16rpx;
  238. .name{
  239. color: rgba(225, 192, 130, 1);
  240. font-size: 32rpx;
  241. }
  242. .date{
  243. color: rgba(211, 185, 134, 1);
  244. font-size: 24rpx;
  245. }
  246. .company{
  247. color: rgba(204, 204, 204, 1);
  248. font-size: 24rpx;
  249. }
  250. .balance{
  251. color: rgba(219, 219, 219, 1);
  252. font-size: 24rpx;
  253. }
  254. }
  255. }
  256. .discount-card{
  257. border-radius: 8px;
  258. background-color: rgba(55, 59, 80, 1);
  259. padding: 24rpx;
  260. margin-top: 24rpx;
  261. .name{
  262. color: rgba(255, 255, 255, 1);
  263. font-size: 32rpx;
  264. }
  265. .progress{
  266. display: flex;
  267. justify-content: space-between;
  268. color: rgba(219, 219, 219, 1);
  269. font-size: 24rpx;
  270. margin-bottom: 16rpx;
  271. }
  272. /deep/.u-active{
  273. background: linear-gradient(84.49deg, rgba(59,182,254,1) 4.25%,rgba(0,185,98,1) 95.02%);
  274. }
  275. }
  276. }
  277. </style>