var __defProp = Object.defineProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
import { r as requireNativePlugin, f as formatAppLog, a as resolveEasycom, o as onLoad } from "./uni-app.es.js";
import { openBlock, createElementBlock, normalizeStyle, toDisplayString, normalizeClass, renderSlot, createCommentVNode, resolveDynamicComponent, createElementVNode, createBlock, createVNode, withCtx, ref, watch, getCurrentInstance, computed, Fragment, withModifiers, onMounted, reactive, resolveComponent, nextTick, onBeforeUnmount, renderList } from "vue";
import { _ as _export_sfc } from "./_plugin-vue_export-helper.js";
import { createStore } from "vuex";
const fontData = [
{
"font_class": "arrow-down",
"unicode": ""
},
{
"font_class": "arrow-left",
"unicode": ""
},
{
"font_class": "arrow-right",
"unicode": ""
},
{
"font_class": "arrow-up",
"unicode": ""
},
{
"font_class": "auth",
"unicode": ""
},
{
"font_class": "auth-filled",
"unicode": ""
},
{
"font_class": "back",
"unicode": ""
},
{
"font_class": "bars",
"unicode": ""
},
{
"font_class": "calendar",
"unicode": ""
},
{
"font_class": "calendar-filled",
"unicode": ""
},
{
"font_class": "camera",
"unicode": ""
},
{
"font_class": "camera-filled",
"unicode": ""
},
{
"font_class": "cart",
"unicode": ""
},
{
"font_class": "cart-filled",
"unicode": ""
},
{
"font_class": "chat",
"unicode": ""
},
{
"font_class": "chat-filled",
"unicode": ""
},
{
"font_class": "chatboxes",
"unicode": ""
},
{
"font_class": "chatboxes-filled",
"unicode": ""
},
{
"font_class": "chatbubble",
"unicode": ""
},
{
"font_class": "chatbubble-filled",
"unicode": ""
},
{
"font_class": "checkbox",
"unicode": ""
},
{
"font_class": "checkbox-filled",
"unicode": ""
},
{
"font_class": "checkmarkempty",
"unicode": ""
},
{
"font_class": "circle",
"unicode": ""
},
{
"font_class": "circle-filled",
"unicode": ""
},
{
"font_class": "clear",
"unicode": ""
},
{
"font_class": "close",
"unicode": ""
},
{
"font_class": "closeempty",
"unicode": ""
},
{
"font_class": "cloud-download",
"unicode": ""
},
{
"font_class": "cloud-download-filled",
"unicode": ""
},
{
"font_class": "cloud-upload",
"unicode": ""
},
{
"font_class": "cloud-upload-filled",
"unicode": ""
},
{
"font_class": "color",
"unicode": ""
},
{
"font_class": "color-filled",
"unicode": ""
},
{
"font_class": "compose",
"unicode": ""
},
{
"font_class": "contact",
"unicode": ""
},
{
"font_class": "contact-filled",
"unicode": ""
},
{
"font_class": "down",
"unicode": ""
},
{
"font_class": "bottom",
"unicode": ""
},
{
"font_class": "download",
"unicode": ""
},
{
"font_class": "download-filled",
"unicode": ""
},
{
"font_class": "email",
"unicode": ""
},
{
"font_class": "email-filled",
"unicode": ""
},
{
"font_class": "eye",
"unicode": ""
},
{
"font_class": "eye-filled",
"unicode": ""
},
{
"font_class": "eye-slash",
"unicode": ""
},
{
"font_class": "eye-slash-filled",
"unicode": ""
},
{
"font_class": "fire",
"unicode": ""
},
{
"font_class": "fire-filled",
"unicode": ""
},
{
"font_class": "flag",
"unicode": ""
},
{
"font_class": "flag-filled",
"unicode": ""
},
{
"font_class": "folder-add",
"unicode": ""
},
{
"font_class": "folder-add-filled",
"unicode": ""
},
{
"font_class": "font",
"unicode": ""
},
{
"font_class": "forward",
"unicode": ""
},
{
"font_class": "gear",
"unicode": ""
},
{
"font_class": "gear-filled",
"unicode": ""
},
{
"font_class": "gift",
"unicode": ""
},
{
"font_class": "gift-filled",
"unicode": ""
},
{
"font_class": "hand-down",
"unicode": ""
},
{
"font_class": "hand-down-filled",
"unicode": ""
},
{
"font_class": "hand-up",
"unicode": ""
},
{
"font_class": "hand-up-filled",
"unicode": ""
},
{
"font_class": "headphones",
"unicode": ""
},
{
"font_class": "heart",
"unicode": ""
},
{
"font_class": "heart-filled",
"unicode": ""
},
{
"font_class": "help",
"unicode": ""
},
{
"font_class": "help-filled",
"unicode": ""
},
{
"font_class": "home",
"unicode": ""
},
{
"font_class": "home-filled",
"unicode": ""
},
{
"font_class": "image",
"unicode": ""
},
{
"font_class": "image-filled",
"unicode": ""
},
{
"font_class": "images",
"unicode": ""
},
{
"font_class": "images-filled",
"unicode": ""
},
{
"font_class": "info",
"unicode": ""
},
{
"font_class": "info-filled",
"unicode": ""
},
{
"font_class": "left",
"unicode": ""
},
{
"font_class": "link",
"unicode": ""
},
{
"font_class": "list",
"unicode": ""
},
{
"font_class": "location",
"unicode": ""
},
{
"font_class": "location-filled",
"unicode": ""
},
{
"font_class": "locked",
"unicode": ""
},
{
"font_class": "locked-filled",
"unicode": ""
},
{
"font_class": "loop",
"unicode": ""
},
{
"font_class": "mail-open",
"unicode": ""
},
{
"font_class": "mail-open-filled",
"unicode": ""
},
{
"font_class": "map",
"unicode": ""
},
{
"font_class": "map-filled",
"unicode": ""
},
{
"font_class": "map-pin",
"unicode": ""
},
{
"font_class": "map-pin-ellipse",
"unicode": ""
},
{
"font_class": "medal",
"unicode": ""
},
{
"font_class": "medal-filled",
"unicode": ""
},
{
"font_class": "mic",
"unicode": ""
},
{
"font_class": "mic-filled",
"unicode": ""
},
{
"font_class": "micoff",
"unicode": ""
},
{
"font_class": "micoff-filled",
"unicode": ""
},
{
"font_class": "minus",
"unicode": ""
},
{
"font_class": "minus-filled",
"unicode": ""
},
{
"font_class": "more",
"unicode": ""
},
{
"font_class": "more-filled",
"unicode": ""
},
{
"font_class": "navigate",
"unicode": ""
},
{
"font_class": "navigate-filled",
"unicode": ""
},
{
"font_class": "notification",
"unicode": ""
},
{
"font_class": "notification-filled",
"unicode": ""
},
{
"font_class": "paperclip",
"unicode": ""
},
{
"font_class": "paperplane",
"unicode": ""
},
{
"font_class": "paperplane-filled",
"unicode": ""
},
{
"font_class": "person",
"unicode": ""
},
{
"font_class": "person-filled",
"unicode": ""
},
{
"font_class": "personadd",
"unicode": ""
},
{
"font_class": "personadd-filled",
"unicode": ""
},
{
"font_class": "personadd-filled-copy",
"unicode": ""
},
{
"font_class": "phone",
"unicode": ""
},
{
"font_class": "phone-filled",
"unicode": ""
},
{
"font_class": "plus",
"unicode": ""
},
{
"font_class": "plus-filled",
"unicode": ""
},
{
"font_class": "plusempty",
"unicode": ""
},
{
"font_class": "pulldown",
"unicode": ""
},
{
"font_class": "pyq",
"unicode": ""
},
{
"font_class": "qq",
"unicode": ""
},
{
"font_class": "redo",
"unicode": ""
},
{
"font_class": "redo-filled",
"unicode": ""
},
{
"font_class": "refresh",
"unicode": ""
},
{
"font_class": "refresh-filled",
"unicode": ""
},
{
"font_class": "refreshempty",
"unicode": ""
},
{
"font_class": "reload",
"unicode": ""
},
{
"font_class": "right",
"unicode": ""
},
{
"font_class": "scan",
"unicode": ""
},
{
"font_class": "search",
"unicode": ""
},
{
"font_class": "settings",
"unicode": ""
},
{
"font_class": "settings-filled",
"unicode": ""
},
{
"font_class": "shop",
"unicode": ""
},
{
"font_class": "shop-filled",
"unicode": ""
},
{
"font_class": "smallcircle",
"unicode": ""
},
{
"font_class": "smallcircle-filled",
"unicode": ""
},
{
"font_class": "sound",
"unicode": ""
},
{
"font_class": "sound-filled",
"unicode": ""
},
{
"font_class": "spinner-cycle",
"unicode": ""
},
{
"font_class": "staff",
"unicode": ""
},
{
"font_class": "staff-filled",
"unicode": ""
},
{
"font_class": "star",
"unicode": ""
},
{
"font_class": "star-filled",
"unicode": ""
},
{
"font_class": "starhalf",
"unicode": ""
},
{
"font_class": "trash",
"unicode": ""
},
{
"font_class": "trash-filled",
"unicode": ""
},
{
"font_class": "tune",
"unicode": ""
},
{
"font_class": "tune-filled",
"unicode": ""
},
{
"font_class": "undo",
"unicode": ""
},
{
"font_class": "undo-filled",
"unicode": ""
},
{
"font_class": "up",
"unicode": ""
},
{
"font_class": "top",
"unicode": ""
},
{
"font_class": "upload",
"unicode": ""
},
{
"font_class": "upload-filled",
"unicode": ""
},
{
"font_class": "videocam",
"unicode": ""
},
{
"font_class": "videocam-filled",
"unicode": ""
},
{
"font_class": "vip",
"unicode": ""
},
{
"font_class": "vip-filled",
"unicode": ""
},
{
"font_class": "wallet",
"unicode": ""
},
{
"font_class": "wallet-filled",
"unicode": ""
},
{
"font_class": "weibo",
"unicode": ""
},
{
"font_class": "weixin",
"unicode": ""
}
];
const iconUrl = "/assets/uniicons.32e978a5.ttf";
const _style_0$a = { "uni-icons": { "": { "fontFamily": "uniicons", "textDecoration": "none", "textAlign": "center" } } };
const getVal = (val) => {
const reg = /^[0-9]*$/g;
return typeof val === "number" || reg.test(val) ? val + "px" : val;
};
var domModule = weex.requireModule("dom");
domModule.addRule("fontFace", {
"fontFamily": "uniicons",
"src": "url('" + iconUrl + "')"
});
const _sfc_main$c = {
name: "UniIcons",
emits: ["click"],
props: {
type: {
type: String,
default: ""
},
color: {
type: String,
default: "#333333"
},
size: {
type: [Number, String],
default: 16
},
customPrefix: {
type: String,
default: ""
},
fontFamily: {
type: String,
default: ""
}
},
data() {
return {
icons: fontData
};
},
computed: {
unicode() {
let code = this.icons.find((v) => v.font_class === this.type);
if (code) {
return code.unicode;
}
return "";
},
iconSize() {
return getVal(this.size);
},
styleObj() {
if (this.fontFamily !== "") {
return `color: ${this.color}; font-size: ${this.iconSize}; font-family: ${this.fontFamily};`;
}
return `color: ${this.color}; font-size: ${this.iconSize};`;
}
},
methods: {
_onClick() {
this.$emit("click");
}
}
};
function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock(
"u-text",
{
style: normalizeStyle($options.styleObj),
class: "uni-icons",
onClick: _cache[0] || (_cache[0] = (...args) => $options._onClick && $options._onClick(...args))
},
toDisplayString($options.unicode),
5
/* TEXT, STYLE */
);
}
const __easycom_0 = /* @__PURE__ */ _export_sfc(_sfc_main$c, [["render", _sfc_render$c], ["styles", [_style_0$a]], ["__file", "D:/document/九亿商城/jy/jiuyi2/uni_modules/uni-icons/components/uni-icons/uni-icons.vue"]]);
const nvueAnimation = requireNativePlugin("animation");
class MPAnimation {
constructor(options, _this) {
this.options = options;
this.animation = uni.createAnimation({
...options
});
this.currentStepAnimates = {};
this.next = 0;
this.$ = _this;
}
_nvuePushAnimates(type, args) {
let aniObj = this.currentStepAnimates[this.next];
let styles = {};
if (!aniObj) {
styles = {
styles: {},
config: {}
};
} else {
styles = aniObj;
}
if (animateTypes1.includes(type)) {
if (!styles.styles.transform) {
styles.styles.transform = "";
}
let unit = "";
if (type === "rotate") {
unit = "deg";
}
styles.styles.transform += `${type}(${args + unit}) `;
} else {
styles.styles[type] = `${args}`;
}
this.currentStepAnimates[this.next] = styles;
}
_animateRun(styles = {}, config2 = {}) {
let ref2 = this.$.$refs["ani"].ref;
if (!ref2)
return;
return new Promise((resolve, reject) => {
nvueAnimation.transition(ref2, {
styles,
...config2
}, (res) => {
resolve();
});
});
}
_nvueNextAnimate(animates, step = 0, fn) {
let obj = animates[step];
if (obj) {
let {
styles,
config: config2
} = obj;
this._animateRun(styles, config2).then(() => {
step += 1;
this._nvueNextAnimate(animates, step, fn);
});
} else {
this.currentStepAnimates = {};
typeof fn === "function" && fn();
this.isEnd = true;
}
}
step(config2 = {}) {
this.currentStepAnimates[this.next].config = Object.assign({}, this.options, config2);
this.currentStepAnimates[this.next].styles.transformOrigin = this.currentStepAnimates[this.next].config.transformOrigin;
this.next++;
return this;
}
run(fn) {
this.isEnd = false;
let ref2 = this.$.$refs["ani"] && this.$.$refs["ani"].ref;
if (!ref2)
return;
this._nvueNextAnimate(this.currentStepAnimates, 0, fn);
this.next = 0;
}
}
const animateTypes1 = [
"matrix",
"matrix3d",
"rotate",
"rotate3d",
"rotateX",
"rotateY",
"rotateZ",
"scale",
"scale3d",
"scaleX",
"scaleY",
"scaleZ",
"skew",
"skewX",
"skewY",
"translate",
"translate3d",
"translateX",
"translateY",
"translateZ"
];
const animateTypes2 = ["opacity", "backgroundColor"];
const animateTypes3 = ["width", "height", "left", "right", "top", "bottom"];
animateTypes1.concat(animateTypes2, animateTypes3).forEach((type) => {
MPAnimation.prototype[type] = function(...args) {
this._nvuePushAnimates(type, args);
return this;
};
});
function createAnimation(option, _this) {
if (!_this)
return;
clearTimeout(_this.timer);
return new MPAnimation(option, _this);
}
const _sfc_main$b = {
name: "uniTransition",
emits: ["click", "change"],
props: {
show: {
type: Boolean,
default: false
},
modeClass: {
type: [Array, String],
default() {
return "fade";
}
},
duration: {
type: Number,
default: 300
},
styles: {
type: Object,
default() {
return {};
}
},
customClass: {
type: String,
default: ""
},
onceRender: {
type: Boolean,
default: false
}
},
data() {
return {
isShow: false,
transform: "",
opacity: 1,
animationData: {},
durationTime: 300,
config: {}
};
},
watch: {
show: {
handler(newVal) {
if (newVal) {
this.open();
} else {
if (this.isShow) {
this.close();
}
}
},
immediate: true
}
},
computed: {
// 生成样式数据
stylesObject() {
let styles = {
...this.styles,
"transition-duration": this.duration / 1e3 + "s"
};
let transform = "";
for (let i in styles) {
let line = this.toLine(i);
transform += line + ":" + styles[i] + ";";
}
return transform;
},
// 初始化动画条件
transformStyles() {
return "transform:" + this.transform + ";opacity:" + this.opacity + ";" + this.stylesObject;
}
},
created() {
this.config = {
duration: this.duration,
timingFunction: "ease",
transformOrigin: "50% 50%",
delay: 0
};
this.durationTime = this.duration;
},
methods: {
/**
* ref 触发 初始化动画
*/
init(obj = {}) {
if (obj.duration) {
this.durationTime = obj.duration;
}
this.animation = createAnimation(Object.assign(this.config, obj), this);
},
/**
* 点击组件触发回调
*/
onClick() {
this.$emit("click", {
detail: this.isShow
});
},
/**
* ref 触发 动画分组
* @param {Object} obj
*/
step(obj, config2 = {}) {
if (!this.animation)
return;
for (let i in obj) {
try {
if (typeof obj[i] === "object") {
this.animation[i](...obj[i]);
} else {
this.animation[i](obj[i]);
}
} catch (e) {
formatAppLog("error", "at uni_modules/uni-transition/components/uni-transition/uni-transition.vue:148", `方法 ${i} 不存在`);
}
}
this.animation.step(config2);
return this;
},
/**
* ref 触发 执行动画
*/
run(fn) {
if (!this.animation)
return;
this.animation.run(fn);
},
// 开始过度动画
open() {
clearTimeout(this.timer);
this.transform = "";
this.isShow = true;
let { opacity, transform } = this.styleInit(false);
if (typeof opacity !== "undefined") {
this.opacity = opacity;
}
this.transform = transform;
this.$nextTick(() => {
this.timer = setTimeout(() => {
this.animation = createAnimation(this.config, this);
this.tranfromInit(false).step();
this.animation.run();
this.$emit("change", {
detail: this.isShow
});
}, 20);
});
},
// 关闭过度动画
close(type) {
if (!this.animation)
return;
this.tranfromInit(true).step().run(() => {
this.isShow = false;
this.animationData = null;
this.animation = null;
let { opacity, transform } = this.styleInit(false);
this.opacity = opacity || 1;
this.transform = transform;
this.$emit("change", {
detail: this.isShow
});
});
},
// 处理动画开始前的默认样式
styleInit(type) {
let styles = {
transform: ""
};
let buildStyle = (type2, mode) => {
if (mode === "fade") {
styles.opacity = this.animationType(type2)[mode];
} else {
styles.transform += this.animationType(type2)[mode] + " ";
}
};
if (typeof this.modeClass === "string") {
buildStyle(type, this.modeClass);
} else {
this.modeClass.forEach((mode) => {
buildStyle(type, mode);
});
}
return styles;
},
// 处理内置组合动画
tranfromInit(type) {
let buildTranfrom = (type2, mode) => {
let aniNum = null;
if (mode === "fade") {
aniNum = type2 ? 0 : 1;
} else {
aniNum = type2 ? "-100%" : "0";
if (mode === "zoom-in") {
aniNum = type2 ? 0.8 : 1;
}
if (mode === "zoom-out") {
aniNum = type2 ? 1.2 : 1;
}
if (mode === "slide-right") {
aniNum = type2 ? "100%" : "0";
}
if (mode === "slide-bottom") {
aniNum = type2 ? "100%" : "0";
}
}
this.animation[this.animationMode()[mode]](aniNum);
};
if (typeof this.modeClass === "string") {
buildTranfrom(type, this.modeClass);
} else {
this.modeClass.forEach((mode) => {
buildTranfrom(type, mode);
});
}
return this.animation;
},
animationType(type) {
return {
fade: type ? 0 : 1,
"slide-top": `translateY(${type ? "0" : "-100%"})`,
"slide-right": `translateX(${type ? "0" : "100%"})`,
"slide-bottom": `translateY(${type ? "0" : "100%"})`,
"slide-left": `translateX(${type ? "0" : "-100%"})`,
"zoom-in": `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
"zoom-out": `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
};
},
// 内置动画类型与实际动画对应字典
animationMode() {
return {
fade: "opacity",
"slide-top": "translateY",
"slide-right": "translateX",
"slide-bottom": "translateY",
"slide-left": "translateX",
"zoom-in": "scale",
"zoom-out": "scale"
};
},
// 驼峰转中横线
toLine(name) {
return name.replace(/([A-Z])/g, "-$1").toLowerCase();
}
}
};
function _sfc_render$b(_ctx, _cache, $props, $setup, $data, $options) {
return $data.isShow ? (openBlock(), createElementBlock("view", {
key: 0,
ref: "ani",
animation: $data.animationData,
class: normalizeClass($props.customClass),
style: normalizeStyle($options.transformStyles),
onClick: _cache[0] || (_cache[0] = (...args) => $options.onClick && $options.onClick(...args)),
renderWhole: true
}, [
renderSlot(_ctx.$slots, "default")
], 14, ["animation"])) : createCommentVNode("v-if", true);
}
const __easycom_1$2 = /* @__PURE__ */ _export_sfc(_sfc_main$b, [["render", _sfc_render$b], ["__file", "D:/document/九亿商城/jy/jiuyi2/uni_modules/uni-transition/components/uni-transition/uni-transition.vue"]]);
const _style_0$9 = { "uni-popup": { "": { "position": "fixed" }, ".top": { "top": 0 }, ".left": { "top": 0 }, ".right": { "top": 0 } }, "uni-popup__wrapper": { ".uni-popup ": { "position": "relative" }, ".uni-popup .left": { "paddingTop": 0, "flex": 1 }, ".uni-popup .right": { "paddingTop": 0, "flex": 1 } }, "fixforpc-top": { "": { "top": 0 } } };
const _sfc_main$a = {
name: "uniPopup",
components: {},
emits: ["change", "maskClick"],
props: {
// 开启动画
animation: {
type: Boolean,
default: true
},
// 弹出层类型,可选值,top: 顶部弹出层;bottom:底部弹出层;center:全屏弹出层
// message: 消息提示 ; dialog : 对话框
type: {
type: String,
default: "center"
},
// maskClick
isMaskClick: {
type: Boolean,
default: null
},
// TODO 2 个版本后废弃属性 ,使用 isMaskClick
maskClick: {
type: Boolean,
default: null
},
backgroundColor: {
type: String,
default: "none"
},
safeArea: {
type: Boolean,
default: true
},
maskBackgroundColor: {
type: String,
default: "rgba(0, 0, 0, 0.4)"
},
borderRadius: {
type: String
}
},
watch: {
/**
* 监听type类型
*/
type: {
handler: function(type) {
if (!this.config[type])
return;
this[this.config[type]](true);
},
immediate: true
},
isDesktop: {
handler: function(newVal) {
if (!this.config[newVal])
return;
this[this.config[this.type]](true);
},
immediate: true
},
/**
* 监听遮罩是否可点击
* @param {Object} val
*/
maskClick: {
handler: function(val) {
this.mkclick = val;
},
immediate: true
},
isMaskClick: {
handler: function(val) {
this.mkclick = val;
},
immediate: true
},
// H5 下禁止底部滚动
showPopup(show) {
}
},
data() {
return {
duration: 300,
ani: [],
showPopup: false,
showTrans: false,
popupWidth: 0,
popupHeight: 0,
config: {
top: "top",
bottom: "bottom",
center: "center",
left: "left",
right: "right",
message: "top",
dialog: "center",
share: "bottom"
},
maskClass: {
position: "fixed",
bottom: 0,
top: 0,
left: 0,
right: 0,
backgroundColor: "rgba(0, 0, 0, 0.4)"
},
transClass: {
backgroundColor: "transparent",
borderRadius: this.borderRadius || "0",
position: "fixed",
left: 0,
right: 0
},
maskShow: true,
mkclick: true,
popupstyle: "top"
};
},
computed: {
getStyles() {
let res = { backgroundColor: this.bg };
if (this.borderRadius || "0") {
res = Object.assign(res, { borderRadius: this.borderRadius });
}
return res;
},
isDesktop() {
return this.popupWidth >= 500 && this.popupHeight >= 500;
},
bg() {
if (this.backgroundColor === "" || this.backgroundColor === "none") {
return "transparent";
}
return this.backgroundColor;
}
},
mounted() {
const fixSize = () => {
const {
windowWidth,
windowHeight,
windowTop,
safeArea,
screenHeight,
safeAreaInsets
} = uni.getSystemInfoSync();
this.popupWidth = windowWidth;
this.popupHeight = windowHeight + (windowTop || 0);
if (safeArea && this.safeArea) {
this.safeAreaInsets = safeAreaInsets.bottom;
} else {
this.safeAreaInsets = 0;
}
};
fixSize();
},
// TODO vue3
unmounted() {
this.setH5Visible();
},
activated() {
this.setH5Visible(!this.showPopup);
},
deactivated() {
this.setH5Visible(true);
},
created() {
if (this.isMaskClick === null && this.maskClick === null) {
this.mkclick = true;
} else {
this.mkclick = this.isMaskClick !== null ? this.isMaskClick : this.maskClick;
}
if (this.animation) {
this.duration = 300;
} else {
this.duration = 0;
}
this.messageChild = null;
this.clearPropagation = false;
this.maskClass.backgroundColor = this.maskBackgroundColor;
},
methods: {
setH5Visible(visible = true) {
},
/**
* 公用方法,不显示遮罩层
*/
closeMask() {
this.maskShow = false;
},
/**
* 公用方法,遮罩层禁止点击
*/
disableMask() {
this.mkclick = false;
},
// TODO nvue 取消冒泡
clear(e) {
this.clearPropagation = true;
},
open(direction) {
if (this.showPopup) {
return;
}
let innerType = ["top", "center", "bottom", "left", "right", "message", "dialog", "share"];
if (!(direction && innerType.indexOf(direction) !== -1)) {
direction = this.type;
}
if (!this.config[direction]) {
formatAppLog("error", "at uni_modules/uni-popup/components/uni-popup/uni-popup.vue:298", "缺少类型:", direction);
return;
}
this[this.config[direction]]();
this.$emit("change", {
show: true,
type: direction
});
},
close(type) {
this.showTrans = false;
this.$emit("change", {
show: false,
type: this.type
});
clearTimeout(this.timer);
this.timer = setTimeout(() => {
this.showPopup = false;
}, 300);
},
// TODO 处理冒泡事件,头条的冒泡事件有问题 ,先这样兼容
touchstart() {
this.clearPropagation = false;
},
onTap() {
if (this.clearPropagation) {
this.clearPropagation = false;
return;
}
this.$emit("maskClick");
if (!this.mkclick)
return;
this.close();
},
/**
* 顶部弹出样式处理
*/
top(type) {
this.popupstyle = this.isDesktop ? "fixforpc-top" : "top";
this.ani = ["slide-top"];
this.transClass = {
position: "fixed",
left: 0,
right: 0,
backgroundColor: this.bg,
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPopup = true;
this.showTrans = true;
this.$nextTick(() => {
if (this.messageChild && this.type === "message") {
this.messageChild.timerClose();
}
});
},
/**
* 底部弹出样式处理
*/
bottom(type) {
this.popupstyle = "bottom";
this.ani = ["slide-bottom"];
this.transClass = {
position: "fixed",
left: 0,
right: 0,
bottom: 0,
paddingBottom: this.safeAreaInsets + "px",
backgroundColor: this.bg,
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPopup = true;
this.showTrans = true;
},
/**
* 中间弹出样式处理
*/
center(type) {
this.popupstyle = "center";
this.ani = ["zoom-out", "fade"];
this.transClass = {
position: "fixed",
bottom: 0,
left: 0,
right: 0,
top: 0,
justifyContent: "center",
alignItems: "center",
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPopup = true;
this.showTrans = true;
},
left(type) {
this.popupstyle = "left";
this.ani = ["slide-left"];
this.transClass = {
position: "fixed",
left: 0,
bottom: 0,
top: 0,
backgroundColor: this.bg,
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPopup = true;
this.showTrans = true;
},
right(type) {
this.popupstyle = "right";
this.ani = ["slide-right"];
this.transClass = {
position: "fixed",
bottom: 0,
right: 0,
top: 0,
backgroundColor: this.bg,
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPopup = true;
this.showTrans = true;
}
}
};
function _sfc_render$a(_ctx, _cache, $props, $setup, $data, $options) {
const _component_uni_transition = resolveEasycom(resolveDynamicComponent("uni-transition"), __easycom_1$2);
return $data.showPopup ? (openBlock(), createElementBlock(
"view",
{
key: 0,
class: normalizeClass(["uni-popup", [$data.popupstyle, $options.isDesktop ? "fixforpc-z-index" : ""]]),
renderWhole: true
},
[
createElementVNode(
"view",
{
onTouchstart: _cache[1] || (_cache[1] = (...args) => $options.touchstart && $options.touchstart(...args))
},
[
$data.maskShow ? (openBlock(), createBlock(_component_uni_transition, {
key: "1",
name: "mask",
"mode-class": "fade",
styles: $data.maskClass,
duration: $data.duration,
show: $data.showTrans,
onClick: $options.onTap
}, null, 8, ["styles", "duration", "show", "onClick"])) : createCommentVNode("v-if", true),
createVNode(_component_uni_transition, {
key: "2",
"mode-class": $data.ani,
name: "content",
styles: $data.transClass,
duration: $data.duration,
show: $data.showTrans,
onClick: $options.onTap
}, {
default: withCtx(() => [
createElementVNode(
"view",
{
class: normalizeClass(["uni-popup__wrapper", [$data.popupstyle]]),
style: normalizeStyle($options.getStyles),
onClick: _cache[0] || (_cache[0] = (...args) => $options.clear && $options.clear(...args))
},
[
renderSlot(_ctx.$slots, "default")
],
6
/* CLASS, STYLE */
)
]),
_: 3
/* FORWARDED */
}, 8, ["mode-class", "styles", "duration", "show", "onClick"])
],
32
/* NEED_HYDRATION */
)
],
2
/* CLASS */
)) : createCommentVNode("v-if", true);
}
const __easycom_1$1 = /* @__PURE__ */ _export_sfc(_sfc_main$a, [["render", _sfc_render$a], ["styles", [_style_0$9]], ["__file", "D:/document/九亿商城/jy/jiuyi2/uni_modules/uni-popup/components/uni-popup/uni-popup.vue"]]);
const store = createStore({
state: {
// 用户信息
userinfo: {},
// tabbar当前的模式 default视频端 shop商城端
tabbarMode: "default",
// 闹钟时间
alarmTime: "",
// 资产
purse: {
balance: 0,
fruit: 0,
score: 0,
seed: 0
},
// 任务
task: {
//任务类型 0.任务读秒 1.流量点(种子)读秒
taskType: 0,
//有效时长
viewingDuration: 0
}
},
mutations: {
// 获取内容
setState(state, option) {
const key = option.key;
const value = option.value;
state[key] = value;
},
// 设置用户信息
setUserInfo(state, value) {
state.userinfo = value;
},
// 设置 tabbar 模式
setTabbarMode(state, mode) {
state.tabbarMode = mode;
}
},
getters: {
getUserInfo(state) {
return state.userinfo;
},
getTabbarMode(state) {
return state.tabbarMode;
}
},
actions: {
updateUserInfo({
commit
}, payload) {
commit("setUserInfo", payload);
},
changeTabbarMode({
commit
}, mode) {
commit("setTabbarMode", mode);
}
}
});
const config = {
// 接口域名
host: "http://5310d716.r22.cpolar.top",
// host: 'http://192.168.1.236:8080',
// 上传文件二级路径
uploadFilePath: "/homecommon/file/preview?fileName=",
// 上传视频二级路径
uploadVideoPath: "/homecommon/file/play?fileName=",
// 图片大小 单位m
img_size: 5,
// 视频限制大小 单位m
video_size: 300,
// h5路径
h5: "",
// 腾讯im聊天
TChat: {
// appid
SDKAppID: "1600057470",
// 验签
secretKey: "7d016821bf27a846739e209534abe4c4bba131559b3318e19f8ccf9294e08b29",
//
userSig: ""
}
};
const login = {
/**
* 用户注册
* @param {Object} param
*/
userRegister(param) {
return util$1.request({
url: `/user/register`,
data: param.data,
load: true
});
},
/**
* 获取验证码
* @param {Object} param
*/
getCaptcha(param) {
return util$1.request({
url: "/user/sendVerifyCode",
query: param.query,
method: "GET"
});
},
/**
* 用户密码登录接口
* @param {Object} param
*/
userLoginByPassword(param) {
return util$1.request({
url: "/user/login",
data: param.data,
load: true
});
},
/**
* 修改用户密码
* @param {Object} param
*/
resetPassword(param) {
return util$1.request({
url: "/user/login/resetPassword",
data: param.data,
path: param.path,
method: "POST"
});
},
/**
* 获取IMtoken
* @param {Object} param
*/
getIMToken(param) {
return util$1.request({
url: "/user/chat/getUserSig",
query: param.query,
method: "GET"
});
}
};
const mine = {
/**
* 获取用户信息
* @param {Object} param
*/
getUserinfo(param) {
return util$1.request({
url: `/user/getUserData`,
method: "GET"
});
},
/**
* 修改用户信息
* @param {Object} param
*/
updateUserInfo(param) {
return util$1.request({
url: `/user/updateUserData`,
data: param.data,
method: "PUT",
load: 1
});
},
/**
* 获取我的评论
* @param {Object} param
*/
myComment(param) {
return util$1.request({
url: `/user/home/myComment`,
query: param.query,
method: "POST"
});
},
// 实名认证
certification(param) {
return util$1.request({
url: `/user/info/certification`,
data: param.data,
method: "POST",
load: true
});
},
/**
* 查询我的钱包接口
* @param {Object} param
*/
selectPurse(param) {
return util$1.request({
url: "/user/selectPurse",
method: "GET"
});
},
/**
* 获取待释放列表
* @param {Object} param
*/
releasedList(param) {
return util$1.request({
url: "/user/released/list",
query: param.query,
method: "GET"
});
},
/**
* 根据用户账号查询用户id
* @param {Object} param
*/
getUserDataByAccount(param) {
return util$1.request({
url: "/coreplay/app/durian/getUserDataByAccount",
query: param.query,
method: "GET"
});
},
/**
* 设置二级密码
* @param {Object} param
*/
setSecondLevelCipher(param) {
return util$1.request({
url: "/user/user/setSecondLevelCipher",
data: param.data,
method: "POST"
});
},
/**
* 验证二级密码
* @param {Object} param
*/
checkSecondLevelCipher(param) {
return util$1.request({
url: "/user/user/checkSecondLevelCipher",
data: param.data,
method: "POST"
});
}
};
const video = {
/**
* 申请完播量
* @param {Object} param
*/
applyVideo(param) {
return util$1.request({
url: `/homecommon/applyVideo`,
query: param.query,
data: param.data,
method: "POST",
load: true
});
},
/**
* 展播量推送
* @param {Object} param
*/
pushVideo(param) {
return util$1.request({
url: `/homecommon/pushVideo`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 他人用户主页
* @param {Object} param
*/
getUserInfo(param) {
return util$1.request({
url: `/home/getUserInfo`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 用户视频列表
* @param {Object} param
*/
myVideoList(param) {
return util$1.request({
url: `/home/myVideoList`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 我的收藏列表
* @param {Object} param
*/
getCollectList(param) {
return util$1.request({
url: `/collect/getCollectList`,
query: param.query,
method: "POST"
});
},
/**
* 新建收藏夹
* @param {Object} param
*/
saveCollectList(param) {
return util$1.request({
url: `/collect/saveCollectList`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 编辑收藏夹
* @param {Object} param
*/
updateCollectList(param) {
return util$1.request({
url: `/collect/updateCollectList`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 删除收藏夹
* @param {Object} param
*/
deleteCollect(param) {
return util$1.request({
url: `/collect/deleteCollect`,
query: param.query,
load: true,
method: "POST"
});
},
/**
* 我的收藏视频列表
* @param {Object} param
*/
getCollectVideoList(param) {
return util$1.request({
url: `/collect/getCollectVideoList`,
query: param.query,
load: true,
method: "POST"
});
},
/**
* 收藏视频
* @param {Object} param
*/
collectVideo(param) {
return util$1.request({
url: `/collect/collectVideo`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 取消收藏
* @param {Object} param
*/
cancelCollect(param) {
return util$1.request({
url: `/collect/cancelCollect`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 首页视频分页接口
* @param {Object} param
*/
homeVideo(param) {
return util$1.request({
url: `/video/video/list`,
query: param.query,
method: "GET"
});
},
/**
* 我的关注视频列表
* @param {Object} param
*/
followVideo(param) {
return util$1.request({
url: `/homecommon/followVideo`,
query: param.query,
method: "POST"
});
},
/**
* 查看标签分类
* @param {Object} param
*/
getLabel(param) {
return util$1.request({
url: `/video/tag/list`,
query: param.query,
method: "GET",
load: true
});
},
/**
* 新增或编辑标签
* @param {Object} param
*/
setLabel(param) {
return util$1.request({
url: `/video/tag/add`,
query: param.query,
method: "POST",
load: true
});
},
/**
* 发布作品
* @param {Object} param
*/
publishVideo(param) {
return util$1.request({
url: `/video/video/add`,
data: param.data,
method: "POST"
});
},
/**
* 修改视频信息接口
* @param {Object} param
*/
updateVideo(param) {
return util$1.request({
url: `/homecommon/updateVideo`,
data: param.data,
method: "POST"
});
},
/**
* 视频评论列表
* @param {Object} param
*/
commentList(param) {
return util$1.request({
url: `/home/commentList`,
query: param.query,
method: "POST"
});
},
/**
* 下级评论列表
* @param {Object} param
*/
levelCommentList(param) {
return util$1.request({
url: `/home/levelCommentList`,
query: param.query,
method: "POST"
});
},
/**
* 点赞/取消点赞接口 0取消 1点赞
* @param {Object} param
*/
thumbsUp(param) {
return util$1.request({
url: `/home/thumbsUp`,
query: param.query,
method: "POST"
});
},
/**
* 发表评论
* @param {Object} param
*/
comment(param) {
return util$1.request({
url: `/home/comment`,
query: param.query,
method: "POST"
});
},
/**
* 视频 点赞取消赞
* @param {Object} param
*/
videoLike(param) {
return util$1.request({
url: `/home/videoLike`,
query: param.query,
method: "POST"
});
},
/**
* 观看视频记录接口
* @param {Object} param
*/
browseLog(param) {
return util$1.request({
url: `/video/Effective/second`,
data: param.data,
method: "POST"
});
},
/**
* 热点视频
* @param {Object} param
*/
hotVideos(param) {
return util$1.request({
url: `/home/hotVideos`,
// query: param.query,
method: "POST"
});
},
/**
* 视频搜索记录
* @param {Object} param
*/
videoSearchLog(param) {
return util$1.request({
url: `/home/videoSearchLog`,
// query: param.query,
method: "POST"
});
},
/**
* 视频模糊搜索
* @param {Object} param
*/
videoSearch(param) {
return util$1.request({
url: `/home/videoSearch`,
query: param.query,
method: "POST"
});
},
/**
* 同意好友申请
* @param {Object} param
*/
agreeFriend(param) {
return util$1.request({
url: `/user/friend/agreeFriend`,
path: param.path,
query: param.query,
method: "POST"
});
},
/**
* 拒绝好友申请
* @param {Object} param
*/
refuseFriend(param) {
return util$1.request({
url: `/user/friend/refuseFriend`,
path: param.path,
query: param.query,
method: "POST"
});
},
/**
* 好友列表
* @param {Object} param
*/
getFriendList(param) {
return util$1.request({
url: `/user/friend/getFriendList`,
path: param.path,
query: param.query,
method: "GET"
});
},
/**
* 关注列表
* @param {Object} param
*/
getFansList(param) {
return util$1.request({
url: `/user/attention/getFansList`,
path: param.path,
query: param.query,
method: "GET"
});
},
/**
* 关注列表
* @param {Object} param
*/
getAttentionList(param) {
return util$1.request({
url: `/user/attention/getAttentionList`,
path: param.path,
query: param.query,
method: "GET"
});
},
/**
* 关注用户 关注状态 0:取关 1:关注
* @param {Object} param
*/
attention(param) {
return util$1.request({
url: `/user/attention`,
path: param.path,
data: param.data,
method: "POST"
});
},
/**
* 视频观看权限 (不看他) 0拉黑 1放出
* @param {Object} param
*/
videoBlock(param) {
return util$1.request({
url: `/home/videoBlock`,
query: param.query,
load: true,
method: "POST"
});
},
/**
* 举报视频
* @param {Object} param
*/
reportVideo(param) {
return util$1.request({
url: `/report/reportVideo`,
data: param.data,
method: "POST"
});
},
/**
* 我的喜欢视频列表 分页
* @param {Object} param
*/
myLikeVideoList(param) {
return util$1.request({
url: `/home/myLikeVideoList`,
query: param.query,
method: "POST"
});
},
/**
* 视频详情
* @param {Object} param
*/
getVideoById(param) {
return util$1.request({
url: `/homecommon/getVideoById`,
query: param.query,
method: "POST"
});
},
/**
* 视频分享
* @param {Object} param
*/
videoShare(param) {
return util$1.request({
url: `/home/videoShare`,
query: param.query,
method: "POST"
});
},
/**
* 设置闹铃
* @param {Object} param
*/
setAlarm(param) {
return util$1.request({
url: `/home/setAlarm`,
query: param.query,
method: "POST"
});
},
/**
* 查看自己的闹铃
*/
getAlarm() {
return util$1.request({
url: `/home/getAlarm`,
method: "POST"
});
},
/**
* 查看我的今日观看任务
*/
viewingTasks() {
return util$1.request({
url: `/home/viewingTasks`,
method: "POST"
});
}
};
const news = {
/**
* 获取腾讯云用户签名
* @param {Object} param
*/
getUserSig(param) {
return util$1.request({
url: `/user/chat/getUserSig`,
method: "GET",
query: param.query
});
},
/**
* 设置好友备注
* @param {Object} param
*/
setNotes(param) {
return util$1.request({
url: `/user/friend/setNotes`,
method: "POST",
query: param.query
});
},
/**
* 删除好友
* @param {Object} param
*/
deleteFriend(param) {
return util$1.request({
url: `/user/friend/deleteFriend`,
method: "POST",
path: param.path
});
},
/**
* 添加好友
* @param {Object} param
*/
addFriend(param) {
return util$1.request({
url: `/user/friend/addFriend`,
method: "POST",
path: param.path
});
},
/**
* 好友申请列表-分页
* @param {Object} param
*/
getFriendListPage(param) {
return util$1.request({
url: `/user/friend/getFriendListPage`,
path: param.path,
query: param.query,
method: "GET"
});
},
/**
* 根据用户名模糊搜索好友-分页
* @param {Object} param
*/
searchFriendByName(param) {
return util$1.request({
url: `/user/friend/searchFriendByName`,
path: param.path,
query: param.query,
method: "GET"
});
},
/**
* 商品列表
* @param {Object} param
*/
getImToken(param) {
return util$1.request({
url: `/im/token/getUserAppToken`,
method: "get",
query: param
});
},
/**
* 商品列表
* @param {Object} param
*/
sendRedBag(param) {
return util$1.request({
url: `/home/sendRedBag`,
method: "POST",
data: param.data
});
},
// 抢红包
grabred(param) {
return util$1.request({
url: `/home/grabred`,
method: "POST",
data: param.data
});
},
// 红包详情
getRedbag(param) {
return util$1.request({
url: `/home/getRedbag`,
method: "POST",
query: param.data
});
},
grabredLog(param) {
return util$1.request({
url: `/home/grabredLog`,
method: "POST",
query: param
});
}
};
const team = {
/**
* 我的团队
* @param {Object} param
*/
myTeam(param = {}) {
return util$1.request({
url: `/user/team/get`,
query: param,
method: "GET"
});
},
lowTeam(param) {
return util$1.request({
url: `/home/lowTeam`,
method: "post",
query: param.query
});
}
};
const intergral = {
/**
* 卷轴列表
* @param {Object} param
*/
scrollList(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/scroll-list`,
method: "GET",
query: param.query,
load: true
});
},
/**
* 我购买的卷轴列表
* @param {Object} param
*/
buyScrollList(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/boughtListByUser`,
method: "GET",
load: true
});
},
/**
* 查看卷轴(按id)
* @param {Object} param
*/
scrollinfo(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo`,
method: "GET",
path: param.path,
load: true
});
},
/**
* 按用户id按日期查卷轴积分明细
* @param {Object} param
*/
getDetailInfoByDate(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/getDetailInfoByDate`,
method: "GET",
query: param.query
});
},
/**
* 按卷轴id查卷轴积分明细
* @param {Object} param
*/
getDetailInfoByScrollId(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/getDetailInfoByScrollId`,
method: "GET",
path: param.path,
query: param.query
});
},
/**
* 按用户id查卷轴积分明细
* @param {Object} param
*/
getDetailInfoByUserId(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/getDetailInfoByUserId`,
method: "GET",
query: param.query
});
},
/**
* 今日任务读秒记录
* @param {Object} param
*/
viewingTasks(param) {
return util$1.request({
url: `/video/Effective/return`,
method: "GET",
query: param.query
});
},
/**
* 购买卷轴
* @param {Object} param
*/
buyScroll(param) {
return util$1.request({
url: `/coreplay/app/scrollinfo/buyScroll`,
method: "POST",
data: param.data
});
}
};
const durian = {
/**
* 果树列表
* @param {Object} param
*/
durianList(param) {
return util$1.request({
url: `/coreplay/duriantreeinfo/tree-list`,
method: "GET",
query: param.query
});
},
/**
* 我的榴莲果树
* @param {Object} param
*/
buyDurianList(param) {
return util$1.request({
url: `/coreplay/duriantreeinfo/boughtListByUser`,
method: "GET",
query: param.query
});
},
/**
* 榴莲果置换
* @param {Object} param
*/
exchange(param) {
return util$1.request({
url: `/coreplay/duriantreeinfo/exchange`,
method: "POST",
data: param.data,
load: true
});
},
/**
* 校验姓名
* @param {Object} param
*/
nameComparison(param) {
return util$1.request({
url: `/coreplay/app/durian/nameComparison`,
method: "GET",
query: param.query,
load: true
});
},
/**
* 交易榴莲果
* @param {Object} param
*/
consume(param) {
return util$1.request({
url: `/coreplay/app/durian/consume`,
method: "POST",
data: param.data,
load: true
});
}
};
const shop = {
/**
* 商品列表
* @param {Object} param
*/
getProduct(param) {
return util$1.request({
url: `/appProductionApi/getProductionList`,
method: "GET",
data: param.data
});
},
/**
* 商品列表
* @param {Object} param
*/
getCategory(param) {
return util$1.request({
url: `/appProductionApi/getProductCategory`,
method: "GET",
query: param.query
});
},
/**
* 根据商品主键获取商品详情
* @param {Object} param
*/
productDetail(param) {
return util$1.request({
url: `/appProductionApi/getProductionDetail`,
method: "GET",
query: param.query
});
}
};
const api = {
// 登录
login,
// 我的
mine,
// 视频模块
video,
// 消息
news,
// 我的团队
team,
// 积分
intergral,
// 榴莲果
durian,
// 商城模块
shop,
// 上传图片地址
uploadImg: "/homecommon/upload",
// 上传视频地址
uploadVideo: "/homecommon/uploadVideo",
// 公共模块可以放在这里 比如获取各种文章
/**
* 获取文章
* @param {Object} param
*/
getArticle(param) {
return util$1.request({
url: "/home/getArticle",
query: param.query,
method: "POST"
});
},
/**
* 获取各种配置
* @param {Object} param
*/
getConfig() {
return util$1.request({
url: "/coreplay/configinfo/getConf",
method: "GET"
});
}
};
const util = {
// 配置参数
config,
// 正则
reg: {
// 手机号
tel: /^1[3-9]\d{9}$/,
// 身份证
idCard: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
},
/**
* 弹窗
* @param {Object|String} obj String类型只是弹出文字 object如下
* @param {String} obj.title 弹窗的标题
* @param {String} obj.content 弹窗的内容
* @param {String} obj.confirmText 确定的文本
* @param {String} obj.showCancel 是否显示取消
* @param {String} obj.cancelText 取消的文本
* @param {Function} params.success 请求成功回调 可通过promise.then捕获
* @param {Function} params.fail 请求失败回调 可通过promise.catch捕获
* @param {Function} params.complete 请求结束回调 无论是否成功失败都会执行
* @return {Object} string返回null object返回返回promis对象 执行成功返回resolve 执行失败返回reject
*/
alert(obj) {
if (obj == null || obj == void 0)
return;
if (typeof obj == "string" || typeof obj == "number") {
uni.showToast({
"title": "" + obj,
"icon": "none",
duration: 3e3
});
return null;
}
obj.title = obj.title ? obj.title : "";
obj.content = obj.content ? obj.content : "";
obj.confirmText = obj.confirmText ? obj.confirmText : "确定";
obj.showCancel = obj.showCancel === false ? false : true;
obj.cancelText = obj.cancelText ? obj.cancelText : "取消";
return new Promise((resolve, reject) => {
uni.showModal({
title: obj.title,
content: obj.content,
confirmText: obj.confirmText,
showCancel: obj.showCancel,
cancelText: obj.cancelText,
success: (res) => {
obj.success ? obj.success(res) : () => {
};
resolve(res);
},
fail: (err) => {
obj.fail ? obj.fail(err) : () => {
};
reject(err);
},
complete: (res) => {
}
});
});
},
/**
* 上传文件
* @param {Object} obj
* @param {String} obj.mode img图片 video视频
*/
upload(obj) {
return new Promise((resolve, reject) => {
let token = uni.getStorageSync("token") || "";
obj.url = obj.url ? obj.url : "/file/upload";
obj.file = obj.file ? obj.file : "";
obj.data = obj.data ? obj.data : {};
obj.header = {
// 'Content-Type': 'multipart/form-data; ',
// 'Content-Type': 'application/json;charset=UTF-8',
"Access-Control-Allow-Origin": "*",
...obj.header
};
if (token)
obj.header["Authorization"] = `Bearer ${token}`;
uni.showLoading({
title: "正在上传"
});
uni.uploadFile({
url: util.config.host + obj.url,
filePath: obj.file,
header: obj.header,
formData: obj.data,
dataType: "json",
name: "file",
success: (res) => {
uni.hideLoading();
obj.success ? obj.success(JSON.parse(res.data)) : "";
resolve(JSON.parse(res.data));
},
fail: (res) => {
uni.hideLoading();
obj.fail ? obj.fail(res.data) : "";
reject(res);
}
});
});
},
/**
* 发送网络请求
* @param {Object} params 传参
* @param {String} params.url 请求地址 一般用于后台请求接口
* @param {Array} params.query 请求地址拼接参数 用于后台请求地址拼接补全
* @param {String} params.fullurl 全请求地址 一般用于第三方请求地址
* @param {Boolean} params.load 是否显示加载动画 默认不显示
* @param {Object} params.data 请求入参 没有则不传
* @param {Object} params.header 请求头 默认不传
* @param {String} params.method 请求方式 默认值POST
* @param {Function} params.success 请求成功回调 可通过promise.then捕获
* @param {Function} params.fail 请求失败回调 可通过promise.catch捕获
* @param {Function} params.complete 请求结束回调 无论是否成功失败都会执行
* @return {Object} 返回promis对象 执行成功返回resolve 执行失败返回reject
*/
request(params2) {
let token = uni.getStorageSync("token") || "";
return new Promise((resolve, reject) => {
let url = util.config.host + (params2.url ? params2.url : "/api/index/index");
if (params2.path && params2.path instanceof Array)
params2.path.forEach((item) => {
url += `/${item}`;
});
if (params2.query) {
url = util.setUrl(url, params2.query);
}
if (params2.load) {
uni.showLoading({
title: "加载中",
mask: true
});
}
params2.header = {
"Content-Type": "application/json;charset=UTF-8",
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept",
// token: uni.getStorageSync('token'),
"Access-Control-Allow-Origin": "*",
"IS_APP_REQ": "APP_REQ",
...params2.header
};
if (token)
params2.header["Authorization"] = `Bearer ${token}`;
uni.request({
// 请求地址
url,
// 请求方式 get/post
method: params2.method ? params2.method : "POST",
// 是否开启SSL验证
sslVerify: false,
// 请求参数
data: params2.data,
// header请求头
header: params2.header,
// 数据类型
dataType: "json",
responseType: params2.responseType || "text",
// 请求成功返回
success: (res) => {
if (params2.load) {
uni.hideLoading();
}
if (res.data.code == 401) {
util.logout(() => {
util.alert("请先登录");
reject(res.data);
});
}
params2.success ? params2.success(res.data) : "";
resolve(res.data);
},
// 请求失败返回
fail: (res) => {
if (params2.load) {
uni.hideLoading();
}
params2.fail ? params2.fail(res) : "";
reject(res);
},
complete(res) {
params2.complete ? params2.complete(res) : "";
}
});
});
},
// 替换图片的宽度为最大宽度100% (移动端解析html富文本专用)
imgReplace(value, th) {
if (!th) {
value = value.replace(//ig, '
').replace(/ {
let [key, val] = item.split("=");
obj[key] = val;
});
return obj;
},
/**
* 倒计时
* @param {String} endtime 结束时间
*/
countDownd(endtime) {
if (!endtime) {
return;
}
endtime = Number(endtime);
let day = util.timeFormin(parseInt(time / (60 * 60 * 24)));
let hou = util.timeFormin(parseInt(time % (60 * 60 * 24) / 3600));
let min = util.timeFormin(parseInt(time % (60 * 60 * 24) % 3600 / 60));
let sec = util.timeFormin(parseInt(time % (60 * 60 * 24) % 3600 % 60));
let str = "";
if (day) {
str += day + "天";
}
if (hou || hou == 0) {
if (hou > 9) {
str += hou + ":";
} else {
str += "0" + hou + ":";
}
} else {
str += "00:";
}
if (min || min == 0) {
if (min > 9) {
str += min + ":";
} else {
str += "0" + min + ":";
}
} else {
str += "00:";
}
if (sec) {
if (sec > 9) {
str += sec;
} else {
str += "0" + sec;
}
} else {
str += "00";
}
return str;
},
// 格式化时间
timeFormin(param) {
return param < 0 ? 0 : param;
},
/**
* 对二补齐
* @param {String} str 数字或数字字符串
*/
toTwo(str) {
let num = String(Number(str));
if (num.length < 2) {
num = "0" + num;
}
return num;
},
/**
* 时间戳处理成时间
* @param {Object} str
* 时间格式 月、日、时、分、秒 单个字母不补0
* yyyy 年
* MM 月
* dd 日
* WW 周
* HH 小时 24小时制
* hh 小时 12小时制
* mm 分钟
* ss 秒
* a am/pm
* 比如 'yyyy-MM-dd HH:mm:ss 周w a' 返回2023-02-06 11:19:19 周一 pm
* @param {Number} timestamp 需要处理时间戳
*/
formatTime(str, timestamp) {
const nowDate = /* @__PURE__ */ new Date();
let weekList = ["日", "一", "二", "三", "四", "五", "六"];
if (!str || typeof str != "string") {
str = "yyyy-MM-dd HH:mm:ss";
}
if (!timestamp) {
timestamp = nowDate.valueOf();
} else if (String(timestamp).length <= 10) {
timestamp = timestamp * 1e3;
}
const date = new Date(timestamp);
let year = date.getFullYear(), moth = date.getMonth() + 1, day = date.getDate(), week = date.getDay(), hour = date.getHours(), minute = date.getMinutes(), second = date.getSeconds();
str = str.replace("yyyy", year);
str = str.replace("MM", this.toTwo(moth));
str = str.replace("M", moth);
str = str.replace("dd", this.toTwo(day));
str = str.replace("d", day);
str = str.replace("w", weekList[week]);
if (str.match("h")) {
hour = hour > 12 ? hour - 12 : hour;
str = str.replace("hh", this.toTwo(hour));
str = str.replace("h", hour);
} else if (str.match("H")) {
str = str.replace("HH", this.toTwo(hour));
str = str.replace("H", hour);
}
str = str.replace("mm", this.toTwo(minute));
str = str.replace("m", minute);
str = str.replace("ss", this.toTwo(second));
str = str.replace("s", second);
let a = hour > 12 ? "am" : "pm";
str = str.replace("a", a);
return str;
},
/**
* 时间计算
* @param {String} format 格式化 规则
* format '+1 month' 往后一个月
* @param {Number} value 需要处理的时间戳 单位秒
*/
strtotime(format, value) {
if (value && format.indexOf(" ") > -1) {
let unit = format.split(" ");
let pre = unit[0];
let next = unit[1];
if (!value)
value = nowDate2.valueOf();
else if (String(value).length <= 10)
value = value * 1e3;
let nowDate2 = new Date(value);
switch (next) {
case "year":
nowDate2.setYear(nowDate2.getFullYear() + parseInt(pre));
break;
case "month":
nowDate2.setMonth(nowDate2.getMonth() + parseInt(pre));
break;
case "day":
nowDate2.setDate(nowDate2.getDate() + parseInt(pre));
break;
case "week":
nowDate2.setDate(nowDate2.getDate() + parseInt(pre) * 7);
break;
case "hour":
nowDate2.setHours(nowDate2.getHours() + parseInt(pre));
break;
case "minute":
nowDate2.setMinutes(nowDate2.getMinutes() + parseInt(pre));
break;
}
return nowDate2.getTime();
} else {
var nowDate = new Date(value);
return nowDate.getTime();
}
},
/**
* 上传图片
* @param {Object} obj 对象类型
* @param {Array} obj.value 操作的对象
* @param {Boolean} obj.unlimited 不限制
* @param {Number} obj.count 图片计数
* @param {Number} obj.type 1单张 2多张
* @param {Array} obj.sourceType ['album', 'camera']
* @param {Function} obj.success 执行成功返回的方法return修改的对象
*/
upload_image(obj) {
const count = obj.count ? obj.count : 8;
if (!obj.type)
obj.type = 2;
if (obj.value != "" && obj.value == void 0 && obj.value == null)
obj.value = obj.type == 1 ? "" : [];
if (obj.value.length >= count && obj.type == 2) {
util.alert("上传图片已达上限");
return;
}
let sourceType = ["album", "camera"];
uni.chooseImage({
// 限制图片
count: obj.type == 1 ? 1 : count - obj.value.length,
sourceType: obj.sourceType || sourceType,
success: (rs) => {
rs.tempFiles.forEach((item) => {
let size = 1024 * 1024 * util.config.img_size;
if (item.size > size && !obj.unlimited) {
util.alert(`大小超过${util.config.img_size}m`);
return;
}
util.upload({
file: item.path,
mode: "img",
success(res) {
if (res.code === 200) {
const result = res.data.url;
if (obj.type == 2) {
obj.value.push(result);
} else if (obj.type == 1) {
obj.value = result;
}
obj.success && obj.success({
value: result
});
return;
}
util.alert(rs.msg);
}
});
});
},
fail(rs) {
if (rs.errMsg == "chooseImage:fail cancel")
;
}
});
},
/**
* 上传视频
* @param {Object} obj 对象类型
* @param {Array} obj.value 操作的对象
* @param {Object} obj.unlimited 不限制
* @param {Object} obj.count 计数
* @param {Object} obj.success 执行成功返回的方法return修改的对象
*/
upload_video(obj) {
obj.count ? obj.count : 1;
uni.chooseVideo({
compressed: false,
success(rs) {
util.upload({
file: rs.tempFilePath,
mode: "video",
success(res) {
if (res.code == 200) {
obj.success && obj.success({
value: res.data.url,
width: rs.width,
height: rs.height,
size: rs.size,
duration: rs.duration
// value: fullUrl,
});
return;
} else {
util.alert(res.msg);
}
}
});
},
fail(rs) {
if (rs.errMsg == "chooseImage:fail cancel")
;
}
});
},
/**
* 上传文件
* @param {Object} obj 对象类型
* @param {Array} obj.value 操作的对象
* @param {Object} obj.count 计数
* @param {Object} obj.success 执行成功返回的方法return修改的对象
*/
upload_files(obj) {
const value = obj.value;
const file_suffix = util.config.file_suffix;
const count = obj.count ? obj.count : 1;
if (value.length >= count) {
util.alert("上传数量已达上限");
return;
}
formatAppLog("log", "at common/js/util.js:719", "upload_files", obj);
function result_fn(path) {
let str = path.split(".").pop().toLowerCase();
let reult = file_suffix.find((node) => node.id == str);
if (!reult) {
util.alert(`不能上传${str}格式文件`);
return;
}
util.upload({
file: path,
success(res) {
if (res.code == 200) {
value.push(res.data);
obj.success && obj.success({
...res.data,
value
});
} else {
util.alert(res.msg);
}
}
});
}
if (uni.getSystemInfoSync().platform == "android") {
formatAppLog("log", "at common/js/util.js:771", "chooseFile");
chooseFile((rs) => {
formatAppLog("log", "at common/js/util.js:773", "rs", rs);
result_fn(rs);
});
} else {
util.alert("因权限问题,暂不支持非android平台");
}
return;
},
/**
* 上传音频
* @param {Object} obj 对象类型
* @param {Array} obj.value 操作的对象
* @param {Object} obj.count 计数
* @param {Object} obj.success 执行成功返回的方法return修改的对象
*/
upload_audio(obj) {
const value = obj.value;
const audio_suffix = util.config.audio_suffix;
const count = obj.count ? obj.count : 1;
if (value.length >= count) {
util.alert("上传数量已达上限");
return;
}
function result_fn(path) {
let str = path.split(".").pop().toLowerCase();
let reult = audio_suffix.find((node) => node.id == str);
if (!reult) {
util.alert(`不能上传${str}格式文件`);
return;
}
util.upload({
file: path,
success(res) {
if (res.code == 200) {
value.push(res.data);
obj.success && obj.success({
...res.data,
value
});
} else {
util.alert(res.msg);
}
}
});
}
if (uni.getSystemInfoSync().platform == "android") {
chooseFile((rs) => {
formatAppLog("log", "at common/js/util.js:856", "chooseFile", rs);
result_fn(rs);
});
} else {
util.alert("因权限问题,暂不支持非android平台");
}
return;
},
/**
* 视频转封面 oss特有
* @param {Object} url 视频路径
*/
video_coverImage(url) {
let result = `${url}?x-oss-process=video/snapshot,t_1,m_fast`;
return result;
},
/**
* 预览图片
* @param {Array} urls 图片列表
* @param {Number} current 当前预览的下标
*/
view_imgs(urls, current) {
if (!urls || urls.length == 0) {
util.alert("暂无");
return;
}
uni.previewImage({
urls,
current
});
},
/**
* 预览文件
* @param {String} url 文件路径
*/
view_file(url) {
let suffix = util.get_file_suffix(url).id;
if (!["doc", "xls", "ppt", "pdf", "docx", "xlsx", "pptx"].includes(suffix)) {
util.alert("操作需要在web端");
formatAppLog("log", "at common/js/util.js:903", "Unsupported suffix", suffix);
return;
}
uni.downloadFile({
url,
success: (res) => {
uni.openDocument({
filePath: res.tempFilePath,
fail: (rs) => {
formatAppLog("log", "at common/js/util.js:912", "rs", rs);
}
});
}
});
},
/**
* 通过路径获取文件后缀
* @param {Object} url 需要获取的文件路径
* @param {Object} type file文件 audio音频
* @return {Object} 返回后缀列表对象 util.config.file_suffix
*/
get_file_suffix(url, type) {
if (!type)
type = "file";
const file_suffix = util.config[{
"file": "file_suffix",
"audio": "audio_suffix"
}[type]];
let result = "";
if (url)
result = file_suffix.find((item) => item.id === url.split(".").pop().toLowerCase());
return result;
},
/**
* 通过路径获取音频后缀
* @param {Object} url 需要获取的文件路径
* @return {Object} 返回后缀列表对象 util.config.file_suffix
*/
get_audio_suffix(url) {
const audio_suffix = util.config.audio_suffix;
let result = "";
if (url)
result = audio_suffix.find((item) => item.id === url.split(".").pop().toLowerCase());
return result;
},
/**
* 调起支付
* @param {Object} obj 操作对象
* @param {String} obj.payType 支付方式 WeChat微信 AliPay支付宝 4钱包
* @param {String} obj.method 支付环境 app手机应用 mp小程序
* @param {String} obj.debug 调试模式
* @param {Boolean|Object} obj.cb 支付结果跳转 false为不跳转 跳转需携带object定义对象
* @param {String} obj.cb.styles 风格 style1蓝色 style2绿色 style3橙色
* @param {String} obj.cb.result 结果 success成功 fail失败
* @param {String} obj.cb.price 价格
* @param {String} obj.cb.url 跳转的详情路径
* @param {Function} obj.fn 请求接口函数
* @param {Function} obj.success 成功方法
* @param {Function} obj.fail 失败方法
* @param {Function} obj.complete 结束方法
*/
payment(obj) {
obj = obj ? obj : {};
obj.data = obj.data ? obj.data : {};
obj.method = "app";
util.payment_request(obj);
},
// 支付请求
payment_request(obj) {
obj.debug ? formatAppLog("log", "at common/js/util.js:993", "params", obj) : "";
if (!obj.fn) {
throw "no function";
}
function result_goto(result) {
const cb = obj.cb;
if (!cb)
return;
uni.redirectTo({
url: util.setUrl("/index/pay_result", {
orderNumber: cb.orderNumbers || "",
result,
styles: cb.styles || "",
price: cb.price || "",
url: cb.url || ""
})
});
}
obj.fn(obj.data).then((rs) => {
obj.debug ? formatAppLog("log", "at common/js/util.js:1022", "request success result", rs) : "";
if (rs.code == 200) {
switch (obj.data.payType) {
case "1":
switch (obj.method) {
case "mp":
if (rs.data && rs.data.paySign) {
uni.requestPayment({
provider: "wxpay",
timeStamp: rs.data.timeStamp,
package: rs.data.package,
nonceStr: rs.data.nonceStr,
paySign: rs.data.paySign,
signType: rs.data.signType,
success(result) {
obj.success ? obj.success(rs) : "";
result_goto("success");
},
fail(result) {
obj.fail ? obj.fail(result) : "";
result_goto("fail");
},
complete(result) {
obj.debug ? formatAppLog(
"log",
"at common/js/util.js:1048",
"requestPayment complete",
result
) : "";
obj.complete ? obj.complete(result) : "";
}
});
} else {
obj.fail ? obj.fail("no data") : "";
}
break;
case "app":
uni.requestPayment({
provider: "wxpay",
orderInfo: rs.data,
success(result) {
obj.success ? obj.success(rs) : "";
result_goto("success");
},
fail(result) {
obj.fail ? obj.fail(result) : "";
result_goto("fail");
},
complete(result) {
obj.debug ? formatAppLog("log", "at common/js/util.js:1071", "requestPayment complete", result) : "";
obj.complete ? obj.complete(result) : "";
}
});
break;
}
break;
case "2":
switch (obj.method) {
case "app":
uni.requestPayment({
provider: "alipay",
orderInfo: rs.msg,
success(result) {
obj.success ? obj.success(rs) : "";
result_goto("success");
},
fail(result) {
obj.fail ? obj.fail(result) : "";
result_goto("fail");
},
complete(result) {
obj.debug ? formatAppLog("log", "at common/js/util.js:1096", "requestPayment complete", result) : "";
obj.complete ? obj.complete(result) : "";
}
});
break;
}
break;
case "4":
obj.success ? obj.success(rs) : "";
result_goto("success");
break;
}
} else {
util.alert(rs.msg);
obj.fail ? obj.fail(rs) : "";
}
}).catch((rs) => {
formatAppLog("log", "at common/js/util.js:1116", "request catch result", rs);
});
},
// 微信小程序登录
weChatLogin(obj) {
obj = obj ? obj : {};
const parent_id = uni.getStorageSync("parent_id");
const admin_id = uni.getStorageSync("admin_id");
uni.getUserProfile({
desc: "weixin",
success: (e) => {
const userInfo = e.userInfo;
let data = {
nickName: userInfo.nickName,
avatarUrl: userInfo.avatarUrl
};
uni.login({
provider: "weixin",
success: (rs) => {
data.code = rs.code;
data.platform = "wechatMini";
if (parent_id)
data.parent_id = parent_id;
if (admin_id)
data.admin_id = admin_id;
if (rs.errMsg == "login:ok") {
util.request({
url: "/api/user/third",
data,
load: 1
}).then((res) => {
if (res.code == 200) {
obj.success ? obj.success(res) : "";
}
});
}
}
});
},
fail(res) {
util.alert("您拒绝了授权");
obj.fail ? obj.fail(res) : (res2) => {
};
},
complete() {
obj.complete ? obj.complete() : "";
}
});
},
/**
* 拉起授权请求: 微信小程序、app
*/
authorize(obj) {
return new Promise((resolve, reject) => {
obj ? obj : obj = {};
let isAgreePrivacy = plus.runtime.isAgreePrivacy();
if (!isAgreePrivacy) {
resolve("未同意用户协议隐私政策");
return;
}
const menu = {
// 定位
location: {
name: "定位服务",
scope: "scope.userLocation",
txt: "需要获取您的地理位置"
},
// 相册
photosAlbum: {
name: "相册",
scope: "scope.writePhotosAlbum",
txt: "需要访问您的相册"
},
// 相机
camera: {
name: "摄像头",
scope: "scope.camera",
txt: "需要访问您的摄像头"
}
};
if (obj.key) {
obj = {
...obj,
...menu[obj.key]
};
}
let fnName = "";
fnName = "appAuthorize";
this[fnName](obj).then((rs) => {
obj.success ? obj.success(rs) : "";
resolve(rs);
}).catch((err) => {
obj.fail ? obj.fail(err) : "";
reject(err);
});
});
},
// app授权
appAuthorize(obj) {
return new Promise((resolve, reject) => {
const systemSetting = uni.getSystemSetting();
if (systemSetting.locationEnabled === false) {
this.alert(obj.txt);
reject({
msg: "未授权对应功能"
});
return;
}
const authorized = uni.getAppAuthorizeSetting().locationAuthorized;
formatAppLog("log", "at common/js/util.js:1278", "locationAuthorized", authorized);
if (authorized === "config error") {
reject({
msg: "开发者未勾选定位服务模块"
});
return;
} else if (authorized === "denied")
;
else if (authorized === "authorized") {
resolve(obj);
return;
}
if (uni.getSystemInfoSync().platform == "android") {
plus.android.requestPermissions(
// 对应权限
["android.permission.ACCESS_FINE_LOCATION"],
// 成功
(resultObj) => {
let result = null;
for (let i = 0; i < resultObj.granted.length; i++) {
let grantedPermission = resultObj.granted[i];
formatAppLog("log", "at common/js/util.js:1310", "已获取的权限:" + grantedPermission);
}
for (let i = 0; i < resultObj.deniedPresent.length; i++) {
let deniedPresentPermission = resultObj.deniedPresent[i];
formatAppLog("log", "at common/js/util.js:1317", "拒绝本次申请的权限:" + deniedPresentPermission);
}
for (let i = 0; i < resultObj.deniedAlways.length; i++) {
let deniedAlwaysPermission = resultObj.deniedAlways[i];
formatAppLog("log", "at common/js/util.js:1323", "永久拒绝申请的权限:" + deniedAlwaysPermission);
}
if ([-1].includes(result)) {
uni.openAppAuthorizeSetting({
success: (rs) => {
reject({
msg: "引导用户打开设置页面",
info: rs
});
},
fail: (err) => {
reject({
msg: "用户设置页面打开失败",
info: err
});
}
});
}
},
// 失败
(error) => {
formatAppLog("log", "at common/js/util.js:1353", "申请权限错误:" + error.code + " = " + error.message);
resolve({
code: error.code,
message: error.message
});
}
);
} else {
this.alert("请在设置里允许打开定位信息");
resolve({
msg: "用户未开启定位权限"
});
return;
}
});
},
// 微信小程序授权
weChatAuthorize(obj) {
return new Promise((resolve, reject) => {
if (![
"scope.userInfo",
"scope.userLocation",
"scope.userLocationBackground",
"scope.address",
"scope.record",
"scope.writePhotosAlbum",
"scope.camera",
"scope.invoice",
"scope.invoiceTitle",
"scope.werun"
].includes(obj.scope)) {
resolve({
msg: "不在限制范围内"
});
return;
}
uni.authorize({
scope: obj.scope,
success: (rs) => {
resolve(rs);
},
fail: (err) => {
reject(err);
util.alert({
title: "系统提示",
value: obj.txt,
success: (rs) => {
if (rs.confirm) {
uni.openSetting();
}
}
});
}
});
});
},
/**
* 最终登录 用于请求登录接口后统一调用的登录方法
* @param {Object} param 数据对象
* @param {Function} cb 回调函数
*/
finalLogin(param, cb) {
const token = param.data;
uni.setStorageSync("token", token);
uni.showLoading({
mask: true
});
util.getUserinfo((userinfo) => {
uni.$emit("login");
util.loginTencent(userinfo);
setTimeout(() => {
uni.switchTab({
url: "/pages/index/index"
});
}, 500);
cb ? cb() : "";
});
},
// 登录账号管理
loginAccountManagement(userInfo) {
let userList = uni.getStorageSync("userInfoList") || [];
const index = userList.findIndex((item) => item.userId === userInfo.userId);
if (index !== -1) {
userList.splice(index, 1);
}
userList.push(userInfo);
uni.setStorageSync("userInfoList", userList);
},
// 登录腾讯聊天
loginTencent(userinfo) {
api.login.getIMToken({}).then((rs) => {
const loginParams = {
SDKAppID: util.config.TChat.SDKAppID,
userID: userinfo.id + "",
userSig: rs.msg
};
uni.$TUICallKit.login(loginParams, (res) => {
if (res.code === 0) {
formatAppLog("log", "at common/js/util.js:1476", "[TUICallKit] login success.");
} else {
formatAppLog("error", "at common/js/util.js:1478", "[TUICallKit] login failed, failed message = ", res.msg, params);
}
});
uni.$chat.login({
userID: userinfo.id + "",
userSig: rs.msg
}).then((rs2) => {
formatAppLog("log", "at common/js/util.js:1487", "im login success", rs2);
});
});
return;
},
/**
* 获取用户信息
* @param {Function} cb 回调函数
*/
getUserinfo(cb) {
return new Promise((reslove) => {
api.mine.getUserinfo().then((rs) => {
if (rs.code === 200) {
const userinfo = rs.data;
reslove(userinfo);
store.commit("setState", {
key: "userinfo",
value: userinfo
});
uni.setStorageSync("userinfo", userinfo);
cb ? cb(userinfo) : "";
}
}).finally(() => {
uni.hideLoading();
});
});
},
/**
* 验证登录
* @param {Object} cb 回调函数
*/
isLogin(cb) {
let userinfo = uni.$store.state.userinfo;
return new Promise((resolve, reject) => {
if (!userinfo.id) {
reject();
return;
}
resolve();
cb ? cb() : "";
});
},
/**
* 清除登录状态
* @param {Function} cb 回调函数
*/
logout(cb) {
const userinfo = store.state.userinfo;
if (userinfo.userId) {
uni.$emit("logout");
uni.$chat.logout().then((rs) => {
formatAppLog("log", "at common/js/util.js:1562", "tim logout rs");
}).catch((rs) => {
formatAppLog("log", "at common/js/util.js:1564", "tim logout error:", rs);
});
}
store.commit("setState", {
key: "userinfo",
value: {}
});
uni.removeStorageSync("userinfo");
uni.removeStorageSync("token");
cb ? cb() : "";
},
// 是否实名
isAuth(param) {
util.isLogin(() => {
const userinfo = uni.$store.state.userinfo;
formatAppLog("log", "at common/js/util.js:1586", "userinfo.userIdCard", userinfo.userIdCard);
if (userinfo.userIdCard) {
param.success ? param.success(userinfo) : "";
return;
}
if (!param.noLink)
uni.navigateTo({
url: "/pages/mine/realname"
});
param.fail ? pararm.fail(userinfo) : "";
});
},
// 拨打电话
makePhone(phoneNumber) {
if (!phoneNumber) {
util.alert("暂无手机号");
}
uni.makePhoneCall({
phoneNumber,
fail(err) {
formatAppLog("log", "at common/js/util.js:1608", "err", err);
}
});
},
/**
* 处理路径添加host或这默认图片地址
* @param {String} ev 需要处理的字符串
* @param {String} mode img图片 video视频
* @return {String} 返回的路径
*/
format_url(ev, mode) {
if (!ev)
return "";
if (ev.match(/^http/))
return ev;
return "https://9yvideo.oss-cn-beijing.aliyuncs.com/" + ev;
},
/**
* 去除路径里的host
* @param {Object} ev 需要处理的字符串
* @return {String} 处理之后的路径
*/
replace_url(ev) {
if (!ev || typeof ev != "string")
throw `${ev} is not String`;
let result = ev.slice(ev.indexOf("/images") + 1);
return result;
},
/**
* 格式化经纬度
* @param {String} num 数字或数字字符串
*/
formart_lnglat(num) {
if (!num)
return num;
num = parseFloat(Number(num).toFixed(6));
return num;
},
/**
* 检查跳转
* @param {String} route 路径
* @param {String} type 跳转
*/
checkLink(route, type = "navigateTo") {
const currentPages = getCurrentPages();
const find_route = route;
const find_index = currentPages.findIndex((node) => {
return node.route == find_route;
});
if (find_index < 0) {
uni[type]({
url: `/${find_route}`
});
} else {
uni.navigateBack({
delta: currentPages.length - find_index - 1
});
}
},
/**
* 数字转化
*/
rp(n) {
var cnum = ["零", "一", "二", "三", "四", "五", "六", "七", "八", "九", "十"];
var s = "";
n = "" + n;
for (var i = 0; i < n.length; i++) {
s += cnum[parseInt(n.charAt(i))];
}
if (s.length == 2) {
if (s.charAt(1) == cnum[0]) {
s = s.charAt(0) + cnum[10];
if (s == cnum[1] + cnum[10]) {
s = cnum[10];
}
} else if (s.charAt(0) == cnum[1]) {
s = cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[2]) {
s = cnum[2] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[3]) {
s = cnum[3] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[4]) {
s = cnum[4] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[5]) {
s = cnum[5] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[6]) {
s = cnum[6] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[7]) {
s = cnum[7] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[8]) {
s = cnum[8] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[9]) {
s = cnum[9] + cnum[10] + s.charAt(1);
} else if (s.charAt(0) == cnum[10]) {
s = cnum[10] + cnum[10] + s.charAt(1);
}
}
return s;
},
/**
* 复制文本
* @param {String} text 需要复制的文本
*/
copyText(text) {
uni.setClipboardData({
data: text,
success: () => {
util.alert({
title: "文本已复制到剪贴板"
});
}
});
},
showToastAndRedirect(title, icon = "none", fun = () => {
}) {
uni.showToast({
title,
icon,
duration: 2e3,
// 显示两秒
complete: () => {
fun();
uni.hideLoading();
}
});
},
/**
* 去聊天
* @param {Object} option
* @param {Object} option.name 标题昵称
* @param {Object} option.msgId 聊天对象id
* @param {Object} option.type 聊天类型
*/
toChat(option) {
uni.navigateTo({
url: util.setUrl("/pages/news/chat/chat", {
name: option.name,
msgId: option.msgId,
type: option.type
})
});
},
// 扫码
scan() {
uni.scanCode({
success: (res) => {
if (res && res.result) {
let result = JSON.parse(res.result);
if (result.key == "user") {
uni.navigateTo({
url: util.setUrl("/pages/news/applyFriend", {
userId: result.userId,
nickname: result.userNickname
})
});
}
}
},
fail: (err) => {
util.alert("二维码扫描失败");
}
});
},
// 获取我的钱包
getPurse() {
api.mine.selectPurse().then((rs) => {
if (rs.code == 200) {
uni.$store.commit("setState", {
key: "purse",
value: rs.data
});
return;
}
util.alert({
content: rs.msg,
showCancel: false
});
});
},
// 获取我的任务
getMyTask() {
util.isLogin().then(() => {
api.intergral.viewingTasks({}).then((rs) => {
if (rs.code == 200) {
uni.$store.commit("setState", {
key: "task",
value: rs.data
});
return;
}
});
}).catch(() => {
uni.$store.commit("setState", {
key: "task",
value: {
//任务类型 0.任务读秒 1.流量点(种子)读秒
taskType: 0,
//有效时长
viewingDuration: 0
}
});
});
}
};
const util$1 = util;
const _style_0$8 = {};
const _sfc_main$9 = {
__name: "statusBar",
setup(__props, { expose: __expose }) {
__expose();
const height = ref(0);
onLoad(() => {
uni.getSystemInfo().then((rs) => {
height.value = rs.statusBarHeight + "px";
});
});
const __returned__ = { height, get onLoad() {
return onLoad;
}, ref };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render$9(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock(
"view",
{
style: normalizeStyle({ height: $setup.height }),
renderWhole: true
},
null,
4
/* STYLE */
);
}
const statusBar = /* @__PURE__ */ _export_sfc(_sfc_main$9, [["render", _sfc_render$9], ["styles", [_style_0$8]], ["__file", "D:/document/九亿商城/jy/jiuyi2/components/header/statusBar.vue"]]);
const _style_0$7 = { "timeBox": { "": { "position": "fixed", "left": 0, "right": 0, "bottom": "300rpx", "textAlign": "center", "zIndex": 9 } }, "time": { ".timeBox ": { "width": "450rpx", "paddingTop": 0, "paddingRight": "20rpx", "paddingBottom": 0, "paddingLeft": "20rpx", "backgroundColor": "rgba(0,0,0,0.6)", "borderRadius": "10rpx" } }, "text": { ".timeBox ": { "marginTop": "10rpx", "marginRight": "20rpx", "marginBottom": "10rpx", "marginLeft": "20rpx", "fontSize": "50rpx", "color": "#ffffff" } }, "durationBox": { "": { "paddingTop": "60rpx" } }, "duration": { ".durationBox ": { "width": "750rpx", "backgroundColor": "rgba(255,255,255,0.3)" } }, "line": { ".durationBox .duration ": { "width": 0, "height": "2rpx", "backgroundColor": "rgba(255,255,255,0.8)", "transitionDuration": 250 } }, "@TRANSITION": { "line": { "duration": 250 } } };
const _sfc_main$8 = {
__name: "videoProgress",
props: {
time: {
type: Object,
default: {
duration: 0,
currentTime: 0
}
},
// 组件宽度
viewWidth: {
type: Number
}
},
emits: ["change", "end"],
setup(__props, { expose: __expose, emit: __emit }) {
__expose();
const props = __props;
watch(props.time, (nV, oV) => {
formatAppLog("log", "at components/index/videoProgress.vue:29", "time", nV, oV);
}, {
deep: true
});
const emit = __emit;
const {
proxy
} = getCurrentInstance();
const trigger = ref(false);
const videoTime = ref(0);
const videoProgress2 = ref(0);
const videoCurrent = computed(() => {
let result = formatNum(props.time.currentTime);
if (trigger.value)
result = videoTime.value;
return result;
});
const progress = computed(() => {
let result = 0;
if (!trigger.value) {
const duration = formatNum(props.time.duration);
if (duration != 0)
result = formatNum(props.time.currentTime) / duration * props.viewWidth;
result = formatNum(result);
} else {
result = videoProgress2.value;
}
return result;
});
const formatDuration = computed(() => {
let result = formatNum(props.time.duration).toFixed(2);
return result;
});
function formatNum(num) {
let result = Number.parseFloat(num).toFixed(2);
return Number.parseFloat(result);
}
function onStart() {
trigger.value = true;
}
function onMove(ev) {
const time2 = formatNum(ev.changedTouches[0].screenX);
let target = formatNum(formatNum(time2 / props.viewWidth) * Number(formatDuration.value));
videoTime.value = target;
videoProgress2.value = time2;
}
function onEnd(ev) {
trigger.value = false;
emit("change", {
time: videoTime.value
});
}
const __returned__ = { props, emit, proxy, trigger, videoTime, videoProgress: videoProgress2, videoCurrent, progress, formatDuration, formatNum, onStart, onMove, onEnd, ref, computed, onMounted, getCurrentInstance, watch };
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
return __returned__;
}
};
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock(
Fragment,
null,
[
$setup.trigger ? (openBlock(), createElementBlock("view", {
key: 0,
class: "timeBox fdr jcc"
}, [
createElementVNode("view", { class: "time fdr jcc" }, [
createElementVNode(
"u-text",
{ class: "text f1" },
toDisplayString($setup.videoCurrent),
1
/* TEXT */
),
createElementVNode("u-text", { class: "text" }, "/"),
createElementVNode(
"u-text",
{ class: "text f1" },
toDisplayString($setup.formatDuration),
1
/* TEXT */
)
])
])) : createCommentVNode("v-if", true),
createElementVNode(
"view",
{
class: "durationBox",
ref: "durationBoxRef",
onTouchstart: withModifiers($setup.onStart, ["stop"]),
onTouchmove: withModifiers($setup.onMove, ["stop"]),
onTouchcancel: $setup.onEnd,
onTouchend: withModifiers($setup.onEnd, ["stop"])
},
[
createCommentVNode('