123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811 |
- <template>
- <view class="user">
- <!--头部-->
- <view class="user-section" :class="'bg-' + themeColor.name">
- <!--用户信息-->
- <view class="user-info-box">
- <view class="portrait-box" v-if="hasLogin">
- <image class="portrait" :src="avatar"></image>
- <text class="username">
- {{user.nickName}}
- {{ user.phonenumber}}
- </text>
- </view>
- <view class="portrait-box" v-else @tap="navTo(`/pages/public/login`)">
- <image class="portrait" :src="headImg"></image>
- <text class="username">
- {{'登录/注册'}}
- </text>
- </view>
- </view>
- </view>
- <!-- 个人中心 内容区-->
- <view class="cover-container" :style="[
- {
- transform: coverTransform,
- transition: coverTransition
- }
- ]" @touchstart="coverTouchstart" @touchmove="coverTouchmove" @touchend="coverTouchend">
- <image class="arc" :src="arc"></image>
- <!-- 个人资料 -->
- <view class="set">
- <view class="list-cell b-b" :class="{ 'm-t': item.class === 'mT' }" v-for="item in setList"
- :key="item.title" @tap="navTo(item.url)" hover-class="cell-hover" :hover-stay-time="50">
- <text class="cell-tit updateDotParent">{{ item.title }}<i v-show="item.title =='检查更新'"></i></text><!-- v-bind:class="{'updateTipDot':neepUpdate}" -->
- <text class="cell-tip">{{ item.content }}</text>
- <text class="cell-more iconfont iconyou"></text>
- {{item.tatle}}
- </view>
-
- </view>
- <!-- <view class="cu-list menu sm-border card-menu">
- <view class="cu-item">
- <view class="content flex align-center">
- <text class="cuIcon-colorlens" :class="'text-' + themeColor.name"></text>
- <view class="padding solid radius shadow-blur" :class="'bg-' + themeColor.name"></view>
- <view class="title">主题色:<text :class="'text-' + themeColor.name">{{
- themeColor.title
- }}</text></view>
- </view>
- <view class="action">
- <button class="cu-btn round shadow" @click="showColorModal" :class="'bg-' + themeColor.name">
- <text class="cuIcon-colorlens"></text> 选择主题
- </button>
- </view>
- </view>
- </view> -->
- <view v-if="hasLogin" class="list-cell log-out-btn" :class="'text-' + themeColor.name" @tap="toLogout">
- <text class="cell-tit">退出登录</text>
- </view>
- <!-- 选择颜色模态框 -->
- <view class="cu-modal" :class="{ show: colorModal }">
- <view class="cu-dialog">
- <view class="cu-bar justify-end solid-bottom">
- <view class="content">选择颜色</view>
- <view class="action" @tap="colorModal = false">
- <text class="cuIcon-close text-red"></text>
- </view>
- </view>
- <view class="grid col-5 padding">
- <view class="padding-xs" v-for="(item, index) in themeList" :key="index" @tap="SetColor(item)"
- :data-color="item.name">
- <view class="padding-tb radius" :class="'bg-' + item.name">
- {{ item.title }}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapMutations
- } from 'vuex';
- import listCell from '@/components/oa-list-cell';
- let startY = 0,
- moveY = 0,
- pageAtTop = true;
- export default {
- components: {
- listCell
- },
- data() {
- return {
- hasLogin: false,
- user: {
- },
- colorModal: false,
- mycenterList: this.$mConstDataConfig.mycenterList,
- themeList: this.$mConstDataConfig.themeList,
- setList: this.$mConstDataConfig.setList,
- headImg: this.$mAssetsPath.headImg,
- userBg: this.$mAssetsPath.userBg,
- arc: this.$mAssetsPath.arc,
- coverTransform: 'translateY(0px)',
- coverTransition: '0s',
- moving: false,
- avatar:'',
- //控制有更新时的提示红点
- neepUpdate:this.$needUpdate,
- };
- },
- onShow() {
- // 初始化数据
- this.initData();
- },
- onLoad() {
- // #ifdef APP-PLUS
- if (uni.getSystemInfoSync().platform === 'ios') {
- this.CustomBar = 0;
- }
- // #endif
- },
- // #ifndef MP
- onNavigationBarButtonTap(e) {
- const index = e.index;
- if (index === 0) {
- this.navTo('/pages/set/set');
- } else if (index === 1) {}
- },
- // #endif
- methods: {
- handleTip(isNewVersion) {
- this.isNewVersion = isNewVersion;
- },
- handleVersionUpgradeShow() {
- this.isVersionUpgradeShow = false;
- },
- // 数据初始化
- initData() {
- this.user = uni.getStorageSync('user');
- // 缓存大小
- //this.setList[2].content = `${uni.getStorageInfoSync().currentSize} kb`;
- let that = this;
- // #ifdef APP-PLUS
- plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
- //version属性
- that.setList[3].content = `V ` + wgtinfo.version
- } );
- // this.setList[3].content = `当前版本 V` + plus.runtime.version;
- // #endif
- this.hasLogin = this.$store.getters.hasLogin;
- //this.user = this.$store.state.user;
- //console.log(JSON.stringify(this.user))file:///C:/Users/Administrator/Desktop/portrait.png
- if(this.user.avatar){
- this.avatar = this.$mConfig.baseUrl + this.user.avatar;
- }else{
- this.avatar = "../../static/portrait.png";
- }
-
- uni.setTabBarStyle({
- selectedColor: this.themeColor.color,
- borderStyle: 'white'
- });
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: this.themeColor.color,
- animation: {
- duration: 400,
- timingFunc: 'easeIn'
- }
- });
- this.themeColor.tabList && this.themeColor.tabList.forEach((selectedIconPath, index) => {
- uni.setTabBarItem({
- index,
- selectedIconPath
- });
- });
- },
- showColorModal() {
- this.colorModal = true;
- },
- SetColor(item) {
- this.colorModal = false;
- this.themeColor = item;
- this.$mStore.commit('setThemeColor', item);
- uni.setNavigationBarColor({
- frontColor: '#ffffff',
- backgroundColor: this.themeColor.color,
- animation: {
- duration: 400,
- timingFunc: 'easeIn'
- }
- });
- uni.setTabBarStyle({
- selectedColor: this.themeColor.color,
- borderStyle: 'white'
- });
- this.themeColor.tabList && this.themeColor.tabList.forEach((selectedIconPath, index) => {
- uni.setTabBarItem({
- index,
- selectedIconPath
- });
- });
- },
- // 统一跳转接口,拦截未登录路由
- navTo(route) {
- if (!route) return;
- if (route === 'clearCache') {
- uni.showModal({
- content: '确定要清除缓存吗',
- success: e => {
- if (e.confirm) {
- uni.clearStorageSync();
- this.setList[2].content = '0 kb';
- this.$mStore.commit('login', this.user);
- this.$mHelper.toast('清除缓存成功');
- }
- }
- });
- return;
- } else if (route === 'versionUpgrade') {
- //当前版本号
- let nativeVersion = null
- let that = this
- // #ifdef APP-PLUS
- plus.runtime.getProperty( plus.runtime.appid, function ( wgtinfo ) {
- nativeVersion = wgtinfo.version || plus.runtime.version
- console.log("本地运行时版本"+nativeVersion)
- that.checkUpdate(nativeVersion);
- } );
- // #endif
- console.log("本地版本"+nativeVersion)
-
- // this.checkUpdate(wgtinfo.version || plus.runtime.version);
- //检查版本号
- // this.checkUpdate(nativeVersion);
- // this.isVersionUpgradeShow = true;
- // if (this.isNewVersion) {
- // this.$mHelper.toast('已经是最新版本');
- // }
- return;
- } else {
- this.$mRouter.push({
- route
- });
- }
- },
- coverTouchstart(e) {
- if (pageAtTop === false) {
- return;
- }
- this.coverTransition = 'transform .1s linear';
- startY = e.touches[0].clientY;
- },
- coverTouchmove(e) {
- moveY = e.touches[0].clientY;
- let moveDistance = moveY - startY;
- if (moveDistance < 0) {
- this.moving = false;
- return;
- }
- this.moving = true;
- if (moveDistance >= 80 && moveDistance < 100) {
- moveDistance = 80;
- }
- if (moveDistance > 0 && moveDistance <= 80) {
- this.coverTransform = `translateY(${moveDistance}px)`;
- }
- },
- coverTouchend() {
- if (this.moving === false) {
- return;
- }
- this.moving = false;
- this.coverTransition = 'transform 0.3s cubic-bezier(.21,1.93,.53,.64)';
- this.coverTransform = 'translateY(0px)';
- },
- toLogout() {
- var that = this;
- uni.showModal({
- title: "提示",
- content: "确认退出吗?",
- success: function(res) {
- if (res.confirm) {
- that.$store.commit('logout', that.$store.state);
- uni.reLaunch({
- url: '/pages/public/login'
- })
- }
- }
- })
- },
- //检查服务器版本号
- checkUpdate(nativeVersion) {
- console.log("版本号为:"+nativeVersion)
- //请求的url
- let url = this.$mConfig.baseUrl + '/appinterface/ip/version';
- //用户token 必传参数
- let token = this.$preToken + ' ' + this.$store.state.accessToken;
- this.$http.request({
- url: url,
- header: {
- 'content-type': 'application/json'
- },
- }).then(r => {
- //获取到的app最新版本号
- //获取url,如果含有中文,进行编码处理
- let url = encodeURI(r.data.dataUrl);
- let app_last_version = r.data.lastVersion;
- // console.log("下载地址"+url)
- // console.log("服务器版本:" + app_last_version)
- // console.log("客户端版本:" + nativeVersion)
- //比较两个版本
- let result = this.compareVersion(nativeVersion, app_last_version);
- console.log("需要更新"+result)
- console.log(this.$mConfig.baseUrl + r.data.dataUrl)
- // result为true,表示本地版本小于服务器版本
- if (result) {
- var that = this
- uni.showModal({
- title: "有新的版本",
- content: "请确认是否更新?",
- success: (info) => {
- console.log("服务器版本:" + app_last_version)
- console.log("客户端版本:" + nativeVersion)
- if (info.confirm) {
- // console.log(plus.os.name)
- // 因为App.vue中不能直接使用组件,这里用到了vuex来调用下载进度的组件
- // 显示下载进度弹窗
- //this.$store.commit('setHide',true)
- if (plus.os.name.toLowerCase() == 'ios') {
- // ios直接跳转到下载页面
- let downloadUrl = this.$mConfig.baseUrl + r.data.dataUrl
- return plus.runtime.openURL(downloadUrl)
- } else {
- let downloadUrl = this.$mConfig.baseUrl + r.data.dataUrl
- if(downloadUrl.substring(downloadUrl.lastIndexOf(".")+1) == "apk"){
- return that.downloadApk(downloadUrl)
- }else if(downloadUrl.substring(downloadUrl.lastIndexOf(".")+1) == "wgt"){
- return that.downloadWgt(downloadUrl)
- }
- }
- }
- }
- })
- //下载apk
- // this.$mHelper.toast('准备下载新版本');
- // let downloadUrl = this.$mConfig.baseUrl + r.data.dataUrl
- // console.log(downloadUrl)
- // this.downloadApk(downloadUrl);
- //安装apk
- } else {
- this.$mHelper.toast('已经是最新版本');
- }
- })
- .catch(() => {
- toastMsg('warning', "失败");
- });
- },
- compareVersion(nativeVersion, lastVersion) {
- nativeVersion = nativeVersion.split('.');
- lastVersion = lastVersion.split('.');
- let n = Math.max(nativeVersion.length, lastVersion.length)
- for (let i = 0; i < n; i++) {
- let code1 = (nativeVersion[i] === undefined) ? 0 : parseInt(nativeVersion[i]);
- let code2 = (lastVersion[i] === undefined) ? 0 : parseInt(lastVersion[i]);
- if (code1 > code2) {
- return false
- } else if (code1 < code2) {
- return true
- }
- }
- return false;
- },
- downloadApk(url) {
- let that = this;
- let watiting = plus.nativeUI.showWaiting("下载文件...");
- let dtask = plus.downloader.createDownload(url, {
- method: "GET",
- retry: 0,
- });
- dtask.addEventListener(
- "statechanged",
- function(task, status) {
- if (!dtask) {
- return;
- }
- switch (task.state) {
- case 1:
- break;
- case 2:
- break;
- case 3:
- var nowData = Math.floor(
- (task.downloadedSize * 100) / task.totalSize
- );
- watiting.setTitle("已下载:" + nowData + "%");
- if (nowData === 100) {
- watiting.toast("正在准备环境,请稍后!");
- watiting.close();
- }
- break;
- case 4:
- // 安装apk资源包
- plus.runtime.install(
- dtask.filename, {},
- function() {
- plus.nativeUI.closeWaiting();
- this.$needUpdate = false;
- plus.runtime.restart();
- // plus.nativeUI.alert("更新完成!", function () {
- // // 更新完成后重启应用
- // plus.runtime.restart();
- // });
- },
- function(e) {
- plus.nativeUI.closeWaiting();
- plus.nativeUI.toast("安装更新失败!");
- this.$needUpdate = true;
- }
- );
- break;
- default:
- break;
- }
- },
- false
- );
- dtask.setRequestHeader("Access-Control-Allow-Origin", "*");
- dtask.start();
- },
- //安装wgt
- downloadWgt(url){
-
- uni.downloadFile({
- url: url,
- success: (downloadResult) => {
- // console.log(plus.runtime.version)
- // console.log(url)
- // console.log(downloadResult.tempFilePath+'==========='+downloadResult.statusCode)
- plus.nativeUI.showWaiting("下载wgt文件...");
- if (downloadResult.statusCode === 200) {
- plus.nativeUI.toast("正在准备环境...");
- plus.runtime.install(downloadResult.tempFilePath, {
- force: false
- }, function() {
- plus.nativeUI.closeWaiting();
- plus.nativeUI.toast("更新成功,正在重启应用!");
- this.$needUpdate = false;
- plus.runtime.restart();
- }, function(e) {
- plus.nativeUI.closeWaiting();
- plus.nativeUI.toast("安装更新失败!"+e);
- this.$needUpdate = true;
- console.log(e)
- });
- }
- }
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- background-color: $page-color-base;
- }
-
- .updateDotParent{
- position:relative;
- }
- .updateTipDot {
- display:block;
- background:#f00;
- border-radius:50%;
- width:8px;
- height:8px;
- top:9px;
- left:73px;
- position:absolute;
- }
-
- .user {
- .promotion-center {
- background: #fff;
- margin-bottom: 20upx;
- /*分类列表*/
- .category-list {
- width: 100%;
- padding: 0 0 30upx 0;
- border-bottom: solid 2upx #f6f6f6;
- display: flex;
- flex-wrap: wrap;
- .category {
- width: 33.3%;
- margin-top: 50upx;
- display: flex;
- justify-content: center;
- flex-wrap: wrap;
- .img {
- width: 100%;
- display: flex;
- justify-content: center;
- .iconfont {
- font-size: $font-lg + 24upx;
- }
- }
- .text {
- width: 100%;
- display: flex;
- justify-content: center;
- font-size: 24upx;
- color: #3c3c3c;
- }
- .share-btn {
- height: 142upx;
- text-align: left;
- background: none;
- padding: 0;
- margin: 0;
- }
- .share-btn:after {
- border: none;
- border-radius: none;
- }
- }
- }
- }
- .order-section {
- @extend %section;
- padding: 28upx 0;
- .order-item {
- @extend %flex-center;
- width: 120upx;
- height: 120upx;
- border-radius: 10upx;
- font-size: $font-sm;
- color: $font-color-dark;
- position: relative;
- }
- .badge {
- position: absolute;
- top: 0;
- right: 4upx;
- }
- .iconfont {
- font-size: 48upx;
- }
- .icon-shouhoutuikuan {
- font-size: 44upx;
- }
- }
- .no-foot-print {
- text-align: center;
- padding: 48upx 0;
- .no-foot-print-icon {
- font-size: $font-lg + 2upx;
- margin-right: 10upx;
- }
- }
- .set {
- padding: $spacing-base 0;
- }
- .cu-list.card-menu {
- margin: $spacing-base 0;
- .title {
- margin-left: $spacing-base;
- }
- }
- .user-section {
- height: 520upx;
- padding: 100upx 30upx 0;
- position: relative;
- .bg {
- position: absolute;
- left: 0;
- top: 0;
- width: 100vw;
- height: 60vw;
- opacity: 0.84;
- }
- .user-info-box {
- height: 180upx;
- display: flex;
- align-items: center;
- position: relative;
- z-index: 1;
- justify-content: space-between;
- .portrait-box {
- display: flex;
- align-items: center;
- .portrait {
- width: 130upx;
- height: 130upx;
- border: 5upx solid #fff;
- border-radius: 50%;
- }
- .username {
- font-size: $font-lg + 6upx;
- color: $color-white;
- margin-left: 20upx;
- }
- button {
- background-color: transparent;
- font-size: $font-lg + 6upx;
- color: $font-color-dark;
- border: none;
- }
- button::after {
- border: none;
- }
- }
- }
- .vip-card-box {
- display: flex;
- flex-direction: column;
- color: #f7d680;
- height: 240upx;
- background: url('/static/vip-card.png');
- background-size: 100% 100%;
- border-radius: 16upx 16upx 0 0;
- overflow: hidden;
- position: relative;
- padding: 20upx 24upx;
- .b-btn {
- position: absolute;
- right: 24upx;
- top: 24upx;
- width: 160upx;
- height: 40upx;
- text-align: center;
- line-height: 40upx;
- font-size: 22upx;
- color: #36343c;
- border-radius: 20px;
- background: linear-gradient(to left, #f9e6af, #ffd465);
- z-index: 1;
- }
- .tit {
- font-size: $font-base + 2upx;
- color: #f7d680;
- margin-bottom: 28upx;
- .iconfont {
- color: #f6e5a3;
- display: inline-block;
- margin-right: 16upx;
- }
- }
- }
- }
- .cover-container {
- margin-top: -150upx;
- padding: 0 30upx 20upx;
- position: relative;
- background-color: $page-color-base;
- .arc {
- position: absolute;
- left: 0;
- top: -34upx;
- width: 100%;
- height: 36upx;
- }
- .promotion-center {
- background: #fff;
- margin-bottom: 20upx;
- /*分类列表*/
- .category-list {
- width: 100%;
- padding: 0 0 30upx 0;
- border-bottom: solid 2upx #f6f6f6;
- display: flex;
- flex-wrap: wrap;
- .category {
- width: 33.3%;
- margin-top: 50upx;
- display: flex;
- justify-content: center;
- flex-wrap: wrap;
- .img {
- width: 100%;
- display: flex;
- justify-content: center;
- .iconfont {
- font-size: $font-lg + 24upx;
- }
- }
- .text {
- width: 100%;
- display: flex;
- justify-content: center;
- font-size: 24upx;
- color: #3c3c3c;
- }
- .share-btn {
- height: 142upx;
- text-align: left;
- background: none;
- padding: 0;
- margin: 0;
- }
- .share-btn:after {
- border: none;
- border-radius: none;
- }
- }
- }
- }
- .tj-sction {
- @extend %section;
- display: flex;
- .tj-item {
- @extend %flex-center;
- flex: 1;
- flex-direction: column;
- margin: 30upx 0;
- font-size: $font-sm;
- color: #75787d;
- /*border-right: 2upx solid rgba(0, 0, 0, 0.2);*/
- }
- /*.tj-item:last-child {*/
- /*border-right: none;*/
- /*}*/
- .num {
- font-size: $font-base;
- }
- .red {
- color: $base-color;
- }
- }
- }
- }
-
- .log-out-btn{
- border: 1px solid;
- border-radius: 10px;
- }
- %flex-center {
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- %section {
- justify-content: space-around;
- display: flex;
- align-content: center;
- background: #fff;
- border-radius: 10upx;
- }
- </style>
|