优化返回页面

This commit is contained in:
pengxiaolong
2025-05-22 22:05:55 +08:00
parent 6ca66f45d4
commit c55be10783
59 changed files with 3428 additions and 44 deletions

View File

@@ -8012,7 +8012,7 @@ function isConsoleWritable() {
function initRuntimeSocketService() {
const hosts = "192.168.0.111,127.0.0.1";
const port = "8090";
const id = "mp-weixin_Z0m08P";
const id = "mp-weixin_Jf3Rfu";
const lazy = typeof swan !== "undefined";
let restoreError = lazy ? () => {
} : initOnError();

View File

@@ -0,0 +1,32 @@
"use strict";
const common_vendor = require("../common/vendor.js");
function VerifyLogin() {
return new Promise((resolve, reject) => {
common_vendor.index.getStorage({
key: "userinfo",
success: (res) => {
if (res.data) {
if (res.data.nickName) {
resolve(true);
} else {
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
resolve(false);
}
} else {
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.navigateTo({ url: "/pages/login/login" });
resolve(false);
}
},
fail: (err) => {
common_vendor.index.__f__("error", "at components/VerifyLogin.js:22", "获取用户信息失败", err);
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.navigateTo({ url: "/pages/login/login" });
reject(err);
}
});
});
}
exports.VerifyLogin = VerifyLogin;
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/VerifyLogin.js.map

View File

@@ -1,8 +1,10 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const components_request = require("../request.js");
const components_formatDate = require("../formatDate.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
inject: ["$global"],
data() {
return {
page: 0,
@@ -27,6 +29,7 @@ const _sfc_main = {
}
});
},
formatDate: components_formatDate.formatDate,
async pkList() {
const res = await components_request.request({
url: "pk/pkList",
@@ -38,10 +41,10 @@ const _sfc_main = {
},
userInfo: false
});
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:64", res);
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:66", res);
if (res.code === 200) {
this.list.push(...res.data);
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:67", this.list);
common_vendor.index.__f__("log", "at components/contentList/contentList.vue:69", this.list);
}
},
onScrollToLower() {
@@ -69,7 +72,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
f: common_vendor.t(item.sex === "1" ? "男" : "女"),
g: item.sex === "1" ? 1 : "",
h: item.sex === "2" ? 1 : "",
i: common_vendor.t(_ctx.formatDate(item.pkTime)),
i: common_vendor.t($options.formatDate(item.pkTime)),
j: common_vendor.t(item.coin + "K"),
k: common_vendor.o$1(($event) => $options.goDetail(item)),
l: "4813d59a-0-" + i0

View File

@@ -1,2 +1,13 @@
"use strict";
function formatDate(timestamp) {
const date = new Date(timestamp * 1e3);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hour = String(date.getHours()).padStart(2, "0");
const minute = String(date.getMinutes()).padStart(2, "0");
const second = String(date.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
}
exports.formatDate = formatDate;
//# sourceMappingURL=../../.sourcemap/mp-weixin/components/formatDate.js.map

View File

@@ -24,15 +24,17 @@ function request(urldata) {
}
});
} else {
this.$global.lastPage = common_vendor.index.page.route;
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.reLaunch({ url: "/pages/UserInformation/UserInformation" });
}
} else {
this.$global.lastPage = common_vendor.index.page.route;
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.navigateTo({ url: "/pages/login/login" });
}
},
fail: function(res) {
common_vendor.index.setStorageSync("lastPage", getCurrentPages()[getCurrentPages().length - 1].route);
common_vendor.index.navigateTo({ url: "/pages/login/login" });
reject(res);
}
});
@@ -45,7 +47,7 @@ function request(urldata) {
method,
header,
success: function(res) {
common_vendor.index.__f__("log", "at components/request.js:48", "请求成功2", res);
common_vendor.index.__f__("log", "at components/request.js:50", "请求成功2", res);
resolve(res.data);
},
fail: function(res) {

View File

@@ -14,6 +14,7 @@ const _sfc_main = {
},
methods: {
goAdvertisement() {
common_vendor.index.navigateTo({ url: "/pages/pkDetail/pkDetail" });
}
},
components: {

View File

@@ -11,7 +11,8 @@ const _sfc_main = {
name: "",
id: "",
info: {},
userSig: ""
userSig: "",
lastPage: ""
};
},
onLoad(option) {
@@ -27,6 +28,15 @@ const _sfc_main = {
this.userSig = res.data;
}
});
common_vendor.index.getStorage({
key: "lastPage",
success: (res) => {
this.lastPage = "/" + res.data;
},
fail: () => {
this.lastPage = "/pages/Home/Home";
}
});
},
methods: {
// 输入昵称
@@ -54,7 +64,7 @@ const _sfc_main = {
}).then((res) => {
this.userinfo = res;
}).catch((err) => {
common_vendor.index.__f__("log", "at pages/UserInformation/UserInformation.vue:76", err);
common_vendor.index.__f__("log", "at pages/UserInformation/UserInformation.vue:86", err);
});
if (this.userinfo) {
const res = await components_request.request({
@@ -77,8 +87,7 @@ const _sfc_main = {
common_vendor.index.setStorageSync("userinfo", res.data.info);
common_vendor.index.hideLoading();
common_vendor.index.reLaunch({
url: this.$global.lastPage || "/pages/Home/Home"
// 默认页
url: this.lastPage
});
} else {
common_vendor.index.showToast({

View File

@@ -9,7 +9,8 @@ const _sfc_main = {
return {
userInfo: {},
info: {},
userSig: ""
userSig: "",
lastPage: ""
};
},
onLoad() {
@@ -19,6 +20,16 @@ const _sfc_main = {
this.userInfo = res.userInfo;
}
});
common_vendor.index.getStorage({
key: "lastPage",
success: (res) => {
this.lastPage = "/" + res.data;
common_vendor.index.__f__("log", "at pages/login/login.vue:37", this.lastPage);
},
fail: () => {
this.lastPage = "/pages/Home/Home";
}
});
},
methods: {
// 获取手机号
@@ -55,9 +66,9 @@ const _sfc_main = {
common_vendor.index.setStorageSync("userinfo", this.info.data.info);
common_vendor.index.hideLoading();
components_TUILogin.TUIlogin(this.info.data.chatInfo.appId, this.info.data.info.id, this.userSig.userSig);
common_vendor.index.__f__("log", "at pages/login/login.vue:81", "跳的地址", this.lastPage);
common_vendor.index.reLaunch({
url: this.$global.lastPage || "/pages/Home/Home"
// 默认页
url: this.lastPage
});
}
} else {

View File

@@ -1,6 +1,10 @@
"use strict";
const common_vendor = require("../../common/vendor.js");
const components_formatDate = require("../../components/formatDate.js");
const components_VerifyLogin = require("../../components/VerifyLogin.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
inject: ["$global"],
data() {
return {
item: {}
@@ -10,19 +14,62 @@ const _sfc_main = {
const eventChannel = this.getOpenerEventChannel();
eventChannel.on("itemDetail", (data) => {
this.item = data.item;
common_vendor.index.__f__("log", "at pages/pkDetail/pkDetail.vue:30", "接收到的数据:", this.item);
common_vendor.index.__f__("log", "at pages/pkDetail/pkDetail.vue:65", "接收到的数据:", this.item);
});
},
methods: {}
methods: {
formatDate: components_formatDate.formatDate,
Returnfunc() {
common_vendor.index.navigateBack({
delta: 1
});
},
open() {
this.$refs.popup.open("center");
},
invite() {
},
close() {
this.$refs.popup.close();
},
openChat() {
components_VerifyLogin.VerifyLogin().then(() => {
const conversationID = `C2C${this.item.senderId}`;
common_vendor.index.redirectTo({
url: `/TUIKit/components/TUIChat/index?conversationID=${conversationID}`
});
});
}
}
};
if (!Array) {
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
_easycom_uni_popup2();
}
const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
_easycom_uni_popup();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($data.item.anchorId),
b: common_vendor.t($data.item.sex === 1 ? "男" : "女"),
c: common_vendor.t($data.item.country),
d: common_vendor.t($data.item.coin),
e: common_vendor.t($data.item.remark),
f: common_vendor.t($data.item.pkTime)
a: common_assets._imports_0,
b: common_vendor.o$1((...args) => $options.Returnfunc && $options.Returnfunc(...args)),
c: common_assets._imports_1,
d: common_vendor.t($data.item.anchorId),
e: common_vendor.t($data.item.sex === 1 ? "男" : "女"),
f: common_vendor.t($data.item.country),
g: common_vendor.t($data.item.coin),
h: common_vendor.t($options.formatDate($data.item.pkTime)),
i: common_vendor.t($data.item.remark),
j: common_vendor.o$1(($event) => $options.openChat()),
k: common_vendor.o$1(($event) => $options.open()),
l: common_vendor.o$1(($event) => $options.invite()),
m: common_vendor.o$1(($event) => $options.close()),
n: common_vendor.sr("popup", "9639f721-0"),
o: common_vendor.p({
type: "center",
["border-radius"]: "10px 10px 0 0"
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-9639f721"]]);

View File

@@ -1,4 +1,6 @@
{
"navigationBarTitleText": "PK详情",
"usingComponents": {}
"usingComponents": {
"uni-popup": "../../uni_modules/uni-popup/components/uni-popup/uni-popup"
}
}

View File

@@ -1 +1 @@
<view class="container data-v-9639f721"><view class="data-v-9639f721">主播名称{{a}}</view><view class="data-v-9639f721">主播性别{{b}}</view><view class="data-v-9639f721"> 国家{{c}}</view><view class="data-v-9639f721">金币{{d}}</view><view class="data-v-9639f721">主播备注{{e}}</view><view class="data-v-9639f721">PK时间{{f}}</view></view>
<view class="Navigation data-v-9639f721"><image src="{{a}}" mode="scaleToFill" class="Navigationimg data-v-9639f721"/><image bindtap="{{b}}" src="{{c}}" mode="scaleToFill" class="Return data-v-9639f721"/></view><view class="container data-v-9639f721"><view class="individual data-v-9639f721"><view class="anchor data-v-9639f721"></view><view class="data-v-9639f721"><view class="data-v-9639f721">主播名称{{d}}</view><view class="data-v-9639f721">主播性别{{e}}</view><view class="data-v-9639f721"> 国家{{f}}</view></view></view><view class="data-v-9639f721">金币{{g}}</view><view class="data-v-9639f721">PK时间{{h}}</view><view class="data-v-9639f721">主播备注{{i}}</view><button class="data-v-9639f721" bindtap="{{j}}">聊了个天</button><button class="data-v-9639f721" bindtap="{{k}}">立即邀请PK</button></view><uni-popup wx:if="{{o}}" class="r data-v-9639f721" u-s="{{['d']}}" u-r="popup" u-i="9639f721-0" bind:__l="__l" u-p="{{o}}"><view class="popup-content data-v-9639f721"><view class="popup-title data-v-9639f721">您确定要邀请主播PK吗</view><view class="popup-btn data-v-9639f721"><button class="invite data-v-9639f721" type="primary" bindtap="{{l}}">邀请</button><button class="cancel data-v-9639f721" type="default" bindtap="{{m}}">取消</button></view></view></uni-popup>

View File

@@ -1,2 +1,74 @@
/* 样式定义 */
.Navigation.data-v-9639f721 {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 200rpx;
}
.Navigationimg.data-v-9639f721 {
width: 100%;
height: 100%;
}
.Return.data-v-9639f721 {
position: absolute;
left: 60rpx;
bottom: 40rpx;
width: 60rpx;
height: 60rpx;
}
.container.data-v-9639f721 {
position: absolute;
top: 200rpx;
left: 0;
right: 0;
bottom: 0;
}
.individual.data-v-9639f721 {
display: flex;
/* justify-content: center; */
margin-top: 50rpx;
}
.anchor.data-v-9639f721 {
width: 200rpx;
height: 200rpx;
background-color: rgba(0, 0, 255, 0.369);
border-radius: 50%;
}
.popup-content.data-v-9639f721 {
width: 500rpx;
height: 300rpx;
background-color: #fff;
border-radius: 10px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.popup-title.data-v-9639f721 {
font-size: 30rpx;
margin-top: 50rpx;
text-align: center;
}
.popup-btn.data-v-9639f721 {
display: flex;
justify-content: space-around;
margin-top: 50rpx;
}
.invite.data-v-9639f721 {
width: 200rpx;
height: 80rpx;
font-size: 30rpx;
line-height: 80rpx;
border-radius: 20rpx;
background-color: #1aff0087;
}
.cancel.data-v-9639f721 {
width: 200rpx;
height: 80rpx;
font-size: 30rpx;
line-height: 80rpx;
margin-left: 30rpx;
border-radius: 20rpx;
}

View File

@@ -0,0 +1,397 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
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
} = common_vendor.index.getWindowInfo();
this.popupWidth = windowWidth;
this.popupHeight = windowHeight + (windowTop || 0);
if (safeArea && this.safeArea) {
this.safeAreaInsets = screenHeight - safeArea.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) {
e.stopPropagation();
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]) {
common_vendor.index.__f__("error", "at uni_modules/uni-popup/components/uni-popup/uni-popup.vue:310", "缺少类型:", 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(() => {
this.showPoptrans();
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.showPoptrans();
},
/**
* 中间弹出样式处理
*/
center(type) {
this.popupstyle = "center";
this.ani = ["fade"];
this.transClass = {
position: "fixed",
display: "flex",
flexDirection: "column",
bottom: 0,
left: 0,
right: 0,
top: 0,
justifyContent: "center",
alignItems: "center",
borderRadius: this.borderRadius || "0"
};
if (type)
return;
this.showPoptrans();
},
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",
display: "flex",
flexDirection: "column"
};
if (type)
return;
this.showPoptrans();
},
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",
display: "flex",
flexDirection: "column"
};
if (type)
return;
this.showPoptrans();
},
showPoptrans() {
this.$nextTick(() => {
this.showPopup = true;
this.showTrans = true;
});
}
}
};
if (!Array) {
const _easycom_uni_transition2 = common_vendor.resolveComponent("uni-transition");
_easycom_uni_transition2();
}
const _easycom_uni_transition = () => "../../../uni-transition/components/uni-transition/uni-transition.js";
if (!Math) {
_easycom_uni_transition();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: $data.showPopup
}, $data.showPopup ? common_vendor.e({
b: $data.maskShow
}, $data.maskShow ? {
c: common_vendor.o$1($options.onTap),
d: common_vendor.p({
name: "mask",
["mode-class"]: "fade",
styles: $data.maskClass,
duration: $data.duration,
show: $data.showTrans
})
} : {}, {
e: common_vendor.s($options.getStyles),
f: common_vendor.n($data.popupstyle),
g: common_vendor.o$1((...args) => $options.clear && $options.clear(...args)),
h: common_vendor.o$1($options.onTap),
i: common_vendor.p({
["mode-class"]: $data.ani,
name: "content",
styles: $data.transClass,
duration: $data.duration,
show: $data.showTrans
}),
j: common_vendor.o$1((...args) => $options.touchstart && $options.touchstart(...args)),
k: common_vendor.n($data.popupstyle),
l: common_vendor.n($options.isDesktop ? "fixforpc-z-index" : "")
}) : {});
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-popup/components/uni-popup/uni-popup.js.map

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"uni-transition": "../../../uni-transition/components/uni-transition/uni-transition"
}
}

View File

@@ -0,0 +1 @@
<view wx:if="{{a}}" class="{{['uni-popup', k, l]}}"><view bindtouchstart="{{j}}"><uni-transition wx:if="{{b}}" key="1" bindclick="{{c}}" u-i="3309e7c7-0" bind:__l="__l" u-p="{{d}}"/><uni-transition wx:if="{{i}}" u-s="{{['d']}}" key="2" bindclick="{{h}}" u-i="3309e7c7-1" bind:__l="__l" u-p="{{i}}"><view style="{{e}}" class="{{['uni-popup__wrapper', f]}}" bindtap="{{g}}"><slot/></view></uni-transition></view></view>

View File

@@ -0,0 +1,47 @@
/**
* 这里是uni-app内置的常用样式变量
*
* uni-app 官方扩展插件及插件市场https://ext.dcloud.net.cn上很多三方插件均使用了这些样式变量
* 如果你是插件开发者建议你使用scss预处理并在插件代码中直接使用这些变量无需 import 这个文件方便用户通过搭积木的方式开发整体风格一致的App
*
*/
/**
* 如果你是App开发者插件使用者你可以通过修改这些变量来定制自己的插件主题实现自定义主题功能
*
* 如果你的项目同样使用了scss预处理你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
*/
/* 颜色变量 */
/* 行为相关颜色 */
/* 文字基本颜色 */
/* 背景颜色 */
/* 边框颜色 */
/* 尺寸变量 */
/* 文字尺寸 */
/* 图片尺寸 */
/* Border Radius */
/* 水平间距 */
/* 垂直间距 */
/* 透明度 */
/* 文章场景相关 */
.uni-popup {
position: fixed;
z-index: 99;
}
.uni-popup.top, .uni-popup.left, .uni-popup.right {
top: 0;
}
.uni-popup .uni-popup__wrapper {
display: block;
position: relative;
/* iphonex 等安全区设置,底部安全区适配 */
}
.uni-popup .uni-popup__wrapper.left, .uni-popup .uni-popup__wrapper.right {
padding-top: 0;
flex: 1;
}
.fixforpc-z-index {
z-index: 999;
}
.fixforpc-top {
top: 0;
}

View File

@@ -0,0 +1,116 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
class MPAnimation {
constructor(options, _this) {
this.options = options;
this.animation = common_vendor.index.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 = {}, config = {}) {
let ref = this.$.$refs["ani"].ref;
if (!ref)
return;
return new Promise((resolve, reject) => {
nvueAnimation.transition(ref, {
styles,
...config
}, (res) => {
resolve();
});
});
}
_nvueNextAnimate(animates, step = 0, fn) {
let obj = animates[step];
if (obj) {
let {
styles,
config
} = obj;
this._animateRun(styles, config).then(() => {
step += 1;
this._nvueNextAnimate(animates, step, fn);
});
} else {
this.currentStepAnimates = {};
typeof fn === "function" && fn();
this.isEnd = true;
}
}
step(config = {}) {
this.animation.step(config);
return this;
}
run(fn) {
this.$.animationData = this.animation.export();
this.$.timer = setTimeout(() => {
typeof fn === "function" && fn();
}, this.$.durationTime);
}
}
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.animation[type](...args);
return this;
};
});
function createAnimation(option, _this) {
if (!_this)
return;
clearTimeout(_this.timer);
return new MPAnimation(option, _this);
}
exports.createAnimation = createAnimation;
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-transition/components/uni-transition/createAnimation.js.map

