jinx 3 éve
szülő
commit
56ca78b3fd
3 módosított fájl, 95 hozzáadás és 63 törlés
  1. 46 45
      pages/ucenter/index/index.wxml
  2. 48 17
      pages/user/user.js
  3. 1 1
      pages/user/user.wxml

+ 46 - 45
pages/ucenter/index/index.wxml

@@ -1,68 +1,69 @@
 <view class="container">
   <auth bindlogin="onShow" />
-	
+
   <!-- <lip-sync /> -->
   <view class="userinfo">
     <image src="../../../static/images/ucenterbg.png" class="user-bg"></image>
-    <view class="u-avatar"  bindtap="tapByIdx" data-url="/pages/user/user">
+    <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">{{userInfo.nickName}}</text>
+      <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>
     </view>
-    <view class="userinfo-setting navigator"  bindtap="tapByIdx" data-url="/pages/user/user">
+    <view class="userinfo-setting navigator" bindtap="tapByIdx" data-url="/pages/user/user">
       <image wx:if="{{imgServer}}" src="../../../static/images/c_setting.png"></image>
     </view>
-	</view>
+  </view>
+
 
-  
   <view class="order-list">
 
 
-      <view wx:for="{{orderList}}"  bindtap="tapByIdx" wx:key="{{item.id}}" data-url="{{'/pages/ucenter/order/order?id='+item.id}}" class="navigator a">
-        <view class="icon-item">
-          <image wx:if="{{imgServer}}" src="{{'/static/images/'+item.icon+'.png'}}"></image>
-          <span class="count" wx:if="{{item.count}}">{{item.count}}</span>
-        </view>
-        <view class="txt">{{item.name}}</view>
+    <view wx:for="{{orderList}}" bindtap="tapByIdx" wx:key="{{item.id}}" data-url="{{'/pages/ucenter/order/order?id='+item.id}}" class="navigator a">
+      <view class="icon-item">
+        <image wx:if="{{imgServer}}" src="{{'/static/images/'+item.icon+'.png'}}"></image>
+        <span class="count" wx:if="{{item.count}}">{{item.count}}</span>
       </view>
-      
-      <view class="i-line"></view>
-      
-      <view  bindtap="tapByIdx" data-url="{{'/pages/ucenter/order/order?id='+all.id}}" class="navigator a or-a">
-        <view class="icon-item">
-          <image wx:if="{{imgServer}}" src="{{'/static/images/'+all.icon+'.png'}}"></image>
-        </view>
-        <view class="txt">{{all.name}}</view>
+      <view class="txt">{{item.name}}</view>
+    </view>
+
+    <view class="i-line"></view>
+
+    <view bindtap="tapByIdx" data-url="{{'/pages/ucenter/order/order?id='+all.id}}" class="navigator a or-a">
+      <view class="icon-item">
+        <image wx:if="{{imgServer}}" src="{{'/static/images/'+all.icon+'.png'}}"></image>
       </view>
+      <view class="txt">{{all.name}}</view>
+    </view>
   </view>
 
-    <view class="order-list-v">
-      <view wx:for="{{senceList}}"  bindtap="tapByIdx" wx:key="{{item.id}}" data-type="{{item.type}}"  data-url="{{item.url}}" class="navigator a">
-        <image wx:if="{{imgServer}}" src="{{'/static/images/icon/'+item.icon+'.png'}}"></image>
-        <view>{{item.name}}</view>
-        <image src="/static/images/go.png" class="go"></image>
-      </view>
-      <view bindtap="toReport"   class="navigator a {{ hasBrand ? '' : 'hidden'}}">
-        <image src="{{'/static/images/report.png'}}"></image>
-        <view>数据统计</view>
-        <image src="/static/images/go.png" class="go"></image>
-      </view>
+  <view class="order-list-v">
+    <view wx:for="{{senceList}}" bindtap="tapByIdx" wx:key="{{item.id}}" data-type="{{item.type}}" data-url="{{item.url}}" class="navigator a">
+      <image wx:if="{{imgServer}}" src="{{'/static/images/icon/'+item.icon+'.png'}}"></image>
+      <view>{{item.name}}</view>
+      <image src="/static/images/go.png" class="go"></image>
+    </view>
+    <view bindtap="toReport" class="navigator a {{ hasBrand ? '' : 'hidden'}}">
+      <image src="{{'/static/images/report.png'}}"></image>
+      <view>数据统计</view>
+      <image src="/static/images/go.png" class="go"></image>
+    </view>
+  </view>
+  <view class="order-list-v">
+    <view bindtap="tapByIdx" data-url="/pages/ucenter/feedback/feedback" class="navigator a">
+      <image wx:if="{{imgServer}}" src="/static/images/cb3.png"></image>
+      <view>意见反馈</view>
+      <image src="/static/images/go.png" class="go"></image>
     </view>
