فهرست منبع

feat:实名模块添加开关

DaMoWang 2 سال پیش
والد
کامیت
e9e9e4fd2c
6فایلهای تغییر یافته به همراه117 افزوده شده و 123 حذف شده
  1. 6 12
      src/main.js
  2. 16 6
      src/pages/accountDetails/integral.vue
  3. 3 1
      src/pages/accountDetails/teaBaby.vue
  4. 54 78
      src/pages/my/index.vue
  5. 31 26
      src/utils/myfun.js
  6. 7 0
      src/utils/run_now.js

+ 6 - 12
src/main.js

@@ -6,6 +6,9 @@ Vue.config.productionTip = false
 // import uView from "uview-ui";
 // Vue.use(uView);
 
+// 此文件配置进入app即运行的方法
+require('@/utils/run_now.js');
+
 import md5 from 'js-md5';
 Vue.prototype.$md5 = md5;
 
@@ -23,18 +26,6 @@ Vue.mixin(share)
 import highPrecision from "@/utils/highPrecision";
 Vue.prototype.$h = highPrecision;
 
-Vue.prototype.tidyTpye = (da) => {
-    switch(da) {
-        case '1': return "零售专区";
-        case '2': return "批发专区";
-        case '3': return "精品专区";
-        case '4': return "今日值得买";
-        case '5': return "茶宝兑换";
-        case '6': return "天天捡漏";
-        default: return ""
-    }
-}
-
 // 自动适配接口域名
 import hosts from "@/request/config";
 Vue.prototype.$hosts = hosts;
@@ -46,6 +37,9 @@ Vue.prototype.$up = up;
 // 页面跳转
 import { goto } from '@/utils/myfun.js';
 Vue.prototype.goto = goto;
+// 专区判断
+import { tidyTpye } from '@/utils/myfun.js';
+Vue.prototype.tidyTpye = tidyTpye;
 
 App.mpType = 'app'
 

+ 16 - 6
src/pages/accountDetails/integral.vue

@@ -16,10 +16,8 @@
     <view class="con">
       <view class="list" v-for="(item, index) in list" :key="index">
         <view class="list_head flex_r flex_ac flex_jb">
-          <view class="head_name" v-if="item.type == 0">零售收货发放积分</view>
-          <view class="head_name" v-else-if="item.type == 1">批发扣除积分</view>
-          <view class="head_name" v-else-if="item.type == 2">退货积分</view>
-          <view class="head_price g_color">{{item.act}}{{ item.num }}</view>
+          <view class="head_name">{{ type(item.type) }}</view>
+          <view :class="['head_price',item.act == '+' ? 'g_color' : '']">{{item.act}}{{ item.num }}</view>
         </view>
         <view class="list_con flex_r flex_ac flex_jb">
           <view class="list_balance">{{ item.create_time }}</view>
@@ -55,7 +53,7 @@ export default {
       page: 1,
     };
   },
