main.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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. this.branchParameter=process.car.branchParameter;
  137. var ProjectName=process.car.ProjectName;
  138. if(process.car.NODE_ENV=='dev'||process.car.NODE_ENV=='test'){
  139. ProjectName+='('+process.car.NODE_ENV+')';
  140. }
  141. uni.setNavigationBarTitle({
  142. title:ProjectName
  143. })
  144. },
  145. methods: {
  146. branchParameterBl(val){
  147. if(val=="ud"||val=="youdian"){
  148. return this.branchParameter=="youdian"
  149. }
  150. return this.branchParameter=="51team"
  151. },
  152. setValidity(periodOfValidity){
  153. if(periodOfValidity<=365){
  154. return periodOfValidity+'天';
  155. }else{
  156. return parseInt(periodOfValidity/365)+'年'+(periodOfValidity%365==0?'':periodOfValidity%365+'天')
  157. }
  158. },
  159. showNumJP(val){
  160. if(val||val==0){
  161. val=""+val
  162. if(val.indexOf(".")>-1){
  163. val= val.substring(0,val.indexOf(".")+3);
  164. }
  165. try{
  166. val = parseFloat(val).toFixed(2);
  167. }catch(e){
  168. console.log("error +++"+e)
  169. }
  170. }
  171. return val
  172. },
  173. channelNoShow(channelNo,manufacturer ){
  174. console.log(manufacturer)
  175. var text=channelNo;
  176. if(manufacturer=='szwinline'||manufacturer=='sinexcel'){
  177. switch(channelNo){
  178. case '1':
  179. text="A";
  180. break;
  181. case '2':
  182. text="B";
  183. break;
  184. case '3':
  185. text="C";
  186. break;
  187. case 1:
  188. text="A";
  189. break;
  190. case 2:
  191. text="B";
  192. break;
  193. case 3:
  194. text="C";
  195. break;
  196. }
  197. }
  198. return text
  199. },
  200. discountRatio10(value){
  201. //value=80;
  202. var val=value;
  203. // if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  204. // }
  205. val=value/10
  206. if(val||val==0){
  207. val=""+val
  208. if(val.indexOf(".")>-1){
  209. val= val.substring(0,val.indexOf(".")+2);
  210. // if(value<10){
  211. // }else{
  212. // val= val.substring(0,val.indexOf("."));
  213. // }
  214. if(parseInt(val)==parseFloat(val)){
  215. val=parseInt(val);
  216. }
  217. }
  218. }
  219. if([10,20,30,40,50,60,70,80,90].indexOf(value)!=-1){
  220. val=val+".0"
  221. }
  222. return val
  223. },
  224. gotoUrl(url) {
  225. uni.navigateTo({
  226. url: "/" + url
  227. })
  228. },
  229. gotoUrl2(url) {
  230. var mod = {}
  231. mod.clickUrl = url
  232. if (mod.clickUrl == null) {
  233. } else if (mod.clickUrl.indexOf('http') == 0) {
  234. window.location = mod.clickUrl ;
  235. } else if (mod.clickUrl.indexOf('#/') == 0) {
  236. if (mod.clickUrl.indexOf("?") == -1) {
  237. mod.clickUrl += '?';
  238. }
  239. var url = mod.clickUrl.split("#")[1]
  240. //window.location = mod.clickUrl;
  241. uni.navigateTo({
  242. url: url
  243. })
  244. } else if (mod.clickUrl == '#' || mod.clickUrl == '') {
  245. } else {
  246. uni.navigateTo({
  247. url: mod.clickUrl
  248. })
  249. }
  250. }
  251. }
  252. })
  253. app.$mount()