Browse Source

消息提醒完成

xjc 2 years ago
parent
commit
12b4533784
3 changed files with 8 additions and 13 deletions
  1. 6 3
      pages/message/message.js
  2. 2 5
      pages/message/message.wxml
  3. 0 5
      utils/api.js

+ 6 - 3
pages/message/message.js

@@ -19,11 +19,13 @@ Page({
      * 生命周期函数--监听页面加载
      */
     onLoad: function (options) {
+      var _this = this
       this.getData()
       wx.getStorage({
         key: this.data.template_id,
         success: res=> {
-          this.setData({
+          console.log(res,3333333333)
+          _this.setData({
             subscribe: true
           })
         },
@@ -47,8 +49,8 @@ Page({
         })
     },
     subscribe(){
-      const template_id = this.data.template_id
-      const that = this;
+      var template_id = this.data.template_id
+      var that = this;
       wx.requestSubscribeMessage({
         tmplIds: [template_id],
         success (res) { 
@@ -60,6 +62,7 @@ Page({
             that.setData({
               subscribe:true
             })
+            that.post()
           }
         }
       })

+ 2 - 5
pages/message/message.wxml

@@ -1,8 +1,4 @@
 <view id="messageScroll">
-    <view class="subscribe" wx:if="{{!subscribe}}">
-      <image src="../../images/lb.png" mode="widthFix" class="notice"></image>
-      <text class="noticeMsg" bindtap="subscribe">点我开通即时消息提醒!</text>
-    </view>
     <view class="list" wx:for="{{list}}" >
         <view class="me" wx:if='{{item.user_id}}'>
             <image src="{{item.user_avatar}}" ></image>
@@ -18,7 +14,8 @@
     </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>
+        <button wx:if="{{!subscribe}}" bindtap="subscribe">提交</button>
+        <button wx:else bindtap="post">提交</button>
     </view>
     <view style="clear: both;"></view>
 </view>

+ 0 - 5
utils/api.js

@@ -22,11 +22,6 @@ function request(method, url, data) {
           'content-type': 'application/json',
           'Authorization': token
         };
-        if(data){
-          Object.keys(data).length?data.pass = 1:{"pass":1}
-        }else{
-          data = {"pass":1}
-        }
         wx.request({
           url: baseURL + url,
           method: method,