Browse Source

修复手机预览前端时发现的问题

nnkwrik 6 years ago
parent
commit
8c452ed92b

+ 2 - 1
wx-front/app.json

@@ -39,7 +39,8 @@
     "pages/ucenter/about/about",
     "pages/user/user",
     "pages/chat/chatIndex/chatIndex",
-    "pages/chat/chatForm/chatForm"
+    "pages/chat/chatForm/chatForm",
+    "pages/undone/undone"
   ],
   "window": {
     "backgroundTextStyle": "dark",

+ 4 - 3
wx-front/config/api.js

@@ -1,6 +1,7 @@
-// const ApiRootUrl = 'https://5d876383.ngrok.io/';
-const ApiRootUrl = 'http://127.0.0.1:8080/';
-const WebSocktUrl = 'ws://127.0.0.1:8805/'
+const ApiRootUrl = 'https://01bcd133.ngrok.io/';
+const WebSocktUrl = 'ws://f5763704.ngrok.io/'
+// const ApiRootUrl = 'http://127.0.0.1:8080/';
+// const WebSocktUrl = 'ws://127.0.0.1:8805/'
 
 module.exports = {
   IndexUrl: ApiRootUrl + 'index/index', //首页数据接口

+ 5 - 1
wx-front/pages/auth/auth.js

@@ -12,7 +12,8 @@ Page({
   data: {
     userInfo: app.globalData.userInfo,
     hasUserInfo: false,
-    canIUse: wx.canIUse('button.open-type.getUserInfo')
+    canIUse: wx.canIUse('button.open-type.getUserInfo'),
+    load:false
   },
 
   /**
@@ -24,6 +25,9 @@ Page({
 
   startLogin: function(e) {
     console.log(e);
+    this.setData({
+      load:true
+    })
     util.backendLogin(e.detail).then((userInfo) => {
       this.setData({
         userInfo: userInfo,

+ 1 - 1
wx-front/pages/auth/auth.wxml

@@ -11,7 +11,7 @@
     <!-- 不能用 open-type="getUserInfo" 的版本 -->
     <button wx:if="{{!canIUse}}" class="btn" disabled="true" >微信版本过低,请更新后再尝试授权</button>
     
-    <button wx:elif="{{!hasUserInfo}}" class="btn" open-type="getUserInfo" bindgetuserinfo="startLogin">授权登录</button>
+    <button wx:elif="{{!hasUserInfo}}" class="btn" open-type="getUserInfo" bindgetuserinfo="startLogin">{{load?'请稍等..':'授权登录'}}</button>
     <button wx:else disabled="true" class="btn">授权成功</button>
 
     <button type="default" class="btn" bindtap="goback">返回上一页</button>

+ 16 - 8
wx-front/pages/chat/chatForm/chatForm.js

@@ -23,6 +23,7 @@ Page({
     newScrollHeight: 0,
     noMore: false,
     input: '',
+    typing: '',
   },
 
   /**
@@ -142,14 +143,17 @@ Page({
     })
   },
   sendMsg: function() {
-    if (this.data.input.trim() == '') {
-      this.setData({
-        input: '',
-      })
-      return
-    }
+
     let that = this
     var data = this.createMsg()
+    var input = this.data.input
+    this.setData({
+      typing: '',
+      input: '',
+    })
+    if (input.trim() == '') {
+      return
+    }
     //通过webSocket发送消息
     websocket.sendMessage(data).then(res => {
       console.log(res)
@@ -158,12 +162,13 @@ Page({
         chatId: this.data.id,
         u1ToU2: wx.getStorageSync('userInfo').openId < this.data.otherSide.openId ? true : false,
         messageType: 1,
-        messageBody: this.data.input,
+        messageBody: input,
         sendTime: util.formatTime(new Date()),
       }]
 
       that.addHistoryList(newHistory)
 
+
     }).catch((res) => {
       console.log(res)
       util.showErrorToast('发送失败')
@@ -174,10 +179,10 @@ Page({
     //把新的数据加入目前的对话框
     var newHistoryList = this.data.historyList.concat(historyList)
     this.setData({
-      input: '',
       historyList: newHistoryList,
     })
 
+
     //重新设置scroll
     let _this = this
     this.getScrollHeight().then((res) => {
@@ -207,6 +212,9 @@ Page({
     })
     return data
   },
+  buy:function(){
+    util.showErrorToast('功能开发中')
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 2 - 2
wx-front/pages/chat/chatForm/chatForm.wxml

@@ -6,7 +6,7 @@
         <view class='name' bindtap='toGoods' data-id='{{goods.id}}'>{{goods.name}}</view>
         <view class='order'>
           <view class='price' bindtap='toGoods' data-id='{{goods.id}}'>¥ {{goods.price}}</view>
-          <view class='btn'>立即购买</view>
+          <view class='btn' bindtap='buy'>立即购买</view>
         </view>
         <view class='msg'>交易前聊一聊</view>
       </view>
@@ -70,7 +70,7 @@
     <view class="input">
 
       <view class="content">
-        <input class='' focus='{{openComment}}' placeholder="" maxlength='800' confirm-type="done" bindconfirm='done' value='{{input}}' bindinput="inputChange" />
+        <input class='' confirm-hold="true" placeholder="" maxlength='800' confirm-type="done" bindconfirm='done' value='{{typing}}' bindinput="inputChange" bindconfirm='sendMsg'/>
 
       </view>
       <view class='send' bindtap='sendMsg'>发送</view>

+ 4 - 3
wx-front/pages/chat/chatIndex/chatIndex.js

@@ -61,9 +61,10 @@ Page({
       offsetTime: now.toISOString(),
       chatList: []
     })
-
-    this.getChatList();
-    this.openListen();
+    if (wx.getStorageSync('token')){
+      this.getChatList();
+      this.openListen();
+    }
   },
   onHide: function() {
     // 页面隐藏

+ 11 - 1
wx-front/pages/goods/goods.js

@@ -20,6 +20,7 @@ Page({
 
     openComment: false,
     openDelete: false,
+    showInput: false,
     replyId: '',
     replyUserId: '',
     replyUserName: '',
@@ -35,6 +36,7 @@ Page({
     let that = this;
     util.request(api.GoodsDetail + '/' + that.data.id).then(function(res) {
       if (res.errno === 0) {
+        console.log(res.data)
         if (res.data.info.isDelete) {
           util.showErrorToast('商品不存在')
           setTimeout(function callback() {
@@ -45,11 +47,13 @@ Page({
           }, 1000)
           return
         }
-
+        
         //计算卖家来平台第几天
         let registerTime = res.data.seller.registerTime
+        registerTime = registerTime.replace('T', ' ').replace(/-/g, '/').split(".")[0];
         let duration = new Date().getTime() - new Date(registerTime).getTime();
         let dates = parseInt(Math.floor(duration) / (1000 * 60 * 60 * 24));
+        console.log("dates " + dates)
         that.setData({
           goods: res.data.info,
           gallery: res.data.gallery,
@@ -177,6 +181,12 @@ Page({
         this.setData({
           openComment: !this.data.openComment
         });
+        let that = this
+        setTimeout(function callback() {
+          that.setData({
+            showInput: true
+          })
+        }, 100)
       }
     })
 

+ 2 - 2
wx-front/pages/goods/goods.wxml

@@ -82,7 +82,7 @@
               </view>
               <view class="time">{{iitem.createTime}}</view>
             </view>
-            <view class="reply-content" bindtap="switchCommentPop" data-reply-id="{{iitem.id}}" data-reply-user-id="{{iitem.simpleUser.openId}}" data-reply-user-name='{{iitem.simpleUser.nickName}}'>
+            <view class="reply-content" bindtap="switchCommentPop" data-reply-id="{{item.id}}" data-reply-user-id="{{iitem.simpleUser.openId}}" data-reply-user-name='{{iitem.simpleUser.nickName}}'>
               回复@{{iitem.replyUserName}}:{{iitem.content}}
             </view>
           </view>
@@ -131,7 +131,7 @@
       </view>
 
       <view class="content">
-        <input id='comment-input' class='' focus='{{openComment}}' placeholder="输入文本" maxlength='100' bindblur='closeComment' bindconfirm='postComment' value='{{commentContent}}' />
+        <input id='comment-input' class='' focus='{{showInput}}' placeholder="输入文本" maxlength='100' bindblur='closeComment' bindconfirm='postComment' value='{{commentContent}}' />
       </view>
 
     </view>

+ 2 - 2
wx-front/pages/goods/goods.wxss

@@ -1,5 +1,5 @@
 .container {
-  margin-bottom: 100rpx;
+  padding-bottom: 100rpx;
 }
 
 .goodsimgs {
@@ -684,7 +684,7 @@
   width: 100%;
   height: auto;
   max-height: 780rpx;
-  padding: 10rpx;
+  padding: 15rpx;
   background: #fff;
   position: fixed;
   z-index: 9;

+ 1 - 6
wx-front/pages/index/index.wxml

@@ -11,15 +11,10 @@
 
   <!-- 首页分类 -->
   <view class="m-menu">
-    <navigator class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
+    <navigator open-type="{{item.url == '/pages/catalog/catalog' ? 'reLaunch':'navigate'}}" class="item" url="{{item.url}}" wx:for="{{channel}}" wx:key="{{item.id}}">
       <image src="{{item.iconUrl}}" background-size="cover"></image>
       <text>{{item.name}}</text>
     </navigator>
-    <navigator open-type="reLaunch" class="item" url="/pages/catalog/catalog">
-      <image src="https://i.postimg.cc/x17Z3PJd/visualization.png" background-size="cover"></image>
-      <text>全部分类</text>
-    </navigator>
-
   </view>
 
 

+ 1 - 1
wx-front/pages/post/post.js

@@ -79,7 +79,7 @@ Page({
   uploadFile(url, i) {
     let that = this;
     wx.uploadFile({
-      url: '	https://sm.ms/api/upload',
+      url: 'https://sm.ms/api/upload',
       filePath: url,
       name: 'smfile',
       success(res) {

+ 1 - 1
wx-front/pages/post/post.wxss

@@ -129,7 +129,7 @@ page, .container {
 }
 
 .img .blur {
-  filter: blur(1rpx) contrast(50%);
+  filter: blur(1rpx);
   background-size: cover;
   background-position: center center;
 }

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

@@ -47,14 +47,14 @@
     </view>
 
         <view class="item ">
-      <navigator url="/pages/ucenter/order/order" class="a">
+      <navigator url="/pages/undone/undone" class="a">
         <text class="icon order"></text>
         <text class="txt">我的订单</text>
       </navigator>
     </view>
 
     <view class="item item-bottom">
-      <navigator url="../address/address" class="a">
+      <navigator url="/pages/undone/undone" class="a">
         <text class="icon map"></text>
         <text class="txt">地址管理</text>
       </navigator>

+ 66 - 0
wx-front/pages/undone/undone.js

@@ -0,0 +1,66 @@
+// pages/undone/undonw.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 1 - 0
wx-front/pages/undone/undone.json

@@ -0,0 +1 @@
+{}

+ 7 - 0
wx-front/pages/undone/undone.wxml

@@ -0,0 +1,7 @@
+<view class="container">
+
+  <view class="result-empty" >
+    <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noSearchResult-7572a94f32.png"></image>
+    <text class="text">功能正在开发中..</text>
+  </view>
+</view>

+ 31 - 0
wx-front/pages/undone/undone.wxss

@@ -0,0 +1,31 @@
+page {
+  background: #f4f4f4;
+  min-height: 100%;
+}
+
+.container {
+  background: #f4f4f4;
+  min-height: 100%;
+}
+
+.result-empty {
+  width: 100%;
+  height: 100%;
+  padding-top: 300rpx;
+}
+
+.result-empty .icon {
+  margin: 0 auto;
+  display: block;
+  width: 240rpx;
+  height: 240rpx;
+}
+
+.result-empty .text {
+  display: block;
+  width: 100%;
+  height: 40rpx;
+  font-size: 28rpx;
+  text-align: center;
+  color: #999;
+}

+ 1 - 0
wx-front/pages/user/user.js

@@ -49,6 +49,7 @@ Page({
 
         //计算卖家来平台第几天
         let registerTime = res.data.user.registerTime
+        registerTime = registerTime.replace('T', ' ').replace(/-/g, '/').split(".")[0];
         let duration = new Date().getTime() - new Date(registerTime).getTime();
         let dates = parseInt(Math.floor(duration) / (1000 * 60 * 60 * 24));
 

+ 1 - 1
wx-front/pages/user/user.wxml

@@ -32,7 +32,7 @@
     </view>
   </view>
   <view class="result-empty" wx:else>
-    <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noSearchResult-7572a94f32.png"></image>
+    <!-- <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noSearchResult-7572a94f32.png"></image> -->
     <text class="text">该用户还没发布过宝贝</text>
   </view>
 </view>

+ 4 - 3
wx-front/pages/user/user.wxss

@@ -10,11 +10,12 @@ page {
 
 .top {
   height: 350rpx;
-  border-bottom: 4rpx solid #ddd;
+  border-bottom: 1rpx solid #e1e1e1;
+  margin-bottom: 10rpx;
 }
 
 .bg {
-  filter: blur(2px) ;
+  filter: blur(1px) ;
   width: 100%;
   height: 345rpx;
   position: absolute;
@@ -61,7 +62,7 @@ border:5rpx solid #fff;
   display: block;
   height: 45rpx;
   line-height: 45rpx;
-  /* color: #555; */
+  color: #555;
   font-size: 37.5rpx;
   margin-top: 20rpx;
 }

+ 6 - 1
wx-front/services/websocket.js

@@ -13,9 +13,13 @@ var badge = 0
 function wsConnect() {
 
   let that = this
-  var openId = wx.getStorageSync('userInfo').openId
+  let userInfo = wx.getStorageSync('userInfo')
   // 创建Socket
   return new Promise(function(resolve, reject) {
+    if (!userInfo){
+      reject("未登录")
+    }
+    var openId = userInfo.openId
     SocketTask = wx.connectSocket({
       url: api.ChatWs + '/' + openId,
       header: {
@@ -239,5 +243,6 @@ module.exports = {
   listenChatIndex,
   lessBadge,
   listenBadge,
+  wsClose,
   // stopListenForm,
 };