main.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. console.log(process.car.branchParameter)
  143. var ProjectName=process.car.ProjectName;
  144. if(process.car.NODE_ENV=='dev'||process.car.NODE_ENV=='test'){
  145. ProjectName+='('+process.car.NODE_ENV+')';
  146. }
  147. uni.setNavigationBarTitle({
  148. title:ProjectName
  149. })
  150. },
  151. methods: {
  152. tagNameBy(tagName,i){
  153. var str=""
  154. if(tagName){
  155. if(tagName.indexOf('@')!=-1){
  156. var sz=tagName.split('@')
  157. if(i==0){
  158. str=sz[0]
  159. }
  160. if(i==1){
  161. str=sz[1]
  162. }
  163. }else{
  164. if(i==0){
  165. str=tagName
  166. }
  167. }
  168. }
  169. return str
  170. },
  171. quickChargeReduceMethod1(station){
  172. //普通满减活动
  173. if(station.quickChargeReduceResult&&(!station.quickChargeJoinActivity|| station.quickChargeJoinActivity==0)){
  174. return true
  175. }
  176. return false
  177. },
  178. quickChargeReduceMethod2(station){
  179. //转盘
  180. if(station.quickChargeReduceResult&& station.quickChargeJoinActivity==1){
  181. return true
  182. }
  183. return false
  184. },
  185. branchParameterBl(val){
  186. if(val=="ud"||val=="youdian"){
  187. return process.car.branchParameter=="youdian"
  188. }
  189. return process.car.branchParameter=="51team"
  190. },
  191. setValidity(periodOfValidity){
  192. if(periodOfValidity<=365){
  193. return periodOfValidity+'天';
  194. }else{
  195. return parseInt(periodOfValidity/365)+'年'+(periodOfValidity%365==0?'':periodOfValidity%365+'天')
  196. }
  197. },
  198. showNumJP(val){
  199. if(val||val==0){
  200. val=""+val
  201. if(val.indexOf(".")>-1){
  202. val= val.substring(0,val.indexOf(".")+3);
  203. }
  204. try{
  205. val = parseFloat(val).toFixed(2);
  206. }catch(e){
  207. console.log("error +++"+e)
  208. }
  209. }
  210. return val
  211. },
  212. channelNoShow(channelNo,manufacturer,customNo ){
  213. if(customNo){
  214. return customNo
  215. }
  216. var text=channelNo;
  217. if(manufacturer=='szwinline'||manufacturer=='sinexcel'){
  218. switch(channelNo){
  219. case '1':
  220. text="A";
  221. break;
  222. case '2':
  223. text="B";
  224. break;
  225. case '3':
  226. text="C";
  227. break;
  228. case 1:
  229. text="A";
  230. break;
  231. case 2:
  232. text="B";
  233. break;
  234. case 3:
  235. text="C";
  236. break;
  237. }
  238. }
  239. return text
  240. },
  241. discountRatio10(value){
  242. //value=80;
  243. var val=value;
  244. // if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  245. // }
  246. val=value/10
  247. if(val||val==0){
  248. val=""+val
  249. if(val.indexOf(".")>-1){
  250. val= val.substring(0,val.indexOf(".")+2);
  251. // if(value<10){
  252. // }else{
  253. // val= val.substring(0,val.indexOf("."));
  254. // }
  255. if(parseInt(val)==parseFloat(val)){
  256. val=parseInt(val);
  257. }
  258. }
  259. }
  260. if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  261. val=val+".0"
  262. }
  263. return val
  264. },
  265. gotoUrl(url,bl) {
  266. if(bl){
  267. uni.redirectTo({
  268. url: "/" + url
  269. })
  270. }else{
  271. uni.navigateTo({
  272. url: "/" + url
  273. })
  274. }
  275. },
  276. gotoUrl2(url) {
  277. var mod = {}
  278. mod.clickUrl = url
  279. if (mod.clickUrl == null) {
  280. } else if (mod.clickUrl.indexOf('http') == 0) {
  281. window.location = mod.clickUrl ;
  282. } else if (mod.clickUrl.indexOf('#/') == 0) {
  283. if (mod.clickUrl.indexOf("?") == -1) {
  284. mod.clickUrl += '?';
  285. }
  286. var url = mod.clickUrl.split("#")[1]
  287. //window.location = mod.clickUrl;
  288. uni.navigateTo({
  289. url: url
  290. })
  291. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  292. } else {
  293. uni.navigateTo({
  294. url: mod.clickUrl
  295. })
  296. }
  297. }
  298. }
  299. })
  300. app.$mount()