Răsfoiți Sursa

update:watchlist操作栏优化v2

lvzhiqiang 2 ani în urmă
părinte
comite
bb5bed356b

+ 6 - 3
src/main/java/top/lvzhiqiang/controller/CoinController.java

@@ -73,12 +73,15 @@ public class CoinController {
         return coinService.orderDetail2(orderId, symbol);
     }
 
-    @GetMapping("/watchlistDetail/{symbol}")
-    public Object watchlistDetail(@PathVariable String symbol) {
+    @GetMapping("/watchlistDetail/{symbol}/{operationType}")
+    public Object watchlistDetail(@PathVariable String symbol, @PathVariable String operationType) {
         if (StringUtils.isEmpty(symbol)) {
             throw new ParameterException("symbol不能为空!");
         }
+        if (StringUtils.isEmpty(operationType)) {
+            throw new ParameterException("operationType!");
+        }
 
-        return R.ok().data(coinService.watchlistDetail(symbol));
+        return R.ok().data(coinService.watchlistDetail(symbol, operationType));
     }
 }

+ 1 - 1
src/main/java/top/lvzhiqiang/service/CoinService.java

@@ -41,5 +41,5 @@ public interface CoinService {
 
     void syncData4TraderListSub(JSONArray dataList);
 
-    String watchlistDetail(String symbol);
+    String watchlistDetail(String symbol, String operationType);
 }

+ 8 - 2
src/main/java/top/lvzhiqiang/service/impl/CoinServiceImpl.java

@@ -203,13 +203,19 @@ public class CoinServiceImpl implements CoinService {
     }
 
     @Override
-    public String watchlistDetail(String symbol) {
+    public String watchlistDetail(String symbol, String operationType) {
         CoinWatchlist coinWatchlist = coinMapper.findWatchlistBySymbol(symbol);
         if (coinWatchlist == null) {
             throw new BusinessException(1, "symbol不存在!");
         }
 
-        return MarkdownToHtmlUtils.markdownToHtmlExtensions(coinWatchlist.getRemark());
+        if ("detail".equals(operationType)) {
+            return MarkdownToHtmlUtils.markdownToHtmlExtensions(coinWatchlist.getRemark());
+        } else if ("update".equals(operationType)) {
+            return coinWatchlist.getRemark();
+        } else {
+            return "暂不支持该操作!";
+        }
     }
 
     private List<CoinTrader> parseMixTradeList(JSONArray dataList) {

+ 6 - 0
src/main/resources/static/coin.html

@@ -36,6 +36,11 @@
         height: 50%;
     }
 
+    .watchlistpreview-top {
+        height: 40px;
+        line-height: 40px;
+    }
+
     .watchlistpreview-content {
         overflow: auto;
         height: calc(100% - 40px);
@@ -280,6 +285,7 @@
     <div class="watchlistpreview-loading"><img src='cover/loading.gif'></div>
     <div class="watchlistpreview-top">
         <div style="float: left;" class="watchlistpreview-top-title">详情</div>
+        <div style="float: right;" class="watchlistpreview-top-submit"><img src="cover/submit.svg"></div>
         <div style="float: right;" class="watchlistpreview-top-close"><img src="cover/close.svg"></div>
     </div>
     <div class="watchlistpreview-content"></div>

+ 1 - 0
src/main/resources/static/cover/submit.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1703141600470" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9485" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32"><path d="M512 0C229.668571 0 0 229.668571 0 512s229.668571 512 512 512 512-229.668571 512-512S794.331429 0 512 0z m307.2 343.771429s-267.702857 295.497143-327.68 365.714285c-59.977143 70.217143-106.788571 0-106.788571 0L210.651429 529.554286s-27.794286-42.422857 21.942857-81.92c46.811429-38.034286 84.845714 0 84.845714 0l122.88 128.731428L746.057143 291.108571s29.257143-20.48 59.977143 5.851429c23.405714 21.942857 13.165714 46.811429 13.165714 46.811429z" fill="#68BF7B" p-id="9486"></path></svg>

+ 18 - 4
src/main/resources/static/js/my-coin.js

@@ -341,7 +341,8 @@ function mainSearch(url, nameEn, slideDiv, needCustomFlag) {
 
                     if (nameEn === 'watchlist') {
                         str += '<td style="padding: 0px 10px 0px 10px;">';
-                        str += '<button class="apis-quiet-div-watchlist-detail" symbolName="' + dataDetail.symbol + '">详情</button>';
+                        str += '<button class="apis-quiet-div-watchlist-detail" operationType="detail" symbolName="' + dataDetail.symbol + '">详情</button>';
+                        str += '<button class="apis-quiet-div-watchlist-update" operationType="update" symbolName="' + dataDetail.symbol + '">编辑</button>';
                         str += '</td>';
                     }
 
@@ -350,6 +351,7 @@ function mainSearch(url, nameEn, slideDiv, needCustomFlag) {
 
                 if (nameEn === 'watchlist') {
                     $(".apis-quiet-div-watchlist-detail").unbind("click");
+                    $(".apis-quiet-div-watchlist-update").unbind("click");
                     $(".watchlistpreview-top-close").unbind("click");
                 }
 
@@ -380,7 +382,7 @@ function initContentEvent(nameEn) {
     }
 
     if (nameEn === 'watchlist') {
-        $(".apis-quiet-div-watchlist-detail").click(function () {
+        $(".apis-quiet-div-watchlist-detail,.apis-quiet-div-watchlist-update").click(function () {
             if ($("#watchlistpreview").css("display") === 'none') {
                 $("#watchlistpreview").css("display", "block");
             } else if ($("#watchlistpreview").css("display") === 'block') {
@@ -396,15 +398,27 @@ function initContentEvent(nameEn) {
                 $(this).unbind("click");
             });
 
+            var operationType = $(this).attr("operationType");
+            if (operationType === 'detail') {
+                $(".watchlistpreview-top-submit").css("display", "none");
+            } else if (operationType === 'update') {
+                $(".watchlistpreview-top-submit").css("display", "block");
+            }
             $.ajax({
-                url: "coin/watchlistDetail/" + $(this).attr("symbolName"), //请求的url地址
+                url: "coin/watchlistDetail/" + $(this).attr("symbolName") + "/" + operationType, //请求的url地址
                 type: "get", //请求方式
                 async: true, //请求是否异步,默认为异步,这也是ajax重要特性
                 success: function (data) {
                     //请求成功时处理
                     if (data != null && $.trim(data) != "" && data.success) {
                         data = data.data;
-                        $(".watchlistpreview-content").html(data);
+
+                        if (operationType === 'detail') {
+                            $(".watchlistpreview-content").html(data);
+                        } else if (operationType === 'update') {
+                            var update4Text = '<textarea rows="4" cols="50" style="width: 100%;height: 100%;">' + data + '</textarea>';
+                            $(".watchlistpreview-content").html(update4Text);
+                        }
                     } else {
                         //alert(data.message);
                     }