This commit is contained in:
zoujiandong
2025-06-17 17:58:29 +08:00
commit b496603f7c
129 changed files with 14644 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
const base64src = (base64data, fun) => {
const base64 = base64data; //base64格式图片
const time = new Date().getTime();
const imgPath = wx.env.USER_DATA_PATH + "/poster" + time + "share" + ".png";
//如果图片字符串不含要清空的前缀,可以不执行下行代码.
const imageData = base64.replace(/^data:image\/\w+;base64,/, "");
const file = wx.getFileSystemManager();
file.writeFileSync(imgPath, imageData, "base64");
fun(imgPath);
};
export { base64src };
+33
View File
@@ -0,0 +1,33 @@
function hostConfig(){
const Hosts = {
host_dev:'https://dev-case.igandan.com/api',
img_dev: 'https://medical-case.oss-cn-beijing.aliyuncs.com/static', //开发环境
host_prod:'https://case.igandan.com/api',
img_prod: 'https://medical-case.oss-cn-beijing.aliyuncs.com/static', //线上环境
};
const { envVersion } = wx.getAccountInfoSync().miniProgram;
let imghost="";
let host='';
switch (envVersion) {
case 'develop': //开发环境
host = `${Hosts.host_dev}`;
imghost= `${Hosts.img_dev}`;
break;
case 'trial': //体验版环境
host = `${Hosts.host_dev}`;
imghost=`${Hosts.img_dev}`;
break;
case 'release':
host =`${Hosts.host_prod}`;
imghost=`${Hosts.img_prod}`;
break;
};
return { host, imghost};
}
module.exports={
hostConfig
}
+120
View File
@@ -0,0 +1,120 @@
!(function (t, e) {
'object' === typeof exports && 'undefined' !== typeof module ? module.exports = e() : 'function' === typeof define && define.amd ? define(e) : (t = 'undefined' !== typeof globalThis ? globalThis : t || self).dayjs = e();
}(this, (() => {
'use strict';const t = 1e3; const e = 6e4; const n = 36e5; const r = 'millisecond'; const i = 'second'; const s = 'minute'; const u = 'hour'; const a = 'day'; const o = 'week'; const f = 'month'; const h = 'quarter'; const c = 'year'; const d = 'date'; const $ = 'Invalid Date'; const l = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/; const y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g; const M = { name: 'en', weekdays: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'), months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_') }; const m = function (t, e, n) {
const r = String(t);return !r || r.length >= e ? t : `${Array(e + 1 - r.length).join(n)}${t}`;
}; const g = { s: m, z(t) {
const e = -t.utcOffset(); const n = Math.abs(e); const r = Math.floor(n / 60); const i = n % 60;return `${(e <= 0 ? '+' : '-') + m(r, 2, '0')}:${m(i, 2, '0')}`;
}, m: function t(e, n) {
if (e.date() < n.date()) return -t(n, e);const r = 12 * (n.year() - e.year()) + (n.month() - e.month()); const i = e.clone().add(r, f); const s = n - i < 0; const u = e.clone().add(r + (s ? -1 : 1), f);return +(-(r + (n - i) / (s ? i - u : u - i)) || 0);
}, a(t) {
return t < 0 ? Math.ceil(t) || 0 : Math.floor(t);
}, p(t) {
return { M: f, y: c, w: o, d: a, D: d, h: u, m: s, s: i, ms: r, Q: h }[t] || String(t || '').toLowerCase()
.replace(/s$/, '');
}, u(t) {
return void 0 === t;
} }; let D = 'en'; const v = {};v[D] = M;const p = function (t) {
return t instanceof _;
}; const S = function (t, e, n) {
let r;if (!t) return D;if ('string' === typeof t)v[t] && (r = t), e && (v[t] = e, r = t);else {
const i = t.name;v[i] = t, r = i;
} return !n && r && (D = r), r || !n && D;
}; const w = function (t, e) {
if (p(t)) return t.clone();const n = 'object' === typeof e ? e : {};return n.date = t, n.args = arguments, new _(n);
}; const O = g;O.l = S, O.i = p, O.w = function (t, e) {
return w(t, { locale: e.$L, utc: e.$u, x: e.$x, $offset: e.$offset });
};
var _ = (function () {
function M(t) {
this.$L = S(t.locale, null, !0), this.parse(t);
} const m = M.prototype;return m.parse = function (t) {
this.$d = (function (t) {
const e = t.date; const n = t.utc;if (null === e) return new Date(NaN);if (O.u(e)) return new Date;if (e instanceof Date) return new Date(e);if ('string' === typeof e && !/Z$/i.test(e)) {
const r = e.match(l);if (r) {
const i = r[2] - 1 || 0; const s = (r[7] || '0').substring(0, 3);return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s);
}
} return new Date(e);
}(t)), this.$x = t.x || {}, this.init();
}, m.init = function () {
const t = this.$d;this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
}, m.$utils = function () {
return O;
}, m.isValid = function () {
return !(this.$d.toString() === $);
}, m.isSame = function (t, e) {
const n = w(t);return this.startOf(e) <= n && n <= this.endOf(e);
}, m.isAfter = function (t, e) {
return w(t) < this.startOf(e);
}, m.isBefore = function (t, e) {
return this.endOf(e) < w(t);
}, m.$g = function (t, e, n) {
return O.u(t) ? this[e] : this.set(n, t);
}, m.unix = function () {
return Math.floor(this.valueOf() / 1e3);
}, m.valueOf = function () {
return this.$d.getTime();
}, m.startOf = function (t, e) {
const n = this; const r = !!O.u(e) || e; const h = O.p(t); const $ = function (t, e) {
const i = O.w(n.$u ? Date.UTC(n.$y, e, t) : new Date(n.$y, e, t), n);return r ? i : i.endOf(a);
}; const l = function (t, e) {
return O.w(n.toDate()[t].apply(n.toDate('s'), (r ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), n);
}; const y = this.$W; const M = this.$M; const m = this.$D; const g = `set${this.$u ? 'UTC' : ''}`;switch (h) {
// eslint-disable-next-line no-var
case c:return r ? $(1, 0) : $(31, 11);case f:return r ? $(1, M) : $(0, M + 1);case o:var D = this.$locale().weekStart || 0; var v = (y < D ? y + 7 : y) - D;return $(r ? m - v : m + (6 - v), M);case a:case d:return l(`${g}Hours`, 0);case u:return l(`${g}Minutes`, 1);case s:return l(`${g}Seconds`, 2);case i:return l(`${g}Milliseconds`, 3);default:return this.clone();
}
}, m.endOf = function (t) {
return this.startOf(t, !1);
}, m.$set = function (t, e) {
let n; const o = O.p(t); const h = `set${this.$u ? 'UTC' : ''}`; const $ = (n = {}, n[a] = `${h}Date`, n[d] = `${h}Date`, n[f] = `${h}Month`, n[c] = `${h}FullYear`, n[u] = `${h}Hours`, n[s] = `${h}Minutes`, n[i] = `${h}Seconds`, n[r] = `${h}Milliseconds`, n)[o]; const l = o === a ? this.$D + (e - this.$W) : e;if (o === f || o === c) {
const y = this.clone().set(d, 1);y.$d[$](l), y.init(), this.$d = y.set(d, Math.min(this.$D, y.daysInMonth())).$d;
} else $ && this.$d[$](l);return this.init(), this;
}, m.set = function (t, e) {
return this.clone().$set(t, e);
}, m.get = function (t) {
return this[O.p(t)]();
}, m.add = function (r, h) {
let d; const $ = this;r = Number(r);const l = O.p(h); const y = function (t) {
const e = w($);return O.w(e.date(e.date() + Math.round(t * r)), $);
};if (l === f) return this.set(f, this.$M + r);if (l === c) return this.set(c, this.$y + r);if (l === a) return y(1);if (l === o) return y(7);const M = (d = {}, d[s] = e, d[u] = n, d[i] = t, d)[l] || 1; const m = this.$d.getTime() + r * M;return O.w(m, this);
}, m.subtract = function (t, e) {
return this.add(-1 * t, e);
}, m.format = function (t) {
const e = this; const n = this.$locale();if (!this.isValid()) return n.invalidDate || $;const r = t || 'YYYY-MM-DDTHH:mm:ssZ'; const i = O.z(this); const s = this.$H; const u = this.$m; const a = this.$M; const o = n.weekdays; const f = n.months; const h = function (t, n, i, s) {
return t && (t[n] || t(e, r)) || i[n].substr(0, s);
}; const c = function (t) {
return O.s(s % 12 || 12, t, '0');
}; const d = n.meridiem || function (t, _e, n) {
const r = t < 12 ? 'AM' : 'PM';return n ? r.toLowerCase() : r;
}; const l = { YY: String(this.$y).slice(-2), YYYY: this.$y, M: a + 1, MM: O.s(a + 1, 2, '0'), MMM: h(n.monthsShort, a, f, 3), MMMM: h(f, a), D: this.$D, DD: O.s(this.$D, 2, '0'), d: String(this.$W), dd: h(n.weekdaysMin, this.$W, o, 2), ddd: h(n.weekdaysShort, this.$W, o, 3), dddd: o[this.$W], H: String(s), HH: O.s(s, 2, '0'), h: c(1), hh: c(2), a: d(s, u, !0), A: d(s, u, !1), m: String(u), mm: O.s(u, 2, '0'), s: String(this.$s), ss: O.s(this.$s, 2, '0'), SSS: O.s(this.$ms, 3, '0'), Z: i };return r.replace(y, ((t, e) => e || l[t] || i.replace(':', '')));
}, m.utcOffset = function () {
return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
}, m.diff = function (r, d, $) {
let l; const y = O.p(d); const M = w(r); const m = (M.utcOffset() - this.utcOffset()) * e; const g = this - M; let D = O.m(this, M);return D = (l = {}, l[c] = D / 12, l[f] = D, l[h] = D / 3, l[o] = (g - m) / 6048e5, l[a] = (g - m) / 864e5, l[u] = g / n, l[s] = g / e, l[i] = g / t, l)[y] || g, $ ? D : O.a(D);
}, m.daysInMonth = function () {
return this.endOf(f).$D;
}, m.$locale = function () {
return v[this.$L];
}, m.locale = function (t, e) {
if (!t) return this.$L;const n = this.clone(); const r = S(t, e, !0);return r && (n.$L = r), n;
}, m.clone = function () {
return O.w(this.$d, this);
}, m.toDate = function () {
return new Date(this.valueOf());
}, m.toJSON = function () {
return this.isValid() ? this.toISOString() : null;
}, m.toISOString = function () {
return this.$d.toISOString();
}, m.toString = function () {
return this.$d.toUTCString();
}, M;
}()); const b = _.prototype;return w.prototype = b, [['$ms', r], ['$s', i], ['$m', s], ['$H', u], ['$W', a], ['$M', f], ['$y', c], ['$D', d]].forEach(((t) => {
b[t[1]] = function (e) {
return this.$g(e, t[0], t[1]);
};
})), w.extend = function (t, e) {
return t.$i || (t(e, _, w), t.$i = !0), w;
}, w.locale = S, w.isDayjs = p, w.unix = function (t) {
return w(1e3 * t);
}, w.en = v[D], w.Ls = v, w.p = {}, w;
})));
+91
View File
@@ -0,0 +1,91 @@
const FileUtil = {
//file 为微信file 单文件
getFileName(file){
// size: 132224
// thumb: "http://tmp/0ftStiYfd18K517836423bbfde024c385140a666b344.png"
// type: "image"
// url: "http://tmp/0ftStiYfd18K517836423bbfde024c385140a666b344.png"
if(file){
const uuid = this.UUID().replace("/-/g","");
if(file.url && (file.url.indexOf(".") > -1)){
const fileType = file.url.split(".")[1];
return uuid+"."+fileType;
}else{
return;
}
}
return;
},
UUID () {
if (typeof crypto === 'object') {
if (typeof crypto.randomUUID === 'function') {
return crypto.randomUUID();
}
if (typeof crypto.getRandomValues === 'function' && typeof Uint8Array === 'function') {
const callback = (c) => {
const num = Number(c);
return (num ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (num / 4)))).toString(16);
};
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, callback);
}
}
let timestamp = new Date().getTime();
let perforNow = (typeof performance !== 'undefined' && performance.now && performance.now() * 1000) || 0;
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
let random = Math.random() * 16;
if (timestamp > 0) {
random = (timestamp + random) % 16 | 0;
timestamp = Math.floor(timestamp / 16);
} else {
random = (perforNow + random) % 16 | 0;
perforNow = Math.floor(perforNow / 16);
}
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16);
});
},
canvasToFile(){
let canvas = window.map3DControl.viewer.canvas;
let imgWidth = 1920;
let img = Canvas2Image.convertToImage(
canvas,
imgWidth,
(imgWidth * canvas.height) / canvas.width,
"png"
);
let file_name = new Date().getTime() + ".png";
let imgsrc = img.src.slice(22)
let file = this.convertBase64UrlToImgFile(
imgsrc,
file_name,
"image/png"
)
return file;
},
convertBase64UrlToImgFile(urlData, fileName, fileType) {
urlData = urlData.replace(/^data:image\/\w+;base64,/, "");
let bytes = wx.base64ToArrayBuffer(urlData);
// var bytes = wx.atob(urlData); //转换为byte
//处理异常,将ascii码小于0的转换为大于0
var ab = new ArrayBuffer(bytes.length);
var ia = new Int8Array(ab);
var i;
for (i = 0; i < bytes.length; i++) {
ia[i] = bytes.charCodeAt(i);
}
//转换成文件,添加文件的typenamelastModifiedDate属性
var blob = new Blob([ab], { type: fileType });
blob.lastModifiedDate = new Date();
blob.name = fileName;
return blob;
}
}
export { FileUtil }
+26
View File
@@ -0,0 +1,26 @@
import {
getCurrentPageUrl,
getCurrentPageParam
} from "./getUrl"
function formatUrl(){
let redirectUrl=getCurrentPageUrl();
let options=getCurrentPageParam();
let params="";
let url='';
for (const key in options) {
if(params){
params=params+'&'+key+'='+options[key];
}else{
params=params+key+'='+options[key];
}
};
if(params){
url=redirectUrl+"?"+params
}else{
url=redirectUrl
}
return encodeURIComponent(url);
}
module.exports={
formatUrl
}
+23
View File
@@ -0,0 +1,23 @@
/*获取当前页url*/
const getCurrentPageUrl=()=>{
try {
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1]
let url = currentPage.route
//当前页面url
return url
} catch (error) {
}
}
/*获取当前页参数*/
const getCurrentPageParam=()=>{
let pages = getCurrentPages() //获取加载的页面
let currentPage = pages[pages.length-1] //获取当前页面的对象
let options = currentPage.options //如果要获取url中所带的参数可以查看options
return options
}
module.exports = {
getCurrentPageUrl,
getCurrentPageParam
}
+119
View File
@@ -0,0 +1,119 @@
import {formatUrl} from "../utils/formatParams"
import {getCurrentPageUrl} from "../utils/getUrl"
import {hostConfig} from "../utils/config"
let host=hostConfig().host;
let tokenStr=''
const { envVersion } = wx.getAccountInfoSync().miniProgram;
if(envVersion=="develop" || envVersion=="trial"){
tokenStr="DEV_CASE_TOKEN"
}else{
tokenStr="PROD_CASE_TOKEN"
}
//loding 是否加loading弹窗
function request(url, method, data, loding = false) {
if (loding) {
wx.showLoading({
title: '加载中',
mask: true
})
}
// if (!token) {
// let freelist = ["/wx/user/", '/login/mobile_login','/code/phone','/patient/index',"/popup","/sign/im"];//接口白名单
// let currentUrl=getCurrentPageUrl();
// if (freelist.indexOf(url) == -1 && currentUrl!="pages/personCenter/personCenter") {
// let redirectUrl=formatUrl();
// wx.reLaunch({
// url: '/case/pages/login/login?redirectUrl='+redirectUrl
// });
// }
// }
let token = wx.getStorageSync(tokenStr);
console.log(token)
let header = {
'content-type': 'application/json',
'x-access-token': token
// 'Authorization': 'Bearer ' + token
}
return new Promise((resolve, reject) => {
wx.request({
url: host + url,
method: method,
data: data,
header: header,
success: function (res) {
console.log(res.data);
// var Authorization_token = res.header['x-access-token'];
// if (Authorization_token) {
// wx.setStorageSync(tokenStr, Authorization_token); //当token快过期时,服务器会返回新token,本地刷新
// }
if (loding) {
wx.hideLoading()
wx.stopPullDownRefresh();
}
if (Number(res.data.code) == 200 || Number(res.data.code) == 0) {
resolve(res.data.data);
}else if (Number(res.data.code) == 401 ) {
let redirectUrl=formatUrl();
wx.reLaunch({
url: '/case/pages/mobileLogin/mobileLogin?redirectUrl='+redirectUrl
});
}else if(Number(res.data.code) ==30007 || Number(res.data.code) ==10007){
reject(res.data);
} else {
console.log(res.data)
reject(res.data);
wx.showToast({
title: res.data.msg,
icon: 'none',
duration: 2000
})
}
},
fail: function (res) {
console.log(res)
// wx.showToast({
// title: '网络错误,请稍后再试',
// icon: 'none',
// duration: 2000
// })
// reject(false)
}
})
})
}
function uploadFile(url, data) {
return new Promise((resolve, reject) => {
wx.uploadFile({
url: host + url,
formData: data,
success(res) {
const result = res.data
resolve(result)
},
// fail(res){
// wx.showToast({
// title: '网络错误,请稍后再试',
// icon: 'none',
// })
// reject(false)
// }
})
})
}
module.exports = {
request,
uploadFile
}
+28
View File
@@ -0,0 +1,28 @@
// router.js
module.exports = {
navigateTo(object) {
if (getCurrentPages().length >= 10) {
wx.redirectTo(object)
} else {
wx.navigateTo(object)
}
},
// 其他跳转不处理
navigateBack(object) {
wx.navigateBack(object)
},
switchTab(object) {
wx.switchTab(object)
},
redirectTo(object) {
wx.redirectTo(object)
},
reLaunch(object) {
wx.reLaunch(object)
},
}
+18
View File
@@ -0,0 +1,18 @@
const throttle=function(fn,wait=1000){
var flag = true;
var timer = null;
return function(){
if(flag) {
fn.apply(this,arguments);
flag = false;
timer = setTimeout(() => {
flag = true
},wait)
}
}
}
module.exports = {
throttle
}