xjc 2 anni fa
parent
commit
b7d3681e72

+ 5 - 1
pages/detail/detail.js

@@ -15,11 +15,15 @@ Page({
    */
   onLoad: function (options) {
     $api.getArticle({id:options.id}).then(res=>{
+      let data = res.data.data
+      data.content = data.content.replaceAll('<img', '<img class="rich-img"')
       this.setData({
-        info:res.data.data,
+        info:data,
         name:res.data.data.name,
         articleid:options.id,
       })
+      console.log()
+      this.data.info.content = this.data.info.content.replace('<img', '<img class="rich-img"')
     })
   },
 

+ 3 - 0
pages/detail/detail.wxss

@@ -17,3 +17,6 @@ page{
   font-size: 32rpx;
   line-height: 56rpx;
 }
+.content .rich-img{
+  width:100%;
+}

+ 12 - 2
pages/message/message.js

@@ -9,7 +9,8 @@ Page({
      * 页面的初始数据
      */
     data: {
-        focus:false
+        focus:false,
+        scrollTop:0
     },
 
     /**
@@ -61,7 +62,16 @@ Page({
      * 生命周期函数--监听页面显示
      */
     onShow: function () {
-      
+      let that = this;
+      wx.createSelectorQuery().select("#messageScroll").boundingClientRect(function(rect){
+        wx.pageScrollTo({
+          scrollTop:rect.height,
+          duration:100
+        })
+        that.setData({
+          scrollTop:rect.height - that.data.scrollTop
+        })
+      }).exec()
     },
 
     /**

+ 17 - 17
pages/message/message.wxml

@@ -1,20 +1,20 @@
-<view class="list" wx:for="{{list}}">
-    <view class="me" wx:if='{{item.user_id}}'>
-        <image src="{{item.user_avatar}}" ></image>
-        <view class="content">{{item.content}}</view>
-    </view>
-    <view class="wz" wx:else>
-        <image src="../../images/wz.jpg" ></image>
-        <view>
-            <text class="name">顽主</text>
-            <view class="content">{{item.reply_content}}</view>
+<view id="messageScroll">
+    <view class="list" wx:for="{{list}}" >
+        <view class="me" wx:if='{{item.user_id}}'>
+            <image src="{{item.user_avatar}}" ></image>
+            <view class="content">{{item.content}}</view>
+        </view>
+        <view class="wz" wx:else>
+            <image src="../../images/wz.jpg" ></image>
+            <view>
+                <text class="name">顽主</text>
+                <view class="content">{{item.reply_content}}</view>
+            </view>
         </view>
     </view>
-</view>
-
-
-
-<view class="post">
-    <input confirm-type='send' bindconfirm='post' value="{{comment}}" placeholder-style="color:#999" maxlength="500" bindinput="inputchange" type="text" placeholder="我要咨询"/>
-    <button bindtap="post">提交</button>
+    <view class="post">
+        <input confirm-type='send' bindconfirm='post' value="{{comment}}" placeholder-style="color:#999" maxlength="500" bindinput="inputchange" type="text" placeholder="我要咨询"/>
+        <button bindtap="post">提交</button>
+    </view>
+    <view style="clear: both;"></view>
 </view>

+ 4 - 1
pages/message/message.wxss

@@ -5,7 +5,10 @@ page{
 }
 .list{
     position: relative;
-    margin-bottom: 24rpx;
+    margin-bottom: 48rpx;
+}
+.list:last-child{
+    padding-bottom: 160rpx;
 }
 .post{
     position: fixed;

+ 5 - 5
pages/style/style.js

@@ -80,10 +80,10 @@ Page({
         })
         const tempFilePaths = res.tempFiles
         for (let i = 0; i < tempFilePaths.length; i++) {
-          $api.upload(tempFilePaths[i].path,'file').then(res=>{
+          $api.uploadAvatar(tempFilePaths[i].path,'file').then(res=>{
               wx.hideLoading()
               if(res.code == 0){
-                form.account_img=res.data.url;
+                form.avatar=res.data.url;
                 this.setData({
                   form: form
                 })
@@ -103,13 +103,13 @@ Page({
   },
   preview(){
     wx.previewImage({
-      urls: [this.data.form.account_img],
-      current: this.data.form.account_img
+      urls: [this.data.form.avatar],
+      current: this.data.form.avatar
     })
   },
   del(){
     let form = this.data.form;
-    form.account_img ='';
+    form.avatar ='';
     this.setData({
       form: form
     })

+ 13 - 12
pages/style/style.wxml

@@ -1,4 +1,15 @@
 <wxs src="../../utils/tool.wxs" module="tool"></wxs>
+<view class="item">
+  <label>头像</label>
+  <view class="tags">
+      <image class="account_img" wx:if='{{form.avatar}}' bindtap="preview" src="{{form.avatar}}"></image>
+      <icon wx:if='{{form.avatar}}' bindtap="del" class="icon-small" type="cancel" size="25"></icon>
+      <view wx:else class="upload" bindtap="uploadImg">
+          <image mode="widthFix" src="../../images/img.png"></image>
+            上传头像
+      </view>
+  </view>
+</view>
 <view class="item" wx:if="{{form.is_player==1}}"> 
    <label>参赛名</label>
    <view class="tags"> 
@@ -18,7 +29,7 @@
   </view>
 </view>
 
-<view class="title">请选择你的操作风格</view>
+<view class="title">操作风格</view>
 <view wx:if='{{arr1.length>0}}'>
 <view class="item">
   <label>周期</label>
@@ -53,16 +64,6 @@
       <view style="color:red;font-size:23rpx;">比赛期间有资金进出请联系QQ客服除权,再提交作业</view> -->
   <!-- </view> -->
 <!-- </view> -->
-<!-- <view class="item">
-  <label>账户截图</label>
-  <view class="tags">
-      <image class="account_img" wx:if='{{form.account_img}}' bindtap="preview" src="{{form.account_img}}"></image>
-      <icon wx:if='{{form.account_img}}' bindtap="del" class="icon-small" type="cancel" size="25"></icon>
-      <view wx:else class="upload" bindtap="uploadImg">
-          <image mode="widthFix" src="../../images/img.png"></image>
-            上传图片
-      </view>
-  </view>
-</view> -->
+
 <button bindtap="post" class="post_btn">确定</button>
 </view>

+ 2 - 1
utils/api.js

@@ -31,7 +31,7 @@ function request(method, url, data) {
             //请求成功
             //判断状态码---errCode状态根据后端定义来判断
 
-            if (res.data.code == 0) {
+            if (res.data.code == 0||res.data.pass==1) {
               resolve(res);
             } else if (res.data.code == 403) {
               //未登录
@@ -118,6 +118,7 @@ const API = {
   getSellStock: (data) => request(GET, `/api/wx/v2/hot/stock/sell/players`, data),
   getChampionlList: (data) => request(GET, `/api/wx/v2/champion/article/list`, data),
   upload: (filePath, name) => uploadFile(`/api/wx/uploadfile`, filePath, name),
+  uploadAvatar: (filePath, name) => uploadFile(`/api/wx/uploadavatar`, filePath, name),
   updateStyle: (data) => request(PUT, `/api/wx/v2/mine/style`, data),
   getMyStyle: (data) => request(GET, `/api/wx/v2/mine/style`, data),
   getMyFollow: (data) => request(GET, `/api/wx/v2/user/follow/list`, data),