chargePriceDetails.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <view style="padding-bottom: 296rpx;">
  3. <ujp-navbar title="充电价格详情"></ujp-navbar>
  4. <view class="main" >
  5. <view class="tabs-box">
  6. <u-tabs inactive-color="#888888" active-color="#101010" :list="list" :is-scroll="true"
  7. :current="current" @change="change"></u-tabs>
  8. </view>
  9. <view style="width: 100%;">
  10. <view ><u-line color="#999999" /></view>
  11. <view class="time-frame" v-for="(item,index) in items" :key="index">
  12. <view class="time-items">
  13. <view class="time-price">
  14. <view class="time">
  15. {{item.time}}
  16. </view>
  17. <view class="price">
  18. <text class="price-text">{{item.price.toFixed(2)}}</text>
  19. <text class="unit">元/度</text>
  20. </view>
  21. </view>
  22. <view class="unitPrice-serviceCharge">
  23. 充电单价:{{item.single_price.toFixed(2)}}元 | 服务费:{{item.service_price.toFixed(2)}}元
  24. </view>
  25. <view v-if="item.current" class="product_tip">
  26. <view class="product_tip_bg"></view>
  27. <p>当前</p>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <!-- <view class="line-box"><u-line color="#999999" /></view>-->
  33. </view>
  34. <view class="hint">
  35. *充电费用仅供参考,请以充电桩上的费用为准。
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import * as api from "@/apis/site.js"
  41. let _self;
  42. var formatNum=function(num) {
  43. let res = Number(num);
  44. return res < 10 ? '0' + res : res;
  45. };
  46. export default {
  47. data() {
  48. return {
  49. id:"",
  50. type:"",
  51. elderMode:false,
  52. list:[],
  53. items:[],
  54. current: 0
  55. }
  56. },
  57. onLoad(op){
  58. _self = this;
  59. if(op.type){
  60. this.type=op.type;
  61. }
  62. if(op.id){
  63. this.id=op.id;
  64. }
  65. let date = new Date();
  66. let hours = date.getHours();
  67. let minutes = date.getMinutes();
  68. let seconds = date.getSeconds();
  69. let date_str = formatNum(hours)+ ':'+ formatNum(minutes);//+ ' ' +formatWeek;
  70. if(op!=null && op.stationId!=null){
  71. //('stationId'+JSON.stringify(op.stationId))
  72. let data = {stationId:op.stationId};
  73. api.getChargingStationPrice(data).then(function(res){
  74. // //('data'+JSON.stringify(res))
  75. if(res.result){
  76. let data = res.data;
  77. if(data.prices){
  78. //('data'+JSON.stringify(data.prices))
  79. _self.list = [];
  80. for(let i = 0;i< data.prices.length;i++){
  81. let _item = data.prices[i];
  82. if(_self.id){
  83. if(_item.id==_self.type){
  84. _self.current=i;
  85. }
  86. }else{
  87. if(_item.type==_self.type){
  88. if(_self.current==0){
  89. _self.current=i;
  90. }
  91. }
  92. }
  93. let item = {name:data.prices[i].name,items:[]};
  94. for(let j = 0;j<_item.priceList.length;j++){
  95. let _subitem = _item.priceList[j];
  96. //('priceList'+JSON.stringify(_subitem))
  97. let subitem = {time:'00:00-07:00',single_price:0,service_price:0,price:0};
  98. subitem.time = _subitem.startTime + '-'+_subitem.endTime;
  99. subitem.single_price = _subitem.electricityPrice;
  100. subitem.service_price = _subitem.servicePrice;
  101. subitem.price = _subitem.costPrice;
  102. subitem.current = false;
  103. let start_time = subitem.time.substr(0,5);
  104. let end_time = subitem.time.substr(6,5);
  105. if(date_str>=start_time && date_str<= end_time)
  106. {
  107. subitem.current = true;
  108. }
  109. subitem.startTime = _subitem.startTime;
  110. subitem.endTime = _subitem.endTime;
  111. item.items.push(subitem);
  112. }
  113. _self.list.push(item);
  114. }
  115. if(_self.list.length>0){
  116. _self.change(_self.current);
  117. }
  118. //('站点价格详情'+JSON.stringify(_self.list));
  119. }
  120. }
  121. })
  122. }
  123. /* api.getPriceDetails(op).then(function(res){
  124. _self.list = res;
  125. },function(err){
  126. }
  127. );*/
  128. },
  129. onReady(){
  130. this.elderMode = this.carhelp.get('getElderModeClass') == '长辈模式';
  131. if(this.elderMode)
  132. this.theme('elder')
  133. else
  134. this.theme('standard')
  135. let date = new Date();
  136. let hours = date.getHours();
  137. let minutes = date.getMinutes();
  138. let seconds = date.getSeconds();
  139. let date_str = formatNum(hours)+ ':'+ formatNum(minutes);//+ ' ' +formatWeek;
  140. //('date_str'+JSON.stringify(date_str))
  141. for(let i = 0;i< _self.list.length;i++)
  142. {
  143. for(let j = 0;j< _self.list[i].items.length;j++){
  144. let start_time = _self.list[i].items[j].time.substr(0,5);
  145. let end_time = _self.list[i].items[j].time.substr(6,5);
  146. // //('start time ' +JSON.stringify())
  147. // //('end time ' +JSON.stringify())
  148. if(date_str< start_time)
  149. continue;
  150. if(date_str> end_time)
  151. continue;
  152. _self.list[i].items[j].current = true;
  153. }
  154. }
  155. },
  156. methods: {
  157. change(index) {
  158. this.current = index;
  159. this.items = this.list[index].items;
  160. },
  161. theme(type) {
  162. if(type == 'elder')
  163. {
  164. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  165. }
  166. else
  167. {
  168. document.getElementsByTagName('body')[0].setAttribute('data-theme',type);
  169. }
  170. }
  171. }
  172. }
  173. </script>
  174. <style lang="scss" scoped>
  175. @import "@/_theme.scss";
  176. .product_tip{
  177. position: absolute;
  178. top: 0;
  179. right: 0;
  180. width: 55rpx;
  181. height: 55rpx;
  182. text-align: right;
  183. p{
  184. font-size: 24rpx;
  185. color: #ffffff;
  186. transform: rotate(45deg);
  187. position: relative;
  188. top: 0rpx;
  189. right: 0rpx;
  190. }
  191. .product_tip_bg{
  192. width: 0;
  193. height: 0;
  194. border-bottom: 44rpx solid #FD662A;
  195. border-right: 44rpx solid transparent;
  196. border-left: 44rpx solid transparent;
  197. transform: rotate(45deg);
  198. position: absolute;
  199. top: -7rpx;
  200. right: -29rpx;
  201. }
  202. }
  203. .main {
  204. background-color: #fff;
  205. .tabs-box {
  206. width: 55%;
  207. height: 88rpx;
  208. margin: 0 auto;
  209. // line-height: 44px;
  210. position: relative;
  211. }
  212. .line-box{
  213. width: 100%;
  214. height: 88rpx;
  215. position: absolute;
  216. top: 145rpx;
  217. }
  218. .time-frame {
  219. padding-left: 32rpx;
  220. /* position: absolute;
  221. top:260rpx;
  222. */
  223. .time-items {
  224. padding-right: 32rpx;
  225. height: 152rpx;
  226. border-bottom: #F2F4F4 2rpx solid;
  227. position: relative;
  228. .time-price {
  229. display: flex;
  230. justify-content: space-between;
  231. padding: 32rpx 0 20rpx;
  232. .time {
  233. color: rgba(16, 16, 16, 100);
  234. @include themeify{
  235. font-size:themed('font-size3');
  236. }
  237. /* font-size: 32rpx;*/
  238. }
  239. .price {
  240. .price-text{
  241. color: #ff3d00;
  242. @include themeify{
  243. font-size:themed('font-size4');
  244. }
  245. /* font-size: 36rpx;*/
  246. }
  247. .unit {
  248. color: rgba(102, 102, 102, 100);
  249. @include themeify{
  250. font-size:themed('font-size2');
  251. }
  252. /* font-size: 28rpx;*/
  253. margin-left: 8rpx;
  254. }
  255. }
  256. }
  257. .unitPrice-serviceCharge {
  258. float: right;
  259. @include themeify{
  260. font-size:themed('font-size1');
  261. }
  262. /* font-size: 24rpx;*/
  263. color: #888888;
  264. }
  265. }
  266. }
  267. }
  268. .hint{
  269. width: 100%;
  270. text-align: center;
  271. color: #999999;
  272. @include themeify{
  273. font-size:themed('font-size1');
  274. }
  275. /* font-size: 24rpx;*/
  276. position: absolute;
  277. bottom: 24rpx;
  278. left: 0;
  279. }
  280. .tabs-box{
  281. width: 90% !important;
  282. }
  283. </style>