Commit de56eca3 authored by liwei's avatar liwei

新增了动态里的评论页面

parent efb2fadc
<template>
<div>
<view>
<ArticleItem @delete="deleteFn" :info="item" @selectShare="selectShare(item)" @praise="praise"
@close="close" @open="open"/>
</view>
<view class="commentTitle">
<view>
<text>评论区</text>
......@@ -188,10 +192,28 @@
</template>
<script>
// 发送消息 第一个参数为消息名(事件名),第二个参数为通信的值(可以不穿)
import ArticleItem from './components/articleItem.vue'
export default{
components: {
ArticleItem,
},
data () {
return {
item:{
createTime:'2024-12-28 15:02:01',
headPortrait:'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg',//头像
nickName:'不爱吃辣的小王',//nickName
gender:'MALE',//性别
information:'02·重庆市·硕士·互联网',//个人信息
content:'昨天的快乐留在今天发,那就是100%',//动态内容
time:'2024-11-11 15:02:01',//发布动态的时间
commentCount:'10',//评论数
likeCount:'11',//点赞数
img:[
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg',
'http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'
]
},
commentValue:'',
commentChildren:[
{
......
<template>
<view class="item">
<view class="left">
<image @click="gotoUserInfo(info)" :src="info.headPortrait" mode="aspectFill"></image>
</view>
<view class="center">
<template>
<view class="name">
<text @click="gotoUserInfo(info)">{{info.nickName}}</text>
<image v-if="info.gender!='MALE'" class="gender" src="../../static/images/like/famale.png" mode="">
</image>
<image v-else class="gender" src="../../static/images/like/male.png" mode=""></image>
</view>
<view class="info">
<text decode="true" style="color: #434343;">{{info.information}}</text>
</view>
</template>
<view class="content">
<template v-if="info.content">
<u-read-more ref="uReadMore" :shadowStyle="shadowStyle" :toggle="true" color="#415C9E" :textIndent="0" showHeight="126rpx">
<view @click="gotoDetail(info)" style="font-size: 28rpx;color: #333333;">
<view class="" style="line-height: 1.5;">
{{info.content}}
</view>
</view>
</u-read-more>
</template>
</view>
<view class="contentImg">
<imageAdaptation :imgList="imgs" :imgLayout1="imgLayout1" :imgLayout2="imgLayout2"
:imgLayout3="imgLayout3" @previewImg="preview"></imageAdaptation>
<q-previewImage ref="previewImage" :urls="imgs" @onLongpress="onLongpress" @open="open"
@close="close"></q-previewImage>
</view>
<view class="time">
{{info.time}}
</view>
</view>
</view>
</template>
<script>
import imageAdaptation from '@/components/images-adaptation/imageAdaptation.vue'
import xzjReadMore from "@/components/xzj-readMore/xzj-readMore.vue"
export default {
name:'ArticleItem',
options: {
styleIsolation: 'shared'
},
components: {
imageAdaptation,
xzjReadMore
},
props: {
info: {
type: Object,
default: () => {}
}
},
watch: {
info: {
handler(newValue) {
if (newValue?.img?.length) {
this.imgs = newValue.img
}
},
deep: true,
immediate: true
}
},
mounted() {
if (this.$refs.uReadMore) {
setTimeout(() => {
this.$nextTick(() => {
this.$refs.uReadMore.init();
})
}, 100)
}
},
data() {
return {
tagStyle: {
text: 'line-height:1em'
},
imgs: [],
imgLayout1: [450, 450],
imgLayout2: [220, 220],
imgLayout3: [160, 160],
show: false,
list: [{
name: '删除',
},
// {
// name: "举报"
// }
],
shadowStyle: {
'backgroundImage': 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 50%, #fff 100%)',
justifyContent: 'flex-end'
},
tipMsg: '',
isConfirm: false
}
},
methods: {
load() {
this.$refs.uReadMore.init();
},
select() {
this.$emit("selectShare", this.info)
},
//查看动态详情
gotoDetail(item) {
uni.navigateTo({
url: '/pagesArticle/articleDetail?userId=' + item.userId
})
},
//查看用户详情
gotoUserInfo(item) {
uni.navigateTo({
url: '/pageslike/like/userInfo?id=' + item.userId
})
},
// 点赞
praise(value) {
this.$emit("praise", value)
},
// 删除
selectClick(item) {
if (item.name == "删除") {
this.$emit("delete", this.info)
} else if (item.name == "举报") {
this.tipMsg = "尽情期待";
this.$refs.elm.showDialog();
}
},
preview({
url,
index
}) {
uni.previewImage({
current: index,
urls: this.imgs,
longPressActions: {
// itemList: ['发送给朋友', '保存图片', '收藏'],
success: function(data) {
console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
},
fail: function(err) {
console.log(err.errMsg);
}
}
});
// // #ifdef MP-WEIXIN
// this.$nextTick(() => {
// this.$refs.previewImage.open(url); // 传入当前选中的图片地址(小程序必须添加$nextTick,解决组件首次加载无图)
// })
// // #endif
// // #ifndef MP-WEIXIN
// this.$refs.previewImage.open(url); // 传入当前选中的图片地址
// // #endif
},
onLongpress(e) { //长按事件
console.log('当前长按的图片是' + e);
uni.showActionSheet({
itemList: ['转发给朋友', '保存到手机'],
success: function(res) {
console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
},
fail: function(res) {
console.log(res.errMsg);
}
});
},
/* open和close方法一般用不到,但是在一些特殊场景会用到,
* 比如预览图片时你需要覆盖 NavigationBar和 TabBar,
* 或者在app中需要预览图片时覆盖住原生组件,比如video或者map等,
* 你可以根据open和close去做一些操作,例如隐藏导航栏或者隐藏一些原生组件等
*/
open() { //监听组件显示 (隐藏TabBar和NavigationBar,隐藏video原生组件)
uni.hideTabBar()
uni.setNavigationBarColor({
frontColor: '#000000', // 设置前景色为黑色
backgroundColor: '#000000', // 设置背景色为黑色
})
// this.videoShow = false
this.$emit("open")
},
close() { //监听组件隐藏 (显示TabBar和NavigationBar,显示video原生组件)
uni.showTabBar()
uni.setNavigationBarColor({
frontColor: '#ffffff', // 设置前景色为白色
backgroundColor: '#000000', // 设置背景色为黑色
})
// this.videoShow = true
this.$emit("close")
},
showSelect(info) {
if (info.isDelete != true) {
const index = this.list.findIndex(i => i.name === '删除');
if (index !== -1) {
this.list.splice(index, 1);
}
}
this.show = true;
}
}
}
</script>
<style lang="scss" scoped>
.bor {
border-top: 2rpx solid #F5F5F5;
}
.item {
display: flex;
justify-content: space-between;
padding: 40rpx 0 0rpx 0;
margin-left: 32rpx;
margin-right: 32rpx;
.left {
image {
width: 68rpx;
height: 68rpx;
border-radius: 50%;
}
.l {
height: 100%;
margin-right: 10rpx;
.box {
font-weight: 600;
font-size: 24rpx;
color: #111827;
.str {
font-size: 30rpx;
}
.month {
font-size: 20rpx;
}
}
}
.line {
margin-left: 10rpx;
width: 0;
height: calc(100% - 80rpx);
border: 1rpx solid #E6E6E6;
margin-top: 20rpx;
}
}
.center {
margin: 0 20rpx;
flex: 1;
.name {
text {
font-weight: 600;
font-size: 32rpx;
color: #333333;
}
.gender {
width: 36rpx;
height: 36rpx;
margin-left: 16rpx;
vertical-align: middle;
}
}
.info {
font-weight: 400;
font-size: 24rpx;
color: #434343;
margin: 12rpx 0 24rpx 0;
}
.content {
font-weight: 400;
font-size: 28rpx;
color: #333333;
margin-bottom: 16rpx;
::v-deep .u-read-more__toggle {
justify-content: flex-end !important;
}
}
.contentImg {
// max-height: 450rpx;
}
.time {
font-weight: 400;
font-size: 24rpx;
color: #939393;
margin: 22rpx 0 34rpx 0;
}
.btns {
display: flex;
justify-content: space-between;
.btn {
image {
width: 28rpx;
height: 28rpx;
margin-right: 8rpx;
vertical-align: middle;
}
text {
font-weight: 400;
font-size: 24rpx;
color: #434343;
}
}
}
}
.right {
view {
display: flex;
height: 30rpx;
padding-top: 14rpx;
text {
width: 8rpx;
height: 8rpx;
background-color: #333;
border-radius: 50%;
margin-right: 6rpx;
}
}
}
}
</style>
<template>
<view class="dialog_box" v-if="show">
<view class="bg" ></view>
<view class="dialog_content">
<view class="bag">
<image class="pop-bgc" :src="img + '/img/home-pop-bg.png'"></image>
<view class="divss">
<image class="touxiang" :src="touxiang" mode="aspectFill"></image>
<image class="suo-img" src="../../../static/images/like/suo.png" mode="aspectFill"></image>
<view class="namne">解锁对方身份</view>
<view class="namnes">解锁后,对方喜欢你、访问 你的主页将不再隐藏身份</view>
<view class="button" @click="unlock(userInfo)">立即解锁({{bitext}}币)</view>
<view class="buttons" @click="unlock(null)">解锁全部 ({{discountText}})</view>
</view>
</view>
<view class="dialog_foot" @click="hideDialog()"><image src="../../../static/images/closeing.png" mode="aspectFill" style="width: 64rpx;height: 64rpx;;"></image></view>
</view>
</view>
</template>
<script>
export default {
props: ['dataInfo'],
props: {
touxiang: {
type: String,
default: "",
},
bitext: {
type: String,
default: "",
},
show:{
type:Boolean,
default: false
},
discountText: {
type: String,
default: "五折 ",
},
userInfo: {
type: Number,
default:null,
}
},
data() {
return {
img: this.$BASE_URL,
info: this.dataInfo,
};
},
onLoad() {},
methods: {
showDialog() {
this.show = true;
},
hideDialog() {
this.$emit('closePopup',false);
},
unlock(user) {
this.$emit('unlock',user);
}
}
};
</script>
<style lang="scss" >
.dialog_box {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 999;
.bg {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 1;
background-color: rgba(0, 0, 0, 0.5);
}
.dialog_content {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
z-index: 10;
text-align: center;
.title {
font-size: 50rpx;
color: #fff;
margin: 40rpx auto;
}
.bag {
position: relative;
width: 586rpx;
height: 774rpx;
background: #ffffff;
border-radius: 24rpx 24rpx 24rpx 24rpx;
opacity: 1;
overflow: hidden;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
.divss {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding-top: 40rpx;
.touxiang{
width: 144rpx;
height: 144rpx;
border-radius: 16rpx;
filter: blur(8rpx);
filter: progid:DXImageTransform.Microsoft.Blur(PixelRadius=2, MakeShadow=false);
position: relative;
z-index: 88;
}
.suo-img{
width: 40rpx;
height: 40rpx;
border-radius: 8rpx;
margin-top: -20rpx;
margin-bottom: 16rpx;
position: relative;
z-index: 99;
}
.namne {
width: 100%;
height: 56rpx;
font-size: 38rpx;
font-family: 'PingFang SC-Heavy';
font-weight: 600;
color: #4a4a4a;
line-height: 56rpx;
// margin-top: 156rpx;
text-align: center;
}
.button {
width: 392rpx;
height: 84rpx;
background: linear-gradient(86deg, #c2d2f9 0%, #c5c2f3 100%);
border-radius: 42rpx;
font-size: 28rpx;
font-family: 'PingFang SC-Heavy';
font-weight: 400;
color: #415c9e;
line-height: 84rpx;
text-align: center;
margin: 0 auto;
margin-top: 44rpx;
}
.buttons{
width: 392rpx;
height: 84rpx;
border-radius: 42rpx;
border: 2rpx solid #9FB5EB;
background-color: #ffffff;
color: #9FB5EB ;
font-size: 28rpx;
font-family: 'PingFang SC-Heavy';
font-weight: 400;
line-height: 84rpx;
text-align: center;
margin: 0 auto;
margin-top: 28rpx;
}
.namnes {
width: 364rpx;
height: 96rpx;
font-size: 28rpx;
font-family: 'PingFang SC-Heavy';
font-weight: 400;
color: #4a4a4a;
line-height: 48rpx;
margin: 0 auto;
margin-top: 18rpx;
text-align: center;
}
}
.pop-bgc {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 78%;
// z-index: -1;
}
.bag_body {
width: 100%;
height: 500rpx;
margin: auto;
background-color: #ff2c21;
border-bottom-left-radius: 50rpx;
border-bottom-right-radius: 50rpx;
margin-top: -200rpx;
.ul {
margin: -100rpx 20rpx 20rpx;
border-radius: 32rpx;
background-color: #ffffff;
width: calc(100% - 40rpx);
height: calc(100% - 20rpx);
.li {
position: relative;
padding: 20rpx;
font-size: 0;
border-bottom: 1px solid #eee;
.lred,
.rred {
position: absolute;
bottom: -20rpx;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background-color: #ff2c21;
}
.lred {
left: -20rpx;
}
.rred {
right: -20rpx;
}
&:last-child {
.lred,
.rred {
display: none;
}
}
.img,
.txt,
.money {
vertical-align: middle;
display: inline-block;
}
.img {
width: 80rpx;
}
.txt {
text-align: left;
margin-left: 20rpx;
width: calc(80% - 100rpx);
.name {
font-size: 40rpx;
color: #000;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.tip {
font-size: 20rpx;
color: #bbbbbb;
}
}
.money {
font-size: 40rpx;
color: #ca6143;
font-weight: 700;
width: 20%;
label {
font-size: 20rpx;
}
}
}
}
}
.bag_foot {
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 100rpx;
&::before {
content: '';
position: absolute;
left: -10%;
top: -100rpx;
width: 120%;
height: 100rpx;
border-radius: 50%;
box-shadow: 0 50rpx 0 0 #f4c35d;
}
&::after {
content: '';
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(#f4c35d, #fb3e2a);
}
.txt {
position: absolute;
left: 0;
top: 0;
z-index: 10;
width: 100%;
height: 100rpx;
line-height: 100rpx;
font-size: 30rpx;
color: #fff;
text-align: center;
}
}
}
}
.dialog_foot {
text-align: center;
position: absolute;
top: 80%;
left: 50%;
transform: translate(-50%,0%);
}
}
.sasas {
width: 530rpx;
height: 260rpx;
background: #ffffff;
border-radius: 20rpx;
}
.sasasa {
width: 460rpx;
margin: 0 auto 0rpx;
padding-top: 100rpx;
height: 120rpx;
font-size: 28rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #666666;
line-height: 40rpx;
}
</style>
......@@ -6,7 +6,7 @@
<view class="div" style="height: 100%;background: #F4F5F9;">
<view class="">
<view class="box">
<!-- 下方俩图标 喜欢和不喜欢-->
<!-- 图片右上角的图标-->
<view class="swiper">
<ls-swiper :list="userData.imgList" imgKey="" :loop="true" :dots="true" :autoplay="true"
:height="340" />
......@@ -33,7 +33,7 @@
</view>
</view>
</view>
<!-- 图片下方学历栏-->
<view class="box-jj">
<view class="box-jj-ta">
<view class="box-jj-ta-left">
......@@ -223,10 +223,13 @@
</view>
</view>
</view>
<view class="footer-fixed" @click="goSedMsg" v-if="userData.result != null && userData.result">
<image src="../../static/images/like/chat.png" mode="aspectFill"/>
发起聊天
</view>
<!-- 发起聊天按钮-->
<!-- <view class="footer-fixed" @click="goSedMsg" v-if="userData.result != null && userData.result">-->
<!-- <image src="../../static/images/like/chat.png" mode="aspectFill"/>-->
<!-- 发起聊天-->
<!-- </view>-->
<!-- 两个图标按钮 喜欢和不喜欢-->
<view v-if="showArrowDown">
<view class="footer-fixedlike" v-if="userData.selfMatchingStatus == null">
<view class="left" @click="logion(userData.id, false, '../../static/images/clo.png')">
......@@ -237,44 +240,10 @@
</view>
</view>
</view>
<!-- v-show="showAnima" -->
<image v-if="showAnima" :src="animUrl" mode="aspectFill" class="animate-middel-top"></image>
<image v-show="showArrowDown" src="../../static/images/home/arrow_down_sm.png" mode="aspectFill"
class="fixed_down"></image>
<!-- 相关喜欢的弹窗 -->
<u-popup :show="showLikePop" mode="center" round="12" :closeOnClickOverlay="false" @close="closeLikePop"
@open="openLikePop" :safeAreaInsetBottom="false">
<view class="mutual_like">
<image class="likepopbg" :src="img + '/img/likepopbg.png'" mode="aspectFill"></image>
<image class="trbg" src="../../static/images/like/likebg.png" mode="aspectFill"></image>
<view class="like-pop-content">
<view class="title">互相喜欢</view>
<view class="toname">
你已和
<text class="toname_to">{{ mutualInfo.otherNickName }}</text>
已互相喜欢
</view>
<view class="avatar_anmi">
<view class="avatar avat_left_anmi">
<image :src="mutualInfo.selfHeadPortrait" mode="aspectFill"></image>
</view>
<image class="liketo-icon" src="../../static/images/like/liketo.png" mode="aspectFill">
</image>
<view class="avatar avat_right_anmi">
<image :src="mutualInfo.otherHeadPortrait" mode="aspectFill"></image>
</view>
</view>
<view class="pt52">
相遇是最浪漫的事
<br />
相守是最感动的话
</view>
<view class="like-pop-btn qdzh" @click="goSedMsg">去打招呼</view>
<view class="like-pop-btn shzl" @click.stop="closeLikePop">稍后再聊</view>
</view>
</view>
</u-popup>
<login @change="getUserInfowx" :isLoginPop="isLoginPop" class="my-select"></login>
<!-- 点击喜欢和不喜欢的动画效果-->
<image v-if="showAnima" :src="animUrl" mode="aspectFill" class="animate-middel-top"/>
<!-- 向下滑动的箭头-->
<image v-show="showArrowDown" src="../../static/images/home/arrow_down_sm.png" mode="aspectFill" class="fixed_down"/>
</view>
<myPopup v-if="isShow" :content="userData.selfMatchingStatus=='NOT_LIKE'?'是否取消无感?':
userData.selfMatchingStatus=='LIKE'?'是否取消喜欢?':'是否解除匹配?'" @confirm="confirm" @cancel="cancelbtn">
......@@ -284,14 +253,10 @@
<script>
let util = require('@/util/means.js');
import ELM from '../../components/elm-toast/index.vue';
import LsSwiper from '../../components/ls-swiper/index.vue';
import login from '../../components/login/login.vue';
import myPopup from '@/components/myPopup.vue'
export default {
components: {
ELM,
login,
LsSwiper,
myPopup
},
......@@ -299,6 +264,7 @@
return {
//用户信息
userData: {
result:true,
imgList:['http://192.168.1.80/upload/CmsBanner/20241230/18E63B570FF04DB3A8EFE277D58256C4.jpg'],
school:'天津大学',
education:'Undergraduate',
......@@ -331,7 +297,6 @@
showLikePop: false,
animUrl: '',
showAnima: false,
showBtn: true,
showArrowDown: true,
isInit: true,
showTabbar: true,
......@@ -339,7 +304,6 @@
unfold: false,
isLoginPop: false,
img: this.$BASE_URL,
// bgColor: 'linear-gradient(to bottom, #e8eef6, #eef5f6)',
bgColor: '#F4F5F9',
base_lsit: [
......@@ -493,11 +457,9 @@
if(this.userData.userArticleViewResponse.articleImg.length>3){
this.userData.userArticleViewResponse.articleImg = this.userData.userArticleViewResponse.articleImg.splice(0,3)
}
this.showBtn = true;
console.log(this.userData, 'this.userData');
},
goSedMsg() {
uni.navigateTo({
url: `/pages2/sedMsg/sedMsg?sendUserId=${this.userData.id}&nickName=${this.userData.nickName}`
})
......@@ -505,199 +467,20 @@
canelLike() {
this.isShow = true;
},
handleNoAgree() {
this.tipsShow = false;
},
handAgree() {
this.tipsShow = false;
this.canelLike(this.id);
},
async logion(id, type, url) {
this.animUrl = url;
const res = await this.$getId();
if (res == 11003) {
if (uni.getStorageSync('itemobj')) {
this.isLoginPop = true;
} else {
uni.reLaunch({
url: '/pageslogin/index/index'
});
}
} else {
// 滑动到顶部
if (!this.showBtn) {
console.log('防止连续点击');
return;
}
this.userIsLike(id, type);
}
this.userIsLike(id, type);
},
//type 喜欢 true 还是 取消 false
userIsLike(userId, type) {
console.log("开始匹配:" + userId)
this.showBtn = false;
// 点击 取消 喜欢 根据返回结果展示
this.$myRequest({
url: 'nostalgia/usermatching/match',
data: {
otherUser: userId,
result: type
},
withToken: true,
method: 'POST'
}).then(res => {
console.log("匹配结束1:" + userId)
if (res.data.code == 200) {
this.showAnima = true;
setTimeout(() => {
this.showAnima = false;
}, 1000);
// 显示 相互 弹窗 this.showLikePop = true;
if (res.data.data && res.data.data.result) {
this.showLikePop = true;
this.mutualInfo = res.data.data;
console.log(this.mutualInfo, 'this.mutualInfo');
}
console.log("匹配结束2:" + userId)
this.getUserInfo();
} else {
this.showBtn = true;
}
})
},
getUserInfowx(e) {
if (e == 0) {
this.isLoginPop = false;
return;
}
// #ifdef MP-WEIXIN
try {
wx.getUserProfile({
desc: '用于完善会员资料',
success: resinfo => {
wx.login({
success: res => {
if (res.code) {
console.log(res.code, resinfo);
this.setCode(res.code, resinfo);
} else {}
},
fail: err => {}
});
},
fail: errinfo => {
this.setCode(this.generateRandomString(10), 'null');
}
});
} catch {
wx.getUserInfo({
success: resinfo => {
wx.login({
success: res => {
if (res.code) {
console.log(res.code, resinfo);
this.setCode(res.code, resinfo);
} else {}
},
fail: err => {}
});
},
fail: errinfo => {}
});
}
// #endif
// #ifndef MP-WEIXIN
this.setCode("ip", 'null');
// #endif
},
async setCode(code, resinfo) {
const res = await this.$myRequest({
url: 'token/wxAppletLogin',
data: {
code: code
},
method: 'POST'
});
console.log(res, 'delshoucang');
var obj = {
code: code,
state: res.data.code,
nickName: resinfo != 'null' ? resinfo.userInfo.nickName : "匿名用户"
};
uni.setStorageSync('verification', obj);
if (res.data.code == 200) {
this.isLoginPop = false;
uni.showToast({
title: '登录成功',
icon: 'none'
});
var info = {
birthday: res.data.data.info.birthday,
city: res.data.data.info.city,
gender: res.data.data.info.gender,
headPortrait: res.data.data.info.headPortrait,
id: res.data.data.info.id,
nickName: res.data.data.info.nickName
};
uni.setStorageSync('info', info);
uni.setStorageSync('token', res.data.data.token);
} else if (res.data.code == 11002) {
this.isLoginPop = false;
uni.reLaunch({
url: '/pagesintroduction/selfIntroduction?code=' + code
});
} else {
}
this.showAnima = true;
},
backbar() {
if (this.share != null && this.share == "true") {
if (uni.getStorageSync('itemobj')) {
uni.switchTab({
url: '/pages/tab/index'
});
} else {
uni.reLaunch({
url: '/pageslogin/index/index'
});
}
} else {
uni.navigateBack({
delta: 1, //返回层数,2则上上页
})
}
uni.navigateBack({
delta: 1, //返回层数,2则上上页
})
},
generateRandomString(length) {
let result = uni.getStorageSync('touristopenid');
if (result != null&&result!="") {
return result;
}else{
result='';
}
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; // 包含大小写字母和数字的所有字符集合
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
result += characters[randomIndex];
}
var now = new Date();
var year = now.getFullYear(); // 年份
var month = (now.getMonth() + 1).toString().padStart(2, '0'); // 月份(注意要加上1)
var day = now.getDate().toString().padStart(2, '0'); // 天数
var hours = now.getHours().toString().padStart(2, '0'); // 小时
var minutes = now.getMinutes().toString().padStart(2, '0'); // 分钟
var seconds = now.getSeconds().toString().padStart(2, '0'); // 秒数
result = "touristopenid" + result + (+year + month + day + hours + minutes + seconds);
uni.setStorageSync('touristopenid', result);
return result;
}
}
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment