main.js 7.3 KB

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