Files
h5-uniapp/pages/index/index.vue
T
li 6b02df55ab feat: contract account tab, full i18n, male avatar, PC home stretch
- Asset page: add Contract account row + tab, show num_lh balance
- Total Assets = Spot + Contract + Fiat
- All Chinese text eliminated (z-paging, loadmore, colorui, pages)
- Password/payword pages use image captcha instead of OTP
- Home page PC: full-width stretch layout
- Register captcha input type fix, invite code lock
2026-04-05 13:05:27 +08:00

925 lines
22 KiB
Vue

<template>
<view>
<z-paging ref="paging" refresher-only @onRefresh="onRefresh" :style="'background-color: '+theme.bg+';color: '+theme.text">
<custom-refresher slot="refresher" slot-scope="{refresherStatus}" :status="refresherStatus">
</custom-refresher>
<!-- 头部 -->
<view class="width-750 relative flex align-center justify-center"
:style="{height: `calc(${statusBar}px + 110rpx)`,background:theme.bg,color:theme.text}">
<view class="width-750"
:style="{paddingTop: statusBar + 'px', height: `calc(${statusBar}px + 110rpx)`}">
<view class="width-750 height-110 padding-w-30 flex align-center justify-between">
<view @click="router.push('/pages/my/index')" class="flex align-center">
<u-icon name="account" color="#3c9cff" size="40"></u-icon>
</view>
<view class="flex align-center">
<image src="/static/imgs/index/logox.png" mode="heightFix" class="height-40"></image>
</view>
</view>
</view>
</view>
<!-- 身体 -->
<view class="width-750 padding-t-16 padding-b-40">
<!-- 轮播 -->
<view class="width-750 height-350 margin-b-24 padding-w-30">
<view class="swiper-container">
<u-swiper :list="swiperlist" height="350" img-mode="aspectFill" bg-color="transparent"></u-swiper>
</view>
</view>
<!-- 通知 -->
<view @click="router.push('/pages/index/notice')" class="width-750 height-80 padding-w-30 flex align-center justify-between notice-container" :style="'margin:0 30rpx 8rpx 30rpx'">
<view class="notice-left flex align-center">
<image class="notice-icon-left" src="/static/imgs/index/naba.png" mode="aspectFit"></image>
<u-notice-bar class="flex-1" type="none" mode="horizontal" :volume-icon="false"
:list="noticelist" color="#2C2C2C" speed="60"></u-notice-bar>
</view>
<view class="notice-right flex align-center justify-center">
<image class="notice-icon-right" src="/static/imgs/index/gonggao.png" mode="aspectFit"></image>
</view>
</view>
<!-- 功能区 -->
<view class="width-750 padding-14 flex align-center flex-wrap grid col-4 function-area" :style="'margin-top:2rpx'">
<view class="height-120 flex direction-column align-center justify-center"
@click="goURL(item)" v-for="(item,index) in operatelist" :key="index">
<view class="width-125 height-125 flex align-center justify-center function-icon">
<image class="width-100 height-100" :src="item.logo_image" mode=""></image>
</view>
<text class="font-24 margin-t-4 medium-font">{{item.name}}</text>
</view>
</view>
<view class="width-750 padding-t-24 padding-w-30 follow-section" :style="'margin:0 30rpx;border-radius:16rpx;width:690rpx;background-color:#FFFFFF'">
<view class="follow-header">
<text class="follow-title">{{i18n.index.focusMost}}</text>
<view class="follow-more" @click="goMarketMore">
<text class="follow-more-text">{{i18n.index.more}}</text>
<text class="follow-more-arrow">></text>
</view>
</view>
<view v-for="(item,index) in list" :key="index" class="follow-row" @click="gokline(item)">
<view class="follow-left">
<image class="follow-logo" :src="item.logo_image" mode="aspectFit"></image>
<view class="follow-pair">
<text class="follow-pair-text">{{item.name}}/USDT</text>
<text class="follow-sub">{{i18n.market.crypto}}</text>
</view>
</view>
<view class="follow-mid">
<text class="follow-price">{{Number(item.usdt).toFixed(2)}}</text>
<view class="follow-hot">
<image class="follow-hot-icon" src="/static/imgs/index/huo.png" mode="aspectFit"></image>
<text class="follow-hot-num">{{virtualFollowCount(item)}}</text>
</view>
</view>
<view class="follow-right">
<view class="follow-percent" :class="item.increase<0?'follow-percent-down':'follow-percent-up'">{{item.increase<0?'':'+'}}{{(item.increase*100).toFixed(2)}}%</view>
</view>
</view>
<view v-if="loading" class="width-100b padding-c-50 flex align-center justify-center">
<u-loading show mode="circle" size="40"></u-loading>
</view>
<view v-if="!loading&&list.length==0" class="width-100b padding-c-50 flex direction-column align-center justify-center">
<text class="font-28 nummedium-font">{{i18n.assets.index.nodata}}</text>
</view>
</view>
</view>
</z-paging>
</view>
</template>
<script>
// #ifdef APP-PLUS
import APPUpdate from '@/components/APPUpdate/js_sdk/appUpdate';
// #endif
export default {
data() {
return {
statusBar: uni.getSystemInfoSync().statusBarHeight,
userInfo: uni.getStorageSync('userinfo'),
searchVal: '',
swiperlist: [],
noticelist: [],
noticeid: [],
hotlist: [],
operatelist: [
// {
// name: 'C2C',
// imgs: '/static/imgs/index/c2c@2x.png',
// url: '/pages/index/c2c'
// },
// {
// name: 'ICO',
// imgs: '/static/imgs/index/ico@2x.png',
// url: '/pages/index/icoBuy'
// },
// {
// name: '锁仓',
// imgs: '/static/imgs/index/suocang@2x.png',
// url: '/pages/index/lockUp'
// },
// {
// name: '充币',
// imgs: '/static/imgs/index/chongbi@2x.png',
// url: '/pages/index/recharge'
// },
// {
// name: '提币',
// imgs: '/static/imgs/index/tibi@2x.png',
// url: '/pages/index/withdraw'
// },
// {
// name: '合约',
// imgs: '/static/imgs/index/heyue@2x.png',
// url: '/pages/contract/index'
// },
// {
// name: '量化',
// imgs: '/static/imgs/index/lianghua@2x.png',
// url: '/pages/quantify/index'
// },
// {
// name: '客服',
// imgs: '/static/imgs/index/kefu@2x.png',
// url: '/pages/kefu/kefu'
// },
],
currnow: 4, //1=涨,2=跌,3=成交,4=全部
list: [],
loading: true,
avatar: '',
midList: [],
show: false,
rotate: 0,
rotateTimer:null,
followTimer: null,
followInFlight: false,
virtualTick: 0,
tabClick: false,
theme:''
}
},
onLoad() {
this.getLeft()
// #ifdef APP-PLUS
APPUpdate();
// #endif
},
onTabItemTap(item) {
if (item.index == 0 && this.tabClick) { // 200ms 内再次点击
// 这里就是模拟的双击事件,可以写类似数据刷新相关处理
if(this.rotateTimer){
clearInterval(this.rotateTimer)
this.rotateTimer = null
}else{
this.rotateTimer = setInterval(() => {
if (this.rotate >= 360) {
this.rotate = 0
} else {
this.rotate += 1
}
}, 50)
}
}
this.tabClick = true
setTimeout(() => {
this.tabClick = false // 200ms 内没有第二次点击,就当作单击
}, 200)
},
computed: {
i18n() {
return this.$t('message');
}
},
onShow() {
this.theme = this.$store.state.lightTheme
if (typeof uni.setTabBarStyle === 'function') {
// 始终使用浅色主题的底部栏
const lightTheme = this.$store.state.lightTheme;
uni.setTabBarStyle({
selectedColor: '#007AFF',
backgroundColor: lightTheme.backgroundColor,
borderStyle: 'white',
borderColor: 'rgb(238, 238, 238)'
})
// tabbar多语言
uni.setTabBarItem({
index: 0,
text: this.i18n.tabBar.home,
selectedIconPath: lightTheme.selectedIconPath0,
});
uni.setTabBarItem({
index: 1,
text: this.i18n.tabBar.market,
selectedIconPath: lightTheme.selectedIconPath1
});
uni.setTabBarItem({
index: 2,
text: this.i18n.tabBar.cycle,
selectedIconPath: lightTheme.selectedIconPath2
});
uni.setTabBarItem({
index: 3,
text: this.i18n.tabBar.lever,
selectedIconPath: lightTheme.selectedIconPath3
});
uni.setTabBarItem({
index: 4,
text: this.i18n.tabBar.assets,
selectedIconPath: lightTheme.selectedIconPath4
});
}
this.getBanner()
this.getHotcurr()
this.startFollowRealTime()
this.getavatar()
this.getNotices()
this.getCate()
},
onHide() {
this.stopFollowRealTime()
},
onUnload() {
this.stopFollowRealTime()
},
methods: {
startFollowRealTime() {
this.stopFollowRealTime()
this.getPaihang()
this.virtualTick++
this.followTimer = setInterval(() => {
this.getPaihang()
this.virtualTick++
}, 3000)
},
stopFollowRealTime() {
if (this.followTimer) {
clearInterval(this.followTimer)
this.followTimer = null
}
this.followInFlight = false
},
onRefresh() {
this.midList = []
this.list = []
this.hotlist = []
this.swiperlist = []
this.noticelist = []
this.noticeid = []
this.getLeft()
this.getBanner()
this.getHotcurr()
this.getPaihang()
this.getNotices()
this.getCate()
// 以告知z-paging下拉刷新结束,这样才可以开始下一次的下拉刷新
setTimeout(() => {
//1.5秒之后停止刷新动画
this.$refs.paging.complete();
}, 1000)
},
searchCion() {
let inputWord = this.searchVal.toUpperCase()
let temp = this.midList.filter((item) => {
return inputWord == item.name
})
console.log(temp)
if (temp == '') {
this.tos(this.i18n.cycle.nodata)
} else {
this.gokline(temp[0])
}
},
// 获取币种列表
getLeft() {
this.post('/market/get_coin').then(res => {
if (res.code == 1) {
// console.log('币种列表', res)
this.midList = res.data.coin
}
})
},
// 改变功能区
changeoperate() {
this.operatelist[0].name = this.i18n.index.text1
this.operatelist[1].name = this.i18n.index.text2
this.operatelist[2].name = this.i18n.index.text3
this.operatelist[3].name = this.i18n.index.text4
this.operatelist[4].name = this.i18n.index.text5
this.operatelist[5].name = this.i18n.index.text6
this.operatelist[6].name = this.i18n.index.text7
this.operatelist[7].name = this.i18n.index.text8
},
// 获取首页菜单栏
getCate() {
this.post('/index/index_cate').then(res => {
console.log('首页菜单栏', res);
if (res.code == 1) {
const list = Array.isArray(res.data) ? res.data : []
const seen = new Set()
this.operatelist = list.filter((item) => {
if (!item) return false
const key = (item.url || '') || (item.name || '')
if (!key) return true
if (seen.has(key)) return false
seen.add(key)
return true
})
// 多语言翻译菜单名称
this.translateMenuNames()
}
})
},
// 翻译菜单项名称
translateMenuNames() {
const menuTranslations = {
'jp': {
'Deposit': '入金', 'Withdraw': '出金', 'Authentication': '本人確認',
'Live Agent': 'カスタマーサポート', 'Transfer': '振替', 'Contract': '契約',
'Recharge': '入金', 'Withdrawal': '出金', 'Quick Buy': 'クイック購入',
'Quantify': '自動売買', 'Customer Service': 'カスタマーサポート',
'C2C': 'C2C取引', 'ICO': 'ICO', 'Lock': 'ロック',
'Coin Transfer': '通貨振替', 'Market': '市場',
},
'zh-CN': {
'Deposit': '充值', 'Withdraw': '提现', 'Authentication': '实名认证',
'Live Agent': '在线客服', 'Transfer': '划转', 'Contract': '合约',
'Coin Transfer': '币币划转',
},
'kr': {
'Deposit': '입금', 'Withdraw': '출금', 'Authentication': '인증',
'Live Agent': '고객지원', 'Transfer': '이체', 'Contract': '계약',
'Coin Transfer': '코인 이체',
},
'fre': {
'Deposit': 'Dépôt', 'Withdraw': 'Retrait', 'Authentication': 'Vérification',
'Live Agent': 'Support', 'Transfer': 'Transfert',
'Coin Transfer': 'Transfert de devises',
},
'ger': {
'Deposit': 'Einzahlung', 'Withdraw': 'Auszahlung', 'Authentication': 'Verifizierung',
'Live Agent': 'Support', 'Transfer': 'Überweisung',
'Coin Transfer': 'Münztransfer',
},
'ily': {
'Deposit': 'Deposito', 'Withdraw': 'Prelievo', 'Authentication': 'Verifica',
'Live Agent': 'Supporto', 'Transfer': 'Trasferimento',
'Coin Transfer': 'Trasferimento valuta',
},
'mn': {
'Deposit': 'Орлого', 'Withdraw': 'Зарлага', 'Authentication': 'Баталгаажуулалт',
'Live Agent': 'Дэмжлэг', 'Transfer': 'Шилжүүлэг',
'Coin Transfer': 'Зоос шилжүүлэг',
},
'ms': {
'Deposit': 'Deposit', 'Withdraw': 'Pengeluaran', 'Authentication': 'Pengesahan',
'Live Agent': 'Sokongan', 'Transfer': 'Pindahan',
'Coin Transfer': 'Pemindahan syiling',
},
}
const lang = this.$i18n.locale || 'en-US'
// 英文也需要翻译部分菜单名
if (lang === 'en-US') {
const enMap = { 'Withdraw': 'Coin Transfer' }
this.operatelist.forEach(item => {
if (item && item.name && enMap[item.name]) {
item.name = enMap[item.name]
}
})
return
}
let langKey = lang
const map = menuTranslations[langKey]
if (!map) return
this.operatelist.forEach(item => {
if (item && item.name && map[item.name]) {
item.name = map[item.name]
}
})
},
// 去K线
gokline(item) {
// #ifdef H5
uni.navigateTo({
url: '/pages/tradingView/h5?title=' + item.coinname +'&bb_type='+item.bb_type+ '&symbol=' + item.symbol
})
// #endif
// #ifdef APP-PLUS
uni.navigateTo({
url: '/pages/tradingView/index?title=' + item.coinname +'&bb_type='+item.bb_type+ '&symbol=' + item.symbol+ '&close=' + item.usdt
})
// #endif
},
goMarketMore() {
uni.switchTab({
url: '/pages/index/hangqing'
})
},
virtualFollowCount(item) {
const key = String((item && (item.symbol || item.name)) || '')
const seed = Math.floor(this.virtualTick / 2)
let hash = 0
for (let i = 0; i < key.length; i++) {
hash = ((hash << 5) - hash) + key.charCodeAt(i)
hash |= 0
}
hash = ((hash << 5) - hash) + seed
hash |= 0
const base = Math.abs(hash) % 480
return base + 20
},
// 获取用户头像
getavatar() {
if (!uni.getStorageSync('token')) {
this.avatar = ''
return
}
this.post('/my/get_userinfo').then(res => {
if (res.code == 1) {
this.avatar = res.data.avatar
}
})
},
saoma() {
uni.scanCode({
success: function(res) {
// console.log('条码类型:' + res.scanType);
// console.log('条码内容:' + res.result);
uni.navigateTo({
url: '/pages/index/withdraw?type=saoma&result=' + res.result
})
}
});
},
// 获取排行榜
getPaihang() {
if (this.followInFlight) return
this.followInFlight = true
this.loading = true
this.post('/index/get_coin_increase', {
type: this.currnow
}).then(res => {
this.loading = false
// console.log('涨跌幅排行榜', res)
if (res.code == 1) {
this.list = res.data
}
}).finally(() => {
this.followInFlight = false
})
},
// 获取热门币种
getHotcurr() {
this.post('/index/get_hot_coin').then(res => {
// console.log('热门币种', res)
if (res.code == 1) {
this.hotlist = res.data
}
})
},
// 获取轮播图和滚动通知
getBanner() {
this.post('/index/get_banner').then(res => {
// console.log('轮播图', res)
if (res.code == 1) {
this.swiperlist = res.data.banner
}
})
},
//
goNoticedetails(e) {
console.log(e);
this.router.push('/pages/index/noticeDetails?id=' + this.noticeid[e])
},
// 获取滚动通知
getNotices() {
this.post('/index/message_list', {
page: 1,
}).then(res => {
// console.log('滚动通知', res)
if (res.code == 1) {
let data = res.data.data
this.noticelist = []
this.noticeid = []
data.forEach(item => {
this.noticelist.push(item.title)
this.noticeid.push(item.id)
})
}
})
},
// 跳转路由
goURL(item) {
if (item.open_status == 1) {
if (item.type == 1) {
if (item.types == 1) {
uni.navigateTo({
url: item.url
})
} else {
uni.switchTab({
url: item.url
})
}
} else {
// #ifdef APP-PLUS
plus.runtime.openURL(item.url)
// #endif
// #ifdef H5
window.location.replace(item.url)
// #endif
}
} else if (item.open_status == 2) {
this.tos(this.i18n.newWord.toOpen)
} else {
this.tos(this.i18n.newWord.no)
}
},
// 切换榜单
changeCurrnow(now) {
if (this.currnow != now) {
this.currnow = now
this.getPaihang()
}
},
}
}
</script>
<style lang="scss">
.fixed1 {
position: fixed;
top: 0;
z-index: 1000;
// background-color: #FFFFFF;
}
.kuaijieBG {
height: 142rpx;
// width: 362rpx;
// background-image: url('/static/imgs/index/kuaijie@2x.png');
// background-repeat: repeat;
// background-size: 100% 100%;
padding: 0rpx 32rpx 0rpx 180rpx;
position: relative;
}
.angelBG {
// background-image: url(../../static/imgs/index/angel@2x.png);
// background-repeat: repeat;
// background-size: 100% 100%;
height: 120rpx;
// width: 362rpx;
padding: 20rpx 0rpx 18rpx 30rpx;
display: flex;
flex-direction: column;
justify-content: space-between;
}
.searchbox {
width: 450rpx;
height: 64rpx;
// background: #F2F2F2;
border-radius: 100rpx;
padding: 0 20rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
}
.header-avatar {
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.1);
border: 2rpx solid #FFFFFF;
}
.lang-btn {
transition: all 0.3s;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
&:active {
transform: scale(0.95);
}
}
.notice-container {
margin: 0 30rpx;
width: 690rpx;
background: #EAF3FF;
border-radius: 16rpx;
padding: 0 20rpx;
}
.notice-left {
flex: 1;
min-width: 0;
display: flex;
align-items: center;
}
.notice-icon-left {
width: 34rpx;
height: 34rpx;
margin-right: 12rpx;
}
.notice-right {
width: 52rpx;
height: 52rpx;
border-radius: 50%;
}
.notice-icon-right {
width: 30rpx;
height: 30rpx;
}
.hot-coins-container {
margin: 20rpx 30rpx;
width: 690rpx;
height: auto;
}
.hot-coin-item {
flex: 1;
transition: all 0.3s;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
}
.follow-section {
margin: 0 30rpx;
width: 690rpx;
background: #FFFFFF;
border-radius: 16rpx;
overflow: hidden;
}
.follow-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 28rpx 0 12rpx;
}
.follow-title {
font-size: 32rpx;
font-weight: 800;
color: #111111;
}
.follow-more {
display: flex;
align-items: center;
gap: 6rpx;
}
.follow-more-text {
font-size: 22rpx;
color: #A0A0A0;
line-height: 1;
}
.follow-more-arrow {
font-size: 22rpx;
color: #A0A0A0;
line-height: 1;
}
.follow-row {
display: flex;
align-items: center;
justify-content: space-between;
padding: 18rpx 0;
}
.follow-left {
display: flex;
align-items: center;
gap: 16rpx;
flex: 1 1 45%;
min-width: 0;
}
.follow-logo {
width: 52rpx;
height: 52rpx;
flex: 0 0 52rpx;
}
.follow-pair {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 6rpx;
}
.follow-pair-text {
font-size: 28rpx;
font-weight: 800;
color: #111111;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.follow-sub {
font-size: 20rpx;
color: #B8B8B8;
line-height: 1.1;
}
.follow-mid {
flex: 0 0 170rpx;
display: flex;
flex-direction: column;
align-items: flex-end;
justify-content: center;
gap: 10rpx;
}
.follow-price {
font-size: 28rpx;
font-weight: 500;
color: #111111;
line-height: 1.1;
}
.follow-hot {
display: flex;
align-items: center;
gap: 8rpx;
color: #F49B2A;
}
.follow-hot-icon {
width: 24rpx;
height: 24rpx;
}
.follow-hot-num {
font-size: 20rpx;
line-height: 1;
}
.follow-right {
flex: 0 0 150rpx;
display: flex;
justify-content: flex-end;
}
.follow-percent {
min-width: 132rpx;
height: 54rpx;
padding: 0 14rpx;
border-radius: 10rpx;
color: #FFFFFF;
font-size: 24rpx;
font-weight: 600;
display: flex;
align-items: center;
justify-content: center;
}
.follow-percent-down {
background: #EA3943;
}
.follow-percent-up {
background: #16C784;
}
.function-icon {
transition: all 0.3s;
&:active {
transform: scale(0.95);
}
}
.quick-buy-container {
transition: all 0.3s;
&:active {
transform: scale(0.98);
}
}
.quick-buy-btn {
transition: all 0.3s;
&:active {
transform: scale(0.95);
}
}
.ranking-list {
overflow: hidden;
}
.ranking-tabs {
margin-bottom: 10rpx;
}
.ranking-active {
transition: all 0.3s;
}
.list-item {
transition: all 0.3s;
&:active {
background-color: rgba(0,0,0,0.02);
}
}
.coin-info {
display: flex;
align-items: center;
}
.percent-btn {
border-radius: 8rpx;
transition: all 0.3s;
box-shadow: 0 2rpx 5rpx rgba(0,0,0,0.1);
}
.border-0165EE {
border: 1rpx solid #0165EE;
}
.curron {
font-size: 28rpx;
font-weight: bold;
color: #FFFFFF;
}
.curroff {
font-size: 28rpx;
font-weight: 400;
color: #70767A;
}
.upbtn {
width: 148rpx;
height: 50rpx;
background: #06C38D;
border-radius: 8rpx;
line-height: 50rpx;
text-align: center;
font-size: 28rpx;
color: #FFFFFF;
}
.downbtn {
width: 148rpx;
height: 50rpx;
background: #DC4B43;
border-radius: 8rpx;
line-height: 50rpx;
text-align: center;
font-size: 28rpx;
color: #FFFFFF;
}
.swiper-container {
width: 100%;
height: 100%;
border-radius: 16rpx;
overflow: hidden;
}
/* 隐藏轮播图指示器 */
.swiper-container ::v-deep .u-swiper-indicator {
display: none !important;
}
/* ========== PC 端适配 — 全宽拉伸 ========== */
@media screen and (min-width: 768px) {
.width-750 {
width: 100% !important;
max-width: 100% !important;
}
.notice-container {
width: calc(100% - 60px) !important;
max-width: 100% !important;
margin: 0 30px 8px 30px !important;
}
.follow-section {
width: calc(100% - 60px) !important;
max-width: 100% !important;
margin: 0 30px !important;
}
.function-area {
width: 100% !important;
max-width: 100% !important;
}
.swiper-container {
width: 100% !important;
max-width: 100% !important;
}
}
</style>