Commit 04ad5f0e52e4fe581f0da22573b7efbd96e7b128

Authored by 后端研发-苏泰源
2 parents a6300182 bc2d5c69

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

pages/user/index/index.js
@@ -41,7 +41,9 @@ Page({ @@ -41,7 +41,9 @@ Page({
41 actImg: "", 41 actImg: "",
42 is_assistance: 0, //助力活动 42 is_assistance: 0, //助力活动
43 ad_img:"", 43 ad_img:"",
44 - add_card_data:'', //等级卡的内容 44 + add_card_data:'', //等级卡的内容
  45 +
  46 +
45 }, 47 },
46 goto_nav: function(e) { 48 goto_nav: function(e) {
47 var th = this; 49 var th = this;
@@ -72,6 +74,9 @@ Page({ @@ -72,6 +74,9 @@ Page({
72 }) 74 })
73 app.getUserFir(); 75 app.getUserFir();
74 76
  77 +
  78 +
  79 +
75 //-- 读取会员中心按钮列表 -- 80 //-- 读取会员中心按钮列表 --
76 /*-- 81 /*--
77 getApp().request.get("/api/weshop/userTool/page?pageSize=100&store_id="+os.stoid, { 82 getApp().request.get("/api/weshop/userTool/page?pageSize=100&store_id="+os.stoid, {
@@ -460,6 +465,8 @@ Page({ @@ -460,6 +465,8 @@ Page({
460 465
461 }, 466 },
462 467
  468 +
  469 +
463 //判断会员是后有改服务项目 470 //判断会员是后有改服务项目
464 check_is_has_qy: function(item, g_qy_list) { 471 check_is_has_qy: function(item, g_qy_list) {
465 if (!g_qy_list) return false; 472 if (!g_qy_list) return false;
pages/user/userinfo/userinfo.js
@@ -69,6 +69,10 @@ Page({ @@ -69,6 +69,10 @@ Page({
69 check_label: [], //我选择的兴趣标签 69 check_label: [], //我选择的兴趣标签
70 fir_guide_id:null, //存储会员详情接口出来的美导ID 70 fir_guide_id:null, //存储会员详情接口出来的美导ID
71 71
  72 + userInfo: {},
  73 + hasUserInfo: false,
  74 + canIUseGetUserProfile: false,
  75 +
72 }, 76 },
73 //通过路径跳转到其他页面 77 //通过路径跳转到其他页面
74 goto: function(e) { 78 goto: function(e) {
@@ -615,7 +619,55 @@ Page({ @@ -615,7 +619,55 @@ Page({
615 } 619 }
616 } 620 }
617 this.initial_user(); 621 this.initial_user();
  622 +
  623 + // 获取用户昵称
  624 + if (wx.getUserProfile) {
  625 + this.setData({
  626 + canIUseGetUserProfile: true
  627 + })
  628 + }
  629 +
  630 + },
  631 +
  632 + // 获取用户头像昵称
  633 + getUserProfile(e) {
  634 + var th = this;
  635 + new Promise((resolve, reject) => {
  636 + wx.getUserProfile({
  637 + desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  638 + success: (res) => {
  639 + th.data.user.nickname = res.userInfo.nickName;
  640 + th.data.user.head_pic = res.userInfo.avatarUrl;
  641 + this.setData({
  642 + userInfo: res.userInfo,
  643 + hasUserInfo: true,
  644 + user: th.data.user,
  645 + });
  646 + resolve(res.userInfo);
  647 + },
  648 +
  649 + });
  650 + }).then((userInfo) => {
  651 + getApp().request.put("/api/weshop/users/update", {
  652 + data: {
  653 + storeId: r.stoid,
  654 + user_id: getApp().globalData.user_id,
  655 + nickname: userInfo.nickName,
  656 + head_pic: userInfo.avatarUrl
  657 +
  658 + },
  659 + success: function(su) {
  660 + if (su.data.code == 0) {
  661 + console.log("update user info OK");
  662 + }
  663 + }
  664 + });
  665 + });
  666 +
  667 +
618 }, 668 },
  669 +
  670 +
619 //-----------会员是否初始化--------------------- 671 //-----------会员是否初始化---------------------
620 initial_user: function() { 672 initial_user: function() {
621 673
pages/user/userinfo/userinfo.wxml
@@ -8,11 +8,16 @@ @@ -8,11 +8,16 @@
8 <view class="flex-center"> 8 <view class="flex-center">
9 <image class="Headportrait" src="{{user.head_pic}}"></image> 9 <image class="Headportrait" src="{{user.head_pic}}"></image>
10 </view> 10 </view>
  11 +
11 <view class="flex-center vipmax"> 12 <view class="flex-center vipmax">
12 <view> 13 <view>
  14 +
13 <view> 15 <view>
14 - <view class="ellipsis-2 Nickname" style="font-size: 31rpx">{{user.nickname}} 16 + <view class="ellipsis-2 Nickname" style="font-size: 31rpx">
  17 + <view style="float:left;">{{user.nickname}}</view>
  18 + <button bindtap="getUserProfile" style="margin-left:10rpx;float:left;width: 200rpx;height:50rpx;font-size:20rpx;" class="flex-center fs30 confirmtext"> 点击更新头像昵称 </button>
15 </view> 19 </view>
  20 +
16 </view> 21 </view>
17 22
18 <view class="flex fs22 vip"> 23 <view class="flex fs22 vip">
@@ -33,6 +38,8 @@ @@ -33,6 +38,8 @@
33 </navigator> 38 </navigator>
34 </block> 39 </block>
35 </view> 40 </view>
  41 +
  42 +
36 </view> 43 </view>
37 </view> 44 </view>
38 </view> 45 </view>