-  onShow: function () {
+  onShow() {
     this.page = 1;
     this.list = [];
     this.loadData();
@@ -102,10 +100,22 @@ export default {
       this.loadData();
     },
   },
+  computed: {
+    type() {
+      return (va) => {
+        switch (va) {
+          case 0: return "零售收货发放积分";
+          case 1: return "批发扣除积分";
+          case 2: return "退货积分";
+          default: return "";
+        }
+      }
+    }
+  },
   /**
    * 页面上拉触底事件的处理函数
    */
-  onReachBottom: function () {
+  onReachBottom() {
     if (page != -1) {
       var that = this;
       setTimeout(function () {

+ 3 - 1
src/pages/accountDetails/teaBaby.vue

@@ -101,6 +101,7 @@ export default {
   computed: {
     type() {
       return (va) => {
+        let is = uni.getStorageSync("isAuthentication");
         switch (va) {
           case 0: return "购物送茶宝";
           case 1: return "签到送茶宝";
@@ -113,7 +114,8 @@ export default {
           case 8: return "核销后送茶宝";
           case 9: return "余额转化茶宝";
           case 10: return "收到赠送茶宝";
-          case 11: return "实名送茶宝";
+          case 11: return is ? "实名送茶宝" : "注册送茶宝";
+          case 12: return "分享用户送茶宝";
           default: return "";
         }
       }

+ 54 - 78
src/pages/my/index.vue

@@ -1,9 +1,6 @@
 <template>
   <view class="container">
-    <view
-      class="content"
-      :style="userinfo.is_authentication == 1 ? 'padding-top:30rpx;' : ''"
-    >
+    <view class="content" :style="isShiMing ? '' : 'padding-top:30rpx;'">
       <!-- 用户信息 -->
       <view class="uerInfo mar_t16 flex_r">
         <view class="user_img">
@@ -15,8 +12,8 @@
           ></image>
           <view
             class="coupon_info flex_r flex_ac"
-            v-if="isShiMing"
             @tap="goToAutonym"
+            v-if="isShiMing"
           >
             完成实名认证,享受更多权益
             <image
@@ -26,20 +23,15 @@
               @tap.stop="closeAuto"
             >
             </image>
-            <view class="sj_icon"></view>
           </view>
         </view>
-        <block v-if="userinfo && userinfo != ''">
+        <block v-if="userinfo.nickname">
           <view class="user_con flex_c">
             <view class="user_name flex_r flex_ae ellipsis">
               <view @click="goto('/pages/my/userinfo')">{{
                 userinfo.nickname
               }}</view>
-              <text
-                >({{
-                  userinfo.is_authentication == 0 ? "未实名" : "已实名"
-                }})</text
-              >
+              <text v-if="isAuthentication">({{ userinfo.is_authentication == 0 ? "未实名" : "已实名" }})</text>
             </view>
             <view class="flex_r flex_ac">
               <view class="user_level clearfix">
@@ -393,11 +385,10 @@
 </template>
 
 <script>
-let page = 1;
 let app = getApp();
 var appEv = app.$vm.$options;
-import authorizeModule from "@/components/authorize-module/index";
 import uniCopy from "@/utils/copy";
+import authorizeModule from "@/components/authorize-module/index";
 import { get, post } from "@/request/api.js";
 export default {
   components: {
@@ -410,7 +401,7 @@ export default {
       shopInfo: {}, // 商铺信息
       userInfoAccount: {}, // 账户数据
       customerServiceWeiXin: "", // 客服微信
-      isShiMing: true,
+      isShiMing: true, //未实名提示弹窗
       agentName: "", // 缘起
       user_id: undefined,
       userinfo: undefined, // 获取用户信息
@@ -420,33 +411,30 @@ export default {
       // isGetUserInfo:false,
       invited: "",
 
-      updataUserimg: {},
-
       allChaYou: "",
+
+      isAuthentication: true, //是否开启实名模块
     };
   },
-  onLoad: function (options) {
+  created () {
+    this.isAuthentication = uni.getStorageSync("isAuthentication");
+  },
+  onLoad(options) {
     //推荐人ID
     if (options.invite) {
       app.globalData.agentId = options.invite;
       this.invited = options.invite;
     }
-    post("/my/chayou").then((res) => {
-      if (res.code === 0) {
-        this.allChaYou = res.data.data.below + res.data.data.lower_level;
-      }
-    });
+    this.closeAuto(); //关闭实名功能
+    this.getchayou(); //获取茶友
   },
-  onShow: function () {
+  onShow() {
     let token = uni.getStorageSync("token");
-
     this.userinfo = uni.getStorageSync("userinfo");
-    this.isShiMing = this.userinfo.is_authentication == 0 ? true : false;
 
     if (!token) {
       this.login();
-    }
-    if (token) {
+    }else {
       this.getuserInfo();
     }
   },
@@ -475,7 +463,7 @@ export default {
                 } else {
                   that.unid = res.data.unid;
                   that.shopInfo = app.globalData.shopInfo;
-                  that.showAuth = true;
+                  that.showAuth = true; //调取授权弹窗
                 }
               }
             });
@@ -488,6 +476,7 @@ export default {
       this.goto("/pages/my/login");
       // #endif
     },
+    // 获取手机号
     onauthGetTelSuccess(da) {
       this.showAuth = false;
       post("getMobile", {
@@ -500,18 +489,19 @@ export default {
         }
       });
     },
+    // 获取userinfo
     getuserInfo() {
       post("/user/userinfo").then((res) => {
         if (res.code === 0) {
           uni.setStorageSync("userinfo", res.data.data);
           this.userinfo = res.data.data;
-          this.isShiMing = this.userinfo.is_authentication == 0 ? true : false;
+          if(this.isAuthentication) this.isShiMing = this.userinfo.is_authentication == 0;
+          else this.isShiMing = false;
         }
       });
     },
-
     //授权并登录
-    onAuthSuccess: function () {
+    onAuthSuccess() {
       var that = this;
       uni.showLoading({
         mask: true,
@@ -523,53 +513,42 @@ export default {
     },
     // 跳转到实名页面
     goToAutonym() {
-      // post('/user/isPayAuth').then(res => {
-      // 	if(res.code === 0){
-      // 		if(res.data.)
-      // 	}
-      // })
-      // return
-      uni.navigateTo({
-        url: "/pages/autonym-submit/index",
-      });
+      this.goto("/pages/autonym-submit/index")
     },
-    // 关闭实名信息
+    // 关闭实名信息 提示
     closeAuto() {
       this.isShiMing = false;
     },
     // 未开放提示信息
-    SetHint: function () {
+    SetHint() {
       uni.navigateTo({
         url: "/pages/tea-rule/index",
       });
     },
-
     // 跳转到分享页面
-    getImgPage: function () {
-      let that = this;
-      if (this.userinfo.is_authentication == 1) {
-        uni.navigateTo({
-          url: "/pages/invi-img/index",
-        });
-      } else {
-        appEv.errTips("您还未实名");
-        uni.navigateTo({
-          url: "/pages/autonym-submit/index",
-        });
+    getImgPage() {
+      if(this.isAuthentication){
+        if (this.userinfo.is_authentication == 1) {
+          this.goto("/pages/invi-img/index")
+        }else{
+          appEv.errTips("您还未实名");
+          this.goToAutonym();
+        }
+      }else{
+        this.goto("/pages/invi-img/index")
       }
     },
     // 跳转到提现页面
-    getToCash: function () {
-      let that = this;
-      if (this.userinfo.is_authentication == 1) {
-        uni.navigateTo({
-          url: "/pages/cash/index",
-        });
-      } else {
-        appEv.errTips("您还未实名");
-        uni.navigateTo({
-          url: "/pages/autonym-submit/index",
-        });
+    getToCash() {
+      if(this.isAuthentication){
+        if (this.userinfo.is_authentication == 1) {
+          this.goto("/pages/cash/index")
+        }else{
+          appEv.errTips("您还未实名");
+          this.goToAutonym();
+        }
+      }else{
+        this.goto("/pages/cash/index")
       }
     },
     // 复制账号
@@ -604,13 +583,12 @@ export default {
         url: "/pages/my-acc-money/my-acc-money",
       });
     },
-
     // 更换头像
     upheadimg() {
       let that = this;
       uni.chooseImage({
         count: 1, // 最多可以选择的图片张数,默认9
-        sizeType: ["compressed"], // original 原图,compressed 压缩图,默认二者都有
+        sizeType: ["original"], // original 原图,compressed 压缩图,默认二者都有
         sourceType: ["album", "camera"], // album 从相册选图,camera 使用相机,默认二者都有
         success: function (res) {
           var arr = res.tempFiles;
@@ -626,6 +604,14 @@ export default {
         },
       });
     },
+    // 获取茶友
+    getchayou(){
+      post("my/chayou").then((res) => {
+        if (res.code === 0) {
+          this.allChaYou = res.data.data.below + res.data.data.lower_level;
+        }
+      });
+    }
   },
 };
 </script>
@@ -657,16 +643,6 @@ page {
   width: 26rpx;
 }
 
-.sj_icon {
-  position: absolute;
-  top: 100%;
-  left: 60rpx;
-  border-top: 16rpx solid rgba(0, 0, 0, 0.8);
-  border-right: 16rpx solid transparent;
-  border-left: 16rpx solid transparent;
-  border-bottom: 0;
-}
-
 .coupon_info {
   position: absolute;
   top: -70rpx;

+ 31 - 26
src/utils/myfun.js

@@ -1,7 +1,7 @@
 // 返回两个日期之间的月份
 export function getDiffDate(minDate, maxDate) {
-  let startDate = new Date(minDate.replace(/-/g,'/'));
-  let endDate = new Date(maxDate.replace(/-/g,'/'));
+  let startDate = new Date(minDate.replace(/-/g, '/'));
+  let endDate = new Date(maxDate.replace(/-/g, '/'));
   let months = [];
   //把时间的天数都设置成当前月第一天
   startDate.setDate(1)
@@ -22,7 +22,9 @@ export function getDiffDate(minDate, maxDate) {
   return months;
 }
 
-export function times(date, ym, txt) {
+// 时间格式化
+export function times(date, ym) {
+  date = new Date(date.replace(/-/g, '/'));
   var y = date.getFullYear();
   var m = date.getMonth() + 1;
   m = m < 10 ? "0" + m : m;
@@ -34,24 +36,14 @@ export function times(date, ym, txt) {
   minute = minute < 10 ? "0" + minute : minute;
   var second = date.getSeconds();
   second = second < 10 ? "0" + second : second;
-  if(txt === 1){
-    if (ym === "mds") {
-      return m + "月" + d + "日 " + h + ":" + minute;
-    }
-  } else if(txt === 2){
-    if (ym === "ymds") {
-      return y + "." + m + "." + d + " " + h + ":" + minute;
-    }
-  } else {
-    if (ym == "ym") {
-      return y + "-" + m;
-    }
-    else if (ym == "ymd") {
-      return y + "-" + m + "-" + d;
-    }
-    else if (ym == "ymds") {
-      return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
-    }
+  if (ym == "ym") {
+    return y + "-" + m;
+  }
+  else if (ym == "ymd") {
+    return y + "-" + m + "-" + d;
+  }
+  else if (ym == "ymds") {
+    return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
   }
 }
 
@@ -67,12 +59,12 @@ export function RtoH(color) {
 }
 // 将hex颜色转成rgb
 export function HtoR(hex, opacity) {
-  var RGBA = "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt( "0x" + hex.slice(5, 7)) + "," + opacity + ")";
+  var RGBA = "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")";
   // return { red: parseInt("0x" + hex.slice(1, 3)), green: parseInt("0x" + hex.slice(3, 5)), blue: parseInt("0x" + hex.slice(5, 7)), rgba: RGBA }
   return RGBA;
 }
 
-  // 189 **** 0222
+// 189 **** 0222
 export function phoneNumA(value) {
   if (value && value.length > 8) {
     return `${value.substring(0, 3)} ${"*".repeat(value.length - 7).replace(/(.{4})/g, "$1 ")}${value.length % 4 ? " " : ""}${value.slice(-4)}`;
@@ -80,12 +72,12 @@ export function phoneNumA(value) {
   return value;
 }
 
-//$goto
+// goto
 export function goto(url, json) {
   let params = "";
-  if(json){
+  if (json) {
     params = [];
-    let da = Object.keys(json).map(function(key) {
+    let da = Object.keys(json).map(function (key) {
       if (json[key]) return encodeURIComponent(key) + "=" + encodeURIComponent(json[key]);
     });
     da.forEach(e => {
@@ -96,4 +88,17 @@ export function goto(url, json) {
   uni.navigateTo({
     url: url + '?' + params
   });
+}
+
+// tidyTpye
+export function tidyTpye(va) {
+  switch (va) {
+    case '1': return "零售专区";
+    case '2': return "批发专区";
+    case '3': return "精品专区";
+    case '4': return "今日值得买";
+    case '5': return "茶宝兑换";
+    case '6': return "天天捡漏";
+    default: return ""
+  }
 }

+ 7 - 0
src/utils/run_now.js

@@ -0,0 +1,7 @@
+import { get, post } from "@/request/api.js";
+post('isAuthentication').then(res => {
+    if (res.code === 0) {
+        // uni.setStorageSync("isAuthentication", true);
+        uni.setStorageSync("isAuthentication", res.data.data);
+    }
+})