Files
dtx_store/pages/user/index.vue
唐明明 466c4e707a merge
2022-10-12 16:51:17 +08:00

977 lines
34 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="content">
<!-- 用户信息 -->
<view class="info-box" style="background-color: red;">
<image src="@/static/user/user_back.png" mode="aspectFill" />
<view class="user-flex">
<view class="news" @click="onBtn('newsIndex', {})">
<u-icon class="bell_fill" name="bell-fill" color="#fff" size="28" />
<u-badge class="bell_fill_dot" :isDot="messages > 0" type="error" />
</view>
<image class="cover" @click="onBtn('Setting', {})"
:src="userInfo.avatar || require('@/static/user/cover.png')" mode="aspectFill" />
<view class="user-content">
<view class="name">{{ userInfo.nickname }}</view>
<view class="tabs">
<view class="tabs-item">
<image :src="identity.cover_url" mode="heightFix" />{{identity.identity_text}}
</view>
</view>
<view class="chainAddress" v-if="userInfo.addr">
<text @click="copy(userInfo.addr)">区块地址:{{userInfo.addr.substring(0,5) + '****' + userInfo.addr.substring(userInfo.addr.length - 5)}}</text>
</view>
</view>
</view>
</view>
<!-- 会员卡 -->
<view class="vip-card">
<view class="title" @click="onNum">
<image src="@/static/user/icon_06.png" mode="widthFix" />
{{serial === '' ? '共力会员': 'NO:' + serial}}
</view>
<view class="subtitle">
<u-notice-bar :text="cardText" icon="" bgColor="" duration="3000" color="#fcc692" direction="column">
</u-notice-bar>
</view>
<view class="btn" @click="onBtn('Vip', {})">{{userInfo.isOpenVip ? '开通': '续费'}}</view>
</view>
<!-- 账户信息 -->
<view class="health-flex">
<view class="health-flex-item">
<view class="title">共力分</view>
<view class="num">{{account.glz}}</view>
</view>
<view class="health-flex-item" @click="onBtn('AccountDt', {})">
<view class="title">DT积分</view>
<view class="num">{{account.dt}}</view>
</view>
</view>
<!-- 计时器 -->
<view class="onTime">
<u-count-down ref="onTimeCount" :time="2000" @finish="walletNum = 0" :autoStart="false"></u-count-down>
</view>
<!-- 订单 -->
<view class="order-box">
<view class="order-box-item" @click="onBtn('Order', { index: 0 })">
<image class="icon" src="@/static/user/order_icon_04.png" mode="widthFix" />
<view class="title">我的订单</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 1 })">
<view class="number" v-show="order.init > 0">{{order.init}}</view>
<image class="icon" src="@/static/user/order_icon_01.png" mode="widthFix" />
<view class="title">待付款</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 2 })">
<view class="number" v-show="order.paid > 0">{{order.paid}}</view>
<image class="icon" src="@/static/user/order_icon_02.png" mode="widthFix" />
<view class="title">待发货</view>
</view>
<view class="order-box-item" @click="onBtn('Order', { index: 3 })">
<view class="number" v-show="order.delivered > 0">{{order.delivered}}</view>
<image class="icon" src="@/static/user/order_icon_03.png" mode="widthFix" />
<view class="title">待收货</view>
</view>
<view class="order-box-item" @click="onBtn('OrderRefund')">
<view class="number" v-show="order.refund > 0">{{order.refund}}</view>
<image class="icon" src="@/static/user/order_icon_05.png" mode="widthFix" />
<view class="title">退换货</view>
</view>
</view>
<!-- 功能块 -->
<view class="btns-box" v-if="isWallet">
<view class="btns-box-item" @click="onBtn('AccountIntegral', {})">
<image class="icon" src="@/static/user/userIcon_10.png" mode="widthFix" />
共力分钱包
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onBtn('AccountDt', {})">
<image class="icon" src="@/static/user/userIcon_01.png" mode="widthFix" />
DT积分钱包
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onMnemonic">
<image class="icon" src="@/static/user/userIcon_02.png" mode="widthFix" />
导出助记词
<uni-icons class="forward" type="forward" color="#999" />
</view>
<!-- <view class="btns-box-item" @click="onWbt">
<image class="icon" src="@/static/user/userIcon_02.png" mode="widthFix" />
文版通账号
<uni-icons class="forward" type="forward" color="#999" />
</view> -->
<view class="btns-box-item" @click="resetPassword">
<image class="icon" src="@/static/user/userIcon_13.png" mode="widthFix" />
{{hasPassword ? '修改' : '设置'}}支付密码
<uni-icons class="forward" type="forward" color="#999" />
</view>
<block v-if="canSeeData">
<view class="btns-box-item" @click="onBtn('DataBoard', {})">
<image class="icon" src="@/static/user/userIcon_12.png" mode="widthFix" />
平台数据看板
<uni-icons class="forward" type="forward" color="#999" />
</view>
</block>
</view>
<view class="btns-box">
<!-- <view class="btns-box-item" @click="onBtn('PinList', {})" v-if="collage_switch">
<image class="icon" src="@/static/user/userIcon_15.png" mode="widthFix" />
我的拼单 <uni-icons class="forward" type="forward" color="#999" />
</view> -->
<view class="btns-box-item" @click="onBtn('MyCard', {})">
<image class="icon" src="@/static/user/userIcon_00.png" mode="widthFix" />
我的卡券 <uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onBtn('Address', { type: 'edit' })">
<image class="icon" src="@/static/user/userIcon_03.png" mode="widthFix" />
地址管理 <uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onBtn('Invitation', {})">
<image class="icon" src="@/static/user/userIcon_07.png" mode="widthFix" />
分享邀请 <uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="onBtn('Supplier', {})">
<image class="icon" src="@/static/user/userIcon_09.png" mode="widthFix" />
供应商入驻 <uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="btns-box">
<view class="btns-box-item" @click="onShare">
<image class="icon" src="@/static/user/userIcon_14.png" mode="widthFix" />绑定分享关系
<block v-if="share == null"> <uni-icons class="forward" type="forward" color="#999" /> </block>
<block v-else> <text class="forward" style="color: gray;">{{share.nickname}}</text> </block>
</view>
</view>
<view class="btns-box">
<view class="btns-box-item" @click="onBtn('Feedback', {})">
<image class="icon" src="@/static/user/userIcon_06.png" mode="widthFix" />意见反馈
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="updateApp">
<image class="icon" src="@/static/user/userIcon_08.png" mode="widthFix" />
版本更新
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="mianze">
<image class="icon" src="@/static/user/userIcon_02.png" mode="widthFix" />
免责声明
<uni-icons class="forward" type="forward" color="#999" />
</view>
<view class="btns-box-item" @click="logOut" v-if="$store.state.token != ''">
<image class="icon" src="@/static/user/userIcon_05.png" mode="widthFix" />
退出登录
<uni-icons class="forward" type="forward" color="#999" />
</view>
</view>
<view class="footer-text">
<view>共力生态</view>
<view>The total force ecological</view>
</view>
<!-- 助记词弹出框 -->
<u-modal :show="wordsShow" :zoom="false" confirmText="复制" @confirm="copyWord('zjc')" confirmColor="#34CE98">
<slot default>
<view class="wordsCont">
<view class="wordsCont-title">导出助记词</view>
<view class="wordsCont-tips">请务必抄下助记词并存在安全的地方若助记词丢失重装或换设备登录时将无法查看历史消息若助记词被他人获取将可能获取你的信息</view>
<view class="wordsCont-text">{{mnemonic}}</view>
<image class="wordsCont-close" @click="wordsShow = false" src="@/static/icon/userCloes.png"
mode="widthFix"></image>
</view>
</slot>
</u-modal>
<!-- 查看文版通账号 -->
<u-modal :show="wbtShow" :zoom="false" confirmText="复制" @confirm="copyWord('wbt')" confirmColor="#34CE98">
<slot default>
<view class="wordsCont">
<view class="wordsCont-title">文版通账号</view>
<view class="wordsCont-tips">请务必抄下文版通账号并存在安全的地方若文版通账号丢失重装或换设备登录时将无法查看历史消息若文版通账号被他人获取将可能获取你的信息</view>
<view class="wordsCont-text">账号{{wbtAccount}}</view>
<image class="wordsCont-close" @click="wordsShow = false;wbtShow= false;" src="@/static/icon/userCloes.png"
mode="widthFix"></image>
</view>
</slot>
</u-modal>
<!-- 输入支付密码 -->
<u-modal :show="showIv" title="请输入钱包支付密码" :showCancelButton="true" confirmColor="#34CE98" negativeTop="160"
@confirm="validationIv" @cancel="()=>{ this.showIv = false, this.iv = '' }">
<slot name="default">
<view class="mnemonic-pwass">
<input class="iv-input" :focus="true" type="number" password v-model="iv" maxlength="10"
placeholder="输入支付密码" />
</view>
</slot>
</u-modal>
<!-- 绑定分享关系 -->
<u-modal
:show="showBind"
confirmColor="#34CE98"
:showCancelButton="true"
:confirmText="isInvitation ? '校验邀请码': '绑定关系'"
@cancel="()=> {
this.showBind = false
this.isInvitation = true
this.invitation = ''
}"
@confirm="onBind"
>
<slot>
<view class="bind-view" v-if="isInvitation">
<view class="bind-title">邀请码</view>
<view class="bind-subtitle">请输入好友的邀请码</view>
<view class="bind-input">
<input type="text" v-model="invitation" placeholder="输入邀请码">
</view>
</view>
<view class="bind-user" v-else>
<view class="bind-title">邀请用户</view>
<view class="bind-subtitle">请确认绑定关系用户信息</view>
<view class="bind-acitve">
<image :src="invitationUser.avatar" mode="aspectFill"></image>
</view>
<view class="bind-nickname">{{invitationUser.nickname}}</view>
<view class="bind-username">{{invitationUser.username}}</view>
</view>
</slot>
</u-modal>
</view>
</template>
<script>
import { info, chainSeed, relationsBind, relationsVerify } from '@/apis/interfaces/user';
import { payPassword } from '@/apis/interfaces/account.js'
import { getVersions } from '@/apis/interfaces/versions.js'
export default {
data() {
return {
cardText: [],
userInfo: {
nickname: '',
addr: '',
avatar: '',
isOpenVip: '',
},
identity: {
button_cover_url: '',
cover_url: '',
identity_text: ''
},
account: {
glz: 0.00,
dt: 0.00
},
mnemonic: '',
wordsShow: false,
order: {
init: 0,
paid: 0,
delivered: 0,
refund: 0
},
serial: '',
hasPassword: false,
showIv: false,
iv: '',
// 是否显示钱包
isWallet: false,
walletNum: 0,
// 数据看板权限
canSeeData: false,
messages:0,
wbtAccount:'',
wbtShow:false,
// 绑定关系
share : null,
showBind : false,
invitation : '',
isInvitation : true,
invitationUser : {},
collage_switch : false,
};
},
onShow() {
// if(uni.getStorageSync('isWalleNum') != '' && uni.getStorageSync('isWalleNum') === 1) this.isWallet = true
this.getInfo();
},
methods: {
onWbt(){
if(this.wbtAccount === ''){
uni.showModal({
title:'温馨提示',
content:'当前账号没有绑定文版通账号,是否现在就去绑定',
confirmText:'立即绑定',
cancelText:'先不绑定',
success:(res) => {
if(res.confirm){
this.$Router.push({name:'WbtBind'})
}
}
})
}else{
this.wbtShow = true;
}
},
// 绑定分享关系
onShare(){
if(this.share != null){
return
}
this.showBind = true
},
// 绑定邀请码
onBind(){
// 检验邀请码
if(this.isInvitation){
if(this.invitation === ''){
uni.showToast({
title: '请输入邀请码',
icon : 'none'
})
return
}
relationsVerify(this.invitation).then(res => {
this.invitationUser = res
this.isInvitation = false
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
return
}
// 绑定关系
relationsBind(this.invitation).then(res => {
this.showBind = false
uni.showModal({
title : '提示',
content : '关系绑定成功',
showCancel : false,
success : res => {
this.getInfo()
}
})
}).catch(err => {
uni.showToast({
title: err.message,
icon : 'none'
})
})
},
// 用户信息
getInfo() {
if (this.$store.state.token === '') return;
info().then(res => {
uni.setNavigationBarTitle({
title: res.nickname
});
this.share = String(res.share) == '' ? null : res.share
this.canSeeData = res.can_see_data
this.order = res.order
this.cardText = res.identity_array
this.userInfo = {
nickname: res.nickname,
addr: res.addr,
avatar: res.avatar,
isOpenVip: res.is_open_vip,
username: res.username
}
this.identity = res.identity;
this.account = res.account;
this.serial = res.serial;
this.hasPassword = res.has_transfer_password;
this.messages = Number(res.messages);
this.wbtAccount = res.wbt_account;
this.collage_switch = res.collage_switch;
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
});
});
},
// 导出助记词
onMnemonic() {
if (!this.hasPassword) {
uni.showModal({
title: '提示',
content: '暂未设置账户支付密码,无法导出助记词,请设置密码后重试',
cancelText: '稍后设置',
confirmText: '立即设置',
success: modalRes => {
if (modalRes.confirm) {
this.$Router.push({
name: 'AccountResetPassword',
params: {
phone: this.userInfo.username
}
})
return
}
this.showIv = false
}
})
return
}
this.showIv = true
},
resetPassword(){
this.$Router.push({
name: 'AccountResetPassword',
params: {
phone: this.userInfo.username
}
})
},
// 验证支付密码
validationIv() {
chainSeed({
transfer_password: this.iv
}).then(res => {
this.mnemonic = res.seed
this.showIv = false
this.wordsShow = true
this.iv = ''
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
},
mianze() {
uni.navigateTo({
url: 'pages/vip/agreement?id=7'
})
},
// 按钮导航
onBtn(name, params) {
this.$Router.push({
name,
params
});
},
// 退出登录
logOut() {
uni.removeStorageSync('isnew')
// uni.removeStorageSync('isWalleNum')
this.$store.commit('setToken', '');
this.$Router.replaceAll({
name: 'Auth'
})
},
// 复制
copy(data) {
uni.setClipboardData({
data: data,
success: function() {
uni.showToast({
title: '复制成功',
icon: 'none',
mask: true,
duration: 2000
})
}
});
},
// 连续点击
onNum() {
if (this.isWallet) {
return
}
this.walletNum++
this.$refs.onTimeCount.reset();
this.$refs.onTimeCount.start();
if (this.walletNum >= 7) {
uni.showToast({
title: '已开启共力钱包',
icon: 'none'
})
this.isWallet = true
this.walletNum = 0
this.$refs.onTimeCount.pause();
// uni.setStorageSync('isWalleNum', 1)
}
},
// 复制助记词
copyWord(type) {
uni.setClipboardData({
data: type === 'zjc'?this.mnemonic:this.wbtAccount,
success: () => {
this.wordsShow = false
this.wbtShow = false
uni.showToast({
title: type === 'zjc' ? '助记词已复制' : '文版通账号已复制',
icon: 'none',
mask: true
})
}
});
},
// 检查版本更新
updateApp() {
uni.showLoading({
title: '检查更新'
})
//#ifdef APP-PLUS
// 获取系统版本号
getVersions({
platform: plus.os.name,
version: plus.runtime.version
}).then(res => {
uni.hideLoading()
if (res.update) {
uni.showModal({
title: "更新提示",
content: res.note || '版本更新信息',
confirmText: "更新",
success: modalRes => {
if (modalRes.confirm) {
if (plus.os.name == "Android") {
uni.showToast({
title: '新版本下载中,将在下载完成后自动为您安装更新包',
icon: 'none'
})
uni.downloadFile({
url: res.info.download,
success: apkPick => {
plus.runtime.install(apkPick
.tempFilePath, '',
installRES => {
// 安装完成用于提示新版本引导,暂时无用
}, installERR => {
// 安装失败
})
},
fail(err) {
uni.showToast({
title: '安装包下载失败,请检查您的网络或稍后重试',
icon: 'none'
})
}
})
} else {
uni.showToast({
title: 'IOS应用暂未上架请打开测试(TestFlight)工具点击更新',
icon: 'none'
})
}
}
}
})
return
}
uni.showModal({
title: "提示",
content: "当前已是最新版本",
showCancel: false,
})
}).catch(err => {
uni.showToast({
title: err.message,
icon: 'none'
})
})
//#endif
}
}
};
</script>
<style lang="scss" scoped>
.onTime {
height: 0px;
overflow: hidden;
}
.content {
background: $window-color;
min-height: 100vh;
}
// 邀请码
.bind-view{
padding: 15rpx 30rpx;
width: 100%;
box-sizing: border-box;
.bind-title{
text-align: center;
font-size: 36rpx;
font-weight: bold;
}
.bind-subtitle{
line-height: 40rpx;
font-size: 28rpx;
color: gray;
padding-top: 15rpx;
text-align: center;
}
.bind-input{
padding-top: 30rpx;
input{
background: #f8f8f8;
width: 100%;
height: 80rpx;
padding: 0 30rpx;
border-radius: 40rpx;
text-align: center;
box-sizing: border-box;
font-size: 32rpx;
font-weight: bold;
}
}
}
// 确认绑定用户关系
.bind-user{
padding: 15rpx 30rpx;
width: 100%;
box-sizing: border-box;
.bind-title{
text-align: center;
font-size: 36rpx;
font-weight: bold;
}
.bind-subtitle{
line-height: 40rpx;
font-size: 28rpx;
color: gray;
padding-top: 15rpx;
text-align: center;
}
.bind-acitve{
text-align: center;
padding-top: 30rpx;
image{
width: 108rpx;
height: 108rpx;
background: #f8f8f8;
border-radius: 50%;
}
}
.bind-nickname{
text-align: center;
font-size: 32rpx;
color: #333;
font-weight: bold;
line-height: 40rpx;
padding-top: 20rpx;
}
.bind-username{
text-align: center;
font-weight: bold;
font-size: 28rpx;
color: gray;
}
}
// 版权信息
.footer-text {
text-align: center;
font-size: $title-size-sm;
padding: $padding $padding $padding * 2;
color: $text-gray-m;
}
// 用户信息
.info-box {
position: relative;
background: linear-gradient(to right, #34ce98, #22aa98);
color: white;
@extend .ios-top;
&>image {
position: absolute;
top: 0;
right: 0;
width: 100%;
height: 100%;
}
.user-flex {
position: relative;
padding: $padding * 2 $padding ($padding * 2 + 60);
height: 128rpx;
.news{
top: -30rpx;
right: -30rpx;
position: relative;
.bell_fill_dot{
position: absolute;
top: 24rpx;
right: 46rpx;
z-index: 1000;
}
.bell_fill{
position: absolute;
right: 50rpx;
top: 30rpx;
z-index: 10000000;
}
}
.cover {
position: absolute;
width: 128rpx;
height: 128rpx;
border-radius: 50%;
border: solid 6rpx white;
box-sizing: border-box;
z-index: 100;
background-color: #fff;
}
.user-content {
padding-left: 158rpx;
height: 160rpx;
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
.chainAddress {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
font-size: $title-size-m;
padding-top: 10rpx;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
position: relative;
z-index: 200;
}
.name {
line-height: 50rpx;
font-weight: bold;
font-size: $title-size + 8;
@extend .nowrap;
}
.tabs {
padding-top: 10rpx;
&-item {
background: rgba($color: #000000, $alpha: 0.3);
font-size: $title-size-sm - 4;
display: inline-block;
line-height: 36rpx;
padding: 0 20rpx;
border-radius: 20rpx;
image {
width: 38rpx;
height: 38rpx;
vertical-align: middle;
margin-bottom: 2rpx;
margin-right: 8rpx;
}
}
}
}
}
}
// 会员卡
.vip-card {
position: relative;
margin: -60rpx $margin $margin;
background: linear-gradient(to right bottom, #3e5364, #31364a);
border-radius: $radius;
box-sizing: border-box;
color: #fcc692;
padding: $padding ($padding + 170) $padding $padding;
.title {
font-weight: bold;
font-size: $title-size-lg;
line-height: 40rpx;
image {
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
vertical-align: middle;
margin-bottom: 4rpx;
}
}
.subtitle {
font-size: $title-size-sm;
margin-top: 10rpx;
.u-notice-bar {
padding: 0;
}
}
.btn {
position: absolute;
right: $margin;
margin-top: -30rpx;
top: 50%;
height: 60rpx;
line-height: 60rpx;
background: linear-gradient(to right, #fce3c5, #fcc590);
color: #31364a;
font-weight: bold;
width: 150rpx;
text-align: center;
font-size: $title-size-m;
border-radius: 30rpx;
}
}
// 订单信息
.order-box {
margin: $margin;
background: white;
border-radius: $radius;
display: flex;
justify-content: space-between;
&-item {
position: relative;
width: 25%;
padding: $padding $padding/2;
text-align: center;
.icon {
width: 48rpx;
height: 48rpx;
vertical-align: top;
}
.title {
font-size: $title-size-sm;
margin-top: $margin/3;
}
.number {
position: absolute;
top: 22rpx;
z-index: 2;
right: 20%;
background: $text-price;
color: white;
font-size: 22rpx;
min-width: 30rpx;
line-height: 30rpx;
border-radius: 50%;
}
}
}
// 健康数据
.health-flex {
display: flex;
margin: $margin ($margin - 10);
&-item {
margin: 0 10rpx;
background: white;
width: calc(50% - 20rpx);
border-radius: $radius;
padding: $padding;
box-sizing: border-box;
.title {
font-size: $title-size-lg;
.icon {
width: 32rpx;
height: 32rpx;
vertical-align: middle;
margin-left: 10rpx;
margin-bottom: 2rpx;
}
}
.num {
font-weight: bold;
font-size: $title-size + 10;
padding: $padding/3 0 0;
text {
font-size: 70%;
padding-left: 10rpx;
}
}
}
}
// 模块
.btns-box {
background: white;
margin: $margin;
border-radius: $radius;
&-item {
position: relative;
line-height: 90rpx;
padding: $padding * 0.6 $padding;
font-size: $title-size-lg;
&::after {
position: absolute;
height: 1rpx;
content: ' ';
left: $margin;
right: $margin;
bottom: 0;
background-color: #f9f9f9;
}
&:last-child::after {
display: none;
}
.forward {
position: absolute;
right: $margin;
}
.icon {
width: 44rpx;
height: 44rpx;
vertical-align: middle;
margin-right: $margin/2;
margin-bottom: 8rpx;
}
}
}
/* 助记词弹框 */
.wordsCont {
width: 100%;
position: relative;
text-align: center;
}
.wordsCont-title {
width: 100%;
font-weight: 600;
font-size: 44rpx;
}
.wordsCont-tips {
padding: 30rpx 0;
box-sizing: border-box;
color: #de5660;
line-height: 48rpx;
font-size: 30rpx;
}
.wordsCont-text {
font-weight: 500;
margin-top: 10rpx;
}
.wordsCont-close {
position: absolute;
top: 0;
right: 0;
width: 44rpx;
height: 44rpx;
}
</style>