v1.1
1、提货点 2、客服(腾讯云智服) 3、接口权限控制 4、复制第三方商品可配置 4、优化附件上传配置 5、手机端核销订单 6、手机端订单统计、订单管理 7、短信优化 8、订阅消息全自动化
This commit is contained in:
57
admin/src/libs/dialog.js
Normal file
57
admin/src/libs/dialog.js
Normal file
@@ -0,0 +1,57 @@
|
||||
import {
|
||||
Confirm as confirm,
|
||||
Alert as alert,
|
||||
Toast as toast,
|
||||
Notify as notify,
|
||||
Loading as loading
|
||||
} from "vue-ydui/dist/lib.rem/dialog";
|
||||
|
||||
const dialog = {
|
||||
confirm,
|
||||
alert,
|
||||
toast,
|
||||
notify,
|
||||
loading
|
||||
};
|
||||
|
||||
const icons = { error: "操作失败", success: "操作成功" };
|
||||
Object.keys(icons).reduce((dialog, key) => {
|
||||
dialog[key] = (mes, obj = {}) => {
|
||||
return new Promise(function(resolve) {
|
||||
toast({
|
||||
mes: mes || icons[key],
|
||||
timeout: 1000,
|
||||
icon: key,
|
||||
callback: () => {
|
||||
resolve();
|
||||
},
|
||||
...obj
|
||||
});
|
||||
});
|
||||
};
|
||||
return dialog;
|
||||
}, dialog);
|
||||
|
||||
dialog.message = (mes = "操作失败", obj = {}) => {
|
||||
return new Promise(function(resolve) {
|
||||
toast({
|
||||
mes,
|
||||
timeout: 1000,
|
||||
callback: () => {
|
||||
resolve();
|
||||
},
|
||||
...obj
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
dialog.validateError = (...args) => {
|
||||
validatorDefaultCatch(...args);
|
||||
};
|
||||
|
||||
export function validatorDefaultCatch(err, type = "message") {
|
||||
console.log(err)
|
||||
return dialog[type](err.errors[0].message);
|
||||
}
|
||||
|
||||
export default dialog;
|
||||
38
admin/src/libs/loading.js
Normal file
38
admin/src/libs/loading.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const events = [];
|
||||
|
||||
const $scroll = function(dom, fn) {
|
||||
events.push({ dom, fn });
|
||||
fn._index = events.length - 1;
|
||||
};
|
||||
|
||||
$scroll.remove = function(fn) {
|
||||
fn._index && events.splice(fn._index, 1);
|
||||
};
|
||||
|
||||
//上拉加载;
|
||||
const Scroll = {
|
||||
addHandler: function(element, type, handler) {
|
||||
if (element.addEventListener)
|
||||
element.addEventListener(type, handler, false);
|
||||
else if (element.attachEvent) element.attachEvent("on" + type, handler);
|
||||
else element["on" + type] = handler;
|
||||
},
|
||||
listenTouchDirection: function() {
|
||||
this.addHandler(window, "scroll", function() {
|
||||
const wh = window.innerHeight,
|
||||
st = window.scrollY;
|
||||
events
|
||||
.filter(e => e.dom.scrollHeight && e.dom.scrollHeight > 0)
|
||||
.forEach(e => {
|
||||
var dh = e.dom.scrollHeight;
|
||||
var s = Math.ceil((st / (dh - wh)) * 100);
|
||||
if (s > 85) e.fn();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Scroll.listenTouchDirection();
|
||||
|
||||
export default $scroll;
|
||||
export { Scroll };
|
||||
@@ -1,5 +1,7 @@
|
||||
import { storeStaffListApi } from '@/api/storePoint'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
export function modalSure(title) {
|
||||
console.log(title)
|
||||
return new Promise((resolve, reject) => {
|
||||
this.$confirm(`确定${title || '永久删除该文件'}?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -17,7 +19,6 @@ export function modalSure(title) {
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description 短信是否登录
|
||||
*/
|
||||
@@ -30,3 +31,14 @@ export function isLogin() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 核销员列表
|
||||
*/
|
||||
export function getStoreStaff() {
|
||||
return new Promise((resolve, reject) => {
|
||||
storeStaffListApi({page: 1, limit: 9999}).then(async res => {
|
||||
localStorage.setItem('storeStaffList', res.list ? JSON.stringify(res.list) : [])
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
167
admin/src/libs/wechat.js
Normal file
167
admin/src/libs/wechat.js
Normal file
@@ -0,0 +1,167 @@
|
||||
import WechatJSSDK from "wechat-jssdk/dist/client.umd";
|
||||
import { getWechatConfig, wechatAuth } from "@/api/wxApi";
|
||||
import { getToken, removeToken, setToken } from '@/utils/auth'
|
||||
import { parseQuery } from "@/utils";
|
||||
import Cookies from 'js-cookie'
|
||||
const STATE_KEY = "wx_authorize_state";
|
||||
import store from "@/store";
|
||||
const WX_AUTH = "wx_auth";
|
||||
const BACK_URL = "login_back_url";
|
||||
const LOGINTYPE = "loginType";
|
||||
let instance;
|
||||
let wechatObj;
|
||||
const LONGITUDE = "user_longitude";
|
||||
const LATITUDE = "user_latitude";
|
||||
|
||||
const WECHAT_SCRIPT_URL = "//res.wx.qq.com/open/js/jweixin-1.6.0.js";
|
||||
|
||||
/**
|
||||
* 是否是微信
|
||||
*/
|
||||
export function isWeixin() {
|
||||
return navigator.userAgent.toLowerCase().indexOf("micromessenger") !== -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是移动端
|
||||
*/
|
||||
export function isPhone() {
|
||||
return /(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent);
|
||||
}
|
||||
|
||||
export default function wechat() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (instance) return resolve(instance);
|
||||
getWechatConfig()
|
||||
.then(res => {
|
||||
const _wx = WechatJSSDK(res);
|
||||
wechatObj = _wx;
|
||||
_wx
|
||||
.initialize()
|
||||
.then(() => {
|
||||
instance = _wx.wx;
|
||||
instance.initConfig = res;
|
||||
resolve(instance);
|
||||
})
|
||||
.catch(reject);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function loginByWxCode(code) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let loginType = getToken();
|
||||
wechatAuth(code)
|
||||
.then((res) => {
|
||||
store.commit('SET_TOKEN', res.token)
|
||||
setToken(res.token)
|
||||
Cookies.set(WX_AUTH, code);
|
||||
resolve(res);
|
||||
})
|
||||
.catch((err)=>{
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function getWXCodeByUrl(path, step) {
|
||||
if( getToken() ) return;
|
||||
generatorWxUrl(path, step);
|
||||
}
|
||||
|
||||
export function generatorWxUrl(path, step) {
|
||||
wechat().then(wx => {
|
||||
window.location.href = getAuthUrl(wx.initConfig, path, step);
|
||||
});
|
||||
}
|
||||
|
||||
function getAuthUrl(config, path, step) {
|
||||
const finalUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${config.appId}&redirect_uri=${encodeURIComponent(path)}&response_type=code&scope=snsapi_base&state=${step}#wechat_redirect`;
|
||||
return finalUrl;
|
||||
}
|
||||
|
||||
function getQueryString(name) {
|
||||
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
|
||||
var reg_rewrite = new RegExp("(^|/)" + name + "/([^/]*)(/|$)", "i");
|
||||
var r = window.location.search.substr(1).match(reg);
|
||||
var q = window.location.pathname.substr(1).match(reg_rewrite);
|
||||
if(r != null){
|
||||
return unescape(r[2]);
|
||||
}else if(q != null){
|
||||
return unescape(q[2]);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 公众号事件
|
||||
* @param name 事件名
|
||||
* @param config 配置
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
export function wechatEvevt(name, config) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let wx;
|
||||
let configDefault = {
|
||||
fail(res) {
|
||||
if (wx) return reject({ is_ready: true, wx: wx });
|
||||
getWechatConfig().then(res => {
|
||||
wechatObj.signSignature({
|
||||
nonceStr: res.nonceStr,
|
||||
signature: res.signature,
|
||||
timestamp: res.timestamp
|
||||
});
|
||||
wx = wechatObj.getOriginalWx();
|
||||
reject({ is_ready: true, wx: wx });
|
||||
});
|
||||
},
|
||||
success(res) {
|
||||
resolve(res);
|
||||
},
|
||||
cancel(err) {
|
||||
reject(err);
|
||||
},
|
||||
complete(err) {
|
||||
reject(err);
|
||||
}
|
||||
};
|
||||
Object.assign(configDefault, config);
|
||||
getWechatConfig().then(res => {
|
||||
const _wx = WechatJSSDK(res);
|
||||
_wx.initialize().then(() => {
|
||||
instance = _wx.getOriginalWx();
|
||||
instance.ready(() => {
|
||||
if (typeof name === "object") {
|
||||
name.forEach(item => {
|
||||
instance[item] && instance[item](configDefault);
|
||||
});
|
||||
} else instance[name] && instance[name](configDefault);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function ready() {
|
||||
return new Promise(resolve => {
|
||||
if (typeof instance !== "undefined") {
|
||||
instance.ready(() => {
|
||||
resolve(instance);
|
||||
});
|
||||
} else {
|
||||
getWechatConfig().then(res => {
|
||||
const _wx = WechatJSSDK(res);
|
||||
_wx.initialize().then(() => {
|
||||
instance = _wx.wx;
|
||||
instance.ready(() => {
|
||||
resolve(instance);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user