Browse Source

邀请开店功能优化

ouyang 4 days ago
parent
commit
da4feb4bfc

+ 3 - 0
hdApp/src/admin/cg/me.vue

@@ -284,6 +284,7 @@ export default {
       outAmountShow: false,
       inAmountShow: false,
       menuList: [
+        { key: "applyInvite", name: "邀请开店", icon: "member-level" },
         { key: "modifyName", name: "修改名称", icon: "modify_shop" },
         { key: "address", name: "修改门店", icon: "modify_shop" },
         { key: "deletedWholesaler", name: "已删批发店", icon: "store-delete" },
@@ -383,6 +384,8 @@ export default {
         this.$util.pageTo({ url: "/admin/shop/add?id=" + shopId });
       } else if (item.key == "book") {
         this.$util.pageTo({ url: "/admin/book/index" });
+      } else if (item.key == "applyInvite") {
+        this.goApplyInvite();
       } else if (item.key == "modifyName") {
         this.$util.pageTo({ url: "/admin/home/edit" });
       } else if (item.key == "lakala") {

+ 1 - 0
hdApp/src/admin/home/me.vue

@@ -297,6 +297,7 @@ export default {
       outAmountShow: false,
       inAmountShow: false,
       menuList: [
+        { key: "shopInvite", name: "邀请门店", icon: "member-level" },
         { key: "address", name: "修改门店", icon: "shop_modify" },
         { key: "book", name: "使用教程", icon: "book" },
         { key: "lakala", name: "收款账户管理", icon: "pay-code" },

+ 10 - 3
hdApp/src/admin/home/shopInviteCommissionList.vue

@@ -32,11 +32,11 @@
               mode="aspectFill"
             />
             <view v-else class="shop-thumb shop-thumb--placeholder">
-              <text>花</text>
+              <text>{{ item.flowType === 2 ? '存' : '' }}</text>
             </view>
             <view class="card-body">
               <view class="title-row">
-                <text class="shop-name">{{ item.shopName || '-' }}</text>
+                <text class="shop-name">{{ displayShopName(item) }}</text>
                 <text
                   class="commission-money"
                   :class="item.commissionSign < 0 ? 'commission-money--minus' : 'commission-money--plus'"
@@ -44,7 +44,7 @@
                   {{ commissionPrefix(item) }} ¥ {{ moneyText(item.commissionAmount) }}
                 </text>
               </view>
-              <text class="meta-line">手机号 {{ item.mobileMask || item.mobile || '-' }}</text>
+              <text v-if="item.flowType !== 2" class="meta-line">手机号 {{ item.mobileMask || item.mobile || '-' }}</text>
               <text class="meta-line">
                 {{ item.orderSnLabel || '会员订单号' }} {{ item.orderSn || '-' }}
               </text>
@@ -114,6 +114,13 @@ export default {
       }
       return '+'
     },
+    /** flowType=1 显示受邀花店名;flowType=2 固定「存入钱包余额」 */
+    displayShopName (item) {
+      if (item && Number(item.flowType) === 2) {
+        return '存入钱包余额'
+      }
+      return (item && item.shopName) ? item.shopName : '-'
+    },
     selectDateFn (val) {
       this.searchTime = val.searchTime || 'last30Days'
       this.startTime = val.startTime || ''

+ 41 - 3
hdApp/src/admin/home/shopInviteHub.vue

@@ -96,7 +96,7 @@
 </template>
 
 <script>
-import { getMainInviteIndex } from '@/api/main-invite'
+import { getMainInviteIndex, postMainInviteDepositBalance } from '@/api/main-invite'
 
 export default {
   name: 'shopInviteHub',
@@ -111,7 +111,8 @@ export default {
         hdDiscountAmount: 0,
         inviteCount: 0
       },
-      recentList: []
+      recentList: [],
+      depositSubmitting: false
     }
   },
   computed: {
@@ -181,8 +182,45 @@ export default {
     onCommissionTip () {
       uni.showToast({ title: '可提现佣金为当前可申请存入余额的金额', icon: 'none' })
     },
+    /** 确认后将全部可用佣金存入中央钱包 */
     onDeposit () {
-      uni.showToast({ title: '功能开发中', icon: 'none' })
+      const amount = parseFloat(this.invite.ableCommission)
+      if (isNaN(amount) || amount <= 0) {
+        uni.showToast({ title: '暂无可存入佣金', icon: 'none' })
+        return
+      }
+      uni.showModal({
+        title: '存入余额',
+        content: '确认将全部可用佣金 ¥' + this.moneyText(amount) + ' 存入中央钱包余额?',
+        success: (res) => {
+          if (res.confirm) {
+            this.doDeposit()
+          }
+        }
+      })
+    },
+    async doDeposit () {
+      if (this.depositSubmitting) {
+        return
+      }
+      this.depositSubmitting = true
+      try {
+        const res = await postMainInviteDepositBalance()
+        if (res.code !== 1) {
+          uni.showToast({ title: res.msg || '存入失败', icon: 'none' })
+          return
+        }
+        if (res.data && res.data.invite) {
+          this.invite = { ...this.invite, ...res.data.invite }
+        } else {
+          await this.loadData()
+        }
+        uni.showToast({ title: '存入成功', icon: 'none' })
+      } catch (e) {
+        uni.showToast({ title: '存入失败,请稍后再试', icon: 'none' })
+      } finally {
+        this.depositSubmitting = false
+      }
     },
     copyInviteCode () {
       const code = this.invite.inviteCode

+ 3 - 0
hdApp/src/api/main-invite/index.js

@@ -8,3 +8,6 @@ export const getMainInviteIndex = data => https.get('/main-invite/index', data)
 export const getMainInviteShopList = data => https.get('/main-invite/invite-shop-list', data)
 
 export const getMainInviteCommissionList = data => https.get('/main-invite/commission-list', data)
+
+/** 可提现佣金全额存入中央钱包余额 */
+export const postMainInviteDepositBalance = data => https.post('/main-invite/deposit-balance', data)

+ 46 - 12
hdApp/src/pagesClient/official/applyInvite.vue

@@ -18,7 +18,7 @@
             <text class="member-banner-title">{{ feePreview.memberTypeName || '年度会员' }}</text>
             <view class="member-banner-price-row">
               <text class="member-banner-yen">¥</text>
-              <text class="member-banner-price">{{ priceInteger }}</text>
+              <text class="member-banner-price">{{ memberBannerPrice }}</text>
               <text class="member-banner-unit">/年</text>
             </view>
           </view>
@@ -207,8 +207,8 @@
         </view>
       </view>
 
-      <simple-address ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
-      <app-area-sel :show.sync="showRegion" :city="form.city" :initial-list="addressInitialList" @change="changeAreaFn" />
+      <simple-address v-if="needRegisterForm" ref="simpleAddress" :pickerValueDefault="cityPickerValueDefault" @onConfirm="onCityConfirm"></simple-address>
+      <app-area-sel v-if="needRegisterForm" :show.sync="showRegion" :city="form.city" :initial-list="addressInitialList" @change="changeAreaFn" />
     </form>
   </view>
 </template>
@@ -310,11 +310,21 @@ export default {
       /** 分享链接/启动参数带入的邀请码,优先级高于 xhApply */
       inviteCodeFromLink: '',
       /** 是否已有 xhRenew 付费成功(续费不再享受邀请减免/佣金) */
-      hasPaidRegisterRenew: false
+      hasPaidRegisterRenew: false,
+      /** register-invite-context 是否已返回(已登录用户需等上下文再决定是否挂载注册表单) */
+      inviteContextReady: false,
+      hasMapLoaded: false
     };
   },
 	computed:{
 		...mapGetters(["getLoginInfo"]),
+    /** 是否需要展示新注册表单(仅此时才挂载地址组件并请求 region/tree) */
+    needRegisterForm () {
+      if (!this.inviteContextReady) {
+        return !uni.getStorageSync('token')
+      }
+      return !this.hasShop
+    },
     /** 是否仍可使用邀请码减免 */
     inviteBenefitAvailable () {
       return !this.hasPaidRegisterRenew
@@ -331,13 +341,20 @@ export default {
       const host = (this.$constant && this.$constant.imgUrl) || ''
       return host ? host + '/hzg/invite/shop_invite_bg.png' : ''
     },
-    /** 横幅展示整数价 */
-    priceInteger () {
-      const n = parseFloat(this.feePreview.price)
-      if (isNaN(n)) {
+    /** 横幅会员价:不做四舍五入,按接口原价原样展示 */
+    memberBannerPrice () {
+      const val = this.feePreview.price
+      if (val === '' || val === null || val === undefined) {
         return '0'
       }
-      return String(Math.round(n))
+      let s = String(val).trim()
+      if (s === '' || isNaN(Number(s))) {
+        return '0'
+      }
+      if (s.indexOf('.') >= 0) {
+        s = s.replace(/(\.\d*?)0+$/, '$1').replace(/\.$/, '')
+      }
+      return s
     }
 	},
   onLoad () {
@@ -358,9 +375,6 @@ export default {
     // #ifdef APP-PLUS
     this.fillMobile = 1
     // #endif
-    getHasMap().then(res => {
-      this.hasMap = res.data.hasMap
-    })
     const linkCode = this.getLaunchInviteCode()
     if (linkCode) {
       this.inviteCodeFromLink = linkCode
@@ -450,12 +464,24 @@ export default {
         this.hasPaidRegisterRenew = false
       }
     },
+    /** 新注册才拉地图选点配置 */
+    loadRegisterMapConfig () {
+      if (this.hasMapLoaded || this.hasShop) {
+        return
+      }
+      this.hasMapLoaded = true
+      getHasMap().then(res => {
+        this.hasMap = res.data.hasMap
+      })
+    },
     /** 拉取是否已开店及 xhApply 邀请快照;skipInviteFill 为 true 时不改邀请码输入框 */
     async loadRegisterInviteContext (skipInviteFill) {
       const token = uni.getStorageSync('token')
       if (!token) {
         this.hasShop = false
         this.applyId = 0
+        this.inviteContextReady = true
+        this.loadRegisterMapConfig()
         return
       }
       try {
@@ -471,12 +497,17 @@ export default {
           mobile: d.shopMobile || ''
         }
         this.syncInviteBenefitFlags(d)
+        if (!this.hasShop) {
+          this.loadRegisterMapConfig()
+        }
         if (!skipInviteFill) {
           this.applyInviteCodeFromContext(d.inviteCode || '')
           await this.loadRegisterFeePreview(false)
         }
       } catch (e) {
         // 网络失败不打断填写
+      } finally {
+        this.inviteContextReady = true
       }
     },
     /** 拉取会员费 / 邀请减免预览 */
@@ -761,6 +792,9 @@ export default {
       });
     },
     openAddres () {
+      if (!this.$refs.simpleAddress) {
+        return
+      }
       this.$refs.simpleAddress.open();
     },
     onCityConfirm (e) {