Prechádzať zdrojové kódy

feat: migrate address.vue and address-edit.vue to CFC API

Replace config.danshop() with CFC /api/user-address/* endpoints.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
liaoxg 4 mesiacov pred
rodič
commit
d8b0e59449

+ 7 - 8
cfc-frontend/pages/shop/address-edit/address-edit.vue

@@ -76,7 +76,6 @@ export default {
   data() {
     return {
       addressId: null,
-      userId: null,
       saving: false,
       form: {
         receiverName: '',
@@ -91,7 +90,6 @@ export default {
     }
   },
   onLoad(options) {
-    this.userId = uni.getStorageSync('userId')
     if (options.addressId) {
       this.addressId = parseInt(options.addressId)
       uni.setNavigationBarTitle({ title: '编辑地址' })
@@ -104,7 +102,7 @@ export default {
     loadAddress() {
       var that = this
       uni.request({
-        url: config.danshop('/danshop/address/get'),
+        url: config.api('/api/user/address/get'),
         method: 'POST',
         data: { id: this.addressId },
         header: {
@@ -132,7 +130,7 @@ export default {
       // Load provinces first
       uni.showLoading({ title: '加载地址...' })
       uni.request({
-        url: config.danshop('/danshop/region/provinces'),
+        url: config.api('/api/region/provinces'),
         method: 'POST',
         header: {
           'Content-Type': 'application/json',
@@ -167,7 +165,7 @@ export default {
       var that = this
       uni.showLoading({ title: '加载城市...' })
       uni.request({
-        url: config.danshop('/danshop/region/cities'),
+        url: config.api('/api/region/cities'),
         method: 'POST',
         data: { parentId: provinceId },
         header: {
@@ -199,7 +197,7 @@ export default {
       var that = this
       uni.showLoading({ title: '加载区县...' })
       uni.request({
-        url: config.danshop('/danshop/region/districts'),
+        url: config.api('/api/region/districts'),
         method: 'POST',
         data: { parentId: cityId },
         header: {
@@ -264,7 +262,6 @@ export default {
 
       this.saving = true
       var data = {
-        userId: this.userId,
         receiverName: this.form.receiverName.trim(),
         phone: this.form.phone.trim(),
         province: this.form.province,
@@ -279,7 +276,9 @@ export default {
 
       var that = this
       uni.request({
-        url: config.danshop('/danshop/address/save'),
+        url: this.addressId
+          ? config.api('/api/user/address/update')
+          : config.api('/api/user/address/create'),
         method: 'POST',
         data: data,
         header: {

+ 4 - 4
cfc-frontend/pages/shop/address/address.vue

@@ -78,9 +78,9 @@ export default {
       this.loading = true
       var that = this
       uni.request({
-        url: config.danshop('/danshop/address/list'),
+        url: config.api('/api/user/address/list'),
         method: 'POST',
-        data: { userId: this.userId },
+        data: {},
         header: {
           'Content-Type': 'application/json',
           'Authorization': 'Bearer ' + uni.getStorageSync('token')
@@ -126,7 +126,7 @@ export default {
         success: function(confirm) {
           if (confirm.confirm) {
             uni.request({
-              url: config.danshop('/danshop/address/delete'),
+              url: config.api('/api/user/address/delete'),
               method: 'POST',
               data: { id: id },
               header: {
@@ -149,7 +149,7 @@ export default {
     onSetDefault(id) {
       var that = this
       uni.request({
-        url: config.danshop('/danshop/address/setDefault'),
+        url: config.api('/api/user/address/setDefault'),
         method: 'POST',
         data: { id: id },
         header: {