feat:v1.4前端更新

This commit is contained in:
超凡
2025-06-24 14:43:09 +08:00
parent 0268aa5033
commit 35fec82e4a
1026 changed files with 118424 additions and 56490 deletions

View File

@@ -1,6 +1,27 @@
import { appAuth } from '../api/public';
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import { appAuth } from '../api/public';
import { tokenIsExistApi } from '@/api/api.js';
class Apps{
/**
* 校验token是否有效,true为有效false为无效
*/
getTokenIsExist(){
return new Promise( (resolve,reject) => {
tokenIsExistApi().then(res => {
resolve(res.data);
}).catch(reject);
})
}
/**
* 授权登录获取token
* @param {Object} code

View File

@@ -1,60 +1,77 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import $store from "@/store";
import { VUE_APP_WS_URL } from "@/utils/index.js";
import {
VUE_APP_WS_URL
} from "@/utils/index.js";
const Socket = function() {
this.ws = new WebSocket(wss(VUE_APP_WS_URL));
this.ws.onopen = this.onOpen.bind(this);
this.ws.onerror = this.onError.bind(this);
this.ws.onmessage = this.onMessage.bind(this);
this.ws.onclose = this.onClose.bind(this);
this.ws = new WebSocket(wss(VUE_APP_WS_URL));
this.ws.onopen = this.onOpen.bind(this);
this.ws.onerror = this.onError.bind(this);
this.ws.onmessage = this.onMessage.bind(this);
this.ws.onclose = this.onClose.bind(this);
};
function wss(wsSocketUrl) {
let ishttps = document.location.protocol == 'https:';
if (ishttps) {
return wsSocketUrl.replace('ws:', 'wss:');
} else {
return wsSocketUrl.replace('wss:', 'ws:');
}
let ishttps = document.location.protocol == 'https:';
if (ishttps) {
return wsSocketUrl.replace('ws:', 'wss:');
} else {
return wsSocketUrl.replace('wss:', 'ws:');
}
}
Socket.prototype = {
vm(vm) {
this.vm = vm;
},
close() {
clearInterval(this.timer);
this.ws.close();
},
onOpen: function() {
console.log("ws open");
this.init();
this.send({
type: "login",
data: $store.state.app.token
});
this.vm.$emit("socket_open");
},
init: function() {
var that = this;
this.timer = setInterval(function() {
that.send({ type: "ping" });
}, 10000);
},
send: function(data) {
return this.ws.send(JSON.stringify(data));
},
onMessage: function(res) {
const { type, data = {} } = JSON.parse(res.data);
this.vm.$emit(type, data);
},
onClose: function() {
clearInterval(this.timer);
},
onError: function(e) {
console.log(e);
this.vm.$emit("socket_error", e);
}
vm(vm) {
this.vm = vm;
},
close() {
clearInterval(this.timer);
this.ws.close();
},
onOpen: function() {
console.log("ws open");
this.init();
this.send({
type: "login",
data: $store.state.app.token
});
this.vm.$emit("socket_open");
},
init: function() {
var that = this;
this.timer = setInterval(function() {
that.send({
type: "ping"
});
}, 10000);
},
send: function(data) {
return this.ws.send(JSON.stringify(data));
},
onMessage: function(res) {
const {
type,
data = {}
} = JSON.parse(res.data);
this.vm.$emit(type, data);
},
onClose: function() {
clearInterval(this.timer);
},
onError: function(e) {
console.log(e);
this.vm.$emit("socket_error", e);
}
};
Socket.prototype.constructor = Socket;

10
app/libs/global.js Normal file
View File

@@ -0,0 +1,10 @@
/**
* 全局使用的变量值
*/
import Cache from '@/utils/cache'
import Vue from 'vue'
const global = {
//图片域名
urlDomain: Cache.get('imgHost')?Cache.get('imgHost'):''
}
Vue.prototype.$GLOBAL = global

23
app/libs/iframe.js Normal file
View File

@@ -0,0 +1,23 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
let app = getApp();
/**
* 点击事件判断是否是isIframe页面
*/
export function goPage() {
return new Promise(resolve => {
if (app.globalData.isIframe == false) {
resolve(true);
}else{
return false
}
});
}

View File

@@ -1,46 +1,50 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import store from "../store";
import Cache from '../utils/cache';
import { Debounce } from '@/utils/validate.js'
// #ifdef H5
// #ifdef H5 || APP-PLUS
import { isWeixin } from "../utils";
import auth from './wechat';
// #endif
import { LOGIN_STATUS, USER_INFO, EXPIRES_TIME, STATE_R_KEY, BACK_URL} from './../config/cache';
function prePage(){
let pages = getCurrentPages();
let prePage = pages[pages.length - 1];
return prePage.route;
return prePage.$page.fullPath;
}
export const toLogin = Debounce(_toLogin,800)
export function _toLogin(push, pathLogin) {
// 公众号登录方式(单选),1微信授权2手机号登录/
let publicLoginType = getApp().globalData.publicLoginType;
store.commit("LOGOUT");
let path = prePage();
let login_back_url = Cache.get(BACK_URL);
// #ifdef APP
uni.navigateTo({
url: '/pages/users/login/index'
})
return
// #endif
// #ifdef H5
// path = location.href;
path = location.href;
path = location.pathname + location.search;
// #endif
if(!pathLogin){
pathLogin = '/page/users/login/index'
Cache.set('login_back_url',path);
Cache.set(BACK_URL,path);
}
// #ifdef H5
if (isWeixin()) {
if (isWeixin() && publicLoginType ==1) {
let urlData = location.pathname + location.search
if (urlData.indexOf('?') !== -1) {
urlData += '&go_longin=1';
@@ -68,9 +72,26 @@ export function _toLogin(push, pathLogin) {
if (['pages/user/index','/pages/user/index'].indexOf(login_back_url) == -1) {
// #ifdef MP
uni.navigateTo({
url: '/pages/users/wechat_login/index'
url: '/pages/users/wechat_login/index'
})
// #endif
// #ifdef APP-PLUS
uni.showModal({
title: '登录提示',
content: '登录以后可体验商城完整功能',
cancelColor: '#000000',
confirmColor: '#526BB1',
success: function (res) {
if (res.confirm) {
uni.navigateTo({
url: '/pages/users/login/index'
})
} else if (res.cancel) {
// console.log('用户点击取消');
}
}
});
// #endif
}
}

View File

@@ -1,8 +1,16 @@
import {
preOrderApi
} from '@/api/order.js';
import util from 'utils/util'
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import {preOrderApi} from '@/api/order.js';
import util from 'utils/util'
import animationType from '@/utils/animationType.js'
/**
* 去商品详情
*/
@@ -36,7 +44,7 @@ export function getPreOrder(preOrderType, orderDetails) {
"orderDetails": orderDetails
}).then(res => {
uni.navigateTo({
url: '/pages/users/order_confirm/index?preOrderNo=' + res.data.preOrderNo
url: '/pages/order/order_confirm/index?preOrderNo=' + res.data.preOrderNo
});
}).catch(err => {
return util.Tips({

View File

@@ -1,7 +1,18 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
import store from '../store';
import { checkLogin } from './login';
import { login } from '../api/public';
import Cache from '../utils/cache';
import { spread } from "@/api/user";
import { STATE_R_KEY, USER_INFO, EXPIRES_TIME, LOGIN_STATUS} from './../config/cache';
class Routine
{
@@ -18,6 +29,35 @@ class Routine
return code;
}
/**
* 小程序基础库版本号比较
*/
compareVersion(v1, v2) {
v1 = v1.split('.')
v2 = v2.split('.')
const len = Math.max(v1.length, v2.length)
while (v1.length < len) {
v1.push('0')
}
while (v2.length < len) {
v2.push('0')
}
for (let i = 0; i < len; i++) {
const num1 = parseInt(v1[i])
const num2 = parseInt(v2[i])
if (num1 > num2) {
return 1
} else if (num1 < num2) {
return -1
}
}
return 0
}
/**
* 获取用户信息
*/

View File

@@ -1,7 +1,15 @@
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
// #ifdef H5
import WechatJSSDK from "@/plugin/jweixin-module/index.js";
import {
getWechatConfig,
wechatAuth
@@ -17,6 +25,7 @@ import {
} from '@/utils';
import store from '@/store';
import Cache from '@/utils/cache';
import util from '@/utils/util'
class AuthWechat {
@@ -29,17 +38,17 @@ class AuthWechat {
this.initConfig = {};
}
isAndroid(){
isAndroid() {
let u = navigator.userAgent;
return u.indexOf('Android') > -1 || u.indexOf('Adr') > -1;
}
signLink() {
if (typeof window.entryUrl === 'undefined' || window.entryUrl === '') {
window.entryUrl = location.href.split('#')[0]
}
return /(Android)/i.test(navigator.userAgent) ? location.href.split('#')[0] : window.entryUrl;
window.entryUrl = location.href.split('#')[0]
}
return /(Android)/i.test(navigator.userAgent) ? location.href.split('#')[0] : window.entryUrl;
}
@@ -58,7 +67,10 @@ class AuthWechat {
resolve(this.instance);
})
}).catch(err => {
console.log('微信分享配置失败',err);
util.Tips({
title: '请正确配置公众号后使用!' + err
});
console.log('微信分享配置失败', err);
this.status = false;
reject(err);
});
@@ -97,11 +109,13 @@ class AuthWechat {
});
}
// 获取经纬度;
location(){
// 获取经纬度;
location() {
return new Promise((resolve, reject) => {
this.wechat().then(wx => {
this.toPromise(wx.getLocation,{type: 'wgs84'}).then(res => {
this.toPromise(wx.getLocation, {
type: 'wgs84'
}).then(res => {
resolve(res);
}).catch(err => {
reject(err);
@@ -110,10 +124,10 @@ class AuthWechat {
reject(err);
})
});
}
}
// 使用微信内置地图查看位置接口;
seeLocation(config){
seeLocation(config) {
return new Promise((resolve, reject) => {
this.wechat().then(wx => {
this.toPromise(wx.openLocation, config).then(res => {
@@ -126,7 +140,7 @@ class AuthWechat {
})
});
}
/**
* 微信支付
* @param {Object} config
@@ -144,7 +158,7 @@ class AuthWechat {
});
});
}
toPromise(fn, config = {}) {
return new Promise((resolve, reject) => {
fn({
@@ -168,19 +182,19 @@ class AuthWechat {
/**
* 自动去授权
*/
oAuth(snsapiBase,url) {
oAuth(snsapiBase, url) {
if (uni.getStorageSync(WX_AUTH) && store.state.app.token && snsapiBase == 'snsapi_base') return;
const {
code
} = parseQuery();
if (!code || code == uni.getStorageSync('snsapiCode')){
return this.toAuth(snsapiBase,url);
}else{
if(Cache.has('snsapiKey'))
return this.auth(code).catch(error=>{
if (!code || code == uni.getStorageSync('snsapiCode')) {
return this.toAuth(snsapiBase, url);
} else {
if (Cache.has('snsapiKey'))
return this.auth(code).catch(error => {
uni.showToast({
title:error,
icon:'none'
title: error,
icon: 'none'
})
})
}
@@ -211,7 +225,7 @@ class AuthWechat {
*/
auth(code) {
return new Promise((resolve, reject) => {
wechatAuth(code, Cache.get("spread"))
wechatAuth(code, Cache.get('spread'))
.then(({
data
}) => {
@@ -220,7 +234,7 @@ class AuthWechat {
Cache.clear(STATE_KEY);
// Cache.clear('spread');
loginType && Cache.clear(LOGINTYPE);
})
.catch(reject);
});
@@ -230,43 +244,43 @@ class AuthWechat {
* 获取跳转授权后的地址
* @param {Object} appId
*/
getAuthUrl(appId,snsapiBase,backUrl) {
getAuthUrl(appId, snsapiBase, backUrl) {
let url = `${location.origin}${backUrl}`
if(url.indexOf('?') == -1){
url = url+'?'
}else{
url = url+'&'
}
const redirect_uri = encodeURIComponent(
`${url}scope=${snsapiBase}&back_url=` +
encodeURIComponent(
encodeURIComponent(
uni.getStorageSync(BACK_URL) ?
uni.getStorageSync(BACK_URL) :
location.pathname + location.search
)
)
);
uni.removeStorageSync(BACK_URL);
const state = encodeURIComponent(
("" + Math.random()).split(".")[1] + "authorizestate"
);
uni.setStorageSync(STATE_KEY, state);
return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
// if(snsapiBase==='snsapi_base'){
// return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=${state}#wechat_redirect`;
// }else{
// return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
// }
}
if (url.indexOf('?') == -1) {
url = url + '?'
} else {
url = url + '&'
}
const redirect_uri = encodeURIComponent(
`${url}scope=${snsapiBase}&back_url=` +
encodeURIComponent(
encodeURIComponent(
uni.getStorageSync(BACK_URL) ?
uni.getStorageSync(BACK_URL) :
location.pathname + location.search
)
)
);
uni.removeStorageSync(BACK_URL);
const state = encodeURIComponent(
("" + Math.random()).split(".")[1] + "authorizestate"
);
uni.setStorageSync(STATE_KEY, state);
return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
// if(snsapiBase==='snsapi_base'){
// return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_base&state=${state}#wechat_redirect`;
// }else{
// return `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=${state}#wechat_redirect`;
// }
}
/**
* 跳转自动登录
*/
toAuth(snsapiBase,backUrl) {
toAuth(snsapiBase, backUrl) {
let that = this;
this.wechat().then(wx => {
location.href = this.getAuthUrl(that.initConfig.appId,snsapiBase,backUrl);
location.href = this.getAuthUrl(that.initConfig.appId, snsapiBase, backUrl);
})
}
@@ -292,7 +306,7 @@ class AuthWechat {
})
},
success(res) {
return resolve(res,2222);
return resolve(res, 2222);
}
};
Object.assign(configDefault, config);