zero.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. // StepPage/pages/zero/zero.js
  2. import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. is_shi:true,
  9. is_pan:true,
  10. is_lin:true,
  11. is_tui:true,
  12. is_diao:true,
  13. is_shen:true
  14. },
  15. handleQrCode(){
  16. let app = getApp();
  17. if(!app.globalData.openID){
  18. return Dialog.confirm({
  19. title: '确认登录',
  20. message: '当前账户未登录是否登录?',
  21. }).then(() => {
  22. // on confirm
  23. wx.redirectTo({
  24. url: '../beforeLogin/beforeLogin',
  25. })
  26. })
  27. .catch(() => {
  28. // on cancel
  29. });
  30. }else{
  31. wx.p.request({
  32. url: `${app.globalData.url}wx/wxCheck`,
  33. method:'POST',
  34. data:{
  35. type:1,
  36. openid:app.globalData.openID
  37. }
  38. }).then(req=>{
  39. if(req.data.code==200){
  40. wx.redirectTo({
  41. url: '../../StepPage/pages/qrCode/qrCode',
  42. })
  43. }else{
  44. wx.showToast({
  45. icon:'none',
  46. title: req.data.msg
  47. })
  48. if(req.data.code==1){
  49. wx.redirectTo({
  50. url: '../beforeLogin/beforeLogin',
  51. })
  52. }
  53. }
  54. })
  55. }
  56. },
  57. changeShi(){
  58. this.data.is_shi = !this.data.is_shi;
  59. this.setData({
  60. is_shen:true,
  61. is_shi:this.data.is_shi,
  62. is_pan:true,
  63. is_lin:true,
  64. is_tui:true,
  65. is_diao:true
  66. })
  67. },
  68. changeLin(){
  69. this.data.is_lin = !this.data.is_lin;
  70. this.setData({
  71. is_shen:true,
  72. is_shi:true,
  73. is_pan:true,
  74. is_lin:this.data.is_lin,
  75. is_tui:true,
  76. is_diao:true
  77. })
  78. },
  79. changeTui(){
  80. this.data.is_tui = !this.data.is_tui;
  81. this.setData({
  82. is_shen:true,
  83. is_shi:true,
  84. is_pan:true,
  85. is_lin:true,
  86. is_tui:this.data.is_tui,
  87. is_diao:true
  88. })
  89. },
  90. changePan(){
  91. this.data.is_pan = !this.data.is_pan;
  92. this.setData({
  93. is_shen:true,
  94. is_shi:true,
  95. is_pan:this.data.is_pan,
  96. is_lin:true,
  97. is_tui:true,
  98. is_diao:true
  99. })
  100. },
  101. changeDiao(){
  102. this.data.is_diao = !this.data.is_diao;
  103. this.setData({
  104. is_shen:true,
  105. is_shi:true,
  106. is_pan:true,
  107. is_lin:true,
  108. is_tui:true,
  109. is_diao:this.data.is_diao
  110. })
  111. },
  112. changeShen(){
  113. this.data.is_shen = !this.data.is_shen;
  114. this.setData({
  115. is_shen:this.data.is_shen,
  116. is_shi:true,
  117. is_pan:true,
  118. is_lin:true,
  119. is_tui:true,
  120. is_diao:true
  121. })
  122. },
  123. creatPan(){
  124. let app = getApp();
  125. app.globalData.typePage = 2;
  126. wx.redirectTo({
  127. url: '../../StepPage/pages/first/first',
  128. })
  129. },
  130. creatLin(){
  131. wx.redirectTo({
  132. url: '../../StepPage/pages/firstLin/firstLin',
  133. })
  134. },
  135. creatTui(){
  136. wx.redirectTo({
  137. url: '../../StepPage/pages/firstTui/firstTui',
  138. })
  139. },
  140. creatDiao(){
  141. wx.navigateTo({
  142. url: '../../StepPage/pages/diao/diao',
  143. })
  144. },
  145. creatShen(){
  146. wx.navigateTo({
  147. url: '../../StepPage/pages/shen/shen',
  148. })
  149. },
  150. creatWork(){
  151. let app = getApp();
  152. let openid = app.globalData.openID;
  153. wx.p.request({
  154. url: `${app.globalData.url}wx/getWxConstructionData`,
  155. method:'POST',
  156. data:{
  157. type:1,
  158. openid
  159. }
  160. }).then(req=>{
  161. if(req.data.code==200){
  162. if(req.data.data.data&&req.data.data.length!=0){
  163. let data = JSON.parse(req.data.data.data);
  164. let sort = 1;
  165. data.stepData.forEach(ele => {
  166. console.log(ele);
  167. if((ele.sort*1)>sort){
  168. sort = ele.sort;
  169. }
  170. });
  171. app.globalData = data;
  172. app.globalData.typePage=1;
  173. app.globalData.set_status = '';
  174. switch(sort){
  175. case 1:
  176. wx.redirectTo({
  177. url: '../../StepPage/pages/first/first',
  178. })
  179. break;
  180. case 2:
  181. wx.redirectTo({
  182. url: '../../StepPage/pages/second/second',
  183. })
  184. break;
  185. case 3:
  186. wx.redirectTo({
  187. url: '../../StepPage/pages/third/third',
  188. })
  189. break;
  190. case 4:
  191. wx.redirectTo({
  192. url: '../../StepPage/pages/writeVIN/writeVIN',
  193. })
  194. break;
  195. case 5:
  196. wx.redirectTo({
  197. url: '../../StepPage/pages/fourth/fourth',
  198. })
  199. break;
  200. case 6:
  201. wx.redirectTo({
  202. url: '../../StepPage/pages/fifth/fifth',
  203. })
  204. break;
  205. }
  206. }else{
  207. app.globalData.typePage = 1;
  208. app.globalData.set_status = '';
  209. wx.redirectTo({
  210. url: '../../StepPage/pages/first/first',
  211. })
  212. }
  213. }
  214. })
  215. },
  216. handleCreate(){
  217. //新增
  218. if(this.data.is_diao&&this.data.is_shen&&this.data.is_tui&&this.data.is_lin&&this.data.is_pan&&this.data.is_shi){
  219. return wx.showToast({
  220. icon:'error',
  221. title: '请选择'
  222. })
  223. }
  224. let app = getApp();
  225. if(!app.globalData.openID){
  226. return Dialog.confirm({
  227. title: '确认登录',
  228. message: '当前账户未登录是否登录?',
  229. }).then(() => {
  230. // on confirm
  231. wx.redirectTo({
  232. url: '../beforeLogin/beforeLogin',
  233. })
  234. })
  235. .catch(() => {
  236. // on cancel
  237. });
  238. }else{
  239. wx.p.request({
  240. url: `${app.globalData.url}wx/wxCheck`,
  241. method:'POST',
  242. data:{
  243. type:1,
  244. openid:app.globalData.openID
  245. }
  246. }).then(req=>{
  247. if(req.data.code==200){
  248. app.globalData.set_status = '';
  249. if(!this.data.is_pan){
  250. this.creatPan()
  251. }else if(!this.data.is_shen){
  252. this.creatShen()
  253. }else if(!this.data.is_shi){
  254. this.creatWork()
  255. }else if(!this.data.is_lin){
  256. this.creatLin()
  257. }else if(!this.data.is_diao){
  258. this.creatDiao()
  259. }else if(!this.data.is_tui){
  260. this.creatTui()
  261. }
  262. }else{
  263. wx.showToast({
  264. icon:'none',
  265. title: req.data.msg
  266. })
  267. if(req.data.code==1){
  268. wx.redirectTo({
  269. url: '../beforeLogin/beforeLogin',
  270. })
  271. }
  272. }
  273. })
  274. }
  275. },
  276. handleCheck(){
  277. //查询
  278. if(this.data.is_diao&&this.data.is_shen&&this.data.is_tui&&this.data.is_lin&&this.data.is_pan&&this.data.is_shi){
  279. return wx.showToast({
  280. icon:'error',
  281. title: '请选择'
  282. })
  283. }
  284. let app = getApp();
  285. if(!app.globalData.openID){
  286. return Dialog.confirm({
  287. title: '确认登录',
  288. message: '当前账户未登录是否登录?',
  289. })
  290. .then(() => {
  291. // on confirm
  292. wx.redirectTo({
  293. url: '../beforeLogin/beforeLogin',
  294. })
  295. })
  296. .catch(() => {
  297. // on cancel
  298. });
  299. }else{
  300. wx.p.request({
  301. url: `${app.globalData.url}wx/wxCheck`,
  302. method:'POST',
  303. data:{
  304. type:1,
  305. openid:app.globalData.openID
  306. }
  307. }).then(req=>{
  308. if(req.data.code==200){
  309. if(!this.data.is_pan){
  310. wx.redirectTo({
  311. url: '../../StepPage/pages/report/PanList/PanList',
  312. })
  313. }else if(!this.data.is_shen){
  314. wx.redirectTo({
  315. url: '../../StepPage/pages/report/ShenList/ShenList',
  316. })
  317. }else if(!this.data.is_shi){
  318. wx.redirectTo({
  319. url: '../../StepPage/pages/report/ShiList/ShiList',
  320. })
  321. }else if(!this.data.is_lin){
  322. wx.redirectTo({
  323. url: '../../StepPage/pages/report/LinList/LinList',
  324. })
  325. }else if(!this.data.is_diao){
  326. wx.redirectTo({
  327. url: '../../StepPage/pages/report/DiaoList/DiaoList',
  328. })
  329. }else if(!this.data.is_tui){
  330. wx.redirectTo({
  331. url: '../../StepPage/pages/report/TuiList/TuiList',
  332. })
  333. }
  334. }else{
  335. wx.showToast({
  336. icon:'none',
  337. title: req.data.msg
  338. })
  339. if(req.data.code==1){
  340. wx.redirectTo({
  341. url: '../beforeLogin/beforeLogin',
  342. })
  343. }
  344. }
  345. })
  346. }
  347. },
  348. /**
  349. * 生命周期函数--监听页面加载
  350. */
  351. onLoad(options) {
  352. let app = getApp();
  353. if(app.globalData.openID){
  354. wx.p.request({
  355. url: `${app.globalData.url}wx/wxCheckWb`,
  356. method:'POST',
  357. data:{
  358. openid:app.globalData.openID
  359. }
  360. }).then(req=>{
  361. if(req.data.data&&req.data.data.is_wb){
  362. this.creatWork()
  363. }
  364. })
  365. }
  366. },
  367. /**
  368. * 生命周期函数--监听页面初次渲染完成
  369. */
  370. onReady() {
  371. },
  372. /**
  373. * 生命周期函数--监听页面显示
  374. */
  375. onShow() {
  376. },
  377. /**
  378. * 生命周期函数--监听页面隐藏
  379. */
  380. onHide() {
  381. },
  382. /**
  383. * 生命周期函数--监听页面卸载
  384. */
  385. onUnload() {
  386. },
  387. /**
  388. * 页面相关事件处理函数--监听用户下拉动作
  389. */
  390. onPullDownRefresh() {
  391. },
  392. /**
  393. * 页面上拉触底事件的处理函数
  394. */
  395. onReachBottom() {
  396. },
  397. /**
  398. * 用户点击右上角分享
  399. */
  400. onShareAppMessage() {
  401. }
  402. })