main.js 7.7 KB

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