// pages/storeApply/storeApply.js var app = getApp(); var location = require("../../../mybehaviors/location/location"); // var WxParse = require('../../../wxParse/wxParse.js'); Page({ behaviors: [location], /** * 页面的初始数据 */ data: { shop_commission: false, //是否开启平台提成 customer_open: true, service_QRcode: '', service_mobile: '', show1: false, msgText: 0, pass_safe: 0, showtips: true, swlist: [], swlis: [], shenqShow: false, is_hotel: false, uploadUrl: '', o2o_status: 1, o2o_info: "", //定位信息 address: "", point: { lat: '', lng: '' }, city: '', title: '', noIs: true, bor: true, showDel: false, applyModel: { password: "", realname: "", mobile: "", //store名字 storeName: "", lng: "", lat: "", beginTime: "00:00", endTime: "00:00", categoryId: "", //省市区 街道id provinceId: "", cityId: "", districtId: "", streetId: "", address: "", //门店图片src storeImg: "", //资质图片src aptitudeImg: [], remark: "", starRated: "", // 其他图片 otherImg: [], // 门店详情图片 information_thumb: "", idCardImg: [] }, categoryName: '', strShow: false, provinceData: [], cityData: [], districtData: [], pickerValue: [0, 0, 0], selectAddressData: [], districtVal: [], streetShow: false, addressShow: false, addressName: '', provice: '', beginTimeshow: false, endTimeshow: false, imageUrl: '', hotelTitleType: '', levelShow: false, star_arr: [{ name: "二星及以下/经济型", value: 2 }, { name: "三星/舒适", value: 3 }, { name: "四星/高档", value: 4 }, { name: "五星/豪华", value: 5 }, { name: "六星", value: 6 }, { name: "七星", value: 7 }, { name: "八星", value: 8 }, { name: "不限", value: 0 } ], goods_id: '', status: false, // 申请后是否跳页面 coverViewFlag: false }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { try { wx.removeStorageSync('applyaddresspoint'); } catch (e) { // Do something when catch error } this.initData(); if (options.name == "hotelApply") { this.setData({ is_hotel: true, uploadUrl: "upload.uploadPic", }); this.getCustomizeHotelHead(); } else { wx.setNavigationBarTitle({ title: '门店申请' }); this.setData({ uploadUrl: 'upload.uploadPic' }); } this.checkrouter(); //加载地址数据初始化 this._initAddressInfo(); this.isToGoos(); this.getData(); this._getLocation((mapdata, e) => { this.setData({ 'applyModel.lng': e.lng, 'applyModel.lat': e.lat, mapdata_address: mapdata.address }); }); this.getCategory(); this.setWatcher(this.data, this.watch); }, isToGoos() { let that = this; let urlStr = app.getNetAddresss("plugin.store-cashier.frontend.store.enter.enable"); app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.data.status = res.data.status; } }, fail: function (res) { console.log(res); } }); }, checkrouter() { // 推广中心是否开启该功能,没开启跳转到指定路径 let basic_info = wx.getStorageSync("yz_basic_info"); let stop_info = basic_info.popularize_page.mini.vue_route; for (let i = 0; i < stop_info.length; i++) { if (stop_info[i] == 'storeApply') { console.log(basic_info.popularize_page.mini.mini_url + "跳转的路径"); wx.showToast({ title: '未开启推广权限', duration: 2000, icon: 'none', success: function () { setTimeout(() => { wx.redirectTo({ url: basic_info.popularize_page.mini.mini_url, }); }, 1000); } }); return; } } }, showdel(e) { console.log(e); this.setData({ showDel: true }); }, delIntu(e) { var delpaths = this.data.showpaths; // let del = e.currentTarget.id; // var indelpaths = delpaths.splice(del, 1); this.setData({ showpaths: delpaths }); }, delIntu_2(e) { var delpaths = this.data.showpaths_two; // let del = e.currentTarget.id; // var indelpaths = delpaths.splice(del, 1); this.setData({ showpaths_two: delpaths }); }, shenqShow() { this.setData({ shenqShow: true }); }, onClicksQ() { this.setData({ shenqShow: false }); }, callKf() { console.log('联系客服'); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { try { var value = wx.getStorageSync('applyaddresspoint'); if (value) { this.setData({ 'applyModel.lng': value.point.lng, 'applyModel.lat': value.point.lat, mapdata_address: value.address }); console.log(this.data.applyModel); // Do something with return value } } catch (e) { console.log(e); } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, callPhone() { wx.makePhoneCall({ phoneNumber: this.data.service_mobile, }); }, showPop() { if (this.data.customer_open) { this.setData({ show1: true }); } }, closePop() { this.setData({ show1: false }); }, initData() { this.setData({ customer_open: true, service_QRcode: '', service_mobile: '', show1: false, pass_safe: 0, showtips: true, msgText: 0, o2o_status: 1, // fileList2: [], 'applyModel.username': "", 'applyModel.password': "", 'applyModel.realname': "", 'applyModel.mobile': '', 'applyModel.storeName': '', 'applyModel.lng': '', 'applyModel.lat': '', 'applyModel.categoryId': '', 'applyModel.provinceId': "", 'applyModel.cityId': "", 'applyModel.districtId': '', 'applyModel.streetId': '', 'applyModel.storeImg': '', 'applyModel.aptitudeImg': [], 'applyModel.remark': "", 'agreementChoose': false }); }, toGeolocation() { wx.navigateTo({ url: '/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=storeApply' }); }, //获取数据 getData() { let that = this; let urlStr = ""; if (this.data.is_hotel) { urlStr += app.getNetAddresss("plugin.hotel.frontend.hotel.hotel.verify-apply-status"); } else { urlStr += app.getNetAddresss("plugin.store-cashier.frontend.store.store.verify-apply-status"); } app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ shop_commission: res.data.shop_commission == 1 ? true : false, o2o_status: res.data.status, o2o_info: res.data.agreement, top_thumb: res.data.top_thumb, pass_safe: res.data.safe, customer_open: res.data.customer_open == '1' ? true : false, service_QRcode: res.data.service_QRcode, service_mobile: res.data.service_mobile, is_business_license: res.data.is_business_license }); if(res.data.status == -1){ if(Object.values((res.data.last_info).length > 0)){ that.setData({ 'applyModel.username': res.data.last_info.username, 'applyModel.realname': res.data.last_info.realname, 'applyModel.mobile': res.data.last_info.mobile, 'applyModel.storeName': res.data.last_info.information.store_name, categoryName:res.data.last_info.information.store_category_text, 'applyModel.categoryId': res.data.last_info.information.category_id, addressName: res.data.last_info.information.province +' '+ res.data.last_info.information.city +' '+ res.data.last_info.information.district, 'applyModel.provinceId': res.data.last_info.information.province_id, 'applyModel.cityId': res.data.last_info.information.city_id, 'applyModel.districtId': res.data.last_info.information.district_id, 'applyModel.address': res.data.last_info.information.address, 'applyModel.beginTime': res.data.last_info.information.business_hours_start, 'applyModel.endTime': res.data.last_info.information.business_hours_end, imageUrl: res.data.last_info.information.thumb, 'applyModel.storeImg': res.data.last_info.information.thumb, fileList2: res.data.last_info.information.banner_thumb, 'applyModel.bannerImg': res.data.last_info.information.banner_thumb, 'applyModel.storeIntroduce': res.data.last_info.information.store_introduce, showpaths: res.data.last_info.information.information_thumb, swlist: res.data.last_info.information.information_thumb, 'applyModel.information_thumb': res.data.last_info.information.information_thumb, fileList3: res.data.last_info.information.aptitude_imgs, 'applyModel.aptitudeImg': res.data.last_info.information.aptitude_imgs, fileList5: res.data.last_info.information.id_card_imgs[0], fileList4: res.data.last_info.information.id_card_imgs[1], 'applyModel.idCardImg': res.data.last_info.information.id_card_imgs, showpaths_two: res.data.last_info.information.other_imgs, swlis: res.data.last_info.information.other_imgs, 'applyModel.otherImg': res.data.last_info.information.id_card_imgs, 'applyModel.shop_commission': res.data.last_info.information.shop_commission, 'applyModel.remark': res.data.last_info.information.remark, }); } } if (app._isTextEmpty(res.data.cservice)) { console.log('空的'); that.setData({ cservice: false }); } else { console.log('不空的'); that.setData({ cservice: true }); } // let article = that.data.o2o_info; /** * WxParse.wxParse(bindName , type, data, target,imagePadding) * 1.bindName绑定的数据名(必填) * 2.type可以为html或者md(必填) * 3.data为传入的具体数据(必填) * 4.target为Page对象,一般为this(必填) * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选) */ // WxParse.wxParse('article', 'html', article, that); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } }, fail: function (res) { console.log(res); } }); }, //获取分类和协议 getCategory() { let that = this; let urlStr = ""; if (this.data.is_hotel) { urlStr += app.getNetAddresss("plugin.hotel.frontend.hotel.hotel.get-hotel-categorys"); } else { urlStr += app.getNetAddresss("plugin.store-cashier.frontend.store.store.get-store-categorys"); } app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ categoryList: res.data.store_categorys, agreement: res.data.agreement }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } }, fail: function (res) { console.log(res); } }); }, usernameinp(e) { let val = e.detail.value; this.setData({ 'applyModel.username': val }); }, passwordinp(e) { let val = e.detail; this.setData({ 'applyModel.password': val }); this.data.msgText = this.checkStrong(val); if (this.data.msgText == 3) { this.setData({ 'showtips': false }); } else { this.setData({ 'showtips': true }); } }, checkStrong(sValue) { var modes = 0; //正则表达式验证符合要求的 if (sValue.length < 1) return modes; if (/\d/.test(sValue)) modes++; //数字 if (/[a-z]/.test(sValue)) modes++; //小写 if (/[A-Z]/.test(sValue)) modes++; //大写 // if (/\W/.test(sValue)) modes++; //特殊字符 //逻辑处理 // switch (modes) { // case 1: // break; // case 2: // return 2; // break; // case 3: // sValue.length < 8 ? 2 : 3; // break; // } // return x; if (modes == 1) { return 1; } else if (modes == 2) { return 2; } else if (modes == 3) { return sValue.length < 8 ? 2 : 3; } }, realnameinp(e) { let val = e.detail.value; this.setData({ 'applyModel.realname': val }); }, mobileinp(e) { let val = e.detail.value; this.setData({ 'applyModel.mobile': val }); }, storeNameinp(e) { let val = e.detail.value; this.setData({ 'applyModel.storeName': val }); }, showCategory() { this.setData({ categoryShow: true }); }, onClickLeft() { this.setData({ categoryShow: false }); }, chooseCategory(e) { let item = e.currentTarget.dataset.item; this.setData({ categoryName: item.name, 'applyModel.categoryId': item.id, 'categoryShow': false }); }, addressShowbtn() { this.setData({ addressShow: true }); }, //所在地选择显示 showAddBtn(e) { let idx = e.currentTarget.dataset.idex; this.setData({ ["diydata[" + idx + "].showAdd"]: true }); }, // 关闭选择收货地址 _closeDateLw: function () { this.setData({ addressShow: false }); }, //地址选择器数据初始化 _initAddressInfo: function () { var that = this; var _keyName = 'provinceData'; wx.getStorage({ key: _keyName, success: function (res) { console.log("地址信息准备就绪"); that._getProvinceData(); }, fail: function (res) { console.log("省fail"); app._getNetWork({ url: app.getNetAddresss("member.member-address.address"), success: function (res) { var response = res.data; var province = response.data.province; var city = response.data.city; var district = response.data.district; wx.setStorage({ key: 'provinceData', data: province }); wx.setStorage({ key: 'cityData', data: city }); wx.setStorage({ key: 'districtData', data: district }); that._initAddressInfo(); }, fail: function (res) {}, state: true }); } }); }, // 读取省key _getProvinceData: function () { var that = this; var _keyName = 'provinceData'; wx.getStorage({ key: _keyName, success: function (res) { console.log("省读取成功", res.data); that.setData({ provinceData: res.data }); that.setData({ "selectAddressData[0].name": res.data[that.data.pickerValue[0]].areaname, "selectAddressData[0].id": res.data[that.data.pickerValue[0]].id, "selectAddressData[0].index": that.data.pickerValue[0] }); that._getCityData(); } }); }, // 读取城市key,筛选城市data _getCityData: function () { var _data = this.data.selectAddressData[0]; console.log("城市", "_data", _data); var that = this; var _keyName = 'cityData'; wx.getStorage({ key: _keyName, success: function (res) { console.log("城市读取成功", res); var _json = []; for (var i = 0; i < res.data.length; i++) { if (res.data[i].parentid == _data.id) { _json.push(res.data[i]); } } console.log("城市数据筛选", _json); that.setData({ cityData: _json }); that.setData({ "selectAddressData[1].name": _json[that.data.pickerValue[1]].areaname, "selectAddressData[1].id": _json[that.data.pickerValue[1]].id, "selectAddressData[1].index": that.data.pickerValue[1] }); that._getDistrictData(); } }); }, // 读取地区key,筛选地区data _getDistrictData: function () { var _data = this.data.selectAddressData[1]; console.log("地区", "_data", _data); console.log(_data); var that = this; var _keyName = 'districtData'; wx.getStorage({ key: _keyName, success: function (res) { console.log("地区读取成功"); var _json = []; for (var i = 0; i < res.data.length; i++) { if (res.data[i].parentid == _data.id) { _json.push(res.data[i]); } } console.log("地区数据筛选", _json); that.setData({ districtData: _json }); console.log("districtData", _json); that.setData({ "selectAddressData[2].name": _json[that.data.pickerValue[2]].areaname, "selectAddressData[2].id": _json[that.data.pickerValue[2]].id, "selectAddressData[2].index": that.data.pickerValue[2] }); console.log("over", that.data.selectAddressData); } }); }, // 收货地址滚动事件 bindChange: function (e) { var val = e.detail.value; if (this.data.pickerValue[0] != val[0]) { val[1] = 0; val[2] = 0; } if (this.data.pickerValue[1] != val[1]) { val[2] = 0; } this.setData({ "pickerValue[0]": val[0], "pickerValue[1]": val[1], "pickerValue[2]": val[2] }); this._initAddressInfo(); }, //城市结果 resultAdd: function () { let seleData = this.data.selectAddressData; let retCity = seleData[0].name + ' ' + seleData[1].name + ' ' + seleData[2].name; this.setData({ addressName: retCity, provice: seleData[0].name, city: seleData[1].name, district: seleData[2].name }); this.setData({ 'applyModel.provinceId': seleData[0].id, 'applyModel.cityId': seleData[1].id, 'applyModel.districtId': seleData[2].id, 'addressShow': false, }); this.getStreet(seleData[2].id); }, //获取街道 getStreet(param) { let that = this; let urlStr = ""; urlStr += app.getNetAddresss("member.memberAddress.street"); urlStr += '&district_id=' + param; app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { if (!app._isTextEmpty(res.data) && res.data.length > 0) { that.setData({ districtVal: res.data, strShow: true, }); } else { that.setData({ strShow: false }); } } else { that.setData({ strShow: false }); } }, fail: function (res) { console.log(res); } }); }, streetShowbtn() { this.setData({ streetShow: true }); }, treetShowLeft() { this.setData({ streetShow: false }); }, streetConfirm(e) { let item = e.currentTarget.dataset.item; this.setData({ street: item.areaname, 'applyModel.streetId': item.id, 'streetShow': false }); }, addressinp(e) { let val = e.detail.value; this.setData({ 'applyModel.address': val }); }, // beginTimebtn() { // this.setData({ // beginTimeshow: true // }) // }, // beginTimeClose() { // this.setData({ // beginTimeshow: false // }) // }, endTimebtn() { this.setData({ endTimeshow: true }); }, endTimeClose() { this.setData({ endTimeshow: false }); }, beginTimemessage(e) { let time = e.detail.value; this.setData({ 'applyModel.beginTime': time, }); // beginTimeshow: false }, endTimemessage(e) { let time = e.detail.value; this.setData({ 'applyModel.endTime': time, }); // endTimeshow: false }, //选择图片 onRead() { let that = this; let urlStr = app.getNetAddresss(this.data.uploadUrl); wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { const tempFilePaths = res.tempFilePaths; console.log(tempFilePaths[0]); // wx.compressImage({ // src: tempFilePaths[0], // 图片路径 // quality: 60, // 压缩质量 // success(e) { // let photourl = e.tempFilePath let photourl = tempFilePaths[0]; wx.uploadFile({ url: urlStr, filePath: photourl, name: 'file', success(resdata) { var res = JSON.parse(resdata.data); if (res.result == 1) { that.setData({ imageUrl: res.data.img_url, 'applyModel.storeImg': res.data.img_url }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } } }); // }, // fail(e) { // }, // complete(e) { // } // }) } }); }, //选择图片 onRead_1() { let that = this; let urlStr = app.getNetAddresss(this.data.uploadUrl); wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { const tempFilePaths = res.tempFilePaths; console.log(tempFilePaths[0]); // wx.compressImage({ // src: tempFilePaths[0], // 图片路径 // quality: 60, // 压缩质量 // success(e) { let photourl = tempFilePaths[0]; //e.tempFilePath wx.uploadFile({ url: urlStr, filePath: photourl, name: 'file', success(resdata) { var res = JSON.parse(resdata.data); if (res.result == 1) { // let fileList1 = that.data.applyModel.aptitudeImg; // let fileList2 = that.data.fileList2; // fileList1.push({ // url: res.data.img // }) // fileList2.push({ // url: photourl // }) that.setData({ 'applyModel.bannerImg': res.data.img_url, fileList2: res.data.img_url }); console.log(res); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } } }); // }, // fail(e) { // }, // complete(e) { // } // }) } }); }, // 其他图片 onRead_6() { let that = this; // let urlStr = app.getNetAddresss(this.data.uploadUrl); let ig = '2'; wx.chooseImage({ count: 9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { // var tempFilePaths = res.tempFilePaths that.unload({ tempFilePaths: res.tempFilePaths }, ig); } }); }, // 门店介绍选择图片 onRead_2() { let that = this; // let urlStr = app.getNetAddresss(this.data.uploadUrl); let ig = '1'; wx.chooseImage({ count: 9, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { // var tempFilePaths = res.tempFilePaths console.log(res.tempFilePaths); that.unload({ tempFilePaths: res.tempFilePaths }, ig); } }); }, //多张上传方法 unload(data, ig) { console.log(ig); let urlStr = app.getNetAddresss(this.data.uploadUrl); var that = this, i = data.i ? data.i : 0, success = data.success ? data.success : 0, fail = data.fail ? data.fail : 0; wx.uploadFile({ url: urlStr, filePath: data.tempFilePaths[i], name: 'file', formData: null, success(resdata) { var res = JSON.parse(resdata.data); console.log(res.data.img_url); if (ig == '1') { that.data.swlist.push(res.data.img_url); that.setData({ showpaths: that.data.swlist, 'applyModel.information_thumb': that.data.swlist }); } else if (ig == 2) { that.data.swlis.push(res.data.img_url); that.setData({ showpaths_two: that.data.swlis, 'applyModel.otherImg': that.data.swlis }); } console.log(that.data.applyModel); }, fail(e) { fail++; }, complete(e) { i++; if (i == data.tempFilePaths.length) { //当图片传完时,停止调用 console.log('执行完毕'); console.log('成功:' + success + " 失败:" + fail); } else { //若图片还没有传完,则继续调用函数 data.i = i; data.success = success; data.fail = fail; that.unload(data, ig); //递归,回调自己 } } }); }, onRead_3() { let that = this; let urlStr = app.getNetAddresss(this.data.uploadUrl); wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { const tempFilePaths = res.tempFilePaths; console.log(tempFilePaths[0]); // wx.compressImage({ // src: tempFilePaths[0], // 图片路径 // quality: 60, // 压缩质量 // success(e) { let photourl = tempFilePaths[0]; wx.uploadFile({ url: urlStr, filePath: photourl, name: 'file', success(resdata) { var res = JSON.parse(resdata.data); if (res.result == 1) { that.setData({ fileList3: res.data.img_url, 'applyModel.aptitudeImg[0]': res.data.img_url }); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } } }); // }, // fail(e) { // }, // complete(e) { // } // }) } }); }, onRead_4() { let that = this; let urlStr = app.getNetAddresss(this.data.uploadUrl); wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { const tempFilePaths = res.tempFilePaths; console.log(tempFilePaths[0]); // wx.compressImage({ // src: tempFilePaths[0], // 图片路径 // quality: 60, // 压缩质量 // success(e) { let photourl = tempFilePaths[0]; wx.uploadFile({ url: urlStr, filePath: photourl, name: 'file', success(resdata) { var res = JSON.parse(resdata.data); if (res.result == 1) { that.setData({ fileList4: photourl, 'applyModel.idCardImg[0]': res.data.img_url }); console.log(that.data.applyModel.idCardImg); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } } }); // }, // fail(e) { // }, // complete(e) { // } // }) } }); }, onRead_5() { let that = this; let urlStr = app.getNetAddresss(this.data.uploadUrl); wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { const tempFilePaths = res.tempFilePaths; console.log(tempFilePaths[0]); // wx.compressImage({ // src: tempFilePaths[0], // 图片路径 // quality: 60, // 压缩质量 // success(e) { let photourl = tempFilePaths[0]; wx.uploadFile({ url: urlStr, filePath: photourl, name: 'file', success(resdata) { var res = JSON.parse(resdata.data); if (res.result == 1) { that.setData({ fileList5: res.data.img_url, 'applyModel.idCardImg[1]': res.data.img_url }); console.log(that.data.applyModel); } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } } }); }, // fail(e) { // }, // complete(e) { // } // }) // } }); }, remarkinp(e) { let val = e.detail.value; console.log(val); this.setData({ 'applyModel.remark': val }); }, storeIn(e) { console.log(e.detail.value); let val = e.detail.value; this.setData({ 'applyModel.storeIntroduce': val }); }, Chooseinp(e) { let Bol = e.detail; this.setData({ agreementChoose: Bol }); }, removeImg: function (e) { let index = e.currentTarget.dataset.index; let aptitudeImg = this.data.applyModel.aptitudeImg; let fileList2 = this.data.fileList2; aptitudeImg.splice(index, 1); fileList2.splice(index, 1); this.setData({ 'applyModel.aptitudeImg': aptitudeImg, 'fileList2': fileList2 }); }, //提交数据 setApplyData() { console.log(this.data.applyModel); if (this.data.is_business_license == '1') { if (app._isTextEmpty(this.data.applyModel.aptitudeImg)) { wx.showToast({ icon: 'none', title: '请上传营业执照', duration: 1500 }); return; } } if (app._isTextEmpty(this.data.applyModel.username)) { wx.showToast({ icon: 'none', title: '请填写账号', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.password)) { wx.showToast({ icon: 'none', title: '请填写密码', duration: 1500 }); return; } if (this.data.msgText != 3 && this.data.pass_safe == 1) { wx.showToast({ icon: 'none', title: '请正确填写密码', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.realname)) { wx.showToast({ icon: 'none', title: '请填写真实姓名', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.mobile)) { wx.showToast({ icon: 'none', title: '请填写手机号码', duration: 1500 }); return; } if (app._isMoblie(this.data.applyModel.mobile)) { wx.showToast({ icon: 'none', title: '请输入正确的手机号', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.storeName)) { if (this.data.is_hotel) { wx.showToast({ icon: 'none', title: '请填写酒店名称', duration: 1500 }); return; } else { wx.showToast({ icon: 'none', title: '请填写门店名称', duration: 1500 }); return; } } if (app._isTextEmpty(this.data.applyModel.storeImg)) { if (this.data.is_hotel) { wx.showToast({ icon: 'none', title: '请上传酒店图片', duration: 1500 }); return; } else { wx.showToast({ icon: 'none', title: '请上传门店logo图片', duration: 1500 }); return; } } if (app._isTextEmpty(this.data.applyModel.categoryId)) { if (this.data.is_hotel) { wx.showToast({ icon: 'none', title: '请选择酒店分类', duration: 1500 }); return; } else { wx.showToast({ icon: 'none', title: '请选择门店分类', duration: 1500 }); return; } } if ( app._isTextEmpty(this.data.applyModel.provinceId) || app._isTextEmpty(this.data.applyModel.cityId) || app._isTextEmpty(this.data.applyModel.districtId) ) { wx.showToast({ icon: 'none', title: '请选择省市区', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.streetId)) { // 任务编号: 59594 街道地址优化成选填 this.setData({ ['applyModel.streetId']: 0 }); } if (app._isTextEmpty(this.data.applyModel.address)) { wx.showToast({ icon: 'none', title: '请填写详细地址', duration: 1500 }); return; } if ( app._isTextEmpty(this.data.applyModel.lng) || app._isTextEmpty(this.data.applyModel.lat) ) { wx.showToast({ icon: 'none', title: '经纬度不能为空', duration: 1500 }); return; } if ( app._isTextEmpty(this.data.applyModel.beginTime) || app._isTextEmpty(this.data.applyModel.endTime) ) { wx.showToast({ icon: 'none', title: '营业开始时间活营业结束时间不能为空', duration: 1500 }); return; } if (!this.data.is_hotel) { if (app._isTextEmpty(this.data.applyModel.aptitudeImg)) { wx.showToast({ icon: 'none', title: '请上传资质图片', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.bannerImg)) { wx.showToast({ icon: 'none', title: '请上传门店banner图片', duration: 1500 }); return; } if (app._isTextEmpty(this.data.applyModel.bannerImg)) { wx.showToast({ icon: 'none', title: '请上传门店banner图片', duration: 1500 }); return; } // if (this.data.applyModel.idCardImg.length != 2) { // wx.showToast({ // icon: 'none', // title: '请上传身份证正反面图片', // duration: 1500 // }) // return; // } } else { if (app._isTextEmpty(this.data.applyModel.starRated)) { wx.showToast({ icon: 'none', title: '请上选择星级', duration: 1500 }); return; } } if (!this.data.agreementChoose) { wx.showToast({ icon: 'none', title: '请同意申请协议', duration: 1500 }); return; } if (this.data.shop_commission && app._isTextEmpty(this.data.applyModel.shop_commission)) { wx.showToast({ icon: 'none', title: '请输入平台提成', duration: 1500 }); return; } let that = this; let json = { apply: this.data.applyModel }; let urlStr = ""; if (this.data.is_hotel) { urlStr = app.getNetAddresss("plugin.hotel.frontend.hotel.hotel.apply"); } else { urlStr = app.getNetAddresss("plugin.store-cashier.frontend.store.store.apply"); } app._postNetWork({ url: urlStr, showToastIn: false, data: json, success: function (resdata) { var res = resdata.data; if (res.result == 1) { if (that.data.status == 1) { if (res.data.goods_id) { // 不确定接口是否改了 that.data.goods_id = res.data.goods_id; } else { that.data.goods_id = res.data.goods_info.id; } that.goOrder(); } else { wx.showToast({ title: res.msg, icon: 'none', duration: 1500, success: function () { setTimeout(function () { //要延时执行的代码 that.goHome(); }, 1500); //延迟时间 }, }); } } else { wx.showToast({ icon: 'none', title: res.msg, duration: 1500 }); } }, fail: function (res) {} }); }, shop_commissionInp(e) { console.log(e); let txt = e.detail.value; this.setData({ 'applyModel.shop_commission': txt }); }, // 去订单页面 goOrder() { let submitActionTag = "-2"; // 立即购买 let _optionsId = ""; let _total = 1; let _goodsId = this.data.goods_id; wx.redirectTo({ url: '/packageD/buy/myOrder_v2/myOrder_v2?tag=' + submitActionTag + '&goodsId=' + _goodsId + '&optionsId=' + _optionsId + '&total=' + _total }); }, //去商城 goHome() { wx.reLaunch({ url: '/packageG/index/index' }); }, //获取酒店自定义字段 getCustomizeHotelHead() { let that = this; let isQuestHotel = ""; try { const value = wx.getStorageSync('customizeHotelHead'); if (value) { isQuestHotel = value; // Do something with return value } } catch (e) { // Do something when catch error } if (!app._isTextEmpty(isQuestHotel)) { this.setData({ hotelTitleType: JSON.parse(isQuestHotel).hotels }); wx.setNavigationBarTitle({ title: `${that.data.hotelTitleType}申请` }); } else { let urlStr = app.getNetAddresss("plugin.hotel.frontend.hotel.get-hotel-info.get-custom-name"); app._getNetWork({ url: urlStr, success: function (resdata) { var res = resdata.data; if (res.result == 1) { that.setData({ hotelTitleType: res.data.hotels }); wx.setNavigationBarTitle({ title: `${that.data.hotelTitleType}申请` }); try { wx.setStorageSync('customizeHotelHead', JSON.stringify(res.data)); } catch (e) { console.log(e); } } }, fail: function (res) { console.log(res); } }); } }, levelShowbtn() { this.setData({ levelShow: true }); }, levelShowLeft() { this.setData({ levelShow: false }); }, chooseStarLevel(e) { let item = e.currentTarget.dataset.item; this.setData({ 'applyModel.starRated': item.value, 'levelShow': false, levelName: item.name }); }, watch: { 'shenqShow,categoryShow,addressShow,streetShow,levelShow,show1': function (newVal, oldVla) { console.log("刷新改变"); setTimeout(() => { this.setData({ coverViewFlag: newVal }); }, 1000); } }, /** * 设置监听器 */ setWatcher(data, watch) { // 接收index.js传过来的data对象和watch对象 Object.keys(watch).forEach(v => { // 将watch对象内的key遍历 let names = v.split(','); for (let i = 0; i < names.length; i++) { this.observe(data, names[i], watch[v]); // 监听data内的v属性,传入watch内对应函数以调用 } }); }, /** * 监听属性 并执行监听函数 */ observe(obj, key, watchFun) { let that = this; var val = obj[key]; // 给该属性设默认值 Object.defineProperty(obj, key, { configurable: true, enumerable: true, set: function (value) { val = value; watchFun.call(that, value, val); // 赋值(set)时,调用对应函数 }, get: function () { return val; } }); } });