mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 10:57:25 +08:00
refactor: 移动端升级 Vue3 + uView Plus
将 lilishop-uniapp 从 Vue2/uView 1.6 迁移到 Vue3/uview-plus,优先支持 H5/微商城与微信小程序;移除 vendored uview-ui,改用 npm 依赖、Vuex4 与迁移脚本/补丁,并补充 VUE3_MIGRATION.md 回归清单。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<view class="u-skeleton" v-if="!articleData">
|
||||
<u-empty text="文章暂无内容" mode="list"></u-empty>
|
||||
</view>
|
||||
<u-parse v-else :html="articleData"></u-parse>
|
||||
<u-parse v-else :content="articleData"></u-parse>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<u-navbar :border-bottom="false"></u-navbar>
|
||||
<u-navbar :border="false"></u-navbar>
|
||||
<step1 v-if="current == 1" :companyData="companyData" @callback="next()" />
|
||||
<step2 v-if="current == 2" :companyData="companyData" @callback="next()" />
|
||||
<step3
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<u-navbar :border-bottom="false"></u-navbar>
|
||||
<u-navbar :border="false"></u-navbar>
|
||||
<div>
|
||||
<div class="title">店铺入驻</div>
|
||||
<div class="step-list">
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
if(this.$options.filters.tipsToLogin()){
|
||||
if(this.tipsToLogin()){
|
||||
this.init();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -116,12 +116,10 @@
|
||||
<div>
|
||||
<u-upload
|
||||
:file-list="licencePhotoFileList"
|
||||
:header="{ accessToken: storage.getAccessToken() }"
|
||||
:action="action"
|
||||
:auto-upload="false"
|
||||
width="200"
|
||||
@on-uploaded="onUploaded($event, 'licencePhoto')"
|
||||
@afterRead="onUploadAfterRead($event, 'licencePhoto', 'licencePhotoFileList')"
|
||||
:max-count="1"
|
||||
:show-progress="false"
|
||||
></u-upload>
|
||||
|
||||
<div class="tips">
|
||||
@@ -155,21 +153,17 @@
|
||||
<div>
|
||||
<u-upload
|
||||
:file-list="legalPhotoFileList"
|
||||
:header="{ accessToken: storage.getAccessToken() }"
|
||||
:action="action"
|
||||
:auto-upload="false"
|
||||
width="200"
|
||||
@on-uploaded="onUploaded($event, 'legalPhoto')"
|
||||
@afterRead="onUploadAfterRead($event, 'legalPhoto', 'legalPhotoFileList')"
|
||||
:max-count="1"
|
||||
:show-progress="false"
|
||||
></u-upload>
|
||||
<u-upload
|
||||
:file-list="legalPhotoFileList"
|
||||
:header="{ accessToken: storage.getAccessToken() }"
|
||||
:action="action"
|
||||
:file-list="legalPhotoBackFileList"
|
||||
:auto-upload="false"
|
||||
width="200"
|
||||
@on-uploaded="onUploaded($event, 'legalPhoto')"
|
||||
@afterRead="onUploadAfterRead($event, 'legalPhoto', 'legalPhotoBackFileList')"
|
||||
:max-count="1"
|
||||
:show-progress="false"
|
||||
></u-upload>
|
||||
</div>
|
||||
</u-form-item>
|
||||
@@ -192,20 +186,20 @@
|
||||
import { applyFirst } from "@/api/entry";
|
||||
import city from "@/components/m-city/m-city.vue";
|
||||
import storage from "@/utils/storage.js";
|
||||
import { upload } from "@/api/common.js";
|
||||
import { handleUploadAfterRead, getUploadedUrls } from "@/utils/uploadHelper.js";
|
||||
import * as RegExp from "@/utils/RegExp.js";
|
||||
export default {
|
||||
components: { "m-city": city },
|
||||
data() {
|
||||
return {
|
||||
storage,
|
||||
action: upload, //图片上传数据
|
||||
defaultInputStyle: {
|
||||
background: "#f7f7f7",
|
||||
padding: "0 20rpx",
|
||||
"border-radius": "10rpx",
|
||||
},
|
||||
legalPhotoFileList: [],
|
||||
legalPhotoBackFileList: [],
|
||||
licencePhotoFileList: [],
|
||||
form: {
|
||||
companyName: "",
|
||||
@@ -316,7 +310,7 @@ export default {
|
||||
companyData: {
|
||||
handler(val) {
|
||||
if (val) {
|
||||
this.$set(this, "form", val);
|
||||
this["form"] = val;
|
||||
// 给图片赋值
|
||||
const judgeDeepPhoto = ["legalPhoto", "licencePhoto"];
|
||||
judgeDeepPhoto.forEach((key) => {
|
||||
@@ -332,16 +326,20 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 图片上传
|
||||
onUploaded(lists, key) {
|
||||
let images = [];
|
||||
if(!this.form[key]){
|
||||
onUploadAfterRead(event, key, fileListKey) {
|
||||
if (!Array.isArray(this.form[key])) {
|
||||
this.form[key] = [];
|
||||
}
|
||||
lists.forEach((item) => {
|
||||
images.push(item.response.result);
|
||||
handleUploadAfterRead(event, this[fileListKey], () => {
|
||||
if (key === "legalPhoto") {
|
||||
this.form[key] = [
|
||||
...getUploadedUrls(this.legalPhotoFileList),
|
||||
...getUploadedUrls(this.legalPhotoBackFileList),
|
||||
];
|
||||
} else {
|
||||
this.form[key] = getUploadedUrls(this[fileListKey]);
|
||||
}
|
||||
});
|
||||
this.form[key].push(images[0]);
|
||||
},
|
||||
getPickerParentValue(e) {
|
||||
this.form.companyAddressIdPath = [];
|
||||
|
||||
@@ -89,7 +89,7 @@ export default {
|
||||
watch: {
|
||||
companyData: {
|
||||
handler(val) {
|
||||
this.$set(this, "form", val);
|
||||
this["form"] = val;
|
||||
console.log(this.form)
|
||||
},
|
||||
deep: true,
|
||||
|
||||
@@ -19,12 +19,10 @@
|
||||
<div>
|
||||
<u-upload
|
||||
:file-list="storeLogoFileList"
|
||||
:header="{ accessToken: storage.getAccessToken() }"
|
||||
:action="action"
|
||||
:auto-upload="false"
|
||||
width="200"
|
||||
@on-uploaded="onUploaded($event, 'storeLogo')"
|
||||
@afterRead="onUploadAfterRead($event, 'storeLogo', 'storeLogoFileList')"
|
||||
:max-count="1"
|
||||
:show-progress="false"
|
||||
></u-upload>
|
||||
</div>
|
||||
</u-form-item>
|
||||
@@ -101,7 +99,7 @@
|
||||
</m-city>
|
||||
|
||||
<u-select
|
||||
v-model="enableCategory"
|
||||
v-model:show="enableCategory"
|
||||
@confirm="confirmCategory"
|
||||
:list="categoryList"
|
||||
></u-select>
|
||||
@@ -115,7 +113,7 @@ import { applyThird } from "@/api/entry";
|
||||
import { getCategoryList } from "@/api/goods";
|
||||
import city from "@/components/m-city/m-city.vue";
|
||||
import storage from "@/utils/storage.js";
|
||||
import { upload } from "@/api/common.js";
|
||||
import { handleUploadAfterRead } from "@/utils/uploadHelper.js";
|
||||
import uniMap from "@/components/uniMap";
|
||||
import permision from "@/js_sdk/wa-permission/permission.js";
|
||||
export default {
|
||||
@@ -124,7 +122,6 @@ export default {
|
||||
return {
|
||||
storage,
|
||||
mapFlag: false,
|
||||
action: upload, //图片上传数据
|
||||
defaultInputStyle: {
|
||||
background: "#f7f7f7",
|
||||
padding: "0 20rpx",
|
||||
@@ -171,7 +168,7 @@ export default {
|
||||
watch: {
|
||||
companyData: {
|
||||
handler(val) {
|
||||
this.$set(this, "form", val);
|
||||
this["form"] = val;
|
||||
// 给图片赋值
|
||||
const judgeDeepPhoto = ["storeLogo"];
|
||||
|
||||
@@ -282,13 +279,10 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
// 图片上传
|
||||
onUploaded(lists, key) {
|
||||
let images = [];
|
||||
lists.forEach((item) => {
|
||||
images.push(item.response.result);
|
||||
onUploadAfterRead(event, key, fileListKey) {
|
||||
handleUploadAfterRead(event, this[fileListKey], (urls) => {
|
||||
this.form[key] = urls;
|
||||
});
|
||||
this.form[key] = images;
|
||||
},
|
||||
getPickerParentValue(e) {
|
||||
this.form.storeAddressIdPath = [];
|
||||
@@ -303,7 +297,7 @@ export default {
|
||||
} else {
|
||||
name += item.localName + ",";
|
||||
}
|
||||
this.$set(this.form,'storeAddressPath',name)
|
||||
this.form['storeAddressPath'] = name
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<div v-if="!wechatLogin">
|
||||
<u-navbar :is-back="showBack" :border-bottom="false"></u-navbar>
|
||||
<u-navbar :auto-back="showBack" :border="false"></u-navbar>
|
||||
<div>
|
||||
<div class="title">{{ loginTitleWay[current].title }}</div>
|
||||
<div :class="current == 1 ? 'desc-light' : 'desc'">
|
||||
{{ loginTitleWay[current].desc
|
||||
}}<span v-if="current == 1">{{ mobile | secrecyMobile }}</span>
|
||||
}}<span v-if="current == 1">{{secrecyMobile(mobile) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 手机号 -->
|
||||
@@ -24,9 +24,9 @@
|
||||
boxNormalColor="#D8D8D8" cursorColor="#D8D8D8" />
|
||||
|
||||
<div class="fetch-btn">
|
||||
<u-verification-code change-text="验证码已发送(x)" end-text="重新获取验证码" unique-key="page-login"
|
||||
<u-code change-text="验证码已发送(x)" end-text="重新获取验证码" unique-key="page-login"
|
||||
:seconds="seconds" @end="end" @start="start" ref="uCode" @change="codeChange">
|
||||
</u-verification-code>
|
||||
</u-code>
|
||||
<span @tap="fetchCode" :style="{ color: codeColor }">
|
||||
{{ tips }}</span>
|
||||
</div>
|
||||
@@ -46,9 +46,7 @@
|
||||
</div>
|
||||
|
||||
<div class="flex" v-show="current != 1">
|
||||
<u-checkbox-group :icon-size="24" width="45rpx">
|
||||
<u-checkbox shape="circle" v-model="enablePrivacy" active-color="#FF5E00"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
<u-checkbox usedAlone :icon-size="24" shape="circle" v-model:checked="enablePrivacy" active-color="#FF5E00"></u-checkbox>
|
||||
<div class="tips">
|
||||
未注册的手机号验证后将自动创建用户账号,登录即代表您已同意<span @click="navigateToPrivacy('PRIVACY_POLICY')">《隐私协议》</span>
|
||||
<span @click="navigateToPrivacy('USER_AGREEMENT')">
|
||||
@@ -63,14 +61,15 @@
|
||||
|
||||
<!-- 循环出当前可使用的第三方登录模式 -->
|
||||
<div class="flex login-list">
|
||||
<div v-if="item.code" :style="{ background: item.color }" class="login-item"
|
||||
v-for="(item, index) in loginList" :key="index">
|
||||
<template v-for="(item, index) in loginList" :key="index">
|
||||
<div v-if="item.code" :style="{ background: item.color }" class="login-item">
|
||||
<u-icon v-if="item.title != 'APPLE'" color="#fff" size="42" :name="item.icon"
|
||||
@click="navigateLogin(item)">
|
||||
</u-icon>
|
||||
<u-image v-else src="/static/appleidButton@2x.png" :lazy-load="false" @click="navigateLogin(item)"
|
||||
width="80" height="80" />
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<myVerification v-if="codeFlag" @send="verification" class="verification" ref="verification"
|
||||
business="LOGIN" />
|
||||
|
||||
@@ -46,7 +46,7 @@ export default {
|
||||
},
|
||||
},
|
||||
onShow() {
|
||||
this.$options.filters.forceLogin();
|
||||
this.forceLogin();
|
||||
scannerCodeLogin({ token: this.token }).then((res) => {
|
||||
if (res.data.code == 200) {
|
||||
let code = res.data.result;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<u-navbar :custom-back="back" title="公众网页登录"></u-navbar>
|
||||
<u-navbar :auto-back="false" @leftClick="back" title="公众网页登录"></u-navbar>
|
||||
<view class="wx-auth-container">
|
||||
<div class="box">
|
||||
<view class="logo-info">
|
||||
|
||||
@@ -1,383 +1,417 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<u-navbar :custom-back="back" title="小程序登录"></u-navbar>
|
||||
<u-modal v-model="phoneAuthPopup" :mask-close-able="true" :title="projectName+'商城'"
|
||||
:show-confirm-button="false">
|
||||
<div class="tips">
|
||||
为了更好地用户体验,需要您授权手机号
|
||||
</div>
|
||||
<button class="register" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
去授权
|
||||
</button>
|
||||
</u-modal>
|
||||
<view class="wx-auth-container">
|
||||
<div class="box">
|
||||
<view class="logo-info">
|
||||
<text class="title">欢迎进入{{ projectName }}</text>
|
||||
</view>
|
||||
<view class="small-tips">
|
||||
<view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
|
||||
<view>您的公开信息(昵称、头像)</view>
|
||||
</view>
|
||||
<view class="btns">
|
||||
<button type="primary" :disabled="logingFlag" bindtap="getUserProfile" @click="getUserProfile()"
|
||||
class="btn-auth">登录</button>
|
||||
<div @click="backToHome" class="btn-callback">暂不登录</div>
|
||||
</view>
|
||||
<div class="privacy">
|
||||
<u-checkbox shape="circle" v-model="checked" :active-color="lightColor">
|
||||
<div class="flex">
|
||||
阅读并同意<navigator class="light-color" url="/pages/mine/help/tips?type=PRIVACY_POLICY">《隐私协议》</navigator>
|
||||
<navigator class="light-color" url="/pages/mine/help/tips?type=USER_AGREEMENT">《用户协议》</navigator>
|
||||
</div>
|
||||
</u-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mpAutoLogin
|
||||
} from "@/api/connect.js";
|
||||
|
||||
import {
|
||||
whetherNavigate
|
||||
} from "@/utils/Foundation"; //登录跳转
|
||||
import {
|
||||
getUserInfo
|
||||
} from "@/api/members";
|
||||
import storage from "@/utils/storage.js";
|
||||
import config from '@/config/config'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
lightColor:this.$lightColor,
|
||||
checked:false,
|
||||
configs:config,
|
||||
// 是否展示手机号码授权弹窗,默认第一步不展示,要先获取用户基础信息
|
||||
phoneAuthPopup: false,
|
||||
// 授权信息展示,商城名称
|
||||
projectName: config.name,
|
||||
//微信返回信息,用于揭秘信息,获取sessionkey
|
||||
code: "",
|
||||
//微信昵称
|
||||
nickName: "",
|
||||
logingFlag: false,
|
||||
//微信头像
|
||||
image: "",
|
||||
};
|
||||
},
|
||||
|
||||
//微信小程序进入页面,先获取code,否则几率出现code和后续交互数据不对应情况
|
||||
mounted() {
|
||||
// 小程序默认分享
|
||||
uni.showShareMenu({
|
||||
withShareTicket: true
|
||||
});
|
||||
|
||||
|
||||
//获取code
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
if(res.errMsg === "login:ok") {
|
||||
this.code = res.code
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "系统异常,请联系管理员!"
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* TODO 此方法不一定是最优解,如果有更好的办法请在 https://gitee.com/beijing_hongye_huicheng/lilishop/issues 中提出
|
||||
* 小程序返回bug
|
||||
* 1.介于微信登录是在login.vue的基础上作为判断跳转来
|
||||
* 所以在页面栈中会自动记录回退路径,所以导致每次微信小程序点击回退就会自动返回login页面
|
||||
* 当然login页面的判断就是 没有登录就会跳转到微信小程序页面 导致了无法回退到之前页面
|
||||
* 2.解决方法: 尝试在回退的时候判断地址,让回退多一级这样就避免了
|
||||
*/
|
||||
|
||||
back() {
|
||||
whetherNavigate("wx");
|
||||
},
|
||||
backToHome() {
|
||||
uni.switchTab({
|
||||
url: `/pages/tabbar/home/index`,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
//获取用户信息
|
||||
getUserProfile(e) {
|
||||
if(!this.checked){
|
||||
uni.showToast({
|
||||
title:"请勾选协议",
|
||||
icon:'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.logingFlag = true;
|
||||
|
||||
if (this.code) {
|
||||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
|
||||
uni.getUserProfile({
|
||||
desc: "用于完善会员资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
||||
success: (res) => {
|
||||
console.log("success", res)
|
||||
this.nickName = res.userInfo.nickName;
|
||||
this.image = res.userInfo.avatarUrl;
|
||||
|
||||
/**
|
||||
* 根据公有的配置设置登录方式
|
||||
*/
|
||||
if(this.configs.enableFetchMobileLogin){
|
||||
this.phoneAuthPopup = true;
|
||||
return false
|
||||
}
|
||||
let iv = res.iv;
|
||||
let encryptedData = res.encryptedData;
|
||||
|
||||
let code = this.code;
|
||||
let image = this.image;
|
||||
let nickName = this.nickName;
|
||||
mpAutoLogin({
|
||||
encryptedData,
|
||||
iv,
|
||||
code,
|
||||
image,
|
||||
nickName,
|
||||
}).then((apiRes) => {
|
||||
storage.setAccessToken(apiRes.data.result.accessToken);
|
||||
storage.setRefreshToken(apiRes.data.result.refreshToken);
|
||||
// 登录成功
|
||||
uni.showToast({
|
||||
title: "登录成功!",
|
||||
icon: "none",
|
||||
});
|
||||
//获取用户信息
|
||||
getUserInfo().then((user) => {
|
||||
storage.setUserInfo(user.data.result);
|
||||
storage.setHasLogin(true);
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res)
|
||||
},
|
||||
});
|
||||
|
||||
this.logingFlag = false;
|
||||
}
|
||||
},
|
||||
|
||||
//获取手机号授权
|
||||
getPhoneNumber(e) {
|
||||
let iv = e.detail.iv;
|
||||
let encryptedData = e.detail.encryptedData;
|
||||
if (!e.detail.encryptedData) {
|
||||
uni.showToast({
|
||||
title: "请授予手机号码权限,手机号码会和会员系统用户绑定!",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let code = this.code;
|
||||
let image = this.image;
|
||||
let nickName = this.nickName;
|
||||
mpAutoLogin({
|
||||
encryptedData,
|
||||
iv,
|
||||
code,
|
||||
image,
|
||||
nickName,
|
||||
}).then((res) => {
|
||||
storage.setAccessToken(res.data.result.accessToken);
|
||||
storage.setRefreshToken(res.data.result.refreshToken);
|
||||
// 登录成功
|
||||
uni.showToast({
|
||||
title: "登录成功!",
|
||||
icon: "none",
|
||||
});
|
||||
//获取用户信息
|
||||
getUserInfo().then((user) => {
|
||||
storage.setUserInfo(user.data.result);
|
||||
storage.setHasLogin(true);
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/*微信授权*/
|
||||
page {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wx-auth-container {
|
||||
width: 100%;
|
||||
margin-top: 20%;
|
||||
}
|
||||
|
||||
.logo-info {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: flex-start;
|
||||
flex-direction: row;
|
||||
align-items: flex-start;
|
||||
padding: 20rpx;
|
||||
|
||||
flex-direction: column;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
text-align: center;
|
||||
-webkit-transform: scale(2.5);
|
||||
transform: scale(2.5);
|
||||
}
|
||||
|
||||
.logo-info-img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
text.title,
|
||||
text.shop {
|
||||
display: inline-block;
|
||||
font-size: 60rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
text.shop {
|
||||
display: inline-block;
|
||||
font-size: 55rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.box {
|
||||
margin: 0 32rpx;
|
||||
}
|
||||
|
||||
/* 文字提示*/
|
||||
.small-tips {
|
||||
width: 94%;
|
||||
padding: 20rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 0 0 20rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.auth-button {
|
||||
padding: 10px 20px;
|
||||
width: calc(100% - 20 * 4rpx);
|
||||
}
|
||||
|
||||
.tips {
|
||||
width: 80%;
|
||||
text-align: left;
|
||||
margin: 6% 10%;
|
||||
margin-top: 48rpx;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.register {
|
||||
color: $weChat-color !important;
|
||||
border: none !important;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
.btn-auth {
|
||||
width: 92%;
|
||||
margin: 0 auto 40rpx;
|
||||
border-radius: 100px;
|
||||
// animation: mymove 5s infinite;
|
||||
// -webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
|
||||
// animation-direction: alternate; /*轮流反向播放动画。*/
|
||||
// animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
||||
// /* Safari 和 Chrome */
|
||||
// -webkit-animation: mymove 5s infinite;
|
||||
// -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
|
||||
// -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
||||
}
|
||||
.btn-callback {
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
background: #ededed;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 100px;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btn-callback {
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
background: #ededed;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 100px;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btns {
|
||||
margin-top: 100rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@keyframes mymove {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
/*开始为原始大小*/
|
||||
}
|
||||
|
||||
25% {
|
||||
transform: scale(1.1);
|
||||
/*放大1.1倍*/
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
75% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.privacy{
|
||||
text-align: center;
|
||||
margin-top: 20rpx;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
<template>
|
||||
<view class="container">
|
||||
<u-navbar :auto-back="false" :fixed="true" :placeholder="true" @leftClick="back" title="小程序登录"></u-navbar>
|
||||
<u-modal v-model:show="phoneAuthPopup" :mask-close-able="true" :title="projectName+'商城'"
|
||||
:show-confirm-button="false">
|
||||
<div class="tips">
|
||||
为了更好地用户体验,需要您授权手机号
|
||||
</div>
|
||||
<button class="register" type="primary" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
|
||||
去授权
|
||||
</button>
|
||||
</u-modal>
|
||||
<view class="wx-auth-container">
|
||||
<div class="box">
|
||||
<view class="logo-info">
|
||||
<text class="title">欢迎进入{{ projectName }}</text>
|
||||
</view>
|
||||
<view class="small-tips">
|
||||
<view>为您提供优质服务,{{ projectName }}需要获取以下信息</view>
|
||||
<view>您的公开信息(昵称、头像)</view>
|
||||
</view>
|
||||
<view class="btns">
|
||||
<button type="primary" :disabled="logingFlag" bindtap="getUserProfile" @click="getUserProfile()"
|
||||
class="btn-auth">登录</button>
|
||||
<div @click="backToHome" class="btn-callback">暂不登录</div>
|
||||
</view>
|
||||
<view class="privacy">
|
||||
<view class="privacy-row">
|
||||
<u-checkbox
|
||||
class="privacy-check"
|
||||
usedAlone
|
||||
shape="circle"
|
||||
v-model:checked="checked"
|
||||
:active-color="lightColor"
|
||||
:icon-size="18"
|
||||
></u-checkbox>
|
||||
<view class="privacy-text">
|
||||
阅读并同意
|
||||
<navigator class="privacy-link" url="/pages/mine/help/tips?type=PRIVACY_POLICY">《隐私协议》</navigator>
|
||||
<navigator class="privacy-link" url="/pages/mine/help/tips?type=USER_AGREEMENT">《用户协议》</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</div>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
mpAutoLogin
|
||||
} from "@/api/connect.js";
|
||||
|
||||
import {
|
||||
whetherNavigate
|
||||
} from "@/utils/Foundation"; //登录跳转
|
||||
import {
|
||||
getUserInfo
|
||||
} from "@/api/members";
|
||||
import storage from "@/utils/storage.js";
|
||||
import config from '@/config/config'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
lightColor:this.$lightColor,
|
||||
checked:false,
|
||||
configs:config,
|
||||
// 是否展示手机号码授权弹窗,默认第一步不展示,要先获取用户基础信息
|
||||
phoneAuthPopup: false,
|
||||
// 授权信息展示,商城名称
|
||||
projectName: config.name,
|
||||
//微信返回信息,用于揭秘信息,获取sessionkey
|
||||
code: "",
|
||||
//微信昵称
|
||||
nickName: "",
|
||||
logingFlag: false,
|
||||
//微信头像
|
||||
image: "",
|
||||
};
|
||||
},
|
||||
|
||||
//微信小程序进入页面,先获取code,否则几率出现code和后续交互数据不对应情况
|
||||
mounted() {
|
||||
// 小程序默认分享
|
||||
uni.showShareMenu({
|
||||
withShareTicket: true
|
||||
});
|
||||
|
||||
|
||||
//获取code
|
||||
uni.login({
|
||||
success: (res) => {
|
||||
if(res.errMsg === "login:ok") {
|
||||
this.code = res.code
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: "系统异常,请联系管理员!"
|
||||
})
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
},
|
||||
methods: {
|
||||
/**
|
||||
* TODO 此方法不一定是最优解,如果有更好的办法请在 https://gitee.com/beijing_hongye_huicheng/lilishop/issues 中提出
|
||||
* 小程序返回bug
|
||||
* 1.介于微信登录是在login.vue的基础上作为判断跳转来
|
||||
* 所以在页面栈中会自动记录回退路径,所以导致每次微信小程序点击回退就会自动返回login页面
|
||||
* 当然login页面的判断就是 没有登录就会跳转到微信小程序页面 导致了无法回退到之前页面
|
||||
* 2.解决方法: 尝试在回退的时候判断地址,让回退多一级这样就避免了
|
||||
*/
|
||||
|
||||
back() {
|
||||
whetherNavigate("wx");
|
||||
},
|
||||
backToHome() {
|
||||
uni.switchTab({
|
||||
url: `/pages/tabbar/home/index`,
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
//获取用户信息
|
||||
getUserProfile(e) {
|
||||
if(!this.checked){
|
||||
uni.showToast({
|
||||
title:"请勾选协议",
|
||||
icon:'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
this.logingFlag = true;
|
||||
|
||||
if (this.code) {
|
||||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
|
||||
uni.getUserProfile({
|
||||
desc: "用于完善会员资料", // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
||||
success: (res) => {
|
||||
console.log("success", res)
|
||||
this.nickName = res.userInfo.nickName;
|
||||
this.image = res.userInfo.avatarUrl;
|
||||
|
||||
/**
|
||||
* 根据公有的配置设置登录方式
|
||||
*/
|
||||
if(this.configs.enableFetchMobileLogin){
|
||||
this.phoneAuthPopup = true;
|
||||
return false
|
||||
}
|
||||
let iv = res.iv;
|
||||
let encryptedData = res.encryptedData;
|
||||
|
||||
let code = this.code;
|
||||
let image = this.image;
|
||||
let nickName = this.nickName;
|
||||
mpAutoLogin({
|
||||
encryptedData,
|
||||
iv,
|
||||
code,
|
||||
image,
|
||||
nickName,
|
||||
}).then((apiRes) => {
|
||||
storage.setAccessToken(apiRes.data.result.accessToken);
|
||||
storage.setRefreshToken(apiRes.data.result.refreshToken);
|
||||
// 登录成功
|
||||
uni.showToast({
|
||||
title: "登录成功!",
|
||||
icon: "none",
|
||||
});
|
||||
//获取用户信息
|
||||
getUserInfo().then((user) => {
|
||||
storage.setUserInfo(user.data.result);
|
||||
storage.setHasLogin(true);
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
fail: (res) => {
|
||||
console.log("fail", res)
|
||||
},
|
||||
});
|
||||
|
||||
this.logingFlag = false;
|
||||
}
|
||||
},
|
||||
|
||||
//获取手机号授权
|
||||
getPhoneNumber(e) {
|
||||
let iv = e.detail.iv;
|
||||
let encryptedData = e.detail.encryptedData;
|
||||
if (!e.detail.encryptedData) {
|
||||
uni.showToast({
|
||||
title: "请授予手机号码权限,手机号码会和会员系统用户绑定!",
|
||||
icon: "none",
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let code = this.code;
|
||||
let image = this.image;
|
||||
let nickName = this.nickName;
|
||||
mpAutoLogin({
|
||||
encryptedData,
|
||||
iv,
|
||||
code,
|
||||
image,
|
||||
nickName,
|
||||
}).then((res) => {
|
||||
storage.setAccessToken(res.data.result.accessToken);
|
||||
storage.setRefreshToken(res.data.result.refreshToken);
|
||||
// 登录成功
|
||||
uni.showToast({
|
||||
title: "登录成功!",
|
||||
icon: "none",
|
||||
});
|
||||
//获取用户信息
|
||||
getUserInfo().then((user) => {
|
||||
storage.setUserInfo(user.data.result);
|
||||
storage.setHasLogin(true);
|
||||
|
||||
uni.navigateBack({
|
||||
delta: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
/*微信授权*/
|
||||
page {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.wx-auth-container {
|
||||
width: 100%;
|
||||
padding-top: 120rpx;
|
||||
}
|
||||
|
||||
.logo-info {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
padding: 0 20rpx;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
image {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
text-align: center;
|
||||
-webkit-transform: scale(2.5);
|
||||
transform: scale(2.5);
|
||||
}
|
||||
|
||||
.logo-info-img {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
}
|
||||
|
||||
text.title,
|
||||
text.shop {
|
||||
display: inline-block;
|
||||
font-size: 60rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
text.shop {
|
||||
display: inline-block;
|
||||
font-size: 55rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.box {
|
||||
margin: 0 32rpx;
|
||||
}
|
||||
|
||||
/* 文字提示*/
|
||||
.small-tips {
|
||||
width: 94%;
|
||||
padding: 20rpx;
|
||||
font-size: 24rpx;
|
||||
margin: 0 0 20rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.auth-button {
|
||||
padding: 10px 20px;
|
||||
width: calc(100% - 20 * 4rpx);
|
||||
}
|
||||
|
||||
.tips {
|
||||
width: 80%;
|
||||
text-align: left;
|
||||
margin: 6% 10%;
|
||||
margin-top: 48rpx;
|
||||
line-height: 1.75;
|
||||
}
|
||||
|
||||
.register {
|
||||
color: $weChat-color !important;
|
||||
border: none !important;
|
||||
background: #fff !important;
|
||||
}
|
||||
|
||||
.btn-auth {
|
||||
width: 92%;
|
||||
margin: 0 auto 40rpx;
|
||||
border-radius: 100px;
|
||||
// animation: mymove 5s infinite;
|
||||
// -webkit-animation: mymove 5s infinite; /*Safari and Chrome*/
|
||||
// animation-direction: alternate; /*轮流反向播放动画。*/
|
||||
// animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
||||
// /* Safari 和 Chrome */
|
||||
// -webkit-animation: mymove 5s infinite;
|
||||
// -webkit-animation-direction: alternate; /*轮流反向播放动画。*/
|
||||
// -webkit-animation-timing-function: ease-in-out; /*动画的速度曲线*/
|
||||
}
|
||||
.btn-callback {
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
background: #ededed;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 100px;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btn-callback {
|
||||
text-align: center;
|
||||
font-size: 30rpx;
|
||||
background: #ededed;
|
||||
height: 90rpx;
|
||||
line-height: 90rpx;
|
||||
border-radius: 100px;
|
||||
width: 92%;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.btns {
|
||||
margin-top: 100rpx;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
@keyframes mymove {
|
||||
0% {
|
||||
transform: scale(1);
|
||||
/*开始为原始大小*/
|
||||
}
|
||||
|
||||
25% {
|
||||
transform: scale(1.1);
|
||||
/*放大1.1倍*/
|
||||
}
|
||||
|
||||
50% {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
75% {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
}
|
||||
|
||||
.privacy {
|
||||
margin-top: 32rpx;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.privacy-row {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
width: 92%;
|
||||
}
|
||||
|
||||
.privacy-check {
|
||||
flex-shrink: 0;
|
||||
margin-top: 4rpx;
|
||||
|
||||
::v-deep .u-checkbox {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.privacy-text {
|
||||
flex: 1;
|
||||
margin-left: 12rpx;
|
||||
font-size: 24rpx;
|
||||
line-height: 36rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.privacy-link {
|
||||
display: inline;
|
||||
color: $light-color;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user