1468 lines
47 KiB
JavaScript
1468 lines
47 KiB
JavaScript
import newhost from "/host.js";
|
||
import locales from "/utils/language.js";
|
||
|
||
var QQMapWX = require('/mymap/qqmap-wx-jssdk.min.js');
|
||
var qqmapsdk;
|
||
var yzFirstlogin = 1;
|
||
var yzValidate_page = 1;
|
||
let livePlayer = null;
|
||
try {
|
||
livePlayer = requirePlugin("live-player-plugin");
|
||
} catch (error) {
|
||
}
|
||
|
||
var loginTap = false;
|
||
// var loginTap = false;
|
||
App({
|
||
data: {
|
||
// wx_token: ''
|
||
host: newhost.host,
|
||
uniacid: newhost.uniacid,
|
||
store_id: newhost.store_id,
|
||
basic_info: {},
|
||
validate_page: {},
|
||
front_accept_message_id: "wx446c12387876992d", //后屏幕小程序appdid
|
||
front_mini_programs_id: "wxf90477356b51ec91",
|
||
accept_message_id: "wxa0ecf1f5513abab3", //前屏幕小程序appdid
|
||
mini_programs_id: "wxf90477356b51ec91",
|
||
clearlogin: null,
|
||
|
||
login_type: 1, //1无请求,2正在请求 状态锁
|
||
login_fun_list: [] // 需要登录后再请求的接口队列
|
||
},
|
||
onLaunch(options) {
|
||
let that = this;
|
||
wx.getSystemInfo({
|
||
success: (res) => {
|
||
this.globalData.statusBarHeight = res.statusBarHeight;
|
||
this.globalData.navBarHeight = 44 + res.statusBarHeight;
|
||
},
|
||
});
|
||
this._getLanguage(locales);
|
||
//删除首次模板信息
|
||
try {
|
||
// 每次关闭要清除存储
|
||
wx.removeStorageSync("tempIndex");
|
||
wx.removeStorageSync("iPhoneBottom");
|
||
wx.removeStorageSync("deliverId");
|
||
} catch (e) {
|
||
// Do something when catch error
|
||
}
|
||
|
||
//记录首次进入小程序页面
|
||
try {
|
||
if (options.query) {
|
||
console.log(options, 'options1');
|
||
this.seyzredirect(options.path, options.query);
|
||
if (options.query.store_alone_id ||options.query.store_id) {
|
||
// 如果有store_alone_id,进入门店独立模块
|
||
this.globalData.STORE_ID = options.query.store_alone_id || newhost.store_id;
|
||
this.globalData.store_alone_temp = 1;
|
||
}
|
||
if (options.query.dyID) {
|
||
//deliverId 获取链接上的参数,自提点id
|
||
this.setDeliver(options);
|
||
}
|
||
} else {
|
||
// wx.setStorageSync("yz_redirect", options.path);
|
||
this.seyzredirect(options.path);
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
//隐藏底部菜单栏
|
||
// wx.hideTabBar({})
|
||
|
||
// try {
|
||
// wx.removeStorageSync('withdraw_status')
|
||
// } catch (e) {
|
||
// // Do something when catch error
|
||
// }
|
||
if (options.query.mid) {
|
||
this._setMid(options.query.mid);
|
||
}
|
||
if (options.query && options.query.scene) {
|
||
let scene = decodeURIComponent(options.query.scene);
|
||
if (scene) {
|
||
let info_arr = [];
|
||
info_arr = scene.split(',');
|
||
for (let i = 0; i < info_arr.length; i++) {
|
||
let chil_arr = [];
|
||
chil_arr = info_arr[i].split('=');
|
||
if (chil_arr[0] == 'mid') {
|
||
this._setMid(chil_arr[1]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
this.gotochecklogin(options);
|
||
this.getSystemInfo();
|
||
try {
|
||
//获取青蛙相关信息
|
||
wxfaceapp.checkWxFacePayOsInfo({
|
||
success(res) {
|
||
console.log("1111111::::::", res.screenInfo);
|
||
if (res.screenInfo == "back-screen") {
|
||
wxfaceapp.onRemoteMessage(function (resdata) {
|
||
if (resdata.content) {
|
||
let content = JSON.parse(resdata.content);
|
||
if (content.redirectType) {
|
||
if (content.redirectType == "succeededPayment") {
|
||
wx.redirectTo({
|
||
url: "/packageC/frogpro/succeededPayment/succeededPayment?money=" + content.money,
|
||
});
|
||
} else if (content.redirectType == "login") {
|
||
wx.redirectTo({
|
||
url: "/packageC/frogpro/backScreenlogin/backScreenlogin",
|
||
});
|
||
} else if (content.redirectType == "lose") {
|
||
wx.redirectTo({
|
||
url: "/packageC/frogpro/lose/lose?money=" + content.money,
|
||
});
|
||
} else if (content.redirectType == "waitingPayment") {
|
||
wx.redirectTo({
|
||
url: "/packageC/frogpro/waitingPayment/waitingPayment?money=" + content.money,
|
||
});
|
||
}
|
||
}
|
||
}
|
||
});
|
||
that.startLogin();
|
||
}
|
||
},
|
||
fail(res) {
|
||
},
|
||
});
|
||
} catch (e) {
|
||
//TODO handle the exception
|
||
}
|
||
console.log(this.globalData.STORE_ID, 'STORE_ID=============>>>>>>>>>>');
|
||
this.overShare();
|
||
|
||
wx.setInnerAudioOption({
|
||
obeyMuteSwitch: false,
|
||
// 解决小程序createInnerAudioContext()音频播放iOS端真机调试没有声音问题
|
||
success: function (res) {
|
||
console.log("开启静音模式下播放音乐的功能");
|
||
},
|
||
|
||
fail: function (err) {
|
||
console.log("静音设置失败");
|
||
},
|
||
});
|
||
|
||
},
|
||
onShow(options) {
|
||
// 页面出现在前台时执行
|
||
// this.getInvite();
|
||
yzFirstlogin = 1;
|
||
yzValidate_page = 1;
|
||
this.data.login_type = 1;
|
||
this._getTemplate();
|
||
if (options.query && options.query.custom_params) {
|
||
this._setMid(JSON.parse(decodeURIComponent(options.query.custom_params)).mid);
|
||
}
|
||
const sceneList = [1007, 1008, 1014, 1044, 1045, 1046, 1047, 1048, 1049, 1073, 1154, 1155];
|
||
// 分享卡片入口场景才调用getShareParams接口获取以下参数
|
||
console.log(options, 'onShow');
|
||
if (livePlayer && sceneList.indexOf(options.scene) > -1) {
|
||
livePlayer
|
||
.getShareParams()
|
||
.then((res) => {
|
||
console.log('get room id', res.room_id); // 房间号
|
||
// console.log('get openid', res.openid) // 用户openid
|
||
// console.log('get share openid', res.share_openid) // 分享者openid,分享卡片进入场景才有
|
||
console.log("get custom params", res.custom_params); // 开发者在跳转进入直播间页面时,页面路径上携带的自定义参数,这里传回给开发者
|
||
this._setMid(res.custom_params.mid);
|
||
})
|
||
.catch((err) => {
|
||
console.log("get share params", err);
|
||
});
|
||
}
|
||
if (options.referrerInfo && options.referrerInfo.extraData) {
|
||
this.globalData.integralOtherMiniData = options.referrerInfo.extraData || {};
|
||
}
|
||
if (options.query.store_alone_id) {
|
||
// 如果有store_alone_id,进入门店独立模块
|
||
this.globalData.STORE_ID = options.query.store_alone_id;
|
||
this.globalData.store_alone_temp = 1;
|
||
}
|
||
},
|
||
onHide() {
|
||
// 会员的弹窗广告
|
||
wx.removeStorageSync("firstAdvertisement");
|
||
// 首页的弹窗广告
|
||
wx.removeStorageSync("fullAdvertisement");
|
||
wx.removeStorageSync("popAdvertisement");
|
||
//装修的弹窗广告
|
||
wx.removeStorageSync("page_idFull_screens");
|
||
wx.removeStorageSync("page_idAdvertisings");
|
||
// 关闭时删除Storage的地址
|
||
wx.removeStorageSync("address-point");
|
||
|
||
// 新装修数据
|
||
wx.removeStorageSync("home_onUnload");
|
||
wx.removeStorageSync("new_decorate");
|
||
},
|
||
/**
|
||
* url 请求地址
|
||
* data 请求的参数
|
||
* success 成功的回调
|
||
* fail 失败的回调
|
||
* complete 结束的回调函数(调用成功、失败都会执行)
|
||
*/
|
||
_getNetWork: function (_ObjData) {
|
||
return this._Request(_ObjData, 'GET');
|
||
},
|
||
/**
|
||
* url 请求地址
|
||
* success 成功的回调
|
||
* fail 失败的回调
|
||
* complete 结束的回调函数(调用成功、失败都会执行)
|
||
*/
|
||
_postNetWork: function (_ObjData) {
|
||
return this._Request(_ObjData, 'POST');
|
||
},
|
||
|
||
_Request(obj, method) {
|
||
return new Promise((resolve, reject) => {
|
||
obj.resolve = resolve;
|
||
obj.reject = reject;
|
||
obj.method = method;
|
||
//1就发起第一次请求,2加入队列数组
|
||
if (this.data.login_type == 1) {
|
||
this.toRequestNetWork(obj);
|
||
} else {
|
||
this.data.login_fun_list.push(obj);
|
||
}
|
||
});
|
||
},
|
||
|
||
toRequestNetWork(_ObjData) {
|
||
var url = _ObjData.url;
|
||
var resolve = _ObjData.resolve;
|
||
var reject = _ObjData.reject;
|
||
var method = _ObjData.method;
|
||
var data = _ObjData.data || {};
|
||
let params = _ObjData.data;
|
||
var success = _ObjData.success;
|
||
var fail = _ObjData.fail;
|
||
var complete = _ObjData.complete;
|
||
var validateBol = _ObjData.validateBol == 2 ? false : true;
|
||
// 加载遮罩
|
||
var showToastIn = true;
|
||
if (typeof _ObjData.showToastIn == "boolean") {
|
||
showToastIn = _ObjData.showToastIn;
|
||
}
|
||
|
||
var that = this;
|
||
if (showToastIn) {
|
||
wx.showNavigationBarLoading();
|
||
}
|
||
|
||
let _session = "";
|
||
let _wx_token = "";
|
||
try {
|
||
let value = wx.getStorageSync("session");
|
||
if (value) {
|
||
_session = value;
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
try {
|
||
let value = wx.getStorageSync("wx_token");
|
||
if (value) {
|
||
_wx_token = value;
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
|
||
if (yzFirstlogin === 0 && yzValidate_page === 1) {
|
||
if (data.not_validate_page == '0' && data) {
|
||
//想接口不返回validate_page的参数
|
||
} else {
|
||
url += "&validate_page=1";
|
||
}
|
||
}
|
||
|
||
if ((yzFirstlogin === 1 && url.indexOf("member.login.index") < 0 && url.indexOf("member.member.wxJsSdkConfig") < 0) || url.indexOf("finance.income-page.index") >= 0) {
|
||
url += "&basic_info=1&validate_page=1";
|
||
}
|
||
|
||
if (method === 'GET' && params) {
|
||
let paramsArray = [];
|
||
Object.keys(params).forEach(key =>
|
||
paramsArray.push(key + "=" + params[key])
|
||
);
|
||
url += "&" + paramsArray.join("&");
|
||
}
|
||
|
||
url += "&app_type=wechat";
|
||
url += "&3rd_session=" + _session;
|
||
|
||
if (this.globalData.store_alone_temp == 1) {
|
||
// 开启门店独立模块
|
||
url += "&store_id=" + this.globalData.STORE_ID;
|
||
}
|
||
console.log(method, "请求中Url:", url);
|
||
|
||
let headers = {
|
||
"Content-Type": "application/json",
|
||
Accept: "application/json",
|
||
Cookie: "PHPSESSID=" + _wx_token,
|
||
};
|
||
|
||
if (this.globalData.new_page_comeIn != 2) {
|
||
let pages = getCurrentPages();
|
||
let view = pages[pages.length - 1];
|
||
// 浏览足迹 new_page_comeIn == 2为页面第一个请求接口
|
||
headers['local-url'] = view.route;
|
||
this.globalData.new_page_comeIn = 2;
|
||
}
|
||
|
||
url += "&mini_version=v1.1.136";
|
||
this.data.login_type = 2;
|
||
wx.request({
|
||
url: url,
|
||
method: method,
|
||
data: data,
|
||
header: headers,
|
||
timeout: 10000,
|
||
success: (res) => {
|
||
if (res.data.basic_info) {
|
||
yzFirstlogin = 0;
|
||
that.data.basic_info = res.data.basic_info;
|
||
that.initLanguage(that.data.basic_info.lang);
|
||
try {
|
||
wx.setStorageSync("yz_basic_info", res.data.basic_info);
|
||
|
||
// 判断门店独立模块是否开启
|
||
// let basic_info = res.data.basic_info;
|
||
// if (basic_info.plugin_setting && basic_info.plugin_setting.store_alone_temp && basic_info.plugin_setting.store_alone_temp.enable == 1) {
|
||
// this.globalData.store_alone_temp = 1;
|
||
// let pages = getCurrentPages(),
|
||
// view = pages[pages.length - 1]; //获取当前页面的对象
|
||
// if (!this.globalData.STORE_ID && view.route !== 'packageG/independent_store/index/index') {
|
||
// // this.isHasStoreId();
|
||
// return false;
|
||
// }
|
||
// }
|
||
|
||
this.globalData.cart_num = res.data.basic_info.globalParameter ? res.data.basic_info.globalParameter.cart_num : '';
|
||
if (res.data.basic_info.home && res.data.basic_info.home.mailInfo && res.data.basic_info.home.mailInfo) {
|
||
// 积分名称
|
||
wx.setStorageSync('integral', res.data.basic_info.home.mailInfo.credit1 || '积分');
|
||
}
|
||
} catch (e) {
|
||
console.log("yz_basic_info存储出错", e);
|
||
}
|
||
try {
|
||
if (res.data.basic_info.home.plugin.new_member_prize && res.data.basic_info.home.plugin.new_member_prize.prize && res.data.basic_info.home.plugin.new_member_prize.prize.length != 0) {
|
||
console.log("storage_newAward存储====");
|
||
wx.setStorageSync("storage_newAward", res.data.basic_info.home.plugin.new_member_prize);
|
||
}
|
||
} catch (e) {
|
||
console.log("storage_newAward存储出错", e);
|
||
}
|
||
}
|
||
|
||
if (validateBol && res.data.validate_page) {
|
||
that.getInvite(res.data.validate_page);
|
||
}
|
||
|
||
if (res.data.result == 0 && res.data.msg === "请登录") {
|
||
that.login_state(_ObjData, "get");
|
||
return;
|
||
}
|
||
if (res.data.result == 2) {
|
||
wx.removeStorage({
|
||
key: "session",
|
||
success: function (res) {
|
||
console.log(res.data);
|
||
},
|
||
});
|
||
wx.removeStorage({
|
||
key: "openid",
|
||
success: function (res) {
|
||
console.log(res.data);
|
||
},
|
||
});
|
||
wx.removeStorage({
|
||
key: "wx_token",
|
||
success: function (res) {
|
||
console.log(res.data);
|
||
},
|
||
});
|
||
wx.removeStorage({
|
||
key: "userInfo",
|
||
success: function (res) {
|
||
that._getNetWork(_ObjData);
|
||
},
|
||
});
|
||
} else {
|
||
// wx.hideToast()
|
||
wx.hideNavigationBarLoading();
|
||
success && success(res);
|
||
resolve(res);
|
||
this.data.login_type = 1;
|
||
if (this.data.login_fun_list.length > 0) {
|
||
let obj = this.data.login_fun_list.shift();
|
||
this.toRequestNetWork(obj);
|
||
// console.log(obj,"-------------------------------------------------success")
|
||
}
|
||
}
|
||
},
|
||
fail: (res) => {
|
||
this.data.login_type = 1;
|
||
if (fail && typeof fail === "function") {
|
||
fail(res);
|
||
}
|
||
reject(res);
|
||
wx.showToast({
|
||
title: "数据获取失败!",
|
||
icon: "loading",
|
||
duration: 2000,
|
||
mask: true,
|
||
});
|
||
console.log("数据获取失败:", url, res);
|
||
},
|
||
complete: (res) => {
|
||
if (complete && typeof complete === "function") {
|
||
complete(res);
|
||
}
|
||
},
|
||
});
|
||
},
|
||
/*青蛙pro信息*/
|
||
requestFrogproServerData(url, method, data) {
|
||
return new Promise(function (resolve, reject) {
|
||
wx.request({
|
||
url: url,
|
||
data: data,
|
||
header: {
|
||
"Content-Type": "application/json",
|
||
Accept: "application/json",
|
||
},
|
||
method: method,
|
||
success: function (res) {
|
||
resolve(res);
|
||
},
|
||
fail: function (res) {
|
||
reject(res);
|
||
},
|
||
});
|
||
});
|
||
},
|
||
// 青蛙小程序登录
|
||
startLogin: function () {
|
||
let that = this;
|
||
that.data.clearlogin = setInterval(function () {
|
||
wx.login({
|
||
success: function (_json) {
|
||
if (_json.code) {
|
||
// 请求登录接口
|
||
that
|
||
.requestFrogproServerData(that.getFrogproNetAddresss("member.login.index"), "get", {
|
||
code: _json.code,
|
||
ver: "2",
|
||
// info: _info
|
||
})
|
||
.then(function (res) {
|
||
var _data = res.data;
|
||
if (_data.result == 1) {
|
||
// 存储key
|
||
if (_data.data.user_info) {
|
||
wx.setStorageSync("nickname", _data.data.user_info.nickname);
|
||
}
|
||
if (_data.msg.session) {
|
||
wx.setStorageSync("session", _data.session);
|
||
}
|
||
if (_data.msg.wx_token) {
|
||
wx.setStorageSync("wx_token", _data.wx_token);
|
||
}
|
||
if (_data.data.store) {
|
||
wx.setStorageSync("storeMessage", _data.data.store);
|
||
}
|
||
let Json = {
|
||
wx_token: _data.msg.wx_token,
|
||
session: _data.msg.session,
|
||
store_id: _data.data.store.store_id,
|
||
dispatch_type_id: 2,
|
||
goods_id: _data.data.store.goods_id,
|
||
host: that.data.host,
|
||
uniacid: that.data.uniacid,
|
||
};
|
||
wxfaceapp.postMsg({
|
||
targetAppid: that.data.accept_message_id,
|
||
content: JSON.stringify(Json),
|
||
success(res) {
|
||
},
|
||
fail(res) {
|
||
},
|
||
});
|
||
} else {
|
||
console.log("错误信息:::" + res.errMsg);
|
||
}
|
||
// 异步请求到的数据data
|
||
})
|
||
.catch(function (res) {
|
||
console.log("错误信息:::" + res.errMsg);
|
||
});
|
||
} else {
|
||
console.log("错误信息:::" + res.errMsg);
|
||
}
|
||
},
|
||
fail: function (res) {
|
||
console.log("登录失败,请求被拒绝!获取用户登录态失败!" + res);
|
||
},
|
||
});
|
||
}, 600000);
|
||
},
|
||
getFrogproNetAddresss: function (action) {
|
||
let wx_token = this.getWxToken();
|
||
var url = this.data.host + "/api/api.php?i=" + this.data.uniacid + "&session_id=" + wx_token + "&type=12&route=" + action;
|
||
if(this.globalData.STORE_ID){
|
||
url += "&store_id=" + this.globalData.STORE_ID;
|
||
}
|
||
return url;
|
||
},
|
||
/*青蛙pro信息*/
|
||
//获取设备信息
|
||
getSystemInfo() {
|
||
try {
|
||
const res = wx.getSystemInfoSync();
|
||
let model = res.model;
|
||
if (/iPhone X/i.test(model) || /iPhone 11/i.test(model) || /iPhone 12/i.test(model) || /iPhone 13/i.test(model)) {
|
||
try {
|
||
wx.setStorageSync("iPhoneBottom", model);
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
}
|
||
} catch (e) {
|
||
// Do something when catch error
|
||
}
|
||
},
|
||
|
||
seyzredirect(path, options) {
|
||
// 设置当前链接 登录后返回
|
||
console.log(path, options, 'options2');
|
||
var pages = getCurrentPages(); //获取加载的页面
|
||
var currentPage = pages[pages.length - 1]; //获取当前页面的对象
|
||
// 优先级 options > currentPage.options 当只有path参数传入即不用options
|
||
let optionsData = options ? options : (path ? '' : currentPage.options);
|
||
let routeData = path ? path : currentPage.route;
|
||
let notLogin = ['pages/login/login', 'packageA/member/editmobile/editmobile'];
|
||
if (notLogin.indexOf(routeData) > -1) {
|
||
return;
|
||
}
|
||
if (optionsData) {
|
||
//参数多时通过&拼接url的参数
|
||
var urlWithArgs = routeData + "?";
|
||
for (var key in optionsData) {
|
||
var value = optionsData[key];
|
||
urlWithArgs += key + "=" + value + "&";
|
||
}
|
||
urlWithArgs = urlWithArgs.substring(0, urlWithArgs.length - 1);
|
||
wx.setStorageSync("yz_redirect", `${urlWithArgs}`);
|
||
} else {
|
||
wx.setStorageSync("yz_redirect", routeData);
|
||
}
|
||
|
||
// console.log(optionsData,routeData, 'options3')
|
||
},
|
||
getyzredirect() {
|
||
let yzredirect = "";
|
||
try {
|
||
let value = wx.getStorageSync("yz_redirect");
|
||
if (value) {
|
||
yzredirect = value;
|
||
}
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
return yzredirect;
|
||
},
|
||
globalData: {
|
||
host: newhost.host,
|
||
uniacid: newhost.uniacid,
|
||
new_page_comeIn: 0,
|
||
statusBarHeight: 0,
|
||
screenHeight: 0,
|
||
define_order_pay: 1, // '确认付款' => 1,这种方法定义常量不用每个js都注入
|
||
define_order_receiv: 5, // '确认收货' => 5,这种方法定义常量不用每个js都注入
|
||
define_order_check: 8, // '查看物流' => 8,这种方法定义常量不用每个js都注入
|
||
define_order_cancle: 9, // '取消订单' => 9,这种方法定义常量不用每个js都注入
|
||
define_order_comment: 10, // '评价' => 10,这种方法定义常量不用每个js都注入
|
||
define_order_recomment: 11, // '追加评价' => 10,这种方法定义常量不用每个js都注入
|
||
define_order_delete: 12, // '删除订单' => 10,这种方法定义常量不用每个js都注入
|
||
define_order_refund: 13, // '退款' => 10,这种方法定义常量不用每个js都注入
|
||
define_order_used: 14, // '确认使用' => 10,这种方法定义常量不用每个js都注入
|
||
// uid: 0,// 推广人id
|
||
mid: 0,
|
||
userInfo: null,
|
||
globaSession: null,
|
||
// 自定义跳转方式选择值,用于区别调用跳转方法
|
||
tabBar: {
|
||
index: "-1",
|
||
category: "-1",
|
||
extension: "-1",
|
||
cart: "-1",
|
||
memindex: "-1",
|
||
},
|
||
// 腾讯地图key值
|
||
qqmapkey: "",
|
||
// 腾讯地图校验码
|
||
qqmapsig: "",
|
||
pathData: "",
|
||
cart_num: 0, //购物车数量
|
||
isLocationIng: false,
|
||
|
||
// 门店独立模块
|
||
store_alone_temp: 1,
|
||
STORE_ID: newhost.store_id,
|
||
integralOtherMiniData: {}
|
||
},
|
||
_getLanguage(data) {
|
||
wx.setStorageSync("langIndex", data);
|
||
},
|
||
_getTemplate() {
|
||
// 获取动态腾讯地图key
|
||
let urlStr = this.getNetAddresss("plugin.min-app.Frontend.Controllers.page.index");
|
||
urlStr = urlStr + "&scope=pass";
|
||
return new Promise((resolve, reject) => {
|
||
wx.request({
|
||
url: urlStr,
|
||
method: "GET",
|
||
header: {
|
||
"Content-Type": "application/json",
|
||
Accept: "application/json",
|
||
},
|
||
success: (resdata) => {
|
||
let res = resdata.data;
|
||
if (res.result === 1) {
|
||
|
||
this.globalData.qqmapkey = res.data.qq_map_web_key;
|
||
this.globalData.qqmapsig = res.data.qq_map_web_sign;
|
||
try {
|
||
// 平台协议
|
||
wx.setStorageSync("new_agreement", {
|
||
agreement_name: res.data.agreement_name,
|
||
new_agreement: res.data.new_agreement
|
||
});
|
||
} catch (error) {
|
||
console.log(error);
|
||
}
|
||
resolve();
|
||
} else {
|
||
this.globalData.qqmapkey = "KUBBZ-IXPCO-3ZNWD-SHC4H-O4TZH-ZSBQR";
|
||
this.globalData.qqmapsig = "l3Fyt4WylOFiPzbBSIkjWJ1aDU6NNa4";
|
||
resolve();
|
||
}
|
||
},
|
||
fail: (res) => {
|
||
this.globalData.qqmapkey = "KUBBZ-IXPCO-3ZNWD-SHC4H-O4TZH-ZSBQR";
|
||
this.globalData.qqmapsig = "l3Fyt4WylOFiPzbBSIkjWJ1aDU6NNa4";
|
||
resolve();
|
||
}
|
||
});
|
||
});
|
||
},
|
||
_setMid: function (mid) {
|
||
this.globalData.mid = mid;
|
||
wx.setStorage({
|
||
key: "mid",
|
||
data: mid,
|
||
});
|
||
},
|
||
_setshopid: function (shop_id) {
|
||
this.globalData.shop_id = shop_id;
|
||
wx.setStorage({
|
||
key: "shop_id",
|
||
data: shop_id,
|
||
});
|
||
},
|
||
_setvid: function (vid) {
|
||
this.globalData.vid = vid;
|
||
},
|
||
_setcircleInvitationId(circle_invitation_id) {
|
||
console.log("设置了circle_invitation_id");
|
||
this.globalData.circle_invitation_id = circle_invitation_id;
|
||
},
|
||
_setroomid: function (roomid) {
|
||
this.globalData.roomid = roomid;
|
||
},
|
||
|
||
|
||
getWxToken: function () {
|
||
var value = wx.getStorageSync("wx_token");
|
||
if (value) {
|
||
console.log("同步token", value);
|
||
return value;
|
||
} else {
|
||
console.log("获取token失败");
|
||
}
|
||
},
|
||
|
||
getNetAddresss: function (action) {
|
||
// let wx_token = this.getWxToken();
|
||
this.getExtJson();
|
||
var url = this.data.host + "/api/api.php?i=" + this.data.uniacid + "&type=2&route=" + action;
|
||
if (this.globalData.STORE_ID) {
|
||
url += "&store_id=" + this.globalData.STORE_ID;
|
||
}
|
||
if (this.globalData.mid) {
|
||
url += "&mid=" + this.globalData.mid;
|
||
}
|
||
if (this.globalData.vid) {
|
||
url += "&vid=" + this.globalData.vid;
|
||
}
|
||
if (this.globalData.circle_invitation_id) {
|
||
console.log("地址带上circle_invitation_id");
|
||
url += "&circle_invitation_id=" + this.globalData.circle_invitation_id;
|
||
}
|
||
if (this.globalData.roomid) {
|
||
url += "&room_id=" + this.globalData.roomid;
|
||
}
|
||
if (this.globalData.shop_id) {
|
||
url += "&shop_id=" + this.globalData.shop_id;
|
||
}
|
||
url += "&ingress=weChatApplet";
|
||
|
||
if (url.indexOf("member.login.index") > -1) {
|
||
// 解决登录授权后没有新人奖(basic_info )
|
||
yzFirstlogin = 1;
|
||
}
|
||
// url += "&mid=399"
|
||
console.log("APP____URL:::", url);
|
||
return url;
|
||
},
|
||
// 时间戳差值
|
||
getTimeDifference(Timestamp) {
|
||
var now = Date.parse(new Date());
|
||
// console.log("Timestamp", Timestamp);
|
||
let time = Timestamp < 1000000000000 ? Timestamp * 1000 : Timestamp;
|
||
// console.log(time - now);
|
||
if (time - now > 0) {
|
||
return time - now;
|
||
} else if (time - now <= 0) {
|
||
return 0;
|
||
}
|
||
},
|
||
|
||
// 返回评价数组
|
||
getEvaluate: function (num) {
|
||
return {
|
||
num: num,
|
||
list: [1, 1, 1, 1, 1, 0, 0, 0, 0, 0].slice(5 - num, 10 - num),
|
||
};
|
||
},
|
||
// 判断是否是空
|
||
_isTextEmpty: function (str) {
|
||
if (str == null || str == "" || str == undefined) {
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
},
|
||
// 判断ios还是android
|
||
isIosOrAndroid: function () {
|
||
let u = navigator.userAgent;
|
||
let isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; // android终端
|
||
let isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
|
||
let isStr = "";
|
||
if (isAndroid) {
|
||
isStr = "android";
|
||
}
|
||
if (isiOS) {
|
||
isStr = "ios";
|
||
}
|
||
return isStr;
|
||
},
|
||
// 判断参数传递是否为空
|
||
setMailLanguage: function (defaultStr, languageStr) {
|
||
let language = this._isTextEmpty(languageStr) ? defaultStr : languageStr;
|
||
return language;
|
||
},
|
||
// 是否手机
|
||
_isMoblie: function (value) {
|
||
// return !/^1(3|5|7|8|9)[0-9]{9}$/.test(value)
|
||
return isNaN(Number(value));
|
||
},
|
||
// 判断URL链接中是否有mid如果有
|
||
_isMid: function (url, val) {
|
||
if (url.indexOf("mid=") >= 0) {
|
||
return this.changeUrlArg(url, "mid", val);
|
||
} else {
|
||
let burl = this.delQueStr(url, "mid");
|
||
return this.changeUrlArg(burl, "mid", val);
|
||
}
|
||
},
|
||
changeUrlArg: function (url, arg, val) {
|
||
var pattern = arg + "=([^&]*)";
|
||
var replaceText = arg + "=" + val;
|
||
return url.match(pattern) ? url.replace(eval("/(" + arg + "=)([^&]*)/gi"), replaceText) : url.match("[?]") ? url + "&" + replaceText : url + "?" + replaceText;
|
||
},
|
||
// 删除参数值
|
||
delQueStr: function (url, ref) {
|
||
var str = "";
|
||
if (url.indexOf("#") != -1) {
|
||
str = url.substr(url.indexOf("#") + 1);
|
||
} else {
|
||
return url;
|
||
}
|
||
var arr = "";
|
||
var returnurl = "";
|
||
if (str.indexOf("&") != -1) {
|
||
arr = str.split("&");
|
||
for (let i = 0; i < arr.length; i++) {
|
||
if (arr[i].split("=")[0] != ref) {
|
||
returnurl = returnurl + arr[i].split("=")[0] + "=" + arr[i].split("=")[1] + "&";
|
||
}
|
||
}
|
||
return url.substr(0, url.indexOf("?")) + "?#" + returnurl.substr(0, returnurl.length - 1);
|
||
} else {
|
||
arr = str.split("=");
|
||
if (arr[0] == ref) return url.substr(0, url.indexOf("?"));
|
||
else return url;
|
||
}
|
||
},
|
||
getExtJson: function () {
|
||
console.log("================enter extJson===============");
|
||
var that = this;
|
||
var extConfig = wx.getExtConfigSync ? wx.getExtConfigSync() : {};
|
||
console.log("********extConfig*********", extConfig);
|
||
if (extConfig.host) {
|
||
console.log("================extJson exists===============");
|
||
that.data.host = extConfig.host;
|
||
that.data.uniacid = extConfig.uniacid;
|
||
} else {
|
||
console.log("================extJson not exists===============");
|
||
wx.getExtConfigSync({
|
||
success: function (res) {
|
||
console.log("================extJson11===============", res.extConfig);
|
||
that.data.host = res.extConfig.host;
|
||
that.data.uniacid = res.extConfig.uniacid;
|
||
},
|
||
fail: function (res) {
|
||
console.log("================error.extJson11===============", res);
|
||
},
|
||
});
|
||
}
|
||
},
|
||
//是否开启邀请页面
|
||
getInvite(data) {
|
||
if (data.is_invite === 1 || data.invite_mobile === 1 || (data.real_name_auth_is_open === 1 && data.is_auth === 1)) {
|
||
yzValidate_page = 0;
|
||
}
|
||
if (data.real_name_auth_is_open === 1) {
|
||
// 判断实名插件是否开启
|
||
if (data.is_auth !== 1 && data.real_name_auth_scene && data.real_name_auth_scene.length > 0) {
|
||
// 是否已经实名过
|
||
this.bind_real_name(data.real_name_auth_scene);
|
||
return;
|
||
}
|
||
}
|
||
if (data.is_bind_mobile !== 0) {
|
||
this.bindMobile(data.is_bind_mobile, this.globalData.pathData);
|
||
} else {
|
||
if (data.is_login === 1) {
|
||
// 登录
|
||
if (data.is_invite !== 1) {
|
||
// 是否填写过邀请人
|
||
if (data.invite_page === 1) {
|
||
//是否开启邀请页面
|
||
wx.redirectTo({
|
||
url: "/packageC/member/visit/Inviter/Inviter",
|
||
});
|
||
}
|
||
} else {
|
||
if (typeof data.invite_mobile != "undefined" && data.invite_mobile !== 1 && data.invite_page === 1) {
|
||
wx.redirectTo({
|
||
url: "/packageC/member/visit/Inviter/Inviter",
|
||
});
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
//查看用户是否需要绑定手机号
|
||
bindMobile(e, setpathData) {
|
||
var pages = getCurrentPages(); //获取加载的页面
|
||
var currentPage = pages[pages.length - 1]; //获取当前页面的对象
|
||
let routeData = currentPage.route;
|
||
if (e == 1) {
|
||
//跳转绑定手机页面
|
||
wx.reLaunch({
|
||
url: "/packageA/member/editmobile/editmobile?fromApp=1",
|
||
});
|
||
} else if (e == 2) {
|
||
if (routeData == "packageG/member_v2/member_v2") {
|
||
wx.reLaunch({
|
||
url: "/packageA/member/editmobile/editmobile?fromApp=2",
|
||
});
|
||
}
|
||
} else if (e == 3) {
|
||
if (routeData.indexOf("detail_v2/detail_v2") > 0) {
|
||
wx.reLaunch({
|
||
url: "/packageA/member/editmobile/editmobile?fromApp=1",
|
||
});
|
||
}
|
||
} else if (e == 4) {
|
||
if (routeData == "packageG/pages/member/extension/extension") {
|
||
wx.reLaunch({
|
||
url: "/packageA/member/editmobile/editmobile?fromApp=4",
|
||
});
|
||
}
|
||
}
|
||
},
|
||
|
||
bind_real_name(scene) {
|
||
// 全局1 提现申请2 发布短视频3 发布微贴4 推广中心5
|
||
var pages = getCurrentPages(); //获取加载的页面
|
||
var currentPage = pages[pages.length - 1]; //获取当前页面的对象
|
||
let routeData = currentPage.route;
|
||
if (routeData !== 'packageH/signPage/personBank/personBank') {
|
||
wx.setStorageSync("real_name_redirect", routeData);
|
||
}
|
||
if (scene.indexOf('1') > -1 && routeData !== 'packageH/signPage/personBank/personBank') {
|
||
wx.reLaunch({
|
||
url: "/packageH/signPage/personBank/personBank?from=bindRealName",
|
||
});
|
||
return;
|
||
}
|
||
if (scene.indexOf('5') > -1) {
|
||
// 推广中心
|
||
if (routeData == "packageG/pages/member/extension/extension") {
|
||
wx.reLaunch({
|
||
url: "/packageH/signPage/personBank/personBank?from=bindRealName",
|
||
});
|
||
}
|
||
}
|
||
if (scene.indexOf('2') > -1) {
|
||
// 提现申请
|
||
if (routeData == "packageA/member/withdrawal/withdrawal") {
|
||
wx.reLaunch({
|
||
url: "/packageH/signPage/personBank/personBank?from=bindRealName",
|
||
});
|
||
}
|
||
}
|
||
if (scene.indexOf('3') > -1) {
|
||
// 发布短视频
|
||
if (routeData == "packageC/video_goods/videoAgreement/videoAgreement" || routeData == "packageC/video_goods/releaseVideo/releaseVideo") {
|
||
wx.reLaunch({
|
||
url: "/packageH/signPage/personBank/personBank?from=bindRealName",
|
||
});
|
||
}
|
||
}
|
||
if (scene.indexOf('4') > -1) {
|
||
// 发布微贴
|
||
if (routeData == "packageC/micro_communities/microRelease/microRelease") {
|
||
wx.reLaunch({
|
||
url: "/packageH/signPage/personBank/personBank?from=bindRealName",
|
||
});
|
||
}
|
||
}
|
||
|
||
},
|
||
requestServerData(url, method, data) {
|
||
if (url.indexOf('member.login.index') > -1) {
|
||
console.log('登录接口');
|
||
}
|
||
return new Promise(function (resolve, reject) {
|
||
wx.request({
|
||
url: url,
|
||
data: data,
|
||
header: {
|
||
"Content-Type": "application/json",
|
||
Accept: "application/json",
|
||
},
|
||
method: method,
|
||
success: function (res) {
|
||
resolve(res);
|
||
},
|
||
fail: function (res) {
|
||
reject(res);
|
||
},
|
||
});
|
||
});
|
||
},
|
||
login_state(ObjData, requestType) {
|
||
//调试用
|
||
// this.seyzredirect();
|
||
// wx.redirectTo({
|
||
// url: "/pages/login/login",
|
||
// });
|
||
// return;
|
||
//接口返回0,并且未登录的情况处理x
|
||
var that = this;
|
||
wx.login({
|
||
success: (_json) => {
|
||
console.log(_json,9999888);
|
||
wx.showLoading({
|
||
title: "自动登录中....",
|
||
});
|
||
if (_json.code) {
|
||
// 请求登录接口查看是否有登陆过
|
||
that
|
||
.requestServerData(that.getNetAddresss("plugin.store-cashier.frontend.login.login.index"), "get", {
|
||
code: _json.code,
|
||
ver: "2",
|
||
})
|
||
.then((res) => {
|
||
wx.hideLoading();
|
||
var _data = res.data;
|
||
that.data.login_type = 1;
|
||
if (_data.result == 1) {
|
||
if (_data.data.session) {
|
||
wx.setStorageSync("session", _data.data.session);
|
||
}
|
||
if (_data.data.user_info) {
|
||
wx.setStorageSync("nickname", _data.data.user_info.nickname);
|
||
}
|
||
wx.setStorage({
|
||
key: "openid",
|
||
data: _data.data.openid,
|
||
});
|
||
if (_data.data.wx_token) {
|
||
wx.setStorageSync("wx_token", _data.data.wx_token);
|
||
}
|
||
wx.setStorage({
|
||
key: "yz_uid",
|
||
data: _data.data.uid,
|
||
});
|
||
wx.removeStorageSync("new_decorate"); //登录之后清除首页缓存数据重新请求
|
||
console.log("登录后", ObjData);
|
||
if (ObjData.method == 'POST') {
|
||
that._postNetWork(ObjData);
|
||
} else {
|
||
that._getNetWork(ObjData);
|
||
}
|
||
} else {
|
||
that.seyzredirect();
|
||
wx.showModal({
|
||
title: "提示",
|
||
content: _data.data,
|
||
success(res) {
|
||
console.log(res);
|
||
},
|
||
});
|
||
wx.redirectTo({
|
||
url: "/pages/login/login",
|
||
});
|
||
}
|
||
// 异步请求到的数据data
|
||
})
|
||
.catch(function (res) {
|
||
console.log(res);
|
||
wx.hideLoading({
|
||
success: (res) => {
|
||
},
|
||
});
|
||
console.log("第三方登录失败session、wx_token获取失败" + res.errMsg);
|
||
});
|
||
} else {
|
||
that.seyzredirect();
|
||
wx.redirectTo({
|
||
url: "/pages/login/login",
|
||
});
|
||
}
|
||
},
|
||
fail: function (res) {
|
||
wx.hideLoading({
|
||
success: (res) => {
|
||
},
|
||
});
|
||
wx.showToast({
|
||
title: "小程序需要登录,请点击右下方前往小程序体验",
|
||
icon: "none",
|
||
duration: 1500,
|
||
});
|
||
console.log(res);
|
||
},
|
||
});
|
||
},
|
||
//初始化语言设置
|
||
initLanguage(data) {
|
||
// let urlStr = this.getNetAddresss("setting.get-lang-setting");
|
||
// this._getNetWork({
|
||
// url: urlStr,
|
||
// data: {},
|
||
// success: function(resdata) {
|
||
// var res = resdata.data;
|
||
// if (res.result == 1) {
|
||
// let data = res.data;
|
||
try {
|
||
wx.setStorageSync("mailLanguage", JSON.stringify(data));
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
this._getLanguage(data && data.plugin_language ? data.plugin_language : locales);
|
||
// }
|
||
// },
|
||
// fail: function(res) {
|
||
// console.log(res);
|
||
// }
|
||
// });
|
||
},
|
||
gotochecklogin(options) {
|
||
let that = this;
|
||
// let loginFlag = wx.getStorageSync('wx_token');
|
||
// if (loginFlag) {
|
||
that.getfirstData(options);
|
||
// } else {
|
||
// 无skey,作为首次登录
|
||
// that.gotoLogin(options);
|
||
// }
|
||
},
|
||
getfirstData(options) {
|
||
this.globalData.pathData = options.path;
|
||
// this.getInvite();
|
||
// this.initLanguage();
|
||
},
|
||
|
||
|
||
// 腾讯转百度(小程序用这个)
|
||
qqMapTransBMap(lng, lat) {
|
||
if (lng == null || lng == '' || lat == null || lat == '') {
|
||
return {
|
||
lng: Number(lng),
|
||
lat: Number(lat)
|
||
};
|
||
}
|
||
|
||
var x_pi = (Math.PI * 3000.0) / 180.0;
|
||
var x = parseFloat(lng);
|
||
var y = parseFloat(lat);
|
||
var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * x_pi);
|
||
var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * x_pi);
|
||
let lng_out = z * Math.cos(theta) + 0.0065;
|
||
let lat_out = z * Math.sin(theta) + 0.006;
|
||
return {
|
||
lng: Number(lng_out),
|
||
lat: Number(lat_out)
|
||
};
|
||
},
|
||
|
||
// 百度转腾讯(小程序用这个)
|
||
BMapTransqqMap(lng, lat) {
|
||
if (lng == null || lng == '' || lat == null || lat == '') {
|
||
return {
|
||
lng: Number(lng),
|
||
lat: Number(lat)
|
||
};
|
||
}
|
||
|
||
var x_pi = (Math.PI * 3000.0) / 180.0;
|
||
var x = parseFloat(lng) - 0.0065;
|
||
var y = parseFloat(lat) - 0.006;
|
||
var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
|
||
var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
|
||
let lng_out = z * Math.cos(theta);
|
||
let lat_out = z * Math.sin(theta);
|
||
|
||
return {
|
||
lng: Number(lng_out),
|
||
lat: Number(lat_out)
|
||
};
|
||
},
|
||
tips(msg, icon = "none", time = 2500) {
|
||
wx.showToast({
|
||
title: msg,
|
||
icon,
|
||
duration: time,
|
||
});
|
||
return false;
|
||
},
|
||
confirm(content, callBack, showCancel = true, confirmText, cancelTextL) {
|
||
// content 弹窗内容,callBack 确认回调,showCancel = true 是否显示取消,confirmText 确认文字,cancelTextL 取消文字
|
||
return new Promise((resolve, reject) => {
|
||
wx.showModal({
|
||
title: '提示',
|
||
content: content,
|
||
showCancel: showCancel,
|
||
confirmText: confirmText || '确认',
|
||
cancelTextL: cancelTextL || '取消',
|
||
success(res) {
|
||
if (res.confirm) {
|
||
resolve(true);
|
||
if (callBack) callBack(true);
|
||
} else if (res.cancel) {
|
||
resolve(false);
|
||
if (callBack) callBack(false);
|
||
}
|
||
},
|
||
fail: () => {
|
||
reject(false);
|
||
}
|
||
});
|
||
});
|
||
},
|
||
setDeliver(_options) {
|
||
let deliverIDStorage = wx.getStorageSync('deliverId') || null; //获取当前会话是否存储了自提点id
|
||
if (_options.query.dyID && !deliverIDStorage) {
|
||
//添加判断sessionStorage是否已存在的目的是防止在其他页面刷新,关联的自提点又变成了链接上的,导致之前手动切换的失效
|
||
let list = ['packageG/index/index', "packageG/newDiy/newDiy"];
|
||
let list_2 = ["packageG/pages/category_v2/category_v2", "packageB/member/category/search_v2/search_v2"];
|
||
if (list_2.indexOf(_options.path) > -1) {
|
||
return false;
|
||
} else if (list.indexOf(_options.path) > -1) {
|
||
wx.setStorageSync("deliverId", _options.query.dyID);
|
||
return false;
|
||
}
|
||
let urlStr = this.getNetAddresss("plugin.package-deliver.frontend.decorate-deliver.getNowPackageDeliver");
|
||
urlStr = urlStr + "&deliver_id=" + _options.query.dyID;
|
||
this._getNetWork({
|
||
url: urlStr,
|
||
success: (resdata) => {
|
||
let res = resdata.data;
|
||
if (res.result == 1) {
|
||
wx.setStorageSync("deliverId", res.data.id);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
},
|
||
shareTimeLine(view) {
|
||
let hasDiyShare = null;
|
||
let shareObject = {};
|
||
let info_config = {}; //获取当前页面的对象
|
||
let value = wx.getStorageSync("yz_uid");
|
||
let mid = null;
|
||
if (value && value != '') {
|
||
mid = value;
|
||
}
|
||
if (view.onShareTimeline) {
|
||
//是否在页面定义配置了onShareTimeline方法;
|
||
hasDiyShare = view.onShareTimeline();
|
||
}
|
||
if (!hasDiyShare) {
|
||
// 有onShareTimeline 但没有没有配置 带上mid
|
||
shareObject.query = `?mid=${mid}`;
|
||
return shareObject;
|
||
} else {
|
||
// 有onShareTimeline 有配置 检查是否有带上mid
|
||
let oldShareFun = view.onShareTimeline; //暂存重写前的分享方法
|
||
view.onShareTimeline = function (e) {
|
||
info_config = oldShareFun();
|
||
if (info_config.query) {
|
||
if (info_config.query.indexOf('mid') > -1) {
|
||
shareObject.query = `${info_config.query}&mid=${mid}`;
|
||
}
|
||
if (info_config.title) {
|
||
shareObject.title = info_config.title;
|
||
}
|
||
return shareObject;
|
||
}
|
||
};
|
||
}
|
||
},
|
||
//设置全局分享
|
||
overShare: function () {
|
||
let that = this;
|
||
// 调用隐藏路由回调
|
||
wx.onAppRoute(function (res) {
|
||
//获取加载的页面
|
||
let pages = getCurrentPages(),
|
||
view = pages[pages.length - 1],
|
||
info_config = {}, //获取当前页面的对象
|
||
hasDiyShare = null;
|
||
// console.log("view.onShareAppMessage=============",view)
|
||
// 浏览足迹 页面切换时更新new_page_comeIn
|
||
that.globalData.new_page_comeIn = 1;
|
||
if (view) {
|
||
try {
|
||
// 分享朋友圈传参全局判断
|
||
that.shareTimeLine(view);
|
||
if (view.onShareAppMessage) {
|
||
//是否在页面定义配置了onShareAppMessage方法;
|
||
hasDiyShare = view.onShareAppMessage();
|
||
}
|
||
if (that.globalData.store_alone_temp == 1 && that.globalData.STORE_ID) {
|
||
that.storeAloneShare(view, info_config);
|
||
} else {
|
||
let shareObject = {};
|
||
let value = wx.getStorageSync("yz_uid");
|
||
let mid = null;
|
||
if (value && value != '') {
|
||
mid = value;
|
||
}
|
||
if (hasDiyShare) {
|
||
let oldShareFun = view.onShareAppMessage; //暂存重写前的分享方法
|
||
view.onShareAppMessage = function (e) {
|
||
info_config = oldShareFun();
|
||
if (e && e.from == "button") {
|
||
return oldShareFun(e);
|
||
}
|
||
//重写分享配置
|
||
// 判断有没有自定义分享path和定义options
|
||
if (info_config.path) {
|
||
//当前页面有配置path
|
||
if (info_config.path.indexOf('mid') > -1) {
|
||
shareObject.path = info_config.path;
|
||
} else if (mid) {
|
||
//在当前页有设置其他分享参数但是没有mid
|
||
if (info_config.path.indexOf('?') > -1) {
|
||
shareObject.path = `${info_config.path}&mid=${mid}`;
|
||
} else {
|
||
shareObject.path = `${info_config.path}?mid=${mid}`;
|
||
}
|
||
}
|
||
} else if (mid) {
|
||
//没有配置,默认带上mid
|
||
shareObject.path = `/${view.route}?mid=${mid}`;
|
||
}
|
||
// 供应商自提点分享传参 ====== start ==========
|
||
let deliverIDStorage = wx.getStorageSync('deliverId') || null; //获取当前会话是否存储了自提点id
|
||
if (deliverIDStorage) {
|
||
shareObject.path = `${shareObject.path}&dyID=${deliverIDStorage}`;
|
||
}
|
||
// 供应商自提点分享传参 ====== end ==========
|
||
|
||
if (info_config.title) shareObject.title = info_config.title; //设置分享标题
|
||
if (info_config.imageUrl) shareObject.imageUrl = info_config.imageUrl; //设置分享图片
|
||
console.log("重写分享配置", shareObject);
|
||
return shareObject;
|
||
};
|
||
} else {
|
||
// 有onShareAppMessage 但没有没有配置
|
||
shareObject.path = `/${view.route}?mid=${mid}`;
|
||
// console.log(shareObject)
|
||
return shareObject;
|
||
}
|
||
|
||
}
|
||
} catch (error) {
|
||
console.log("app.js报错:error:::页面" + view.route + "获取onShareAppMessage报错=============", error);
|
||
}
|
||
}
|
||
});
|
||
},
|
||
// 门店独立模块分享
|
||
storeAloneShare(view, info_config) {
|
||
let value = wx.getStorageSync("yz_uid");
|
||
let mid = "";
|
||
if (value) {
|
||
mid = value;
|
||
}
|
||
if (!info_config) {
|
||
view.onShareAppMessage = function () {
|
||
return {
|
||
path: `/${view.route}?mid=${mid}&store_alone_id=${this.globalData.STORE_ID}`,
|
||
};
|
||
};
|
||
} else {
|
||
if (info_config.path) {
|
||
// 判断有没有自定义分享path和定义options
|
||
if (info_config.path.indexOf('?') > -1) {
|
||
return {
|
||
path: `/${view.route}&store_alone_id=${this.globalData.STORE_ID}`,
|
||
};
|
||
} else {
|
||
return {
|
||
path: `/${view.route}?store_alone_id=${this.globalData.STORE_ID}`,
|
||
};
|
||
}
|
||
} else {
|
||
return {
|
||
path: `/${view.route}?mid=${mid}&store_alone_id=${this.globalData.STORE_ID}`,
|
||
};
|
||
}
|
||
}
|
||
},
|
||
getReverseGeocoder(lat, lng) {
|
||
let that = this;
|
||
return new Promise(function (resolve, reject) {
|
||
if (that.globalData.location && that.globalData.location.latitude == lat && that.globalData.location.longitude == lng) {
|
||
console.log("当前定位位置未发生改变,取globalData里值 》》》》》》》》》》》", that.globalData.location);
|
||
resolve(that.globalData.geocoder);
|
||
return;
|
||
}
|
||
if (!that.globalData.qqmapkey) {
|
||
reject("没有that.globalData.qqmapkey::::", that.globalData.qqmapkey);
|
||
return;
|
||
}
|
||
qqmapsdk = new QQMapWX({
|
||
key: that.globalData.qqmapkey
|
||
});
|
||
qqmapsdk.reverseGeocoder({
|
||
//位置坐标,默认获取当前位置,非必须参数
|
||
location: {
|
||
latitude: lat,
|
||
longitude: lng
|
||
},
|
||
sig: that.globalData.qqmapsig,
|
||
success: function (res) { //成功后的回调
|
||
let mapdata = res.result;
|
||
that.globalData.location = {
|
||
latitude: lat,
|
||
longitude: lng
|
||
};
|
||
that.globalData.geocoder = mapdata;
|
||
console.log("当前定位位置发生改变!!!!!!!重新reverseGeocoder()", that.globalData.location);
|
||
resolve(mapdata);
|
||
},
|
||
fail: function (error) {
|
||
wx.showToast({
|
||
duration: 3000,
|
||
title: error.message,
|
||
icon: 'none'
|
||
});
|
||
reject("app.getReverseGeocoder()报错error::::", error);
|
||
},
|
||
complete: function (res) {
|
||
|
||
}
|
||
});
|
||
});
|
||
},
|
||
getGeocoder(address) {
|
||
let that = this;
|
||
// 需要调用次数 没有特殊要求还是不用
|
||
return new Promise(function (resolve, reject) {
|
||
if (!that.globalData.qqmapkey) {
|
||
reject("没有that.globalData.qqmapkey::::", that.globalData.qqmapkey);
|
||
return;
|
||
}
|
||
qqmapsdk = new QQMapWX({
|
||
key: that.globalData.qqmapkey
|
||
});
|
||
qqmapsdk.geocoder({
|
||
//位置坐标,默认获取当前位置,非必须参数
|
||
address: address, //地址参数,例:固定地址
|
||
sig: that.globalData.qqmapsig,
|
||
success: function (res) { //成功后的回调
|
||
let mapdata = res.result;
|
||
let point = {
|
||
lat: mapdata.location.lat,
|
||
lng: mapdata.location.lng
|
||
};
|
||
resolve(point);
|
||
},
|
||
fail: function (error) {
|
||
wx.showToast({
|
||
duration: 3000,
|
||
title: error.message,
|
||
icon: 'none'
|
||
});
|
||
reject("app.getGeocoder()报错error::::", error);
|
||
},
|
||
complete: function (res) {
|
||
|
||
}
|
||
});
|
||
});
|
||
},
|
||
resetBasicInfo() {
|
||
//重置yzFirstlogin,使下一次接口重新传参basic_info,获取basic_info数据
|
||
yzFirstlogin = 1;
|
||
},
|
||
adConfig: { // 广告配置
|
||
app_id: newhost.adBrightid || '', // 营销云平台应用ID
|
||
domain: newhost.adBrightDomain || '', // 广告服务域名(同步骤2)
|
||
test_id: '', // 广告位测试ID
|
||
h5_path: '/packageI/web-view/h5View' // H5预览页面
|
||
}
|
||
}); |