From 5c5cddb1c2ee0d19adddebaf3a3a10a6d93fd2ad Mon Sep 17 00:00:00 2001
From: wlzboy <66905212@qq.com>
Date: 星期日, 26 十月 2025 10:52:18 +0800
Subject: [PATCH] feat:优化微信小程序可以运行
---
app/pages/mine/index.vue | 77 +++++++++++++++++++++++++++++++++-----
1 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/app/pages/mine/index.vue b/app/pages/mine/index.vue
index e936762..48b20a6 100644
--- a/app/pages/mine/index.vue
+++ b/app/pages/mine/index.vue
@@ -80,6 +80,18 @@
<view>缂栬緫璧勬枡</view>
</view>
</view>
+ <view class="list-cell list-cell-arrow" @click="handleUserAgreement">
+ <view class="menu-item-box">
+ <view class="iconfont icon-text menu-icon"></view>
+ <view>鐢ㄦ埛鏈嶅姟鍗忚</view>
+ </view>
+ </view>
+ <view class="list-cell list-cell-arrow" @click="handlePrivacyPolicy">
+ <view class="menu-item-box">
+ <view class="iconfont icon-safe menu-icon"></view>
+ <view>闅愮鏀跨瓥</view>
+ </view>
+ </view>
<view class="list-cell list-cell-arrow" @click="handleHelp">
<view class="menu-item-box">
<view class="iconfont icon-help menu-icon"></view>
@@ -106,13 +118,15 @@
<script>
import storage from '@/utils/storage'
import { getUserProfile } from "@/api/system/user"
+ import { getUserBoundVehicle, unbindVehicleFromUser } from '@/api/vehicle'
export default {
data() {
return {
- name: this.$store.state.user.name,
+ name: this.$store.state.user.nickName,
phonenumber: '',
- boundVehicle: '', // 妯℃嫙缁戝畾鐨勮溅杈嗕俊鎭�
+ boundVehicle: '', // 缁戝畾鐨勮溅杈嗕俊鎭�
+ boundVehicleId: null, // 缁戝畾鐨勮溅杈咺D
version: getApp().globalData.config.appInfo.version
}
},
@@ -130,18 +144,35 @@
methods: {
// 鑾峰彇鐢ㄦ埛淇℃伅
getUserInfo() {
+ const userId = this.$store.state.user.userId
+
+ // 鑾峰彇鐢ㄦ埛鍩烘湰淇℃伅
getUserProfile().then(response => {
const user = response.data
this.name = user.userName
this.phonenumber = user.phonenumber
- // 妯℃嫙缁戝畾杞﹁締淇℃伅锛屽疄闄呴」鐩腑搴斾粠鐢ㄦ埛淇℃伅鎴栬溅杈嗘帴鍙h幏鍙�
- this.boundVehicle = '绮12345'
}).catch(() => {
// 鑾峰彇鐢ㄦ埛淇℃伅澶辫触鏃朵娇鐢ㄩ粯璁ゅ��
- this.name = this.$store.state.user.name || '鏈櫥褰�'
+ this.name = this.$store.state.user.nickName || '鏈櫥褰�'
this.phonenumber = '鏈粦瀹�'
- this.boundVehicle = '鏈粦瀹�'
})
+
+ // 鑾峰彇鐢ㄦ埛缁戝畾鐨勮溅杈嗕俊鎭�
+ if (userId) {
+ getUserBoundVehicle(userId).then(response => {
+ if (response.code === 200 && response.data) {
+ const vehicle = response.data
+ this.boundVehicle = vehicle.vehicleNumber || '鏈煡杞︾墝'
+ this.boundVehicleId = vehicle.vehicleId
+ } else {
+ this.boundVehicle = '鏈粦瀹�'
+ this.boundVehicleId = null
+ }
+ }).catch(() => {
+ this.boundVehicle = '鏈粦瀹�'
+ this.boundVehicleId = null
+ })
+ }
},
// 璺宠浆鍒扮粦瀹氳溅杈嗛〉闈�
@@ -151,10 +182,30 @@
// 鍙栨秷缁戝畾杞﹁締
unbindVehicle() {
- this.$modal.confirm('鏄惁鍙栨秷缁戝畾杞﹁締锛�').then(() => {
- // 杩欓噷鍙互璋冪敤API鍙栨秷缁戝畾杞﹁締
- this.boundVehicle = '鏈粦瀹�'
- this.$modal.showToast('鍙栨秷缁戝畾鎴愬姛')
+ const userId = this.$store.state.user.userId
+ const vehicleId = this.boundVehicleId
+
+ if (!userId || !vehicleId) {
+ this.$modal.showToast('鏃犳硶鑾峰彇缁戝畾淇℃伅')
+ return
+ }
+
+ this.$modal.confirm(`纭鍙栨秷缁戝畾杞﹁締 ${this.boundVehicle} 鍚楋紵`).then(() => {
+ // 璋冪敤API鍙栨秷缁戝畾杞﹁締
+ unbindVehicleFromUser(userId, vehicleId).then(response => {
+ if (response.code === 200) {
+ this.boundVehicle = '鏈粦瀹�'
+ this.boundVehicleId = null
+ this.$modal.showToast('鍙栨秷缁戝畾鎴愬姛')
+ // 鏇存柊鐢ㄦ埛淇℃伅
+ this.$store.dispatch('GetInfo')
+ } else {
+ this.$modal.showToast(response.msg || '鍙栨秷缁戝畾澶辫触')
+ }
+ }).catch(error => {
+ console.error('鍙栨秷缁戝畾澶辫触:', error)
+ this.$modal.showToast('鍙栨秷缁戝畾澶辫触锛岃閲嶈瘯')
+ })
}).catch(() => {
// 鐢ㄦ埛鍙栨秷鎿嶄綔
})
@@ -188,6 +239,12 @@
handleAbout() {
this.$tab.navigateTo('/pages/mine/about/index')
},
+ handleUserAgreement() {
+ this.$tab.navigateTo('/pages/mine/user-agreement/index')
+ },
+ handlePrivacyPolicy() {
+ this.$tab.navigateTo('/pages/mine/privacy-policy/index')
+ },
handleJiaoLiuQun() {
this.$modal.showToast('QQ缇わ細鈶�133713780(婊�)銆佲憽146013835(婊�)銆佲憿189091635')
},
--
Gitblit v1.9.1