|
|
<template> <view id="personalCenter" v-if="accountInfoInit"> <lf-nav title="我的"></lf-nav>
<!--uto不用--> <view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg" v-if="accountInfo && accountInfo.miniProgram.appId != 'wx53d4c6e7b2c13a13'"> <view class="bg"> <view class="ban-item-l" v-if="token"> <view class="user-avatar"> <image :src="detail.avatar"></image> </view> <view class="user-text"> <view class="nick-name">{{detail.nick_name}}</view> </view> </view> <view class="ban-item-r" v-if="token"> <!--<view class="private-letter"> <view class="iconfont icon--xiaoxi"></view> <view class="dot"></view> </view>-->
<!-- <view class="up-grade" @tap.stop="jumpVip"> <view class="icon-img"> <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image> </view> <view class="vip-copy"> <view class="pretty">VIP</view> <view class="up">升级领特权</view> </view> </view> --> </view>
<view class="iconfont icon-shezhi setting">
</view> <view class="unlogin" v-if="!token"> 登录/注册 </view> </view>
</view>
<!--uni-app-h5-->
<!-- #ifdef H5 -->
<view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg"> <view class="bg"> <view class="ban-item-l" v-if="token"> <view class="user-avatar"> <image :src="detail.avatar"></image> </view> <view class="user-text"> <view class="nick-name">{{detail.nick_name}}</view> <!-- <view class="vip-text"> <view class="vip-grade">V{{detail.grade}}</view> <view class="vip-name" v-if="detail.is_agent">{{detail.agent_name}}</view> <view class="vip-name svip" v-if="detail.vip"> <block v-if="detail.vip.plan.level == 1"> VIP </block> <block v-if="detail.vip.plan.level == 2"> SVIP </block> <block v-if="detail.vip.plan.level == 3"> SVIP+ </block> </view> </view> --> </view> </view> <view class="ban-item-r" v-if="token"> <!--<view class="private-letter"> <view class="iconfont icon--xiaoxi"></view> <view class="dot"></view> </view>--> <!-- <view class="up-grade" @tap.stop="jumpVip"> <view class="icon-img"> <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image> </view> <view class="vip-copy"> <view class="pretty">VIP</view> <view class="up">升级领特权</view> </view> </view> --> </view>
<view class="iconfont icon-shezhi setting">
</view> <view class="unlogin" v-if="!token"> 登录/注册 </view> </view>
</view>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view class="pc-banner" :style="'background: ' + config.mainColor" @tap="jumpImg"> <view class="bg"> <view class="ban-item-l" v-if="token"> <view class="user-avatar"> <image :src="detail.avatar"></image> </view> <view class="user-text"> <view class="nick-name">{{detail.nick_name}}</view> </view> </view> <view class="ban-item-r" v-if="token"> </view>
<view class="iconfont icon-shezhi setting">
</view> <view class="unlogin" v-if="!token"> 登录/注册 </view> </view>
</view>
<!-- #endif -->
<!--uto专用--> <view class="pc-banner uto-banner" @tap="jumpImg" v-if="accountInfo && accountInfo.miniProgram.appId == 'wx53d4c6e7b2c13a13'"> <view class="bg"> <view class="ban-item-l" v-if="token"> <view class="user-avatar"> <image :src="detail.avatar"></image> </view> <view class="user-text"> <view class="nick-name">{{detail.nick_name}}</view> <view class="vip-text"> <view class="vip-grade">V{{detail.grade}}</view> <view class="vip-name" v-if="detail.is_agent">{{detail.agent_name}}</view> <view class="vip-name svip" v-if="detail.vip"> <block v-if="detail.vip.plan.level == 1"> VIP </block> <block v-if="detail.vip.plan.level == 2"> SVIP </block> <block v-if="detail.vip.plan.level == 3"> SVIP+ </block> </view> </view> </view> </view> <view class="ban-item-r" v-if="token"> <!--<view class="private-letter"> <view class="iconfont icon--xiaoxi"></view> <view class="dot"></view> </view>--> <view class="up-grade" @tap.stop="jumpVip"> <view class="icon-img"> <image src="https://ibrand-miniprogram.oss-cn-hangzhou.aliyuncs.com/%E5%B0%8F%E7%A8%8B%E5%BA%8F/%E4%BC%9A%E5%91%98.png"></image> </view> <view class="vip-copy"> <view class="pretty">VIP</view> <view class="up">升级领特权</view> </view> </view> </view>
<view class="iconfont icon-shezhi setting">
</view> <view class="unlogin" v-if="!token"> 登录/注册 </view> </view>
</view>
<view class="binding__phone" @tap="jumpPhone" v-if="!detail.mobile && token && init"> <i class="iconfont icon-warning"></i> <view class="phone-text">应国家监管要求,会员账户需绑定手机号码。</view> <i class="iconfont icon-Chevron"></i> </view> <!-- #ifdef MP-WEIXIN --> <button class="binding__phone binding__user" open-type="getUserInfo" @getuserinfo="bindUserInfo" v-if="!detail.user_info_fill && token && init"> <i class="iconfont icon-warning"></i> <view class="phone-text">请完善个人信息</view> </button> <!-- #endif --> <!-- #ifdef APP-PLUS --> <button class="binding__phone binding__user" @tap="bindappUserInfo" v-if="!detail.user_info_fill && token && init"> <i class="iconfont icon-warning"></i> <view class="phone-text">请完善个人信息</view> </button> <!-- #endif --> <!--优惠券UTO专用--> <view class="new-coupons-box" :style="'top: ' + top + '; margin-bottom: ' + bottom + ';'" v-if="accountInfo && accountInfo.miniProgram.appId == 'wx53d4c6e7b2c13a13'"> <view class="top-item"> <view class="info mx-1px-right" @tap="jumpBalance"> <view class="balance">{{newdetail.balance || 0}}</view> <view class="txt">余额</view> </view> <view class="info" data-url="/pages/point/index/index" @tap="jumpItem"> <view class="balance">{{newdetail.point || 0}}</view> <view class="txt">可用积分</view> </view> </view> <view class="bottom-item"> <view class="bg-img" data-url="/pages/coupon/index/index" @tap="jumpItem"> <view class="title"> 优惠券 </view> <view class="number"> X {{newdetail.coupon || 0}} </view> </view> </view> </view> <view class="all-orders"> <view class="order-header mx-1px-bottom" data-status="0" @tap="jump"> <view class="order-text">全部订单</view> <view class="iconfont icon-Chevron"></view> </view> <view class="order-content"> <view class="item" data-status="1" @tap="jump"> <view class="iconfont icon--daifukuan"></view> <view>待付款</view> <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.newCount">{{newdetail.newCount}}</view> </view> <view class="item" data-status="2" @tap="jump"> <view class="iconfont icon--daifahuo"></view> <view>待发货</view> <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.paidCount">{{newdetail.paidCount}}</view> </view> <view class="item" data-status="3" @tap="jump"> <view class="iconfont icon--daishouhuo"></view> <view>待收货</view> <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.deliveredCount">{{newdetail.deliveredCount}}</view> </view> <!--uto不用-->
<view class="item" @tap="jumpComment"> <view class="iconfont icon--daipingjia"></view> <view>待评价</view> <view class="position-num" :style="'color: ' + config.mainColor + '; border-color: ' + config.mainColor" v-if="token && newdetail.receiveCount">{{newdetail.receiveCount}}</view> </view> <view class="item" @tap="jumpAfterSales"> <view class="iconfont icon-shouhou"></view> <view>售后</view> </view> </view> </view> <!--uto不用--> <view class="info-detail" v-if="accountInfo && accountInfo.miniProgram.appId != 'wx53d4c6e7b2c13a13'"> <!-- <view class="item" @tap="jumpFavor"> <view class="number"><text>{{newdetail.favCount || 0}}</text></view> <view>收藏</view> </view> --> <view class="item" @tap="jumpAddress"> <view v-if="token"> <view class="number"><text>{{newdetail.addressCount || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>地址</view> </view> <view class="item" @tap="jumpBalance"> <view v-if="token"> <view class="number"><text>{{newdetail.balance || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>余额</view> </view> <view class="item" data-url="/pages/point/index/index" @tap="jumpItem"> <view v-if="token"> <view class="number"><text>{{newdetail.point || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>积分</view> </view> <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem"> <view v-if="token"> <view class="number"><text>{{newdetail.couponCount || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>优惠券</view> </view> </view>
<!-- #ifdef H5 --> <view class="info-detail"> <!-- <view class="item" @tap="jumpFavor"> <view class="number"><text>{{newdetail.favCount || 0}}</text></view> <view>收藏</view> </view> --> <view class="item" @tap="jumpAddress"> <view v-if="token"> <view class="number"><text>{{newdetail.addressCount || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>地址</view> </view> <view class="item" @tap="jumpBalance"> <view v-if="token"> <view class="number"><text>{{newdetail.balance || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>余额</view> </view> <view class="item" data-url="/pages/point/index/index" @tap="jumpItem"> <view v-if="token"> <view class="number"><text>{{newdetail.point || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>积分</view> </view> <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem"> <view v-if="token"> <view class="number"><text>{{newdetail.couponCount || 0}}</text></view> </view> <view v-else> <view class="number"><text>0</text></view> </view> <view>优惠券</view> </view> </view> <!-- #endif -->
<!-- #ifdef APP-PLUS --> <view class="info-detail"> <!-- <view class="item" @tap="jumpFavor"> <view class="number"><text>{{newdetail.favCount || 0}}</text></view> <view>收藏</view> </view> --> <view class="item" @tap="jumpAddress"> <view v-if="token" class="number"><text>{{newdetail.addressCount || 0}}</text></view> <view v-else class="number">0</view> <view>地址</view> </view> <view class="item" @tap="jumpBalance"> <view v-if="token" class="number"><text>{{newdetail.balance || 0}}</text></view> <view v-else class="number">0</view> <view>余额</view> </view> <view class="item" data-url="/pages/point/index/index" @tap="jumpItem"> <view v-if="token" class="number"><text>{{newdetail.point || 0}}</text></view> <view v-else class="number">0</view> <view>积分</view> </view> <view class="item" data-url="/pages/coupon/index/index" @tap="jumpItem"> <view v-if="token" class="number"><text>{{newdetail.couponCount || 0}}</text></view> <view v-else class="number">0</view> <view>优惠券</view> </view> </view> <!-- #endif --> <view v-if="token"> <view class="section-serve" v-if="initInfo && initInfo.need_sign_in || initInfo && initInfo.point_mall_status ||initInfo&& initInfo.built_sns_status || detail.distribution_status"> <view class="title mx-1px-bottom">我的服务</view> <view class="server-box mx-1px-bottom"> <!--uto不用--> <view class="item" @tap="jumpCollar" v-if="initInfo && initInfo.need_sign_in"> <view class="iconfont icon-daqiaqiandao info"></view> <view>打卡签到</view> </view> <view class="item" @tap="jumpPoint" v-if="initInfo && initInfo.point_mall_status"> <view class="iconfont icon--jifen info mall"></view> <view>积分商城</view> </view> <!--<view class="item" @tap="jumpTravel" v-if="initInfo.built_sns_status">--> <!--<view class="iconfont icon-mifenquan info mi"></view>--> <!--<view>我的{{initInfo.built_sns_title}}</view>--> <!--</view>--> <view class="item" v-if="detail.distribution_status == 1 && detail.is_agent == 1" data-url="/pages/distribution/distributionCenter/distributionCenter" @tap="jumpItem"> <view class="iconfont icon--fenxiaozhongxin info"></view> <view>分销中心</view> </view> <view class="item" v-if="detail.distribution_status == 1 && detail.distribution_recruit_status == 1 && detail.is_agent == 0" data-url="/pages/distribution/applyDistribution/applyDistribution" @tap="jumpItem"> <view class="iconfont icon--fenxiaozhongxin info"></view> <view>加入分销</view> </view> <view class="item" v-if="detail.wecaht_group" data-url="/pages/user/gidList/gidList" @tap="jumpItem"> <view class="iconfont icon--weixin info mi"></view> <view>群列表</view> </view> <view class="item" @tap="changeAttention"> <view class="iconfont icon-service info mi"></view> <view>联系客服</view> </view> <!-- <view class="item" data-url="/pages/user/find/find" @tap="jumpItem"> <view class="iconfont icon-faxian info mall"></view> <view>素材库</view> </view> --> <view class="item" data-url="/pages/bargain/list/list" @tap="jumpItem"> <view class="iconfont icon-daqiaqiandao info"></view> <view>我的砍价</view> </view> <view class="item" @tap="changeAgreement"> <view class="iconfont icon-question-circle-o info agree"></view> <view>关于果酱</view> </view> </view> </view> </view>
<view class="swiper-adv" v-if="img_list.length"> <swiper indicator-dots="true" autoplay="true" circular="true"> <swiper-item :data-url="item.url" @tap="jumpOpenVip" v-for="(item, index) in img_list" :key="index"> <image :src="item.img"></image> </swiper-item> </swiper> </view>
<view style="text-align: center;padding: 10px 0 20px 0;font-size: 12px;color:#6A6A6A"><view class="copy-right"> Copyright@2019-2020 <view>果酱社区 版权所有</view> </view></view>
<!--弹出客服-->
<view class="maks" :class="show_attention ? 'cur' : ''" @tap="changeAttention">
</view>
<view class="attention-WeChat" :class="show_attention ? 'cur' : ''"> <view class="service-box"> <view class="code item" @tap="previewImage"> <image mode="widthFix" :src="(service_info && service_info.online_service_self&& service_info.online_service_self.qr_code) ?service_info.online_service_self.qr_code:''" alt></image> <view class="text"> 保存二维码用微信识别添加 </view> </view>
<view class="item phone" @tap="callPhone"> <view class="phone-text"> <image mode="widthFix" :src="(service_info && service_info.online_service_self && service_info.online_service_self.qr_code) ?service_info.online_service_self.qr_code:''" alt></image> <view class="phone-warp"> <i class="iconfont icon-dianhua"></i> <view class="phone-num">{{service_info && service_info.online_service_self && service_info.online_service_self.phone ?service_info.online_service_self.phone:''}}</view> <view>点击电话,咨询客服</view> </view> </view> <view> {{(service_info && service_info.online_service_self && service_info.online_service_self.time) ?service_info.online_service_self.time:''}} </view> </view> </view> </view> <view class="is_birthday" v-if="is_showBirth"> <!-- 生日有礼 --> <birthday :gift-data="giftData" @close="changeBirthday"></birthday> </view> <lf-tabbar></lf-tabbar> </view></template><script> import { pageLogin, GetUrl, isBirthday, // #ifdef MP-WEIXIN
autoLogin // #endif
} from '@/common/js/utils.js'; import birthday from '@/components/birthday/birthday.vue'; import lfNav from '@/components/lf-nav/lf-nav.vue'; import lfTabbar from '@/components/lf-tabbar/lf-tabbar.vue'; var app = getApp();
export default { data() { return { detail: "", newdetail: "", token: "", code: '', shop_id: '', unionInFo: '', openInFo: '', init: false, config: '', author: '', initInfo: { need_sign_in: '' }, accountInfo: '', accountInfoInit: false, top: 13, bottom: '-13px', show_attention: false, img_list: "", service_info: '', giftData:'',//生日有礼的数据
is_showBirth:false,//是否显示生日礼
}; }, components:{ birthday, lfNav, lfTabbar },
onLoad(e) {
var accountInfo = ''; // #ifdef MP-WEIXIN
var accountInfo = wx.getAccountInfoSync(); // #endif
this.accountInfo = accountInfo; this.accountInfoInit = true this.inits(e); this.getCenterList(); },
onShow() { // 第三方平台配置颜色
var bgConfig = this.$cookieStorage.get('globalConfig') || ''; var initInfo = this.$cookieStorage.get('init'); this.config = bgConfig; this.initInfo = initInfo; this.author = initInfo && initInfo.other_technical_support ? initInfo.other_technical_support : '';
if (!bgConfig) { let extConfig = {};
if (extConfig) { this.config = extConfig; } }
var token = this.$cookieStorage.get('user_token');
this.token = token;
if (token) { this.getUserInfo(); this.getCenter(); // #ifdef MP-WEIXIN
if (this.code) { wx.checkSession({ success: res => { if (res.errMsg != 'checkSession:ok') { this.getCode(); } } }); } else { this.getCode(); } // #endif
}
}, methods: { //点击进入协议页面
changeAgreement(){ wx.navigateTo({ url:"/pages/user/agreement/agreement" }) }, changeBirthday(){ this.is_showBirth = false; var gift= this.$cookieStorage.get("birthday_gift"); gift.flag=true; this.$cookieStorage.set("birthday_gift",gift); }, changeAttention() {
this.show_attention = !this.show_attention; },
previewImage() {
wx.previewImage({ current: this.service_info.online_service_self.qr_code, urls: [this.service_info.online_service_self.qr_code] }); },
jumpOpenVip(e) { var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url }); },
callPhone() { wx.makePhoneCall({ phoneNumber: this.service_info.online_service_self.phone }); }, // app获取用户信息
/* bindappUserInfo(){ // 获取用户信息
var app_info = this.$cookieStorage.get('app_user_info'); console.log('app_info',app_info); this.updateUserInfo(app_info); }, */
// 获取初始化数据
inits(e) { var token = this.$cookieStorage.get('user_token'); var agent_code = ''; if (e.agent_code) { agent_code = e.agent_code; } if (e.scene) { var scene = decodeURIComponent(e.scene); var sceneArr = scene.split(',');
if (sceneArr.length > 0) { agent_code = sceneArr[1]; } }
this.$http.get({ api: 'api/system/init' }).then(res => { if (res.statusCode == 200) { res = res.data; if (res.status) { if (res.data && res.data.other_technical_support) {
this.author = res.data.other_technical_support; }
this.$cookieStorage.set('init_info', res.data.h5_share); this.$cookieStorage.set('service_info', res.data.online_service_data); this.$cookieStorage.set('distribution_valid_time', res.data.distribution_valid_time); this.$cookieStorage.set('init', res.data); this.$cookieStorage.set('userName', ) var service_info = this.$cookieStorage.get('service_info');
this.service_info = service_info; this.setCode(e);
// #ifdef MP-WEIXIN
if (agent_code && res.data.mini_program_login_type == 'default' && token == '') { wx.showLoading({ title: '正在自动登录', mask: true }); wx.login({ success: res => { if (res.code) { autoLogin(res.code, agent_code).then(res => { if (res.status) { if (res.data.access_token) { var access_token = res.data.token_type + ' ' + res.data.access_token; this.is_login = access_token; this.token = access_token; if(this.is_login){ this.getUserInfo(); this.getCenter(); } if (this.code) { wx.checkSession({ success: res => { if (res.errMsg != 'checkSession:ok') { this.getCode(); } } }); } else { this.getCode(); } } if (res.data.open_id) { wx.reLaunch({ url: '/pages/user/agentlogin/agentlogin?agent_code=' + agent_code + '&open_id=' + res.data.open_id + '&url=' + getUrl() + '&is_tab=true' }); } } wx.hideLoading(); }, err => { wx.hideLoading(); }); } else { wx.showToast({ title: '获取code失败', icon: 'none' }); } } }); } // #endif
// #ifdef H5
if(agent_code && token == ''){ var env = { isIPad: /ipad/i.test(window.navigator.userAgent), isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent), isWechat: /MicroMessenger/i.test(window.navigator.userAgent) } if(env.isWechat){ if(e.openid){ this.$cookieStorage.set('openid',e.openid) } var openid = this.$cookieStorage.get('openid') || e.openid; if(openid){ this.postNewQuickLogin(openid,agent_code); } else{ let origin = window.location.origin; var url = origin+'/pages/user/personal/personal?agent_code='+agent_code; window.location.href = this.$config.GLOBAL.baseUrl+'oauth/wxOauth?redirect_url='+encodeURIComponent(url); } } else{ wx.navigateTo({ url:'/pages/user/loginType/loginType' }) } } // #endif
} else { this.setCode(e); } } else { this.setCode(e); } }); }, postNewQuickLogin(open_id,agent_code){ wx.showLoading({ title: '正在登录', mask: true }); this.$http.post({ api:'api/oauth/newQuickLogin', data:{ open_id:open_id, agent_code:agent_code } }).then(res=>{ res = res.data; if(res.status){ if(res.data.access_token){ var access_token = res.data.token_type + ' ' + res.data.access_token; var expires_in = res.data.expires_in || 315360000; this.$cookieStorage.set("user_token", access_token, expires_in); //如果用户没有绑定手机号
if(res.data.has_bind_mobile == 0){ wx.reLaunch({ url:'/pages/user/bindingphone/bindingphone' }) } else{ this.token = this.$cookieStorage.get('user_token'); if(this.token){ this.getUserInfo(); this.getCenter(); } } } else{ wx.showModal({ content: res.message || '请求失败,请重试', showCancel: false }); } } else{ wx.showModal({ content: res.message || '请求失败,请重试', showCancel: false }); } wx.hideLoading() }).catch(rej=>{ wx.showModal({ content: rej.message || '请求失败,请重试', showCancel: false }); wx.hideLoading() }) },
setCode(e) { const timeMap = { y: 31536000000, m: 2592000000, d: 86400000, h: 3600000, n: 60000, s: 1000 }; // 默认有效期为7天
var valid_time = ""; var clerk_id = e.clerk_id || ""; var shop_id = e.shop_id || ""; var agent_code = e.agent_code || '';
if (e.scene) { var scene = decodeURIComponent(e.scene); var sceneArr = scene.split(',');
if (sceneArr.length > 0) { agent_code = sceneArr[0]; } }
var cook_shop_id = this.$cookieStorage.get('shop_id');
if (!this.$cookieStorage.get('distribution_valid_time')) { valid_time = 10080; } else { valid_time = this.$cookieStorage.get('distribution_valid_time'); } let timeStamp = new Date().getTime(); timeStamp += timeMap.n * valid_time; // 当url上shop_id与缓存中shop_id不一致时,需要清除clerk_id。以此保证shop_id与clerk_id对应
var cook_clerk_id = this.$cookieStorage.get('clerk_id');
if (cook_shop_id != shop_id && cook_clerk_id) { this.$cookieStorage.clear('clerk_id'); }
if (agent_code) { this.$cookieStorage.set('agent_code', agent_code, valid_time + 'n'); // 如果有agent_code就将这次进入的时间缓存
this.$cookieStorage.set('agent_code_time', timeStamp, valid_time + 'n'); // 如果有agent_code并且有coupon_agent_code就将coupon_agent_code清除,保证agent_code为第一位
if (this.$cookieStorage.get('coupon_agent_code')) { this.$cookieStorage.clear('coupon_agent_code'); } }
if (clerk_id) { this.$cookieStorage.set('clerk_id', clerk_id, valid_time + 'n'); }
if (shop_id) { this.$cookieStorage.set('shop_id', shop_id, valid_time + 'n'); // 如果有shop_id就将这次进入的时间缓存
this.$cookieStorage.set('shop_id_time', timeStamp, valid_time + 'n'); } },
jumpAuthor() { wx.navigateTo({ url: '/pages/index/author/author' }); },
getCode() { wx.login({ success: res => { if (res.code) { this.code = res.code; } } }); },
jumpItem(e) { if (!this.token) { return this.jumpLogin(); }
var url = e.currentTarget.dataset.url; wx.navigateTo({ url: url }); },
jumpLogin() { wx.navigateTo({ url: '/pages/user/register/register' }); },
jumpPhone() { wx.navigateTo({ url: '/pages/user/phone/phone' }); },
jumpFavor() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/favorite/index/index' }); },
jumpPoint() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/pointStore/index/index' }); },
jumpTravel() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/travels/myTravel/myTravel' }); },
getUserInfo() { this.$http.get({ api: 'api/me', header: { Authorization: this.$cookieStorage.get('user_token') } }).then(res => { if (res.data.status) { if (!res.data.data.mobile || !res.data.data.user_info_fill) { this.top = 0; this.bottom = '5px'; } this.detail = res.data.data; this.init = true; // 把头像和昵称存起来,签到页面直接获取
this.$cookieStorage.set('userInfoImg', res.data.data.avatar) this.$cookieStorage.set('userInfoName', res.data.data.nick_name) if(!res.data.data.gift_is_receive){ isBirthday().then(()=>{ if(this.$cookieStorage.get("birthday_gift")){ var giftData=this.$cookieStorage.get("birthday_gift").data; this.giftData = giftData; this.is_showBirth = true; } }); } // #ifdef APP-PLUS
if(res.data.data.user_info_fill == 0){ var app_info = this.$cookieStorage.get('app_user_info'); if(app_info){ this.appUpdateInfo(app_info); } } // #endif
} }); },
jumpAddress() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/address/list/list' }); },
jumpComment() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/order/comment/comment' }); },
jumpCollar() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/user/sign/sign' }); },
jumpBalance() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/recharge/balance/balance' }); },
jumpNews() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/user/news/news' }); },
jumpCan() { wx.navigateTo({ url: '/pages/entity/index/index?shop_id=1' }); },
jumpDetail() { wx.navigateTo({ url: '/pages/entity/detail/detail?id=1447&shop_id=1' }); },
jumpVip() { if (!this.token) { return this.jumpLogin(); }
var svip = this.initInfo.vip_plan_status; var isSvip = this.detail.vip;
if (svip == 1) { if (isSvip) { wx.navigateTo({ url: '/pages/user/svip/svip' }); } else { wx.navigateTo({ url: '/pages/recharge/index/index' }); } } else { wx.navigateTo({ url: '/pages/card/index/index' }); } },
jumpImg() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/user/setting/setting' }); },
jump(e) { if (!this.token) { return this.jumpLogin(); }
var status = e.currentTarget.dataset.status; wx.navigateTo({ url: '/pages/order/index/index?type=' + status }); },
jumpAfterSales() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/afterSales/index/index' }); },
jumpSetting() { if (!this.token) { return this.jumpLogin(); }
wx.navigateTo({ url: '/pages/user/out/out' }); },
bindUserInfo(e) { if (e.detail.encryptedData) { e.detail.code = this.code; this.updateUserInfo(e.detail); } }, //app完善信息
appUpdateInfo(data){ wx.showLoading({ title: '完善信息中', mask: true }); this.$http.post({ api:'api/users/update/info', data:{ nick_name:data.nickName, avatar:data.avatarUrl }, header: { Authorization: this.$cookieStorage.get('user_token') } }).then(res=>{ res = res.data; if(res.status){ this.getUserInfo() } else{ wx.showModal({ content: res.message || '请求失败', showCancel: false }); } wx.hideLoading(); }).catch(rej=>{ wx.showModal({ content: rej.message || '请求失败', showCancel: false }); wx.hideLoading(); }) },
updateUserInfo(data) { wx.showLoading({ title: '完善信息中', mask: true }); this.$http.get({ api: 'api/user/bindUserMiniInfo', data: data, header: { Authorization: this.$cookieStorage.get('user_token') } }).then(res => { res = res.data; if (res.status) { // #ifdef MP-WEIXIN
this.getUserInfo(); // #endif
wx.hideLoading(); } else { wx.showModal({ content: res.message || '请求失败', showCancel: false }); this.getCode(); wx.hideLoading(); } wx.hideLoading(); }).catch(rej=>{ wx.showModal({ content: rej.message || '请求失败', showCancel: false }); wx.hideLoading(); }); },
//获取页面信息
getCenter() { var token = this.$cookieStorage.get('user_token'); this.$http.get({ api: 'api/users/ucenter', header: { Authorization: token } }).then(res => { if (res.data.status) { this.newdetail = res.data.data; } }); },
// 获取广告图
getCenterList() { this.$http.get({ api: 'api/user/center/img_list' }).then(res => { if (res.statusCode == 200) { res = res.data;
if (res.status) { this.img_list = res.data; } } }); },
} };</script><style rel="stylesheet/less" lang="less"> @import "personal.less";</style>
|