Преглед изворни кода

简化功能界面新增头像上传与修改

shizhongqi пре 10 месеци
родитељ
комит
afdae15c6f

+ 220 - 7
hdApp/src/admin/home/workbench.vue

@@ -12,6 +12,7 @@
     </view>
   </block>
   <block v-else>
+    <!-- ========== 完整功能界面 ========== -->
     <view class="app-main app-content" v-if="loginStyle  == 2">
       <template v-if="lookMoney == 1">
         <view class="today-overview-card">
@@ -258,14 +259,66 @@
       </template>
 
     </view>
+
+    <!--  ========== 简化功能界面  ========== -->
     <view class="order-page" v-else>
       <view class="ghs_list_page flex-col">
-        <view style="background-color:white;margin-bottom:20upx;">
-          <button class="admin-button-com mini-btn blue" style="margin-left:11upx;padding-top:17upx;padding-bottom:17upx;" @click="pageTo({url:'/admin/shop/myShop'})">我的门店</button>
-          <button class="admin-button-com mini-btn blue" style="margin-left:11upx;padding-top:17upx;padding-bottom:17upx;" @click="pageTo({url:'/admin/staff/list'})">我的员工</button>
-          <button class="admin-button-com mini-btn blue" style="margin-left:11upx;padding-top:17upx;padding-bottom:17upx;" @click="pageTo({url:'/admin/shop/add?id='+loginInfo.shopId})">我的地址</button>
-          <button class="admin-button-com mini-btn blue" style="margin-left:11upx;padding-top:17upx;padding-bottom:17upx;" @click="pageTo({url:'/admin/stat/cgItem'})">采购统计</button>
-          <button class="admin-button-com mini-btn blue" style="margin-left:11upx;padding-top:17upx;padding-bottom:17upx;" @click="goMore()">更多</button>
+        <view class="profile-section">
+          <view class="profile-header">
+            <view class="avatar-container">
+              <button
+                class="avatar-button"
+                open-type="chooseAvatar"
+                @chooseavatar="onChooseAvatar"
+              >
+                <image
+                  class="avatar"
+                  :src="shopAvatar()"
+                  mode="aspectFill"
+                />
+              </button>
+            </view>
+            <view class="user-info">
+              <text class="username">{{ (shopInfo && shopInfo.shopName == '首店') ? (shopInfo.merchantName || '') : (((shopInfo && shopInfo.merchantName) ? shopInfo.merchantName : '') + (shopInfo && shopInfo.shopName ? (' ' + shopInfo.shopName) : '')) }}</text>
+              <text class="user-id">ID {{ shopInfo && shopInfo.id ? shopInfo.id : '' }}</text>
+            </view>
+            <view class="more-icon">
+              <zui-svg-icon icon="home-more" :width="26" color="#FFFFFF" />
+            </view>
+          </view>
+
+          <view class="function-grid function-grid--overlay">
+            <view class="function-item function-item--overlay" @click="pageTo({url:'/admin/shop/myShop'})">
+              <view class="function-icon">
+                <zui-svg-icon icon="home-shop" :width="32" :height="32" color="#FFFFFF" />
+              </view>
+              <text class="function-text function-text--overlay">我的门店</text>
+            </view>
+            <view class="function-item function-item--overlay" @click="pageTo({url:'/admin/staff/list'})">
+              <view class="function-icon">
+                <zui-svg-icon icon="home-staffs" :width="32" :height="32" color="#FFFFFF" />
+              </view>
+              <text class="function-text function-text--overlay">我的员工</text>
+            </view>
+            <view class="function-item function-item--overlay" @click="pageTo({url:'/admin/shop/add?id='+loginInfo.shopId})">
+              <view class="function-icon">
+                <zui-svg-icon icon="home-address" :width="32" :height="32" color="#FFFFFF" />
+              </view>
+              <text class="function-text function-text--overlay">我的地址</text>
+            </view>
+            <view class="function-item function-item--overlay" @click="pageTo({url:'/admin/stat/cgItem'})">
+              <view class="function-icon">
+                <zui-svg-icon icon="home-statistics" :width="32" :height="32" color="#FFFFFF" />
+              </view>
+              <text class="function-text function-text--overlay">采购统计</text>
+            </view>
+            <view class="function-item function-item--overlay" @click="goMore()">
+              <view class="function-icon">
+                <zui-svg-icon icon="home-more-2" :width="30" :height="30" color="#FFFFFF" />
+              </view>
+              <text class="function-text function-text--overlay">更多</text>
+            </view>
+          </view>
         </view>
         <view style="text-align:center;font-size:29upx;">您好,{{ loginInfo.admin && loginInfo.admin.name ? loginInfo.admin.name : '' }} {{ loginInfo.admin && loginInfo.admin.mobile ? loginInfo.admin.mobile : '' }}</view>
         <view v-if="!$util.isEmpty(data.warning)" style="color:red;font-size:36upx;font-weight:bold;text-align: center;margin-bottom:15upx;margin-top:20upx;">{{ data.warning }}</view>
