research.js 12.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
new Vue({
	el:'#research',
	data:{
		cardindex:[],
		part1:[],
		part2:[],
		question0:[],
		question1:[],
		question2:[],
		question3:[],
		question3_title1:'',
		question3_title2:'',
		question3_title3:'',
		answer1:'北舞渡',
		//第二问
		frequency:1,
		//最喜欢的家乡的美食
		food:'',

		province:[],
		city:[],
		county:[],
		street:[],
		detailaddress:'',
		sureinfo:{
			province:"",
			city:"",
			county:"",
			town:"",
			province_id:"",
			city_id:"",
			county_id:"",
			town_id:"",
			selfprovince:"",
			selfprovince_id:"",
			selfcity:"",
			selfcity_id:"",
			selfcounty:"",
			selfcounty_id:"",
		},
		proce:{},
		ci:{},
		coun:{},
		stre:{},


		//家乡省
		selfprovince:[],
		selfcity:[],
		selfcounty:[],
		selfpro:{},
		selfc:{},
		selfcoun:{},
		
		//是否挑战成功
		success:false,
		//优惠券信息
		textarea:'',
		discount_coupon_name:'',
		discount_coupon_price:'',
		
		
		
		},
	created: function() {
		this.detailsinfo();
		this.details();
		this.selfdetails();
		//领取优惠券
		this.getcoupon();

	},
	methods: {
		//获取调研试题
		detailsinfo: function() {
			var that = this;
			var url = '/Inquiry/index'
			var params = {
				
			}
			ajaxsend(url, params, function(res) {
				/*console.log(JSON.stringify(res))*/
				console.log(res);
				var data=res.data;
				that.part1=data.part1;
				that.part2=data.part2;
				console.log(that.part1);
				console.log(that.part2);
				that.question0=that.part2[0];
				that.question1=that.part2[1];
				that.question2=that.part2[2];
				that.question3=that.part2[3];
				var que=that.question3.content.split(' ');
				that.question3_title1=que[0];
				that.question3_title2=que[1];
				that.question3_title3=que[2];
				
				
				
			})
		},
		//第一问的答案
		select1:function(){
			var that = this;
			that.answer1='北舞渡';
			console.log(that.answer1)
		},
		select2:function(){
			var that = this;
			that.answer1='逍遥镇';
			console.log(that.answer1);
		},
		select3:function(){
			var that = this;
			that.answer1='方中山';
			console.log(that.answer1);
		},
		
		//第二问
		fre:function(){
			var that=this;
			that.frequency++;
//			console.log(that.frequency)
		},
		
		//获取信息
		details: function() {
			var that = this;
            //默认市
            var obcity={
                province_id:'000',
                city_name:'市'
            };
            that.city.push(obcity);
            var len=that.city.length;
            that.ci=that.city[len-1];
            console.log( that.ci);

            //默认区
            var obscounty={
                county_id:'000',
                county_name:'区'
            };
            that.county.push(obscounty);
            var len1=that.county.length;
            that.coun=that.county[len1-1];
            //默认街道
            var obstreet={
                town_id:'000',
                town_name:'街道'
            };
            that.street.push(obstreet);
            var len2=that.street.length;
            that.stre=that.street[len2-1];

			var url = '/AjaxPosition/province'
			var params = {
				
			}
			ajaxsend(url, params, function(res) {
				/*console.log(JSON.stringify(res))*/
				console.log(res);
				var data=res.data;
				that.province=data;
                //默认省
                var ob={
                    province_id:'000',
                    province_name:'省'
                }
                data.unshift(ob);
                that.province=data;
                console.log(that.province);
                that.proce=that.province[0];

			})
		},
		//选择城市
		selectcity:function(res){

				var that = this;			
				//省
				var proce_name=that.proce.province_name;
				var provinceid =that.proce.province_id;
				that.sureinfo.province=proce_name;
				that.sureinfo.province_id=provinceid;
				console.log(provinceid)
					var url = '/AjaxPosition/city'
					var params = {
						province_id:provinceid
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
                        var obcity={
                            province_id:'000',
                            city_name:'市'
                        };
                        res.data.unshift(obcity);
                        that.city=res.data;
                        that.ci=that.city[0];

						
					})
			},
		//选择县
		selectcounty:function(res){
			var that = this;
				//市
				var ci_name=that.ci.city_name;
				var cityid=that.ci.city_id;
				that.sureinfo.city=ci_name;
				that.sureinfo.city_id= cityid;
					var url = '/AjaxPosition/county'
					var params = {
						city_id:cityid
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
                        var obscounty={
                            county_id:'000',
                            county_name:'区'
                        };
                        res.data.unshift( obscounty);
                        that.county=res.data;
                        that.coun=that.county[0];
		
			
		    })
		},
		selectstreet:function(res){
				var that = this;				
				//区
				var countyid=that.coun.county_id;
				var coun_name=that.coun.county_name;
				that.sureinfo.county=coun_name;
				that.sureinfo.county_id=countyid;
				
					var url = '/AjaxPosition/town'
					var params = {
						county_id:countyid
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
                        var obstreet={
                            town_id:'000',
                            town_name:'街道'
                        };
                        res.data.unshift(obstreet);
                        that.street=res.data;
                        that.stre=that.street[0];
		    })
		},
		//街道
		select:function(res){
			var that=this;
			var town_id=that.stre.town_id;
			var town=that.stre.town_name;
			that.sureinfo.town=town;
			that.sureinfo.town_id=town_id;

		},
		//家乡省
		selfdetails: function() {
			var that = this;

            //默认家乡市
            var selfobcity={
                province_id:'000',
                city_name:'市'
            };
            that.selfcity.push(selfobcity);
            var len=that.selfcity.length;
            that.selfc=that.selfcity[len-1];
            //console.log( that.ci);

            //默认家乡区
            var selfobscounty={
                county_id:'000',
                county_name:'区'
            };
            that.selfcounty.push(selfobscounty);
            var len1=that.selfcounty.length;
            that.selfcoun=that.selfcounty[len1-1];

			var url = '/AjaxPosition/province'
			var params = {

			}
			ajaxsend(url, params, function(res) {
				/*console.log(JSON.stringify(res))*/
				console.log(res);
				var data=res.data;
				that.selfprovince=data;
				//console.log(that.selfprovince)

                //默认故乡省
                var selfob={
                    province_id:'000',
                    province_name:'省'
                }
                that.selfprovince.push(selfob);
                console.log(that.selfprovince);
                that.selfpro=that.selfprovince[31];
			})
		},
		//代言家乡省
		selfprove:function(){
			var that = this;
			//var el = event.currentTarget;
			//省
			var selfproce_name=that.selfpro.province_name;
			var selfprovinceid =that.selfpro.province_id;
			that.sureinfo.province=selfproce_name;
			that.sureinfo.province_id=selfprovinceid;			
			console.log(selfprovinceid)
			var url = '/AjaxPosition/city'
			var params = {
				province_id:selfprovinceid
			}
			ajaxsend(url, params, function(res) {
				/*console.log(JSON.stringify(res))*/
				console.log(res);
                var obcity={
                    province_id:'000',
                    city_name:'市'
                };
                res.data.unshift(obcity)
                that.selfcity=res.data;
                that.selfc=that.selfcity[0];
			})
		},

		//代言家乡市
		selfci:function(){
			var that = this;
				//市
				var selfci_name=that.selfc.city_name;
				var selfcityid=that.selfc.city_id;
				that.sureinfo.selfcity=selfci_name;
				that.sureinfo.selfcity_id= selfcityid;
					var url = '/AjaxPosition/county'
					var params = {
						city_id:selfcityid
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
						that.selfcounty=res.data;
						console.log(that.selfcounty);
		    })
		},
		//代言家乡区
		selfcou:function(){
			var that=this;
			var selfcountyid=that.selfcoun.county_id;
			var selfcoun_name=that.selfcoun.county_name;
			that.sureinfo.selfcounty=selfcoun_name;
			that.sureinfo.selfcounty_id=selfcountyid;
		},
		sure:function(){
			var that=this;
			var food=that.food;
			var county_id=that.sureinfo.county_id;
			var county=that.sureinfo.county;
			var province=that.sureinfo.province;
			var province_id=that.sureinfo.province_id;
			var city=that.sureinfo.city;
			var city_id=that.sureinfo.city_id;
			var town =that.sureinfo.town;
			var town_id=that.sureinfo.town_id;
			var f_province=that.sureinfo.selfprovince;
			var f_city=that.sureinfo.selfcounty;
			if(province==''){
				alert("请选择省");
				return false;
			}
			if(city==""){
				alert("请选择市");
				return false;
			}
			if(county==""){
				alert("请选择区");
				return false;
			}
			if(town==""){
				alert("请选择街道");
				return false;
			
			}
			if(that.detailaddress==""){
				alert("请选择详细地址");
				return false;
			}
			if(f_province){
				alert("请选择故乡省");
				return false;
			}
			if(f_city==""){
				alert("请选择家乡市");
				return false;
			}
            if(food==''){
               alert("请选择我最喜爱的家乡的美味") ;
                return false;
            }
			var url = '/Inquiry/submitInquiry'
					var params = {
						county_id:county_id,
						county: county,
						province:province,
						province_id:province_id,
						city:city,
						city_id:city_id,
						town:town,
						town_id:town_id,
						address:that.detailaddress,
						f_city:f_city,
						f_province:f_province,
						taste:that.answer1,
						frequency:that.frequency,
						food:that.food,
						unique_id: localStorage.getItem('unique_id'),	
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
						if(res.status==true){
							that.success=true;
							
						}else if(res.status==false){
							that.success=false;
							alert(res.msg)
						}

					})
		},
		
		//获取优惠券
		getcoupon:function(){
			var that = this;
					var url = '/Inquiry/getSuccessDiscountCoupon'
					var params = {
						
					}
					ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
						console.log(res);
						var data=res.data;
						that.discount_coupon_name=data.discount_coupon_name;
						that.discount_coupon_price=data.discount_coupon_price;
						that.textarea=data.textarea;
		
			
		    })
		},
		//领取优惠券
		recivecompoun:function(){
			var that=this;
			window.event.stopPropagation();
			var discount_coupon_name=that.discount_coupon_name;
			var discount_coupon_price=that.discount_coupon_price;
			var url = '/receiveInquiryDiscountCoupon'
			var params = {
					discount_coupon_name:discount_coupon_name,
					discount_coupon_price:discount_coupon_price,
					unique_id: localStorage.getItem('unique_id'),
					
			}
			ajaxsend(url, params, function(res) {
						/*console.log(JSON.stringify(res))*/
				console.log(res);
		    })
		}

	}
	
	
})

//$(function(){
//	var url = '/Inquiry/index'
//			var params = {
//				
//			}
//			ajaxsend(url, params, function(res) {
//				/*console.log(JSON.stringify(res))*/
//				console.log(res);
//				var data=res.data;
//				var part1=data.part1;
//				var part2=data.part2;
//				$(".edit").html(part1);
//				
//				$(".queation1").html(part2[0].content);
//				$(".question2").html(part2[1].content);
//				$(".queation3").html(part2[2].content);
//				var question4=part2[3].content;
//				console.log(question4);
//				var que=question4.split(' ');
//				console.log(que[0]);
//				$(".question4_title1").html(que[0]);
//				$(".question4_title2").html(que[1]);
//				$(".question4_title3").html(que[2]);
//				$(".question4_title1").html(part2[0].title)
//				$(".question4_title2").html(part2[1].title)
//				$(".question4_title3").html(part2[2].title)
//				$(".question4_title4").html(part2[3].title)
//				
//				
//				
//				
//			})
//})