jiuyiUniapp/jiuyi2/pages/mine/setting/binding.vue

158 lines
3.2 KiB
Vue
Raw Normal View History

2024-12-29 19:06:34 +08:00
<script setup>
// 我的绑定
import {
ref,
computed,
2025-01-06 14:04:49 +08:00
getCurrentInstance,
reactive
2024-12-29 19:06:34 +08:00
} from 'vue'
import {
onLoad,
onReady,
} from '@dcloudio/uni-app'
// 工具库
import util from '@/common/js/util.js'
2025-01-06 14:04:49 +08:00
//
import api from '@/api/index.js'
2024-12-29 19:06:34 +08:00
const {
proxy
} = getCurrentInstance()
2025-01-06 14:04:49 +08:00
// 绑定的信息
const detail = reactive({
wechatId: '',
alipayId: '',
})
2024-12-29 19:06:34 +08:00
// 绑定的项
const bindItem = ref({})
// 用户信息
const userinfo = computed(() => {
let result = store.state.userinfo
return result
})
// 绑定列表
const bindList = computed(() => {
let result = [{
2025-01-06 14:04:49 +08:00
key: 'wechatId',
2024-12-29 19:06:34 +08:00
img: '/static/wx.png',
name: '微信号',
2025-01-06 14:04:49 +08:00
value: detail.wechatId,
2024-12-29 19:06:34 +08:00
},
{
2025-01-06 14:04:49 +08:00
key: 'alipayId',
2024-12-29 19:06:34 +08:00
img: '/static/shop-alipay-payment.png',
name: '支付宝号',
2025-01-06 14:04:49 +08:00
value: detail.alipayId,
2024-12-29 19:06:34 +08:00
}
]
return result
})
2025-01-06 14:04:49 +08:00
onLoad(() => {
// 获取绑定的信息
getDetail()
2024-12-29 19:06:34 +08:00
})
2025-01-06 14:04:49 +08:00
// 获取绑定的信息
function getDetail() {
api.mine.getBindAccount().then(rs => {
if (rs.code == 200) {
// 详情
Object.assign(detail, rs.data)
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2024-12-29 19:06:34 +08:00
// 点击项
function handleItem(item) {
bindItem.value = item
proxy.$refs.bind.open()
}
2025-01-06 14:04:49 +08:00
// 绑定支付宝号
function handleSubmit() {
// 验证必填项
if (!bindItem.value.name) {
util.alert(`${bindItem.name}不能为空`)
return
}
// 提交
const data = {}
// 添加提交数据
data[bindItem.value.key] = bindItem.value.value
//
api.mine.bindAccount({
data,
}).then(rs => {
if (rs.code == 200) {
2025-02-21 17:56:36 +08:00
uni.$emit('updateBindingAccount')
2025-01-06 14:04:49 +08:00
//
detail[bindItem.value.key] = bindItem.value.value
//
proxy.$refs.bind.close()
return
}
util.alert({
content: rs.msg,
showCancel: false,
})
})
}
2024-12-29 19:06:34 +08:00
</script>
<template>
<view class="app">
<view class="container">
<view class="line rows mtb30 mlr30 ptb40 plr30 bfff br20" v-for="(item,index) in bindList" :key="index"
@click="handleItem(item)">
<image class="wh80" :src="item.img" mode="aspectFit" />
<view class="f1 ml20">
<view class="key f32">{{item.name}}</view>
<view class="content mt10 c999 f26">
2025-01-06 14:04:49 +08:00
<text v-if="item.value != ''">{{item.value}}</text>
2024-12-29 19:06:34 +08:00
<text v-else>未绑定</text>
</view>
</view>
</view>
</view>
2025-01-06 14:04:49 +08:00
</view>
2024-12-29 19:06:34 +08:00
2025-01-06 14:04:49 +08:00
<!-- 绑定弹窗 -->
<uni-popup ref="bind" type="bottom">
<view class="bindAlt popBot plr30 bfff">
<view class="header rows mtb30">
<view class="">
<text v-if="detail[bindItem.key]">修改</text>
<text v-else>绑定</text>
<text>{{bindItem.name}}</text>
2024-12-29 19:06:34 +08:00
</view>
2025-01-06 14:04:49 +08:00
</view>
2024-12-29 19:06:34 +08:00
2025-01-06 14:04:49 +08:00
<view class="inputBox mtb30 ptb10 plr20">
<input type="text" v-model="bindItem.value" placeholder="请输入" />
</view>
2024-12-29 19:06:34 +08:00
2025-02-28 13:15:03 +08:00
<view class="hint mtb30 c999 f26">免责声明请核对信息后进行绑定因信息错误产生问题后果责任由用户您本人自行承担</view>
2024-12-29 19:06:34 +08:00
2025-01-06 14:04:49 +08:00
<view class="btn bar black mtb30" @click="handleSubmit">添加</view>
</view>
</uni-popup>
2024-12-29 19:06:34 +08:00
</template>
2025-01-06 14:04:49 +08:00
<style lang="scss" scoped>
// 绑定弹窗
2024-12-29 19:06:34 +08:00
.bindAlt {
2025-01-06 14:04:49 +08:00
// 提示
2024-12-29 19:06:34 +08:00
.hint {
color: #aa3333;
}
}
</style>