Browse Source

no message

linwenxin 1 year ago
parent
commit
e251a9b5d9

+ 2 - 2
.env.production

@@ -2,10 +2,10 @@
 NODE_ENV = 'production'
 
 # URL地址
-VUE_APP_BASE_URL = 'https://knowledge.gd-jxm.com'
+VUE_APP_BASE_URL = 'https://jiasm.zfire.top'
 
 # API
-VUE_APP_BASE_API = '/api'
+VUE_APP_BASE_API = '/recycleapi'
 
 # PATH
 VUE_APP_BASE_PATH = '/recycleh5/'

+ 1 - 1
.env.test

@@ -2,7 +2,7 @@
 NODE_ENV = 'test'
 
 # URL地址
-VUE_APP_BASE_URL = 'https://knowledge.zfire.top'
+VUE_APP_BASE_URL = 'https://jiasm.zfire.top'
 
 # API
 VUE_APP_BASE_API = '/api'

+ 18 - 0
src/common/utils/common.js

@@ -218,6 +218,24 @@ export function isWeixin() {
 	}
 }
 
+// 解析地址栏参数
+export function getQueryVariable(variable) {
+	// 从?开始获取后面的所有数据
+	var query = window.location.search.substring(1);
+	// 从字符串&开始分隔成数组split
+	var vars = query.split('&');
+	// 遍历该数组
+	for (var i = 0; i < vars.length; i++) {
+		// 从等号部分分割成字符
+		var pair = vars[i].split('=');
+		// 如果第一个元素等于 传进来的参的话 就输出第二个元素
+		if (pair[0] == variable) {
+		return pair[1];
+		}
+	}
+	return undefined;
+}
+
 
 export default {
 	toast,

+ 243 - 0
src/components/zj-dialog-verification.vue

@@ -0,0 +1,243 @@
+<template>
+	<u-popup
+		mode="center" 
+		:round="10" 
+		:closeable="true" 
+		:show="isShow" 
+		@close="closeDialog">
+		<view class="code-dialog">
+			<view class="title">请完成安全验证</view>
+			<view class="pt">
+				<view class="pt-verification-box">
+					<view class="pt-verification-images">
+						<view class="iconfont refresh" @click="refresh">&#xe64c;</view>
+						<image mode="widthFix" :src="'data:image/jpeg;base64,'+bgImg" class="bg-img"></image>
+						<image :src="'data:image/jpeg;base64,'+maskImg" class="drag-img" mode="widthFix" :style="{ left: dragWidth + 'px', top: top + 'px'}"></image>
+						<view class="mask"></view>
+					</view>
+					<view class="pt-dragbar">
+						<view :class="['pt-drag-area',{fail: isFail,success: isSuccess}]" :style="{ width: dragWidth + 'px'}" v-if="dragWidth"></view>
+						<movable-area class="pt-dragbar-area">
+							<movable-view
+								:class="['pt-dragbar-view',{active: dragWidth > 2,fail: isFail,success: isSuccess}]"
+								:direction="direction"
+								@change="dragStart"
+								@touchend="dragEnd"
+								:damping="200"
+								:x="x"
+								:animation="false"
+								:disabled="disabled"
+								:data-dragWidth="dragWidth">
+								<text class="iconfont">
+									<block v-if="isSuccess">&#xe687;</block>
+									<block v-else-if="isFail">&#xe65c;</block>
+									<block v-else>&#xe62a;</block>
+								</text>
+							</movable-view>
+							<text v-if="dragWidth==0" class="tips">{{tips}}</text>
+						</movable-area>
+					</view>
+				</view>
+			</view>
+		</view>
+	</u-popup>
+</template>
+
+<script>
+	export default {
+		props: {
+			isShow: {
+				type: Boolean,
+				default: false
+			},
+			// 背景大图
+			bgImg: {
+				type:  [String,Number],
+				default: ''
+			},
+			// 块状小图
+			maskImg: {
+				type:  [String,Number],
+				default: ''
+			},
+			// 坑位的top值
+			top: {
+				type: [String,Number],
+				default: 0
+			},
+			// 滑块滑动的方向
+			direction: {
+				type:  [String,Number],
+				default: 'horizontal'
+			},
+			// 判断是否成功
+			isSuccess: {
+				type: Boolean,
+				default: false,
+			},
+			// 判断是否失败
+			isFail: {
+				type: Boolean,
+				default: false,
+			}
+		},
+		data() {
+			return {
+				tips: '向右拖动滑块填充拼图',
+				disabled: false,
+				dragWidth: 0,
+				x: 0
+			};
+		},
+		methods: {
+			closeDialog() {
+				this.$emit('close');
+			},
+			
+			// 开始滑动
+			dragStart(e){
+				this.dragWidth = e.detail.x
+			},
+			
+			// 停止滑动
+			dragEnd(e){
+				this.x = this.dragWidth;
+				this.$emit('finish', this.dragWidth);
+			},
+			
+			refresh(){
+				console.log(1);
+				this.dragWidth = 0;
+				this.isFail = false;
+				this.isSuccess = false;
+				this.x = 0;
+				this.disabled = false;
+				this.$emit('refresh');
+			}
+		}
+	}
+</script>
+
+<style lang="scss">
+	@font-face {
+	  font-family: 'iconfont';  /* project id 2047533 */
+	  src: url('https://at.alicdn.com/t/font_2047533_o8axbabfs3.ttf') format('truetype')
+	}
+	.iconfont {
+	  font-family: iconfont !important;
+	  font-size: 16px;
+	  font-style: normal;
+	  -webkit-font-smoothing: antialiased;
+	  -moz-osx-font-smoothing: grayscale;
+	}
+	.code-dialog {
+		padding: 20px;
+		border-radius: 10rpx;
+		display: flex;
+		flex-direction: column;
+		align-items: center;
+		.title {
+			font-size: 28rpx;
+			color: #333333;
+			width: 100%;
+			text-align: left;
+			margin-bottom: 10px;
+		}
+	}
+	.pt{
+		width: 300px;
+		margin: 0 auto;
+		&-verification-images{
+			position: relative;
+			.refresh{
+				position: absolute;
+				right: 20rpx;
+				top: 20rpx;
+				z-index: 10;
+				color: #FFF;
+				font-weight: bold;
+			}
+			.bg-img{
+				width: 100%;
+				vertical-align: top;
+			}
+			.drag-img{
+				position: absolute;
+				width: 112rpx;
+				height: 91rpx;
+				top: 0;
+				left: 0;
+				z-index: 1;
+			}
+			.mask {
+				position: absolute;
+				top: 0;
+				left: 0;
+				width: 100%;
+				height: 100%;
+				background: rgba($color: #000000, $alpha: .2);
+			}
+		}
+		&-dragbar{
+			position: relative;
+			height: 80rpx;
+			background-color: #F7F7F7;
+			border: solid 2rpx #EEE;
+			margin-top: 20rpx;
+			.pt-drag-area{
+				position: absolute;
+				height: 80rpx;
+				border: solid 2rpx $uni-color-primary;
+				background-color: #D1E9F1;
+				top: -2rpx;
+				&.fail{
+					border-color: $uni-color-error;
+					background-color: #ffdbdb;
+				}
+				&.success{
+					border-color: $uni-color-success;
+					background-color: #d7ffe1;
+				}
+			}
+			&-area{
+				position: absolute;
+				width: 100%;
+				height: 100%;
+				left: 0;
+				top: 0;
+				.tips{
+					font-size: 24rpx;
+					color: #999;
+					position: absolute;
+					left: 50%;
+					top: 50%;
+					transform: translate(-50%,-50%);
+				}
+			}
+			&-view{
+				width: 80rpx;
+				height: 80rpx;
+				display: flex;
+				align-items: center;
+				justify-content: center;
+				border: solid 2rpx #EEE;
+				background-color: #FFF;
+				top: -2rpx;
+				left: 0;
+				&.active{
+					background-color: $uni-color-primary;
+					border-color: $uni-color-primary;
+					color: #FFF;
+				}
+				&.fail{
+					background-color: $uni-color-error;
+					border-color: $uni-color-error;
+				}
+				&.success{
+					border-color: $uni-color-success;
+					background-color: #00a029;
+				}
+			}
+		}
+	}
+</style>

+ 3 - 2
src/manifest.json

@@ -44,8 +44,9 @@
     },
     // 使用地图或位置相关功能必须填写其一
     "mp-weixin" : {
-        /* 微信小程序特有相关 */
-        "appid" : "wxd935838591c00e16",
+        /* 小程序特有相关 */
+        "requiredPrivateInfos" : [ "chooseLocation", "getLocation", "chooseAddress" ],
+        "appid" : "wx930bbe7fd37277e6",
         "setting" : {
             "urlCheck" : false,
             "es6" : true,

+ 85 - 106
src/pages/login/indexs.vue

@@ -1,137 +1,142 @@
 <template>
-  <view class>
+  <view>
     <view class="logo">
       <view class="logo_top">
         <image style="width: 100%;height: 100%" src="@/static/login/logo.png" mode=""></image>
       </view>
       <view class="logo_bottom">
-        家盛茂-智能学习平台
+        家盛茂-回收平台
       </view>
     </view>
     <view class="loginForm">
       <u--form labelPosition="left" :model="model" :rules="rules" ref='model'>
-        <u-form-item label="" prop="accountCode" ref>
-          <u--input clearable shape='circle' placeholder="请输入账号" border="surround" v-model="model.accountCode">
+        <u-form-item label="" prop="mobile">
+          <u--input clearable shape='circle' placeholder="请输入手机号"  v-model="model.mobile">
             <view class="" style="" slot='prefix'>
               <image class="icon" src="@/static/login/icon_login_account.png" mode=""></image>
             </view>
           </u--input>
-          <!-- <u--input v-model="model.accountCode" border="none"></u--input> -->
         </u-form-item>
-        <u-form-item label="" prop="password" ref>
-          <u--input clearable :type='!eyeIcon ? "password":""' shape='circle' placeholder="请输入密码" border="surround"
-            v-model="model.password">
-            <view class="" style="" slot='prefix'>
-              <image class="icon" src="@/static/login/icon_login_password.png" mode=""></image>
-            </view>
-            <view class="" slot='suffix' @click="eyeFn">
-              <image v-show='eyeIcon === false' class="icon" src="@/static/login/icon_eyes_close.png" mode=""></image>
-              <image v-show='eyeIcon === true' class="icon" src="@/static/login/icon_eyes_open.png" mode=""></image>
-            </view>
-          </u--input>
-          <!-- <u--input v-model="model.password" border="none"></u--input> -->
-        </u-form-item>
-        <u-form-item label="" prop="codeValue" ref>
-          <u--input clearable shape='circle' placeholder="请输入验证码" border="surround" v-model="model.codeValue">
+        <u-form-item label="" prop="code">
+          <u--input clearable shape='circle' placeholder="请输入验证码" v-model="model.code">
             <view class="" style="" slot='prefix'>
               <image class="icon" src="@/static/login/icon_003.png" mode=""></image>
             </view>
-            <view class="" slot='suffix'>
-              <image @click="refreshFn" style="width: 240rpx;height: 60rpx;"
-                :src="'data:image/jpeg;base64,' + model.codeImage" mode=""></image>
+            <view class="" slot='suffix' @click="getImgV">
+              {{countDown?countDown+'S':'获取验证码'}}
             </view>
           </u--input>
-
-          <!-- <u--input v-model="model.codeValue" border="none"></u--input>
-          <image @click="refreshFn" style="width: 240rpx;height: 60rpx;"
-            :src="'data:image/jpeg;base64,' +model.codeImage" mode=""></image> -->
         </u-form-item>
       </u--form>
-      <view style="margin-top: 20rpx;">
-        <u-checkbox-group v-model="remember">
-          <u-checkbox shape='circle' label='记住密码' name='""'>
-          </u-checkbox>
-        </u-checkbox-group>
-      </view>
       <u-button @click='loginFn' class='loginBtn' type="primary" shape="circle" size="" text="登录"></u-button>
     </view>
-
-    <!-- <u-button @click='loginFn' type="primary" shape="circle" size="mini" text="重新学习"></u-button> -->
+    <zjDialogVerification
+        ref="verification" 
+        :isShow="isShowCodeDialog" 
+        :top="codeObj.yHeight" 
+        :bgImg="codeObj.bigImage" 
+        :maskImg="codeObj.smallImage" 
+        :isSuccess="codeObj.isSuccess" 
+        :isFail="codeObj.isFail" 
+        @close="isShowCodeDialog = false" 
+        @refresh="refresh" 
+        @finish="finish">
+      </zjDialogVerification>
   </view>
 </template>
 
 <script>
+  import zjDialogVerification from "@/components/zj-dialog-verification.vue";
+  import api from '@/common/http/'
   export default {
+    components:{
+      zjDialogVerification
+    },
     data() {
       return {
+        isShowCodeDialog:false,
+        codeObj: {
+					bigImage: '',
+					smallImage: '',
+					key: '',
+					yHeight: '',
+					isSuccess: false,
+					isFail: false,
+				},
         model: {
-          accountCode: '',
-          password: '',
+          mobile: '',
           code: '',
-          codeValue: '',
-          codeImage: ''
         },
         rules: {
-          accountCode: {
+          mobile: {
             type: 'string',
             required: true,
-            message: '号不能为空',
+            message: '手机号不能为空',
             trigger: ['blur', 'change']
           },
-          password: {
-            type: 'string',
-            required: true,
-            message: '密码不能为空',
-            trigger: ['blur', 'change']
-          },
-          codeValue: {
+          code: {
             type: 'string',
             required: true,
             message: '验证码不能为空',
             trigger: ['blur', 'change']
           },
-
         },
-        eyeIcon: false,
-        remember: [],
-
+        countDown: 0,
       }
     },
-    onShow() {
-      const value = uni.getStorageSync('recycle_mobile_login');
-      if (value) {
-        this.model.accountCode = value.usercode
-        this.model.password = value.password
+    watch:{
+      countDown(){
+        if(this.countDown>0){
+          setTimeout(()=>{
+            this.countDown--
+          },1000)
+        }
       }
-      // this.getCode()
     },
     methods: {
-      //存储账号密码
-      saveData() {
-        let data = {
-          usercode: this.model.accountCode,
-          password: this.model.password
-        }
-        uni.setStorageSync('recycle_mobile_login', data);
+      async getImgV(){
+        try {
+          if(this.countDown==0){
+            this.$refs.model.validateField("mobile",(res)=>{
+              if(!res.length){
+                api.get('/admin/user/getVerifi').then(res=>{
+                  this.codeObj = res.data;
+                  this.isShowCodeDialog = true
+                })
+              }
+            })
+          }
+        } catch (e) {}
       },
-      //密码显示隐藏
-      eyeFn() {
-        this.eyeIcon = !this.eyeIcon
+      refresh(){
+        this.getImgV()
+      },
+      finish(val){
+        api.postJson('/admin/user/smsCode',{
+          mobile:this.model.mobile,
+          code:this.codeObj.key,
+          codeValue:parseInt(val),
+        }).then(res=>{
+          this.isShowCodeDialog = false
+          this.codeObj = {
+            bigImage: '',
+            smallImage: '',
+            key: '',
+            yHeight: '',
+            isSuccess: false,
+            isFail: false,
+          }
+          this.countDown = 60
+        })
       },
       //登录
       async loginFn() {
-
-        await this.$refs.model.validate()
-        let newpassword = this.$passwordFn(this.model.password, this.model.password)
-        let params = {
-          "accountCode": this.model.accountCode,
-          "code": this.model.code,
-          "codeValue": this.model.codeValue,
-          "loginType": "account",
-          "passWord": newpassword,
-          "source": 1
-        }
         try {
+          await this.$refs.model.validate()
+          let params = {
+            "mobile": this.model.mobile,
+            "code": this.model.code,
+          }
           await this.$store.dispatch('user/login', params)
           await this.$store.dispatch('user/getInfo')
           await this.$Prompt.toast({
@@ -141,32 +146,8 @@
           this.$Router.push({
             name: 'learn'
           })
-
-          if (this.remember.length > 0) {
-            this.saveData()
-          }
-
-        } catch (e) {
-          this.$Prompt.toast({
-            title: '登陆失败',
-            icon: 'error'
-          })
-        }
-
+        } catch (e) {}
       },
-      //刷新验证码
-      refreshFn() {
-        this.getCode()
-      },
-      // 获取验证码
-      getCode() {
-        this.$api.get('/base/imageVerification').then(res => {
-          // console.log(res);
-          this.model.code = res.data.code
-          this.model.codeImage = res.data.pic
-        })
-      },
-
     }
   }
 </script>
@@ -208,8 +189,6 @@
   }
 
   .loginBtn {
-    // width: 630rpx;
-    // height: 100rpx;
     margin-top: 44rpx;
     background: linear-gradient(135deg, #7fdaff 0%, #6da7ff 100%);
     border-radius: 50rpx;

+ 35 - 12
src/router/index.js

@@ -4,7 +4,16 @@ import {
   createRouter
 } from 'uni-simple-router';
 import store from '@/store/index.js'
-// console.log(ROUTES);
+import {
+  isWeixin,
+  getQueryVariable
+} from '@/common/utils/common';
+
+function goJianquan(url){
+  const href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxaddd13c267e81e70&redirect_uri=${url}&response_type=code&scope=snsapi_userinfo#wechat_redirect`;
+  window.location.href = href;
+}
+
 const router = createRouter({
   platform: process.env.VUE_APP_PLATFORM,
   //H5跳转路由锁
@@ -36,18 +45,32 @@ router.beforeEach((to, from, next) => {
     '/pages/index/index',
     '/pages/mine/index',
   ]
-  
-  next();
-  // if (store.getters.token) {
-  //   next();
-  // } else {
-  //   if (whitePages.indexOf(to.path) >= 0) {
-  //     next();
-  //   } else {
-  //     next('/pages/login/index');
-  //   }
-  // }
+
+  // next();
+  if (whitePages.indexOf(to.path) >= 0) {
+    next();
+  }else{
+    if(isWeixin()){
+      if (store.getters.token) {
+        next();
+      }else{
+        var code = getQueryVariable('code');
+        if (code) {
+          // 去登入
+        } else if (!uni.getStorageSync('code')) {
+          goJianquan(location.href)
+        }
+      }
+    }else{
+      if (store.getters.token) {
+        next();
+      } else {
+        next('/pages/login/indexs');
+      }
+    }
+  }
 });
+
 // 全局路由后置守卫
 router.afterEach((to, from) => {
   // console.log('跳转结束')

+ 9 - 2
src/store/modules/user/actions.js

@@ -6,23 +6,30 @@ export default {
   async autoLogin({
     commit
   }, params) {
-    let res = await api.post('/account/mobile-login', params);
+    let res = await api.get('/wechat/user/auth', params);
     let {
       data
     } = res;
+
+    console.log(data)
+
     commit('set_token', data.token);
     commit('set_username', data.accountBase.accountName);
     commit('set_usercode', data.accountBase.accountCode);
     uni.setStorageSync('recycle_mobile_token', data.token);
   },
+  
   // 登录
   async login({
     commit
   }, params) {
-    let res = await api.post('/account/login', params);
+    let res = await api.post('/wechat/user/mobile-login', params);
     let {
       data
     } = res;
+
+    console.log(data)
+
     commit('set_token', data.token);
     commit('set_username', data.accountBase.accountName);
     commit('set_usercode', data.accountBase.accountCode);