main.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. userChargingAmountMethod(obj){
  153. var m=obj.money
  154. //m=2760
  155. var sz=[
  156. {
  157. num1:3000,
  158. num2:999999999,
  159. num3:800,
  160. },
  161. {
  162. num1:2000,
  163. num2:2500,
  164. num3:427,
  165. },
  166. {
  167. num1:1000,
  168. num2:1500,
  169. num3:133,
  170. },
  171. {
  172. num1:500,
  173. num2:750,
  174. num3:40,
  175. },
  176. ]
  177. var obj={}
  178. for(var i in sz){
  179. var item=sz[i]
  180. if(m<item.num2){
  181. obj=item
  182. }
  183. }
  184. return obj
  185. },
  186. tagNameBy(tagName,i){
  187. var str=""
  188. if(tagName){
  189. if(tagName.indexOf('@')!=-1){
  190. var sz=tagName.split('@')
  191. if(i==0){
  192. str=sz[0]
  193. }
  194. if(i==1){
  195. str=sz[1]
  196. }
  197. }else{
  198. if(i==0){
  199. str=tagName
  200. }
  201. }
  202. }
  203. return str
  204. },
  205. quickChargeReduceMethod1(station){
  206. //普通满减活动
  207. if(station.quickChargeReduceResult&&(!station.quickChargeJoinActivity|| station.quickChargeJoinActivity==0)){
  208. return true
  209. }
  210. return false
  211. },
  212. quickChargeReduceMethod2(station){
  213. //转盘
  214. if(station.quickChargeReduceResult&& station.quickChargeJoinActivity==1){
  215. return true
  216. }
  217. return false
  218. },
  219. branchParameterBl(val){
  220. if(val=="ud"||val=="youdian"){
  221. return process.car.branchParameter=="youdian"
  222. }
  223. return process.car.branchParameter=="51team"
  224. },
  225. setValidity(periodOfValidity){
  226. if(periodOfValidity<=365){
  227. return periodOfValidity+'天';
  228. }else{
  229. return parseInt(periodOfValidity/365)+'年'+(periodOfValidity%365==0?'':periodOfValidity%365+'天')
  230. }
  231. },
  232. showNumJP(val){
  233. if(val||val==0){
  234. val=""+val
  235. if(val.indexOf(".")>-1){
  236. val= val.substring(0,val.indexOf(".")+3);
  237. }
  238. try{
  239. val = parseFloat(val).toFixed(2);
  240. }catch(e){
  241. console.log("error +++"+e)
  242. }
  243. }
  244. return val
  245. },
  246. channelNoShow(channelNo,manufacturer,customNo ){
  247. if(customNo){
  248. return customNo
  249. }
  250. var text=channelNo;
  251. if(manufacturer=='szwinline'||manufacturer=='sinexcel'){
  252. switch(channelNo){
  253. case '1':
  254. text="A";
  255. break;
  256. case '2':
  257. text="B";
  258. break;
  259. case '3':
  260. text="C";
  261. break;
  262. case 1:
  263. text="A";
  264. break;
  265. case 2:
  266. text="B";
  267. break;
  268. case 3:
  269. text="C";
  270. break;
  271. }
  272. }
  273. return text
  274. },
  275. discountRatio10(value){
  276. //value=80;
  277. var val=value;
  278. // if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  279. // }
  280. val=value/10
  281. if(val||val==0){
  282. val=""+val
  283. if(val.indexOf(".")>-1){
  284. val= val.substring(0,val.indexOf(".")+2);
  285. // if(value<10){
  286. // }else{
  287. // val= val.substring(0,val.indexOf("."));
  288. // }
  289. if(parseInt(val)==parseFloat(val)){
  290. val=parseInt(val);
  291. }
  292. }
  293. }
  294. if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  295. val=val+".0"
  296. }
  297. return val
  298. },
  299. gotoUrl(url,bl) {
  300. if(bl){
  301. uni.redirectTo({
  302. url: "/" + url
  303. })
  304. }else{
  305. uni.navigateTo({
  306. url: "/" + url
  307. })
  308. }
  309. },
  310. gotoUrl2(url) {
  311. var mod = {}
  312. mod.clickUrl = url
  313. if (mod.clickUrl == null) {
  314. } else if (mod.clickUrl.indexOf('http') == 0) {
  315. window.location = mod.clickUrl ;
  316. } else if (mod.clickUrl.indexOf('#/') == 0) {
  317. if (mod.clickUrl.indexOf("?") == -1) {
  318. mod.clickUrl += '?';
  319. }
  320. var url = mod.clickUrl.split("#")[1]
  321. //window.location = mod.clickUrl;
  322. uni.navigateTo({
  323. url: url
  324. })
  325. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  326. } else {
  327. uni.navigateTo({
  328. url: mod.clickUrl
  329. })
  330. }
  331. }
  332. }
  333. })
  334. app.$mount()