gemercheung 2 rokov pred
rodič
commit
ed4c13fbb2

+ 101 - 0
component/auth/auth copy.js

@@ -0,0 +1,101 @@
+// component/auth/auth.js
+const api = require('../../config/api')
+const util = require('../../utils/util.js');
+import {
+  getSubOpen
+} from './api'
+
+Component({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    show: false,
+    canIUse: wx.canIUse('button.open-type.getUserInfo')
+  },
+
+  attached() {
+    this.callback = () => {
+      this.setData({
+        show: !getApp().globalData.loginProps.isLogin
+      })
+
+      let pages = getCurrentPages()
+      let currPage = pages[pages.length - 1].route
+      if (currPage === 'pages/discover/discover') {
+        this.setData({
+          bottom: '50px'
+        })
+      } else {
+        this.setData({
+          bottom: 0
+        })
+      }
+    }
+    this.callback()
+    getApp().addLoginListener(this.callback)
+
+    getSubOpen()
+  },
+  detached() {
+    getApp().removeLoginListener(this.callback)
+  },
+  methods: {
+    quitHandle: function () {
+      getApp().setLoginProps(true)
+    },
+    getCode: function () {
+      return new Promise(r => {
+        wx.login({
+          success: function (res) {
+            console.log(res)
+            if (res.code) {
+              r(res.code)
+            }
+          }
+        });
+      })
+    },
+    authLogin() {
+      this.triggerEvent('login')
+    },
+
+    getUserProfile: async function (e) {
+      // wx.getUserProfile({
+      // desc: '用于完善用户资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+      // success: async (userInfo_res) => {
+      // console.log(userInfo_res.userInfo)
+      let info = {
+        userInfo: {
+
+        }
+      }
+      let code = await this.getCode()
+
+      //登录远程服务器
+      util.request(api.AuthLoginByWeixin, {
+        code: code,
+        userInfo: info
+      }, 'POST', 'application/json').then(res => {
+        if (res.errno === 0) {
+          console.log('&&&&&&&')
+          console.log('login-Info', res.data)
+          //存储用户信息
+          res.data.userInfo.userId = res.data.userId
+          res.data.userInfo.sessionKey = res.data.sessionKey
+  
+          console.log('-------', res.data.userInfo)
+          wx.setStorageSync('userInfo', res.data.userInfo);
+          wx.setStorageSync('token', res.data.token);
+          wx.setStorageSync('userId', res.data.userId);
+          wx.setStorageSync('isLogin', true);
+          getApp().setLoginProps(true)
+          this.authLogin()
+          getSubOpen()
+
+        }
+      });
+    }
+  }
+})

+ 15 - 52
component/auth/auth.js

