Bladeren bron

Merge branch 'dev' of https://git.citupro.com/zhengnaiwen_citu/menduner into dev

lifanagju_citu 4 maanden geleden
bovenliggende
commit
7287c08fa6
4 gewijzigde bestanden met toevoegingen van 60 en 24 verwijderingen
  1. 2 1
      src/layout/personal/navBar.vue
  2. 1 1
      src/version.js
  3. 1 0
      src/views/mall/components/details.vue
  4. 56 22
      src/views/mall/user/address/index.vue

+ 2 - 1
src/layout/personal/navBar.vue

@@ -183,7 +183,8 @@ const navList = [
   // },
   { title: '门墩儿招聘', path: '/recruit/personal/recommend', noLeaving: true },
   { title: '门墩儿猎头', path: '/headhunting' },
-  { title: '门墩儿商城', path: '/pointsExchange' },
+  // { title: '门墩儿商城', path: '/pointsExchange' },
+  { title: '门墩儿商城', path: '/mall' },
   { title: '火苗儿校企' },
   // { title: '产业联合会' },
   // { title: '数据' },

+ 1 - 1
src/version.js

@@ -1,2 +1,2 @@
 // 版本号
-export const vue_version = 'v24.12.19.1908'
+export const vue_version = 'v24.12.23.1257'

+ 1 - 0
src/views/mall/components/details.vue

@@ -1,6 +1,7 @@
 <!-- 商品详情 -->
 <template>
   <div class="default-width py-5" v-if="state.goodsInfo && Object.keys(state.goodsInfo).length">
+    <v-btn class="mb-3" size="large" color="primary" variant="text" prepend-icon="mdi-chevron-triple-left" @click="router.go(-1)">返回上一页</v-btn>
     <v-card class="carousel border-radius-8 white-bgc pa-5" style="width: 100%;">
       <div class=" d-flex">
         <!-- 图片展示-轮播 -->

+ 56 - 22
src/views/mall/user/address/index.vue

@@ -19,10 +19,28 @@
 
   <CtDialog :visible="showDialog" titleClass="text-h6" :footer="true" :widthType="3" :title="isAdd ? '新增收货地址' : '编辑收货地址'" @submit="handleSubmit" @close="handleClose">
     <CtForm ref="CtFormRef" :items="formItems">
+      <template #areaId="{ item }">
+        <div class="d-flex" style="width: 100%;">
+          <div class="mt-2" style="color: #777; width: 100px;">省市区 *</div>
+          <el-cascader
+            ref="cascaderAddr"
+            v-model="item.value"
+            size="large"
+            clearable
+            class="mb-5"
+            placeholder="省市区 *"
+            style="flex: 1;"
+            :props="{ value: 'id', label: 'name', emitPath: false }"
+            :options="item.items"
+            @change="handleChangeArea(item)"
+            @clear="item.labelValue = ''"
+          ></el-cascader>
+        </div>
+      </template>
       <template #defaultStatus="{ item }">
         <div class="d-flex align-center">
           <span class="color-666 mr-5">设为默认地址</span>
-          <v-switch v-model="item.value" label="" hide-details color="primary" inset></v-switch>
+          <v-switch v-model="item.value" hide-details color="primary"></v-switch>
         </div>
       </template>
     </CtForm>
@@ -38,6 +56,7 @@ import { getDict } from '@/hooks/web/useDictionaries'
 import Snackbar from '@/plugins/snackbar'
 
 const isAdd = ref(true)
+const editId = ref(null)
 const showDialog = ref(false)
 const items = ref([])
 const headers = [
@@ -48,6 +67,7 @@ const headers = [
   { title: '是否默认', key: 'defaultStatus', sortable: false, value: item => item.defaultStatus ? '是' : '否' },
   { title: '操作', key: 'actions', sortable: false }
 ]
+const cascaderAddr = ref()
 const CtFormRef = ref()
 const formItems = ref({
   options: [
@@ -70,16 +90,11 @@ const formItems = ref({
       rules: [v => !!v || '请填写收货人联系电话']
     },
     {
-      type: 'cascade',
+      slotName: 'areaId',
       key: 'areaId',
-      value: [],
-      default: [],
-      label: '省市区',
-      itemText: 'name',
-      itemValue: 'id',
-      required: true,
-      clearable: false,
-      emitPath: true,
+      labelValue: '',
+      value: null,
+      default: null,
       items: []
     },
     {
@@ -93,8 +108,9 @@ const formItems = ref({
     {
       slotName: 'defaultStatus',
       key: 'defaultStatus',
-      value: false
-    }
+      value: false,
+      default: false,
+    } 
   ]
 })
 getDict('areaTreeData', null, 'areaTreeData').then(({ data }) => {
@@ -111,10 +127,18 @@ getAddressList()
 
 // 新增
 const handleAdd = () => {
+  formItems.value.options.forEach(e => e.value = e.default)
   showDialog.value = true
   isAdd.value = true
 }
 
+// 地区选择
+const handleChangeArea = (item) => {
+  const node = cascaderAddr.value.getCheckedNodes() ? cascaderAddr.value.getCheckedNodes()[0] : null
+  if (!node) return
+  item.labelValue = node.pathLabels.join(' ')
+}
+
 // 设置为默认地址
 const handleSetDefault = async (item) => {
   Confirm('系统提示', '是否确定设置该地址为默认收货地址?').then(async () => {
@@ -127,24 +151,34 @@ const handleSetDefault = async (item) => {
 // 编辑
 const handleEdit = (item) => {
   isAdd.value = false
+  editId.value = item.id
   formItems.value.options.forEach(e => e.value = item[e.key])
   showDialog.value = true
 }
 
+// 提交
+const handleClose = () => {
+  showDialog.value = false
+  editId.value = null
+}
+
 const handleSubmit = async () => {
   const { valid } = await CtFormRef.value.formRef.validate()
   if (!valid) return
   const obj = {}
-  formItems.value.options.forEach(e => obj[e.key] = e.value)
-  console.log(obj, 'submit')
-  // try {
-  //   isAdd.value ? await createMallUserAddress(obj) : await updateMallUserAddress(obj)
-  // } catch {}
-}
-
-const handleClose = () => {
-  showDialog.value = false
-
+  formItems.value.options.forEach(e => {
+    if (e.key === 'areaId') {
+      obj.areaId = e.value
+      obj.areaName = e.labelValue
+    } else obj[e.key] = e.value
+  })
+  if (!obj.areaId && !obj.areaName) return Snackbar.warning('请将必填项填写完整')
+  try {
+    isAdd.value ? await createMallUserAddress(obj) : await updateMallUserAddress(obj)
+    Snackbar.success(isAdd.value ? '新增成功' : '编辑成功')
+    handleClose()
+    getAddressList()
+  } catch {}
 }
 
 // 删除