|
|
@@ -0,0 +1,431 @@
|
|
|
+<template>
|
|
|
+ <view class="app-main app-content">
|
|
|
+ <view class="model">
|
|
|
+ <view class="experFrame">
|
|
|
+ <view>
|
|
|
+ <view style="text-align:center;margin-bottom:10upx;">
|
|
|
+ <image :src="`${constant.imgUrl}/logo3.png`" class="logo" mode="widthFix"></image>
|
|
|
+ </view>
|
|
|
+ <view style="color:#666666;text-align:center;margin-bottom:50upx;font-size:35upx;">销花宝</view>
|
|
|
+
|
|
|
+ <template>
|
|
|
+ <view>
|
|
|
+ <input @focus="mobile=''" v-model="mobile" class="experInput" placeholder="手机号" type="number" />
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <input @focus="password=''" v-model="password" class="experInput" placeholder="密码" type="password" />
|
|
|
+ </view>
|
|
|
+ <view style="margin-top:40upx;">
|
|
|
+ <CaptchaVerify
|
|
|
+ ref="captchaVerify"
|
|
|
+ @verify-success="onVerifySuccess"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+ <view style="margin-top:40upx;display:flex;justify-content:center;">
|
|
|
+ <button class="admin-button-com big" :class="[verified== true ? 'blue' : 'default']" style="width:75%;" @click="loginFun">登陆</button>
|
|
|
+ </view>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <!-- #ifdef MP-WEIXIN -->
|
|
|
+ <view style="margin-top:35upx;">
|
|
|
+ <view style="color:black;font-size:30upx;margin-top:20upx;">这是门店的管理后台,需获取你的手机号登录后</view>
|
|
|
+ <view style="color:black;font-size:30upx;margin-top:15upx;">才能使用相应功能,请谅解</view>
|
|
|
+ <view style="color:black;font-size:30upx;margin-top:15upx;margin-bottom:30upx;">如不需要,可以点击<text style="color:#3385FF;font-size:36upx;font-weight:bold;margin-left:8upx;" @click="goBack()">拒绝使用</text></view>
|
|
|
+ </view>
|
|
|
+ <!-- #endif -->
|
|
|
+ <!-- #ifdef APP-PLUS -->
|
|
|
+ <view style="color:#999999;font-size:25upx;margin-top:55upx;">
|
|
|
+ <checkbox-group @change="agreeItem">
|
|
|
+ <label>
|
|
|
+ <checkbox value="1" style="transform:scale(0.8)" :checked="agree == 1" />
|
|
|
+ <text>
|
|
|
+ 我已阅读并同意
|
|
|
+ <text style="font-weight:bold;color:#666666;" @click.stop="goToService">《服务协议》</text>
|
|
|
+ 和
|
|
|
+ <text style="font-weight:bold;color:#666666;" @click.stop="goToPrivacy">《隐私政策》</text>
|
|
|
+ </text>
|
|
|
+ </label>
|
|
|
+ </checkbox-group>
|
|
|
+ </view>
|
|
|
+ <!-- #endif -->
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+</template>
|
|
|
+<script>
|
|
|
+import { mapActions } from "vuex";
|
|
|
+import { getShopInfo} from "@/utils/auth";
|
|
|
+import {appLogin} from '@/api/common'
|
|
|
+import { getDictionaries,postWxCode } from '@/api/mini'
|
|
|
+import { replaceClientId } from '@/api/admin'
|
|
|
+import { phoneLogin,wxMobileLogin } from "@/api/auth";
|
|
|
+import CaptchaVerify from "@/components/CaptchaVerify.vue";
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "login",
|
|
|
+ components: {
|
|
|
+ CaptchaVerify
|
|
|
+ },
|
|
|
+ mixins: [],
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ mobile:'',
|
|
|
+ password: '',
|
|
|
+ hasMobileNet:false,
|
|
|
+ agree:0,
|
|
|
+ showAccountLogin:false,
|
|
|
+
|
|
|
+ verified: false // 是否已通过验证
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ },
|
|
|
+ onLoad(){
|
|
|
+ let that = this
|
|
|
+ uni.getNetworkType({
|
|
|
+ success: function (res) {
|
|
|
+ that.dealLogin(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ uni.onNetworkStatusChange(this.dealLogin)
|
|
|
+
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ //如果登录状态失效了,重新登录一次,更新session_key,这样session_key才有效,微信手机号登录才会成功
|
|
|
+ uni.checkSession({
|
|
|
+ success(){
|
|
|
+ console.log('checkSession success')
|
|
|
+ },
|
|
|
+ fail(){
|
|
|
+ uni.login({
|
|
|
+ provider: 'weixin',
|
|
|
+ success: res => {
|
|
|
+ uni.setStorageSync('code', res.code)
|
|
|
+ postWxCode({ code: res.code }).then(subRes => {
|
|
|
+ if(subRes.data.currentMiniOpenId){
|
|
|
+ let currentMiniOpenId = subRes.data.currentMiniOpenId
|
|
|
+ uni.setStorageSync('currentMiniOpenId', currentMiniOpenId)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ },
|
|
|
+ onUnload(){
|
|
|
+ uni.offNetworkStatusChange(this.dealLogin)
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ ...mapActions(['setUserShopAll']),
|
|
|
+ goBack(){
|
|
|
+ uni.navigateBack({})
|
|
|
+ },
|
|
|
+ // 验证成功回调
|
|
|
+ onVerifySuccess() {
|
|
|
+ this.verified = true;
|
|
|
+ this.$msg ? this.$msg('验证成功') : uni.showToast({ title: '验证成功', icon: 'success' });
|
|
|
+ },
|
|
|
+ useSms(){
|
|
|
+ this.$util.pageTo({url: "/admin/home/smsLogin",type:2})
|
|
|
+ },
|
|
|
+ useAccount(){
|
|
|
+ this.showAccountLogin = true
|
|
|
+ this.agree = 0
|
|
|
+ this.$forceUpdate()
|
|
|
+ },
|
|
|
+ goToService(){
|
|
|
+ plus.runtime.openURL('http://www.wixhb.com/main/xhb-register')
|
|
|
+ },
|
|
|
+ goToPrivacy(){
|
|
|
+ plus.runtime.openURL('http://www.wixhb.com/main/xhb-privacy')
|
|
|
+ },
|
|
|
+ agreeItem(e){
|
|
|
+ let arr = e.target.value
|
|
|
+ if (this.$util.isEmpty(arr)) {
|
|
|
+ this.agree = 0
|
|
|
+ }else{
|
|
|
+ this.agree = 1
|
|
|
+ }
|
|
|
+ },
|
|
|
+ dealLogin(res){
|
|
|
+ let that = this
|
|
|
+ console.log(res)
|
|
|
+ switch(res.networkType){
|
|
|
+ case '2g':
|
|
|
+ that.hasMobileNet = true
|
|
|
+ break;
|
|
|
+ case '3g':
|
|
|
+ that.hasMobileNet = true
|
|
|
+ break;
|
|
|
+ case '4g':
|
|
|
+ that.hasMobileNet = true
|
|
|
+ break;
|
|
|
+ case '5g':
|
|
|
+ that.hasMobileNet = true
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ that.hasMobileNet = false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ wxPhoneLogin(e){
|
|
|
+ let that = this
|
|
|
+ let currentMiniOpenId = uni.getStorageSync('currentMiniOpenId')
|
|
|
+ if (e.detail.errMsg === "getPhoneNumber:ok") {
|
|
|
+ wxMobileLogin({ iv: e.detail.iv, encryptedData: e.detail.encryptedData,miniOpenId:currentMiniOpenId }).then(subRes => {
|
|
|
+ uni.hideLoading()
|
|
|
+ if(subRes.data && subRes.data.hasNoOpenId && subRes.data.hasNoOpenId ==1){
|
|
|
+ that.$util.confirmModal({content:'网络异常,请重新操作'},() => {
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ uni.clearStorage()
|
|
|
+ that.$store.commit("setLoginInfo", {})
|
|
|
+ that.$util.pageTo({url: "/admin/home/workbench",type: 3})
|
|
|
+ // #endif
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ uni.clearStorage()
|
|
|
+ that.$store.commit("setLoginInfo", {})
|
|
|
+ plus.runtime.restart()
|
|
|
+ // #endif
|
|
|
+ })
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ let token = subRes.data.token || ''
|
|
|
+ if (that.$util.isEmpty(token)) {
|
|
|
+ that.$msg('请先注册')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
+ if(subRes.code == 1){
|
|
|
+ if (that.$util.isEmpty(subRes)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ uni.setStorageSync('token', subRes.data.token)
|
|
|
+ uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
|
|
|
+ getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
+ if (that.$util.isEmpty(res)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
+ that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
+ })
|
|
|
+ that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
+ getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
+ that.setUserShopAll()
|
|
|
+
|
|
|
+ uni.navigateBack()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.$msg("登录失败");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mobileLogin(){
|
|
|
+ let that = this
|
|
|
+
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ if(this.agree == 0){
|
|
|
+ this.$msg('请同意并勾选服务协议和隐私政策')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ uni.preLogin({
|
|
|
+ provider: 'univerify',
|
|
|
+ success:()=>{
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.login({
|
|
|
+ provider: 'univerify',
|
|
|
+ // 自定义登录框样式
|
|
|
+ univerifyStyle: {
|
|
|
+ "fullScreen": true,
|
|
|
+ "privacyTerms": {
|
|
|
+ "defaultCheckBoxState":false,
|
|
|
+ "checkBoxSize":18
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 登录成功
|
|
|
+ success:(res)=>{
|
|
|
+ let openid = res.authResult.openid
|
|
|
+ let access_token = res.authResult.access_token
|
|
|
+ phoneLogin({openid,access_token}).then(subRes=>{
|
|
|
+ let token = subRes.data.token || ''
|
|
|
+ if (that.$util.isEmpty(token)) {
|
|
|
+ that.$msg('请先注册')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
+ if(subRes.code == 1){
|
|
|
+ if (that.$util.isEmpty(subRes)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ uni.setStorageSync('token', subRes.data.token)
|
|
|
+ uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
|
|
|
+ getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
+ if (that.$util.isEmpty(res)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
+ that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
+ })
|
|
|
+ that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
+ getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
+ that.setUserShopAll()
|
|
|
+ uni.navigateBack()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(res){
|
|
|
+ uni.showToast({title:'已取消', duration: 3000, icon:'none'})
|
|
|
+ //关闭一键登录弹出窗口
|
|
|
+ uni.closeAuthView()
|
|
|
+ console.log(res)
|
|
|
+ },
|
|
|
+ complete: (res) => {
|
|
|
+ uni.hideLoading()
|
|
|
+ uni.closeAuthView()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(res){
|
|
|
+ //如果手机没有插入有效的sim卡,或者手机蜂窝数据网络关闭,都有可能造成预登录校验失败
|
|
|
+ if (res.code == 30005) {
|
|
|
+ uni.showToast({title: '请关闭WIFI,打开移动流量', duration: 3000, icon:'none'})
|
|
|
+ } else if(res.code == 1000) {
|
|
|
+ uni.showToast({title: '即将开通', duration: 3000, icon:'none'})
|
|
|
+ } else if(res.code == 40004) {
|
|
|
+ uni.showToast({title: '即将开通...', duration: 3000, icon:'none'})
|
|
|
+ } else {
|
|
|
+ uni.showToast({title: '登录失败...', duration: 3000, icon:'none'})
|
|
|
+ }
|
|
|
+ console.log(res)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ loginFun(){
|
|
|
+ let that = this
|
|
|
+ let mobile = this.mobile
|
|
|
+ let password = this.password
|
|
|
+ // #ifdef APP-PLUS
|
|
|
+ if(that.agree == 0){
|
|
|
+ this.$msg('请同意并勾选服务协议和隐私政策')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // #endif
|
|
|
+ if (that.$util.isEmpty(mobile)) {
|
|
|
+ this.$msg('请输入手机号')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(this.$util.checkMobile(mobile) == false){
|
|
|
+ this.$msg('请输入正确手机号')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if (that.$util.isEmpty(password)) {
|
|
|
+ this.$msg('请输入密码')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ // 检查是否已通过验证码验证
|
|
|
+ if (!this.verified) {
|
|
|
+ this.$msg('请先完成验证')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ uni.showLoading({mask:true})
|
|
|
+ //有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
|
|
|
+ appLogin({mobile, password}).then(subRes=>{
|
|
|
+ uni.hideLoading()
|
|
|
+ if(subRes.code == 1){
|
|
|
+ if (that.$util.isEmpty(subRes)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ uni.setStorageSync('token', subRes.data.token)
|
|
|
+ uni.setStorageSync('shopId', subRes.data.admin.currentGhsShopId)
|
|
|
+ getDictionaries({ token: subRes.data.token }).then(res => {
|
|
|
+ if (that.$util.isEmpty(res)) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ that.$store.commit('setDictionariesInfo', { ...res.data.dict, ...res.data })
|
|
|
+ that.$store.commit('setMyShopInfo', { ...res.data.shop, ...res.data })
|
|
|
+ })
|
|
|
+ that.$store.commit('setLoginInfo', { ...subRes.data.admin, ...subRes.data })
|
|
|
+ getShopInfo(true).then(res => { uni.setNavigationBarTitle({ title: res.name }) })
|
|
|
+ that.setUserShopAll()
|
|
|
+ uni.navigateBack()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.model {
|
|
|
+ position: fixed;
|
|
|
+ z-index: 9999;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ width: 100vw;
|
|
|
+ height: 100vh;
|
|
|
+ color: #fff;
|
|
|
+ overflow: hidden;
|
|
|
+ text-align: center;
|
|
|
+ & > .noData_img {
|
|
|
+ width: 318upx;
|
|
|
+ height: 318upx;
|
|
|
+ margin: 332upx auto 0;
|
|
|
+ }
|
|
|
+ & > .no_data_text {
|
|
|
+ font-size: 32upx;
|
|
|
+ color: #ffffff;
|
|
|
+ text-align: center;
|
|
|
+ margin: 50upx 0;
|
|
|
+ }
|
|
|
+ & > .freeApply {
|
|
|
+ width: 376upx;
|
|
|
+ height: 88upx;
|
|
|
+ line-height: 88upx;
|
|
|
+ background: linear-gradient(90deg, #3385ff, #33b0ff);
|
|
|
+ border-radius: 44upx;
|
|
|
+ margin: 0 auto;
|
|
|
+ font-size: 32upx;
|
|
|
+ color: #ffffff;
|
|
|
+ text-align: center;
|
|
|
+ }
|
|
|
+ &>.experience{
|
|
|
+ margin-top: 40upx;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 30upx;
|
|
|
+ }
|
|
|
+ &>.experFrame{
|
|
|
+ margin-top:20upx;
|
|
|
+ height: 50upx;
|
|
|
+ .experInput{
|
|
|
+ height: 80upx;
|
|
|
+ width: 550upx;
|
|
|
+ margin-bottom:38upx;
|
|
|
+ display: inline-block;
|
|
|
+ vertical-align: middle;
|
|
|
+ background-color: #f5f5f5;
|
|
|
+ border:none;
|
|
|
+ border-bottom: 1px solid #CCCCCC;
|
|
|
+ color: #666;
|
|
|
+ padding-left: 20upx;
|
|
|
+ box-sizing: border-box;
|
|
|
+ text-align: left;
|
|
|
+ }
|
|
|
+ .buttonText{
|
|
|
+ display: inline-block;
|
|
|
+ line-height:92upx;
|
|
|
+ padding: 0 20upx;
|
|
|
+ vertical-align: middle;
|
|
|
+ font-size: 32upx;
|
|
|
+ width: 550upx;
|
|
|
+ height:90upx;
|
|
|
+ }
|
|
|
+ .logo{
|
|
|
+ width:180upx;
|
|
|
+ margin:0 auto;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|