@@ -60,21 +60,31 @@ Component({
     authLogin() {
       this.triggerEvent('login')
     },
-    bindGetUserInfo: async function (e) {
+
+    getUserProfile: async function (e) {
+      // wx.getUserProfile({
+      // desc: '用于完善用户资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
+      // success: async (userInfo_res) => {
+      // console.log(userInfo_res.userInfo)
+      let info = {
+        userInfo: {
+
+        }
+      }
       let code = await this.getCode()
-      console.log('******')
-      console.log(e.detail)
+
       //登录远程服务器
       util.request(api.AuthLoginByWeixin, {
         code: code,
-        userInfo: e.detail
+        userInfo: info
       }, 'POST', 'application/json').then(res => {
         if (res.errno === 0) {
           console.log('&&&&&&&')
-          console.log(res.data)
+          console.log('login-Info', res.data)
           //存储用户信息
           res.data.userInfo.userId = res.data.userId
           res.data.userInfo.sessionKey = res.data.sessionKey
+  
           console.log('-------', res.data.userInfo)
           wx.setStorageSync('userInfo', res.data.userInfo);
           wx.setStorageSync('token', res.data.token);
@@ -84,55 +94,8 @@ Component({
           this.authLogin()
           getSubOpen()
 
-        } else {
-          // util.showErrorToast(res.errmsg)
-          // wx.showModal({
-          //   title: '提示',
-          //   content: res.errmsg,
-          //   showCancel: false
-          // });
         }
       });
-    },
-    getUserProfile: function (e) {
-      wx.getUserProfile({
-        desc: '用于完善用户资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
-        success: async  (userInfo_res) => {
-          console.log(userInfo_res.userInfo)
-          let info = {userInfo:userInfo_res.userInfo}
-          let code = await this.getCode()
-
-          //登录远程服务器
-          util.request(api.AuthLoginByWeixin, {
-            code: code,
-            userInfo: info
-          }, 'POST', 'application/json').then(res => {
-            if (res.errno === 0) {
-              console.log('&&&&&&&')
-              console.log(res.data)
-              //存储用户信息
-              res.data.userInfo.userId = res.data.userId
-              res.data.userInfo.sessionKey = res.data.sessionKey
-              console.log('-------', res.data.userInfo)
-              wx.setStorageSync('userInfo', res.data.userInfo);
-              wx.setStorageSync('token', res.data.token);
-              wx.setStorageSync('userId', res.data.userId);
-              wx.setStorageSync('isLogin', true);
-              getApp().setLoginProps(true)
-              this.authLogin()
-              getSubOpen()
-
-            } else {
-              // util.showErrorToast(res.errmsg)
-              // wx.showModal({
-              //   title: '提示',
-              //   content: res.errmsg,
-              //   showCancel: false
-              // });
-            }
-          });
-        }
-      })
     }
   }
 })

+ 1 - 1
component/auth/auth.wxml

@@ -15,7 +15,7 @@
         </cover-view>
       </cover-view>
 
-      <button class="button" bindtap="getUserProfile">允许使用</button>
+      <button class="button" bindtap="getUserProfile">允许使用1111</button>
       <!-- <button class="button" wx:if="{{canIUse}}" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo">允许使用</button> -->
     </cover-view>
 </view>

+ 55 - 55
pages/brand/brand.js

@@ -1,56 +1,56 @@
-var util = require('../../utils/util.js');
-var api = require('../../config/api.js');
-var app = getApp();
-Page({
-  data: {
-    brandList: [],
-    page: 1,
-    size: 10,
-    totalPages: 1
-  },
-  onLoad: function (options) {
-    // 页面初始化 options为页面跳转所带来的参数
-    this.getBrandList();
-  },
-  getBrandList: function () {
-    wx.showLoading({
-      title: '加载中...',
-    });
-    let that = this;
-    util.request(api.BrandList, { page: that.data.page, size: that.data.size }).then(function (res) {
-      if (res.errno === 0) {
-        that.setData({
-          brandList: that.data.brandList.concat(res.data.data),
-          totalPages: res.data.totalPages
-        });
-      }
-      wx.hideLoading();
-    });
-  },
-  onReachBottom (){
-    if (this.data.totalPages > this.data.page) {
-      this.setData({
-        page: this.data.page + 1
-      });
-    } else {
-      return false;
-    }
-
-    this.getBrandList();
-  },
-  onReady: function () {
-
-  },
-  onShow: function () {
-    // 页面显示
-
-  },
-  onHide: function () {
-    // 页面隐藏
-
-  },
-  onUnload: function () {
-    // 页面关闭
-
-  }
+var util = require('../../utils/util.js');
+var api = require('../../config/api.js');
+var app = getApp();
+Page({
+  data: {
+    brandList: [],
+    page: 1,
+    size: 10,
+    totalPages: 1
+  },
+  onLoad: function (options) {
+    // 页面初始化 options为页面跳转所带来的参数
+    this.getBrandList();
+  },
+  getBrandList: function () {
+    wx.showLoading({
+      title: '加载中...',
+    });
+    let that = this;
+    util.request(api.BrandList, { page: that.data.page, size: that.data.size }).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          brandList: that.data.brandList.concat(res.data.data),
+          totalPages: res.data.totalPages
+        });
+      }
+      wx.hideLoading();
+    });
+  },
+  onReachBottom (){
+    if (this.data.totalPages > this.data.page) {
+      this.setData({
+        page: this.data.page + 1
+      });
+    } else {
+      return false;
+    }
+
+    this.getBrandList();
+  },
+  onReady: function () {
+
+  },
+  onShow: function () {
+    // 页面显示
+
+  },
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+
+  }
 })

+ 284 - 276
pages/ucenter/index/index.js

