123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <template>
- <view>
- <u-cell-item :title="userInfo.mobile?'修改手机号':'绑定手机号'" :value="tel" @click="gophone"></u-cell-item>
- <u-cell-item title="修改密码" @click="gopwd"></u-cell-item>
- <view class="fixed-bottom pb-80" v-if="token">
- <u-button type="primary" @click="exit">退出登录</u-button>
- </view>
- <u-modal v-model="show" content="确定解除微信绑定?" :show-cancel-button="true" @confirm="confirm"></u-modal>
- </view>
- </template>
- <script>
- import {
- mapState
- } from 'vuex'
- export default {
- data() {
- return {
- show: false,
- }
- },
- computed: {
- ...mapState(['userInfo', 'token']),
- tel() {
- return !this.token? '请登录':this.userInfo.mobile ? this.userInfo.mobile : '未绑定'
- },
- vx() {
- return !this.token? '请登录':this.userInfo.openid ? '已绑定(' + this.userInfo.wx_name + ')' : '未绑定'
- }
- },
- methods: {
- gophone() { //修改手机号
- if (this.token) {
- if (this.userInfo.mobile) {
- uni.navigateTo({
- url: '/pages/my/set/phone-number'
- })
- } else {
- uni.navigateTo({
- url: '/pages/login/phone?type=1'
- })
- }
- }
- },
- gopwd() { //修改密码
- if (this.token) {
- uni.navigateTo({
- url: '/pages/login/forget-pwd?type=2'
- })
- }
- },
- exit() {
- this.$store.commit('exitLogin')
- uni.navigateBack({})
- setTimeout(() => {
- uni.showToast({
- title: '退出成功'
- })
- }, 100)
- },
- wxLogin() {
- if (this.token) {
- if (this.vx == '未绑定') {
- let _this = this;
- uni.login({
- provider: 'weixin',
- success: function(loginRes) {
- console.log(loginRes.authResult);
- // 获取用户信息
- uni.getUserInfo({
- provider: 'weixin',
- success: function(infoRes) {
- console.log(infoRes.userInfo);
- _this.$http('/addons/ddrive/wx_login/wxlogin', {
- openid: infoRes.userInfo.openId,
- wx_name: infoRes.userInfo.nickName
- }, "POST").then(data => {
- console.log(data);
- _this.$store.dispatch('updateUserInfo')
- setTimeout(() => {
- uni.showToast({
- title: '绑定成功'
- })
- }, 100)
- })
- }
- });
- }
- });
- } else {
- if (this.userInfo.mobile) {
- this.show = true
- }
- }
- }
- },
- // 解除微信绑定
- confirm() {
- this.$http('/addons/ddrive/wx_login/untie', "POST").then(data => {
- this.$store.dispatch('updateUserInfo')
- uni.showToast({
- title: '解绑成功'
- })
- console.log(data);
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/.u-btn {
- height: 96rpx !important;
- }
- /deep/.u-primary-hover {
- background-color: $blue !important;
- }
- /deep/.u-cell {
- padding: 30rpx 32rpx;
- }
-
- </style>
|