C端小程序
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.

377 lines
10 KiB

  1. // pages/park/addPark/addPark.js
  2. const app = getApp();
  3. const navigationBarHeight = (getApp().statusBarHeight + 44) + 'px'
  4. const imgurl = require("../../utils/imgurl");
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. navigationBarHeight,
  11. shanchuGrayUrl: imgurl.shanchuGray.url,
  12. shanchuUrl: imgurl.shanchu.url,
  13. title: '京',
  14. numFir: '',
  15. numSco: '',
  16. numThr: '',
  17. numFor: '',
  18. numFive: '',
  19. numSix: '',
  20. numSource: '',
  21. titleShow: true,
  22. englishShow: '',
  23. numShow: '',
  24. specShow: '',
  25. chooseClass: '京',
  26. choose: 'carData.title',
  27. chooseTop: 'carData.title',
  28. buttonStatus: false,
  29. chooseTitle: [
  30. ['京', '津', '冀', '晋', '蒙', '辽', '吉'],
  31. ['黑', '沪', '苏', '浙', '皖', '闽', '赣'],
  32. ['鲁', '豫', '鄂', '湘', '粤', '桂', '琼'],
  33. ['渝', '川', '贵', '云', '藏', '陕', '甘'],
  34. ['青', '宁', '新', '台', '', '', 'DEL']
  35. ],
  36. chooseNumFir: [
  37. ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  38. ['H', 'I', 'J', 'K', 'L', 'M', 'N'],
  39. ['O', 'P', 'Q', 'R', 'S', 'T', 'U'],
  40. ['V', 'W', 'X', 'Y', 'Z', '', ''],
  41. ['', '', '', '', '', '', 'DEL']
  42. ],
  43. chooseNumSco: [
  44. ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  45. ['H', 'I', 'J', 'K', 'L', 'M', 'N'],
  46. ['O', 'P', 'Q', 'R', 'S', 'T', 'U'],
  47. ['V', 'W', 'X', 'Y', 'Z', '1', '2'],
  48. ['3', '4', '5', '6', '7', '8', '9'],
  49. ['0', '', '', '', '', '', 'DEL']
  50. ],
  51. chooseSpec: [
  52. ['A', 'B', 'C', 'D', 'E', 'F', 'G'],
  53. ['H', 'I', 'J', 'K', 'L', 'M', 'N'],
  54. ['O', 'P', 'Q', 'R', 'S', 'T', 'U'],
  55. ['V', 'W', 'X', 'Y', 'Z', '港', '澳'],
  56. ['1', '2', '3', '4', '5', '6', '7'],
  57. ['8', '9', '0', '', '', '', 'DEL']
  58. ],
  59. },
  60. onLoad: function(options) {
  61. let that = this;
  62. if (Object.keys(options).length != 0) {
  63. that.setData({
  64. flags: options.flags
  65. })
  66. }
  67. },
  68. jumpTo: function() {
  69. // 返回
  70. wx.navigateBack({
  71. url: '/index/passCar'
  72. })
  73. },
  74. handleTap: function(e) {
  75. this.buttonStatus();
  76. this.setData({
  77. choose: e.target.dataset.cardata,
  78. chooseClass: e.target.dataset.msg,
  79. chooseTop: e.target.dataset.cardata
  80. });
  81. if (e.target.dataset.cardata == "carData.title") {
  82. this.setData({
  83. titleShow: true,
  84. englishShow: false,
  85. numShow: false,
  86. specShow: false
  87. })
  88. } else if (e.target.dataset.cardata == "carData.numFir") {
  89. this.setData({
  90. titleShow: false,
  91. englishShow: true,
  92. numShow: false,
  93. specShow: false
  94. })
  95. } else {
  96. if (e.target.dataset.cardata == 'carData.numSix' && this.data.title == '粤') {
  97. this.setData({
  98. titleShow: false,
  99. englishShow: false,
  100. numShow: false,
  101. specShow: true
  102. })
  103. } else {
  104. this.setData({
  105. titleShow: false,
  106. englishShow: false,
  107. numShow: true,
  108. specShow: false
  109. })
  110. }
  111. }
  112. },
  113. chooseNum: function(e) {
  114. if (e.target.dataset.msg == 'I') {
  115. return
  116. }
  117. if (!!e.target.dataset.msg && e.target.dataset.msg != 'DEL') {
  118. switch (this.data.choose) {
  119. case "carData.title":
  120. this.setData({
  121. title: e.target.dataset.msg,
  122. chooseClass: e.target.dataset.msg,
  123. chooseTop: 'carData.numFir'
  124. });
  125. break;
  126. case "carData.numFir":
  127. this.setData({
  128. numFir: e.target.dataset.msg,
  129. chooseClass: e.target.dataset.msg,
  130. chooseTop: 'carData.numSco'
  131. });
  132. break;
  133. case "carData.numSco":
  134. this.setData({
  135. numSco: e.target.dataset.msg,
  136. chooseClass: e.target.dataset.msg,
  137. chooseTop: 'carData.numThr'
  138. });
  139. break;
  140. case "carData.numThr":
  141. this.setData({
  142. numThr: e.target.dataset.msg,
  143. chooseClass: e.target.dataset.msg,
  144. chooseTop: 'carData.numFor'
  145. });
  146. break;
  147. case "carData.numFor":
  148. this.setData({
  149. numFor: e.target.dataset.msg,
  150. chooseClass: e.target.dataset.msg,
  151. chooseTop: 'carData.numFive'
  152. });
  153. break;
  154. case "carData.numFive":
  155. this.setData({
  156. numFive: e.target.dataset.msg,
  157. chooseClass: e.target.dataset.msg,
  158. chooseTop: 'carData.numSix'
  159. });
  160. break;
  161. case "carData.numSix":
  162. this.setData({
  163. numSix: e.target.dataset.msg,
  164. chooseClass: e.target.dataset.msg
  165. });
  166. break;
  167. case "carData.numSource":
  168. this.setData({
  169. numSource: e.target.dataset.msg,
  170. chooseClass: e.target.dataset.msg
  171. });
  172. break;
  173. };
  174. switch (this.data.chooseTop) {
  175. case "carData.numFir":
  176. this.setData({
  177. choose: 'carData.numFir',
  178. titleShow: false,
  179. englishShow: true,
  180. numShow: false,
  181. specShow: false
  182. })
  183. break;
  184. case "carData.numSco":
  185. this.setData({
  186. choose: 'carData.numSco',
  187. titleShow: false,
  188. englishShow: false,
  189. numShow: true,
  190. specShow: false
  191. })
  192. break;
  193. case "carData.numThr":
  194. this.setData({
  195. choose: 'carData.numThr',
  196. titleShow: false,
  197. englishShow: false,
  198. numShow: true,
  199. specShow: false
  200. })
  201. break;
  202. case "carData.numFor":
  203. this.setData({
  204. choose: 'carData.numFor',
  205. titleShow: false,
  206. englishShow: false,
  207. numShow: true,
  208. specShow: false
  209. })
  210. break;
  211. case "carData.numFive":
  212. this.setData({
  213. choose: 'carData.numFive',
  214. titleShow: false,
  215. englishShow: false,
  216. numShow: true,
  217. specShow: false
  218. })
  219. break;
  220. case "carData.numSix":
  221. if (this.data.title == '粤') {
  222. this.setData({
  223. choose: 'carData.numSix',
  224. titleShow: false,
  225. englishShow: false,
  226. numShow: false,
  227. specShow: true
  228. })
  229. } else {
  230. this.setData({
  231. choose: 'carData.numSix',
  232. titleShow: false,
  233. englishShow: false,
  234. numShow: true,
  235. specShow: false
  236. })
  237. }
  238. break;
  239. }
  240. } else if (e.target.dataset.msg == 'DEL') {
  241. switch (this.data.choose) {
  242. case "carData.title":
  243. this.setData({
  244. title: '',
  245. chooseTop: 'carData.title',
  246. choose: 'carData.title',
  247. titleShow: true,
  248. englishShow: false,
  249. numShow: false,
  250. specShow: false
  251. });
  252. break;
  253. case "carData.numFir":
  254. this.setData({
  255. numFir: '',
  256. chooseTop: 'carData.title',
  257. choose: 'carData.title',
  258. titleShow: true,
  259. englishShow: false,
  260. numShow: false,
  261. specShow: false
  262. });
  263. break;
  264. case "carData.numSco":
  265. this.setData({
  266. numSco: '',
  267. // chooseClass: e.target.dataset.msg,
  268. chooseTop: 'carData.numFir',
  269. choose: 'carData.numFir',
  270. titleShow: false,
  271. englishShow: true,
  272. numShow: false,
  273. specShow: false
  274. });
  275. break;
  276. case "carData.numThr":
  277. this.setData({
  278. numThr: '',
  279. // chooseClass: e.target.dataset.msg,
  280. chooseTop: 'carData.numSco',
  281. choose: 'carData.numSco',
  282. titleShow: false,
  283. englishShow: false,
  284. numShow: true,
  285. specShow: false
  286. });
  287. break;
  288. case "carData.numFor":
  289. this.setData({
  290. numFor: '',
  291. // chooseClass: e.target.dataset.msg,
  292. chooseTop: 'carData.numThr',
  293. choose: 'carData.numThr',
  294. titleShow: false,
  295. englishShow: false,
  296. numShow: true,
  297. specShow: false
  298. });
  299. break;
  300. case "carData.numFive":
  301. this.setData({
  302. numFive: '',
  303. // chooseClass: e.target.dataset.msg,
  304. chooseTop: 'carData.numFor',
  305. choose: 'carData.numFor',
  306. titleShow: false,
  307. englishShow: false,
  308. numShow: true,
  309. specShow: false
  310. });
  311. break;
  312. case "carData.numSix":
  313. this.setData({
  314. numSix: '',
  315. // chooseClass: e.target.dataset.msg
  316. chooseTop: 'carData.numFive',
  317. choose: 'carData.numFive',
  318. titleShow: false,
  319. englishShow: false,
  320. numShow: true,
  321. specShow: false
  322. });
  323. break;
  324. case "carData.numSource":
  325. this.setData({
  326. numSource: ''
  327. });
  328. break;
  329. }
  330. }
  331. this.buttonStatus();
  332. },
  333. submit: function() {
  334. if (this.data.title != "" && this.data.numFir != "" && this.data.numSco != "" && this.data.numThr != "" && this.data.numFor != "" && this.data.numFive != "" && this.data.numSix != "") {
  335. var carNumber = ''
  336. carNumber += this.data.title + this.data.numFir + this.data.numSco + this.data.numThr + this.data.numFor + this.data.numFive + this.data.numSix
  337. if (this.data.numSource != "")
  338. carNumber += this.data.numSource
  339. var pages = getCurrentPages();
  340. var prevPage = pages[pages.length - 2];
  341. prevPage.setData({
  342. addCar: carNumber
  343. })
  344. if (this.data.flags == 'managepalte') {
  345. wx.navigateBack({
  346. url: '/pages/managelicenseplate/managelicenseplate?addcar=' + carNumber,
  347. })
  348. } else {
  349. wx.navigateBack({
  350. url: '/index/passCar?addcar=' + carNumber,
  351. })
  352. }
  353. }
  354. },
  355. buttonStatus: function() {
  356. if (this.data.title != "" && this.data.numFir != "" && this.data.numSco != "" && this.data.numThr != "" && this.data.numFor != "" && this.data.numFive != "" && this.data.numSix != "") {
  357. this.setData({
  358. buttonStatus: true
  359. });
  360. } else {
  361. this.setData({
  362. buttonStatus: false
  363. });
  364. }
  365. }
  366. })