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.

tools.js 8.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. // import md5 from '../sys/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. // import http from './http.js'; //身份类型
  9. const identityData = [
  10. {
  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. {
  73. name: '万集',
  74. value: 'WJ'
  75. },
  76. {
  77. name: '聚利',
  78. value: 'JL'
  79. },
  80. {
  81. name: '金溢',
  82. value: 'JY'
  83. },
  84. {
  85. name: '埃特斯',
  86. value: 'AT'
  87. },
  88. {
  89. name: '建投',
  90. value: 'JT'
  91. },
  92. {
  93. name: '握奇',
  94. value: 'WQ'
  95. },
  96. {
  97. name: '成谷',
  98. value: 'CG'
  99. },
  100. {
  101. name: '天地融',
  102. value: 'TD'
  103. },
  104. {
  105. name: '智载',
  106. value: 'ZZ'
  107. }
  108. ];
  109. /********************** 路由跳转 **********************/
  110. //保留当前页面,跳转到应用内的某个页面
  111. function toUrl(url) {
  112. wx.showToast({
  113. //显示消息提示框 此处是提升用户体验的作用
  114. title: '加载中',
  115. icon: 'loading'
  116. }); // if (url.indexOf("?")==-1){
  117. // url += '?rand=' + datas.randomNum(1000,9999)
  118. // }else{
  119. // url += '&rand=' + datas.randomNum(1000,9999)
  120. // }
  121. console.log('url:*****' + url);
  122. wx.navigateTo({
  123. url: url,
  124. complete: function (response) {
  125. wx.hideToast();
  126. }
  127. });
  128. } //关闭当前页面,返回上一页面或多级页面。
  129. function navigateBack(delta, successFunc = null, failFunc = null) {
  130. wx.navigateBack({
  131. delta: delta,
  132. success: function (res) {
  133. //接口调用成功的回调函数
  134. if (successFunc != null) {
  135. successFunc(res);
  136. }
  137. },
  138. fail: function (res) {
  139. //接口调用失败的回调函数
  140. if (failFunc != null) {
  141. failFunc(res);
  142. }
  143. },
  144. complete: function (res) {} //接口调用结束的回调函数(调用成功、失败都会执行)
  145. });
  146. }
  147. /********************** showModalAlert ************************/
  148. function showModalAlert(content, successFunc = null, failFunc = null, title = '温馨提示', showCancel = false) {
  149. wx.showModal({
  150. title: title,
  151. content: content,
  152. showCancel: showCancel,
  153. //是否显示取消按钮
  154. cancelText: '取消',
  155. //默认是“取消”
  156. cancelColor: theme.cancelModalColor,
  157. //取消文字的颜色
  158. confirmText: '确定',
  159. //默认是“确定”
  160. confirmColor: theme.modalColor,
  161. //确定文字的颜色
  162. success: function (res) {
  163. //接口调用成功的回调函数
  164. if (successFunc != null) {
  165. successFunc(res);
  166. }
  167. },
  168. fail: function (res) {
  169. //接口调用失败的回调函数
  170. if (failFunc != null) {
  171. failFunc(res);
  172. }
  173. },
  174. complete: function (res) {} //接口调用结束的回调函数(调用成功、失败都会执行)
  175. });
  176. }
  177. /*******************showToastAlert********************/
  178. function showToastAlert(title = '成功', icon = 'none', image = '', duration = 2000, mask = true, successFunc = null, failFunc = null, completeFun = null) {
  179. wx.showToast({
  180. title: title,
  181. icon: icon,
  182. //success显示成功图标,loading显示加载图标,none不显示图标
  183. image: image,
  184. duration: duration,
  185. mask: mask,
  186. ////是否显示透明蒙层,防止触摸穿透
  187. success: function (res) {
  188. //接口调用成功的回调函数
  189. if (successFunc != null) {
  190. successFunc(res);
  191. }
  192. },
  193. fail: function (res) {
  194. //接口调用失败的回调函数
  195. if (failFunc != null) {
  196. failFunc(res);
  197. }
  198. },
  199. complete: function (res) {
  200. //接口调用结束的回调函数(调用成功、失败都会执行)
  201. if (completeFun != null) {
  202. completeFun(res);
  203. }
  204. }
  205. });
  206. }
  207. /******************showLoadingAlert************************/
  208. function showLoadingAlert(title = '加载中...', mask = true, successFunc = null, failFunc = null, completeFun = null) {
  209. wx.showLoading({
  210. title: title,
  211. mask: mask,
  212. //是否显示透明蒙层,防止触摸穿透
  213. success: function (res) {
  214. //接口调用成功的回调函数
  215. if (successFunc != null) {
  216. successFunc(res);
  217. }
  218. },
  219. fail: function (res) {
  220. //接口调用失败的回调函数
  221. if (failFunc != null) {
  222. failFunc(res);
  223. }
  224. },
  225. complete: function (res) {
  226. //接口调用结束的回调函数(调用成功、失败都会执行)
  227. if (completeFun != null) {
  228. completeFun(res);
  229. }
  230. }
  231. });
  232. }
  233. function hideLoadingAlert(successFunc = null, failFunc = null, completeFun = null) {
  234. wx.hideLoading({
  235. success: function (res) {
  236. //接口调用成功的回调函数
  237. if (successFunc != null) {
  238. successFunc(res);
  239. }
  240. },
  241. fail: function (res) {
  242. //接口调用失败的回调函数
  243. if (failFunc != null) {
  244. failFunc(res);
  245. }
  246. },
  247. complete: function (res) {
  248. //接口调用结束的回调函数(调用成功、失败都会执行)
  249. if (completeFun != null) {
  250. completeFun(res);
  251. }
  252. }
  253. });
  254. } //签名
  255. function alertF(msg) {
  256. //隐藏加载框
  257. hideLoadingAlert(); //提示对话框
  258. showModalAlert(msg);
  259. }
  260. function alertFback(msg, backcall) {
  261. //隐藏加载框
  262. hideLoadingAlert(); //提示对话框
  263. showModalAlert(msg, backcall);
  264. }
  265. /**
  266. * 车牌数字转车牌中文
  267. */
  268. function vehiclePlateStr(num, successFun) {
  269. var vehicleColorStr;
  270. switch (num) {
  271. case 0:
  272. vehicleColorStr = '蓝色';
  273. successFun(vehicleColorStr);
  274. break;
  275. case 1:
  276. vehicleColorStr = '黄色';
  277. successFun(vehicleColorStr);
  278. break;
  279. case 2:
  280. vehicleColorStr = '黑色';
  281. successFun(vehicleColorStr);
  282. break;
  283. case 3:
  284. vehicleColorStr = '白色';
  285. successFun(vehicleColorStr);
  286. break;
  287. case 4:
  288. vehicleColorStr = '渐变绿色';
  289. successFun(vehicleColorStr);
  290. break;
  291. case 5:
  292. vehicleColorStr = '黄绿双拼色';
  293. successFun(vehicleColorStr);
  294. break;
  295. case 6:
  296. vehicleColorStr = '蓝白渐变色';
  297. successFun(vehicleColorStr);
  298. break;
  299. case 7:
  300. vehicleColorStr = '临时牌照';
  301. successFun(vehicleColorStr);
  302. break;
  303. case 9:
  304. vehicleColorStr = '未确定';
  305. successFun(vehicleColorStr);
  306. break;
  307. case 11:
  308. vehicleColorStr = '绿色';
  309. successFun(vehicleColorStr);
  310. break;
  311. case 12:
  312. vehicleColorStr = '红色';
  313. successFun(vehicleColorStr);
  314. break;
  315. default:
  316. vehicleColorStr = '未知';
  317. successFun(vehicleColorStr);
  318. break;
  319. }
  320. }
  321. module.exports = {
  322. toUrl,
  323. navigateBack,
  324. showModalAlert,
  325. showToastAlert,
  326. showLoadingAlert,
  327. hideLoadingAlert,
  328. // getEtcBankList,
  329. // showAlertv2,
  330. // loading,
  331. // md5Str,
  332. // sha1Str,
  333. alertF,
  334. alertFback,
  335. identityData,
  336. deviceModel,
  337. // isFollow,
  338. vehiclePlateStr
  339. };