tanyanfei %!s(int64=2) %!d(string=hai) anos
pai
achega
7a355322bc
Modificáronse 3 ficheiros con 14 adicións e 1 borrados
  1. 12 0
      pages/stock/stock.js
  2. 1 1
      pages/stock/stock.wxml
  3. 1 0
      utils/api.js

+ 12 - 0
pages/stock/stock.js

@@ -109,6 +109,18 @@ Page({
       })
     })
   },
+  delchoice(){
+    $api.deletechoice({stock_id:this.data.id}).then(res=>{
+      wx.showToast({
+        title: '取消成功',
+      })
+      var info=this.data.info;
+      info.choiced=0
+      this.setData({
+        info: info
+      })
+    })
+  },
   tab(e){
       this.setData({
           cur:e.target.dataset.id

+ 1 - 1
pages/stock/stock.wxml

@@ -8,7 +8,7 @@
 <view wx:if='{{id}}'>
   <view class="stock_name">{{info.name}} <text wx:if='{{info.code}}'>{{info.code}}</text>
   <view wx:if='{{!info.choiced}}' bindtap="choice">加入自选</view>
-  <view wx:else>我的自选</view>
+  <view wx:else bindtap="delchoice">取消自选</view>
   </view>
   <!-- <image wx:if='{{info.img}}' mode="withFix" src="{{info.img}}"></image>
   <view wx:if='{{info.desc}}' class="desc">{{info.desc}}</view> -->

+ 1 - 0
utils/api.js

@@ -148,6 +148,7 @@ const API = {
   update: (data) => request(PUT, `/api/wx/v3/user/fund/modify`, data),
   getChoice: (data) => request(GET, `/api/wx/v3/user/choice/list`, data),
   addchoice: (data) => request(POST, `/api/wx/v3/user/choice`, data),
+  deletechoice: (data) => request(DELETE, `/api/wx/v3/user/choice`, data),
   initfund: (data) => request(PUT, `/api/wx/player/fund`, data),