feat: 点餐分享
This commit is contained in:
parent
b1ff9a68e4
commit
892d6f3707
148
App.vue
148
App.vue
|
|
@ -23,6 +23,8 @@
|
||||||
}
|
}
|
||||||
import store from '@/store/index';
|
import store from '@/store/index';
|
||||||
import { HTTP_REQUEST_URL } from '@/config/app.js'
|
import { HTTP_REQUEST_URL } from '@/config/app.js'
|
||||||
|
import { mapMutations} from 'vuex'
|
||||||
|
import { spread } from '@/request/restaurant/index.js'
|
||||||
export default {
|
export default {
|
||||||
globalData: {
|
globalData: {
|
||||||
// FPT上传地址
|
// FPT上传地址
|
||||||
|
|
@ -38,9 +40,8 @@
|
||||||
// },
|
// },
|
||||||
parameters: {}
|
parameters: {}
|
||||||
},
|
},
|
||||||
onLaunch: function(parameters = {}) {
|
|
||||||
|
|
||||||
console.log(navigator.userAgent,'userAgent');
|
onLaunch: function(parameters = {}) {
|
||||||
// 动态构建script标签,用于引入wxjs文件
|
// 动态构建script标签,用于引入wxjs文件
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js";
|
script.src = "https://res.wx.qq.com/open/js/jweixin-1.6.0.js";
|
||||||
|
|
@ -48,7 +49,19 @@
|
||||||
// 为适配旧版本项目代码中的取参逻辑此处为迭代后新版本传参并整合为旧版本参数格式
|
// 为适配旧版本项目代码中的取参逻辑此处为迭代后新版本传参并整合为旧版本参数格式
|
||||||
let basurl = uri(decodeURIComponent(window.location.href))
|
let basurl = uri(decodeURIComponent(window.location.href))
|
||||||
let querys = basurl.query(true);
|
let querys = basurl.query(true);
|
||||||
console.log(querys,'querys');
|
if (querys.token) {
|
||||||
|
store.commit('SETTOKEN', 'Bearer ' + querys.token);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 锁粉?后的
|
||||||
|
if (querys.spread) {
|
||||||
|
setTimeout(() => {
|
||||||
|
spread({ puid: querys.spread, code: 0 }).then(res => {
|
||||||
|
console.log(res)
|
||||||
|
})
|
||||||
|
}, 1000)
|
||||||
|
};
|
||||||
|
|
||||||
if(Object.keys(querys)['length'] > 0){
|
if(Object.keys(querys)['length'] > 0){
|
||||||
if(querys?.para){
|
if(querys?.para){
|
||||||
// 获取URL参数
|
// 获取URL参数
|
||||||
|
|
@ -61,10 +74,8 @@
|
||||||
|
|
||||||
// 参数初始化处理
|
// 参数初始化处理
|
||||||
if (typeof _para == 'object' && _para['para'] != undefined) {
|
if (typeof _para == 'object' && _para['para'] != undefined) {
|
||||||
console.log('存在参数');
|
|
||||||
// URL参数
|
// URL参数
|
||||||
var URLpara = decodeURIComponent(getUrlParams(window.location.href)['para']);
|
var URLpara = decodeURIComponent(getUrlParams(window.location.href)['para']);
|
||||||
console.log(JSON.parse(URLpara),'*****');
|
|
||||||
try{
|
try{
|
||||||
// 转换过来的URL参数为一个JSON字符串其中存在一个#/字符,直接使用JSON.parse会报错,所以将#/截取出来
|
// 转换过来的URL参数为一个JSON字符串其中存在一个#/字符,直接使用JSON.parse会报错,所以将#/截取出来
|
||||||
var _r = URLpara.substr(0, URLpara.lastIndexOf("#/"));
|
var _r = URLpara.substr(0, URLpara.lastIndexOf("#/"));
|
||||||
|
|
@ -89,15 +100,36 @@
|
||||||
console.log(JSON.stringify(this['globalData']['parameters'],null,10), 'App Launch');
|
console.log(JSON.stringify(this['globalData']['parameters'],null,10), 'App Launch');
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
for(let key in querys){
|
console.log('存在参数1997', !querys.token)
|
||||||
console.log(querys);
|
if (!querys.token) {
|
||||||
querys[key] = JSON.parse(querys[key])
|
for(let key in querys){
|
||||||
};
|
const value = querys[key];
|
||||||
this['globalData']['parameters'] = { ...querys['userinfor'], ...querys['query'], timestamp:querys['timestamp']}
|
querys[key] = JSON.parse(value);
|
||||||
// 小程序首页会直接进入店铺首页,首页无赋值店铺信息逻辑所再次处进入之后赋值
|
}
|
||||||
if(this['globalData']['parameters']?.brand_id && typeof this['globalData']['parameters']['brand_id'] != 'undefined' && typeof this['globalData']['parameters']['brand_id'] != undefined && this['globalData']['parameters']?.brand_name && typeof this['globalData']['parameters']['brand_name'] != 'undefined' && typeof this['globalData']['parameters']['brand_name'] != undefined){
|
}
|
||||||
store.commit('shopping/SETBRANDINFOR', { brand_id: this['globalData']['parameters']['brand_id'], brand_name:decodeURIComponent(this['globalData']['parameters']['brand_name'])});
|
|
||||||
|
|
||||||
|
this['globalData']['parameters'] = { ...querys['userinfor'], ...querys['query'], timestamp:querys['timestamp']};
|
||||||
|
|
||||||
|
if (this['globalData']['parameters']['query']) {
|
||||||
|
store.commit('shopping/SETBRANDINFOR', { brand_id: this['globalData']['parameters']['query']['brand_id'], brand_name:decodeURIComponent(this['globalData']['parameters']['query']['brand_name'])});
|
||||||
|
store.commit('shopping/SETSHOPDETAIL', {
|
||||||
|
city_name: this['globalData']['parameters'].cityInfor.city,
|
||||||
|
is_open: 1,
|
||||||
|
latitude: this['globalData']['parameters']['cityInfor'].lat,
|
||||||
|
longitude: this['globalData']['parameters']['cityInfor'].lng,
|
||||||
|
province_name: this['globalData']['parameters']['cityInfor'].province,
|
||||||
|
regoin_name: null,
|
||||||
|
restaurant_address: this['globalData']['parameters']['query'].restaurant_address,
|
||||||
|
restaurant_id: this['globalData']['parameters']['query'].restaurant_id,
|
||||||
|
restaurant_name: this['globalData']['parameters']['query'].restaurant_name,
|
||||||
|
special: false,
|
||||||
|
distance: this['globalData']['parameters']['query'].distance
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 小程序首页会直接进入店铺首页,首页无赋值店铺信息逻辑所再次处进入之后赋值
|
||||||
|
if(this['globalData']['parameters']?.brand_id){
|
||||||
|
store.commit('shopping/SETBRANDINFOR', { brand_id: this['globalData']['parameters']['brand_id'], brand_name:decodeURIComponent(this['globalData']['parameters']['brand_name'])});
|
||||||
// 设置店铺信息JIN
|
// 设置店铺信息JIN
|
||||||
store.commit('shopping/SETSHOPDETAIL', {
|
store.commit('shopping/SETSHOPDETAIL', {
|
||||||
city_name: this['globalData']['parameters'].cityInfor.city,
|
city_name: this['globalData']['parameters'].cityInfor.city,
|
||||||
|
|
@ -113,11 +145,13 @@
|
||||||
special: false,
|
special: false,
|
||||||
distance: this['globalData']['parameters'].distance
|
distance: this['globalData']['parameters'].distance
|
||||||
})
|
})
|
||||||
|
console.log(333333333333333333333333333333)
|
||||||
|
store.commit('SETTOKEN', this['globalData']['parameters']['token']);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
console.log(this['globalData']['parameters'],'测试取参');
|
console.log(this['globalData']['parameters']['spread'],'测试取参');
|
||||||
|
this.SETSPREAD(this['globalData']['parameters']['spread']);
|
||||||
this.clearUrlParams();
|
this.clearUrlParams();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
@ -142,44 +176,58 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapMutations({
|
||||||
|
SETSPREAD:'SETSPREAD',
|
||||||
|
SETTOKEN: 'SETTOKEN'
|
||||||
|
}),
|
||||||
|
getParams(url) {
|
||||||
|
const searchParams = new URLSearchParams(url.split("?")[1]);
|
||||||
|
const params = {};
|
||||||
|
for (const [key, value] of searchParams.entries()) {
|
||||||
|
params[key] = value;
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
},
|
||||||
clearUrlParams() {
|
clearUrlParams() {
|
||||||
// 存储分享链接
|
// 存储分享链接
|
||||||
// let basurl = uri(decodeURIComponent(window.location.href))
|
let basurl = uri(decodeURIComponent(window.location.href))
|
||||||
// let querys = basurl.query(true);
|
let querys = basurl.query(true);
|
||||||
// for(let key in querys){
|
if (querys.token) return; // 从分享进入的
|
||||||
// querys[key] = JSON.parse(querys[key])
|
|
||||||
// };
|
|
||||||
// let parameters = { ...querys['userinfor'], ...querys['query']};
|
|
||||||
// parameters.token = '';
|
|
||||||
|
|
||||||
// const safeDecode = (value) => {
|
for(let key in querys){
|
||||||
// if (value == null) return ''; // 默认空值
|
querys[key] = JSON.parse(querys[key])
|
||||||
// try {
|
}
|
||||||
// return typeof value === 'string' ? decodeURIComponent(value) : value;
|
|
||||||
// } catch {
|
|
||||||
// return value; // 解码失败返回原值
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// const userinfor = {
|
|
||||||
// cityInfor: {
|
|
||||||
// lat: safeDecode(parameters.cityInfor.lat),
|
|
||||||
// lng: safeDecode(parameters.cityInfor.lng),
|
|
||||||
// city: safeDecode(parameters.cityInfor.address),
|
|
||||||
// province: safeDecode(parameters.cityInfor.province),
|
|
||||||
// adcode: safeDecode(parameters.cityInfor.adcode),
|
|
||||||
// },
|
|
||||||
// isWechat: true,
|
|
||||||
// };
|
|
||||||
|
|
||||||
// let query = `userinfor=${encodedUserInfor}×tamp=${Date.now()}`;
|
let parameters = { ...querys['userinfor'], ...querys['query']};
|
||||||
|
parameters.token = '';
|
||||||
|
console.log({...querys['query']}, '111111111111111111111111111111111111111')
|
||||||
|
const safeDecode = (value) => {
|
||||||
|
if (value == null) return ''; // 默认空值
|
||||||
|
try {
|
||||||
|
return typeof value === 'string' ? decodeURIComponent(value) : value;
|
||||||
|
} catch {
|
||||||
|
return value; // 解码失败返回原值
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const userinfor = {
|
||||||
|
cityInfor: {
|
||||||
|
lat: safeDecode(parameters.cityInfor.lat),
|
||||||
|
lng: safeDecode(parameters.cityInfor.lng),
|
||||||
|
city: safeDecode(parameters.cityInfor.address),
|
||||||
|
province: safeDecode(parameters.cityInfor.province),
|
||||||
|
adcode: safeDecode(parameters.cityInfor.adcode),
|
||||||
|
},
|
||||||
|
isWechat: true,
|
||||||
|
query: {...querys['query']}
|
||||||
|
};
|
||||||
|
|
||||||
// console.log(HTTP_REQUEST_URL+'?'+query, '分享链接');
|
let query = `userinfor=${encodeURIComponent(JSON.stringify(userinfor))}×tamp=${Date.now()}`;
|
||||||
// uni.setStorageSync('SHARELINK', HTTP_REQUEST_URL+'?'+query);
|
uni.setStorageSync('SHARELINK', 'http://10.210.254.176:8090'+'/privilege/pages/restaurant/home/shop_home/shop_home?'+query);
|
||||||
|
|
||||||
// 清除
|
// 清除url
|
||||||
const url = new URL(window.location.href);
|
// const url = new URL(window.location.href);
|
||||||
url.search = ''; // 移除所有查询参数
|
// url.search = ''; // 移除所有查询参数
|
||||||
window.history.replaceState(null, '', url.href);
|
// window.history.replaceState(null, '', url.href);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -188,8 +236,10 @@
|
||||||
// 全局初始化参数中存在isWechat属性则代表就是从小程序跳入
|
// 全局初始化参数中存在isWechat属性则代表就是从小程序跳入
|
||||||
if (this['globalData']['parameters']?.isWechat) {
|
if (this['globalData']['parameters']?.isWechat) {
|
||||||
store.commit('SetcityInfor', this['globalData']['parameters']['cityInfor']);
|
store.commit('SetcityInfor', this['globalData']['parameters']['cityInfor']);
|
||||||
if (this['globalData']['parameters']['token']) {
|
if (getUrlParams(window.location.href)['token']) { // 优先登录后token
|
||||||
store.commit('SetToken', this['globalData']['parameters']['token']);
|
store.commit('SETTOKEN', decodeURIComponent(getUrlParams(window.location.href)['token']));
|
||||||
|
} else if (this['globalData']['parameters']['token']) { // 跳入token
|
||||||
|
store.commit('SETTOKEN', this['globalData']['parameters']['token']);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 反之则代表从APP进入H5
|
// 反之则代表从APP进入H5
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,8 @@
|
||||||
import {
|
import {
|
||||||
menuQueryAPI,
|
menuQueryAPI,
|
||||||
getStoreInfoAPI,
|
getStoreInfoAPI,
|
||||||
wxconfig
|
wxconfig,
|
||||||
|
Myspread
|
||||||
} from '@/request/restaurant/index.js';
|
} from '@/request/restaurant/index.js';
|
||||||
// 配置文件
|
// 配置文件
|
||||||
import config from '@/static/js/config.js';
|
import config from '@/static/js/config.js';
|
||||||
|
|
@ -93,7 +94,7 @@
|
||||||
XBKSharing
|
XBKSharing
|
||||||
} from '@/static/js/share.js'
|
} from '@/static/js/share.js'
|
||||||
import wx from 'weixin-js-sdk'
|
import wx from 'weixin-js-sdk'
|
||||||
|
import { mapGetters, mapMutations } from 'vuex';
|
||||||
|
|
||||||
let self;
|
let self;
|
||||||
export default {
|
export default {
|
||||||
|
|
@ -159,6 +160,9 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters({
|
||||||
|
GetSpread: 'GetSpread',
|
||||||
|
}),
|
||||||
deviceOS() {
|
deviceOS() {
|
||||||
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
||||||
|
|
||||||
|
|
@ -174,7 +178,7 @@
|
||||||
onLoad(param) {
|
onLoad(param) {
|
||||||
self = this;
|
self = this;
|
||||||
this.handleWechatShare();
|
this.handleWechatShare();
|
||||||
console.log(param['brand_id'], 'onLoad参数');
|
console.log(param, 'onLoad参数ss');
|
||||||
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
||||||
console.log(isWechat, getApp()['globalData']['parameters']?.brand_id, '是否需要分享');
|
console.log(isWechat, getApp()['globalData']['parameters']?.brand_id, '是否需要分享');
|
||||||
if (isWechat && getApp()['globalData']['parameters']?.brand_id) {
|
if (isWechat && getApp()['globalData']['parameters']?.brand_id) {
|
||||||
|
|
@ -493,9 +497,8 @@
|
||||||
const res = await wxconfig({
|
const res = await wxconfig({
|
||||||
url: this.getUrl()
|
url: this.getUrl()
|
||||||
})
|
})
|
||||||
|
|
||||||
let wxConfig = {
|
let wxConfig = {
|
||||||
debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
|
debug: false,
|
||||||
appId: res.data.appId, // 必填,公众号的唯一标识
|
appId: res.data.appId, // 必填,公众号的唯一标识
|
||||||
timestamp: res.data.timestamp || res.data.timestamp, // 必填,生成签名的时间戳
|
timestamp: res.data.timestamp || res.data.timestamp, // 必填,生成签名的时间戳
|
||||||
nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
|
nonceStr: res.data.nonceStr, // 必填,生成签名的随机串
|
||||||
|
|
@ -503,23 +506,24 @@
|
||||||
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
|
jsApiList: ['updateAppMessageShareData', 'updateTimelineShareData'] // 必填,需要使用的JS接口列表
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2、注入权限验证信息,初始化权限信息(目的是为了能够调用微信的相关api)
|
|
||||||
wx.config(wxConfig)
|
wx.config(wxConfig)
|
||||||
|
|
||||||
// 3、初始化微信自定义分享信息(目的是为了在用户点击右上角分享的时候,把分享的内容从链接 变成 自定义内容的卡片)
|
Myspread().then(res => {
|
||||||
this.initWechatShareData()
|
this.initWechatShareData(res.data.uid)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
initWechatShareData() {
|
initWechatShareData(uid) {
|
||||||
// 分享链接参数
|
// 分享链接参数
|
||||||
let url = uni.getStorageSync('SHARELINK');
|
let shareUrl = uni.getStorageSync('SHARELINK');
|
||||||
|
console.log(shareUrl + '&spread=' + uid, '分享链接')
|
||||||
wx.ready(() => {
|
wx.ready(() => {
|
||||||
// 自定义分享朋友信息
|
// 自定义分享朋友信息
|
||||||
wx.updateAppMessageShareData({
|
wx.updateAppMessageShareData({
|
||||||
shareInfo: {
|
shareInfo: {
|
||||||
desc: '欢迎来到白马精选',
|
desc: '欢迎来到白马精选',
|
||||||
title: '白马精选',
|
title: '白马精选',
|
||||||
link: window.location.href,
|
link: shareUrl + '&spread=' + uid,
|
||||||
imgUrl: 'https://imgs.agrimedia.cn/shop/logo.jpg'
|
imgUrl: 'https://imgs.agrimedia.cn/shop/logo.jpg'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -528,7 +532,7 @@
|
||||||
shareInfo: {
|
shareInfo: {
|
||||||
desc: '欢迎来到白马精选',
|
desc: '欢迎来到白马精选',
|
||||||
title: '白马精选',
|
title: '白马精选',
|
||||||
link: window.location.href,
|
link: shareUrl + '&spread=' + this.GetSpread,
|
||||||
imgUrl: 'https://imgs.agrimedia.cn/shop/logo.jpg'
|
imgUrl: 'https://imgs.agrimedia.cn/shop/logo.jpg'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -312,7 +312,6 @@
|
||||||
},
|
},
|
||||||
onShow() {
|
onShow() {
|
||||||
const value = uni.getStorageSync('isWechatStorage');
|
const value = uni.getStorageSync('isWechatStorage');
|
||||||
this.init();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ class Request {
|
||||||
* @param {String} url请求地址
|
* @param {String} url请求地址
|
||||||
*/
|
*/
|
||||||
Request(config = {}) {
|
Request(config = {}) {
|
||||||
console.log(config, '23333')
|
|
||||||
// 是否存在url
|
// 是否存在url
|
||||||
try {
|
try {
|
||||||
if (!config['url']) {
|
if (!config['url']) {
|
||||||
|
|
@ -122,7 +121,6 @@ class Request {
|
||||||
};
|
};
|
||||||
config['complete'] = (infor) => {
|
config['complete'] = (infor) => {
|
||||||
this.responseintercept(infor);
|
this.responseintercept(infor);
|
||||||
console.log(infor, 'wwwwwwwwww')
|
|
||||||
if (infor.data['status'] == 200 || infor.statusCode == 200) {
|
if (infor.data['status'] == 200 || infor.statusCode == 200) {
|
||||||
// arraybuffer格式返回是不带code的
|
// arraybuffer格式返回是不带code的
|
||||||
// 判断是否是arraybuffer
|
// 判断是否是arraybuffer
|
||||||
|
|
@ -134,7 +132,7 @@ class Request {
|
||||||
if (infor['data']['status'] != 200 && infor['data']['code'] != 7777) {
|
if (infor['data']['status'] != 200 && infor['data']['code'] != 7777) {
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
if (infor['data']['status'] == 110002) {
|
if (infor['data']['status'] == 110002) {
|
||||||
window.location.href = `${HTTP_REQUEST_URL}/JXH5/pages/users/h5_login/index`;
|
window.location.href = `${HTTP_REQUEST_URL}/JXH5/pages/users/h5_login/index&redirect_uri=${window.location.protocol + "//" + window.location.host}/privilege/pages/restaurant/home/shop_home/shop_home`;
|
||||||
}
|
}
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
|
|
@ -206,7 +204,7 @@ class Request {
|
||||||
})
|
})
|
||||||
|
|
||||||
console.log(cityInfor, '定位信息头')
|
console.log(cityInfor, '定位信息头')
|
||||||
if (cityInfor?.city) {
|
if (cityInfor?.adcode) {
|
||||||
// config['header']['city'] = encodeURIComponent(cityInfor['city']);
|
// config['header']['city'] = encodeURIComponent(cityInfor['city']);
|
||||||
config['header']['city'] = encodeURIComponent(cityInfor['province']);
|
config['header']['city'] = encodeURIComponent(cityInfor['province']);
|
||||||
config['header']['address'] = encodeURIComponent(cityInfor['province']);
|
config['header']['address'] = encodeURIComponent(cityInfor['province']);
|
||||||
|
|
@ -221,8 +219,6 @@ class Request {
|
||||||
config['header']['lat'] = '';
|
config['header']['lat'] = '';
|
||||||
config['header']['adcode'] = '';
|
config['header']['adcode'] = '';
|
||||||
};
|
};
|
||||||
// config['header']['ApiToken'] =
|
|
||||||
// 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NjM4MTYzMTAsIm5iZiI6MTY2MzgxNjMxMCwiZXhwIjoxNjY2NDA4MzEwLCJkYXRhIjp7ImNsaWVudF9pZCI6MX19.db_hFkDJ2dogkvDkhaBj5W5gti3bFHWWRCVf3-PyF-E';
|
|
||||||
|
|
||||||
// config['header']['token'] ='123456'
|
// config['header']['token'] ='123456'
|
||||||
//chwl 123456
|
//chwl 123456
|
||||||
|
|
@ -230,11 +226,9 @@ class Request {
|
||||||
//
|
//
|
||||||
// 微信跳转H5后的逻辑为必须携带token
|
// 微信跳转H5后的逻辑为必须携带token
|
||||||
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
||||||
console.log(isWechat, '222222222')
|
|
||||||
if (isWechat) {
|
if (isWechat) {
|
||||||
config['header']['authori-zation'] = getApp()['globalData']['parameters']['token'];
|
config['header']['authori-zation'] = state['getters']['GetToken'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// 测试标识
|
// 测试标识
|
||||||
// 测试时不需要显示在线上的打开
|
// 测试时不需要显示在线上的打开
|
||||||
// config['header']['test1'] = 1;
|
// config['header']['test1'] = 1;
|
||||||
|
|
@ -246,20 +240,16 @@ class Request {
|
||||||
config['header']['env'] = 1;
|
config['header']['env'] = 1;
|
||||||
// config['header']['bm_id'] = bm_id;
|
// config['header']['bm_id'] = bm_id;
|
||||||
// console.log(loginAPI,'loginAPI');
|
// console.log(loginAPI,'loginAPI');
|
||||||
console.log(config, '请求拦截器');
|
|
||||||
return config
|
return config
|
||||||
}
|
}
|
||||||
|
|
||||||
// 响应拦截
|
// 响应拦截
|
||||||
responseintercept(infor) {
|
responseintercept(infor) {
|
||||||
console.log(infor, '响应拦截');
|
|
||||||
// const isWechat = getApp()['globalData']['parameters']?.isWech'at;
|
// const isWechat = getApp()['globalData']['parameters']?.isWech'at;
|
||||||
// console.log(isWechat,process.env.NODE_ENV,'isWechat1');
|
// console.log(isWechat,process.env.NODE_ENV,'isWechat1');
|
||||||
// IOS端不经行任何处理
|
// IOS端不经行任何处理
|
||||||
console.log(isSafari && process.env.NODE_ENV !== 'development','是否测试环境111');
|
|
||||||
let isSafari = (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));
|
let isSafari = (/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent));
|
||||||
if (isSafari && process.env.NODE_ENV !== 'development') return;
|
if (isSafari && process.env.NODE_ENV !== 'development') return;
|
||||||
console.log(infor['statusCode'],'是否测试环境11221');
|
|
||||||
// 响应拦截逻辑开始
|
// 响应拦截逻辑开始
|
||||||
// if (infor['statusCode'] != 200) {
|
// if (infor['statusCode'] != 200) {
|
||||||
if (infor.data['status'] != 200) {
|
if (infor.data['status'] != 200) {
|
||||||
|
|
@ -273,7 +263,6 @@ class Request {
|
||||||
if (infor['data']['code'] == 7777) {
|
if (infor['data']['code'] == 7777) {
|
||||||
// 微信中进入H5后会携带token,但是如果微信进入H5后token过期则提示用户返回小程序重新登录
|
// 微信中进入H5后会携带token,但是如果微信进入H5后token过期则提示用户返回小程序重新登录
|
||||||
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
const isWechat = getApp()['globalData']['parameters']?.isWechat;
|
||||||
console.log(isWechat, 'isWechat1');
|
|
||||||
if (isWechat) {
|
if (isWechat) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '登录过期请刷新微信小程序',
|
title: '登录过期请刷新微信小程序',
|
||||||
|
|
@ -282,7 +271,6 @@ class Request {
|
||||||
});
|
});
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
console.log(process.env.NODE_ENV,'是否测试环境');
|
|
||||||
if (process.env.NODE_ENV == 'development') {
|
if (process.env.NODE_ENV == 'development') {
|
||||||
loginAPI({
|
loginAPI({
|
||||||
// 剑南白马ID
|
// 剑南白马ID
|
||||||
|
|
|
||||||
|
|
@ -110,3 +110,10 @@ export const createFoodOrder = parameters => request.Request({ url: "/api/client
|
||||||
*/
|
*/
|
||||||
export const wxconfig = parameters => request.Request({ url: "/api/wechat/config", parameters });
|
export const wxconfig = parameters => request.Request({ url: "/api/wechat/config", parameters });
|
||||||
|
|
||||||
|
|
||||||
|
// 邀请人绑定
|
||||||
|
export const spread = parameters => request.Request({ url: "/api/user/spread", parameters, method:'POST' });
|
||||||
|
|
||||||
|
|
||||||
|
// 我的邀请码
|
||||||
|
export const Myspread = parameters => request.Request({ url: "/api/user", parameters });
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ Vue.use(Vuex);
|
||||||
import {
|
import {
|
||||||
SETRUSERAREA,
|
SETRUSERAREA,
|
||||||
SETCITYCODE,
|
SETCITYCODE,
|
||||||
SETFILMDATA
|
SETFILMDATA,
|
||||||
|
SETSPREAD,
|
||||||
|
SETTOKEN
|
||||||
} from './mutation-types.js'
|
} from './mutation-types.js'
|
||||||
import card from './module/card';
|
import card from './module/card';
|
||||||
// import brand from './module/brand';
|
// import brand from './module/brand';
|
||||||
|
|
@ -61,7 +63,8 @@ const store = new Vuex.Store({
|
||||||
regionName: "", // 区名
|
regionName: "", // 区名
|
||||||
regionId: "" // 区ID
|
regionId: "" // 区ID
|
||||||
},
|
},
|
||||||
token: ''
|
token: '',
|
||||||
|
spread: ''
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
// 获取操作端
|
// 获取操作端
|
||||||
|
|
@ -75,12 +78,13 @@ const store = new Vuex.Store({
|
||||||
// 获取电影城市数据
|
// 获取电影城市数据
|
||||||
GetFilmData: state => state['FilmCityDate'],
|
GetFilmData: state => state['FilmCityDate'],
|
||||||
|
|
||||||
GetToken: state => state['token']
|
GetToken: state => state['token'],
|
||||||
|
GetSpread: state => state['spread']
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
// 用户自主选择位置之后
|
// 用户自主选择位置之后
|
||||||
[SETRUSERAREA](state, data) {
|
[SETRUSERAREA](state, data) {
|
||||||
console.log(data, '233333333333333')
|
console.log(data, '用户自主选择位置之后')
|
||||||
state['Locationtext'] = data;
|
state['Locationtext'] = data;
|
||||||
},
|
},
|
||||||
// 设置城市code
|
// 设置城市code
|
||||||
|
|
@ -88,6 +92,13 @@ const store = new Vuex.Store({
|
||||||
state['AraeCityCode'] = code;
|
state['AraeCityCode'] = code;
|
||||||
console.log('设置城市code', state['AraeCityCode']);
|
console.log('设置城市code', state['AraeCityCode']);
|
||||||
},
|
},
|
||||||
|
[SETSPREAD](state, code) {
|
||||||
|
state['spread'] = code;
|
||||||
|
console.log('设置邀请码code', state['spread']);
|
||||||
|
},
|
||||||
|
[SETTOKEN](state, data) {
|
||||||
|
state['token'] = data;
|
||||||
|
},
|
||||||
// 设置电影城市数据
|
// 设置电影城市数据
|
||||||
SETFILMDATA(state, data) {
|
SETFILMDATA(state, data) {
|
||||||
console.log(data, 'vuex设置电影城市数据')
|
console.log(data, 'vuex设置电影城市数据')
|
||||||
|
|
@ -110,9 +121,6 @@ const store = new Vuex.Store({
|
||||||
*/
|
*/
|
||||||
GetState(state) {
|
GetState(state) {
|
||||||
// uni.setStorageSync('VUEXSTATE', JSON.stringify(store));
|
// uni.setStorageSync('VUEXSTATE', JSON.stringify(store));
|
||||||
},
|
|
||||||
SetToken(state, data) {
|
|
||||||
state['token'] = data;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
modules: {
|
modules: {
|
||||||
|
|
@ -125,7 +133,6 @@ const store = new Vuex.Store({
|
||||||
// 定制
|
// 定制
|
||||||
diy
|
diy
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
window.addEventListener("beforeunload", () => {
|
window.addEventListener("beforeunload", () => {
|
||||||
uni.setStorageSync('VUEXSTATE', JSON.stringify(store['state']));
|
uni.setStorageSync('VUEXSTATE', JSON.stringify(store['state']));
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ export const REDUCE_CART = 'REDUCE_CART';
|
||||||
export const SETRUSERAREA = 'SETRUSERAREA';
|
export const SETRUSERAREA = 'SETRUSERAREA';
|
||||||
// 订餐模块设置用户城市CODE
|
// 订餐模块设置用户城市CODE
|
||||||
export const SETCITYCODE = 'SETCITYCODE';
|
export const SETCITYCODE = 'SETCITYCODE';
|
||||||
|
export const SETSPREAD = 'SETSPREAD';
|
||||||
// 订餐模块设置用户选择品牌
|
// 订餐模块设置用户选择品牌
|
||||||
export const SETBRANDINFOR = 'SETBRANDINFOR';
|
export const SETBRANDINFOR = 'SETBRANDINFOR';
|
||||||
// 订餐模块设置用户选择餐厅信息
|
// 订餐模块设置用户选择餐厅信息
|
||||||
|
|
@ -26,3 +27,5 @@ export const SETNAVINDEX = 'SETNAVINDEX';
|
||||||
export const SETINFOR = 'SETINFOR';
|
export const SETINFOR = 'SETINFOR';
|
||||||
// 设置下单手机号
|
// 设置下单手机号
|
||||||
export const SETPHONE = 'SETPHONE';
|
export const SETPHONE = 'SETPHONE';
|
||||||
|
export const SETTOKEN = 'SETTOKEN';
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue