second.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. // StepPage/pages/second/second.js
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. s_title:'',
  8. searchBvalue:'',
  9. searchValue:'',
  10. searchSvalue:'',
  11. itemList:[],
  12. productList:[],
  13. specialList:[],
  14. title:'',
  15. b_title:"",
  16. show:false,
  17. b_show:false,
  18. s_show:false,
  19. searchList:[],
  20. searchBList:[],
  21. searchSList:[],
  22. inside:'1',
  23. surface:'1',
  24. set_status:''
  25. },
  26. onChangeInside(event) {
  27. let app = getApp();
  28. app.globalData.inside = event.detail;
  29. this.setData({
  30. inside: event.detail,
  31. });
  32. },
  33. onClickInside(event) {
  34. const { name } = event.currentTarget.dataset;
  35. let app = getApp();
  36. app.globalData.inside = name;
  37. this.setData({
  38. inside: name,
  39. });
  40. },
  41. onChangeSurface(event) {
  42. let app = getApp();
  43. app.globalData.surface = event.detail;
  44. this.setData({
  45. surface: event.detail,
  46. });
  47. },
  48. onClickSurface(event) {
  49. const { name } = event.currentTarget.dataset;
  50. let app = getApp();
  51. app.globalData.surface = name;
  52. this.setData({
  53. surface: name,
  54. });
  55. },
  56. handleCancel(){
  57. this.setData({
  58. show:false
  59. })
  60. },
  61. handleChoose(data){
  62. let app = getApp();
  63. let basic_type_item_id;
  64. basic_type_item_id =data.target.dataset.item.id;
  65. app.globalData.basic_type_item_id = basic_type_item_id;
  66. app.globalData.img_type = data.target.dataset.item.img_type;
  67. app.globalData.img = [];
  68. app.globalData.img_type.split(',').forEach(ele => {
  69. if(ele){
  70. let obj ={};
  71. obj.type=ele;
  72. obj.src = '';
  73. obj.url = `https://zh.qingyaokeji.com/${ele}.jpg`
  74. app.globalData.img.push(obj)
  75. }
  76. });
  77. app.globalData.choose_b_r_f_id = (data.target.dataset.item.b_r_f_id).split(',').map(c=>c&&(c*1));
  78. this.setData({
  79. show:false,
  80. searchValue:'',
  81. searchList:[],
  82. title:data.target.dataset.item.title
  83. })
  84. },
  85. handleCancelFile(){
  86. this.setData({
  87. b_show:false
  88. })
  89. },
  90. handleCancelSpecial(){
  91. this.setData({
  92. s_show:false
  93. })
  94. },
  95. handleChooseFile(data){
  96. let app = getApp();
  97. let basic_type_bussiness_id = data.target.dataset.item.id;
  98. app.globalData.basic_type_bussiness_id = basic_type_bussiness_id;
  99. app.globalData.bussiness_special_type = data.target.dataset.item.special_type;
  100. this.setData({
  101. b_show:false,
  102. searchBvalue:'',
  103. searchBList:[],
  104. b_title:data.target.dataset.item.title
  105. })
  106. },
  107. handleChooseSpecial(data){
  108. let app = getApp();
  109. let basic_type_special_id = data.target.dataset.item.id;
  110. app.globalData.basic_type_special_id = basic_type_special_id;
  111. this.setData({
  112. s_show:false,
  113. searchSvalue:'',
  114. searchSList:[],
  115. s_title:data.target.dataset.item.title
  116. })
  117. },
  118. onChooseSpecial(){
  119. this.setData({
  120. s_show:true,
  121. searchSList:this.data.specialList
  122. })
  123. },
  124. onChooseBusiness(){
  125. this.setData({
  126. b_show:true,
  127. searchBList:this.data.itemList
  128. })
  129. },
  130. onChoose(){
  131. this.setData({
  132. show:true,
  133. searchList:this.data.productList
  134. })
  135. },
  136. onSearchBusiness(event){
  137. let arr = this.data.itemList.filter(v=>v.title.indexOf(event.detail)!=-1);
  138. this.setData({
  139. searchBList:arr
  140. })
  141. },
  142. onSearchSpecial(event){
  143. let arr = this.data.specialList.filter(v=>v.title.indexOf(event.detail)!=-1);
  144. this.setData({
  145. searchSList:arr
  146. })
  147. },
  148. onSearch(event){
  149. let arr = this.data.productList.filter(v=>v.title.indexOf(event.detail)!=-1);
  150. this.setData({
  151. searchList:arr
  152. })
  153. },
  154. handleNext(){
  155. let app = getApp();
  156. let openid = app.globalData.openID;
  157. app.globalData.inside = this.data.inside;
  158. app.globalData.surface = this.data.surface;
  159. if(!this.data.title||!this.data.b_title){
  160. return wx.showToast({
  161. icon:'none',
  162. title: '请选择必填信息!',
  163. })
  164. }
  165. if(this.data.set_status){
  166. wx.redirectTo({
  167. url: '../third/third',
  168. })
  169. }else{
  170. app.globalData.img = app.globalData.img?app.globalData.img:[];
  171. app.globalData.img_type =app.globalData.img_type?app.globalData.img_type:'';
  172. app.globalData.stepData = app.globalData.stepData.filter(v=>v.sort!=2);
  173. app.globalData.stepData.push({
  174. sort:2,
  175. data:{
  176. title:this.data.title,
  177. s_title:this.data.s_title,
  178. b_title:this.data.b_title,
  179. inside:this.data.inside,
  180. surface:this.data.surface
  181. }
  182. })
  183. wx.p.request({
  184. url: `${app.globalData.url}wx/saveWxConstructionData`,
  185. method:'POST',
  186. data:{
  187. openid,
  188. type:1,
  189. data:JSON.stringify(app.globalData)
  190. }
  191. }).then(res=>{
  192. if(res.data.code==200){
  193. wx.redirectTo({
  194. url: '../third/third',
  195. })
  196. }
  197. })
  198. }
  199. },
  200. handleReturn(){
  201. let app = getApp();
  202. let openid = app.globalData.openID;
  203. app.globalData.basic_type_special_id = '';
  204. app.globalData.basic_type_bussiness_id = '';
  205. app.globalData.basic_type_item_id = '';
  206. app.globalData.inside = '1';
  207. app.globalData.surface = '1';
  208. app.globalData.img_type = '';
  209. app.globalData.choose_b_r_f_id = [];
  210. if(this.data.set_status){
  211. wx.redirectTo({
  212. url: '../first/first',
  213. })
  214. }else{
  215. app.globalData.stepData.forEach((v,index)=>{
  216. if(v.sort == '2'){
  217. app.globalData.stepData.splice(index,1);
  218. }
  219. })
  220. wx.p.request({
  221. url: `${app.globalData.url}wx/saveWxConstructionData`,
  222. method:'POST',
  223. data:{
  224. openid,
  225. type:1,
  226. data:JSON.stringify(app.globalData)
  227. }
  228. }).then(res=>{
  229. if(res.data.code==200){
  230. wx.redirectTo({
  231. url: '../first/first',
  232. })
  233. }
  234. })
  235. }
  236. },
  237. /**
  238. * 生命周期函数--监听页面加载
  239. */
  240. onLoad(options) {
  241. let app = getApp();
  242. let openid = app.globalData.openID;
  243. app.globalData.inside = '1';
  244. app.globalData.surface = '1';
  245. wx.p.request({
  246. url: `${app.globalData.url}wx/basicTypeList`,
  247. method:'POST',
  248. data:{
  249. openid
  250. }
  251. }).then(res=>{
  252. if(res.data.code==200){
  253. res.data.data.type_two.forEach(v=>{
  254. v.is_choose = false;
  255. })
  256. res.data.data.type_one.forEach(v=>{
  257. v.is_choose = false;
  258. })
  259. this.setData({
  260. productList:res.data.data.type_two,
  261. itemList:res.data.data.type_one,
  262. specialList:res.data.data.type_three,
  263. inside:app.globalData.inside,
  264. surface:app.globalData.surface
  265. })
  266. }
  267. if(app.globalData.set_status){
  268. app.globalData.inside = app.globalData.detailData.inside+'';
  269. app.globalData.surface = app.globalData.detailData.surface+'';
  270. app.globalData.basic_type_item_id = app.globalData.detailData.basic_type_item_id;
  271. app.globalData.img_type = app.globalData.detailData.item_message.img_type;
  272. app.globalData.img = [];
  273. app.globalData.img_type.split(',').forEach(ele => {
  274. if(ele){
  275. let obj ={};
  276. obj.type=ele;
  277. obj.src = '';
  278. obj.url = `https://zh.qingyaokeji.com/${ele}.jpg`;
  279. app.globalData.img.push(obj)
  280. }
  281. });
  282. app.globalData.choose_b_r_f_id = (app.globalData.detailData.item_message.b_r_f_id).split(',').map(c=>c&&(c*1));
  283. app.globalData.basic_type_bussiness_id = app.globalData.detailData.basic_type_bussiness_id;
  284. app.globalData.basic_type_special_id = app.globalData.detailData.basic_type_special_id;
  285. console.log(app.globalData)
  286. this.setData({
  287. title: app.globalData.detailData.basic_type_item_name,
  288. s_title: app.globalData.detailData.basic_type_special_name,
  289. b_title: app.globalData.detailData.basic_type_bussiness_name,
  290. inside:app.globalData.detailData.inside+'',
  291. surface: app.globalData.detailData.surface+'',
  292. set_status : app.globalData.set_status
  293. })
  294. }else{
  295. this.setData({
  296. set_status : ''
  297. })
  298. wx.p.request({
  299. url: `${app.globalData.url}wx/getWxConstructionData`,
  300. method:'POST',
  301. data:{
  302. type:1,
  303. openid
  304. }
  305. }).then(res=>{
  306. if(res.data.code==200){
  307. if(res.data.data.data){
  308. let data = JSON.parse(res.data.data.data);
  309. let box = data.stepData.find(v=>v.sort==2);
  310. app.globalData = data;
  311. app.globalData.set_status = '';
  312. if(box){
  313. this.setData({
  314. title:box.data.title,
  315. s_title:box.data.s_title,
  316. b_title:box.data.b_title,
  317. inside:box.data.inside?box.data.inside+'':'1',
  318. surface:box.data.surface?box.data.surface+'':'1'
  319. })
  320. }
  321. }
  322. }
  323. })
  324. }
  325. })
  326. },
  327. /**
  328. * 生命周期函数--监听页面初次渲染完成
  329. */
  330. onReady() {
  331. },
  332. /**
  333. * 生命周期函数--监听页面显示
  334. */
  335. onShow() {
  336. },
  337. /**
  338. * 生命周期函数--监听页面隐藏
  339. */
  340. onHide() {
  341. },
  342. /**
  343. * 生命周期函数--监听页面卸载
  344. */
  345. onUnload() {
  346. },
  347. /**
  348. * 页面相关事件处理函数--监听用户下拉动作
  349. */
  350. onPullDownRefresh() {
  351. },
  352. /**
  353. * 页面上拉触底事件的处理函数
  354. */
  355. onReachBottom() {
  356. },
  357. /**
  358. * 用户点击右上角分享
  359. */
  360. onShareAppMessage() {
  361. }
  362. })