Przeglądaj źródła

始宁农业小程序:农事天地

panyong 1 rok temu
rodzic
commit
9f4e74301c

+ 3 - 2
htmldev/shiningWxMini/pages/news/api/index.js

@@ -5,11 +5,12 @@ const { request } = require('../../../api/request')
  * @param id 商户ID
  * @returns {Promise<*>}
  */
-export const postFollowUser = (id) => request({
+export const postFollowUser = (id, type) => request({
   url: '/api/user/follow/user',
   method: 'POST',
   data: {
-    shop_id: id
+    shop_id: id,
+    type: type // 类型(1关注2取消关注)
   },
   showLoading: true
 })

+ 4 - 5
htmldev/shiningWxMini/pages/news/news.js

@@ -112,20 +112,19 @@ Page({
   // 关注
   async followUser(e) {
     const { item, index } = e.target.dataset
+    const type = item.follow_status === 1 ? 2 : 1
 
     this.setData({
       booLock: true
     })
     try {
-      const { status, msg } = await postFollowUser(item.shop_id)
+      const { status, msg } = await postFollowUser(item.shop_id, type)
       if (status) {
         wx.showToast({
-          title: '已关注',
+          title: item.follow_status === 1 ? '已取消关注' : '已关注',
           icon: 'none'
         })
-        this.setData({
-          ['listData[' + index + '].follow_status']: 1
-        })
+        this.refreshOrderList()
       } else {
         wx.showToast({
           title: msg,

+ 5 - 4
htmldev/shiningWxMini/pages/news/news.wxml

@@ -1,7 +1,7 @@
 <page-meta page-style="{{ booPopop ? 'overflow: hidden;' : '' }}"/>
 <view class="wrapper">
   <view class="app_page-header-search">
-    <view class="app_page-header-search-warp app_width-690">
+    <view class="app_page-header-search-warp">
       <label for="header-search">
         <image src="../../image/common/search@2x.png"></image>
       </label>
@@ -12,7 +12,7 @@
         data-formkey="key_words"
         bind:input="handleKeyWords"></input>
     </view>
-    <view class="leaving-a-message" bind:tap="jumpLeavingAMessage" wx:if="{{false}}">
+    <view class="leaving-a-message" bind:tap="jumpLeavingAMessage">
       <image src="../../image/common/message@2x.png"></image>
       <view>8</view>
     </view>
@@ -36,10 +36,11 @@
         </view>
         <button
           class="follow"
-          disabled="{{booLock || item.follow_status === 1}}"
+          disabled="{{booLock}}"
           data-item="{{item}}"
           data-index="{{index}}"
-          bind:tap="followUser">{{item.follow_status === 1 ? '已' : ''}}关注
+          bind:tap="followUser"
+          hidden="{{active === '1' && item.follow_status === 1}}">{{item.follow_status === 1 ? '已' : ''}}关注
         </button>
       </view>
       <view class="news">