You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. import md5 from './md5.js';
  2. // import sha1 from '../sys/sha1.js';
  3. import datas from './datas.js';
  4. // import ksort from '../sys/ksort.js';
  5. import theme from './theme.js';
  6. // import config from '../../config/config.js';
  7. // import urlConfig from '../../config/urlConfig.js';
  8. const common_vendor = require("../../common/vendor.js");
  9. var uni = common_vendor.index
  10. const identityData = [{
  11. id: 101,
  12. name: '身份证(含临时身份证)'
  13. },
  14. {
  15. id: 102,
  16. name: '护照(限外籍人士)'
  17. },
  18. {
  19. id: 103,
  20. name: '港澳居民来往内地通行证'
  21. },
  22. {
  23. id: 104,
  24. name: '台湾居民来往大陆通行证'
  25. },
  26. {
  27. id: 105,
  28. name: '军官证'
  29. },
  30. {
  31. id: 106,
  32. name: '武警警察身份证'
  33. },
  34. {
  35. id: 201,
  36. name: '统一社会信用代码证书'
  37. },
  38. {
  39. id: 202,
  40. name: '组织机构代码证'
  41. },
  42. {
  43. id: 203,
  44. name: '营业执照'
  45. },
  46. {
  47. id: 204,
  48. name: '事业单位法人证书'
  49. },
  50. {
  51. id: 205,
  52. name: '社会团体法人登记证书'
  53. },
  54. {
  55. id: 206,
  56. name: '律师事务所执业许可证'
  57. },
  58. {
  59. id: 217,
  60. name: '公司商业登记副本(3个月内)'
  61. },
  62. {
  63. id: 218,
  64. name: '公司营业税单M8副本'
  65. },
  66. {
  67. id: 219,
  68. name: '公司营业税开业/更改M1副本'
  69. }
  70. ];
  71. const deviceModel = [{
  72. name: '万集',
  73. value: 'WJ'
  74. },
  75. {
  76. name: '聚利',
  77. value: 'JL'
  78. },
  79. {
  80. name: '金溢',
  81. value: 'JY'
  82. },
  83. {
  84. name: '埃特斯',
  85. value: 'AT'
  86. },
  87. {
  88. name: '建投',
  89. value: 'JT'
  90. },
  91. {
  92. name: '握奇',
  93. value: 'WQ'
  94. },
  95. {
  96. name: '成谷',
  97. value: 'CG'
  98. },
  99. {
  100. name: '天地融',
  101. value: 'TD'
  102. },
  103. {
  104. name: '智载',
  105. value: 'ZZ'
  106. }
  107. ];
  108. /********************** 路由跳转 **********************/
  109. //保留当前页面,跳转到应用内的某个页面
  110. function toUrl(url) {
  111. uni.showToast({
  112. //显示消息提示框 此处是提升用户体验的作用
  113. title: '加载中',
  114. icon: 'loading'
  115. }); // if (url.indexOf("?")==-1){
  116. // url += '?rand=' + datas.randomNum(1000,9999)
  117. // }else{
  118. // url += '&rand=' + datas.randomNum(1000,9999)
  119. // }
  120. console.log('url:*****' + url);
  121. uni.navigateTo({
  122. url: url,
  123. complete: function(response) {
  124. uni.hideToast();
  125. }
  126. });
  127. } //关闭当前页面,返回上一页面或多级页面。
  128. function navigateBack(delta, successFunc = null, failFunc = null) {
  129. uni.navigateBack({
  130. delta: delta,
  131. success: function(res) {
  132. //接口调用成功的回调函数
  133. if (successFunc != null) {
  134. successFunc(res);
  135. }
  136. },
  137. fail: function(res) {
  138. //接口调用失败的回调函数
  139. if (failFunc != null) {
  140. failFunc(res);
  141. }
  142. },
  143. complete: function(res) {} //接口调用结束的回调函数(调用成功、失败都会执行)
  144. });
  145. }
  146. /********************** showModalAlert ************************/
  147. function showModalAlert(content, successFunc = null, failFunc = null, title = '温馨提示', showCancel = false) {
  148. console.log("温馨提示", title, content != "")
  149. if (content != "") {
  150. if (content == 'timeout' || content == 'creatConnectionFailure') {
  151. content = "请重新打开OBU设备蓝牙后在手机上重新搜索蓝牙设备"
  152. }
  153. // if (content.indexOf("发送数据失败")) {
  154. // content = "OBU设备蓝牙已关闭,请返回到【选择蓝牙设备】界面重新连接蓝牙设备"
  155. // }
  156. uni.showModal({
  157. title: title,
  158. content: content,
  159. showCancel: showCancel,
  160. //是否显示取消按钮
  161. cancelText: '取消',
  162. //默认是“取消”
  163. cancelColor: theme.cancelModalColor,
  164. //取消文字的颜色
  165. confirmText: '确定',
  166. //默认是“确定”
  167. confirmColor: theme.modalColor,
  168. //确定文字的颜色
  169. success: function(res) {
  170. //接口调用成功的回调函数
  171. if (successFunc != null) {
  172. successFunc(res);
  173. }
  174. },
  175. fail: function(res) {
  176. //接口调用失败的回调函数
  177. if (failFunc != null) {
  178. failFunc(res);
  179. }
  180. },
  181. complete: function(res) {} //接口调用结束的回调函数(调用成功、失败都会执行)
  182. });
  183. }
  184. }
  185. /*******************showToastAlert********************/
  186. function showToastAlert(title = '成功', icon = 'none', image = '', duration = 2000, mask = true, successFunc = null,
  187. failFunc = null, completeFun = null) {
  188. uni.showToast({
  189. title: title,
  190. icon: icon,
  191. //success显示成功图标,loading显示加载图标,none不显示图标
  192. image: image,
  193. duration: duration,
  194. mask: mask,
  195. ////是否显示透明蒙层,防止触摸穿透
  196. success: function(res) {
  197. //接口调用成功的回调函数
  198. if (successFunc != null) {
  199. successFunc(res);
  200. }
  201. },
  202. fail: function(res) {
  203. //接口调用失败的回调函数
  204. if (failFunc != null) {
  205. failFunc(res);
  206. }
  207. },
  208. complete: function(res) {
  209. //接口调用结束的回调函数(调用成功、失败都会执行)
  210. if (completeFun != null) {
  211. completeFun(res);
  212. }
  213. }
  214. });
  215. }
  216. /******************showLoadingAlert************************/
  217. function showLoadingAlert(title = '加载中...', mask = true, successFunc = null, failFunc = null, completeFun = null) {
  218. uni.showLoading({
  219. title: title,
  220. mask: mask,
  221. //是否显示透明蒙层,防止触摸穿透
  222. success: function(res) {
  223. //接口调用成功的回调函数
  224. if (successFunc != null) {
  225. successFunc(res);
  226. }
  227. },
  228. fail: function(res) {
  229. //接口调用失败的回调函数
  230. if (failFunc != null) {
  231. failFunc(res);
  232. }
  233. },
  234. complete: function(res) {
  235. //接口调用结束的回调函数(调用成功、失败都会执行)
  236. if (completeFun != null) {
  237. completeFun(res);
  238. }
  239. //添加安全锁,防止Loading不会关闭
  240. setTimeout(() => {
  241. hideLoadingAlert()
  242. }, 5000)
  243. }
  244. });
  245. }
  246. function hideLoadingAlert(successFunc = null, failFunc = null, completeFun = null) {
  247. uni.hideLoading({
  248. success: function(res) {
  249. //接口调用成功的回调函数
  250. if (successFunc != null) {
  251. successFunc(res);
  252. }
  253. },
  254. fail: function(res) {
  255. //接口调用失败的回调函数
  256. if (failFunc != null) {
  257. failFunc(res);
  258. }
  259. },
  260. complete: function(res) {
  261. //接口调用结束的回调函数(调用成功、失败都会执行)
  262. if (completeFun != null) {
  263. completeFun(res);
  264. }
  265. }
  266. });
  267. } //签名
  268. function alertF(msg) {
  269. //隐藏加载框
  270. hideLoadingAlert(); //提示对话框
  271. showModalAlert(msg);
  272. }
  273. function alertFback(msg, backcall) {
  274. //隐藏加载框
  275. hideLoadingAlert(); //提示对话框
  276. showModalAlert(msg, backcall);
  277. }
  278. /**
  279. * 车牌数字转车牌中文
  280. */
  281. function vehiclePlateStr(num, successFun) {
  282. var vehicleColorStr;
  283. switch (num) {
  284. case 0:
  285. vehicleColorStr = '蓝色';
  286. successFun(vehicleColorStr);
  287. break;
  288. case 1:
  289. vehicleColorStr = '黄色';
  290. successFun(vehicleColorStr);
  291. break;
  292. case 2:
  293. vehicleColorStr = '黑色';
  294. successFun(vehicleColorStr);
  295. break;
  296. case 3:
  297. vehicleColorStr = '白色';
  298. successFun(vehicleColorStr);
  299. break;
  300. case 4:
  301. vehicleColorStr = '渐变绿色';
  302. successFun(vehicleColorStr);
  303. break;
  304. case 5:
  305. vehicleColorStr = '黄绿双拼色';
  306. successFun(vehicleColorStr);
  307. break;
  308. case 6:
  309. vehicleColorStr = '蓝白渐变色';
  310. successFun(vehicleColorStr);
  311. break;
  312. case 7:
  313. vehicleColorStr = '临时牌照';
  314. successFun(vehicleColorStr);
  315. break;
  316. case 9:
  317. vehicleColorStr = '未确定';
  318. successFun(vehicleColorStr);
  319. break;
  320. case 11:
  321. vehicleColorStr = '绿色';
  322. successFun(vehicleColorStr);
  323. break;
  324. case 12:
  325. vehicleColorStr = '红色';
  326. successFun(vehicleColorStr);
  327. break;
  328. default:
  329. vehicleColorStr = '未知';
  330. successFun(vehicleColorStr);
  331. break;
  332. }
  333. }
  334. //字符串加密
  335. function md5Str(str) {
  336. var _str = md5.i(str);
  337. return _str;
  338. }
  339. module.exports = {
  340. toUrl,
  341. navigateBack,
  342. showModalAlert,
  343. showToastAlert,
  344. showLoadingAlert,
  345. hideLoadingAlert,
  346. md5Str,
  347. alertF,
  348. alertFback,
  349. identityData,
  350. deviceModel,
  351. vehiclePlateStr
  352. };