2024-12-18 15:46:27 +08:00
|
|
|
|
<script setup>
|
2025-02-19 16:54:49 +08:00
|
|
|
|
/**
|
|
|
|
|
* 榴莲首页
|
|
|
|
|
*/
|
|
|
|
|
import {
|
|
|
|
|
useStore,
|
|
|
|
|
} from 'vuex'
|
|
|
|
|
import {
|
|
|
|
|
onMounted,
|
|
|
|
|
ref,
|
|
|
|
|
reactive,
|
|
|
|
|
computed,
|
|
|
|
|
getCurrentInstance,
|
|
|
|
|
watch,
|
|
|
|
|
defineExpose,
|
|
|
|
|
} from 'vue';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
onLoad,
|
|
|
|
|
onReady,
|
|
|
|
|
onHide,
|
|
|
|
|
} from '@dcloudio/uni-app'
|
|
|
|
|
// 未登录
|
|
|
|
|
import noLogin from '@/components/login/noLogin.vue'
|
|
|
|
|
// 工具库
|
|
|
|
|
import util from '@/common/js/util.js'
|
|
|
|
|
// 进度
|
|
|
|
|
import task from '@/components/index/task'
|
|
|
|
|
// 接口
|
|
|
|
|
import api from '@/api/index.js'
|
|
|
|
|
// 二级支付
|
|
|
|
|
import payPwd from '@/components/mine/payPwd.vue'
|
|
|
|
|
const {
|
|
|
|
|
proxy
|
|
|
|
|
} = getCurrentInstance()
|
|
|
|
|
// 仓库
|
|
|
|
|
const store = useStore()
|
|
|
|
|
// 互转表单
|
|
|
|
|
const form = reactive({
|
|
|
|
|
// 交易对方的用户ID
|
|
|
|
|
targetUserId: '',
|
|
|
|
|
// 账户
|
|
|
|
|
account: '',
|
|
|
|
|
// 榴莲果数量
|
|
|
|
|
fruitAmount: '',
|
|
|
|
|
// 姓名首字
|
|
|
|
|
first: '',
|
|
|
|
|
// 姓名
|
|
|
|
|
name: '',
|
|
|
|
|
//
|
|
|
|
|
secondPassword: '',
|
|
|
|
|
})
|
|
|
|
|
//读秒记录
|
|
|
|
|
const viewData = ref({
|
|
|
|
|
seconds: 0
|
|
|
|
|
})
|
|
|
|
|
// 用户信息
|
|
|
|
|
const userinfo = computed(() => {
|
|
|
|
|
return store.state.userinfo
|
|
|
|
|
})
|
|
|
|
|
// 进度条
|
|
|
|
|
const progress = computed(() => {
|
|
|
|
|
let result = viewData.value.seconds
|
|
|
|
|
result = Math.min(Number(result), 100)
|
|
|
|
|
return result
|
|
|
|
|
})
|
|
|
|
|
// 我的钱包
|
|
|
|
|
const purse = computed(() => {
|
|
|
|
|
return store.state.purse || {}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// 榴莲果配置
|
|
|
|
|
const configData = reactive({
|
|
|
|
|
minConsumption: '',
|
|
|
|
|
platformPercentage: ''
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onReady(() => {
|
|
|
|
|
// proxy.$refs.dealRef.open()
|
|
|
|
|
// proxy.$refs.payPwdRef.open()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
onLoad(() => {
|
|
|
|
|
// 获取钱包
|
|
|
|
|
util.getPurse()
|
|
|
|
|
|
|
|
|
|
getConfig()
|
|
|
|
|
})
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 榴莲果交易
|
|
|
|
|
function handleSubmit() {
|
|
|
|
|
// 验证必填项
|
|
|
|
|
if (!form.account) {
|
|
|
|
|
util.alert('请输入账号')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!form.fruitAmount) {
|
|
|
|
|
util.alert('请输入榴莲果转账数量')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 验证添加最低金额限制
|
|
|
|
|
const min = parseFloat(configData.minConsumption)
|
|
|
|
|
const price = parseFloat(form.fruitAmount)
|
|
|
|
|
if (price < min) {
|
|
|
|
|
util.alert(`榴莲果最低${min}起转`)
|
2025-01-04 20:33:45 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2025-02-19 16:54:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据账号查询用户id
|
|
|
|
|
api.mine.getUserDataByAccount({
|
|
|
|
|
query: {
|
|
|
|
|
account: form.account,
|
|
|
|
|
},
|
|
|
|
|
}).then(rs => {
|
|
|
|
|
if (rs.code === 200) {
|
|
|
|
|
const result = rs.data
|
|
|
|
|
// 交易对方的id
|
|
|
|
|
form.targetUserId = result.userName
|
|
|
|
|
form.name = result.userRealName.slice(1, result.userRealName.length)
|
|
|
|
|
// 打开姓名校验
|
|
|
|
|
proxy.$refs.payee.open()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
util.alert({
|
|
|
|
|
content: rs.msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
2025-01-04 20:33:45 +08:00
|
|
|
|
})
|
2025-01-04 01:44:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 验证真实姓名
|
|
|
|
|
function handlePayeeConfirm() {
|
|
|
|
|
// 验证必填项
|
|
|
|
|
if (!form.first) {
|
|
|
|
|
util.alert('请输入对方姓名首字母')
|
2025-01-04 20:33:45 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2025-02-19 16:54:49 +08:00
|
|
|
|
|
|
|
|
|
api.durian.nameComparison({
|
|
|
|
|
query: {
|
|
|
|
|
// 对方账号
|
|
|
|
|
account: form.account,
|
|
|
|
|
// 对方姓名
|
|
|
|
|
name: `${form.first}${form.name}`,
|
|
|
|
|
}
|
|
|
|
|
}).then(rs => {
|
|
|
|
|
if (rs.code == 200) {
|
|
|
|
|
if (rs.data) proxy.$refs.payPwdRef.open()
|
2025-02-19 18:02:15 +08:00
|
|
|
|
else {
|
|
|
|
|
util.alert({
|
|
|
|
|
content: '姓名不匹配',
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
|
|
|
|
form.first = ''
|
|
|
|
|
}
|
2025-02-19 16:54:49 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
util.alert({
|
|
|
|
|
content: rs.msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
2025-01-04 20:33:45 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
/**
|
|
|
|
|
* 交易
|
|
|
|
|
* @param {Object} ev 二级密码
|
|
|
|
|
*/
|
|
|
|
|
function handlePwdConfirm(ev) {
|
|
|
|
|
// 验证必填项
|
|
|
|
|
if (!form.first) {
|
|
|
|
|
util.alert('请输入对方姓名首字母')
|
|
|
|
|
return
|
2025-01-04 20:33:45 +08:00
|
|
|
|
}
|
2025-02-19 16:54:49 +08:00
|
|
|
|
if (!form.account) {
|
|
|
|
|
util.alert('请输入账号')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!form.fruitAmount) {
|
|
|
|
|
util.alert('请输入榴莲果转账数量')
|
2025-01-04 20:33:45 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 榴莲果交易
|
|
|
|
|
api.durian.consume({
|
|
|
|
|
data: {
|
|
|
|
|
// 更新用户信息
|
|
|
|
|
userId: userinfo.value.id,
|
|
|
|
|
// 交易对方的用户id
|
|
|
|
|
targetUserId: form.targetUserId,
|
|
|
|
|
// 交易类型
|
|
|
|
|
transactionType: 10,
|
|
|
|
|
// 榴莲果交易数量
|
|
|
|
|
fruitAmount: form.fruitAmount,
|
2025-02-19 18:02:15 +08:00
|
|
|
|
// 交易值
|
|
|
|
|
totalAmount: form.fruitAmount,
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 对方姓名
|
|
|
|
|
name: `${form.first}${form.name}`,
|
|
|
|
|
// 对方账号
|
|
|
|
|
account: form.account,
|
|
|
|
|
// 二级密码
|
|
|
|
|
secondPassword: ev
|
|
|
|
|
}
|
|
|
|
|
}).then(rs => {
|
|
|
|
|
if (rs.code === 200) {
|
2025-02-19 18:02:15 +08:00
|
|
|
|
form.fruitAmount = ''
|
|
|
|
|
form.account = ''
|
|
|
|
|
form.first = ''
|
|
|
|
|
proxy.$refs.dealRef.close()
|
|
|
|
|
proxy.$refs.payee.close()
|
2025-02-19 16:54:49 +08:00
|
|
|
|
//
|
|
|
|
|
util.getPurse()
|
2025-02-19 18:02:15 +08:00
|
|
|
|
//
|
|
|
|
|
util.alert('转让成功')
|
2025-02-19 16:54:49 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
util.alert({
|
|
|
|
|
content: rs.msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-02-18 11:38:36 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 跳转
|
2025-03-04 09:03:08 +08:00
|
|
|
|
function link(path) {
|
2025-02-19 16:54:49 +08:00
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url: path
|
|
|
|
|
})
|
|
|
|
|
}
|
2025-02-18 11:38:36 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 榴莲果配置
|
|
|
|
|
function getConfig() {
|
|
|
|
|
api.durian.durianFruitConfig().then(rs => {
|
|
|
|
|
if (rs.code == 200) {
|
|
|
|
|
configData.minConsumption = rs.data.minConsumption
|
|
|
|
|
configData.platformPercentage = +rs.data.platformPercentage * 100
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
util.alert({
|
|
|
|
|
content: rs.msg,
|
|
|
|
|
showCancel: false,
|
|
|
|
|
})
|
2025-01-02 01:01:23 +08:00
|
|
|
|
})
|
2025-02-19 16:54:49 +08:00
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
2024-12-31 14:46:56 +08:00
|
|
|
|
<view class="page" v-if="!userinfo.id">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<noLogin class="f1" />
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="appbw plr30" v-else>
|
|
|
|
|
|
|
|
|
|
<!-- 有效读秒 -->
|
|
|
|
|
<view class="task mtb30">
|
|
|
|
|
<task />
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 树苗 -->
|
|
|
|
|
<view class="sapling bgColor mtb30 ptb15 plr30">
|
|
|
|
|
<view class="df">
|
2025-03-04 09:03:08 +08:00
|
|
|
|
<view class="f1 fmid" @click="link('/pages/index/seedLog')">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<image class="wh110" src="/static/sapling.png" mode="aspectFit" />
|
|
|
|
|
</view>
|
|
|
|
|
<view class="f1 fmid">
|
2025-02-18 11:38:36 +08:00
|
|
|
|
<view class=" f38 b wsn">* {{ purse.seed }}</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 说明 -->
|
|
|
|
|
<view class="explain ptb30 plr30 bgColor">
|
|
|
|
|
<view class="df">
|
|
|
|
|
<view class="list f1 fmid">
|
|
|
|
|
<view class="item ver f1">
|
|
|
|
|
<image class="wh300" src="/static/tree.png" mode="aspectFit" />
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="df fdc jcsa f1">
|
2025-03-04 09:03:08 +08:00
|
|
|
|
<view class="button btn colourful plr30" @click="link('/pages/index/orchard')">置换</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-03-04 09:03:08 +08:00
|
|
|
|
<view class="button btn colourful plr30 fmid" @click="link('/pages/index/durainActivation')">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<view class="">我的榴莲果树</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 榴莲果专区 -->
|
|
|
|
|
<view class="durianSection bgColor mtb30 ptb30 plr30">
|
|
|
|
|
<!-- <image class="fruit" src="/static/fruit.png" mode="aspectFit" /> -->
|
|
|
|
|
<view class="df mlr30">
|
|
|
|
|
<view class="ver f1">
|
|
|
|
|
<navigator url="/pages/index/durianLog" hover-class="none">
|
|
|
|
|
<image class="fruit wh150" src="/static/fruit.png" mode="aspectFit" />
|
|
|
|
|
<view class="mt30 f20">
|
2025-02-18 11:38:36 +08:00
|
|
|
|
<view class=" f1 b">可用: {{ purse.fruit }}</view>
|
|
|
|
|
<view class="cFF4242 f1 mt10">待释放: {{ purse.fruitFrozen }}</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
</navigator>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="notice df fdc jcsa aic f1">
|
2025-01-02 01:01:23 +08:00
|
|
|
|
<view class="item ver f1" @click="$refs.dealRef.open()">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<view class="key fmid c333 f24">互转</view>
|
|
|
|
|
<!-- <view class="value mt5 c333 f20">销毁30%</view> -->
|
|
|
|
|
</view>
|
2025-03-04 09:03:08 +08:00
|
|
|
|
<view class="item ver f1 mt30" @click="link('/pages/index/trade')">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<view class="key fmid c333 f24">交易</view>
|
|
|
|
|
<!-- <view class="value mt5 c333 f20">求购 出售</view> -->
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
2025-03-04 09:03:08 +08:00
|
|
|
|
<view class="btn plus black mt60 mlr60" @click="link('/pages/index/dataCenter/push')">置换流量</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="fill" style="height: 60rpx;"></view>
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<!-- 互转 -->
|
|
|
|
|
<uni-popup ref="dealRef" type="center">
|
|
|
|
|
<view class="dealAlt popMid ptb40 plr60 bfff br30">
|
2025-02-19 16:54:49 +08:00
|
|
|
|
<view class="title thd tac c333 f32"> 当前可用榴莲果 {{purse.fruit}}</view>
|
|
|
|
|
<view class="content rows mtb30">
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<image class="wh140" src="/static/fruit.png" mode="aspectFit" />
|
|
|
|
|
<image class="wh70" src="/static/dealMid.png" mode="aspectFit" />
|
|
|
|
|
<image class="wh140" src="/static/dealUser.png" mode="aspectFit" />
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="inputBox mtb20 plr30">
|
2025-01-04 20:33:45 +08:00
|
|
|
|
<input v-model.trim="form.account" type="text" placeholder="输入对方账号" />
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
2025-01-04 20:33:45 +08:00
|
|
|
|
|
2024-12-18 15:46:27 +08:00
|
|
|
|
<view class="inputBox mtb20 plr30">
|
2025-01-04 20:33:45 +08:00
|
|
|
|
<input v-model.trim="form.fruitAmount" type="number" placeholder="输入数量" />
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
2025-01-04 20:33:45 +08:00
|
|
|
|
<view class="hint mtb30 tac f22">
|
2025-02-18 11:38:36 +08:00
|
|
|
|
<view>销毁{{ configData.platformPercentage }}%</view>
|
|
|
|
|
<view>(最低{{ configData.minConsumption }}起转)</view>
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
2025-01-04 20:33:45 +08:00
|
|
|
|
<view class="button btn lg bar black" @click="handleSubmit">转移</view>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-popup>
|
|
|
|
|
|
|
|
|
|
<!-- 收款方 -->
|
|
|
|
|
<uni-popup ref="payee" type="center">
|
|
|
|
|
<view class="payee popMid ver ptb40 plr60 bfff br30">
|
|
|
|
|
<view class="title tac c333 f28">收款方确认</view>
|
|
|
|
|
|
|
|
|
|
<view class="mtb20 f28">请补全对方姓名首字,以防转错</view>
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
<view class="inputEdit rows mauto mtb20 plr30">
|
|
|
|
|
<input class="first side" v-model.trim="form.first" type="text" placeholder="" />
|
|
|
|
|
<view class="mlr20">*</view>
|
|
|
|
|
<view class="side tar">
|
|
|
|
|
<text v-if="0">{{ form.name }}</text>
|
|
|
|
|
</view>
|
2025-01-04 20:33:45 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
<view class="rows mt50">
|
|
|
|
|
<view class="btn sm cancel plr40" @click="$refs.payee.close()">取消</view>
|
|
|
|
|
<view class="btn sm black plr40" @click="handlePayeeConfirm">验证</view>
|
|
|
|
|
</view>
|
|
|
|
|
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</view>
|
|
|
|
|
</uni-popup>
|
2025-01-04 20:33:45 +08:00
|
|
|
|
|
|
|
|
|
<!-- 二级支付 -->
|
|
|
|
|
<payPwd ref="payPwdRef" @confirm="handlePwdConfirm" />
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2025-02-19 16:54:49 +08:00
|
|
|
|
//
|
|
|
|
|
.board {
|
|
|
|
|
background-image: linear-gradient(103deg, #27EFE2 0%, #A45EFF 43%, #FF004F 100%);
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 背景颜色
|
|
|
|
|
.bgColor {
|
|
|
|
|
background-color: #FFFBF3;
|
|
|
|
|
border-radius: 20rpx;
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
.explain {
|
|
|
|
|
.button {
|
|
|
|
|
width: 250rpx;
|
|
|
|
|
margin-left: 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 树苗
|
|
|
|
|
.sapling {
|
|
|
|
|
.button {
|
|
|
|
|
width: 300rpx;
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 榴莲果专区
|
|
|
|
|
.durianSection {
|
|
|
|
|
|
|
|
|
|
// 须知
|
|
|
|
|
.notice {
|
|
|
|
|
|
|
|
|
|
.key {
|
|
|
|
|
width: 140rpx;
|
|
|
|
|
height: 70rpx;
|
|
|
|
|
color: #fff;
|
|
|
|
|
background: linear-gradient(99deg, #27efe2 0%, #a45eff 43%, #ff004f 100%), linear-gradient(108deg, #d7f550 -2%, #afef4d 98%);
|
|
|
|
|
border-radius: 100rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
}
|
2025-01-04 20:33:45 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
//
|
|
|
|
|
.dealAlt {
|
|
|
|
|
.hint {
|
|
|
|
|
color: #3d3d3d;
|
|
|
|
|
opacity: .7;
|
|
|
|
|
}
|
2025-02-18 11:38:36 +08:00
|
|
|
|
}
|
2025-01-04 20:33:45 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 支付
|
|
|
|
|
.payee {
|
2025-02-19 18:02:15 +08:00
|
|
|
|
|
2025-02-19 16:54:49 +08:00
|
|
|
|
// 侧边
|
|
|
|
|
.side {
|
|
|
|
|
width: 80rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
.first {
|
|
|
|
|
padding: 20rpx;
|
|
|
|
|
background-color: #f4f4f4;
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
}
|
2025-01-04 20:33:45 +08:00
|
|
|
|
}
|
2024-12-18 15:46:27 +08:00
|
|
|
|
</style>
|