| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- <!--
- 我的
- http://localhost:5173/actMgt/#/pages/my/index
- https://oss-mbh5.colormaprun.com/actMgt/#/pages/my/index
- -->
- <template>
- <view class="body">
- <view class="content uni-column">
- <view class="uni-column top">
- <view class="top-content uni-row">
- <image class="tc-headimg" mode="aspectFit" src="/static/headimg.png"></image>
- <view class="tc-userBox uni-column uni-ais uni-jcse">
- <view class="userBox-name">{{selfInfo.name}}</view>
- <view class="userBox-info uni-row">
- <view class="">等级:{{userLevel[selfInfo.level]}}</view>
- <!-- <view class="" style="margin-left: 20px;">余额:¥120.00</view> -->
- </view>
- </view>
- <view class="btnQuit" @click="btnQuit">退出</view>
- </view>
- </view>
- <view class="main uni-column">
- <uni-list class="center-list" v-for="(sublist , index) in ucenterList" :key="index">
- <uni-list-item v-for="(item,i) in sublist" :title="item.title" :showArrow="item.to != ''" :rightText="item.rightText"
- :key="i" :clickable="true" :to="item.to" @click="ucenterListClick(item)" :show-extra-icon="true"
- :extraIcon="{type:item.icon,color:'#999'}">
- <template v-slot:footer>
- <view v-if="item.rightCustom" class="item-footer" :class="item.rightCustomCss">
- <view class="item-footer-text" v-html="item.rightText"></view>
- </view>
- </template>
- </uni-list-item>
- </uni-list>
- </view>
- </view>
-
- <uni-popup ref="confirmDialog" type="dialog">
- <uni-popup-dialog type="warn" cancelText="取消" confirmText="确定" title="提示" :content="confirmContent"
- @confirm="confirmDialogConfirm"></uni-popup-dialog>
- </uni-popup>
-
- </view>
- </template>
- <script>
- import {
- mapState,
- mapGetters
- } from 'vuex';
- import tools from '/utils/tools.js';
- import { userLevel } from '/utils/define.js';
- import {
- apiSignOut,
- apiGetSelfInfo,
- checkResCode
- } from '/utils/api.js';
-
- export default {
- components: {},
- data() {
- return {
- userLevel: userLevel,
- queryObj: {},
- queryString: "",
- confirmContent: "",
-
- selfInfo: {
- name: "", // 姓名
- phone: "", // 手机号
- balance: "",// 余额
- level: "", // 等级
- },
-
- ucenterList: [
- [{
- "title": "姓名",
- "rightText": "",
- "icon": "person",
- "to": ""
- },
- {
- "title": "手机号",
- "rightText": "",
- "icon": "phone",
- "event": '',
- "to": ""
- }
- ],
- [{
- "title": "余额",
- "rightCustom": true,
- "rightCustomCss": "item-balance",
- "rightText": "",
- "icon": "wallet",
- "to": ""
- /* }, {
- "title": "费用明细",
- "icon": "list",
- "to": "/pages/my/costList"
- }, {
- "title": "在线充值",
- "icon": "shop",
- "to": "/pages/my/onlinePay" */
- }]
- ],
- }
- },
- computed: {
- ...mapState([
- 'username', // 映射 this.username 为 store.state.username
- 'token'
- ]),
- ...mapGetters([
- 'metadata'
- ]),
- },
- onLoad(query) {
- this.init();
- },
- onShow() {
- // console.log("metadata:", this.metadata);
- this.init();
- },
- methods: {
- init() {
- this.getSelfInfo();
- },
- // 获取个人信息
- getSelfInfo() {
- uni.request({
- url: apiGetSelfInfo,
- header: this.metadata,
- method: "POST",
- data: {
- },
- success: (res) => {
- console.log("getSelfInfo", res);
- if (checkResCode(res)) {
- const data = res.data.data;
- this.selfInfo = data;
-
- this.ucenterList[0][0]["rightText"] = this.selfInfo.name;
- this.ucenterList[0][1]["rightText"] = this.selfInfo.phone;
- this.ucenterList[1][0]["rightText"] = this.selfInfo.balance + " 元";
- }
- },
- fail: (err) => {
- console.log("getSelfInfo err", err)
- },
- });
- },
- // 用户退出
- signOut() {
- uni.request({
- url: apiSignOut,
- header: this.metadata,
- method: "POST",
- data: {
- username: this.username,
- password: this.password
- },
- success: (res) => {
- console.log("signOut", res);
- if (res.data.code == 0) {
-
- this.$store.commit("setUsername", "");
- this.$store.commit("setUserlevel", 0);
- this.$store.commit("setToken", "");
-
- uni.showToast({
- title: `账号已退出`,
- icon: 'none',
- duration: 3000
- });
-
- const url = '/pages/login/login';
- tools.appAction(url, "uni.navigateTo");
- } else {
- uni.showToast({
- title: `退出失败: ${res.data.message}`,
- icon: 'none',
- duration: 5000
- });
- }
- },
- fail: (err) => {
- console.log("signOut err", err);
- },
- });
- },
- /* showDetail(data) {
- console.log("showDetail data:", data);
- this.queryObj.actId = data.actId;
- this.queryString = tools.objectToQueryString(this.queryObj);
- const url = '/pages/exchange/style1/goodsDetail?' + this.queryString;
- tools.appAction(url, "uni.navigateTo");
- }, */
- btnQuit() {
- this.confirmContent = `您确定要退出吗?`;
- this.$refs.confirmDialog.open();
- },
- confirmDialogConfirm() {
- this.signOut();
- },
- ucenterListClick(item) {
- if (!item.to && item.event) {
- this[item.event]();
- }
- },
- }
- }
- </script>
- <style scoped>
- /deep/ uni-page {
- background-color: #F6F6F6;
- }
-
- .top {
- background: url("../../static/bg_topbar.png") no-repeat;
- background-size: 100% 100%;
- }
-
- .top-content {
- position: relative;
- width: 90%;
- height: 90px;
- }
- .tc-headimg {
- width: 48px;
- height: 48px;
- }
- .tc-userBox {
- height: 80%;
- margin-left: 20px;
- flex-grow: 1;
- }
- .userBox-name {
- font-size: 16px;
- font-weight: 550;
- color: #ffffff;
- }
- .userBox-info {
- width: 90%;
- font-size: 14px;
- font-weight: 500;
- color: #ffffff;
- }
- .btnQuit {
- width: 45px;
- height: 26px;
- border-radius: 4px;
- background: #FFE19C;
- line-height: 26px;
- text-align: center;
- font-size: 14px;
- font-weight: 400;
- color: #383838;
- }
-
- .center-list {
- width: 100%;
- margin-top: 10px;
- }
-
- ::v-deep .uni-list-item__extra-text {
- font-size: 14px;
- }
-
- .item-footer {
- flex-direction: row;
- align-items: center;
- }
-
- .item-balance {
- color: #383838;
- font-size: 18px;
- font-weight: 500;
- /* padding-right: 10rpx; */
- }
-
- </style>
|