Browse Source

no message

WIN-20230912WHV\Administrator 1 year ago
parent
commit
9e80890dfb

+ 37 - 2
pages/login/index.vue

@@ -49,7 +49,7 @@
           <view class="wx-text sys-size-24 text-color-7c sys-weight-400">第三方登录</view>
           <view class="wx-wire"></view>
         </view>
-        <image class="wx-logo" src="/static/img/login/wx-img.png" mode="aspectFill"></image>
+        <image @click="wxLogin" class="wx-logo" src="/static/img/login/wx-img.png" mode="aspectFill"></image>
       </view>
 
 
@@ -58,7 +58,7 @@
 <script>
   import {commonSend} from "@/api/common";
   import tools from "@/service/tools";
-  import {login} from "@/api/login";
+  import {login, wxLogin} from "@/api/login";
   import EnInput from "@/components/en-from/en-input/index.vue";
   import Agreement from "@/pages/login/model/agreement.vue";
 
@@ -101,6 +101,41 @@
 
     },
     methods: {
+      wxLogin() {
+        if (!this.isConsent) {
+          tools.error('请阅读并同意协议');
+          this.$refs.agreement.setConsentShake()
+          return;
+        }
+        if (this.isAjax) {
+          return false;
+        }
+        this.isAjax = true;
+        uni.login({
+          provider: "weixin",
+          success: (loginRes) =>{
+            wxLogin({'code':loginRes.code}).then((res)=>{
+              if(res.code===403){
+                tools.error('当前用户未注册')
+                uni.setStorageSync('openid',res.data.openid)
+                setTimeout(()=>{
+                  //跳转至注册页面
+                  uni.navigateTo({
+                    url: '/pages/login/register'
+                  });
+                },1500)
+              }else if(res.code===1){
+                tools.setLoginData(res.data,true)
+              }else {
+                tools.error(res.msg)
+              }
+              this.isAjax = false;
+            })
+          }
+        })
+
+
+      },
       goToUrl(type){
         if(type===1){
           uni.navigateTo({

+ 42 - 1
pages/login/register.vue

@@ -2,6 +2,12 @@
   <view class="page-box login-box">
     <view class="login-form sys-radius-50 sys-background-fff">
       <view class="from-box animate__animated animate__fadeIn">
+        <view class=" input-img">
+          <button class="head-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" >
+          <image src="https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/app-serve/2024-4-17/gvbknkvhub.png?imageMogr2/quality/20"  class="head-img"></image>
+          </button>
+          <view class="head-text text-color-666 sys-size-24">点击上传头像</view>
+        </view>
         <view class="input-item  sys-from-background-color sys-radius-30 animate__animated" :class="{'animate__shakeX':shakeNum===1}" >
           <en-input type="nickname" class="login-input" placeholder="请输入昵称"  v-model="accountData.nickname"  ></en-input>
         </view>
@@ -48,6 +54,7 @@ import tools from "../../service/tools";
 import {commonSend} from "../../api/common";
 import Agreement from "@/pages/login/model/agreement.vue";
 import {register, wxLogin} from "@/api/login";
+import txUploadFile from "@/service/txOssSts";
 
 export default {
   components: {Agreement, EnInput},
@@ -62,7 +69,7 @@ export default {
         'wxCode':'',
         'name':'',
         'nickname':'',
-        'head_img':'',
+        'head_img':'https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/app-serve/2024-4-17/gvbknkvhub.png?imageMogr2/quality/20',
       },
       timeNum:0,
       timer:null,
@@ -81,6 +88,21 @@ export default {
     },
   },
   methods:{
+    onChooseAvatar(e) {
+      // console.log(e);
+      txUploadFile(e.detail.avatarUrl).then((res) => {
+        if (res.Location) {
+          this.accountData.head_img = res.Location;
+          tools.hideLoading();
+        }else {
+          tools.hideLoading();
+          tools.error('上传失败')
+        }
+      }).catch((err) => {
+        tools.hideLoading();
+      })
+      // this.accountData.head_img = e.detail.avatarUrl;
+    },
     goToUrl(type){
       uni.reLaunch({
         'url':'/pages/login/index'
@@ -258,6 +280,25 @@ export default {
       line-height: 96rpx;
       text-align: center;
     }
+    .input-img{
+      display: flex;
+      flex-direction: column;
+      justify-content: center;
+      .head-button{
+        margin: auto;
+        padding: 0;
+        border-radius: 50%;
+        .head-img{
+          width: 90rpx;
+          height: 90rpx;
+          border-radius: 50%;
+        }
+      }
+
+      .head-text{
+        text-align: center;
+      }
+    }
   }
   .register-box{
     display: flex;

File diff suppressed because it is too large
+ 0 - 0
service/cos-wx-sdk-v5.min.js


+ 286 - 36
service/tools.js

@@ -1,9 +1,3 @@
-
-import {
-    Base64
-} from '@/js_sdk/js-base64/base64';
-
-
 let tools = {}
 /**
  * 大小判断
@@ -15,7 +9,15 @@ tools.sortNumber = function (a, b) {
     return a - b;
 }
 
-
+/**
+ * 隐藏手机号码
+ * @param phone
+ * @returns {*}
+ */
+tools.hidePhone = function (phone) {
+    let reg = /^(\d{3})\d{4}(\d{4})$/;
+    return phone.replace(reg, '$1****$2');
+}
 /**
  * 保留两位小数
  * @param num
@@ -53,7 +55,7 @@ tools.error = function (msg) {
         'title': msg,
         'icon': 'error',
         'mask': true,
-        'duration': 1500
+        'duration': 1000
     })
 }
 
@@ -66,7 +68,7 @@ tools.success = function (msg) {
         'title': msg,
         'icon': 'success',
         'mask': true,
-        'duration': 1500
+        'duration': 1000
     })
 }
 
@@ -87,6 +89,23 @@ tools.hideLoading = function () {
     uni.hideLoading();
 }
 
+/**
+ * 32位随机字符串+时间 首位字母
+ */
+tools.SetString = function () {
+	let str = '';
+	let list=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','1','2','3','4','5','6','7','8','9','0'];
+	let numOne = Math.round(Math.random()*14);
+	let oneStr = list[numOne];
+	for (let i=1;i<=32;i++){
+		let num = Math.round(Math.random()*24);
+		str += list[num];
+	}
+	let time = new Date().getTime()
+	return oneStr+str+time;
+}
+
+
 /**
  * 获取时间戳(毫秒)
  * @returns {number}
@@ -96,6 +115,20 @@ tools.getTime = function () {
 }
 
 
+// 返回上级
+tools.leftClick = function () {
+    let pages = getCurrentPages();
+    if (pages.length > 1) {
+        uni.navigateBack({
+            delta: 1
+        })
+    } else {
+        uni.reLaunch({
+            url: '/pages/index/index'
+        });
+    }
+}
+
 tools.updateVersion = function (sysVersion, appUrl) {
     let app_version = plus.runtime.version;
     console.log('版本号信息对比------------------------------' + app_version + '---------' + sysVersion)
@@ -118,8 +151,8 @@ tools.updateVersion = function (sysVersion, appUrl) {
                             if (res.confirm === true) {
                                 plus.runtime.install(//安装
                                     downloadResult.tempFilePath, {
-                                    force: true
-                                },
+                                        force: true
+                                    },
                                     function (res) {
                                         tools.success('更新成功,重启中')
                                         plus.runtime.restart();
@@ -143,33 +176,141 @@ tools.updateVersion = function (sysVersion, appUrl) {
  */
 tools.imgDeal = function (str) {
     console.log(str)
-    if(str===null || str===undefined){
+    if (str === null || str === undefined) {
         return '';
-    }else {
+    } else {
         return str.replace(/\<img/gi, '<img style="width:100%;height:auto;display:block;"');
     }
 
 }
 
+/**
+ * 获取用户类型
+ * @returns {number}
+ */
+tools.getReceivingType = function () {
+    let receivingType = uni.getStorageSync('receivingType')
+    if (!receivingType) {
+        receivingType = 0;
+    } else {
+        receivingType = receivingType * 1;
+    }
+    return receivingType;
+}
 
 /**
- * 获取平台类型  1:微信,2:支付宝
- * @returns {boolean|number}
+ * 获取是否有录单权限
+ * @returns {number}
  */
-tools.platformType = function () {
-    let ua = window.navigator.userAgent.toLowerCase();
-    if (ua.indexOf('micromessenger') != -1) {
-        return 1;
-    } else if (ua.indexOf('alipay') != -1) {
-        return 2;
+tools.getEnteringType = function () {
+    let enteringType = uni.getStorageSync('enteringType')
+    if (!enteringType) {
+        enteringType = 0;
     } else {
-        return 0;
+        enteringType = enteringType * 1;
     }
+    return enteringType;
+}
+
+/**
+ * 记录用户登录信息
+ * @param data
+ * @param type
+ */
+tools.setLoginData = function (data, type) {
+    uni.setStorageSync('m_id', data.m_id)
+    uni.setStorageSync('token', data.token)
+    uni.setStorageSync('status', data.status)
+    uni.setStorageSync('ministerType', data.minister_type)
+    uni.setStorageSync('receivingType', data.receivingType)
+    uni.setStorageSync('enteringType', data.enteringType)
+    if (type) {
+        tools.success('登陆成功')
+        setTimeout(() => {
+            if (data.status * 1 === 0) {
+                //审核状态跳转至待审核页面
+                uni.reLaunch({
+                    url: '/pages/login/module/await-audit'
+                });
+            } else {
+                let excelPath=uni.getStorageSync('excelPath');
+                console.log('excelPath:'+excelPath)
+                if(excelPath){
+                    uni.reLaunch({
+                        url: excelPath
+                    });
+                }else {
+                    uni.reLaunch({
+                        url: '/pages/index/index'
+                    });
+                }
+
+            }
+        }, 1500)
+    }
+
 }
 
 
 /**
- * 获取开发平台
+ * 获取日期
+ * @returns {string}
+ */
+tools.getDate = function () {
+    let myDate = new Date();
+    // let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
+    // let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
+    // let myToday = myDate.getDate(); //获取当前日(1-31)
+    // let myDay = myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
+    // let myHour = myDate.getHours(); //获取当前小时数(0-23)
+    // let myMinute = myDate.getMinutes(); //获取当前分钟数(0-59)
+    // let mySecond = myDate.getSeconds(); //获取当前秒数(0-59)
+    return myDate.getFullYear() + '-' + (myDate.getMonth() + 1) + '-' + myDate.getDate()
+}
+
+tools.getRandFileName = function (filePath) {
+    let extIndex = filePath.lastIndexOf('.');
+    let extName = extIndex === -1 ? '' : filePath.substr(extIndex);
+    return parseInt('' + Date.now() + Math.floor(Math.random() * 900 + 100), 10).toString(36) + extName;
+}
+
+/**
+ * 拨打电话
+ * @param phone
+ */
+tools.makingCall = function (phone) {
+    uni.makePhoneCall({
+        phoneNumber: phone
+    });
+}
+
+
+tools.getOssVideo = function (url) {
+    let strFileName = url.substring(0, url.lastIndexOf("."));
+    return strFileName + '_vj_0.jpg';
+}
+
+tools.getFileType = function (url) {
+    let suffixArr = ['.pdf', '.doc', '.docx', '.xlsx', '.xls']
+    let suffix = url.substring(url.lastIndexOf("."));
+    console.log(suffix)
+    let suffixKey = suffixArr.indexOf(suffix)
+    let fileType = 1;
+    if (suffixKey < 1) {
+        fileType = 1
+    } else if (suffixKey < 3) {
+        fileType = 2
+    } else {
+        fileType = 3
+    }
+    return fileType
+}
+tools.getFileName = function (url) {
+    return url.substring(url.lastIndexOf("/") - 1, url.lastIndexOf("."));
+}
+
+/**
+ * 获取平台类型
  * @returns {string}
  */
 tools.getPlatform = function () {
@@ -187,7 +328,7 @@ tools.getPlatform = function () {
     platForm = 'APP';
     //#endif
     // #ifdef MP-WEIXIN
-    platForm = 'MP-WEIXIN'; // 小程序
+    platForm = 'MP-WEIXIN';
     //#endif
     // #ifdef MP-ALIPAY
     platForm = 'MP-ALIPAY';
@@ -215,24 +356,133 @@ tools.getPlatform = function () {
 }
 
 /**
- * 记录用户登录信息
- * @param data
- * @param type
+ * 等额本息
+ * @param loansMoney
+ * @param refundNum
+ * @param interestRate
  */
-tools.setLoginData = function (data) {
-    uni.setStorageSync('m_id', data.m_id)
-    uni.setStorageSync('token', data.token)
-    tools.success('登陆成功')
-    setTimeout(() => {
-        uni.reLaunch({
-            url: '/pages/index/index'
-        });
-    }, 1500)
+tools.getAverageCapitalPlusInterest = function (loansMoney, refundNum, interestRate) {
+    console.log('getAverageCapitalPlusInterest:等额本息')
+    let repaymentMoney = 0;
+    if (!loansMoney || loansMoney <= 0 || !refundNum || refundNum <= 0 || !interestRate || interestRate <= 0) {
+        return repaymentMoney
+    }
+    let monthlyInterest = interestRate / 12 / 100;
+    // console.log( ((monthlyInterest * Math.pow((1 + monthlyInterest), refundNum)) / (Math.pow((1 + monthlyInterest), refundNum) - 1)))
+    repaymentMoney = (loansMoney * ((monthlyInterest * Math.pow((1 + monthlyInterest), refundNum)) / (Math.pow((1 + monthlyInterest), refundNum) - 1))).toFixed(2)
+    // console.log('repaymentMoney:'+repaymentMoney)
+    return repaymentMoney
+}
 
+/**
+ * 等额本金
+ * @param loansMoney
+ * @param refundNum
+ * @param interestRate
+ * @returns {number}
+ */
+tools.getAverageCapital = function (loansMoney, refundNum, interestRate) {
+    console.log('getAverageCapital:等额本金')
+    let repaymentMoney = 0;
+    if (!loansMoney || loansMoney <= 0 || !refundNum || refundNum <= 0 || !interestRate || interestRate <= 0) {
+        return repaymentMoney
+    }
+    let monthlyInterest = interestRate / 12 / 100;
+    repaymentMoney = (loansMoney / refundNum + loansMoney * monthlyInterest).toFixed(2)
+    return repaymentMoney
+}
+
+/**
+ * 先息后本
+ * @param loansMoney
+ * @param interestRate
+ * @returns {string|number}
+ */
+tools.getInterestFirst = function (loansMoney, interestRate) {
+    console.log('getInterestFirst:先息后本')
+    let repaymentMoney = 0;
+    if (!loansMoney || loansMoney <= 0 || !interestRate || interestRate <= 0) {
+        return repaymentMoney
+    }
+    let monthlyInterest = interestRate / 12 / 100;
+    repaymentMoney = (loansMoney * monthlyInterest).toFixed(2)
+    return repaymentMoney
+}
+
+/**
+ * 获取日期
+ * @returns {{d: number, y: number, m: number}}
+ */
+tools.getDateArr = function (time) {
+    console.log('time:' + time)
+    let myDate = new Date(time);
+    let myYear = myDate.getFullYear(); //获取完整的年份(4位,1970-????)
+    let myMonth = myDate.getMonth() + 1; //获取当前月份(0-11,0代表1月)
+    let myToday = myDate.getDate(); //获取当前日(1-31)
+    // let myDay = myDate.getDay(); //获取当前星期X(0-6,0代表星期天)
+    // let myHour = myDate.getHours(); //获取当前小时数(0-23)
+    // let myMinute = myDate.getMinutes(); //获取当前分钟数(0-59)
+    // let mySecond = myDate.getSeconds(); //获取当前秒数(0-59)
+    return {'y': myYear, 'm': myMonth>=10?myMonth:'0'+myMonth, 'd': myToday>=10?myToday:'0'+myToday};
 }
 
+/**
+ * 获取统计时间
+ * @param d
+ * @param num
+ * @returns {[{d: number, y: number, m: number},{d: number, y: number, m: number}]}
+ */
+tools.getStatisticsDate = function (d, num) {
+    let date = new Date(d)
+    let dateTime = date.getTime();
+    dateTime += (num * 86400000);
+    return [tools.getDateArr(dateTime), tools.getDateArr(dateTime)];
+}
 
+/**
+ *
+ * @returns {[{d: number, y: number, m: number},{d: number, y: number, m: number}]}
+ */
+tools.getNextWeek = function (d, num) {
+    let date = new Date(d)
+    let dateTime = date.getTime();
+    console.log('start:' + dateTime)
+    dateTime += (num * 86400000);
+    let weekDate = new Date(dateTime)
+    let weekday = weekDate.getDay();
+    let weekStarTime;
+    let weekEndTime;
+    if (weekday === 0) {
+        weekStarTime = dateTime - 86400000 * 6;
+        weekEndTime = dateTime;
+    } else {
+        weekStarTime = dateTime - (86400000 * (weekday - 1));
+        weekEndTime = weekStarTime + (86400000 * 7);
+    }
+    return [tools.getDateArr(weekStarTime), tools.getDateArr(weekEndTime)];
+}
 
+tools.getNextMonth = function (d, num) {
+    let date = new Date(d)
+    let dateTime = date.getTime();
+    dateTime += (num * 86400000);
+    let newDate = new Date(dateTime)
+    let year = newDate.getFullYear(); //获取完整的年份(4位,1970-????)
+    let month = newDate.getMonth(); //获取当前月份(0-11,0代表1月)
+    let starTime = new Date(year, month , 1).valueOf() ;
+    let endTime = new Date(year, month+ 1 , 1).valueOf()  - 86400000;
+    return [tools.getDateArr(starTime), tools.getDateArr(endTime)];
+}
 
+tools.getNextYear = function (d, num) {
+    let date = new Date(d)
+    let dateTime = date.getTime();
+    dateTime += (num * 86400000);
+    let newDate = new Date(dateTime)
+    let year = newDate.getFullYear(); //获取完整的年份(4位,1970-????)
+    let starTime = new Date(year, 0 , 1).valueOf() ;
+    let endTime = new Date(year+ 1, 0 , 1).valueOf()  - 86400000;
+    return [tools.getDateArr(starTime), tools.getDateArr(endTime)];
+}
 
 export default tools

+ 95 - 0
service/txOssSts.js

@@ -0,0 +1,95 @@
+/**
+ * 微信小程序通过STS直传阿里云OSS
+ *(uniapp版上传,小程序原生需要将uni.XXX替换为wx.XXX)
+ *
+ * @param {filePath} 图片临时地址
+ * @param {option|Object} OSS和STS配置
+ * @param {savePath} oss中的文件目录
+ * @param {AccessKeySecret} 服务端返回的STS中的AccessKeySecret
+ * @param {SecurityToken} 服务端返回的STS中的SecurityToken
+ * @param {AccessKeyId} 服务端返回的STS中的AccessKeyId
+ * @param {bucket} 存储桶
+ * @param {area} 地区
+ * @return {string|boolean} 成功返回文件地址,失败返回false
+ */
+import COS from "./cos-wx-sdk-v5.min"
+
+console.log(COS)
+import tools from "./tools";
+import {getTxySts} from "@/api/common";
+
+// 存储桶名称,由bucketname-appid 组成,appid必须填入,可以在COS控制台查看存储桶名称。 https://console.cloud.tencent.com/cos5/bucket
+let Bucket = 'wealfavor-1257406827';
+// 存储桶Region可以在COS控制台指定存储桶的概览页查看 https://console.cloud.tencent.com/cos5/bucket/
+// 关于地域的详情见 https://cloud.tencent.com/document/product/436/6224
+let Region = 'ap-beijing';
+
+let cos=null;
+function startCos(){
+    cos = new COS({
+        getAuthorization: function (options, callback) {
+            console.log('---------------获取初始化信息')
+            getTxySts().then((res)=>{
+                if(res.code===1){
+                    callback({
+                        TmpSecretId: res.data.tmpSecretId,
+                        TmpSecretKey: res.data.tmpSecretKey,
+                        XCosSecurityToken: res.data.sessionToken,
+                        StartTime: res.data.StartTime, // 时间戳,单位秒,如:1580000000,建议返回服务器时间作为签名的开始时间,避免用户浏览器本地时间偏差过大导致签名错误
+                        ExpiredTime: res.data.ExpiredTime, // 时间戳,单位秒,如:1580000900
+
+
+                    })
+                }
+            })
+
+        }
+    });
+}
+
+/**
+ * COS文件上传
+ * @param file
+ * @returns {Promise<unknown>}
+ */
+function txUploadFile(file){
+    if(cos===null){
+        console.log('对象初始化')
+        //初始化对象
+        startCos();
+    }
+    tools.showLoading()
+    return new Promise((resolve, reject) => {
+        console.log('cos-*-------------------------',cos)
+        console.log(file)
+        console.log('/app-serve/'+tools.getDate()+tools.getRandFileName(file))
+        // 分片上传文件
+        cos.postObject({
+            Bucket: Bucket,
+            Region: Region,
+            Key: '/app-serve/'+tools.getDate()+'/'+tools.getRandFileName(file),
+            FilePath: file,
+            onHashProgress: function (progressData) {
+                console.log('校验中', JSON.stringify(progressData));
+            },
+            onProgress: function (progressData) {
+                console.log('上传中', JSON.stringify(progressData));
+            },
+        }, function (err, data) {
+            tools.hideLoading()
+            console.log(err, data);
+            if(data.Location!==undefined){
+                data.Location='https://'+data.Location+'?imageMogr2/quality/50';
+                resolve( data)
+            }else {
+                resolve( false)
+            }
+
+        });
+    })
+
+}
+
+
+
+export default txUploadFile

+ 0 - 42
service/upLoadingFile.js

@@ -1,42 +0,0 @@
-import {
-	getSts
-} from "@/api/common.js";
-import tools from "./tools";
-import AliOss from 'uploading-oss'
-let ossData = null;
-let sysTime = 0;
-let setAliSts = async function () {
-	let res = await getSts({});
-	if (res.code === 1) {
-		ossData = res.data;
-		sysTime = setTime();
-	} else {
-		tools.error(res.msg);
-	}
-}
-
-let setTime = function () {
-	return (new Date()).getTime();
-}
-let getFilPathName = function () {
-	let date = new Date();
-	return "image/" + date.getYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
-}
-
-export const upLoadingFileOss = async function (file) {
-	if (ossData === null || (sysTime + 900000 <= setTime())) {
-		await setAliSts();
-	}
-	return new Promise((resolve, reject) => {
-		AliOss.uploadOss(file, {
-			savePath: getFilPathName(),
-			AccessKeySecret: ossData.AccessKeySecret,
-			SecurityToken: ossData.SecurityToken,
-			AccessKeyId: ossData.AccessKeyId,
-			bucket: "jhnewshop",
-			area: "oss-cn-chengdu",
-		}, function (res) {
-			resolve(res);
-		});
-	});
-}

+ 1 - 1
static/css/login.css

@@ -1,5 +1,5 @@
 .login-box{
-    height: 100vh;
+    min-height: 100vh;
     background-image: url("https://wealfavor-1257406827.cos.ap-beijing.myqcloud.com/app-serve/2024-4-13/gv7g9xqmxv.png?imageMogr2/quality/20");
     background-repeat: no-repeat;
     background-size: 100% auto;

BIN
static/img/login/await_audit.png


BIN
static/img/login/await_bg.png


Some files were not shown because too many files changed in this diff