style: 🎨 优化退出登录功能、优化部分变量名

master
学习很差啦 2023-01-16 16:56:45 +08:00
parent 071599074c
commit 529175c0ab
13 changed files with 96 additions and 219 deletions

2
.gitignore vendored
View File

@ -9,3 +9,5 @@ node_modules/
.vscode/
/unpackage/
.hbuilderx/launch.json
.project.config.json
.project.private.config.json

View File

@ -211,7 +211,8 @@
"version" : "1.3.0",
"provider" : "wx2b03c6e691cd7370"
}
}
},
"requiredPrivateInfos" : [ "chooseLocation", "getLocation" ]
},
"h5" : {
"devServer" : {

View File

@ -32,7 +32,7 @@
<u-empty
mode="coupon"
text="暂无优惠券了"
v-if="navItem.wheterEmpty"
v-if="navItem.whetherEmpty"
></u-empty>
<!-- 数据 -->
@ -139,7 +139,7 @@ export default {
pageSize: 10,
status: 1,
},
wheterEmpty: false,
whetherEmpty: false,
},
{
text: "已使用",
@ -151,7 +151,7 @@ export default {
pageSize: 10,
status: 2,
},
wheterEmpty: false,
whetherEmpty: false,
},
{
text: "已过期",
@ -163,7 +163,7 @@ export default {
pageSize: 10,
status: 3,
},
wheterEmpty: false,
whetherEmpty: false,
},
],
couponList: [], //
@ -206,7 +206,7 @@ export default {
let data = res.data.result.records;
if (data.length == 0) {
if (res.data.pageNumber == 1) {
this.navList[index].wheterEmpty = true;
this.navList[index].whetherEmpty = true;
} else {
this.navList[index].loadStatus = "noMore";
}

View File

@ -1,5 +1,5 @@
<template>
<view class="wrapper" v-if="flage">
<view class="wrapper" v-if="flag">
<div class='goods' v-if="selectedGoods">
<image class="goods-image" :src="selectedGoods.thumbnail" alt="">
<p class="goodsName">{{selectedGoods.goodsName}}</p>
@ -58,7 +58,7 @@
<popupGoods :addr="addr" ref="popupGoods" :buyMask="maskFlag" @closeBuy="closePopupBuy" :goodsDetail="goodsDetail" :goodsSpec="goodsSpec" v-if="goodsDetail.id " @handleClickSku="getGoodsDetail" />
<shares @close="closeShare" :link="'/pages/cart/payment/shareOrderGoods?sn='+this.routers.sn+'&sku='+this.routers.sku+'&goodsId='+this.routers.goodsId" type="pintuan"
:thumbnail="data.promotionGoods.thumbnail" :goodsName="data.promotionGoods.goodsName" v-if="shareFlage " />
:thumbnail="data.promotionGoods.thumbnail" :goodsName="data.promotionGoods.goodsName" v-if="shareFlag " />
</view>
</template>
@ -72,13 +72,13 @@ import popupGoods from "@/components/m-buy/goods"; //购物车商品的模块
export default {
data() {
return {
flage: false, //
flag: false, //
addr: {
id: "",
},
maskFlag: false, //
timeStamp: 0,
shareFlage: false,
shareFlag: false,
data: "",
isMaster: true,
selectedGoods: "", //
@ -116,7 +116,7 @@ export default {
},
methods: {
closeShare() {
this.shareFlage = false;
this.shareFlag = false;
},
//
toBuy() {
@ -131,7 +131,7 @@ export default {
},
//
share() {
this.shareFlage = true;
this.shareFlag = true;
},
closePopupBuy(val) {
this.maskFlag = false;
@ -140,7 +140,7 @@ export default {
async init(sn, sku) {
let res = await getPinTuanShare(sn, sku);
if (res.data.success && res.data.result.promotionGoods) {
this.flage = true;
this.flag = true;
this.data = res.data.result;
this.selectedGoods = res.data.result.promotionGoods;
let endTime = Date.parse(

View File

@ -33,18 +33,18 @@
<m-city :provinceData="list" headTitle="区域选择" ref="cityPicker" @funcValue="getpickerParentValue" pickerSize="4">
</m-city>
<uniMap v-if="mapFlage" @close="closeMap" @callback="callBackAddress" />
<uniMap v-if="mapFlag" @close="closeMap" @callback="callBackAddress" />
</div>
</view>
</template>
<script>
import { addAddress, editAddress, getAddressDetail } from "@/api/address.js";
import gkcity from "@/components/m-city/m-city.vue";
import city from "@/components/m-city/m-city.vue";
import uniMap from "./uniMap";
import permision from "@/js_sdk/wa-permission/permission.js";
export default {
components: {
"m-city": gkcity,
"m-city": city,
uniMap,
},
onShow() {
@ -53,7 +53,7 @@ export default {
methods: {
//
closeMap() {
this.mapFlage = false;
this.mapFlag = false;
},
// 访
clickUniMap() {
@ -61,8 +61,8 @@ export default {
if (plus.os.name == "iOS") {
// ios
permision.judgeIosPermission("location")
? (this.mapFlage = true)
: this.refuseMapOuther();
? (this.mapFlag = true)
: this.refuseMap();
} else {
//
this.requestAndroidPermission(
@ -72,12 +72,12 @@ export default {
// #endif
// #ifndef APP-PLUS
this.mapFlage = true;
this.mapFlag = true;
// #endif
},
//
refuseMapOuther() {
refuseMap() {
uni.showModal({
title: "温馨提示",
content: "您已拒绝定位,请开启",
@ -113,9 +113,9 @@ export default {
var result = await permision.requestAndroidPermission(permisionID);
if (result == 1) {
this.mapFlage = true;
this.mapFlag = true;
} else {
this.refuseMapOuther();
this.refuseMap();
}
},
@ -136,7 +136,7 @@ export default {
uni.hideLoading();
}
this.mapFlage = !this.mapFlage; //
this.mapFlag = !this.mapFlag; //
},
//
@ -206,7 +206,7 @@ export default {
data() {
return {
lightColor: this.$lightColor, //
mapFlage: false, //
mapFlag: false, //
routerVal: "",
form: {
detail: "", //

View File

@ -29,7 +29,8 @@ export default {
});
});
},
fail() {
fail(e) {
console.log(e)
that.$emit("close");
},
});

View File

@ -14,7 +14,7 @@
<swiper class="swiper-box" :current="swiperCurrent">
<swiper-item class="swiper-item" v-for="index in list.length" :key="index">
<scroll-view class="scroll-v view-wrapper" enableBackToTop="true" scroll-with-animation scroll-y @scrolltolower="loadMore">
<view v-if="datas.length!=0" class="view-item" v-for="(logItem, logIndex) in datas" :key="logIndex">
<view v-if="depositData.length!=0" class="view-item" v-for="(logItem, logIndex) in depositData" :key="logIndex">
<view class="view-item-detail">
<view class="-title">{{logItem.detail}}</view>
<!-- <view class="-number">{{logItem.detail}}</view> -->
@ -27,7 +27,7 @@
</view>
</view>
<u-empty v-if="datas.length==0" mode="history" text="暂无记录" />
<u-empty v-if="depositData.length==0" mode="history" text="暂无记录" />
</scroll-view>
@ -45,7 +45,6 @@ export default {
data() {
return {
walletNum: 0,
current: 0,
swiperCurrent: 0,
userInfo: "", //
@ -54,7 +53,7 @@ export default {
pageSize: 10,
order: "desc",
},
datas: [], //
depositData: [], //
rechargeList: "", //
walletLogList: "", //
list: [
@ -82,12 +81,10 @@ export default {
/**分页获取预存款充值记录 */
getRecharge() {
getUserRecharge(this.params).then((res) => {
if (res.data.success) {
if (res.data.result.records.length != 0) {
this.datas.push(...res.data.result.records);
this.depositData.push(...res.data.result.records);
}
}
});
@ -98,7 +95,7 @@ export default {
getWalletLog(this.params).then((res) => {
if (res.data.success) {
if (res.data.result.records.length != 0) {
this.datas.push(...res.data.result.records);
this.depositData.push(...res.data.result.records);
}
}
});
@ -106,7 +103,7 @@ export default {
changed(index) {
this.datas = [];
this.depositData = [];
this.swiperCurrent = index;
this.params.pageNumber = 1;
if (index == 0) {

View File

@ -5,11 +5,11 @@
<div class="deposit">预存款金额</div>
<div class="money">{{walletNum | unitPrice }}</div>
<div class="operation-btns">
<div class="operation-btn light" @click="navgition('/pages/mine/deposit/withdrawal')"></div>
<div class="operation-btn" @click="navgition('/pages/mine/deposit/recharge')"></div>
<div class="operation-btn light" @click="navigateTo('/pages/mine/deposit/withdrawal')"></div>
<div class="operation-btn" @click="navigateTo('/pages/mine/deposit/recharge')"></div>
</div>
</div>
<div class="box list" @click="navgition('/pages/mine/deposit/index')">
<div class="box list" @click="navigateTo('/pages/mine/deposit/index')">
<div class="list-left">预存款明细</div>
<div class="list-right">
<u-icon name="arrow-right"></u-icon>
@ -31,12 +31,6 @@ export default {
let result = await getUserWallet(); //
this.walletNum = result.data.result.memberWallet;
} else {
uni.showToast({
icon: "none",
duration: 3000,
title: "请先登录!",
});
this.$options.filters.navigateToLogin("redirectTo");
}
},
@ -49,7 +43,7 @@ export default {
/**
* 跳转
*/
navgition(url) {
navigateTo(url) {
uni.navigateTo({
url,
});

View File

@ -23,26 +23,22 @@
<u-input v-model="form.___path" disabled @click="clickRegion" />
</u-form-item>
<view class="submit" @click="submit"></view>
<view class="submit" @click="showModalDialog">退</view>
<u-modal show-cancel-button v-model="quitShow" @confirm="confirm" :confirm-color="lightColor" :async-close="true"
:content="'确定要退出登录么?'"></u-modal>
<view class="submit" @click="quiteLoginOut">退</view>
</u-form>
<m-city :provinceData="region" headTitle="区域选择" ref="cityPicker" @funcValue="getpickerParentValue" pickerSize="4"></m-city>
<m-city :provinceData="region" headTitle="区域选择" ref="cityPicker" @funcValue="getPickerParentValue" pickerSize="4"></m-city>
</view>
</template>
<script>
import { logout } from "@/api/login";
import { saveUserInfo } from "@/api/members.js";
import { upload } from "@/api/common.js";
import storage from "@/utils/storage.js";
import uFormItem from "@/uview-ui/components/u-form-item/u-form-item.vue";
import gkcity from "@/components/m-city/m-city.vue";
import city from "@/components/m-city/m-city.vue";
export default {
components: { uFormItem, "m-city": gkcity },
components: { uFormItem, "m-city": city },
data() {
return {
quitShow: false,
lightColor: this.$lightColor, //
form: {
nickName: storage.getUserInfo().nickName || "",
@ -71,38 +67,16 @@ export default {
},
methods: {
/**
* 显示退出登录对话框
* 退出登录
*/
showModalDialog() {
this.quitShow = true;
},
clear() {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setUserInfo({});
this.$options.filters.navigateToLogin("redirectTo");
},
/**
* 确认退出
* 清除缓存重新登录
*/
async confirm() {
try{
await logout();
this.clear();
}catch(e){
//TODO handle the exception
this.clear();
}
quiteLoginOut() {
this.$options.filters.quiteLoginOut();
},
/**
* 选择地址回调
*/
getpickerParentValue(e) {
getPickerParentValue(e) {
this.form.region = [];
this.form.regionId = [];
let name = "";

View File

@ -4,7 +4,6 @@
<u-image width=140 height="140" shape="circle" :src="userInfo.face || userImage" mode="">
</u-image>
<view class="user-name">
{{ userInfo.id ? userInfo.nickName || '' : '暂未登录' }}
</view>
<u-icon color="#ccc" name="arrow-right"></u-icon>
@ -22,23 +21,17 @@
<!-- #endif -->
<u-cell-item :title="`关于${config.name}`" @click="navigateTo('/pages/mine/set/editionIntro')"></u-cell-item>
</u-cell-group>
<view class="submit" @click="showModalDialog">{{userInfo.id ?'退':''}}</view>
<u-modal show-cancel-button v-model="quitShow" @confirm="confirm" :confirm-color="lightColor" :async-close="true"
:content="userInfo.id ? '确定要退出登录么?' : '确定要登录么?'"></u-modal>
<view class="submit" v-if="userInfo.id" @click="quiteLoginOut">退</view>
</view>
</template>
<script>
import { logout } from "@/api/login";
import storage from "@/utils/storage.js";
import config from "@/config/config";
export default {
data() {
return {
config,
userImage:config.defaultUserPhoto,
lightColor: this.$lightColor,
quitShow: false,
isCertificate: false,
userInfo: {},
fileSizeString: "0B",
@ -54,34 +47,14 @@ export default {
url: url,
});
},
clear() {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setUserInfo({});
this.$options.filters.navigateToLogin("redirectTo");
},
/**
* 退出登录
*/
quiteLoginOut() {
this.$options.filters.quiteLoginOut();
},
/**
* 确认退出
* 清除缓存重新登录
*/
async confirm() {
try{
await logout();
this.clear();
}catch(e){
//TODO handle the exception
this.clear();
}
},
/**
* 显示退出登录对话框
*/
showModalDialog() {
this.quitShow = true;
},
/**
* 读取当前缓存
@ -113,11 +86,7 @@ export default {
if (this.$options.filters.isLogin("auth")) {
this.navigateTo("/pages/mine/set/personMsg");
} else {
uni.showToast({
title: "当前暂无用户请登录后重试",
duration: 2000,
icon: "none",
});
this.$options.filters.tipsToLogin();
}
},

View File

@ -1,28 +0,0 @@
{
"appid": "wx98ebde1da5b340d4",
"compileType": "miniprogram",
"libVersion": "2.27.0",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"coverView": true,
"es6": true,
"postcss": true,
"minified": true,
"enhance": true,
"showShadowRootInWxmlPanel": true,
"packNpmRelationList": [],
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
}
},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

View File

@ -1,7 +0,0 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "lilishop-uniapp",
"setting": {
"compileHotReLoad": true
}
}

View File

@ -1,5 +1,6 @@
import Foundation from "./Foundation.js";
import storage from "@/utils/storage.js";
import { logout } from "@/api/login";
import { getUserInfo } from "@/api/members";
import Vue from "vue";
/**
@ -23,8 +24,8 @@ export function unitPrice(val, unit, location) {
/**
* 格式化价格 1999 --> [1999,00]
* @param {*} val
* @returns
* @param {*} val
* @returns
*/
export function goodsFormatPrice(val) {
if (typeof val == "undefined") {
@ -34,7 +35,6 @@ export function goodsFormatPrice(val) {
return valNum.toFixed(2).split(".");
}
/**
* 脱敏姓名
*/
@ -90,11 +90,11 @@ export function unixToDate(unix, format) {
*
* @param {Object} datetime
*/
export function beautifyTime(datetime = "") {
export function beautifyTime(datetime = "") {
if (datetime == null || datetime == undefined || !datetime) {
return "";
}
datetime = datetime.replace(/-/g, "/");
let time = new Date();
@ -154,59 +154,6 @@ export function secrecyMobile(mobile) {
return mobile.replace(/(\d{3})(\d{4})(\d{4})/, "$1****$3");
}
/**
* 人性化时间显示
*
* @param {Object} datetime
*/
export function formatTime(datetime) {
if (datetime == null) return "";
datetime = datetime.replace(/-/g, "/");
let time = new Date();
let outTime = new Date(datetime);
if (/^[1-9]\d*$/.test(datetime)) {
outTime = new Date(parseInt(datetime) * 1000);
}
if (
time.getTime() < outTime.getTime() ||
time.getFullYear() != outTime.getFullYear()
) {
return parseTime(outTime, "{y}-{m}-{d} {h}:{i}");
}
if (time.getMonth() != outTime.getMonth()) {
return parseTime(outTime, "{m}-{d} {h}:{i}");
}
if (time.getDate() != outTime.getDate()) {
let day = outTime.getDate() - time.getDate();
if (day == -1) {
return parseTime(outTime, "昨天 {h}:{i}");
}
if (day == -2) {
return parseTime(outTime, "前天 {h}:{i}");
}
return parseTime(outTime, "{m}-{d} {h}:{i}");
}
if (time.getHours() != outTime.getHours()) {
return parseTime(outTime, "{h}:{i}");
}
let minutes = outTime.getMinutes() - time.getMinutes();
if (minutes == 0) {
return "刚刚";
}
minutes = Math.abs(minutes);
return `${minutes}分钟前`;
}
/**
* 时间格式化方法
*
@ -214,7 +161,7 @@ export function secrecyMobile(mobile) {
* @param {String} cFormat
* @returns {String | null}
*/
export function parseTime(time, cFormat) {
export function parseTime(time, cFormat) {
if (arguments.length === 0) {
return null;
}
@ -281,20 +228,47 @@ export function isLogin(val) {
return storage.getUserInfo();
}
}
/**
* 退出登录
*
*/
export function quiteLoginOut() {
uni.showModal({
title: "提示",
content: "是否退出登录?",
confirmColor: Vue.prototype.$mainColor,
async success(res) {
if (res.confirm) {
storage.setAccessToken("");
storage.setRefreshToken("");
storage.setUserInfo({});
navigateToLogin("redirectTo");
await logout();
}
},
});
}
/**
* 跳转im
*/
export function talkIm(storeId){
if(isLogin('auth')){
* 若未登录提示去登录
*/
export function talkIm(storeId) {
if (isLogin("auth")) {
uni.navigateTo({
url: `/pages/tabbar/home/web-view?IM=${storeId}`,
});
}
else{
tipsToLogin()
} else {
tipsToLogin();
}
}
/**
* 判断当前用户是否登录状态
* 若未登录点击确认跳转到登录
* 点击取消回退上一级页面
*/
export function tipsToLogin() {
if (!isLogin("auth")) {
uni.showModal({