|
|
@@ -710,9 +710,805 @@ var app = new Vue({
|
|
|
if(!_this.agree){
|
|
|
$.closeModal();
|
|
|
$.modal({
|
|
|
- id: "privacy",
|
|
|
+ id: "privacy",var app = new Vue({
|
|
|
+ 'el': '#app',
|
|
|
+ 'data': {
|
|
|
+ // 当前导航
|
|
|
+ curNav: 'member',
|
|
|
+ // 用户信息
|
|
|
+ wxInfo: {},
|
|
|
+ // 用户信息
|
|
|
+ content: {},
|
|
|
+ showContent: '内容加载中...',
|
|
|
+ // 信息
|
|
|
+ params: {
|
|
|
+ nickname: '',
|
|
|
+ mobile: '',
|
|
|
+ avatar: '',
|
|
|
+ sex: '',
|
|
|
+ birthday: '',
|
|
|
+ code: '',
|
|
|
+ height: '',
|
|
|
+ weight: '',
|
|
|
+ wechat_code: '',
|
|
|
+ now_address: '广西壮族自治区 南宁市 西乡塘区',
|
|
|
+ home_address: '广西壮族自治区 南宁市 西乡塘区',
|
|
|
+ married: '',
|
|
|
+ },
|
|
|
+ // 协议
|
|
|
+ agree: false,
|
|
|
+ // 文件
|
|
|
+ file: null,
|
|
|
+ options: {},
|
|
|
+ cropData: {},
|
|
|
+ cropParams: {},
|
|
|
+ // 上传弹窗
|
|
|
+ uploadBox: false,
|
|
|
+ submitting: {'sendcode': null, 'submit': null},
|
|
|
+ rebackurl: '',
|
|
|
+ time: 60,
|
|
|
+ timeText: '获取验证码',
|
|
|
+ timeId: null,
|
|
|
+ },
|
|
|
+ created: function(){
|
|
|
+ this.getInfo();
|
|
|
+ var rebackurl = getParam('rebackurl');
|
|
|
+ if(typeof (rebackurl) != 'undefined' && rebackurl != null){
|
|
|
+ this.rebackurl = rebackurl;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取历史数据
|
|
|
+ var params = sessionStorage.getItem('params')
|
|
|
+ params = typeof(params) != 'undefined' && params!= null? JSON.parse(params) : {};
|
|
|
+ if(params!='' && typeof(params.nickname)!='undefined'){
|
|
|
+ params.code = '';
|
|
|
+ params.birthday_code = typeof (params.birthday_code) != 'undefined'? params.birthday_code : '';
|
|
|
+ this.params = params;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ updated: function(){
|
|
|
+ var _this = this;
|
|
|
+
|
|
|
+ // 居住地
|
|
|
+ $("#now_address").val(_this.params.now_address);
|
|
|
+ $("#now_address").cityPicker({
|
|
|
+ title: "请选择现居地址",
|
|
|
+ onChange: function (picker, values, displayValues) {
|
|
|
+ _this.params.now_address = displayValues.join(' ');
|
|
|
+ // console.log(displayValues);
|
|
|
+ }
|
|
|
+ // showDistrict: false
|
|
|
+ });
|
|
|
+
|
|
|
+ // 家乡
|
|
|
+ $("#home_address").val(_this.params.home_address);
|
|
|
+ $("#home_address").cityPicker({
|
|
|
+ title: "请选择家乡地址",
|
|
|
+ onChange: function (picker, values, displayValues) {
|
|
|
+ _this.params.home_address = displayValues.join(' ');
|
|
|
+ // console.log(displayValues);
|
|
|
+ }
|
|
|
+ // showDistrict: false
|
|
|
+ });
|
|
|
+
|
|
|
+ // 性别
|
|
|
+ var sexs = ['男', '女'];
|
|
|
+ $.each(sexs, function (k, item) {
|
|
|
+ if (_this.params.sex == k+1) {
|
|
|
+ $("#sex").val(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $("#sex").picker({
|
|
|
+ title: "请选择性别",
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ textAlign: 'center',
|
|
|
+ value: _this.params.sex,
|
|
|
+ values: sexs,
|
|
|
+
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ onChange: function(data){
|
|
|
+ $("#sex").attr('data-code',data.cols[0].activeIndex+1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 身高
|
|
|
+ var heightArr = [];
|
|
|
+ for(var i=1; i<=70; i++){
|
|
|
+ if (parseInt(_this.params.height) == i + 145) {
|
|
|
+ $("#height").val((145 + i).toString() + 'cm');
|
|
|
+ //$("#height").attr('data-code', (145 + i).toString());
|
|
|
+ }
|
|
|
+ heightArr.push((145+i).toString()+'cm');
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#height").picker({
|
|
|
+ title: "请选择身高",
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ textAlign: 'center',
|
|
|
+ values: heightArr,
|
|
|
+ onChange: function(data){
|
|
|
+ var code = data.cols[0].value;
|
|
|
+ $("#height").attr('data-code', code.replace('cm',''));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ // 体重
|
|
|
+ var weightArr = [];
|
|
|
+ for(var i=0; i<=80; i++){
|
|
|
+ if (parseInt(_this.params.weight) == i+40) {
|
|
|
+ $("#weight").val((40 + i).toString() + 'KG');
|
|
|
+ //$("#weight").attr('data-code', (40 + i).toString());
|
|
|
+ }
|
|
|
+ weightArr.push((40+i).toString()+'KG');
|
|
|
+ }
|
|
|
+ $("#weight").val(_this.params.weight? _this.params.weight+'kg' : '')
|
|
|
+ $("#weight").picker({
|
|
|
+ title: "请选择体重",
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ textAlign: 'center',
|
|
|
+ values: weightArr,
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ onChange: function(data){
|
|
|
+ var code = data.cols[0].value;
|
|
|
+ $("#weight").attr('data-code', code.replace('KG',''));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 生日
|
|
|
+ var years = [];
|
|
|
+ var date = new Date();
|
|
|
+ var year = date.getFullYear()-20;
|
|
|
+ for(var i=20;i>=0;i--){
|
|
|
+ years.push(year-i);
|
|
|
+ }
|
|
|
+ var code = $("#birthday").val();
|
|
|
+ _this.params.birthday = _this.params.birthday? $.trim(_this.params.birthday)+' ' : (code? code : (year-10)+'-01-01 ');
|
|
|
+ _this.params.birthday_code = _this.params.birthday? $.trim(_this.params.birthday)+' ' : (code? code : (year-10)+'-01-01 ');
|
|
|
+ console.log(_this.params)
|
|
|
+ $("#birthday").val(_this.params.birthday_code);
|
|
|
+ $("#birthday").datetimePicker({
|
|
|
+ title: '请选择出生日期',
|
|
|
+ dateFormat: 'yyyy-mm-dd',
|
|
|
+ years: years,
|
|
|
+ yearSplit: '-',
|
|
|
+ monthSplit: '-',
|
|
|
+ value: _this.params.birthday,
|
|
|
+ // dateSplit: '-',
|
|
|
+ times: function(){
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 婚姻状况
|
|
|
+ var marrieds = ['未婚', '离异','离异有小孩']
|
|
|
+ $.each(marrieds, function (k, item) {
|
|
|
+ if (_this.params.married == k + 1) {
|
|
|
+ $("#married").val(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $("#married").picker({
|
|
|
+ title: "请选择婚姻状况",
|
|
|
+ cols: [
|
|
|
+ {
|
|
|
+ textAlign: 'center',
|
|
|
+ value: _this.params.married,
|
|
|
+ values: marrieds,
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ onChange: function(data){
|
|
|
+ // _this.params.married = data.cols[0].activeIndex+1;
|
|
|
+ $("#married").attr('data-code',data.cols[0].activeIndex+1);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 显示头像弹窗
|
|
|
+ showPop: function(){
|
|
|
+ if(this.uploadBox){
|
|
|
+ this.uploadBox = false;
|
|
|
+ $("body").css('overflowY','auto');
|
|
|
+ }else{
|
|
|
+ this.uploadBox = true;
|
|
|
+ $("body").css('overflowY','hidden');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ showPopup: function(title,type){
|
|
|
+ var _this = this;
|
|
|
+ $.showLoading("数据加载中...");
|
|
|
+ _this.content.title = title
|
|
|
+ $.closePopup()
|
|
|
+ $("body").css('overflowY', 'hidden');
|
|
|
+ // setTimeout(function(){
|
|
|
+ $.hideLoading();
|
|
|
+ _this.showContent = "<iframe src=\"/weixin/page/"+type+"\" style=\"width:100%;height:100%;\"></iframe>"
|
|
|
+ $("#popupBox").popup();
|
|
|
+ },
|
|
|
+ hidePopup: function(){
|
|
|
+ this.content = {}
|
|
|
+ $.closePopup()
|
|
|
+ $("body").css('overflowY', 'scroll');
|
|
|
+ this.showContent = '内容加载中...'
|
|
|
+ //$("#popupBox").hide();
|
|
|
+ },
|
|
|
+ // 获取用户信息
|
|
|
+ getInfo: function(){
|
|
|
+ var _this = this;
|
|
|
+ $.showLoading("数据加载中...");
|
|
|
+ $.post('/api/index/getWxInfo',{}, function(res){
|
|
|
+ $.hideLoading();
|
|
|
+ if(res.code == 'success'){
|
|
|
+ _this.wxInfo = res.data;
|
|
|
+ _this.params.avatar = _this.wxInfo.headimgurl;
|
|
|
+ _this.params.nickname = _this.wxInfo.nickname;
|
|
|
+ _this.params.sex = typeof (_this.wxInfo.sex) !='undefined' &&_this.wxInfo.sex? _this.wxInfo.sex : 1;
|
|
|
+ }
|
|
|
+ }, "json");
|
|
|
+ },
|
|
|
+ // 发送验证码
|
|
|
+ sendCode: function(){
|
|
|
+ var _this = this;
|
|
|
+ if(_this.submitting.sendcode){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ _this.params.mobile = $.trim($("#mobile").val());
|
|
|
+ if(_this.params.mobile == '' || _this.params.mobile == null){
|
|
|
+ $.toast('请填写手机号','text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var patternMobile = /^(1[3-9][0-9]{9})$/;
|
|
|
+ if (!patternMobile.test(_this.params.mobile)) {
|
|
|
+ $.toast("请填写正确格式的手机号码", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ _this.submitting.sendcode = true;
|
|
|
+
|
|
|
+ // 发送验证码
|
|
|
+ $.showLoading('提交中');
|
|
|
+ $.post('/api/sms/sendCode',{mobile: _this.params.mobile}, function(res){
|
|
|
+ $.hideLoading();
|
|
|
+ if(res.code == 'success'){
|
|
|
+ _this.timeLock();
|
|
|
+ }else{
|
|
|
+ _this.submitting.sendcode = false;
|
|
|
+ }
|
|
|
+ $.toast(res.message, 'text');
|
|
|
+
|
|
|
+ }, "json");
|
|
|
+ },
|
|
|
+ // 倒计时
|
|
|
+ timeLock: function(){
|
|
|
+ var _this = this;
|
|
|
+ _this.timeId = setInterval(function(){
|
|
|
+ _this.time--;
|
|
|
+ // _this.timeText = _this.time+'s';
|
|
|
+ $("#btnSendCode").val(_this.time+'s')
|
|
|
+ if(_this.time<=0){
|
|
|
+ _this.time = 60;
|
|
|
+ //_this.timeText = '获取验证码';
|
|
|
+ $("#btnSendCode").val('获取验证码')
|
|
|
+ _this.submitting.sendcode = false;
|
|
|
+ clearInterval(_this.timeId)
|
|
|
+ }
|
|
|
+
|
|
|
+ }, 1000);
|
|
|
+ },
|
|
|
+ // 选择图片
|
|
|
+ selectImg: function(ele, previewId){
|
|
|
+ var _this = this;
|
|
|
+ var selectFile = ele.target.files[0];
|
|
|
+ if (selectFile) {
|
|
|
+ var reader = new FileReader();
|
|
|
+ reader.readAsDataURL(selectFile);
|
|
|
+ reader.onloadend = function (even) {
|
|
|
+ //_this.file = selectFile;
|
|
|
+ // _this.showPop();
|
|
|
+ $('#preview_' + previewId).attr('src', even.currentTarget.result);
|
|
|
+ $('#preview_' + previewId).attr('old-src', even.currentTarget.result);
|
|
|
+ _this.picEdit(previewId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ picEdit: function (id) {
|
|
|
+ var _this = this;
|
|
|
+ $.closePopup();
|
|
|
+ var src = $('#preview_' + id).attr('src');
|
|
|
+ if (src == '') {
|
|
|
+ $.toast('请重新选择图片');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ _this.showPop();
|
|
|
+ $("#cropPreview").hide();
|
|
|
+ $("#preview_box").show();
|
|
|
+ $("body").css('overflowY', 'hidden');
|
|
|
+ $image = $('#preview_' + id);
|
|
|
+ $image.attr('src', src);
|
|
|
+ $image.attr('data-src', src);
|
|
|
+ var width = $("body").outerWidth() * 0.85;
|
|
|
+ var height = (425 / 343) * width;
|
|
|
+
|
|
|
+ var _image = new Image();
|
|
|
+ _image.src = src;
|
|
|
+ var iWidth = _image.width;
|
|
|
+ var iHeight = _image.height;
|
|
|
+ var rate = iWidth/iHeight;
|
|
|
+ $(".preview-box").css('width', width);
|
|
|
+ $(".preview-box").css('height', height);
|
|
|
+ $(".crop-preview .desc").css('width', width);
|
|
|
+ $("#cropBox").popup();
|
|
|
+ $.showLoading('图片加载中')
|
|
|
+ _this.options = {
|
|
|
+ aspectRatio: 0,
|
|
|
+ center: true,
|
|
|
+ movable: true,
|
|
|
+ zoomable: true,
|
|
|
+ zoomOnTouch: true,
|
|
|
+ zoomOnWheel: false,
|
|
|
+ scalable: true,
|
|
|
+ wheelZoomRatio: 0.1,
|
|
|
+ background: false,
|
|
|
+ responsive: true,
|
|
|
+ guides: false,
|
|
|
+ strict: false,
|
|
|
+ width: width,
|
|
|
+ dragMode: 'move',
|
|
|
+ height: height,
|
|
|
+ autoCropArea: 1,
|
|
|
+ cropBoxMovable: false,
|
|
|
+ cropBoxResizable: false,
|
|
|
+ minContainerWidth: width,
|
|
|
+ minContainerHeight: height,
|
|
|
+ minCropBoxWidth: width,
|
|
|
+ maxCropBoxWidth: width,
|
|
|
+ minCropBoxHeight: height,
|
|
|
+ maxCropBoxHeight: height,
|
|
|
+ minCanvasWeight: width,
|
|
|
+ maxCanvasWeight: width,
|
|
|
+ minCanvasHeight: height,
|
|
|
+ maxCanvasHeight: height,
|
|
|
+ viewMode: 1,
|
|
|
+ ready: function () {
|
|
|
+ $.hideLoading();
|
|
|
+ },
|
|
|
+ crop: function (data) {
|
|
|
+ $.hideLoading();
|
|
|
+ _this.cropData = data
|
|
|
+ $(".cropper-container img").attr('id', 'cropimg');
|
|
|
+ $("#cropPreview").html('<div class="cropper-container" style="width: '+width+'px; height: '+height+'px;">'+$(".cropper-container").html()+'</div>');
|
|
|
+ var cropHeight = $(".cropper-view-box img").height();
|
|
|
+ var cropWidth = $(".cropper-view-box img").width();
|
|
|
+ var marginLeft = cropWidth>width? -(cropWidth-width)/2 : 0;
|
|
|
+ var marginTop = cropHeight>height? -(cropHeight-height)/2 : 0;
|
|
|
+ $("#cropPreview .cropper-view-box img").css('marginLeft', marginLeft+'px');
|
|
|
+ $("#cropPreview .cropper-view-box img").css('marginTop', marginTop+'px');
|
|
|
+ $("#cropPreview .cropper-dashed").remove();
|
|
|
+ $("#cropPreview .cropper-face").remove();
|
|
|
+ $("#cropPreview .cropper-line").remove();
|
|
|
+ $("#cropPreview .cropper-point").remove();
|
|
|
+ _this.cropParams = {
|
|
|
+ width: data.height,
|
|
|
+ height: data.width,
|
|
|
+ rotate: data.rotate,
|
|
|
+ imageSmoothingQuality: 'high',
|
|
|
+ fillColor: '#fff',
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_this.jc != null) {
|
|
|
+ $image.cropper(_this.options);
|
|
|
+ $image.cropper('replace', src);
|
|
|
+ } else {
|
|
|
+ $image.cropper(_this.options);
|
|
|
+ _this.jc = $image.cropper('replace', src);
|
|
|
+ }
|
|
|
+
|
|
|
+ _image.onload = function(){
|
|
|
+ rate = 0;
|
|
|
+ iWidth = _image.width;
|
|
|
+ iHeight = _image.height;
|
|
|
+ if((iWidth<iHeight*0.9 || iHeight<iWidth*0.9)){
|
|
|
+ if(iWidth/iHeight < width/height){
|
|
|
+ rate = parseFloat((width/height)/(iWidth/iHeight)).toFixed(2);
|
|
|
+ }else{
|
|
|
+ rate = parseFloat(0.1*((height/width)/(iHeight/iWidth)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(function(){
|
|
|
+ if(rate>0){
|
|
|
+ $image.cropper('zoom', rate);
|
|
|
+ }
|
|
|
+ var cropHeight = $(".cropper-view-box img").height();
|
|
|
+ var cropWidth = $(".cropper-view-box img").width();
|
|
|
+ var marginLeft = cropWidth>width? -(cropWidth-width)/2 : (width-cropWidth)/2;
|
|
|
+ var marginTop = cropHeight>height? -(cropHeight-height)/2 : (height-cropHeight)/2;
|
|
|
+ if(marginLeft != 0){
|
|
|
+ $(".cropper-view-box img").css('marginLeft', marginLeft+'px');
|
|
|
+ }
|
|
|
+
|
|
|
+ $(".cropper-view-box img").css('marginTop', marginTop+'px');
|
|
|
+
|
|
|
+ }, 50)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 取消
|
|
|
+ cropCancel: function(){
|
|
|
+ this.showPop();
|
|
|
+ $("#upload").val("");
|
|
|
+ $("body").css('overflowY', 'scroll');
|
|
|
+ $.closePopup();
|
|
|
+ },
|
|
|
+ // 重置
|
|
|
+ cropReset: function (id) {
|
|
|
+ $image = $("#preview_" + id);
|
|
|
+ var src = $image.attr('old-src');
|
|
|
+ $image.cropper(this.options);
|
|
|
+ this.jc = $image.cropper('replace', src);
|
|
|
+
|
|
|
+ var _image = new Image();
|
|
|
+ _image.src = src;
|
|
|
+ var iWidth = _image.width;
|
|
|
+ var iHeight = _image.height;
|
|
|
+ var width = $("body").outerWidth() * 0.9;
|
|
|
+ var height = (425 / 343) * width;
|
|
|
+ _image.onload = function(){
|
|
|
+ var rate = 0;
|
|
|
+ iWidth = _image.width;
|
|
|
+ iHeight = _image.height;
|
|
|
+ if((iWidth<iHeight*0.9 || iHeight<iWidth*0.9)){
|
|
|
+ if(iWidth/iHeight < width/height){
|
|
|
+ rate = parseFloat((width/height)/(iWidth/iHeight)).toFixed(2);
|
|
|
+ }else{
|
|
|
+ rate = parseFloat(0.1*((height/width)/(iHeight/iWidth)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ setTimeout(function(){
|
|
|
+ if(rate){
|
|
|
+ $image.cropper('zoom', rate);
|
|
|
+ }
|
|
|
+ var cropHeight = $(".cropper-view-box img").height();
|
|
|
+ var cropWidth = $(".cropper-view-box img").width();
|
|
|
+ var marginLeft = cropWidth>width? -(cropWidth-width)/2 : 0;
|
|
|
+ var marginTop = cropHeight>height? -(cropHeight-height)/2 : 0;
|
|
|
+ $(".cropper-view-box img").css('marginLeft', marginLeft+'px');
|
|
|
+ $(".cropper-view-box img").css('marginTop', marginTop+'px');
|
|
|
+ }, 50)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 完成
|
|
|
+ cropConfirm: function (id) {
|
|
|
+ var _this = this;
|
|
|
+ if (this.jc != null) {
|
|
|
+ if(!_this.cropParams){
|
|
|
+ $.toast('请先处理图片','text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $image = $("#preview_" + id);
|
|
|
+ $.showLoading('图片处理中...');
|
|
|
+ $("#cropPreview").show();
|
|
|
+ $("#preview_box").hide();
|
|
|
+ //console.log(_this.cropParams);
|
|
|
+ var canvas = $image.cropper('getCroppedCanvas', _this.cropParams);
|
|
|
+ var url = canvas.toBlob(function (e) {
|
|
|
+ if (e != null && _this.cropData.y > 0) {
|
|
|
+ console.log("剪裁方式");
|
|
|
+ var timestamp = Date.parse(new Date());
|
|
|
+ e.name = timestamp + ".jpeg";
|
|
|
+ url = URL.createObjectURL(e);
|
|
|
+ _this.file = _this.dataURLtoFile(e, e.name);
|
|
|
+ $image.attr('data-src', url);
|
|
|
+ $("body").css('overflowY', 'scroll');
|
|
|
+ setTimeout(function () {
|
|
|
+ $.hideLoading();
|
|
|
+ $.closePopup();
|
|
|
+ $(id).cropper('destroy');
|
|
|
+ $('#' + id).attr('src', $image.attr('data-src'));
|
|
|
+ $("#upload").val("");
|
|
|
+ _this.jc = null;
|
|
|
+ }, 200);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ console.log("合成方式");
|
|
|
+ var width = $("body").outerWidth() * 0.9;
|
|
|
+ var height = (425 / 343) * width;
|
|
|
+ var opts = {
|
|
|
+ width: width,
|
|
|
+ height: height,
|
|
|
+ scale: 5,
|
|
|
+ background: '#fff',
|
|
|
+ useCROS: true,
|
|
|
+ };
|
|
|
+
|
|
|
+ var _image = document.getElementById('cropPreview');
|
|
|
+ html2canvas(_image, opts).then(function (canvas) {
|
|
|
+ const context = canvas.getContext('2d');
|
|
|
+ context.translate(0.5, 0.5);
|
|
|
+ context.mozImageSmoothingEnabled = false;
|
|
|
+ context.webkitImageSmoothingEnabled = false;
|
|
|
+ context.msImageSmoothingEnabled = false;
|
|
|
+ context.imageSmoothingEnabled = false;
|
|
|
+
|
|
|
+ var src = canvas.toDataURL('image/jpeg');
|
|
|
+ var timestamp = Date.parse(new Date());
|
|
|
+ var name = timestamp + ".jpeg";
|
|
|
+ _this.file = _this.dataURLtoFile1(src, name ? name : 'avatar.jpeg');
|
|
|
+ $image.attr('data-src', url);
|
|
|
+ $("body").css('overflowY', 'scroll');
|
|
|
+ setTimeout(function () {
|
|
|
+ $.hideLoading();
|
|
|
+ $.closePopup();
|
|
|
+ $(id).cropper('destroy');
|
|
|
+ $('#' + id).attr('src', src);
|
|
|
+ $("#upload").val("");
|
|
|
+ _this.jc = null;
|
|
|
+ }, 200);
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ }, "image/jpeg");
|
|
|
+ } else {
|
|
|
+ $.toast('处理失败请刷新重试','text');
|
|
|
+ $.closePopup();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // base转文件
|
|
|
+ dataURLtoFile: function (dataurl, filename) {//将base64转换为文件
|
|
|
+ return new File([dataurl], filename, {type: 'image/jpeg'});
|
|
|
+ },
|
|
|
+ //
|
|
|
+ dataURLtoFile1: function (dataurl, filename) {//将base64转换为文件
|
|
|
+ var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1],
|
|
|
+ bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n);
|
|
|
+ while (n--) {
|
|
|
+ u8arr[n] = bstr.charCodeAt(n);
|
|
|
+ }
|
|
|
+ return new File([u8arr], filename, {type: mime});
|
|
|
+ },
|
|
|
+ // blob处理
|
|
|
+ processData: function (dataUrl) {
|
|
|
+ var binaryString = window.atob(dataUrl.split(',')[1]);
|
|
|
+ var arrayBuffer = new ArrayBuffer(binaryString.length);
|
|
|
+ var intArray = new Uint8Array(arrayBuffer);
|
|
|
+ for (var i = 0, j = binaryString.length; i < j; i++) {
|
|
|
+ intArray[i] = binaryString.charCodeAt(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ var data = [intArray],
|
|
|
+ blob;
|
|
|
+
|
|
|
+ try {
|
|
|
+ blob = new Blob(data);
|
|
|
+ } catch (e) {
|
|
|
+ window.BlobBuilder = window.BlobBuilder ||
|
|
|
+ window.WebKitBlobBuilder ||
|
|
|
+ window.MozBlobBuilder ||
|
|
|
+ window.MSBlobBuilder;
|
|
|
+ if (e.name === 'TypeError' && window.BlobBuilder) {
|
|
|
+ var builder = new BlobBuilder();
|
|
|
+ builder.append(arrayBuffer);
|
|
|
+ blob = builder.getBlob(imgType); // imgType为上传文件类型,即 file.type
|
|
|
+ } else {
|
|
|
+ console.log('版本过低,不支持上传图片');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return blob;
|
|
|
+ },
|
|
|
+ // 提交数据
|
|
|
+ postSubmit: function(){
|
|
|
+ var _this = this;
|
|
|
+ var params = _this.params;
|
|
|
+ // var params = JSON.parse(JSON.stringify(_this.params));
|
|
|
+ if(_this.submitting.submit){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var sex = $("#sex").attr('data-code');
|
|
|
+ if(typeof(sex) != 'undefined'){
|
|
|
+ params.sex = sex;
|
|
|
+ }
|
|
|
+ var height = $("#height").attr('data-code');
|
|
|
+ if(typeof(height) != 'undefined'){
|
|
|
+ params.height = height;
|
|
|
+ }
|
|
|
+ var weight = $("#weight").attr('data-code');
|
|
|
+ if(typeof(weight) != 'undefined'){
|
|
|
+ params.weight = weight;
|
|
|
+ }
|
|
|
+ params.nickname = $.trim($("#nickname").val());
|
|
|
+ params.wechat_code = $.trim($("#wechat_code").val());
|
|
|
+ params.mobile = $.trim($("#mobile").val());
|
|
|
+ params.code = $.trim($("#code").val());
|
|
|
+ params.birthday = $("#birthday").val();
|
|
|
+ params.now_address = $("#now_address").val();
|
|
|
+ params.home_address = $("#home_address").val();
|
|
|
+ params.married = $("#married").attr('data-code');
|
|
|
+ params.sex = $("#sex").attr('data-code');
|
|
|
+ //console.log(params);
|
|
|
+ // alert(JSON.stringify(_this.params));
|
|
|
+ if(_this.file == '' || _this.file == null){
|
|
|
+ $.toast("请上传真实头像", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.nickname == ''){
|
|
|
+ params.nickname = _this.wxInfo.nickname;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.nickname == '' || params.nickname == null){
|
|
|
+ $.toast("请填写昵称", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*if(_this.params.realname == '' || _this.params.realname == null){
|
|
|
+ $.toast("请填写真实姓名", 'text');
|
|
|
+ return false;
|
|
|
+ }*/
|
|
|
+
|
|
|
+ if(params.wechat_code == '' || params.wechat_code == null){
|
|
|
+ $.toast("请填写微信号", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.mobile == '' || params.mobile == null){
|
|
|
+ $.toast("请填写手机号", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ var pattMobile = /^(1[3-9][0-9]{9})$/;
|
|
|
+ if(!pattMobile.test(params.mobile)){
|
|
|
+ $.toast("请填写正确格式的手机号", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if(params.code == '' || params.code == null){
|
|
|
+ $.toast("请填写短信验证码", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var pattCode = /^[0-9]{4,6}$/;
|
|
|
+ if(!pattCode.test(params.code)){
|
|
|
+ $.toast("请填写正确格式的短信验证码", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.birthday <=0 || params.birthday == '' || params.birthday == null){
|
|
|
+ $.toast("请选择您的出生日期", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.sex <=0 || params.sex == ''){
|
|
|
+ $.toast("请选择您的性别", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.height <=0 || params.height == ''){
|
|
|
+ $.toast("请选择您的身高", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.weight <=0 || params.weight == ''){
|
|
|
+ $.toast("请选择您的体重", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.now_address == '' || params.now_address == null){
|
|
|
+ $.toast("请选择您的现居地址", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.home_address == '' || params.home_address == null){
|
|
|
+ $.toast("请选择您的家乡地址", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(params.married <= 0 || params.married == ''){
|
|
|
+ $.toast("请选择您的婚姻状况", 'text');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ sessionStorage.setItem('params', JSON.stringify(params))
|
|
|
+ if(!_this.agree){
|
|
|
+ $.closeModal();
|
|
|
+ $.modal({
|
|
|
+ id: "privacy",
|
|
|
+ title: "温馨提示",
|
|
|
+ text: '<div class="tips"><p>非常感谢您对拾光婚恋平台的信任和支持,为了保证平台用户能够在安全的环境中使用该平台,共同营造出真诚靠谱的交友环境,请您仔细阅读并同意相关条款。</p><br><p><a data-type="privacy">《用户服务协议》</a></p><p><a data-type="agree">《隐私保护政策》</a></div>',
|
|
|
+ buttons: [
|
|
|
+ {
|
|
|
+ text: "不同意", className: "default", onClick: function () {
|
|
|
+ _this.agree = false;
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },{
|
|
|
+ text: "同意", className: "success", onClick: function () {
|
|
|
+ _this.agree = true;
|
|
|
+ _this.postSubmit();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }]
|
|
|
+ });
|
|
|
+
|
|
|
+ $(".tips p a ").on('click',function (){
|
|
|
+ var type = $(this).attr('data-type');
|
|
|
+ var title = $(this).text();
|
|
|
+ _this.showPopup(title,type);
|
|
|
+ })
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ var formData = new FormData();
|
|
|
+ $.each(params, function(k,item){
|
|
|
+ formData.append(k, item);
|
|
|
+ })
|
|
|
+
|
|
|
+ if(_this.file != null){
|
|
|
+ formData.append('image', _this.file);
|
|
|
+ }
|
|
|
+
|
|
|
+ _this.agree = false;
|
|
|
+ _this.submitting.submit = true;
|
|
|
+ $.showLoading('数据保存中...');
|
|
|
+ $.ajax({
|
|
|
+ url: '/api/member/setProfile',
|
|
|
+ data: formData,
|
|
|
+ type: "post",
|
|
|
+ dataType: 'json',
|
|
|
+ cache : false,
|
|
|
+ contentType : false,
|
|
|
+ processData : false,
|
|
|
+ success: function(res) {
|
|
|
+ $.hideLoading();
|
|
|
+ _this.submitting.submit = false;
|
|
|
+ if(res.code == 'success'){
|
|
|
+ $.showLoading(res.message);
|
|
|
+ setTimeout(function(){
|
|
|
+ location.href = '/weixin/member/info';
|
|
|
+ }, 500)
|
|
|
+ }else if (res.code == 'login'){
|
|
|
+ var url = res.data.url;
|
|
|
+ $.showLoading(res.message);
|
|
|
+ if(url){
|
|
|
+ setTimeout(function(){
|
|
|
+ location.href = url;
|
|
|
+ }, 500)
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ res.message = typeof(res.message) != 'undefined' && res.message? res.message : '提交失败,请刷新重试';
|
|
|
+ $.toast(res.message,'text');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error:function (res) {
|
|
|
+ res.message = typeof(res.message) != 'undefined' && res.message? res.message : '提交失败,请刷新重试';
|
|
|
+ _this.submitting.submit = false;
|
|
|
+ $.toast(res.message,'text');
|
|
|
+ $.hideLoading();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
title: "温馨提示",
|
|
|
- text: '<div class="tips"><p>非常感谢您对拾光婚恋平台的信任和支持,为了保证平台用户能够在安全的环境中使用该平台,共同营造出真诚靠谱的交友环境,请您仔细阅读并同意相关条款。</p><br><p><a data-type="privacy">《用户服务协议》</a></p><p><a data-type="marketAgree">《隐私保护政策》</a></div>',
|
|
|
+ text: '<div class="tips"><p>非常感谢您对拾光婚恋平台的信任和支持,为了保证平台用户能够在安全的环境中使用该平台,共同营造出真诚靠谱的交友环境,请您仔细阅读并同意相关条款。</p><br><p><a data-type="privacy">《用户服务协议》</a></p><p><a data-type="agree">《隐私保护政策》</a></div>',
|
|
|
buttons: [
|
|
|
{
|
|
|
text: "不同意", className: "default", onClick: function () {
|