| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- var app = new Vue({
- el: '#app',
- data: {
- submitStatus: false,
- shopInfo: {},
- // 会员信息
- memberInfo: {},
- // 提交状态
- submitting: false,
- // 分类数据
- cates: [],
- // 二级分类数据
- subCates: [],
- map: null,
- },
- created: function () {
- this.getCates();
- },
- mounted: function () {
- // 地区
- $("#city-picker").cityPicker({
- title: "请选择地区",
- });
- },
- methods: {
- // 加载地图
- showMap: function(){
- var _this = this;
- var lng = _this.shopInfo.lng>0? _this.shopInfo.lng : '108.360806';
- var lat = _this.shopInfo.lat>0? _this.shopInfo.lat : '22.819143';
- $("#modal").popup();
- var map = new BMap.Map('map');
- var poi = new BMap.Point(lng, lat);
- map.enableScrollWheelZoom();
- map.centerAndZoom(poi, 12);
- var mark = new BMap.Marker(poi);
- map.addOverlay(mark);
- mark.addEventListener("dragend", showInfo);
- mark.enableDragging(); //可拖拽
- /*map.addEventListener("mousemove",function(e){
- console.log(e.point)
- poi = new BMap.Point(e.point.lng, e.point.lat);
- mark = new BMap.Marker(poi);
- mark.addEventListener("dragend", showInfo);
- mark.enableDragging(); //可拖拽
- _this.shopInfo.lng = e.point.lng;
- _this.shopInfo.lat = e.point.lat;
- });*/
- map.addEventListener("click",function(e){
- poi = new BMap.Point(e.point.lng, e.point.lat);
- mark = new BMap.Marker(poi);
- mark.addEventListener("dragend", showInfo);
- mark.enableDragging(); //可拖拽
- _this.shopInfo.lng = e.point.lng;
- _this.shopInfo.lat = e.point.lat;
- });
- // 获取地址信息
- function showInfo(e){
- console.log(e)
- var gc = new BMap.Geocoder();
- gc.getLocation(e.point, function(rs){
- var addComp = rs.addressComponents;
- var address = addComp.province + addComp.city + addComp.district + addComp.street + addComp.streetNumber;//获取地址
- _this.shopInfo.address = address;
- alert(addComp);
- console.log(_this.shopInfo)
- console.log(addComp)
- });
- }
- },
- // 隐藏地图
- hideMap: function(){
- $.closePopup();
- },
- // 获取申请信息
- getShopInfo: function(){
- var _this = this;
- $.post('/weixin/shop/getInfo', {}, function (res) {
- if (res.code == 'success') {
- _this.shopInfo = res.data
- if (!_this.shopInfo) {
- shopInfo = sessionStorage.getItem('shopInfo');
- _this.shopInfo = shopInfo? JSON.parse(shopInfo) : {};
- }
- } else if (res.code == 'login') {
- login(res.data.url);
- }
- _this.catePicker(false);
- }, "json");
- },
- // 获取分类
- getCates: function () {
- var _this = this;
- $.post('/weixin/shop/getCates', {}, function (res) {
- if (res.code == 'success') {
- _this.cates = res.data
- // 初始化数据
- _this.getShopInfo();
- } else if (res.code == 'login') {
- login(res.data.url);
- }
- }, "json");
- },
- // 提交
- doSubmit: function () {
- var _this = this;
- if (_this.submitting) {
- return false;
- }
- if(_this.shopInfo.name == '' || _this.shopInfo.name == null){
- $.toast('请填写店铺名称','text');
- return false;
- }
- if(_this.shopInfo.business_project == '' || _this.shopInfo.business_project == null){
- $.toast('请填写主营项目','text');
- return false;
- }
- if(_this.shopInfo.cate1 == 0 || _this.shopInfo.cate2 == 0){
- $.toast('请选择主营分类','text');
- return false;
- }
- if(_this.shopInfo.contact_name == '' || _this.shopInfo.contact_name == null){
- $.toast('请填写联系人','text');
- return false;
- }
- if(_this.shopInfo.mobile == '' || _this.shopInfo.mobile == null){
- $.toast('请填写手机号','text');
- return false;
- }
- var mobilePatt = /^1[3-9][0-9]{9}$/;
- if(!mobilePatt.test(_this.shopInfo.mobile)){
- $.toast('手机号格式错误','text');
- return false;
- }
- _this.shopInfo.address = $("#city-picker").val();
- if(_this.shopInfo.address == '' || _this.shopInfo.address == null){
- $.toast('请选择所在地区','text');
- return false;
- }
- var formData = new FormData();
- _this.shopInfo.city_codes = $("#city-picker").attr('data-codes');
- $.each(_this.shopInfo, function ($k, $item) {
- formData.append($k,$item);
- })
- sessionStorage.setItem('shopInfo', JSON.stringify(_this.shopInfo));
- var logo = $("#logo")[0].files[0];
- if(logo == null || logo == ''){
- $.toast('请先上传店铺LOGO','text');
- return false;
- }
- var idcard_front = $("#idcard_front")[0].files[0];
- if(idcard_front == null || idcard_front == ''){
- $.toast('请先上传身份证正面','text');
- return false;
- }
- var idcard_back = $("#idcard_back")[0].files[0];
- if(idcard_back == null || idcard_back == ''){
- $.toast('请先上传身份证反面','text');
- return false;
- }
- var business_img = $("#business_img")[0].files[0];
- if(business_img == null || business_img == ''){
- $.toast('请先上传营业执照','text');
- return false;
- }
- formData.append('logo', logo);
- formData.append('idcard_front', idcard_front);
- formData.append('idcard_back', idcard_back);
- formData.append('business_img', business_img);
- var agree = $("#agree").is(":checked") ? true : false;
- if (!agree) {
- $.toast('请先阅读店铺入驻协议并确定', 'text');
- return false;
- }
- if (confirm('确定提交该店铺入驻申请?')) {
- $.showLoading('申请提交...');
- $.ajax({
- url: '/weixin/shop/applySubmit',
- type: "post",
- dataType: 'json',
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- success: function (res) {
- $.hideLoading();
- if (res.code == 'success') {
- sessionStorage.setItem('shopInfo', null);
- $.toast('入驻申请提交成功,请耐心等候审核...');
- setTimeout(function () {
- location.href = '/weixin/news/index';
- }, 800);
- } else if (res.code == 'login') {
- login(res.data.url);
- }else{
- $.toast(res.message,'text');
- }
- }
- });
- }
- },
- // 提交
- doSave: function () {
- var _this = this;
- if (_this.submitting) {
- return false;
- }
- if(_this.shopInfo.name == '' || _this.shopInfo.name == null){
- $.toast('请填写店铺名称','text');
- return false;
- }
- if(_this.shopInfo.business_project == '' || _this.shopInfo.business_project == null){
- $.toast('请填写主营项目','text');
- return false;
- }
- if(_this.shopInfo.cate1 == 0 || _this.shopInfo.cate2 == 0){
- $.toast('请选择主营分类','text');
- return false;
- }
- if(_this.shopInfo.contact_name == '' || _this.shopInfo.contact_name == null){
- $.toast('请填写联系人','text');
- return false;
- }
- if(_this.shopInfo.mobile == '' || _this.shopInfo.mobile == null){
- $.toast('请填写手机号','text');
- return false;
- }
- var mobilePatt = /^1[3-9][0-9]{9}$/;
- if(!mobilePatt.test(_this.shopInfo.mobile)){
- $.toast('手机号格式错误','text');
- return false;
- }
- _this.shopInfo.area = $("#city-picker").val();
- if(_this.shopInfo.area == '' || _this.shopInfo.area == null){
- $.toast('请选择所在地区','text');
- return false;
- }
- if(_this.shopInfo.address == '' || _this.shopInfo.address == null){
- $.toast('请选择店铺定位地址','text');
- return false;
- }
- var formData = new FormData();
- _this.shopInfo.city_codes = $("#city-picker").attr('data-codes');
- $.each(_this.shopInfo, function ($k, $item) {
- formData.append($k,$item);
- })
- sessionStorage.setItem('shopInfo', JSON.stringify(_this.shopInfo));
- var logo = $("#logo")[0].files[0];
- var idcard_front = $("#idcard_front")[0].files[0];
- var idcard_back = $("#idcard_back")[0].files[0];
- var business_img = $("#business_img")[0].files[0];
- if(logo){
- formData.append('logo', logo);
- }
- if(idcard_front){
- formData.append('idcard_front', idcard_front);
- }
- if(idcard_back){
- formData.append('idcard_back', idcard_back);
- }
- if(business_img){
- formData.append('business_img', business_img);
- }
- var agree = $("#agree").is(":checked") ? true : false;
- if (!agree) {
- $.toast('请先阅读店铺入驻协议并确定', 'text');
- return false;
- }
- if (confirm('确定提交该店铺入驻申请?')) {
- $.showLoading('申请提交...');
- $.ajax({
- url: '/weixin/shop/applySubmit',
- type: "post",
- dataType: 'json',
- data: formData,
- cache: false,
- contentType: false,
- processData: false,
- success: function (res) {
- $.hideLoading();
- if (res.code == 'success') {
- sessionStorage.setItem('shopInfo', null);
- $.toast('入驻申请提交成功,请耐心等候审核...');
- setTimeout(function () {
- location.href = '/weixin/news/index';
- }, 800);
- } else if (res.code == 'login') {
- login(res.data.url);
- }else{
- $.toast(res.message,'text');
- }
- }
- });
- }
- },
- // 选择图片
- selectPhoto: function (ele) {
- var file = ele.target.files[0];
- if (file) {
- var reader = new FileReader();
- reader.readAsDataURL(file);
- reader.onloadend = function (even) {
- $(ele.target).siblings('.preview').attr("src", even.currentTarget.result);
- }
- }
- },
- // 分类选择
- catePicker: function (reload) {
- var _this = this;
- var data1 = _this.cates;
- if (data1.length <= 0) {
- return false;
- }
- if(reload){
- _this.shopInfo.cate2 = 0;
- }
- _this.subCates = [];
- if (_this.shopInfo.cate1>0) {
- $.each(data1, function (k, item) {
- if (item.id == _this.shopInfo.cate1) {
- _this.subCates = item.subCates.length ? item.subCates : [];
- }
- })
- } else if(data1.length>0){
- _this.shopInfo.cate1 = 0;
- _this.subCates = data1[0].subCates;
- }
- }
- }
- });
|