@@ -457,9 +510,10 @@ import { consoleIndex } from "@/api/workbench";
 import autoUpdateMixins from "@/mixins/autoUpdate";
 import { ghsList } from "@/api/purchase";
 import { changeDelStatus,hasMoreGhs } from "@/api/ghs";
-import {currentShop} from "@/api/shop";
+import {currentShop, uploadShopAvatar} from "@/api/shop";
 import { clearLogin,hasNotice } from "@/api/admin";
 import { unReadMsgCount } from "@/api/chat";
+import { APIHOST } from "@/config";
 export default {
   name: "workbench",
   mixins: [autoUpdateMixins],
@@ -543,6 +597,67 @@ export default {
 		}
 	},
   methods: {
+    onChooseAvatar(e){
+      if(this.loginInfo && this.loginInfo.staff && this.loginInfo.staff.founder != 2){
+        this.$msg('无权修改头像')
+        return
+      }
+
+      if(e && e.detail && e.detail.avatarUrl){
+        let avatarUrl = e.detail.avatarUrl
+        this.updateShopAvatar(avatarUrl)
+      }else{
+        this.$msg('获取头像失败')
+      }
+    },
+    updateShopAvatar(avatarUrl){
+      let token = uni.getStorageSync('token') || ''
+      let url = APIHOST + '/upload/save-file'
+      uni.uploadFile({
+        url: url,
+        filePath: avatarUrl,
+        name: 'file',
+        header: { token: token },
+        formData: {},
+        success: (res) => {
+          try{
+            const ret = JSON.parse(res.data)
+            if(ret.code == 1){
+              this.shopInfo.avatar = ret.data.shortUrl
+              this.$msg('头像已更新')
+              uni.setStorageSync('shopAvatar', this.shopInfo.avatar)
+
+              //请后端,上传新的头像地址,同步更新xhGhsCustom里面的头像地址
+              uploadShopAvatar({ id: this.shopInfo.id, avatar: ret.data.shortUrl }).then(res => {
+                if(res.code == 1){
+                  // this.$msg('头像上传成功')
+                }else{
+                  // this.$msg(res.msg || '上传失败')
+                  console.log(res.msg || '上传失败')
+                }
+              })
+            }else{
+              this.$msg(ret.msg || '上传失败')
+            }
+          }catch(err){
+            this.$msg('服务异常')
+          }
+        },
+        fail: () => {
+          this.$msg('上传失败')
+        }
+      })
+    },
+    shopAvatar(){
+      const avatar = (this.shopInfo && this.shopInfo.avatar) ? this.shopInfo.avatar : '/hhb_small.png?x-oss-process=image/resize,m_fill,h_130,w_130'
+      if(!avatar){
+        return ''
+      }
+      if(/^https?:\/\//i.test(avatar)){
+        return avatar
+      }
+      return this.$constant.imgUrl + (avatar.indexOf('/') === 0 ? avatar : ('/' + avatar))
+    },
 		buyItem() {
 			let that = this
 			// #ifdef MP-WEIXIN
@@ -1365,6 +1480,104 @@ export default {
   position: relative;
   width: 750upx; 
   overflow: hidden;
+  .profile-section {
+    background-color: #09C567;
+    padding: 24upx;
+    border-radius: 0;
+    .profile-header {
+      display: flex;
+      align-items: center;
+      .avatar-container {
+        width: 120upx;
+        height: 120upx;
+        border-radius: 60upx;
+        overflow: hidden;
+        background-color: rgba(255,255,255,0.2);
+        border: 1upx solid #ffffff;
+        .avatar-button {
+          background: none !important;
+          border: none !important;
+          padding: 0 !important;
+          margin: 0 !important;
+          line-height: 1;
+          display: block;
+          width: 120upx;
+          height: 120upx;
+          color: transparent !important;
+          &::after { border: none !important; }
+        }
+        .avatar {
+          width: 120upx;
+          height: 120upx;
+          border-radius: 60upx;
+        }
+      }
+      .user-info {
+        flex: 1;
+        margin-left: 24upx;
+        .username {
+          display: block;
+          font-size: 36upx;
+          font-weight: bold;
+          color: #ffffff;
+        }
+        .user-id {
+          display: block;
+          margin-top: 6upx;
+          font-size: 26upx;
+          color: #ffffff;
+        }
+      }
+      .more-icon {
+        margin-left: 12upx;
+        width: 60upx;
+        height: 60upx;
+        border-radius: 30upx;
+        align-items: center;
+        justify-content: center;
+        display: flex;
+        // background: rgba(255,255,255,0.15);
+        // border: 1upx solid rgba(255,255,255,0.35);
+      }
+    }
+    .function-grid {
+      margin-top: 24upx;
+      display: flex;
+      flex-wrap: nowrap;
+      justify-content: space-between;
+      gap: 0;
+    }
+    .function-grid--overlay {
+      background: transparent;
+      padding: 12upx 0 0 0;
+    }
+    .function-item {
+      width: 20%;
+      display: flex;
+      flex-direction: column;
+      align-items: center;
+      padding: 20upx 0;
+      border-radius: 16upx;
+      border: 1upx solid rgba(255,255,255,0.5);
+      background: rgba(255,255,255,0.12);
+      backdrop-filter: blur(8upx);
+      box-sizing: border-box;
+    }
+    .function-item--overlay {
+      border-color: rgba(255,255,255,0.5);
+      background: rgba(255,255,255,0.12);
+    }
+    .function-icon {
+      margin-bottom: 10upx;
+    }
+    .function-text {
+      font-size: 26upx;
+      color: #ffffff;
+    }
+    .function-text--overlay {
+      color: #ffffff;
+    }
+  }
   .flex-col {
     display: flex;
     flex-direction: column;

+ 7 - 0
hdApp/src/api/shop/index.js

@@ -69,6 +69,13 @@ export const delShop = data => {
 	return https.get('/shop/delete', data)
 }
 
+/** *
+ * 上传(更新)门店头像
+ */
+export const uploadShopAvatar = data => {
+	return https.post('/shop/update-shop-avatar', data)
+}
+
 /** *
  * 下载收款码
  */

+ 1 - 0
hdApp/src/assets/svg-icons/home/address.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1758012649989" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="10502" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M512 64c-175.8 0-318.3 134.6-318.3 300.5 0 222.9 195.5 430.8 280.1 510.3 21.3 20.1 55.7 20.3 77.4 0.6 85.1-77.2 279.2-278.7 279.2-510.9C830.3 198.6 687.8 64 512 64z m0 401.1c-56.9 0-103.1-46.2-103.1-103.1S455.1 258.9 512 258.9c56.9 0 103.1 46.2 103.1 103.1S568.9 465.1 512 465.1z" p-id="10503"></path><path d="M364.5 926.5a147.5 21.5 0 1 0 295 0 147.5 21.5 0 1 0-295 0Z" p-id="10504"></path></svg>

+ 1 - 0
hdApp/src/assets/svg-icons/home/more-2.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1758013331870" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="16231" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M682.666667 577.6384h236.305066C988.9792 577.6384 1024 612.6592 1024 682.666667v236.305066C1024 988.9792 988.9792 1024 918.971733 1024H682.666667c-70.007467 0-105.028267-35.0208-105.028267-105.028267V682.666667c0-70.007467 35.0208-105.028267 105.028267-105.028267zM105.028267 0H341.333333c70.007467 0 105.028267 35.0208 105.028267 105.028267V341.333333c0 70.007467-35.0208 105.028267-105.028267 105.028267H105.028267C35.0208 446.3616 0 411.3408 0 341.333333V105.028267C0 35.0208 35.0208 0 105.028267 0z m0 577.6384H341.333333c70.007467 0 105.028267 35.0208 105.028267 105.028267v236.305066C446.3616 988.9792 411.3408 1024 341.333333 1024H105.028267C35.0208 1024 0 988.9792 0 918.971733V682.666667c0-70.007467 35.0208-105.028267 105.028267-105.028267z m620.9536-156.228267c34.133333 34.133333 87.9616 34.133333 122.094933 0l136.533333-137.8304c34.133333-34.133333 34.133333-87.9616 0-122.094933l-136.533333-136.533333c-32.802133-32.836267-87.9616-32.836267-120.832 0l-137.796267 136.533333c-34.133333 34.133333-34.133333 87.9616 0 122.094933l136.533334 137.8304z" fill="#38BFD4" p-id="16232"></path></svg>

+ 1 - 0
hdApp/src/assets/svg-icons/home/more.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1758013104896" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="15229" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M323.8912 131.072a51.2 51.2 0 0 1 71.4752-72.8064l6.5536 6.4512L753.664 478.8224a51.2 51.2 0 0 1 5.12 59.1872l-5.4272 7.5776-351.744 405.0944A51.2 51.2 0 0 1 318.8736 890.88l5.4272-7.4752 322.7648-371.9168L323.8912 131.072z" fill="#000000" fill-opacity=".45" p-id="15230"></path></svg>

Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
hdApp/src/assets/svg-icons/home/shop.svg


Разлика између датотеке није приказан због своје велике величине
+ 0 - 0
hdApp/src/assets/svg-icons/home/staffs.svg


+ 1 - 0
hdApp/src/assets/svg-icons/home/statistics.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1758012699298" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="14222" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M0 0h1024v1024H0V0z" fill="#202425" opacity=".01" p-id="14223"></path><path d="M921.6 546.133333A443.733333 443.733333 0 1 1 477.866667 102.4v443.733333h443.733333z" fill="#11AA66" p-id="14224"></path><path d="M989.866667 477.866667A443.733333 443.733333 0 0 0 546.133333 34.133333v443.733334h443.733334z" fill="#FFAA44" p-id="14225"></path></svg>

Разлика између датотеке није приказан због своје велике величине
+ 15 - 1
hdApp/src/static/svg-icons-lib.js


Неке датотеке нису приказане због велике количине промена