@@ -5,108 +5,105 @@ var app = getApp();
 // 定义插件变量 引入方法
 
 const tempUserInfo = {
-  nickName: 'Hi,游客',
+  nickname: 'Hi,游客',
   userName: '点击去登录',
   avatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
 }
 
 Page({
-    data: {
-        userInfo: {},
-        hasMobile: '',
-        imgServer: util.imgServer,
-        all: {
-          icon: 'ct1',
+  data: {
+    userInfo: {},
+    hasMobile: '',
+    imgServer: util.imgServer,
+    all: {
+      icon: 'ct1',
 
-          name: '全部订单',
-          id: -1
-        },
-        orderList:[
-          {
-            icon: 'ct2',
-            name: '待付款',
-            id: 0
-          },
-          {
-            icon: 'ct3',
-            name: '待发货',
-            id: 201
-          },
-          {
-            icon: 'ct4',
-            name: '待收货',
-            id: 300
-          },
-          {
-            icon: 'ct5',
-            name: '已完成',
-            id: 301
-          }
-        ],
-        barList:[
-          {
-            icon: 'cb1',
-            url: '/pages/ucenter/collect/collect',
-            name: '我的收藏',
-            id: 0
-          },
-          {
-            icon: 'cb5',
-            url: '/pages/coupon/coupon',
-            name: '优惠券',
-            id: 5
-          },
-          // {
-          //   icon: 'cb6',
-          //   url: '/pages/ucenter/footprint/footprint',
-          //   name: '我的积分',
-          //   id: 1
-          // },
-          {
-            icon: 'cb2',
-            url: '/pages/ucenter/address/address',
-            name: '地址管理',
-            id: 1
-          }
-        ],
-        senceList:[
-          {
-            icon: 'vr@2x',
-            url: '/pages/sence/sence',
-            name: '场景列表',
-            type: 31
-          },
-          {
-            icon: 'vr_live@2x',
-            url: '/pages/sence/sence',
-            name: '带看',
-            type: 32
-          },
-          {
-            icon: 'vr_live@2x',
-            url: '/pages/roomManger/roomManger',
-            name: '我的房间',
-            type: 33
-          }
-        ],
-        relatedGoods: [],
-        isLogin: app.globalData.isLogin
-
-    },
-    getGoodsRelated: function () {
-      let that = this;
-      util.request(api.GoodsRelated, {}).then(function (res) {
-        if (res.errno === 0) {
-          that.setData({
-            relatedGoods: res.data.goodsList,
-          });
-        }
-      });
+      name: '全部订单',
+      id: -1
     },
+    orderList: [{
+        icon: 'ct2',
+        name: '待付款',
+        id: 0
+      },
+      {
+        icon: 'ct3',
+        name: '待发货',
+        id: 201
+      },
+      {
+        icon: 'ct4',
+        name: '待收货',
+        id: 300
+      },
+      {
+        icon: 'ct5',
+        name: '已完成',
+        id: 301
+      }
+    ],
+    barList: [{
+        icon: 'cb1',
+        url: '/pages/ucenter/collect/collect',
+        name: '我的收藏',
+        id: 0
+      },
+      {
+        icon: 'cb5',
+        url: '/pages/coupon/coupon',
+        name: '优惠券',
+        id: 5
+      },
+      // {
+      //   icon: 'cb6',
+      //   url: '/pages/ucenter/footprint/footprint',
+      //   name: '我的积分',
+      //   id: 1
+      // },
+      {
+        icon: 'cb2',
+        url: '/pages/ucenter/address/address',
+        name: '地址管理',
+        id: 1
+      }
+    ],
+    senceList: [{
+        icon: 'vr@2x',
+        url: '/pages/sence/sence',
+        name: '场景列表',
+        type: 31
+      },
+      {
+        icon: 'vr_live@2x',
+        url: '/pages/sence/sence',
+        name: '带看',
+        type: 32
+      },
+      {
+        icon: 'vr_live@2x',
+        url: '/pages/roomManger/roomManger',
+        name: '我的房间',
+        type: 33
+      }
+    ],
+    relatedGoods: [],
+    isLogin: app.globalData.isLogin
+
+  },
+  getGoodsRelated: function () {
+    let that = this;
+    util.request(api.GoodsRelated, {}).then(function (res) {
+      if (res.errno === 0) {
+        that.setData({
+          relatedGoods: res.data.goodsList,
+        });
+      }
+    });
+  },
 
-  
 
-  tapByIdx:function(e){
+
+  tapByIdx: function (e) {
     let {
       type
     } = e.currentTarget.dataset;
@@ -114,15 +111,15 @@ Page({
       url
     } = e.currentTarget.dataset;
 
-    console.log(url+'?type='+type)
+    console.log(url + '?type=' + type)
 
     // if (this.data.isLogin) {
-      wx.navigateTo({
-        url: url+'?type='+type,
-        success: function (res) { },
-        fail: function (res) { },
-        complete: function (res) { },
-      })
+    wx.navigateTo({
+      url: url + '?type=' + type,
+      success: function (res) {},
+      fail: function (res) {},
+      complete: function (res) {},
+    })
     // } else {
 
     //   wx.navigateTo({
@@ -141,195 +138,206 @@ Page({
 
   },
   onLoad: function (options) {
-      getApp().checkNetStatu();
-      // 页面初始化 options为页面跳转所带来的参数
-      // this.getGoodsRelated()
-      
-      // wx.setNavigationBarColor({
-      //   frontColor:'#ffffff',
-      //   backgroundColor:'#fb6400',
-      //   "navigationStyle":"custom"
-      //   animation: {
-      //     duration: 400,
-      //     timingFunc:'easeIn'
-      //   }
-      // })
-    },
-    onReady: function () {
+    getApp().checkNetStatu();
+    // 页面初始化 options为页面跳转所带来的参数
+    // this.getGoodsRelated()
 
-    },
-    async getCounts() {
-      let { data } = await util.request(api.OrderCount)
-      let orderList = this.data.orderList.map(item => {
-        let ci = data.find(({code}) => code === item.id)
-        if (ci) {
-          item.count = ci.num > 99 ? '..' : ci.num
-        }
-        return { ...item }
-      })
+    // wx.setNavigationBarColor({
+    //   frontColor:'#ffffff',
+    //   backgroundColor:'#fb6400',
+    //   "navigationStyle":"custom"
+    //   animation: {
+    //     duration: 400,
+    //     timingFunc:'easeIn'
+    //   }
+    // })
+  },
+  onReady: function () {
 
-      this.setData({ orderList })
-    },
-    async getUserInfo() {
-      const {data} = await util.request(api.UserInfo)
-      console.log('UserInfo',data)
-      wx.setStorageSync('userinfoDetail', data)
-      this.setData({
-        userInfo: {
-          nickName: data.nickname,
-          avatarUrl: data.avatar,
-        }
-      })
-    },
-    async getBrandList () {
-      let res = await util.request(api.GetAdminBrands)
-      let list = res.data
-      if (list && list.length>0) {
-        this.setData({
-          hasBrand: true
-        })
-      } else {
-        this.setData({
-          hasBrand: false
-        })
+  },
+  async getCounts() {
+    let {
+      data
+    } = await util.request(api.OrderCount)
+    let orderList = this.data.orderList.map(item => {
+      let ci = data.find(({
+        code
+      }) => code === item.id)
+      if (ci) {
+        item.count = ci.num > 99 ? '..' : ci.num
       }
-    },
-    onShow: function () {
-      getApp().updateCardCount()
-      let userInfo = wx.getStorageSync('userInfo');
-      let token = wx.getStorageSync('token');
-      this.getBrandList()
-      this.getUserInfo()
-      this.getCounts()
-      // 页面显示
-      if (userInfo && token) {
-          app.globalData.userInfo = userInfo;
-          app.globalData.token = token;
+      return {
+        ...item
       }
+    })
 
+    this.setData({
+      orderList
+    })
+  },
+  async getUserInfo() {
+    const {
+      data
+    } = await util.request(api.UserInfo)
+    console.log('UserInfo', data)
+    wx.setStorageSync('userinfoDetail', data)
+    this.setData({
+      userInfo: {
+        // nickName: data.nickname || tempUserInfo.nickName,
+        nickname: data.nickname ? data.nickname : (data.username || tempUserInfo.nickname),
+        avatarUrl: data.avatar || tempUserInfo.avatarUrl,
+      }
+    })
+  },
+  async getBrandList() {
+    let res = await util.request(api.GetAdminBrands)
+    let list = res.data
+    if (list && list.length > 0) {
       this.setData({
-        // userInfo: app.globalData.userInfo,
-        token: app.globalData.token
-      });
+        hasBrand: true
+      })
+    } else {
+      this.setData({
+        hasBrand: false
+      })
+    }
+  },
+  onShow: function () {
+    getApp().updateCardCount()
+    let userInfo = wx.getStorageSync('userInfo');
+    let token = wx.getStorageSync('token');
+    // this.getBrandList()
+    this.getUserInfo()
+    this.getCounts()
+    // 页面显示
+    if (userInfo && token) {
+      app.globalData.userInfo = userInfo;
+      app.globalData.token = token;
+    }
 
-      util.request(api.CartList).then((res) => {
-        let isLogin = false
-        if (res.errno === 401) {
-          isLogin = false
-          app.globalData.userInfo = tempUserInfo;
-          app.globalData.token = '';
-        } else {
-          isLogin = true
-          app.globalData.userInfo = userInfo;
-          app.globalData.token = token;
-        }
-        if (!isLogin){
-          this.setData({
-            token:'',
-            userInfo: tempUserInfo
-          });
-        }
+    this.setData({
+      // userInfo: app.globalData.userInfo,
+      token: app.globalData.token
+    });
+
+    util.request(api.CartList).then((res) => {
+      let isLogin = false
+      if (res.errno === 401) {
+        isLogin = false
+        app.globalData.userInfo = tempUserInfo;
+        app.globalData.token = '';
+      } else {
+        isLogin = true
+        app.globalData.userInfo = userInfo;
+        app.globalData.token = token;
+      }
+      if (!isLogin) {
         this.setData({
-          isLogin
+          token: '',
+          userInfo: tempUserInfo
         });
+      }
+      this.setData({
+        isLogin
       });
+    });
 
-      if (typeof this.getTabBar === 'function' && this.getTabBar()) {
-        this.getTabBar().setData({
-          selected: 3
-        })
-      }
+    if (typeof this.getTabBar === 'function' && this.getTabBar()) {
+      this.getTabBar().setData({
+        selected: 3
+      })
+    }
 
-    },
-    onPullDownRefresh() {
- 
-      getApp().onPullDownRefresh()
-    },
- 
-    onHide: function () {
-        // 页面隐藏
+  },
+  onPullDownRefresh() {
 
-    },
-    onUnload: function () {
-        // 页面关闭
-    },
-    bindGetUserInfo(e) {
-      let userInfo = wx.getStorageSync('userInfo');
-      let token = wx.getStorageSync('token');
-      if (userInfo && token) {
-        return;
-      }
-        if (e.detail.userInfo){
-            //用户按了允许授权按钮
-            user.loginByWeixin(e.detail).then(res => {
-                this.setData({
-                    userInfo: res.data.userInfo,
-                    isLogin: true
-                });
-                res.data.userInfo.userId = res.data.userId
-                res.data.userInfo.isAdmin = res.data.isAdmin
-                wx.setStorageSync('userInfo', res.data.userInfo);
-                wx.setStorageSync('token', res.data.token);
-                wx.setStorageSync('userId', res.data.userId);
-                app.globalData.userInfo = res.data.userInfo;
-                app.globalData.token = res.data.token;
-            }).catch((err) => {
-              this.setData({
-                token: '',
-                userInfo: tempUserInfo
-              });
-              app.globalData.userInfo = tempUserInfo;
-              app.globalData.token = '';
-              console.log(err)
-            });
-        } else {
-            //用户按了拒绝按钮
-            // wx.showModal({
-            //     title: '温馨提示',
-            //     content: '您点击了"取消"授权,将无法获取杭州天门科技有限公司完整服务。请“授权”以保证各项功能正常使用。',
-            //     confirmText:'授权',
-            //     success: function (res) {
-            //         if (res.confirm) {
-            //             wx.openSetting({
-            //                 success: (res) => {
-            //                     if (res.authSetting["scope.userInfo"]) {////如果用户重新同意了授权登录
-            //                         user.loginByWeixin(e.detail).then(res => {
-            //                             this.setData({
-            //                                 userInfo: res.data.userInfo
-            //                             });
-            //                             app.globalData.userInfo = res.data.userInfo;
-            //                             app.globalData.token = res.data.token;
-            //                         }).catch((err) => {
-            //                             console.log(err)
-            //                         });
-            //                     }
-            //                 }
-            //             })
-            //         }
-            //     }
-            // });
-        }
-    },
-    exitLogin: function () {
-        wx.showModal({
-            title: '',
-            confirmColor: '#b4282d',
-            content: '退出登录?',
-            success: function (res) {
-                if (res.confirm) {
-                    wx.removeStorageSync('token');
-                    wx.removeStorageSync('userInfo');
-                    wx.switchTab({
-                        url: '/pages/index/index'
-                    });
-                }
-            }
-        })
+    getApp().onPullDownRefresh()
+  },
 
-    },
-    toReport () {
-      wx.navigateTo({
-        url: '/dataReport/pages/data-report/data-report',
-      })
+  onHide: function () {
+    // 页面隐藏
+
+  },
+  onUnload: function () {
+    // 页面关闭
+  },
+  bindGetUserInfo(e) {
+    let userInfo = wx.getStorageSync('userInfo');
+    let token = wx.getStorageSync('token');
+    if (userInfo && token) {
+      return;
     }
+    if (e.detail.userInfo) {
+      //用户按了允许授权按钮
+      user.loginByWeixin(e.detail).then(res => {
+        this.setData({
+          userInfo: res.data.userInfo,
+          isLogin: true
+        });
+        res.data.userInfo.userId = res.data.userId
+        res.data.userInfo.isAdmin = res.data.isAdmin
+        wx.setStorageSync('userInfo', res.data.userInfo);
+        wx.setStorageSync('token', res.data.token);
+        wx.setStorageSync('userId', res.data.userId);
+        app.globalData.userInfo = res.data.userInfo;
+        app.globalData.token = res.data.token;
+      }).catch((err) => {
+        this.setData({
+          token: '',
+          userInfo: tempUserInfo
+        });
+        app.globalData.userInfo = tempUserInfo;
+        app.globalData.token = '';
+        console.log(err)
+      });
+    } else {
+      //用户按了拒绝按钮
+      // wx.showModal({
+      //     title: '温馨提示',
+      //     content: '您点击了"取消"授权,将无法获取杭州天门科技有限公司完整服务。请“授权”以保证各项功能正常使用。',
+      //     confirmText:'授权',
+      //     success: function (res) {
+      //         if (res.confirm) {
+      //             wx.openSetting({
+      //                 success: (res) => {
+      //                     if (res.authSetting["scope.userInfo"]) {////如果用户重新同意了授权登录
+      //                         user.loginByWeixin(e.detail).then(res => {
+      //                             this.setData({
+      //                                 userInfo: res.data.userInfo
+      //                             });
+      //                             app.globalData.userInfo = res.data.userInfo;
+      //                             app.globalData.token = res.data.token;
+      //                         }).catch((err) => {
+      //                             console.log(err)
+      //                         });
+      //                     }
+      //                 }
+      //             })
+      //         }
+      //     }
+      // });
+    }
+  },
+  exitLogin: function () {
+    wx.showModal({
+      title: '',
+      confirmColor: '#b4282d',
+      content: '退出登录?',
+      success: function (res) {
+        if (res.confirm) {
+          wx.removeStorageSync('token');
+          wx.removeStorageSync('userInfo');
+          wx.switchTab({
+            url: '/pages/index/index'
+          });
+        }
+      }
+    })
+
+  },
+  toReport() {
+    wx.navigateTo({
+      url: '/dataReport/pages/data-report/data-report',
+    })
+  }
 })

+ 2 - 2
pages/ucenter/index/index.wxml

@@ -7,8 +7,8 @@
     <view class="u-avatar" bindtap="tapByIdx" data-url="/pages/user/user">
       <!-- <button class="btn-cls" open-type="getUserInfo" bindgetuserinfo="bindGetUserInfo"></button> -->
       <image class="userinfo-avatar" src="{{ userInfo.avatarUrl }}" background-size="cover"></image>
-      <text class="userinfo-nickname" wx:if="{{userInfo.nickName==''}}">【请输入昵称】</text>
-      <text class="userinfo-nickname" wx:else>{{userInfo.nickName}}</text>
+      <text class="userinfo-nickname" wx:if="{{userInfo.nickname==''}}">【请输入昵称】</text>
+      <text class="userinfo-nickname" wx:else>{{userInfo.nickname}}</text>
     </view>
     <view class="userinfo-setting navigator" bindtap="tapByIdx" data-url="/pages/user/user">
       <image wx:if="{{imgServer}}" src="../../../static/images/c_setting.png"></image>

+ 34 - 20
pages/user/user.js

@@ -13,7 +13,9 @@ Page({
     region: [],
     customItem: '全部',
     gender: 0,
-    mobile: null
+    mobile: null,
+    nickname: '',
+    defaultAvatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
   },
 
   updateNickName(ev) {
@@ -52,6 +54,7 @@ Page({
     } = await util.request(api.UserInfo)
     data.region = data.city ? data.city.split(',') : []
     data.birthday = data.birthday || '1990-01-01'
+    data.nickname = data.nickname ? data.nickname : data.username
     this.setData({
       ...data
     })
@@ -115,37 +118,25 @@ Page({
   },
   async save(e) {
     let type = e.currentTarget.dataset.type
+
     console.log(e)
-    if (this.data.nickname == '') {
+    const {
+      nickname
+    } = this.data;
+
+    if (!nickname || nickname == '') {
       wx.showToast({
         title: '请输入昵称',
         icon: 'error'
       })
       return
     }
-    if (this.file) {
-      let avatar = await (new Promise(r => {
-        wx.uploadFile({
-          filePath: this.data.avatar,
-          name: 'file',
-          url: api.UploadFile,
-          header: {
-            'X-Nideshop-Token': wx.getStorageSync('token')
-          },
-          success: (res) => {
-            this.file = null
-            r(JSON.parse(res.data).data)
-          }
-        })
-      }));
-
-      this.data.avatar = avatar
-    }
 
     this.data.city = this.data.region && this.data.region.join(',')
     const body = {
       ...this.data
     }
+
     delete body.region
     const {
       data
@@ -158,6 +149,29 @@ Page({
 
     }
   },
+  async onChooseAvatar(e) {
+    const {
+      avatarUrl
+    } = e.detail
+    const dataURL = await (new Promise(r => {
+      wx.uploadFile({
+        filePath: avatarUrl,
+        name: 'file',
+        url: api.UploadFile,
+        header: {
+          'X-Nideshop-Token': wx.getStorageSync('token')
+        },
+        success: (res) => {
+          const data = JSON.parse(res.data)
+          r(data.message || defaultAvatarUrl)
+        }
+      })
+    }));
+    console.log('upload-file', dataURL)
+    this.setData({
+      avatar: dataURL,
+    })
+  },
   /**
    * 生命周期函数--监听页面初次渲染完成
    */

+ 18 - 14
pages/user/user.wxml

@@ -1,9 +1,13 @@
 <view>
-	<auth bindlogin="loginSuccess" />
+  <auth bindlogin="loginSuccess" />
   <view class="photo">
-    <view class="userinfo-avatar" bindtap="selectPhoto" style="background-image: url({{avatar}})">
-    </view>
-    <!-- <text class="userinfo-nickname">点击修改头像</text> -->
+
+    <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
+      <view class="userinfo-avatar" style="background-image: url({{( avatar || defaultAvatarUrl )}})">
+        <text class="userinfo-nickname">点击修改头像</text>
+      </view>
+    </button>
+
     <!-- {{userInfo.nickName}} -->
   </view>
 
@@ -11,17 +15,17 @@
     <view class="item">
       <text>用户昵称</text>
       <view class="ir">
-        <input placeholder="请输入昵称" maxlength="15" value="{{nickname}}" class="ipname" bindinput="updateNickName"></input>
+        <input type="nickname" placeholder="请输入昵称" maxlength="15" value="{{nickname}}" class="ipname" bindinput="updateNickName"></input>
       </view>
     </view>
     <view class="item">
       <text>手机号</text>
       <view class="ir">
-        <input disabled="{{true}}"  bindblur="save" data-type="2" bindinput="changPhone" value="{{mobile}}" class="ipname"  wx:if="{{mobile}}"></input>
-        <button style="background:transparent;padding:0;" wx:if="{{!mobile}}"  open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" >  
+        <input disabled="{{true}}" bindblur="save" data-type="2" bindinput="changPhone" value="{{mobile}}" class="ipname" wx:if="{{mobile}}"></input>
+        <button style="background:transparent;padding:0;" wx:if="{{!mobile}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber">
           <!-- <input disabled="{{true}}" data-type="2" bindinput="changPhone" value="{{mobile}}" class="ipname"  ></input> -->
         </button>
-    
+
 
         <button wx:if="{{!mobile}}" open-type="getPhoneNumber" bindgetphonenumber="getPhoneNumber" class="getPhone">点击获取手机号</button>
       </view>
@@ -30,16 +34,16 @@
       <text>性别</text>
       <view class="ir radio">
         <view class="checkbox" bindtap="updateSex" data-sex="{{1}}">
-          <image src="{{gender === 1 ?  '/static/images/icon-normal_checkbox-checked.png' :'/static/images/icon-normal_checkbox.png' }}" ></image>
+          <image src="{{gender === 1 ?  '/static/images/icon-normal_checkbox-checked.png' :'/static/images/icon-normal_checkbox.png' }}"></image>
         </view>
         <view class="checkbox" bindtap="updateSex" data-sex="{{0}}">
-          <image src="{{gender === 0 ?  '/static/images/icon-normal_checkbox-checked.png' :'/static/images/icon-normal_checkbox.png' }}" ></image>
+          <image src="{{gender === 0 ?  '/static/images/icon-normal_checkbox-checked.png' :'/static/images/icon-normal_checkbox.png' }}"></image>
         </view>
       </view>
     </view>
-    
+
     <view class="item">
       <text>生日</text>
       <view class="ir">
@@ -56,10 +60,10 @@
     <view class="item">
       <text>城市</text>
       <view class="ir">
-        <picker bindchange="bindRegionChange" mode="region" value="{{region}}" >
+        <picker bindchange="bindRegionChange" mode="region" value="{{region}}">
           <view class="picker-date">
             <block wx:if="{{region.length}}">
-              {{region[0]}},{{region[1]}},{{region[2]}}  
+              {{region[0]}},{{region[1]}},{{region[2]}}
             </block>
             <image src="/static/images/go.png"></image>
           </view>
@@ -69,6 +73,6 @@
   </view>
 
   <view class="save">
-    <button bindtap="save" data-type="1" >保存</button>
+    <button bindtap="save" data-type="1">保存</button>
   </view>
 </view>

+ 18 - 7
pages/user/user.wxss

@@ -12,20 +12,27 @@ page {
 .userinfo-avatar {
   width: 80px;
   height: 80px;
-  border: 1px solid rgba(0,0,0,0.1);
+  border: 1px solid rgba(0, 0, 0, 0.1);
   border-radius: 50%;
   overflow: hidden;
   margin: 0 auto;
   background-size: 80px 80px;
+  overflow: hidden;
+  position: relative;
 }
 
 
 .userinfo-nickname {
   text-align: center;
   display: block;
-  font-size: 22rpx;
-  color: rgba(19, 29, 52, 1);
+  font-size: 18rpx;
+  color: white;
+  background-color: rgba(0, 0, 0, 0.32);
   margin-top: 14rpx;
+  position: absolute;
+  bottom: 0px;
+  width: 100%;
+  left: 0;
 }
 
 .info {
@@ -35,7 +42,7 @@ page {
 }
 
 .info .item {
-  border-bottom: 1px solid rgba(0,0,0,0.1);
+  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
   padding: 28rpx 0;
   display: flex;
   align-items: center;
@@ -45,7 +52,7 @@ page {
   border-bottom: none;
 }
 
-.info .item > text {
+.info .item>text {
   font-size: 30rpx;
   flex: 0 0 auto;
   color: #131D34;
@@ -53,7 +60,7 @@ page {
   margin-right: 10px;
 }
 
-.info .item > .ir {
+.info .item>.ir {
   flex: 1;
 }
 
@@ -65,7 +72,7 @@ page {
 }
 
 
-.checkbox{
+.checkbox {
   padding-left: 80rpx;
   font-size: 26rpx;
   color: #131D34;
@@ -124,4 +131,8 @@ page {
   font-size: 26rpx;
   color: #131D34;
   text-align: right;
+}
+
+.avatar-wrapper {
+  background-color: white;
 }

+ 20 - 1
pages/webview/index.js

@@ -27,6 +27,8 @@ Page({
     roomMaximum: false,
     roomDisMiss: false,
     unKnowError: false, // 未知错误重进
+    isNotPersonalfullpack: false,
+    defaultAvatarUrl: 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
     // url: 'https://www.4dkankan.com/showProPC.html?m=vroMUXdx&origin=4Dplaza&sid=1046051&room_id=1596785144930&user_id=44'
   },
 
@@ -49,7 +51,7 @@ Page({
       this.options.roomId = options.roomId || arr[3]
       this.options.many = "true"
       this.options.inviterId = options.inviterId || arr[5]
-    
+
     }
     // debugger
     console.log(this.options)
@@ -335,5 +337,22 @@ Page({
    */
   onReachBottom: function () {
 
+  },
+  tapInput() {
+    this.setData({
+      //在真机上将焦点给input
+      inputFocus: true,
+      //初始占位清空
+      inputInfo: ''
+    });
+  },
+
+  /**
+   * input 失去焦点后将 input 的输入内容给到cover-view
+   */
+  blurInput(e) {
+    this.setData({
+      inputInfo: e.detail.value || '输入'
+    });
   }
 })

+ 20 - 1
pages/webview/index.wxml

@@ -198,7 +198,7 @@
       </cover-view>
     </cover-view>
 
-    
+
     <cover-view class="dialog invitation-view single-btn" wx:if="{{roomMaximum}}">
       <cover-view class="title">温馨提示</cover-view>
       <cover-view class="content">房间已满员,暂时无法进入</cover-view>
@@ -278,6 +278,25 @@
       </cover-view>
     </cover-view>
 
+    <cover-view class="dialog invitation-view full-fill-view" wx:if="{{false}}">
+      <cover-view class="title">填入个人信息</cover-view>
+      <cover-view class="content">
+
+        <button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
+          <cover-view class="userinfo-avatar" style="background-image: url({{defaultAvatarUrl}})">
+          </cover-view>
+        </button>
+        <cover-view class='cover-input' bindtap='tapInput'>
+          <cover-view class='text'>{{inputInfo}}</cover-view>
+          <input type="nickname" class='input' value='{{inputModel}}' focus='{{inputFocus}}' bindblur='blurInput'></input>
+        </cover-view>
+      </cover-view>
+
+      <cover-view class="btns">
+        <button class="btn" bindtap="updateUserInfo">确定</button>
+      </cover-view>
+    </cover-view>
+
     <!-- <cover-view style="position: fixed;  font-size:10px; background-color: rgba(0,0,0,0.5); color: #fff;white-space:pre-wrap;z-index:989999" wx:if="{{debugerInfo}}">
       {{debugerInfo}}
       <cover-view bindtap="clearDebuger">清除</cover-view>

+ 42 - 1
pages/webview/index.wxss

@@ -337,6 +337,7 @@
   text-align: center;
   height: 110rpx;
 }
+
 .cancel {
   line-height: 86rpx;
   margin-top: 20rpx;
@@ -801,7 +802,47 @@
   width: 76rpx;
   color: #000;
 }
-.roomMaximumBgd{
+
+.roomMaximumBgd {
   background: rgba(0, 0, 0, 0.3);
   z-index: 10;
+}
+
+.full-fill-view .cover-input {
+  height: 32px;
+  width: 90%;
+  line-height: 32px;
+  border-radius: 5px;
+  background-color: rgba(255, 255, 255, 0.9);
+  margin: 0 auto;
+  padding-left: 15rpx;
+  padding-right: 15rpx;
+}
+
+.full-fill-view .cover-input .text {
+  height: 32px;
+  line-height: 32px;
+}
+
+.full-fill-view .cover-input .input {
+  height: 32px;
+  line-height: 32px;
+  /* margin-top为text的高度,保持视觉上一致 */
+  margin-top: -32px;
+}
+
+.avatar-wrapper {
+  background-color: none !important;
+}
+
+.userinfo-avatar {
+  width: 80px;
+  height: 80px;
+  border: 1px solid rgba(0, 0, 0, 0.1);
+  border-radius: 50%;
+  overflow: hidden;
+  margin: 0 auto;
+  background-size: 80px 80px;
+  overflow: hidden;
+  position: relative;
 }

+ 2 - 1
project.private.config.json

@@ -206,5 +206,6 @@
   "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
   "setting": {
     "compileHotReLoad": false
-  }
+  },
+  "libVersion": "2.25.4"
 }

+ 12 - 4
socket.js

@@ -269,6 +269,14 @@ export default {
       const data = res.data
       data.region = data.city ? data.city.split(',') : []
       data.birthday = data.birthday || '1990-01-01'
+      if (!data.nickname) {
+        this.setData({
+          isNotPersonalfullpack: true
+        })
+      }
+      data.nickname = data.nickname ? data.nickname : data.username
+      data.avatar = data.avatar ? data.avatar : 'https://platform-wxmall.oss-cn-beijing.aliyuncs.com/upload/20180727/150547696d798c.png'
+
       return data
     }
   },
@@ -470,9 +478,9 @@ export default {
     // 真正进入统计
 
     if (this.data.inviterId) {
-      wx.showToast({
-        title: '邀请人ID:' + this.data.inviterId,
-      })
+      // wx.showToast({
+      //   title: '邀请人ID:' + this.data.inviterId,
+      // })
     }
 
     if (options.roomId !== '888888') {
@@ -555,7 +563,7 @@ export default {
 
     this.socketSendMessage = (event, obj) => {
       console.error('发送 socket Room', options.roomId, event, obj)
-      socket.emit(event, obj)
+      socket && socket.emit(event, obj)
     }
 
     socket.on('clientSyncAction', (data) => {