first commit
This commit is contained in:
78
pages/agreement/agreement.vue
Normal file
78
pages/agreement/agreement.vue
Normal file
@@ -0,0 +1,78 @@
|
||||
<template>
|
||||
<view class="agreement-page">
|
||||
<view class="title">芝麻信用协议及授权条款</view>
|
||||
<view class="update">更新日期:2026-10-27</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">一、授权范围</view>
|
||||
<view class="paragraph">
|
||||
用户同意本小程序在办理宠物智能项圈租赁免押时,向芝麻信用查询用户的信用评估结果,
|
||||
用于判断是否免除押金。用户可随时在支付宝「芝麻信用 - 我的 - 信用管理」中查看或解除授权。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">二、免押与履约</view>
|
||||
<view class="paragraph">
|
||||
免押租赁期间,用户应按约定时间归还设备并保证设备完好。逾期未归还或设备损坏的,
|
||||
按门店租赁规则处理,并可能影响用户的芝麻信用记录。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view class="section-title">三、信息使用</view>
|
||||
<view class="paragraph">
|
||||
本小程序仅将信用评估结果用于本次免押判断,不会用于与租赁无关的用途,
|
||||
相关信息的存储与保护遵循法律法规及芝麻信用平台规则。
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="placeholder">注:以上为占位文本,正式上线前需替换为经法务/芝麻信用确认的协议全文。</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
.agreement-page {
|
||||
padding: 40rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.update {
|
||||
margin-top: 12rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
.section {
|
||||
margin-top: 40rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
margin-bottom: 16rpx;
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.paragraph {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.8;
|
||||
color: #555555;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
margin-top: 60rpx;
|
||||
padding: 24rpx;
|
||||
border-radius: 12rpx;
|
||||
background: #f5f7fa;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
93
pages/deposit/deposit.vue
Normal file
93
pages/deposit/deposit.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<credit-header title="押金" :show-badge="false"></credit-header>
|
||||
|
||||
<view v-if="order" class="info-section">
|
||||
<rental-info
|
||||
:item-name="order.itemName"
|
||||
:deposit-amount="order.depositAmount"
|
||||
:credit-free="order.depositMode === 'CREDIT'"
|
||||
></rental-info>
|
||||
</view>
|
||||
<view v-else class="empty">暂无押金订单</view>
|
||||
|
||||
<view class="bottom-bar">
|
||||
<button class="btn-primary" :disabled="releasing || !order" @tap="handleRelease">
|
||||
{{ releasing ? '处理中...' : '解除信用授权/退还押金' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { getOrder, getLatestOrder, releaseCreditOrder } from '@/api/order'
|
||||
|
||||
const orderId = ref('')
|
||||
const order = ref(null)
|
||||
const releasing = ref(false)
|
||||
|
||||
onLoad((query) => {
|
||||
orderId.value = (query && query.orderId) || ''
|
||||
loadOrder()
|
||||
})
|
||||
|
||||
async function loadOrder() {
|
||||
try {
|
||||
order.value = orderId.value ? await getOrder(orderId.value) : await getLatestOrder()
|
||||
} catch (error) {
|
||||
order.value = null
|
||||
}
|
||||
}
|
||||
|
||||
function handleRelease() {
|
||||
if (!order.value || releasing.value) return
|
||||
uni.showModal({
|
||||
title: '解除信用授权',
|
||||
content: '解除后本次免押将不再有效,押金按门店规则处理,确认继续?',
|
||||
confirmText: '确认解除',
|
||||
confirmColor: '#1E6BFF',
|
||||
success: (res) => {
|
||||
if (res.confirm) doRelease()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function doRelease() {
|
||||
releasing.value = true
|
||||
uni.showLoading({ title: '处理中', mask: true })
|
||||
try {
|
||||
await releaseCreditOrder(order.value.orderId)
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: '已解除信用授权', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({ url: '/pages/index/index' })
|
||||
}, 1200)
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: error.message || '操作失败,请稍后重试', icon: 'none' })
|
||||
} finally {
|
||||
releasing.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding-bottom: 220rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.empty {
|
||||
padding-top: 120rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
181
pages/index/index.vue
Normal file
181
pages/index/index.vue
Normal file
@@ -0,0 +1,181 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<credit-header title="信用免押金" :show-badge="true" curved></credit-header>
|
||||
|
||||
<view class="brand-card">
|
||||
<image class="brand-logo" :src="brandLogo" mode="aspectFit"></image>
|
||||
</view>
|
||||
|
||||
<view class="brand-name">{{ brandName }}</view>
|
||||
|
||||
<view class="info-section">
|
||||
<rental-info :item-name="itemName" :deposit-amount="depositAmount" credit-free></rental-info>
|
||||
</view>
|
||||
|
||||
<view class="agreement" @tap="toggleAgree">
|
||||
<view class="checkbox" :class="{ checked: agreed }">
|
||||
<view v-if="agreed" class="checkbox-check"></view>
|
||||
</view>
|
||||
<view class="agreement-text">
|
||||
我已阅读并同意
|
||||
<text class="agreement-link" @tap.stop="openAgreement">《芝麻信用协议及授权条款》</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tip">注:请记得归还物品哦,以免对你的信用产生影响</view>
|
||||
|
||||
<view class="bottom-bar">
|
||||
<button class="btn-primary" :disabled="submitting" @tap="handleContinue">
|
||||
{{ submitting ? '处理中...' : '继续' }}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import config from '@/config'
|
||||
import { createCreditOrder, syncOrderStatus } from '@/api/order'
|
||||
import { authorizeCreditBorrow } from '@/utils/zhima'
|
||||
|
||||
const brandName = config.brandName
|
||||
const brandLogo = config.brandLogo
|
||||
const itemName = config.itemName
|
||||
const depositAmount = config.depositAmount
|
||||
|
||||
const agreed = ref(false)
|
||||
const submitting = ref(false)
|
||||
|
||||
function toggleAgree() {
|
||||
agreed.value = !agreed.value
|
||||
}
|
||||
|
||||
function openAgreement() {
|
||||
uni.navigateTo({ url: config.agreements.credit })
|
||||
}
|
||||
|
||||
async function handleContinue() {
|
||||
if (submitting.value) return
|
||||
if (!agreed.value) {
|
||||
uni.showToast({ title: '请先阅读并同意协议', icon: 'none' })
|
||||
return
|
||||
}
|
||||
|
||||
submitting.value = true
|
||||
try {
|
||||
// 1. 服务端创建免押订单,同时向芝麻创建信用借还订单
|
||||
uni.showLoading({ title: '创建订单中', mask: true })
|
||||
const order = await createCreditOrder({
|
||||
itemName,
|
||||
depositAmount
|
||||
})
|
||||
|
||||
// 2. 拉起支付宝原生授权页
|
||||
uni.hideLoading()
|
||||
await authorizeCreditBorrow(order)
|
||||
|
||||
// 3. 以服务端订单状态为准:真实环境靠芝麻异步通知回写
|
||||
uni.showLoading({ title: '确认免押中', mask: true })
|
||||
await syncOrderStatus(order.orderId)
|
||||
uni.hideLoading()
|
||||
|
||||
uni.redirectTo({ url: `/pages/result/result?orderId=${order.orderId}` })
|
||||
} catch (error) {
|
||||
uni.hideLoading()
|
||||
uni.showToast({ title: error.message || '免押开通失败,请重试', icon: 'none' })
|
||||
} finally {
|
||||
submitting.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding-bottom: 220rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
/* 卡片压在蓝色头部与白色内容交界处,对应截图里的悬浮效果 */
|
||||
.brand-card {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 200rpx;
|
||||
height: 200rpx;
|
||||
margin: -120rpx auto 0;
|
||||
border-radius: 32rpx;
|
||||
background: #ffffff;
|
||||
box-shadow: 0 12rpx 40rpx rgba(0, 0, 0, 0.12);
|
||||
}
|
||||
|
||||
.brand-logo {
|
||||
width: 140rpx;
|
||||
height: 140rpx;
|
||||
}
|
||||
|
||||
.brand-name {
|
||||
margin-top: 32rpx;
|
||||
text-align: center;
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.info-section {
|
||||
margin-top: 72rpx;
|
||||
}
|
||||
|
||||
.agreement {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin: 48rpx 40rpx 0;
|
||||
}
|
||||
|
||||
.checkbox {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32rpx;
|
||||
height: 32rpx;
|
||||
margin-top: 4rpx;
|
||||
border: 2rpx solid #c9cdd4;
|
||||
border-radius: 50%;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.checkbox.checked {
|
||||
border-color: #1e6bff;
|
||||
background: #1e6bff;
|
||||
}
|
||||
|
||||
.checkbox-check {
|
||||
width: 12rpx;
|
||||
height: 6rpx;
|
||||
margin-top: -4rpx;
|
||||
border-left: 2rpx solid #ffffff;
|
||||
border-bottom: 2rpx solid #ffffff;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.agreement-text {
|
||||
margin-left: 14rpx;
|
||||
font-size: 26rpx;
|
||||
line-height: 1.5;
|
||||
color: #333333;
|
||||
}
|
||||
|
||||
.agreement-link {
|
||||
color: #1e6bff;
|
||||
}
|
||||
|
||||
.tip {
|
||||
margin: 20rpx 40rpx 0 86rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
121
pages/result/result.vue
Normal file
121
pages/result/result.vue
Normal file
@@ -0,0 +1,121 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<credit-header title="信用免押金" :show-badge="true"></credit-header>
|
||||
|
||||
<view class="result">
|
||||
<view class="success-icon">
|
||||
<view class="success-check"></view>
|
||||
</view>
|
||||
<view class="result-title">成功</view>
|
||||
<view class="result-desc">免押申请成功</view>
|
||||
<view v-if="pollDone && !confirmed" class="result-hint">订单状态确认中,稍后可在支付宝订单中查看</view>
|
||||
</view>
|
||||
|
||||
<view class="bottom-bar">
|
||||
<button class="btn-primary" @tap="goAddDevice">前往添加设备</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import { onLoad, onUnload } from '@dcloudio/uni-app'
|
||||
import { getOrder } from '@/api/order'
|
||||
import { openPetApp } from '@/utils/pet-app'
|
||||
|
||||
const orderId = ref('')
|
||||
const confirmed = ref(false)
|
||||
const pollDone = ref(false)
|
||||
|
||||
let pollTimes = 0
|
||||
let pollTimer = null
|
||||
|
||||
onLoad((query) => {
|
||||
orderId.value = (query && query.orderId) || ''
|
||||
loadOrder()
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
if (pollTimer) clearTimeout(pollTimer)
|
||||
})
|
||||
|
||||
async function loadOrder() {
|
||||
if (!orderId.value) return
|
||||
try {
|
||||
const order = await getOrder(orderId.value)
|
||||
confirmed.value = !!order && order.status === 'ACTIVE'
|
||||
} catch (error) {
|
||||
// 查询失败不打断展示,状态可在支付宝订单详情中查看
|
||||
}
|
||||
|
||||
if (confirmed.value) return
|
||||
if (pollTimes < 6) {
|
||||
pollTimes += 1
|
||||
pollTimer = setTimeout(loadOrder, 1200)
|
||||
} else {
|
||||
pollDone.value = true
|
||||
}
|
||||
}
|
||||
|
||||
// 添加设备在宠物 App 内完成,小程序只做交接
|
||||
function goAddDevice() {
|
||||
openPetApp()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding-bottom: 220rpx;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.result {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
padding-top: 120rpx;
|
||||
}
|
||||
|
||||
.success-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(180deg, #4a90ff 0%, #1e6bff 100%);
|
||||
box-shadow: 0 16rpx 40rpx rgba(30, 107, 255, 0.28);
|
||||
}
|
||||
|
||||
.success-check {
|
||||
width: 62rpx;
|
||||
height: 34rpx;
|
||||
margin-top: -10rpx;
|
||||
border-left: 8rpx solid #ffffff;
|
||||
border-bottom: 8rpx solid #ffffff;
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.result-title {
|
||||
margin-top: 48rpx;
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #1a1a1a;
|
||||
}
|
||||
|
||||
.result-desc {
|
||||
margin-top: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #666666;
|
||||
}
|
||||
|
||||
.result-hint {
|
||||
margin-top: 24rpx;
|
||||
padding: 0 64rpx;
|
||||
text-align: center;
|
||||
font-size: 24rpx;
|
||||
line-height: 1.6;
|
||||
color: #999999;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user