View File

@@ -0,0 +1,269 @@
"use strict";
const common_vendor = require("../../../../common/vendor.js");
const uni_modules_uniTransition_components_uniTransition_createAnimation = require("./createAnimation.js");
const _sfc_main = {
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 = uni_modules_uniTransition_components_uniTransition_createAnimation.createAnimation(Object.assign(this.config, obj), this);
},
/**
* 点击组件触发回调
*/
onClick() {
this.$emit("click", {
detail: this.isShow
});
},
/**
* ref 触发 动画分组
* @param {Object} obj
*/
step(obj, config = {}) {
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) {
common_vendor.index.__f__("error", "at uni_modules/uni-transition/components/uni-transition/uni-transition.vue:148", `方法 ${i} 不存在`);
}
}
this.animation.step(config);
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 = uni_modules_uniTransition_components_uniTransition_createAnimation.createAnimation(this.config, this);
this.tranfromInit(false).step();
this.animation.run(() => {
this.transform = "";
this.opacity = opacity || 1;
});
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(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: $data.isShow,
b: $data.animationData,
c: common_vendor.n($props.customClass),
d: common_vendor.s($options.transformStyles),
e: common_vendor.o$1((...args) => $options.onClick && $options.onClick(...args))
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uni-transition/components/uni-transition/uni-transition.js.map

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1 @@
<view hidden="{{!a}}" ref="ani" animation="{{b}}" class="{{c}}" style="{{d}}" bindtap="{{e}}"><slot></slot></view>