Эх сурвалжийг харах

!134 缺陷修复
Merge pull request !134 from puhui999/dev

芋道源码 7 сар өмнө
parent
commit
11e83df02f

+ 2 - 1
pages/activity/groupon/detail.vue

@@ -209,6 +209,7 @@
   import { isEmpty } from 'lodash-es';
   import CombinationApi from '@/sheep/api/promotion/combination';
   import SpuApi from '@/sheep/api/product/spu';
+  import { SharePageEnum } from '@/sheep/util/const';
 
   const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
   const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;
@@ -234,7 +235,7 @@
         image: sheep.$url.cdn(state.data.headRecord.picUrl),
         desc: state.data.goods?.subtitle,
         params: {
-          page: '5',
+          page: SharePageEnum.GROUPON_DETAIL.value,
           query: state.data.headRecord.id,
         },
       },

+ 3 - 1
pages/commission/index.vue

@@ -23,11 +23,13 @@
 	import commissionMenu from './components/commission-menu.vue';
 	import commissionAuth from './components/commission-auth.vue';
   import sheep from '@/sheep';
+  import { SharePageEnum } from '@/sheep/util/const';
 
+  /** 分销邀请 */
   const shareInfo = computed(() => {
     return sheep.$platform.share.getShareInfo({
       params: {
-        page: '6',
+        page: SharePageEnum.HOME.value, // 用户通邀请进入到首页
       },
     }, {
       type: 'user',

+ 2 - 1
pages/goods/groupon.vue

@@ -159,6 +159,7 @@
   import { useDurationTime, formatGoodsSwiper, fen2yuan } from '@/sheep/hooks/useGoods';
   import CombinationApi from '@/sheep/api/promotion/combination';
   import SpuApi from '@/sheep/api/product/spu';
+  import { SharePageEnum } from '@/sheep/util/const';
 
   const headerBg = sheep.$url.css('/static/img/shop/goods/groupon-bg.png');
   const btnBg = sheep.$url.css('/static/img/shop/goods/groupon-btn.png');
@@ -239,7 +240,7 @@
         title: state.activity.name,
         image: sheep.$url.cdn(state.goodsInfo.picUrl),
         params: {
-          page: '3',
+          page: SharePageEnum.GROUPON.value,
           query: state.activity.id,
         },
       },

+ 2 - 1
pages/goods/index.vue

@@ -234,6 +234,7 @@
   import countDown from '@/sheep/components/countDown/index.vue';
   import OrderApi from '@/sheep/api/trade/order';
   import activity from '@/sheep/api/promotion/activity';
+  import { SharePageEnum } from '@/sheep/util/const';
 
   const bgColor = {
     bgColor: '#E93323',
@@ -318,7 +319,7 @@
         image: sheep.$url.cdn(state.goodsInfo.picUrl),
         desc: state.goodsInfo.introduction,
         params: {
-          page: '2',
+          page: SharePageEnum.GOODS.value,
           query: state.goodsInfo.id,
         },
       },

+ 2 - 3
pages/goods/point.vue

@@ -129,7 +129,7 @@
   import detailCommentCard from './components/detail/detail-comment-card.vue';
   import detailContentCard from './components/detail/detail-content-card.vue';
   import SpuApi from '@/sheep/api/product/spu';
-  import { PromotionActivityTypeEnum } from '@/sheep/util/const';
+  import { PromotionActivityTypeEnum, SharePageEnum } from '@/sheep/util/const';
   import PointApi from '@/sheep/api/promotion/point';
 
   const headerBg = sheep.$url.css('/static/img/shop/goods/score-bg.png');
@@ -180,8 +180,7 @@
         title: activity.value.name,
         image: sheep.$url.cdn(state.goodsInfo.picUrl),
         params: {
-          // TODO @puhui:page 相关,要不搞个枚举,然后都弄过去;
-          page: '6',
+          page: SharePageEnum.POINT.value,
           query: activity.value.id,
         },
       },

+ 2 - 2
pages/goods/seckill.vue

@@ -151,7 +151,7 @@
   import detailProgress from './components/detail/detail-progress.vue';
   import SeckillApi from '@/sheep/api/promotion/seckill';
   import SpuApi from '@/sheep/api/product/spu';
-  import { getTimeStatusEnum, TimeStatusEnum } from '@/sheep/util/const';
+  import { getTimeStatusEnum, SharePageEnum, TimeStatusEnum } from '@/sheep/util/const';
 
   const headerBg = sheep.$url.css('/static/img/shop/goods/seckill-bg.png');
   const btnBg = sheep.$url.css('/static/img/shop/goods/seckill-btn.png');
@@ -206,7 +206,7 @@
         title: activity.value.name,
         image: sheep.$url.cdn(state.goodsInfo.picUrl),
         params: {
-          page: '4',
+          page: SharePageEnum.SECKILL.value,
           query: activity.value.id,
         },
       },

+ 7 - 6
sheep/components/s-layout/s-layout.vue

@@ -60,11 +60,11 @@
   /**
    * 模板组件 - 提供页面公共组件,属性,方法
    */
-  import { computed } from 'vue';
+  import { computed, onMounted } from 'vue';
   import sheep from '@/sheep';
   import { isEmpty } from 'lodash-es';
   // #ifdef MP-WEIXIN
-  import { onShareAppMessage, onShareTimeline, onShow } from '@dcloudio/uni-app';
+  import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
   // #endif
 
   const props = defineProps({
@@ -198,7 +198,7 @@
   onShareAppMessage(() => {
     return {
       title: shareInfo.value.title,
-      path: shareInfo.value.path,
+      path: shareInfo.value.forward.path,
       imageUrl: shareInfo.value.image,
     };
   });
@@ -206,17 +206,18 @@
   onShareTimeline(() => {
     return {
       title: shareInfo.value.title,
-      query: shareInfo.value.path,
+      query: shareInfo.value.forward.path,
       imageUrl: shareInfo.value.image,
     };
   });
   // #endif
 
-  onShow(() => {
+  // 组件中使用 onMounted 监听页面加载,不是页面组件不使用 onShow
+  onMounted(()=>{
     if (!isEmpty(shareInfo.value)) {
       sheep.$platform.share.updateShareInfo(shareInfo.value);
     }
-  });
+  })
 </script>
 
 <style lang="scss" scoped>

+ 0 - 1
sheep/components/s-share-modal/s-share-modal.vue

@@ -92,7 +92,6 @@
       showAuthModal();
       return;
     }
-    console.log(props.shareInfo);
     unref(SharePosterRef).getPoster();
     state.showPosterModal = true;
   };

+ 26 - 25
sheep/platform/share.js

@@ -3,6 +3,8 @@ import $platform from '@/sheep/platform';
 import $router from '@/sheep/router';
 import $url from '@/sheep/url';
 import BrokerageApi from '@/sheep/api/trade/brokerage';
+import { SharePageEnum } from '@/sheep/util/const';
+
 // #ifdef H5
 import $wxsdk from '@/sheep/libs/sdk-h5-weixin';
 // #endif
@@ -35,7 +37,11 @@ const getShareInfo = (
     link: '', // 分享Url+参数
     query: '', // 分享参数
     poster, // 海报所需数据
+    forward: {} // 转发所需参数
   };
+  shareInfo.title = scene.title;
+  shareInfo.image = $url.cdn(scene.image);
+  shareInfo.desc = scene.desc;
 
   const app = $store('app');
   const shareConfig = app.platform.share;
@@ -49,16 +55,9 @@ const getShareInfo = (
   // 配置页面地址带参数
   shareInfo.path = buildSpmPath();
 
-  // 配置转发参数
+  // 配置页面转发参数
   if (shareConfig.methods.includes('forward')) {
-    if (shareConfig.forwardInfo.title === '' || shareConfig.forwardInfo.image === '') {
-      console.log('请在平台设置中配置默认转发信息');
-    }
-    // 设置自定义分享信息
-    shareInfo.title = scene.title || shareConfig.forwardInfo.title;
-    shareInfo.image = $url.cdn(scene.image || shareConfig.forwardInfo.image);
-    shareInfo.desc = scene.desc || shareConfig.forwardInfo.subtitle;
-    shareInfo.path = buildSpmPath(query);
+    shareInfo.forward.path = buildSpmPath(query);
   }
 
   return shareInfo;
@@ -78,7 +77,7 @@ const buildSpmQuery = (params) => {
       shareId = user.userInfo.id;
     }
   }
-  let page = '1'; // 页面类型: 1=首页(默认),2=商品,3=拼团商品,4=秒杀商品,5=邀请参团,6=分销邀请...按需扩展
+  let page = SharePageEnum.HOME.value; // 页面类型,默认首页
   if (typeof params.page !== 'undefined') {
     page = params.page;
   }
@@ -99,6 +98,7 @@ const buildSpmQuery = (params) => {
 const buildSpmPath = (query) => {
   // 默认是主页,页面 page,例如 pages/index/index,根路径前不要填加 /,
   // 不能携带参数(参数请放在scene字段里),如果不填写这个字段,默认跳主页面。scancode_time为系统保留参数,不允许配置
+  // 页面分享时参数使用 ? 拼接
   return typeof query === 'undefined' ? `pages/index/index` : `pages/index/index?${query}`;
 };
 
@@ -122,44 +122,44 @@ const decryptSpm = (spm) => {
   let query;
   shareParams.shareId = shareParamsArray[0];
   switch (shareParamsArray[1]) {
-    case '1':
+    case SharePageEnum.HOME.value:
       // 默认首页不跳转
-      shareParams.page = '/pages/index/index';
+      shareParams.page = SharePageEnum.HOME.page;
       break;
-    case '2':
+    case SharePageEnum.GOODS.value:
       // 普通商品
-      shareParams.page = '/pages/goods/index';
+      shareParams.page = SharePageEnum.GOODS.page;
       shareParams.query = {
         id: shareParamsArray[2],
       };
       break;
-    case '3':
+    case SharePageEnum.GROUPON.value:
       // 拼团商品
-      shareParams.page = '/pages/goods/groupon';
+      shareParams.page = SharePageEnum.GROUPON.page;
       query = shareParamsArray[2].split(',');
       shareParams.query = {
         id: query[0],
         activity_id: query[1],
       };
       break;
-    case '4':
+    case SharePageEnum.SECKILL.value:
       // 秒杀商品
-      shareParams.page = '/pages/goods/seckill';
+      shareParams.page = SharePageEnum.SECKILL.page;
       query = shareParamsArray[2].split(',');
       shareParams.query = {
         id: query[0],
       };
       break;
-    case '5':
+    case SharePageEnum.GROUPON_DETAIL.value:
       // 参与拼团
-      shareParams.page = '/pages/activity/groupon/detail';
+      shareParams.page = SharePageEnum.GROUPON_DETAIL.page;
       shareParams.query = {
         id: shareParamsArray[2],
       };
       break;
-    case '6':
+    case SharePageEnum.POINT.value:
       // 积分商品
-      shareParams.page = '/pages/goods/point';
+      shareParams.page = SharePageEnum.POINT.page;
       shareParams.query = {
         id: shareParamsArray[2],
       };
@@ -176,7 +176,7 @@ const decryptSpm = (spm) => {
     }
   }
 
-  if (shareParams.page !== '/pages/index/index') {
+  if (shareParams.page !== SharePageEnum.HOME.page) {
     $router.go(shareParams.page, shareParams.query);
   }
   return shareParams;
@@ -189,9 +189,10 @@ const bindBrokerageUser = async (val = undefined) => {
     if (!shareId) {
       return;
     }
-    const { data, msg } = await BrokerageApi.bindBrokerageUser({ bindUserId: shareId });
+    // 绑定成功返回 true,失败返回 false
+    const { data } = await BrokerageApi.bindBrokerageUser({ bindUserId: shareId });
     // 绑定成功后清除缓存
-    if (!!data || msg.includes('不能绑定自己')) {
+    if (data) {
       uni.removeStorageSync('shareId');
     }
   } catch (e) {

+ 11 - 10
sheep/request/index.js

@@ -80,13 +80,13 @@ http.interceptors.request.use(
     if (config.custom.showLoading) {
       LoadingInstance.count++;
       LoadingInstance.count === 1 &&
-        uni.showLoading({
-          title: config.custom.loadingMsg,
-          mask: true,
-          fail: () => {
-            uni.hideLoading();
-          },
-        });
+      uni.showLoading({
+        title: config.custom.loadingMsg,
+        mask: true,
+        fail: () => {
+          uni.hideLoading();
+        },
+      });
     }
 
     // 增加 token 令牌、terminal 终端、tenant 租户的请求头
@@ -124,9 +124,10 @@ http.interceptors.response.use(
       if (response.data.code === 401) {
         return refreshToken(response.config);
       }
-
-      // 错误提示
-      if (response.config.custom.showError) {
+      // 特殊:处理分销用户绑定失败的提示
+      if ((response.data.code + '').includes('1011007')) {
+        console.error(`分销用户绑定失败,原因:${response.data.msg}`);
+      } else if (response.config.custom.showError) { // 错误提示
         uni.showToast({
           title: response.data.msg || '服务器开小差啦,请稍后再试~',
           icon: 'none',

+ 4 - 4
sheep/ui/su-tabbar-item/su-tabbar-item.vue

@@ -9,7 +9,7 @@
         <image
           v-if="icon"
           :name="icon"
-          :color="isActive ? parentData.activeColor : parentData.color"
+          :color="isActive ? parentData.activeColor : parentData.inactiveColor"
           :size="20"
         ></image>
         <block v-else>
@@ -30,7 +30,7 @@
         <text
           class="u-tabbar-item__text"
           :style="{
-            color: isActive ? parentData.activeColor : parentData.color,
+            color: isActive ? parentData.activeColor : parentData.inactiveColor,
           }"
         >
           {{ text }}
@@ -120,8 +120,8 @@
         addStyle,
         parentData: {
           value: null,
-          activeColor: '',
-          color: '',
+          activeColor: '', // 选中标签的颜色
+          inactiveColor: '', // 未选中标签的颜色
         },
         parent: {},
       };

+ 36 - 0
sheep/util/const.js

@@ -134,3 +134,39 @@ export const getTimeStatusEnum = (startTime, endTime) => {
     return TimeStatusEnum.STARTED;
   }
 };
+/**
+ * 分享页枚举
+ * 按需扩展
+ * */
+export const SharePageEnum = {
+  HOME: {
+    name: '首页',
+    page: '/pages/index/index',
+    value: '1'
+  },
+  GOODS: {
+    name: '普通商品页',
+    page: '/pages/goods/index',
+    value: '2'
+  },
+  GROUPON: {
+    name: '拼团商品页',
+    page: '/pages/goods/groupon',
+    value: '3'
+  },
+  SECKILL: {
+    name: '秒杀商品页',
+    page: '/pages/goods/seckill',
+    value: '4'
+  },
+  GROUPON_DETAIL: {
+    name: '参与拼团页',
+    page: '/pages/activity/groupon/detail',
+    value: '5'
+  },
+  POINT: {
+    name: '积分商品页',
+    page: '/pages/goods/point',
+    value: '6'
+  }
+}