-    <view class="order-list-v">
-      <view  bindtap="tapByIdx" data-url="/pages/ucenter/feedback/feedback" class="navigator a">
-        <image wx:if="{{imgServer}}" src="/static/images/cb3.png"></image>
-        <view>意见反馈</view>
+    <view class="navigator">
+      <button open-type="contact">
+        <image wx:if="{{imgServer}}" src="{{imgServer+'/cb4.png'}}"></image>
+        <view>联系客服</view>
         <image src="/static/images/go.png" class="go"></image>
-      </view>
-      <view class="navigator" >
-        <button open-type="contact">
-          <image wx:if="{{imgServer}}" src="{{imgServer+'/cb4.png'}}"></image>
-          <view>联系客服</view>
-          <image src="/static/images/go.png" class="go"></image>
-        </button>
-      </view>
+      </button>
     </view>
-    <!-- <view class="related-goods" wx:if="{{relatedGoods.length > 0}}">
+  </view>
+  <!-- <view class="related-goods" wx:if="{{relatedGoods.length > 0}}">
     <view class="h">
       <view class="line"></view>
       <text class="title">大家都在看</text>

+ 48 - 17
pages/user/user.js

@@ -17,7 +17,9 @@ Page({
   },
 
   updateNickName(ev) {
-    this.setData({nickname: ev.detail.value})
+    this.setData({
+      nickname: ev.detail.value
+    })
   },
   /**
    * 生命周期函数--监听页面加载
@@ -30,7 +32,9 @@ Page({
     delete userInfo.avatarUrl
     delete userInfo.sessionKey
 
-    this.setData({ ...userInfo })
+    this.setData({
+      ...userInfo
+    })
   },
 
 
@@ -38,7 +42,9 @@ Page({
     this.onLoad()
   },
   async getUserInfo() {
-    const {data} = await util.request(api.UserInfo)
+    const {
+      data
+    } = await util.request(api.UserInfo)
     data.region = data.city ? data.city.split(',') : []
     data.birthday = data.birthday || '1990-01-01'
     this.setData({
@@ -47,10 +53,17 @@ Page({
   },
 
   async getPhoneNumber(e) {
-    let {encryptedData,iv} =  e.detail
+    let {
+      encryptedData,
+      iv
+    } = e.detail
     console.log(e)
     if (!encryptedData) return;
-    let res = await util.request(api.decryptedPhoneNum, { encryptedData, iv, sessionKey: this.sessionKey })
+    let res = await util.request(api.decryptedPhoneNum, {
+      encryptedData,
+      iv,
+      sessionKey: this.sessionKey
+    })
 
     console.log(res)
     this.setData({
@@ -59,15 +72,21 @@ Page({
   },
 
   updateSex(e) {
-    this.setData({gender: e.currentTarget.dataset.sex})
+    this.setData({
+      gender: e.currentTarget.dataset.sex
+    })
   },
 
   bindDateChange(e) {
-    this.setData({ birthday: e.detail.value })
+    this.setData({
+      birthday: e.detail.value
+    })
   },
 
-  bindRegionChange (e) {
-    this.setData({ region: e.detail.value })
+  bindRegionChange(e) {
+    this.setData({
+      region: e.detail.value
+    })
   },
 
   selectPhoto() {
@@ -84,7 +103,7 @@ Page({
       }
     })
   },
-  changPhone(e){
+  changPhone(e) {
     this.setData({
       'mobile': e.detail.value,
     });
@@ -92,13 +111,22 @@ Page({
   async save(e) {
     let type = e.currentTarget.dataset.type
     console.log(e)
+    if (this.data.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')},
+          header: {
+            'X-Nideshop-Token': wx.getStorageSync('token')
+          },
           success: (res) => {
             this.file = null
             r(JSON.parse(res.data).data)
@@ -110,12 +138,16 @@ Page({
     }
 
     this.data.city = this.data.region && this.data.region.join(',')
-    const body = {...this.data}
+    const body = {
+      ...this.data
+    }
     delete body.region
-    const {data} = await util.request(api.UpdateUserInfo, body, 'POST', 'application/json')
-    if(type=='1'){
+    const {
+      data
+    } = await util.request(api.UpdateUserInfo, body, 'POST', 'application/json')
+    if (type == '1') {
       wx.navigateBack()
-    }else{
+    } else {
 
     }
   },
@@ -129,8 +161,7 @@ Page({
   /**
    * 生命周期函数--监听页面显示
    */
-  onShow: function () {
-  },
+  onShow: function () {},
 
   /**
    * 生命周期函数--监听页面隐藏

+ 1 - 1
pages/user/user.wxml

@@ -11,7 +11,7 @@
     <view class="item">
       <text>用户昵称</text>
       <view class="ir">
-        <input maxlength="15" value="{{nickname}}" class="ipname" bindinput="updateNickName"></input>
+        <input placeholder="请输入昵称" maxlength="15" value="{{nickname}}" class="ipname" bindinput="updateNickName"></input>
       </view>
     </view>
     <view class="item">