commit 5c9aca27e834d213956bb06fb3b529dbf275ec8c
Author: zhouyanli <593579392@qq.com>
Date: Tue Oct 27 13:54:39 2026 +0800
first commit
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..b6a9009
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = tab
+indent_size = 4
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f0cf1f3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+unpackage/
+.DS_Store
+.hbuilderx/
diff --git a/App.vue b/App.vue
new file mode 100644
index 0000000..35788a2
--- /dev/null
+++ b/App.vue
@@ -0,0 +1,67 @@
+
+
+
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fbefd6a
--- /dev/null
+++ b/README.md
@@ -0,0 +1,52 @@
+# 宠物智能项圈 · 芝麻免押小程序
+
+支付宝小程序(uni-app + Vue3),只承载**芝麻信用免押**这一段流程;添加设备、查看宠物数据等其他操作都在宠物 App 内完成。
+
+页面与组件统一用 Vue3 `
+
+
diff --git a/components/rental-info/rental-info.vue b/components/rental-info/rental-info.vue
new file mode 100644
index 0000000..6607437
--- /dev/null
+++ b/components/rental-info/rental-info.vue
@@ -0,0 +1,96 @@
+
+
+
+ 租赁物品
+ {{ itemName }}
+
+
+ 押金
+
+ 免押金
+ {{ depositAmount }}
+ 元
+
+
+
+
+
+
+
+
diff --git a/config/index.js b/config/index.js
new file mode 100644
index 0000000..6eb8421
--- /dev/null
+++ b/config/index.js
@@ -0,0 +1,36 @@
+/**
+ * 全局业务配置
+ *
+ * 本小程序只负责「芝麻信用免押」这一段流程:
+ * 下单页 → 支付宝原生授权页(支付宝提供)→ 免押结果页 → 押金状态页
+ * 添加设备、查看宠物数据等其他操作都在宠物 App 内完成。
+ */
+const config = {
+ // 品牌信息
+ brandName: '宠物智能项圈',
+ brandLogo: '/static/logo.png',
+
+ // 租赁物品与押金,仅用于页面展示,真实金额以服务端下单结果为准
+ itemName: '宠物智能项圈',
+ depositAmount: 69,
+
+ // 服务端接口
+ apiBaseUrl: 'https://api.example.com',
+ // 服务端未就绪时用本地 mock 跑通前端流程,联调时改成 false
+ useMock: true,
+
+ // 宠物 App:添加设备等操作回去做
+ petApp: {
+ // 唤起 App 的地址,需在支付宝开放平台报备后才可用(如 universal link)
+ openUrl: '',
+ // 唤起失败时给用户复制的下载地址
+ downloadUrl: ''
+ },
+
+ // 协议页面(当前是本地占位页,正式文本请替换为芝麻信用官方协议地址)
+ agreements: {
+ credit: '/pages/agreement/agreement'
+ }
+}
+
+export default config
diff --git a/docs/api.md b/docs/api.md
new file mode 100644
index 0000000..39f5bcd
--- /dev/null
+++ b/docs/api.md
@@ -0,0 +1,87 @@
+# 免押订单接口约定(给服务端)
+
+小程序端只负责展示和拉起支付宝原生授权页,**所有芝麻信用相关调用、密钥、加签、异步通知都在服务端**。
+前端目前走 `config/index.js` 的 `useMock: true` 本地 mock,服务端就绪后改 `false` 即可切到下面这套接口。
+
+统一返回体:
+
+```json
+{ "code": 0, "message": "", "data": {} }
+```
+
+`code` 为 `0` 表示成功,非 0 时把 `message` 直接弹给用户。
+
+## 1. 创建免押订单
+
+```
+POST /api/credit/orders
+```
+
+请求:
+
+```json
+{
+ "itemName": "宠物智能项圈",
+ "depositAmount": 69
+}
+```
+
+服务端要做的事:调芝麻信用开放接口创建信用借还订单,把支付宝返回的信用借还单号一并下发。
+
+响应:
+
+```json
+{
+ "orderId": "CO20261027120000",
+ "creditBorrowOrderId": "ZM20261027120000"
+}
+```
+
+`creditBorrowOrderId` 是小程序拉起原生授权页时唯一要用的参数(见 `utils/zhima.js`)。
+
+## 2. 查询订单
+
+```
+GET /api/credit/orders/{orderId}
+```
+
+响应(字段与 mock 对齐):
+
+```json
+{
+ "orderId": "CO20261027120000",
+ "itemName": "宠物智能项圈",
+ "depositAmount": 69,
+ "depositMode": "CREDIT",
+ "status": "ACTIVE",
+ "createdAt": 1761537600000
+}
+```
+
+- `depositMode`:`CREDIT` 信用免押 / `PAID` 现场付押金
+- `status`:`PENDING` 授权中 / `ACTIVE` 免押生效 / `RELEASED` 已解除 / `OVERDUE` 逾期未还
+
+免押结果页会轮询这个接口(约 1.2 秒一次、最多 6 次)确认最终状态,**不要**用客户端回调直接判定成功。
+
+## 3. 最近一单
+
+```
+GET /api/credit/orders/latest
+```
+
+无订单时返回 `null`(`data: null`)。
+
+## 4. 解除信用授权 / 退还押金
+
+```
+POST /api/credit/orders/{orderId}/release
+```
+
+服务端调芝麻接口结束信用订单,并同步完成押金/履约处理;返回更新后的订单对象。
+
+## 服务端必须兜住的几件事
+
+1. **异步通知(notify)验签 + 幂等**:芝麻的授权结果、订单完结等以 notify 为准,重复通知只处理一次。
+2. **信用闭环回传**:订单生成、逾期、归还完结都要真实回传支付宝,不能造数据。
+3. **密钥不下发**:加签私钥、商户 ID 只留服务端,小程序只拿 `orderId` / `creditBorrowOrderId`。
+4. **接口名以开通后的文档为准**:芝麻信用「信用借还」的具体开放接口名、参数随能力开通版本变化,本仓库没有硬编码,集中在 `utils/zhima.js` 与本文档两处待替换。
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..bfb9a1b
--- /dev/null
+++ b/index.html
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/main.js b/main.js
new file mode 100644
index 0000000..3ac0c69
--- /dev/null
+++ b/main.js
@@ -0,0 +1,24 @@
+import App from './App'
+
+// #ifndef VUE3
+import Vue from 'vue'
+import './uni.promisify.adaptor'
+Vue.config.productionTip = false
+App.mpType = 'app'
+const app = new Vue({
+ ...App
+})
+app.$mount()
+// #endif
+
+// #ifdef VUE3
+import {
+ createSSRApp
+} from 'vue'
+export function createApp() {
+ const app = createSSRApp(App)
+ return {
+ app
+ }
+}
+// #endif
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..b395b5c
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,71 @@
+{
+ "name" : "chongdun-mianya",
+ "appid" : "__UNI__2A0D116",
+ "description" : "",
+ "versionName" : "1.0.0",
+ "versionCode" : "100",
+ "transformPx" : false,
+ /* 5+App特有相关 */
+ "app-plus" : {
+ "usingComponents" : true,
+ "nvueStyleCompiler" : "uni-app",
+ "compilerVersion" : 3,
+ "splashscreen" : {
+ "alwaysShowBeforeRender" : true,
+ "waiting" : true,
+ "autoclose" : true,
+ "delay" : 0
+ },
+ /* 模块配置 */
+ "modules" : {},
+ /* 应用发布信息 */
+ "distribute" : {
+ /* android打包配置 */
+ "android" : {
+ "permissions" : [
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ ""
+ ]
+ },
+ /* ios打包配置 */
+ "ios" : {},
+ /* SDK配置 */
+ "sdkConfigs" : {}
+ }
+ },
+ /* 快应用特有相关 */
+ "quickapp" : {},
+ /* 小程序特有相关 */
+ "mp-weixin" : {
+ "appid" : "",
+ "setting" : {
+ "urlCheck" : false
+ },
+ "usingComponents" : true
+ },
+ "mp-alipay" : {
+ /* 在支付宝开放平台创建小程序后,把 appid 填到这里 */
+ "appid" : "",
+ "usingComponents" : true
+ },
+ "mp-baidu" : {
+ "usingComponents" : true
+ },
+ "mp-toutiao" : {
+ "usingComponents" : true
+ },
+ "vueVersion" : "3"
+}
diff --git a/pages.json b/pages.json
new file mode 100644
index 0000000..1947f29
--- /dev/null
+++ b/pages.json
@@ -0,0 +1,49 @@
+{
+ //pages数组中第一项表示应用启动页
+ "pages": [
+ {
+ "path": "pages/index/index",
+ "style": {
+ // 支付宝端靠 transparentTitle + titlePenetrate 实现自定义头部,
+ // navigationStyle: custom 只在微信/H5 生效
+ "navigationStyle": "custom",
+ "transparentTitle": "always",
+ "titlePenetrate": "YES",
+ "navigationBarTitleText": "",
+ "navigationBarTextStyle": "white"
+ }
+ },
+ {
+ "path": "pages/result/result",
+ "style": {
+ "navigationStyle": "custom",
+ "transparentTitle": "always",
+ "titlePenetrate": "YES",
+ "navigationBarTitleText": "",
+ "navigationBarTextStyle": "white"
+ }
+ },
+ {
+ "path": "pages/deposit/deposit",
+ "style": {
+ "navigationStyle": "custom",
+ "transparentTitle": "always",
+ "titlePenetrate": "YES",
+ "navigationBarTitleText": "",
+ "navigationBarTextStyle": "white"
+ }
+ },
+ {
+ "path": "pages/agreement/agreement",
+ "style": {
+ "navigationBarTitleText": "芝麻信用协议及授权条款"
+ }
+ }
+ ],
+ "globalStyle": {
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": "宠物智能项圈免押",
+ "navigationBarBackgroundColor": "#FFFFFF",
+ "backgroundColor": "#FFFFFF"
+ }
+}
diff --git a/pages/agreement/agreement.vue b/pages/agreement/agreement.vue
new file mode 100644
index 0000000..bbef51a
--- /dev/null
+++ b/pages/agreement/agreement.vue
@@ -0,0 +1,78 @@
+
+
+ 芝麻信用协议及授权条款
+ 更新日期:2026-10-27
+
+
+ 一、授权范围
+
+ 用户同意本小程序在办理宠物智能项圈租赁免押时,向芝麻信用查询用户的信用评估结果,
+ 用于判断是否免除押金。用户可随时在支付宝「芝麻信用 - 我的 - 信用管理」中查看或解除授权。
+
+
+
+
+ 二、免押与履约
+
+ 免押租赁期间,用户应按约定时间归还设备并保证设备完好。逾期未归还或设备损坏的,
+ 按门店租赁规则处理,并可能影响用户的芝麻信用记录。
+
+
+
+
+ 三、信息使用
+
+ 本小程序仅将信用评估结果用于本次免押判断,不会用于与租赁无关的用途,
+ 相关信息的存储与保护遵循法律法规及芝麻信用平台规则。
+
+
+
+ 注:以上为占位文本,正式上线前需替换为经法务/芝麻信用确认的协议全文。
+
+
+
+
diff --git a/pages/deposit/deposit.vue b/pages/deposit/deposit.vue
new file mode 100644
index 0000000..f35f6f8
--- /dev/null
+++ b/pages/deposit/deposit.vue
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+ 暂无押金订单
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/index/index.vue b/pages/index/index.vue
new file mode 100644
index 0000000..eeb9386
--- /dev/null
+++ b/pages/index/index.vue
@@ -0,0 +1,181 @@
+
+
+
+
+
+
+
+
+ {{ brandName }}
+
+
+
+
+
+
+
+
+
+
+ 我已阅读并同意
+ 《芝麻信用协议及授权条款》
+
+
+
+ 注:请记得归还物品哦,以免对你的信用产生影响
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/result/result.vue b/pages/result/result.vue
new file mode 100644
index 0000000..b508d7a
--- /dev/null
+++ b/pages/result/result.vue
@@ -0,0 +1,121 @@
+
+
+
+
+
+
+
+
+ 成功
+ 免押申请成功
+ 订单状态确认中,稍后可在支付宝订单中查看
+
+
+
+
+
+
+
+
+
+
+
diff --git a/static/logo.png b/static/logo.png
new file mode 100644
index 0000000..2876961
Binary files /dev/null and b/static/logo.png differ
diff --git a/uni.promisify.adaptor.js b/uni.promisify.adaptor.js
new file mode 100644
index 0000000..92ea3cf
--- /dev/null
+++ b/uni.promisify.adaptor.js
@@ -0,0 +1,14 @@
+uni.addInterceptor({
+ returnValue(res) {
+ if (!(!!res && (typeof res === "object" || typeof res === "function") && typeof res.then ===
+ "function")) {
+ return res;
+ }
+ return new Promise((resolve, reject) => {
+ res.then((res) => {
+ if (!res) return resolve(res)
+ return res[0] ? reject(res[0]) : resolve(res[1])
+ });
+ });
+ },
+});
diff --git a/uni.scss b/uni.scss
new file mode 100644
index 0000000..b9249e9
--- /dev/null
+++ b/uni.scss
@@ -0,0 +1,76 @@
+/**
+ * 这里是uni-app内置的常用样式变量
+ *
+ * uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
+ * 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
+ *
+ */
+
+/**
+ * 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
+ *
+ * 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
+ */
+
+/* 颜色变量 */
+
+/* 行为相关颜色 */
+$uni-color-primary: #007aff;
+$uni-color-success: #4cd964;
+$uni-color-warning: #f0ad4e;
+$uni-color-error: #dd524d;
+
+/* 文字基本颜色 */
+$uni-text-color:#333;//基本色
+$uni-text-color-inverse:#fff;//反色
+$uni-text-color-grey:#999;//辅助灰色,如加载更多的提示信息
+$uni-text-color-placeholder: #808080;
+$uni-text-color-disable:#c0c0c0;
+
+/* 背景颜色 */
+$uni-bg-color:#ffffff;
+$uni-bg-color-grey:#f8f8f8;
+$uni-bg-color-hover:#f1f1f1;//点击状态颜色
+$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
+
+/* 边框颜色 */
+$uni-border-color:#c8c7cc;
+
+/* 尺寸变量 */
+
+/* 文字尺寸 */
+$uni-font-size-sm:12px;
+$uni-font-size-base:14px;
+$uni-font-size-lg:16px;
+
+/* 图片尺寸 */
+$uni-img-size-sm:20px;
+$uni-img-size-base:26px;
+$uni-img-size-lg:40px;
+
+/* Border Radius */
+$uni-border-radius-sm: 2px;
+$uni-border-radius-base: 3px;
+$uni-border-radius-lg: 6px;
+$uni-border-radius-circle: 50%;
+
+/* 水平间距 */
+$uni-spacing-row-sm: 5px;
+$uni-spacing-row-base: 10px;
+$uni-spacing-row-lg: 15px;
+
+/* 垂直间距 */
+$uni-spacing-col-sm: 4px;
+$uni-spacing-col-base: 8px;
+$uni-spacing-col-lg: 12px;
+
+/* 透明度 */
+$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
+
+/* 文章场景相关 */
+$uni-color-title: #2C405A; // 文章标题颜色
+$uni-font-size-title:20px;
+$uni-color-subtitle: #555555; // 二级标题颜色
+$uni-font-size-subtitle:26px;
+$uni-color-paragraph: #3F536E; // 文章段落颜色
+$uni-font-size-paragraph:15px;
diff --git a/utils/pet-app.js b/utils/pet-app.js
new file mode 100644
index 0000000..21dd7f3
--- /dev/null
+++ b/utils/pet-app.js
@@ -0,0 +1,71 @@
+import config from '@/config'
+
+/**
+ * 小程序内不做添加设备,只负责把用户交回宠物 App。
+ * 支付宝小程序无法直接拉起任意第三方 App,openUrl 需要在开放平台报备后才能用,
+ * 所以默认走「提示 + 复制下载链接」的兜底。
+ */
+
+function copyText(text) {
+ uni.setClipboardData({
+ data: text,
+ success: () => uni.showToast({ title: '链接已复制', icon: 'none' })
+ })
+}
+
+function tryOpenUrl(url) {
+ if (!url) return false
+ try {
+ // #ifdef MP-ALIPAY
+ if (typeof my !== 'undefined' && my.ap && typeof my.ap.openURL === 'function') {
+ my.ap.openURL({ url, fail: () => {} })
+ return true
+ }
+ // #endif
+ // #ifdef H5
+ window.location.href = url
+ return true
+ // #endif
+ } catch (e) {
+ // 忽略,走兜底
+ }
+ return false
+}
+
+export function openPetApp() {
+ const { openUrl, downloadUrl } = config.petApp
+ const content = '添加设备、绑定项圈需要在宠物 App 内完成。'
+
+ if (openUrl && downloadUrl) {
+ uni.showModal({
+ title: '前往宠物 App 添加设备',
+ content,
+ confirmText: '打开 App',
+ cancelText: '复制链接',
+ success: (res) => {
+ if (res.confirm && tryOpenUrl(openUrl)) return
+ copyText(downloadUrl)
+ }
+ })
+ return
+ }
+
+ if (downloadUrl) {
+ uni.showModal({
+ title: '前往宠物 App 添加设备',
+ content: `${content}是否复制 App 下载链接?`,
+ confirmText: '复制链接',
+ success: (res) => {
+ if (res.confirm) copyText(downloadUrl)
+ }
+ })
+ return
+ }
+
+ uni.showModal({
+ title: '前往宠物 App 添加设备',
+ content,
+ showCancel: false,
+ confirmText: '我知道了'
+ })
+}
diff --git a/utils/request.js b/utils/request.js
new file mode 100644
index 0000000..c6976ce
--- /dev/null
+++ b/utils/request.js
@@ -0,0 +1,33 @@
+import config from '@/config'
+
+/**
+ * 服务端请求封装
+ *
+ * 约定返回体:{ code: 0, message: '', data: {...} }
+ * code 为 0 或未返回时视为成功,data 直接透出。
+ */
+export function request({ url, method = 'GET', data = {}, header = {} }) {
+ return new Promise((resolve, reject) => {
+ uni.request({
+ url: /^https?:\/\//.test(url) ? url : config.apiBaseUrl + url,
+ method,
+ data,
+ header: {
+ 'Content-Type': 'application/json',
+ ...header
+ },
+ success: (res) => {
+ const body = res.data || {}
+ const ok = res.statusCode >= 200 && res.statusCode < 300
+ if (ok && (body.code === undefined || body.code === 0)) {
+ resolve(body.data !== undefined ? body.data : body)
+ return
+ }
+ reject(new Error(body.message || `请求失败(${res.statusCode})`))
+ },
+ fail: (err) => {
+ reject(new Error(err.errMsg || '网络异常,请稍后重试'))
+ }
+ })
+ })
+}
diff --git a/utils/zhima.js b/utils/zhima.js
new file mode 100644
index 0000000..d55557e
--- /dev/null
+++ b/utils/zhima.js
@@ -0,0 +1,32 @@
+import config from '@/config'
+
+/**
+ * 拉起支付宝原生「信用免押」授权页(截图第 2、3 屏,页面由支付宝提供)。
+ *
+ * 小程序端能做的只有把服务端创建好的信用借还单号交给支付宝,
+ * 具体调用方式以开通芝麻信用能力后的开放平台文档为准,统一收在这一个函数里替换,
+ * 避免接口名散落在页面中。
+ */
+export function authorizeCreditBorrow({ orderId, creditBorrowOrderId }) {
+ if (config.useMock) {
+ // mock:模拟用户在原生授权页点了「同意」
+ return new Promise((resolve) => setTimeout(() => resolve({ authorized: true }), 600))
+ }
+
+ const inAlipay = typeof my !== 'undefined'
+ const canBorrow = inAlipay && my.zmCreditBorrow && typeof my.zmCreditBorrow === 'function'
+
+ if (!canBorrow) {
+ return Promise.reject(new Error('当前环境不支持芝麻信用免押,请用支付宝扫码打开'))
+ }
+
+ return new Promise((resolve, reject) => {
+ my.zmCreditBorrow({
+ creditBorrowOrderId,
+ // 注意:授权成功回调只代表用户点了同意,免押是否真正生效
+ // 以服务端收到芝麻异步通知后的订单状态为准
+ success: () => resolve({ authorized: true }),
+ fail: (err) => reject(new Error((err && err.errorMessage) || '免押授权未完成'))
+ })
+ })
+}