main.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. import Vue from 'vue'
  2. import App from './App'
  3. //import MyCommon from '@/components/Common.vue'
  4. //import CarLoading from '@/components/Loading.vue'
  5. import getOpenId from './utils/init.js'
  6. import {
  7. newDate,
  8. } from '@/utils'
  9. //支付宝的
  10. import getALIOpenId from './utils/initALI.js'
  11. import 'remixicon/fonts/remixicon.css'
  12. import './assets/font/font.css'
  13. var IS_WEIXIN = /MicroMessenger/.test(window.navigator.userAgent)
  14. var IS_ALI = /AlipayClient/.test(window.navigator.userAgent)
  15. // if(IS_WEIXIN){
  16. // }
  17. if(IS_ALI){
  18. getALIOpenId.init()
  19. }else{
  20. getOpenId.init()
  21. }
  22. window.wx = {}
  23. import mixin from './utils/mixin.js'
  24. Vue.config.ignoredElements.push("wx-open-subscribe");
  25. Vue.prototype.carhelp = mixin
  26. // 先运行yarn 初始化
  27. import Vconsole from 'vconsole'
  28. //import './router' // 引入路由
  29. import router from './bobo-router'
  30. // main.js
  31. // 先运行yarn 初始化
  32. import uView from "uview-ui";
  33. Vue.use(uView);
  34. Vue.config.productionTip = false
  35. App.mpType = 'app'
  36. const app = new Vue({
  37. ...App
  38. })
  39. //Vue.component('my-common',MyCommon)
  40. //Vue.component('car-loading',CarLoading)
  41. //Vue.use(mixin)
  42. Vue.mixin({
  43. updated: function() {
  44. this.$nextTick(function() {
  45. var nononoElderModeClass = document.getElementById("nononoElderModeClass")
  46. if(nononoElderModeClass){
  47. return false;
  48. }
  49. var g = '';
  50. var aaa=this.carhelp.get("getElderModeClass");
  51. if(aaa == "长辈模式") {
  52. g = true;
  53. } else {
  54. g = false;
  55. //g = true;
  56. }
  57. var style1="";
  58. var style2="";
  59. // 仅在整个视图都被重新渲染之后才会运行的代码
  60. var list = document.getElementsByClassName("oldTextjp")
  61. var list2 = document.getElementsByClassName("oldTextjp2")
  62. var body= document.getElementsByTagName('uni-page-body')[0].childNodes;
  63. classold(g,body);
  64. styleold(g,list,true)
  65. styleold(g,list2,false)
  66. function classold(g,list){
  67. for (var i = 0; i < list.length; i++) {
  68. try{
  69. var myclass=list[i].getAttribute("class");
  70. if(myclass){
  71. myclass = myclass.trim().replace("oldTextClassF","");
  72. }else{
  73. myclass = ""
  74. }
  75. if(g){
  76. myclass = myclass.trim()
  77. myclass=" oldTextClassF "+myclass;
  78. }else{
  79. }
  80. list[i].setAttribute("class",myclass);
  81. }catch(e){
  82. console.log("---error--classold--")
  83. console.log(list[i])
  84. }
  85. }
  86. }
  87. function styleold(g,list,jp){
  88. for (var i = 0; i < list.length; i++) {
  89. var edit = list[i].getAttribute("oldstyle-edit");
  90. if(!edit){
  91. list[i].setAttribute("oldstyle-edit",list[i].style.cssText);
  92. }else{
  93. edit=""
  94. }
  95. if (g) {
  96. var str = list[i].getAttribute("oldstyle");
  97. if(jp){
  98. str+=";font-weight:bold !important;"
  99. }
  100. if(str){
  101. list[i].style = str
  102. }
  103. }else{
  104. list[i].style=edit
  105. }
  106. }
  107. }
  108. var list_u_title = document.getElementsByClassName("u-title")
  109. var u_cell_title = document.getElementsByClassName("u-cell_title")
  110. style1 ="line-height: 20px;color: rgb(96, 98, 102); font-size: 16px; overflow: unset;"
  111. style2 ="color: rgb(96, 98, 102); font-size: 16px; font-weight: normal;"
  112. //styleg(g,style1,style2,list_u_title)
  113. styleg(g,style1,style2,u_cell_title)
  114. style1 ="line-height: 20px;color: rgb(16, 16, 16); font-size: 16px; overflow: unset;"
  115. var u_cell__label = document.getElementsByClassName("u-cell__label")
  116. styleg(g,style1,style2,u_cell__label)
  117. var list_u_value = document.getElementsByClassName("u-cell__value")
  118. style1 ="line-height: 20px;color: rgb(96, 98, 102); font-size: 16px; overflow: unset;"
  119. style2 ="color: rgb(96, 98, 102); font-size: 15px; font-weight: normal;"
  120. styleg(g,style1,style2,list_u_value)
  121. function styleg(bl,style1,style2,suzhu){
  122. for (var i = 0; i < suzhu.length; i++) {
  123. if (g) {
  124. suzhu[i].style =style1;
  125. }else{
  126. suzhu[i].style =style2;
  127. }
  128. }
  129. }
  130. })
  131. },
  132. onShow(){
  133. },
  134. onReady() {
  135. },
  136. onLoad(option) {
  137. if (option.test == 'test') {
  138. let vConsole = new Vconsole()
  139. }
  140. this.projectName = process.car.ProjectName;
  141. this.branchParameter=process.car.branchParameter;
  142. var ProjectName=process.car.ProjectName;
  143. if(process.car.NODE_ENV=='dev'||process.car.NODE_ENV=='test'){
  144. ProjectName+='('+process.car.NODE_ENV+')';
  145. }
  146. uni.setNavigationBarTitle({
  147. title:ProjectName
  148. })
  149. },
  150. methods: {
  151. quickChargeReduceMethod(station){
  152. if(station.quickChargeReduceResult&& !station.quickChargeJoinActivity){
  153. return true
  154. }
  155. return false
  156. },
  157. branchParameterBl(val){
  158. if(val=="ud"||val=="youdian"){
  159. return this.branchParameter=="youdian"
  160. }
  161. return this.branchParameter=="51team"
  162. },
  163. setValidity(periodOfValidity){
  164. if(periodOfValidity<=365){
  165. return periodOfValidity+'天';
  166. }else{
  167. return parseInt(periodOfValidity/365)+'年'+(periodOfValidity%365==0?'':periodOfValidity%365+'天')
  168. }
  169. },
  170. showNumJP(val){
  171. if(val||val==0){
  172. val=""+val
  173. if(val.indexOf(".")>-1){
  174. val= val.substring(0,val.indexOf(".")+3);
  175. }
  176. try{
  177. val = parseFloat(val).toFixed(2);
  178. }catch(e){
  179. console.log("error +++"+e)
  180. }
  181. }
  182. return val
  183. },
  184. channelNoShow(channelNo,manufacturer,customNo ){
  185. if(customNo){
  186. return customNo
  187. }
  188. var text=channelNo;
  189. if(manufacturer=='szwinline'||manufacturer=='sinexcel'){
  190. switch(channelNo){
  191. case '1':
  192. text="A";
  193. break;
  194. case '2':
  195. text="B";
  196. break;
  197. case '3':
  198. text="C";
  199. break;
  200. case 1:
  201. text="A";
  202. break;
  203. case 2:
  204. text="B";
  205. break;
  206. case 3:
  207. text="C";
  208. break;
  209. }
  210. }
  211. return text
  212. },
  213. discountRatio10(value){
  214. //value=80;
  215. var val=value;
  216. // if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  217. // }
  218. val=value/10
  219. if(val||val==0){
  220. val=""+val
  221. if(val.indexOf(".")>-1){
  222. val= val.substring(0,val.indexOf(".")+2);
  223. // if(value<10){
  224. // }else{
  225. // val= val.substring(0,val.indexOf("."));
  226. // }
  227. if(parseInt(val)==parseFloat(val)){
  228. val=parseInt(val);
  229. }
  230. }
  231. }
  232. if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  233. val=val+".0"
  234. }
  235. return val
  236. },
  237. gotoUrl(url) {
  238. uni.navigateTo({
  239. url: "/" + url
  240. })
  241. },
  242. gotoUrl2(url) {
  243. var mod = {}
  244. mod.clickUrl = url
  245. if (mod.clickUrl == null) {
  246. } else if (mod.clickUrl.indexOf('http') == 0) {
  247. window.location = mod.clickUrl ;
  248. } else if (mod.clickUrl.indexOf('#/') == 0) {
  249. if (mod.clickUrl.indexOf("?") == -1) {
  250. mod.clickUrl += '?';
  251. }
  252. var url = mod.clickUrl.split("#")[1]
  253. //window.location = mod.clickUrl;
  254. uni.navigateTo({
  255. url: url
  256. })
  257. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  258. } else {
  259. uni.navigateTo({
  260. url: mod.clickUrl
  261. })
  262. }
  263. }
  264. }
  265. })
  266. app.$mount()