main.js 6.5 KB

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