1 Star 0 Fork 17

小鱼的心 / 场馆预定小程序

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
App.vue 78.91 KB
一键复制 编辑 原始数据 按行查看 历史
赵同学 提交于 2021-03-23 10:44 . 赵同学-场馆预定小程序
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324
<script>
import { dellUrl } from "./wxcomponents/public/requestUrl";
import { socketFun } from "./wxcomponents/public/json2Form";
// const Promise = require("./wxcomponents/promise/promise.js");
export default {
globalData: {
// clientUrl: 'http://192.168.0.239:3000/chainalliance/', // 本地链接地址
// clientUrl: 'http://127.0.0.1:3000/chainalliance/', // 本地链接地址
clientUrl: 'https://mini.sansancloud.com/chainalliance/',
// clientUrl: 'https://mini.soulmatecharm.com/chainalliance/',
//一定加https
/**
* 切换项目的开关 ↓↓↓↓↓
*/
clientNo: 'daishu',
//自定义的项目的名称。,
preCallbackObj: {
key: {
callback: ''
}
},
getSettingState:false,
loginToken:'',
clientName: '',
version: '3.5.156',
more_scene: '',
//扫码进入场景 用来分销
shareParam: null,
localPoint:null,
//分享页面参数onload
miniIndexPage: '',
miniIndexPageParams:'',
setting: {
platformSetting: {
defaultColor: "#444",
secondColor: "#fff"
}
},
// 全局设置
loginUser: "",
USER_DEFINED_SCENE:0,
//登陆返回的个人信息
cookie: null,
shopOpen: null,
// 店铺营业时间-开关
mapProIconArray: {},
cart_offline: {},
//addr:null,
kefuCount: 0,
socketTask: null,
sharePuid:0,
// notifyTipPage:false,
// preNotifyTipPage: false,
loginSuccessListeners: [],
socketConnect: socketFun.socketConnect,
socketLinkListener: {},
carChangeNotifys: [],
popupNotifysList: [],
payItem: null,
//下单的时候传过去的
userSign: null,
//账号密码
EditAddr: null,
//传值的
richTextHtml: '',
footerCount: 0,
authorizationCount: 0,
showAuthorizationPopup: false,
productParam: null,
//传值的
// customPageJson:null,//page的动态组件json
header: {
'content-type': 'application/json' // 默认值
},
headerPost: {
'content-type': 'application/x-www-form-urlencoded'
},
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
successOnlaunch: false,
showToastLoading: function (title, mask) {
console.log("=====showToastLoading=====", title, mask);
if (this.clientNo != 'naifen') {
wx.showLoading({
title: title,
mask: mask
});
}
},
showToastFun:function(title,time,icon,image){
wx.showToast({
title:title,
icon: icon?icon:'',
duration: time||2000,
image:image||''
});
},
defaultMendianID: "",
// 扫描二维码所带的参数,即扫码进来携带MendianID
enterMenDianID: "",
/* 页面影藏 */
appHide: false,
shareSubPage: true,
addSocketLinkListener: function (listener) {
let that = this;
console.log('addSocketLinkListener', listener);
that.socketLinkListener = Object.assign({}, that.socketLinkListener, listener);
console.log("socketLinkListener", that.socketLinkListener);
},
addLoginListener: function (listener) {
console.log('addLoginListener');
this.loginSuccessListeners.push(listener);
},
authorizationListenerItem:null,
addAuthorizationListenerItem: function (listener) {
let that = this;
console.log("====addAuthorizationListenerItem====", listener);
console.log('addLoginListener', listener);
this.authorizationListenerItem = Object.assign({}, this.authorizationListenerItem, listener);
},
authorizationListener: function (state) {
console.log('====authorizationListener====', state);
try {
this.authorizationListenerItem.getStateData(state);
} catch (e) {
console.log(e);
}
},
addCarChangeNotify: function (listener) {
this.carChangeNotifys.push(listener);
},
addPopupNotifysList: function (listener) {
this.popupNotifysList.push(listener);
},
clearPopupNotifysList: function (data) {
console.log('===clearPopupNotifysList====', data);
if (this.popupNotifysList && this.popupNotifysList.length > 0) {
for (let t = 0; t < this.popupNotifysList.length; t++) {
try {
this.popupNotifysList[t].clearInterval(data);
} catch (e) {
console.log(res);
}
}
}
},
carChangeNotify: function (data) {
console.log('000000carChangeNotify000000', data);
if (this.carChangeNotifys && this.carChangeNotifys.length > 0) {
console.log('000000000000', this.carChangeNotifys);
for (let t = 0; t < this.carChangeNotifys.length; t++) {
try {
this.carChangeNotifys[t].carChangeNotify(data);
} catch (e) {
console.log(res);
}
}
}
},
onLaunchOptions: {},
timer: 0,
// 确保onLaunch事件完成后再开始调用其他函数
promiseonLaunch: function (self) {
let that = this;
console.log('promiseonLaunch');
if (!!this.setting) {
self.onLoad();
} else {
that.timer = setTimeout(function () {
that.promiseonLaunch(self);
}, 500);
}
},
navigateBack: function (time) {
setTimeout(function () {
wx.navigateBack();
}, time);
},
//第一次登录加载的函数
loadFirstEnter: function (more_scene) {
console.log('第一次登录加载的函数');
let that = this;
that.removeStorageFun("cookie",function(res){
console.log("==removeStorageFun==",res.data);
that.cookie = null;
that.header = {
'content-type': 'application/json' // 默认值
};
that.headerPost = {
'content-type': 'application/x-www-form-urlencoded'
};
})
// #ifdef MP
// that.wxLogin(more_scene);
// #endif
// #ifdef APP-PLUS ||H5
// that.getStorageFun("loginToken",function(res){
// console.log("==getStorageFun===res",res)
// let loginToken=''
// if(typeof(res)=="string"){
// loginToken=JSON.parse(res.data);
// }else{
// loginToken=res.data
// }
// that.loginWithLoginToken(loginToken);
// },function(res){
// console.log("获取失败",res)
// })
// #endif
// that.getSetting();
},
loadScene: function (inputPlatformNo) {
this.clientNo = inputPlatformNo;
},
userInfo: null,
sansanUser: null,
sysWidth: wx.getSystemInfoSync().windowWidth,
//图片宽度
sysHeight: wx.getSystemInfoSync().windowHeight,
createOrder: function (baseProData, pintuanData, customFromCommitId, callback, failed) {
console.log('=====app.createOrder=====');
let params = Object.assign({}, params, baseProData, pintuanData, {});
if (customFromCommitId) {
params = Object.assign({}, params, {
customFromCommitId: customFromCommitId
});
}
let that = this;
let customIndex = that.AddClientUrl("/buy_now.html", params, 'post');
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (res) {
console.log("点击确定后内容", res.data);
wx.hideLoading();
if (res.data.errcode != -1 || !res.data.errcode) {
console.log("====成功===");
if (callback) {
callback(res);
return;
}
if (res.data.payStatus == 0) {
wx.navigateTo({
url: '/pages/edit_order/index?orderNo=' + res.data.orderNo
});
} else if (res.data.payStatus == 1 && res.data.processInstanceCount > 0) {
//进入流程列表
let processId = 0;
that.linkEvent("process_list.html"); // wx.navigateTo({
// url: '/pages/process_list/index?processId=' + processId,
// })
} else if (res.data.payStatus == 1 && res.data.processInstanceCount == 0) {
wx.redirectTo({
url: '/pages/order_list_tab/index'
});
}
} else {
wx.showToast({
title: res.data.errMsg,
image: '/wxcomponents/images/icons/tip.png',
duration: 1000
});
}
},
fail: function (res) {// wx.hideLoading()
// app.loadFail()
},
complete: function (res) {}
});
},
getNowTime:function(type,monthType){
let date = new Date();
let seperator1 = "-";
let year = date.getFullYear();
let month = date.getMonth() + 1;
if(monthType){
month=month-1
}
let strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
let currentdate = year + seperator1 + month ;
if(type=='text'){
currentdate = year +'' + month +'';
}
return currentdate;
},
payFinalPaymentFun: function (data,params,callback) {
let that = this;
let customIndex = that.AddClientUrl("/end_payment_unifined_order_wx.html", params, 'post');
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (res) {
console.log(res.data);
let PayStr = res.data;
if(PayStr.errcode&&PayStr.errcode=='-1'){
that.echoErr(PayStr.relateObj)
return
}
PayStr = '{' + PayStr + '}';
let wechatPayStr = JSON.parse(PayStr);
console.log(wechatPayStr);
wx.requestPayment({
'timeStamp': wechatPayStr.timeStamp,
'nonceStr': wechatPayStr.nonceStr,
'package': wechatPayStr.package,
'signType': wechatPayStr.signType,
'paySign': wechatPayStr.paySign,
'success': function (res) {
console.log('------成功--------',res);
callback(res);
},
'fail': function (res) {
console.log('------fail--------',res);
callback(res);
},
'complete': function () {
console.log('------complete--------',res);
}
});
},
complete: function () {}
});
},
getStorageFun:function(keyData,successFun,failFun){
let that=this;
console.log("====获取本地存储======")
uni.getStorage({
key: keyData,
success: function (res) {
console.log("==success===",res.data);
try{
successFun(res)
}catch(e){
console.log("没有成功回调的函数",e)
//TODO handle the exception
}
},
fail:function(err){
console.log("====fail====",err)
try{
failFun(err)
}catch(e){
console.log("没有成功回调的函数",e)
//TODO handle the exception
}
},
complete:function(){
}
});
},
setStorageFun:function(url,resData){
let that=this;
console.log("====本地存储======")
uni.setStorage({
key: url,
data: resData,
success: function (res) {
console.log('success',res);
}
});
},
removeStorageFun:function(url,callback){
let that=this;
console.log("====移除本地存储======",url)
uni.removeStorage({
key: url,
success: function (res) {
console.log('success',res);
if(callback){
callback(res)
}
}
});
},
toIndex: function (jumpType,checkAuthorizationState) {
console.log('首页叫做:' + this.miniIndexPage);
let that = this;
console.log('首页叫做:' + this.clientNo); //这个需要注意 switchTab 和 redirectTo
if (this.clientNo == 'tunzai') {
console.log("1111111111111");
wx.switchTab({
url: '/pageTab/tunzai/index/index'
});
return;
} else if (this.miniIndexPage) {
console.log("2222222222222");
let urlParam=this.miniIndexPage.slice(12);
wx[jumpType||'reLaunch']({
// url: '/pageTab/' + this.miniIndexPage + '/index',
url: '/pageTab/custom_page_index/index?miniIndexPage='+urlParam,
fail: function () {
that.linkEvent(that.miniIndexPage + '.html');
},
success:function(){
if(checkAuthorizationState){
that.showAuthorizationPopup = true
that.authorizationListener(that.showAuthorizationPopup)
}
},
});
} else {
console.log("33333333333333");
wx.switchTab({
url: '/pageTab/custom_page_index/index',
success:function(){
if(checkAuthorizationState){
that.showAuthorizationPopup = true
that.authorizationListener(that.showAuthorizationPopup)
}
},
});
}
},
// 一键回到顶部
goTop: function (e) {
if (wx.pageScrollTo) {
wx.pageScrollTo({
scrollTop: 0
});
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
});
}
},
toMy: function () {
console.log('我的叫做:' + this.clientNo); //这个需要注意 switchTab 和 redirectTo
if (this.clientNo == 'tunzai') {
console.log("1111111111111");
wx.switchTab({
url: '/pageTab/tunzai/myInfo/index'
});
return;
} else {
console.log("222222");
wx.switchTab({
url: '/pageTab/aikucun_userinfo/index'
});
}
},
echoErr: function (errMessage) {
wx.showToast({
title: errMessage,
image: '/wxcomponents/images/icons/tip.png',
duration: 2000
});
},
//加载失败处理
loadFail: function () {
let that = this;
/*
wx.showModal({
title: '提示',
content: '加载失败,重新加载',
success: function (res) {
if (res.confirm) {
that.toIndex()
} else if (res.cancel) {
}
}
})*/
wx.showToast({
title: "加载失败",
image: '/wxcomponents/images/icons/tip.png',
duration: 2000
});
},
loadLogin: function (e) {
let that=this;
wx.showModal({
title: '提示',
content: '用户未登录',
success: function (res) {
if (res.confirm) {
that.linkEvent("login.html")
// wx.navigateTo({
// url: '/pages/login_wx/index'
// });
} else if (res.cancel) {}
}
});
},
//检查是否已经登录
checkIfLogin: function (backUrl) {
if (this.loginUser) {
console.log('已经登录了');
return true;
} else {
console.log('未登录');
let url="login.html"
if(backUrl){
url=url+"?url="+backUrl
}
this.linkEvent(url);
/* wx.showModal({
title: '提示',
content: '用户未登录',
success: function (res) {
if (res.confirm) {
wx.navigateTo({
url: '/pages/login_wx/index'
});
} else if (res.cancel) {}
}
});*/
return false;
}
},
//检查商家开店?
checkShopOpenTime: function () {
let that = this;
let shopBean = this.setting.platformSetting.defaultShopBean;
let nowTime = {
hour: '',
minutes: ''
};
let myDate = new Date();
nowTime.hour = myDate.getHours();
nowTime.minutes = myDate.getMinutes();
let myTime = '';
if (nowTime.minutes < 10) {
myTime = Number(nowTime.hour + '.0' + nowTime.minutes);
} else {
myTime = Number(nowTime.hour + '.' + nowTime.minutes);
}
if (myTime < Number(shopBean.serviceStartTime) || myTime > Number(shopBean.serviceEndTime)) {
wx.showModal({
title: '不是营业时间',
content: '营业时间为' + shopBean.serviceStartTime + '-' + shopBean.serviceEndTime,
success: function (res) {
if (res.confirm) {
that.toIndex();
} else if (res.cancel) {}
}
});
return false;
} else {
return true;
}
},
/* 处理url的函数,放到app里吧 */
AddClientUrl: function (url, params, method, random, noToken) {
let loginToken = this.loginToken?this.loginToken:'';
if (noToken || !this.loginUser || !this.loginUser.platformUser || !this.loginUser.platformUser.loginToken) {
loginToken = '';
} else {
loginToken = this.loginUser.platformUser.loginToken;
}
if (url.indexOf("get_product_comment_list") != -1 || url.indexOf("product_detail") != -1 || url.indexOf("get_platform_setting.html") != -1 || url.indexOf("more_product_list.html") != -1 || url.indexOf("index.html") != -1 || url.indexOf("get_promotions_detail.html") != -1 || url.indexOf("/super_shop_manager_get_mini_code.html") != -1) {
loginToken = "";
random = "tunzai";
}
let paramObj={}
if(params&&params.scene){
this.sharePuid=params.scene||this.sharePuid;
paramObj=Object.assign({},params,{sharePuid:this.sharePuid})
}else{
this.sharePuid=(this.onLaunchOptions.query&&this.onLaunchOptions.query.scene)?this.onLaunchOptions.query.scene.replace("MINI_PLATFORM_USER_ID_",''):this.sharePuid;
paramObj=Object.assign({},params,{sharePuid:this.sharePuid})
}
// this.getStorageFun("localPoint",function(res){
// console.log("==getStorageFun===res",res)
// let localPoint=''
// if(typeof(res)=="string"){
// localPoint=JSON.parse(res.data);
// }else{
// localPoint=res.data
// }
// },function(res){
// console.log("获取失败",res)
// })
if(this.localPoint){
paramObj=Object.assign({},paramObj,{longitude:this.localPoint.longitude,latitude:this.localPoint.latitude})
}
console.log("============================paramObj",paramObj)
var returnUrl = dellUrl(url, paramObj, method, random, loginToken);
console.log("",)
if (returnUrl.url.indexOf("socket") != -1) {
if (this.clientUrl.indexOf("https") != -1) {
returnUrl.url = this.clientUrl.replace("https", "wss") + this.clientNo + returnUrl.url;
} else {
returnUrl.url = this.clientUrl.replace("http", "ws") + this.clientNo + returnUrl.url;
}
}else {
returnUrl.url = this.clientUrl + this.clientNo + returnUrl.url;
}
console.log("returnUrl", returnUrl);
return returnUrl;
},
/* 解析LinkUrl */
getUrlParams: function (url) {
console.log('------getUrlParams--------');
console.log(url);
let theResult = {
url: '',
param: ''
};
if (url.indexOf('?') != -1) {
let str2 = url.substr(0, url.indexOf('?') - 5);
let str3 = url.substr(url.indexOf('?'));
theResult.url = str2;
theResult.param = str3;
}
if (url.indexOf('?') == -1) {
let str2 = url.substr(0, url.indexOf('.'));
let str3 = '';
theResult.url = str2;
theResult.param = str3;
}
console.log("======theResult======", theResult);
return theResult;
},
getSpaceStr: function (str, p) {
let theResult = {
str1: '',
str2: ''
};
if (str.indexOf(p) != -1) {
let str2 = str.substr(0, str.indexOf(p));
let str3 = str.substr(str.indexOf(p) + 1);
theResult.str1 = str2;
theResult.str2 = str3;
}
return theResult;
},
/* 转换成str 带?*/
jsonToStr: function (json) {
var returnParam = "?";
var str = [];
for (var p in json) {
str.push(p + "=" + json[p]); //str.push(encodeURIComponent(p) + "=" + encodeURIComponent(json[p]));
}
returnParam += str.join("&");
console.log(returnParam);
return returnParam;
},
// 不带问号 过滤loginTocken
jsonToStr2: function (json) {
console.log("==json===",json)
var returnParam = "";
var str = [];
for (var p in json) {
if (p != 'loginToken') {
str.push(p + "=" + json[p]);
}
}
returnParam += str.join("&");
console.log("returnParam", returnParam);
return returnParam;
},
//link事件 绑定导向对应的控件上
lookBigImage: function (e) {
let imgSrc = e.currentTarget.dataset.imageurl;
console.log(imgSrc);
let PostImageSrc = imgSrc.replace(/http/, "https"); // let PostImageSrc = imgSrc
console.log(PostImageSrc);
if (!imgSrc) {
return;
}
let urls = [];
urls.push(imgSrc);
wx.previewImage({
current: imgSrc,
// 当前显示图片的http链接
urls: urls // 需要预览的图片http链接列表
});
},
goto: function (linkUrl,jumpType) {
let that = this;
that.shareSubPage = false;
console.log('====linkUrl======', linkUrl);
if (!linkUrl) {
return;
}
let urlData = this.getUrlParams(linkUrl);
console.log("===========urlData============", urlData);
wx[jumpType||'navigateTo']({
url: "/pageTab/" + urlData.url + "/index" + urlData.param,
fail: function () {
//pages里不存在该页面
console.log("pageTab里不存在该页面,跳转pages目录下的页面");
wx[jumpType||'navigateTo']({
url: "/pages/" + urlData.url + "/index" + urlData.param,
success: function () {
that.shareSubPage = true;
},
fail: function () {
console.log("pages里不存在该页面,跳转pagesTwo目录下的页面");
wx[jumpType||'navigateTo']({
url: "/pagesTwo/" + urlData.url + "/index" + urlData.param,
success: function () {
that.shareSubPage = true;
},
fail: function () {
console.log("跳转tab页");
wx.switchTab({
url: "/pageTab/" + urlData.url + "/index" + urlData.param,
success: function () {
that.shareSubPage = true;
},
fail: function () {
console.log("跳转tunzai定制页");
wx.navigateTo({
url: "/pageTab/tunzai/" + urlData.url + "/index" + urlData.param,
success: function () {
that.shareSubPage = true;
},
fail: function () {
console.log("没有定义" + urlData.url + "页面");
that.toIndex();
}
});
}
});
}
});
}
});
}
});
},
//扫一扫 核销
getVerificationCode: function (e) {
console.log("getVerificationCode", e);
wx.scanCode({
onlyFromCamera: true,
success: scanRes => {
console.log("getVerificationCode", scanRes);
wx.navigateTo({
url: "/" + scanRes.path
});
}
});
},
linkEvent: function (linkUrl,jumpType,callback) {
let that = this;
console.log('====linkUrl======', linkUrl,jumpType);
if (!linkUrl) {
return;
}
that.footerCount = 0;
let urlData = that.getUrlParams(linkUrl);
let If_Order_url = urlData.url.substr(0, 10);
console.log('-----toGridLinkUrl---------');
console.log('==urlData===', urlData);
console.log(If_Order_url, that.showAuthorizationPopup); // wx.getSetting({//检查用户是否授权了
let paramStr=urlData.param;
console.log("paramStr",paramStr)
let paramsObj={};
if(paramStr&&paramStr.indexOf("&")!=-1){
paramStr=paramStr.slice(1).split('&');
for(let i=0;i<paramStr.length;i++){
let item={};
let itemArr=paramStr[i].split('=')
item[itemArr[0]]=itemArr[1];
paramsObj=Object.assign({},paramsObj,item)
// paramStr[i]=JSON.parse(JSON.stringify(item))
}
}else if(paramStr){
paramStr=paramStr.slice(1);
let item={};
let itemArr=paramStr.split('=')
item[itemArr[0]]=itemArr[1];
paramsObj=Object.assign({},paramsObj,item)
// paramStr=JSON.parse(JSON.stringify(item))
}
console.log("paramsObj",paramsObj,jumpType)
if(paramsObj.needLogin ==1&&!that.loginUser){
let urlData = that.getUrlParams('login.html');
that.linkToPage("login.html",urlData,jumpType);
return;
}
if (!linkUrl) {
return;
}
// #ifdef MP
if(!that.loginUser||jumpType=='reLaunch'){
console.log("=========111======")
that.linkToPage(linkUrl,urlData,jumpType,callback)
}else{
console.log("=========22======")
that.checkWxAuthUserInfo(function(){
that.linkToPage(linkUrl,urlData,jumpType,callback)
});
}
// #endif
// #ifdef APP-PLUS ||H5
that.linkToPage(linkUrl,urlData,jumpType,callback)
// #endif
},
checkWxAuthUserInfo:function(callback){
var that=this;
wx.getSetting({//检查用户是否授权了
success(res) {
console.warn("======检查用户是否授权了========", res)
if (!res.authSetting['scope.userInfo'] &&that.authorizationListenerItem&&!that.loginUser.platformUser.headimgurl) {
that.showAuthorizationPopup = true
that.authorizationListener(that.showAuthorizationPopup)
return 'authorization'
} else {
if(that.authorizationListenerItem){
console.log('=====已授权====')
}else{
console.log('=====没有检测到授权窗口item====')
}
callback();
}
}
})
},
linkToPage:function(linkUrl,urlData,jumpType,callback){
let that=this;
let If_Order_url = urlData.url.substr(0, 10);
if (linkUrl.substr(0, 3) == 'tel') {
wx.makePhoneCall({
phoneNumber: linkUrl.substr(4) //仅为示例,并非真实的电话号码
});
} else if (linkUrl.substr(0, 4) == 'http' && (linkUrl.substr(-3, 3).toLowerCase() == 'jpg' || linkUrl.substr(-3, 3).toLowerCase() == 'png')) {
that.lookBigImage(linkUrl);
} else if (linkUrl.substr(0, 12) == 'custom_page_'&&jumpType!='reLaunch') {
var resultUrl = linkUrl.substring(12, linkUrl.length - 5);
if (urlData.param == '') {
urlData.param = '?';
}
wx[jumpType||'navigateTo']({
url: '/pages/custom_page/index' + urlData.param + '&Cpage=' + resultUrl
});
} else if (If_Order_url == 'order_list') {
wx[jumpType||'navigateTo']({
url: '/pages/' + 'order_list_tab' + '/index' + urlData.param
});
} else if (linkUrl.substr(0, 14) == 'search_product') {
console.log("that.clientNo", that.clientNo);
that.goto(((that.properties.style_product_list || "milk_product_list") + ".html" + urlData.param),jumpType);
return;
} else if (linkUrl.substr(0, 18) == 'promotion_products') {
wx[jumpType||'navigateTo']({
url: '/pageTab/tunzai/teMai/index' + urlData.param
});
} else if (linkUrl.substr(0, 23) == 'milk_shopping_car_pages') {
wx[jumpType||'navigateTo']({
url: '/pagesTwo/milk_shopping_car_list/index' + urlData.param
});
} else if (linkUrl.substr(0, 9) == 'goto_mini') {
let appId = linkUrl.substr(21);
console.log("========appId======", appId);
wx.navigateToMiniProgram({
appId: appId,
path: '',
extraData: {},
envVersion: 'release',
success(res) {
console.log("小程序跳转成功", res);
}
});
} else if (linkUrl.substr(0, 13) == 'order_pintuan') {
wx[jumpType||'navigateTo']({
url: '/pages/' + 'order_pintuan_list' + '/index' + urlData.param
});
} else if (linkUrl.substr(0, 5) == 'https') {
let url = encodeURIComponent(linkUrl);
console.log("==url+web_view===", url);
wx[jumpType||'navigateTo']({
url: '/pages/' + 'web_view' + '/index?url=' + url
});
} else if (linkUrl.indexOf('_sysLinkMiniRewardAction') != -1) {
if (callback){
callback()
}
} else if (linkUrl.indexOf('_sysScanQrcode') != -1) {
that.getVerificationCode();
} else if (linkUrl.substr(0, 14) == 'product_detail') {
let productId = linkUrl.replace(/[^0-9]/ig, "");
console.log(linkUrl.substr(15, 6)); //
that.goto(((that.properties.style_product_detail || "productDetail") + ".html" + urlData.param + "&addShopId=0"),jumpType);
return;
} else if (linkUrl.indexOf('login.html') != -1) {
var url= 'app_login_page.html'+ urlData.param
// #ifdef MP
url='wx_login_page.html'+ urlData.param
// #endif
that.goto(url,jumpType);
return;
} else if (urlData.url == 'shop_map') {
that.openLocation();
} else if (urlData.url == 'location') {
console.log(urlData.param + urlData.url);
var params = urlData.param.slice(1);
let paramArr = params.split('&');
var paramObj = {};
for (let i = 0; i < paramArr.length; i++) {
var a = paramArr[i].split('=');
paramObj[a[0]] = a[1];
}
var a = Number(paramObj['latitude']);
var b = Number(paramObj['longitude']);
wx.openLocation({
latitude: a,
longitude: b,
scale: 12,
name: paramObj.title,
address: paramObj.description
});
} else {
that.goto(linkUrl,jumpType);
}
},
checkLogin: function () {
//let that = this
if (!this.loginUser) {
this.wxLogin();
}
},
/* 检查是否过期 */
checkSession: function () {
let that = this;
wx.checkSession({
success: function () {
console.log('session 未过期,并且在本生命周期一直有效');
wx.getStorage({
//拿cookie
key: 'cookie',
success: function (res) {
that.cookie = res.data;
that.header = {
'content-type': 'application/json',
// 默认值
'Cookie': res.data
};
that.headerPost = {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': res.data
};
}
});
wx.getStorage({
key: 'loginUser',
success: function (res) {
that.loginUser = res.data;
}
});
},
fail: function () {
//登录态过期
console.log('登录态过期');
that.wxLogin();
}
});
},
/* 设置cookie */
setCookie: function (cookie) {
console.log("===setCookie===",cookie)
this.cookie = cookie;
this.header = {
'content-type': 'application/json',
// 默认值
'Cookie': cookie
};
this.headerPost = {
'content-type': 'application/x-www-form-urlencoded',
'Cookie': cookie
};
if (cookie) {
wx.setStorage({
key: "cookie",
data: cookie
});
}
},
//存用户信息
setloginUser: function (loginUser, cookie) {
console.log('--------setloginUser----------');
if (loginUser) {
wx.setStorage({
key: "loginUser",
data: loginUser
});
}
// if (cookie) {
// wx.setStorage({
// key: "cookie",
// data: cookie
// });
// }
},
//获取小程序session_key
getSessionFun: function (callback) {
let that=this;
console.log("====getSessionFun===")
uni.login({
//微信登入接口
provider: 'weixin',
success: function (res) {
console.log("=======wxCode======", res.code);
if (res.code && res.code.indexOf('mock') == -1) {
let customIndex = that.AddClientUrl("/wx_get_session_key_with_mini_code.html", {wxAuthCode:res.code}, 'post');
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
success: function (res) {
console.log('===========getSessionFun============', res);
callback(res);
},
fail: function (res) {}
});
} else {
console.log('获取用户登录态失败!' + res.errMsg);
}
},
fail: function (res) {
console.log('---------111111 fail登录失败----------',res);
},
complete: function (res) {
console.log('---------111111 complete登录结束----------',res);
wx.hideLoading();
}
});
},
//获取已经登录了的用户信息和login时一样
get_session_userinfo: function () {
let customIndex = this.AddClientUrl("/get_session_userinfo.html", {}, 'post');
let that = this;
wx.request({
url: customIndex.url,
//仅为示例,并非真实的接口地址
data: customIndex.params,
header: that.headerPost,
success: function (res) {
console.log('===========get_session_userinfo============', res);
if (res.data.errcode == 0) {
console.log(res.data.relateObj);
that.loginUser = res.data.relateObj;
that.setloginUser(res.data.relateObj);
}
},
fail: function (res) {}
});
},
//#ifdef APP-PLUS ||H5
getStorageFun:function(keyData,successFun,failFun){
let that=this;
console.log("====获取本地存储======")
uni.getStorage({
key: keyData,
success: function (res) {
console.log("==success===",res.data);
try{
successFun(res)
}catch(e){
console.log("没有成功回调的函数",e)
//TODO handle the exception
}
},
fail:function(err){
console.log("====fail====",err)
try{
failFun(err)
}catch(e){
console.log("没有成功回调的函数",e)
//TODO handle the exception
}
},
complete:function(){
}
});
},
setStorageFun:function(url,resData){
let that=this;
console.log("====本地存储======")
let resJsonData=JSON.stringify(resData)
uni.setStorage({
key: url,
data: resJsonData,
success: function (res) {
console.log('success',res);
}
});
},
removeStorageFun:function(url){
let that=this;
console.log("====移除本地存储======",url)
uni.removeStorage({
key: url,
success: function (res) {
console.log('success',res);
},
complete: function () {
wx.hideLoading();
}
});
},
//#endif
//sentWxUserInfo 第一次登录给他设置头像
sentWxUserInfo: function (loginJson,callback) {
console.warn("========sentWxUserInfo:loginJson=======", loginJson);
let that = this;
let userInfo = that.userInfo;
wx.getUserInfo({
success: function (res) {
console.log('--获取用户信息--');
console.log(res.userInfo);
userInfo = res.userInfo;
let infoParam = {
headimg: '',
nickname: '',
sex: ''
};
if (loginJson && loginJson.platformUser.telNo) {
console.error(loginJson.platformUser.telNo);
infoParam.telno = loginJson.platformUser.telNo;
} else {
infoParam.telno = '';
}
if(loginJson&&loginJson.platformUser&&loginJson.platformUser.userInfoFormCommitId){
infoParam.userInfoFormCommitId = loginJson.platformUser.userInfoFormCommitId;
}
infoParam.headimg = userInfo.avatarUrl;
infoParam.nickname = userInfo.nickName;
infoParam.sex = userInfo.gender; // 用户所在城市,市,区,
infoParam.city = userInfo.city;
if (that.loginUser.nickName != userInfo.nickName) {
let customIndex = that.AddClientUrl("/change_user_info.html", infoParam, 'post');
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (res) {
console.log('---change_user_info----- success-');
console.log(res.data);
if (res.data.errcode == 0) {
that.loginUser.nickName = userInfo.nickName;
that.loginUser.sex = userInfo.sex;
that.loginUser.userIcon = userInfo.avatarUrl;
console.log('-----第一次登录 传头像成功 --------');
} else {
console.log('-----第一次登录 传头像失败 --------');
}
if(callback){
callback(that.loginUser)
}
that.get_session_userinfo();
},
fail: function (res) {
console.log('-----第一次登录 传头像失败 回调fail--------');
console.log();
},
complete: function (res) {}
});
}
},
fail: function (e) {
console.log(e);
setTimeout(function () {
wx.showModal({
title: '授权提示',
content: '取消用户授权可能导致部分功能不可用,请确认授权!',
cancelText: '拒绝',
confirmText: '去授权',
success: function (res) {
if (res.confirm) {
wx.openSetting({
success: res => {
res.authSetting = {
"scope.userInfo": true
};
that.sentWxUserInfo(loginJson);
}
});
} else if (res.cancel) {}
}
});
}, 500);
}
});
},
getCaption: function (str1) {
var str2 = str1.match(/MINI_PLATFORM_USER_ID_(\S*)/)[1];
console.log("这是测试str2" + str2);
return str2;
},
hasNoScope: false,
showAuthUserInfoButton: true,
changeUserBelong: function (more_scene) {
if (!more_scene) return;
let changeMendianOnly = 0;
if (!this.loginUser || !this.loginUser.platformUser || this.loginUser.platformUser.parentId > 0) {
// console.log("parent id:"+this.loginUser.platformUser.parentId);
console.log("未登录或 已经有推广用户了");
if (this.setting.platformSetting && this.setting.platformSetting.scanChangeBelongMendian) {//判断用户是否可以变更归属门店
changeMendianOnly = 1;
} else {
return;
}
} else {
console.log("修改用户推广人");
}
let that = this;
console.error("hello:" + more_scene);
console.log("测试有没有调用");
let parentPlatformUserId = this.getCaption(more_scene);
console.error(parentPlatformUserId);
if (!parentPlatformUserId) {
return;
}
let param_post = {};
param_post.parentPlatformUserId = parentPlatformUserId;
param_post.changeMendianOnly = changeMendianOnly;
var customIndex = that.AddClientUrl("/change_fx_user.html", param_post, 'post');
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (res) {
console.warn('修改分销 -- 返回');
console.log(res.data);
if (res.data.errcode == 0) {
let loginUser = that.loginUser;
loginUser.platformUser.mendian = res.data.relateObj.mendian;
}
},
fail: function (res) {
that.loadFail();
}
});
},
loginWithLoginToken:function(loginToken,successFun,failFun,nextFun){
let that=this;
console.log("===loginWithLoginToken===",loginToken)
// that.toLogin("/get_session_userinfo.html?jsonOnly=1&loginToken="+loginToken, {},successFun,failFun)
// 修改20200904
that.toLogin("/get_session_userinfo.html?jsonOnly=1&loginToken="+loginToken, {},successFun,failFun).then(successData =>{
console.log("登入成功",successData);
that.getSetting().then(function(){
if(nextFun){
nextFun()
}
});
})
},
appLogin:function(params,successFun,failFun){
let that=this;
console.log("=====app登录=====",)
that.toLogin("/login.html?jsonOnly=1", params,successFun,failFun)
},
checkUserInfoFormCommit:function(){
let that=this
if (that.setting.platformSetting.userInfoCustomFormId&&that.setting.platformSetting.userNeedShenhe > 0 && that.loginUser &&!that.loginUser.platformUser.userInfoFormCommitId) {
that.linkEvent("pre_change_user_info.html",'reLaunch')
}
},
toLogin:function(url,params,successFun,failFun){
var that = this;
console.log("====url===",url,params)
let customIndex = that.AddClientUrl(url, params, 'post');
console.log("====customIndex===",customIndex)
return new Promise(function (resolve, reject){
resolve("登录中")
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (e) {
resolve("===调用成功====");
console.log("===========wx.login=============", e);
let header = e.header;
let cookie = null;
if (!!header['Set-Cookie']) {
cookie = header['Set-Cookie'];
}
if (!!header['set-cookie']) {
cookie = header['set-cookie'];
}
let loginJson = e.data.relateObj;
console.log("====cookie====",cookie)
that.setCookie(cookie);
// wx.getStorage({
// key: 'cookie',
// success: function (res) {
// cookie=res.data
// that.setCookie(cookie);
// },
// fail:function(err){
// console.log("cookie-fail",err)
// that.setCookie(cookie);
// },
// });
if (e.data.errcode == 0) {
resolve("===调用成功====");
that.setStorageFun("loginToken",loginJson.platformUser.loginToken);
that.loginToken=loginJson.platformUser.loginToken;
if(successFun){
successFun(e)
}
//that.setStorageFun("loginToken",loginJson.platformUser.loginToken)
console.log('登陆成功');
if (loginJson.platformUser.scanChangeBelongMendian == 1 && that.enterMenDianID != 0 && loginJson.platformUser.belongMendian != that.enterMenDianID && !loginJson.platformUser.managerMendianId) {
console.warn("扫码进来的变更归属门店");
that.changeUserBelongMendianFun(that.enterMenDianID,function(res){
console.log("==changeUserBelongMendianFun==",res)
loginJson.platformUser = res.data.relateObj;
that.setloginUser(loginJson, cookie);
that.loginUser = loginJson;
console.log("==that.loginUser====",that.loginUser)
that.globalData.sansanUser = that.loginUser;
})
} else {
// 把用户信息和cookie存在本地
that.setloginUser(e.data.relateObj, cookie);
that.loginUser = e.data.relateObj;
that.sansanUser = e.data.relateObj;
}
// 未登入成功的将登入成功的数据一一给与赋值
if (that.loginSuccessListeners && that.loginSuccessListeners.length > 0) {
for (let t = 0; t < that.loginSuccessListeners.length; t++) {
try {
that.loginSuccessListeners[t].loginSuccess(that.loginUser);
} catch (e) {
console.log(e);
}
}
}
wx.hideLoading();
socketFun.socketConnect();//链接通讯
// if (!loginJson.platformUser.nickname) {// console.error('没有昵称调用上传接口')
// //that.sentWxUserInfo(loginJson)
// }
that.changeUserBelong(that.USER_DEFINED_SCENE); //修改推荐人
that.checkUserInfoFormCommit();
} else {
console.log("失败原因" + JSON.stringify(e.data));
if(failFun){
failFun(e)
}
wx.hideLoading();
if (that.loginSuccessListeners && that.loginSuccessListeners.length > 0) {
console.log('000000000000', that.loginSuccessListeners);
for (let t = 0; t < that.loginSuccessListeners.length; t++) {
try {
that.loginSuccessListeners[t].loginFailed(e.data);
} catch (e) {
console.log(e);
}
}
}
}
},
fail: function (e) {
console.log('----fail------',e);
if(failFun){
failFun(e)
}
if (that.loginSuccessListeners && that.loginSuccessListeners.length > 0) {
for (let t = 0; t < that.loginSuccessListeners.length; t++) {
try {
that.loginSuccessListeners[t].loginFailed(e);
} catch (e) {
console.log(e);
}
}
}
}
})
})
},
changeUserBelongMendianFun:function(id,callback){
let that=this;
let customIndex = that.AddClientUrl("/wx_change_belong_mendian.html", {
scanMendianId: id
});
wx.request({
url: customIndex.url,
header: that.header,
success: function (res) {
console.log('change_belong_mendian', res);
if(callback){
callback(res)
}
},
fail: function (res) {
console.warn("change_belong_mendian_fail");
}
});
},
/* 微信登录测试 */
wxLogin: function (more_scene,successFun,failFun,nextFun) {
console.warn("===wxLogin===", more_scene);
if (!more_scene || more_scene == 'undefined') {
more_scene = '0';
}
var that = this;
console.log('--------------微信登录--------------');
uni.getProvider({
service: 'oauth',
success: function (res) {
console.log("===getProvider===",res.provider)
if (~res.provider.indexOf('weixin')) {
that.showToastLoading('登录中', true);
uni.login({
//微信登入接口
provider: 'weixin',
success: function (res) {
console.log("=======wxCode======", res.code, more_scene);
if (res.code && res.code.indexOf('mock') == -1) {
//发起网络请求
let loginParam = {};
loginParam.code = res.code;
loginParam.scene = more_scene;
// that.toLogin("/wx_mini_code_login.html",loginParam,successFun,failFun)
// 请求修改20200904
that.toLogin("/wx_mini_code_login.html",loginParam,successFun,failFun).then(newData =>{
console.log("====登入成功====",newData)
that.getSetting().then(function(){
console.log("app中以获取Setting");
if(nextFun){
nextFun()
}
})
});
} else {
console.log('获取用户登录态失败!' + res.errMsg);
}
},
fail: function (res) {
// 请求修改20200904
that.getSetting().then(function(){
console.log("app中以获取Setting");
if(nextFun){
nextFun()
}
})
console.log('---------111111 fail登录失败----------',res);
},
complete: function (res) {
console.log('---------111111 complete登录结束----------',res);
wx.hideLoading();
}
});
}
}
});
},
loginOut:function(url,params,successFun,failFun){
let that = this;
console.log("====url===",url,params)
let customIndex = that.AddClientUrl(url, params||{}, 'post');
console.log("====customIndex===",customIndex)
wx.request({
url: customIndex.url,
data: customIndex.params,
header: that.headerPost,
method: 'POST',
success: function (e) {
console.log("===========loginOut=============", e);
if (e.data.errcode == 0) {
console.log('---------退出成功----------',e);
that.showToastFun("退出成功!",1000,'success')
if(successFun){
successFun()
}
that.removeStorageFun("loginToken")
that.removeStorageFun("loginParams")
that.loginUser = null;
that.removeStorageFun("loginUser",function(res){
console.log(res.data);
console.log("==1==",that.loginUser);
that.loginUser = null;
console.log("==2==",that.loginUser);
})
that.removeStorageFun("cookie",function(res){
console.log(res.data);
that.cookie = null;
that.header = {
'content-type': 'application/json' // 默认值
};
that.headerPost = {
'content-type': 'application/x-www-form-urlencoded'
};
})
setTimeout(function(){
that.toIndex("reLaunch");
},1000)
}
},
fail: function (res) {
console.log('---------退出失败----------',res);
if(failFun){
failFun()
}
},
})
},
//获取setting
getSetting: function (self) {
if (!self) {
self = 0;
}
console.log('**************************************', self);
var settUrl = this.AddClientUrl("/get_platform_setting.html", {}, 'get', 1, 1);
var that = this;
console.log("======settUrl.url======", settUrl.url,that.header); //拿setting
return new Promise(function (resolve, reject) {
wx.request({
url: settUrl.url,
//仅为示例,并非真实的接口地址
header: that.header,
method: 'GET',
success: function (res) {
resolve(res);
console.log("====Promise-resSetting====", res.data); //获取门店ID
console.log("====门店ID====", res.data.platformSetting.defaultShopBean.defaultMendianId);
that.defaultMendianID = res.data.platformSetting.defaultShopBean.defaultMendianId;
if (res.data.platformSetting) {
that.clientName = res.data.platformSetting.platformName;
that.properties = res.data.platformSetting.properties;
if (res.data.platformSetting.categories) {
//产品类别
let categories = res.data.platformSetting.categories;
let allType = {};
allType.id = 'all';
allType.name = '全部';
allType.active = true;
for (let i = 0; i < categories.length; i++) {
categories[i].active = false;
}
categories.unshift(allType);
}
}
that.setting = res.data;
if (res.data.platformSetting.miniIndexPage) {
let miniIndexPage = that.getSpaceStr(res.data.platformSetting.miniIndexPage, '.');
that.miniIndexPage = miniIndexPage.str1;
that.miniIndexPageParams = miniIndexPage.str2;
} else {
that.miniIndexPage = 'custom_page_index';
}
if (!self) {} else {
self.setData({
setting: res.data
});
self.setNavBar();
}
wx.hideLoading(); //隐藏 loading 提示框
return;
let ShopBean = res.data.platformSetting.defaultShopBean;
if (ShopBean.serviceStartTime) {} // 完成初次加载
that.successOnlaunch = true;
},
fail: function (res) {
reject('error');
wx.hideLoading(); //隐藏 loading 提示框
that.loadFail(); //获取失败
}
});
// return new Promise(function (resolve, reject) {
//
// });
})
},
//微信内部地图
openLocation: function () {
console.log('---------打开地图-------');
let markers = this.setting.platformSetting.defaultShopBean;
let lat = Number(markers.latitude);
let lng = Number(markers.longitude);
let name = markers.shopName;
let address = '';
wx.getLocation({
type: 'gcj02',
//返回可以用于wx.openLocation的经纬度
success: function (res) {
console.log('11111');
wx.openLocation({
latitude: Number(markers.latitude),
longitude: Number(markers.longitude),
scale: 28,
name: name,
address: address,
success: function (res) {
console.log(res);
},
fail: function (res) {
console.log(res);
}
});
},
fail: function (res) {
console.log('22222');
console.log(res);
}
});
},
// 拼团转发
sharePintuan: function (pageName, pageTitle, pageCode) {
console.log('pageCode', pageName, pageTitle, pageCode);
let that = this;
let AllCode = '';
if (!pageCode) {
pageCode = '';
}
AllCode = pageCode;
console.log('AllCode', AllCode);
return {
title: pageTitle,
path: '/pages/' + pageName + '/index?' + AllCode,
success: function (res) {
console.log('转发出去的参数集合: ' + AllCode);
},
fail: function (res) {}
};
},
//带参转发
shareForFx: function (pageName, pageTitle, pageCode) {
let that = this;
let AllCode = '';
let fxCode = ''; //userId
if (this.loginUser) {
fxCode = 'scene=MINI_PLATFORM_USER_ID_' + this.loginUser.platformUser.id;
} else {
fxCode = 'scene=MINI_PLATFORM_USER_ID_' + this.more_scene;
}
if (!pageName) {
pageName = 'index';
}
if (!pageTitle) {
pageTitle = that.clientName;
}
if (!pageCode) {
pageCode = '';
AllCode = fxCode;
} else {
AllCode = fxCode + '&' + pageCode;
}
console.log('AllCode', AllCode);
return {
title: pageTitle,
path: '/pages/' + pageName + '/index?' + AllCode,
success: function (res) {
console.log('转发出去的参数集合: ' + AllCode);
},
fail: function (res) {}
};
},
// 获取二维码
getQrCode: function (data) {
console.log(" this.loginUser", this.loginUser);
let userId = "";
let mendianId = "";
if (this.loginUser && this.loginUser.platformUser) {
userId = 'MINI_PLATFORM_USER_ID_' + this.loginUser.platformUser.id;
if (this.loginUser.platformUser.managerMendianId) {
mendianId = '%26ENTER_MENDIAN%3d' + this.loginUser.platformUser.managerMendianId;
}
}
console.log("this.loginUser.platformUser", this.loginUser.platformUser.id);
console.log("data", data); // path=pageTab%2findex%2findex%3fAPPLY_SERVER_CHANNEL_CODE%3d'
let postParam = {};
if(data.otherParams){
postParam=JSON.parse(JSON.stringify(data.otherParams))
}
let str = '';
let str2 = '';
if (data.type == 'active') {
str = 'SHARE_PROMOTION_PRODUCTS_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_PROMOTION_PRODUCTS_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'news_detail') {
console.log(data.type);
str = 'SHARE_NEWS_DETAIL_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_NEWS_DETAIL_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'form_detail') {
console.log(data.type);
str = 'SHARE_FORM_DETAIL_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_FORM_DETAIL_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'check_form_detail') {
console.log(data.type);
str = 'SHARE_CHECK_FORM_DETAIL_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_CHECK_FORM_DETAIL_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'user_info') {
console.log(data.type);
str = 'SHARE_USER_INFO_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_USER_INFO_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'card_voucher') {
console.log(data.type);
str = 'SHARE_CARD_VOUCHER_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_CARD_VOUCHER_PAGE%3d';
postParam[str] = data.id;
} else if (data.type == 'pin_tuan') {
console.log(data.type);
str = 'PINTUAN_CODE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fPINTUAN_CODE%3d';
postParam[str] = data.id;
// 公用海报
} else if (data.type == 'common_page') {
console.log(data.type);
str = 'COMMON_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fCOMMON_PAGE%3d';
postParam[str] = data.id;
} else {
str = 'SHARE_PRODUCT_DETAIL_PAGE';
str2 = '/super_shop_manager_get_mini_code.html?mini=1&path=pageTab%2findex%2findex%3fSHARE_PRODUCT_DETAIL_PAGE%3d';
postParam[str] = data.id;
}
postParam.scene = userId;
console.log(str, str2, postParam); // 上面是需要的参数下面的url
var customIndex = this.AddClientUrl(str2 + postParam[str] + "%26hyaline%3d" + 1 + "%26scene%3d" + userId + mendianId, postParam, 'get', '1');
let paramStr=''
if(data.otherParams){
paramStr=encodeURIComponent('&'+this.jsonToStr2(data.otherParams));
}
console.log("==paramStr===",paramStr)
var result = customIndex.url.split("?");
customIndex.url = result[0] + "?" + result[1]+paramStr;
console.log("customIndex", customIndex.url, result[0]);
var that = this;
return customIndex.url;
},
shareForFx2: function (pageName, pageTitle, pageCode, imageUrl, aliasName) {
//组合参数,交给custompage_index 解析
// 组合参数所带
console.log("000000000000", pageName);
console.log("111111111111", pageTitle);
console.log("333333333333", pageCode);
let that = this;
let AllCode = '';
let fxCode = ''; //userId
if (that.loginUser && that.loginUser.platformUser) {
fxCode = 'scene=MINI_PLATFORM_USER_ID_' + that.loginUser.platformUser.id;
}
if (!pageName && !that.miniIndexPage) {
if (!that.miniIndexPage) {
pageName = 'custom_page_index';
} else {
pageName = that.miniIndexPage;
}
}
if (!pageTitle) {
pageTitle = that.clientName;
}
if (!pageCode) {
pageCode = {};
} // title存在的时候显示活动名
pageCode.clientNo= that.clientNo
if (pageCode.title && pageCode.title != "") {
pageTitle = that.clientName + "-" + pageCode.title;
}
if (pageCode.shopName) {
console.log("=========shopName=====", pageCode.shopName);
pageTitle = pageCode.shopName;
}
if (that.loginUser && that.loginUser.platformUser) {
pageCode.scene = 'MINI_PLATFORM_USER_ID_' + that.loginUser.platformUser.id;
} else {
pageCode.scene = 'MINI_PLATFORM_USER_ID_' + 0;
} // 如果带有id的产品传参则进入产品详情页
if (pageCode.id && pageCode.id != "" && pageName == "productDetail") {
pageCode.SHARE_PRODUCT_DETAIL_PAGE = pageCode.id;
} else if (pageCode.id && pageCode.id != "" && pageName == "news_detail") {
pageCode.SHARE_NEWS_DETAIL_PAGE = pageCode.id;
} else {
pageCode.SHARE_COMMON_PAGE = pageCode[aliasName];
pageCode.linkUrl = pageName;
}
if (pageCode.belongShop && pageCode.belongShop != "") {
pageCode.ENTER_SHOP = pageCode.belongShop;
} // jsonToStr2在333行
AllCode = that.jsonToStr2(pageCode);
console.log('转发出去的参数集合: ' + AllCode);
console.log('转发出去的imageUrl: ' + imageUrl);
console.log('转发出去的pageTitle: ' + pageTitle);
return {
title: pageTitle,
query:AllCode,
path: '/pageTab/index/index?' + AllCode,
imageUrl: imageUrl,
success: function (res) {},
fail: function (res) {}
};
},
toFix: function (money) {
money = money.toFixed(2);
return money;
},
lookBigImage: function (url, urls) {
console.log("==lookBigImage===", url, urls);
if (!url) {
return;
}
if (!urls) {
urls = [];
urls.push(url);
}
wx.previewImage({
current: url,
// 当前显示图片的http链接
urls: urls // 需要预览的图片http链接列表
});
},
getRad: function (d) {
let PI = Math.PI;
return d * PI / 180.0;
},
getDistance: function (lng1, lat1, lng2, lat2) {
let that = this;
let EARTH_RADIUS = 6378.1370; //单位KM
lng1 = parseFloat(lng1);
lat1 = parseFloat(lat1);
lng2 = parseFloat(lng2);
lat2 = parseFloat(lat2);
let radLat1 = that.getRad(lat1);
let radLat2 = that.getRad(lat2);
let a = radLat1 - radLat2;
let b = that.getRad(lng1) - that.getRad(lng2);
let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s = s * EARTH_RADIUS;
s = Math.round(s * 10000) / 10000.0;
console.log("====getDistance===", s);
return s;
},
showPrice: function (cartData, checkedItem) {
console.log("=====app-showPrice======", cartData, checkedItem);
let objData = {};
if (!cartData) {
// this.setData({
// countGood: 0,
// countPrice: 0
// })
objData = {
countGood: 0,
countPrice: 0
};
return objData;
}
var cartDataItem = cartData[0].carItems;
var checkedItem = checkedItem;
var pushItem = [];
var countGood = 0;
var countPrice = 0;
for (let i = 0; i < cartDataItem.length; i++) {
if (checkedItem) {
for (let j = 0; j < checkedItem.length; j++) {
if (cartDataItem[i].id == checkedItem[j]) {
pushItem.push(cartDataItem[i]);
}
}
} else {
pushItem.push(cartDataItem[i]);
}
} // for (let i = 0; i < cartDataItem.length; i++) {
// pushItem.push(cartDataItem[i])
// }
for (let i = 0; i < pushItem.length; i++) {
countGood += parseInt(pushItem[i].count);
console.log("====pushItem=====", pushItem[i]);
let promotionPrice = 0;
let carItemPrice = 0;
let specialSaleTypePrice = 0;
if (pushItem[i].item.itemSpecialSaleType == 1) {
if (parseInt(pushItem[i].count) * pushItem[i].carItemPrice >= Number(pushItem[i].item.itemSpecialSaleValue1)) {
specialSaleTypePrice = Number(pushItem[i].item.itemSpecialSaleValue2);
}
}
if (pushItem[i].item.promotion && pushItem[i].item.promotion != 0) {
promotionPrice = pushItem[i].item.promotionPrice;
} else {
carItemPrice = pushItem[i].carItemPrice;
}
console.log("====pushItem=====", promotionPrice, carItemPrice, specialSaleTypePrice);
if (pushItem[i].item.promotion && pushItem[i].item.promotion != 0) {
countPrice += parseInt(pushItem[i].count) * promotionPrice - specialSaleTypePrice;
} else {
countPrice += parseInt(pushItem[i].count) * carItemPrice - specialSaleTypePrice;
} // if (pushItem[i].item.promotion && pushItem[i].item.promotion!=0) {
// countPrice += parseInt(pushItem[i].count) * pushItem[i].item.promotionPrice
// } else {
// countPrice += parseInt(pushItem[i].count) * pushItem[i].carItemPrice
// }
}
countPrice = Number(countPrice.toFixed(2));
objData = {
pushItem: pushItem,
countGood: countGood,
countPrice: countPrice
};
return objData; // this.setData({
// pushItem: pushItem,
// countGood: countGood,
// countPrice: countPrice
// })
},
calling: function (phoneNumber) {
console.log('====e===', phoneNumber);
wx.makePhoneCall({
phoneNumber: phoneNumber,
//此号码并非真实电话号码,仅用于测试
success: function () {
console.log("拨打电话成功!");
},
fail: function () {
console.log("拨打电话失败!");
}
});
},
navigationToMap: function (info) {
console.log("===navigationToMap===",info);
// let info = e.currentTarget.dataset.info;
console.log(info);
let latitude = info.latitude || info.buyerLatitude;
let longitude = info.longitude || info.buyerLongitude;
let name = info.name || info.buyerName || info.belongShopName;
let address = info.address || info.buyerProvince + info.buyerCity + info.buyerArea + info.buyerAddress; // 判断金纬度是否为空
if (latitude == 0 || longitude == 0) {
console.log("判断金纬度是否为空");
wx.showModal({
title: '提示',
content: '主人~该门店没有设置位置哦!',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
}
});
return;
} else {
wx.openLocation({
latitude: latitude,
longitude: longitude,
scale: 12,
name: name,
address: address
});
}
},
SDKVersion: '',
// 个人信息,连接90行
getSdkVersion: function () {
//获取版本信息
let that = this;
wx.getSystemInfo({
success: function (res) {
console.log("=======getSystemInfo=========", res);
that.SDKVersion = res.SDKVersion;
}
});
},
compareVersion: function (v1, v2) {
//判断版本大小
v1 = v1.split('.');
v2 = v2.split('.');
var len = Math.max(v1.length, v2.length);
while (v1.length < len) {
v1.push('0');
}
while (v2.length < len) {
v2.push('0');
}
for (var i = 0; i < len; i++) {
var num1 = parseInt(v1[i]);
var num2 = parseInt(v2[i]);
if (num1 > num2) {
return 1;
} else if (num1 < num2) {
return -1;
}
}
return 0;
},
consoleFun:function(text,consoleData){
if(consoleData){
for(let i=0;i<consoleData.length;i++){
console.log((text?text:'')+i,consoleData[i])
}
}else{
console.log(text)
}
},
// 时间段
getNextSevenDays: function (num,type) {
let that = this;
let myDate = new Date();
let curDayData = myDate.getDay();
let curLocaleData = myDate.toLocaleDateString(); //获取当前日期
let nextSevenDaysList=[];
let dataNum=num||7
for (let i = 0; i < dataNum; i++) {
let switchData;
let oneData;
if (i + curDayData > 6 && i + curDayData < 14) {
switchData = i + curDayData - 7;
} else if (i + curDayData >= 14) {
switchData = i + curDayData - 14;
} else {
switchData = i + curDayData;
}
switch (switchData) {
case 0:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 1:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 2:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 3:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 4:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 5:
let oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
case 6:
oneData = that.getOneDay(i,type);
nextSevenDaysList.splice(nextSevenDaysList.length, 0, {
weekData: i != 0 ? '' : '',
oneData: oneData,
oneDataStr: oneData.slice(5).replace('-','.')
});
break;
}
}
return nextSevenDaysList
},
getOneDay: function (day,type) {
var dd = new Date();
dd.setDate(dd.getDate() + day); //获取AddDayCount天后的日期
var y = dd.getFullYear();
var m = dd.getMonth() + 1 < 10 ? (type=='00'?'0':'') + (dd.getMonth() + 1) : dd.getMonth() + 1; //获取当前月份的日期
var d = dd.getDate() < 10 ? (type=='00'?'0':'') + dd.getDate() : dd.getDate();
return y + "-" + m + "-" + d;
},
contrastTimeFun:function(time){
let that=this;
console.log("===contrastTimeFun===",time);
var t1 = time;
var d1 = t1.replace(/\-/g, "/");
var date1 = new Date(d1);
var today = new Date();
if(date1 .getTime()< today .getTime()){
return false
}else{
return true
}
},
},
onHide: function (e) {
console.log('hide', this.$options.globalData.shareSubPage);
console.log(e);
},
onShow: function (e) {
let that = this;
console.log('======app.show=====', that.$options.globalData);
console.log("=======eeeee======", e,that.$options.globalData.clientNo);
if(e){
that.$options.globalData.onLaunchOptions = e;
}
// if(e.scene == "1008"||e.scene == "1007"|| e.scene == "1047"){
// // that.$options.globalData.getSetting();
// that.$options.globalData.wxLogin(that.$options.globalData.more_scene,0,0);
// }
if (e.scene == "1011" || e.scene == "1012" || e.scene == "1013" || e.scene == "1047") {
that.$options.globalData.appHide = true;
console.log("=====1011====");
if (e.query.platformNo) {
console.log("HAHAHAHHAA" + e.query.platformNo);
if(e.query.platformNo!=that.$options.globalData.clientNo){
that.$options.globalData.shareSubPage = true;
that.$options.globalData.setting={platformSetting: {defaultColor: "#fff",secondColor: "#fff"}},
that.$options.globalData.clientNo=e.query.platformNo
that.$options.globalData.getSdkVersion();
let more_scene = decodeURIComponent(that.$options.globalData.onLaunchOptions.scene);
if (more_scene) {
that.$options.globalData.more_scene = more_scene;
}
console.log("clinetNo:" + that.$options.globalData.clientNo + " more_scene:" + more_scene);
that.$options.globalData.loadFirstEnter(more_scene);
}
}else{
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
console.log('extConfig1',extConfig);
if (extConfig.clientNo) {
console.log('extConfig2',extConfig);
if(extConfig.clientNo!=that.$options.globalData.clientNo){
that.$options.globalData.shareSubPage = true;
that.$options.globalData.setting={platformSetting: {defaultColor: "#fff",secondColor: "#fff"}},
that.$options.globalData.clientNo = extConfig.clientNo;
that.$options.globalData.getSdkVersion();
let more_scene = decodeURIComponent(that.$options.globalData.onLaunchOptions.scene);
if (more_scene) {
that.$options.globalData.more_scene = more_scene;
}
console.log("clinetNo:" + that.$options.globalData.clientNo + " more_scene:" + more_scene);
if(options.scene=='1154'||options.scene=='1155'){
that.$options.globalData.loadFirstEnter(more_scene);
}
}
}
}
}
console.log("=====on show===" + that.$options.globalData.clientNo);
/* let pagePath = e.path
if(this.appHide){
this.appHide = false
} */
},
/* 第一次加载 */
onLaunch: function (options) {
let that = this;
console.log('------onLaunch------', options,that.$options.globalData.clientNo);
that.$options.globalData.onLaunchOptions = options||{};
// this.getSdkVersion()获取 个人信息例如name,nickname,password,platformNo,手机号等等 在900行
that.$options.globalData.getSdkVersion();
let extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
console.log('extConfig1',extConfig);
if (extConfig.clientNo) {
console.log('extConfig2',extConfig);
that.$options.globalData.clientNo = extConfig.clientNo;
}
console.log('===' + that.$options.globalData.clientNo + '====');
console.log("options111", that.$options.globalData.onLaunchOptions);
let inputPlatformNo = that.$options.globalData.onLaunchOptions.query.platformNo;
if (!!inputPlatformNo) {
that.$options.globalData.clientNo = inputPlatformNo;
}
let more_scene = decodeURIComponent(that.$options.globalData.onLaunchOptions.scene);
if (more_scene) {
that.$options.globalData.more_scene = more_scene;
}
console.log("clinetNo:" + that.$options.globalData.clientNo + " more_scene:" + more_scene);
if(options.scene=='1154'||options.scene=='1155'){
console.log("======11154======")
that.$options.globalData.loadFirstEnter(more_scene);
}
if(options.scene == "1008"||options.scene == "1007"||options.scene == "1047"){
// that.$options.globalDat.getSetting();
console.log("======1007======")
that.$options.globalData.wxLogin(that.$options.globalData.more_scene,0,0);
}
},
methods: {}
};
</script>
<style>
/* @import url("./components/gaoyia-parse/parse.css");*/
@import "./app.css";
</style>
微信
1
https://gitee.com/iskyu/venue-booking-procedures.git
git@gitee.com:iskyu/venue-booking-procedures.git
iskyu
venue-booking-procedures
场馆预定小程序
master

搜索帮助