<template>
|
<view class="setting-wrapper wrapperLayer colCen">
|
<titleBar :titleText='"设置"' :pageForm='"setting"'></titleBar>
|
<view class="body-container colCen">
|
<view class="userSet-content infoContainer colCen">
|
<view class="keyvalueBox rowCenBet borderBox" @tap="goPage('./modifyInfo')">
|
<view class="leftKey">
|
个人信息
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view>
|
<!-- <view class="keyvalueBox rowCenBet borderBox" @tap="goPage('./myAddress')">
|
<view class="leftKey">
|
地址管理
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view> -->
|
<view class="keyvalueBox rowCenBet borderBox" @click="('accountSecurity')">
|
<view class="leftKey">
|
注册时间
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
{{user.createtime}}
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view class="infoContainer" style="margin-top: 20rpx;">
|
<view class="keyvalueBox rowCenBet borderBox" @tap="goUrl('./bindingZFB')">
|
<view class="leftKey">
|
支付宝绑定
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
{{user.zfb_account?user.zfb_account:"未授权"}}
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view>
|
<view class="keyvalueBox rowCenBet borderBox" @tap="wxbinding()">
|
<view class="leftKey">
|
微信绑定
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
{{user.bindingWechat?'已绑定':''}}
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view>
|
<view class="keyvalueBox rowCenBet borderBox" @tap="bindingTB()">
|
<view class="leftKey">
|
淘宝绑定
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
{{user.tb_account?user.tb_account:"未授权"}}
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view class="message-content infoContainer colCen" style="margin-top: 20rpx;">
|
<view class="keyvalueBox rowCenBet borderBox" @click="goUrl('../../login/modifyPass')">
|
<view class="leftKey">
|
修改密码
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
修改
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode=""></image>
|
</view>
|
</view>
|
</view>
|
<view class="keyvalueBox rowCenBet borderBox" @click="openModel('clean')">
|
<view class="leftKey">
|
清除缓存
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
{{storageSize}}
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode="aspectFill"></image>
|
</view>
|
</view>
|
</view>
|
<view class="keyvalueBox rowCenBet borderBox">
|
<view class="leftKey">
|
<view>个性化商品推荐</view><span>(关闭将降低商品推荐与个人喜好的相关度)</span>
|
</view>
|
<view class="rightvalue rowCen">
|
<u-switch v-model="checked" @change="change"></u-switch>
|
</view>
|
</view>
|
<view class="keyvalueBox rowCenBet borderBox" @click="cancellation()">
|
<view class="leftKey">
|
账号注销<span>(账户注销后无法恢复,请谨慎操作)</span>
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode="aspectFill"></image>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view class="about-us infoContainer colCen" style="margin-top: 20rpx;">
|
<view class="keyvalueBox rowCenBet borderBox" @click="goUrl('./aboutUs')">
|
<view class="leftKey">
|
关于我们
|
</view>
|
<view class="rightvalue rowCen">
|
<view class="rightText">
|
<!-- #ifdef APP-PLUS -->
|
{{version}}
|
<!-- #endif -->
|
</view>
|
<view class="arrow-icon defIcon">
|
<image src="../../../static/images/goods/arrow.png" mode="aspectFill"></image>
|
</view>
|
</view>
|
</view>
|
</view>
|
|
<view class="logOut rowCenCen" @click="openModel('logout')">
|
<view class="outText">
|
退出登录
|
</view>
|
</view>
|
</view>
|
|
<!-- 模态窗 -->
|
<u-popup v-model="empowerModel" mode="center" border-radius="12">
|
<empowerModel @closemodel='closeMdl' @updataInfo='updataUser'></empowerModel>
|
</u-popup>
|
<u-modal v-model="showModel" show-cancel-button :content="content" @confirm="confirm" :async-close="true">
|
</u-modal>
|
<u-toast ref="uToast" />
|
</view>
|
</template>
|
|
<script>
|
import empowerModel from '../../../components/empowerModel.vue'
|
import util from '../../../utils/utils.js'
|
import titleBar from '@/components/backTitlebar.vue'
|
const plug = uni.requireNativePlugin('xiguazhu-baichuan');
|
export default {
|
components: {
|
empowerModel,
|
titleBar
|
},
|
data() {
|
return {
|
checked: true,
|
modelType: '',
|
showModel: false,
|
empowerModel: false,
|
content: '',
|
storageSize: '',
|
|
user: '',
|
|
// #ifdef APP-PLUS
|
version: plus.runtime.version
|
// #endif
|
}
|
},
|
onShow() {
|
// #ifdef APP-PLUS
|
this.getStorageSize()
|
// #endif
|
this.updataUser()
|
this.getuserInfo()
|
this.checked = uni.getStorageSync('open_like_recommend') == 1 ? true : false;
|
},
|
methods: {
|
change(status) {
|
if(status){
|
uni.setStorageSync('open_like_recommend',1);
|
this.checked = true;
|
}else{
|
uni.setStorageSync('open_like_recommend',2);
|
this.checked = false;
|
}
|
},
|
cancellation(){
|
uni.navigateTo({
|
url:"cancellation"
|
})
|
},
|
closeMdl() {
|
this.showModel = false
|
this.empowerModel = false
|
},
|
getuserInfo() {
|
var that = this;
|
this.$u.api.getUserInfo({}).then(e => {
|
that.user = e.data.userinfo;
|
util.setCache('userInfo', e.data.userinfo)
|
}).catch(function (err) {
|
console.log(err)
|
})
|
},
|
updataUser() {
|
this.user = util.getCacheSync('userInfo')
|
},
|
getStorageSize() {
|
let that = this;
|
plus.cache.calculate(function(size) { //size是多少个字节单位是b
|
console.log(size);
|
//做下面相应的处理
|
if (size < 1024) {
|
that.storageSize = size + 'B';
|
} else if (size / 1024 >= 1 && size / 1024 / 1024 < 1) {
|
that.storageSize = Math.floor(size / 1024 * 100) / 100 + 'KB';
|
} else if (size / 1024 / 1024 >= 1) {
|
that.storageSize = Math.floor(size / 1024 / 1024 * 100) / 100 + 'M';
|
}
|
});
|
},
|
|
clearCache() {
|
let that = this;
|
let os = plus.os.name;
|
console.log(os);
|
if (os == 'Android') {
|
let main = plus.android.runtimeMainActivity();
|
let sdRoot = main.getCacheDir();
|
let files = plus.android.invoke(sdRoot, "listFiles");
|
let len = files.length;
|
for (let i = 0; i < len; i++) {
|
let filePath = '' + files[i]; // 没有找到合适的方法获取路径,这样写可以转成文件路径
|
plus.io.resolveLocalFileSystemURL(filePath, function(entry) {
|
if (entry.isDirectory) {
|
entry.removeRecursively(function(entry) { //递归删除其下的所有文件及子目录
|
that.$refs.uToast.show({
|
title: '清除缓存成功~',
|
type: 'default',
|
position: 'bottom'
|
})
|
that.getStorageSize(); // 重新计算缓存
|
}, function(e) {
|
console.log(e.message)
|
});
|
} else {
|
entry.remove();
|
}
|
}, function(e) {
|
console.log('文件路径读取失败')
|
});
|
}
|
} else { // ios
|
plus.cache.clear(function() {
|
that.$refs.uToast.show({
|
title: '清除缓存成功~',
|
type: 'default',
|
position: 'bottom'
|
})
|
that.getStorageSize();
|
});
|
}
|
},
|
|
wxbinding() {
|
if (this.user.bindingWechat) {
|
this.openModel('Unbundling')
|
} else {
|
this.wxlogin()
|
}
|
},
|
|
wxlogin() {
|
var that = this;
|
uni.getProvider({
|
service: 'oauth',
|
success: othres => {
|
console.log(othres.provider)
|
if (~othres.provider.indexOf('weixin')) {
|
uni.login({
|
provider: 'weixin',
|
success: (loginRes) => {
|
console.log(loginRes);
|
uni.setStorageSync('openId', loginRes.authResult.openid)
|
uni.getUserInfo({
|
provider: 'weixin',
|
success: infoRes => {
|
console.log('-------获取微信用户所有-----',
|
infoRes)
|
uni.setStorageSync('wxUserInfo', infoRes
|
.userInfo)
|
that.$u.api.bindWechat({
|
avatar: infoRes.userInfo
|
.avatar,
|
gender: infoRes.userInfo
|
.gender,
|
nickName: infoRes.userInfo
|
.nickName,
|
openId: loginRes.authResult
|
.openid
|
}).then(e => {
|
console.log(e)
|
if(e.code == 1)return that.$alert(e.msg);
|
that.getuserInfo()
|
}).catch(function (err) {
|
|
})
|
}
|
});
|
},
|
fail: err => {
|
console.log(err);
|
uni.showToast({
|
title: '微信授权登录失败!',
|
icon: 'none'
|
})
|
}
|
})
|
}
|
}
|
})
|
},
|
|
bindingTB() {
|
if (this.user.tb_account) {} else {
|
this.empowerModel = true
|
}
|
},
|
|
goUrl(url) {
|
uni.navigateTo({
|
url: url
|
})
|
},
|
|
openModel(type) {
|
this.modelType = type;
|
if (this.modelType == 'clean') {
|
this.content = '确定要清除缓存吗?';
|
this.showModel = true;
|
} else if (this.modelType == 'logout') {
|
this.content = '确定要退出当前账号吗?';
|
this.showModel = true;
|
} else if (this.modelType == 'Unbundling') {
|
this.content = '确定要解除微信绑定吗?';
|
this.showModel = true;
|
}
|
},
|
|
confirm() {
|
if (this.modelType == 'clean') {
|
this.modelType = '';
|
this.content = '';
|
this.clearCache();
|
this.showModel = false;
|
} else if (this.modelType == 'logout') {
|
this.showModel = false;
|
try {
|
uni.removeStorageSync('userInfo');
|
uni.removeStorageSync('userData');
|
uni.reLaunch({
|
url: '../../login/wxlogin'
|
})
|
} catch (e) {
|
// error
|
}
|
} else if (this.modelType == 'Unbundling') {
|
var that = this;
|
that.$u.api.unboundWechat({}).then(e => {
|
that.showModel = false
|
that.getuserInfo()
|
uni.showToast({
|
title: '已解除微信绑定',
|
icon: 'none'
|
})
|
}).catch(function (err) {
|
console.log(err)
|
})
|
// this.$http.post('member/unboundWechat').then(res => {
|
// console.log(res);
|
// this.showModel = false
|
// this.getuserInfo()
|
// uni.showToast({
|
// title: '已解除微信绑定',
|
// icon: 'none'
|
// })
|
// })
|
}
|
},
|
|
goPage(url) {
|
uni.navigateTo({
|
url: url
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss">
|
.setting-wrapper {
|
.body-container {
|
width: 100%;
|
margin-top: 20rpx;
|
|
.infoContainer {
|
width: 100%;
|
background-color: #FFFFFF;
|
|
.keyvalueBox {
|
width: 100%;
|
height: 100rpx;
|
border-bottom: 1rpx solid #F2F2F2;
|
padding: 0 30rpx;
|
|
.leftKey {
|
font-size: 28rpx;
|
font-weight: 500;
|
color: #333333;
|
|
span {
|
font-size: 24rpx;
|
font-weight: 500;
|
color: #999999;
|
}
|
}
|
|
.rightvalue {
|
.rightText {
|
font-size: 24rpx;
|
font-weight: 400;
|
color: #999999;
|
margin-right: 15rpx;
|
}
|
|
.arrow-icon {
|
width: 10rpx;
|
height: 18rpx;
|
}
|
}
|
}
|
}
|
|
.logOut {
|
width: 100%;
|
height: 100rpx;
|
margin-top: 20rpx;
|
background-color: #FFFFFF;
|
|
.outText {
|
font-size: 28rpx;
|
font-weight: 500;
|
color: #333333;
|
}
|
}
|
}
|
}
|
</style>
|