You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

348 lines
8.4 KiB

4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
4 weeks ago
  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view class="time-share-title">
  5. <text>分时设计</text>
  6. </view>
  7. <view style="height:57.5vh;background-color: white;">
  8. <view class="title">A股竞价</view>
  9. <view class="top-options">
  10. <view
  11. class="option-btn"
  12. :class="{ 'active': aStockBid === 'auto' }"
  13. @click="handleAStockBidChange('auto')"
  14. >
  15. <text>智能开启</text>
  16. <view class="active-dot" v-if="aStockBid === 'auto'"></view>
  17. </view>
  18. <view
  19. class="option-btn"
  20. :class="{ 'active': aStockBid === 'open' }"
  21. @click="handleAStockBidChange('open')"
  22. >
  23. <text>保持开启</text>
  24. <view class="active-dot" v-if="aStockBid === 'open'"></view>
  25. </view>
  26. <view
  27. class="option-btn"
  28. :class="{ 'active': aStockBid === 'close' }"
  29. @click="handleAStockBidChange('close')"
  30. >
  31. <text>保持关闭</text>
  32. <view class="active-dot" v-if="aStockBid === 'close'"></view>
  33. </view>
  34. </view>
  35. <view class="title">K线样式</view>
  36. <view class="top-options">
  37. <view
  38. class="option-btn"
  39. :class="{ 'active': kStyle === 'common' }"
  40. @click="handleKStyleChange('common')"
  41. >
  42. <image src="../../static/my/common.png" class="kline-icon" />
  43. <text>普通</text>
  44. <view class="active-dot" v-if="kStyle === 'common'"></view>
  45. </view>
  46. <view
  47. class="option-btn"
  48. :class="{ 'active': kStyle === 'Outline' }"
  49. @click="handleKStyleChange('Outline')"
  50. >
  51. <image src="../../static/my/outline.png" class="kline-icon" />
  52. <text>轮廓图</text>
  53. <view class="active-dot" v-if="kStyle === 'Outline'"></view>
  54. </view>
  55. <view
  56. class="option-btn"
  57. :class="{ 'active': kStyle === 'polylines' }"
  58. @click="handleKStyleChange('polylines')"
  59. >
  60. <image src="../../static/my/polylines.png" class="kline-icon" />
  61. <text>折线图</text>
  62. <view class="active-dot" v-if="kStyle === 'polylines'"></view>
  63. </view>
  64. </view>
  65. <view class="title">除权类型</view>
  66. <view class="top-options">
  67. <view
  68. class="option-btn"
  69. :class="{ 'active': exRights === 'exRights' }"
  70. @click="handleExRightsChange('exRights')"
  71. >
  72. <text>除权</text>
  73. <view class="active-dot" v-if="exRights === 'exRights'"></view>
  74. </view>
  75. <view
  76. class="option-btn"
  77. :class="{ 'active': exRights === 'normal' }"
  78. @click="handleExRightsChange('normal')"
  79. >
  80. <text>普通</text>
  81. <view class="active-dot" v-if="exRights === 'normal'"></view>
  82. </view>
  83. <view
  84. class="option-btn"
  85. :class="{ 'active': exRights === 'Weighted' }"
  86. @click="handleExRightsChange('Weighted')"
  87. >
  88. <text>加权</text>
  89. <view class="active-dot" v-if="exRights === 'Weighted'"></view>
  90. </view>
  91. </view>
  92. <view class="title">涨跌颜色</view>
  93. <view class="top-options">
  94. <view
  95. class="option-btn"
  96. :class="{ 'active': rfColor === 'green' }"
  97. @click="handleRfColorChange('green')"
  98. >
  99. <view class="color-icon">
  100. <image src="../../static/my/greenRise.png" class="kline-icon" />
  101. </view>
  102. <text>绿涨红跌</text>
  103. <view class="active-dot" v-if="rfColor === 'green'"></view>
  104. </view>
  105. <view
  106. class="option-btn"
  107. :class="{ 'active': rfColor === 'red' }"
  108. @click="handleRfColorChange('red')"
  109. >
  110. <view class="color-icon">
  111. <image src="../../static/my/redRise.png" class="kline-icon" />
  112. </view>
  113. <text>红涨绿跌</text>
  114. <view class="active-dot" v-if="rfColor === 'red'"></view>
  115. </view>
  116. </view>
  117. <view class="title">副图指标个数</view>
  118. <view class="top-options">
  119. <view
  120. class="option-btn"
  121. :class="{ 'active': indexCount === 1 }"
  122. @click="handleIndexCountChange(1)"
  123. >
  124. <text>1</text>
  125. </view>
  126. <view
  127. class="option-btn"
  128. :class="{ 'active': indexCount === 2 }"
  129. @click="handleIndexCountChange(2)"
  130. >
  131. <text>2</text>
  132. </view>
  133. <view
  134. class="option-btn"
  135. :class="{ 'active': indexCount === 3 }"
  136. @click="handleIndexCountChange(3)"
  137. >
  138. <text>3</text>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="indicator-title">
  143. <text>指标设置</text>
  144. </view>
  145. <view class="indicator-list">
  146. <view class="indicator-item" v-for="(item, index) in indicatorList" :key="index">
  147. <text class="indicator-text">{{ item }}</text>
  148. <view class="indicator-icons">
  149. <image src="../../static/my/setting.png" class="icon" />
  150. <image src="../../static/my/menu.png" class="icon" />
  151. </view>
  152. </view>
  153. <view style="height:10vh;background-color: white;"></view>
  154. </view>
  155. </view>
  156. </template>
  157. <script setup>
  158. import { ref, onMounted } from 'vue'
  159. import { getMarketSetting, updateMarketSetting } from "@/api/setting/market"
  160. const iSMT = ref(0)
  161. const aStockBid = ref('auto') // A股竞价:auto/open/close
  162. const kStyle = ref('common') // K线样式:common/Outline/polylines
  163. const exRights = ref('exRights') // 除权类型:exRights/normal/Weighted
  164. const rfColor = ref('green') // 涨跌颜色:green/red
  165. const indexCount = ref(1) // 副图个数:1/2/3
  166. const indicatorList = ref(['K线', '均线', '成交量', 'KDJ', 'MACD', 'RSI'])
  167. const getMarketSettings = async () => {
  168. try {
  169. const res = await getMarketSetting()
  170. if (res.code === 200) {
  171. aStockBid.value = res.data.auctionDisplay ?? 'auto'
  172. kStyle.value = res.data.klineStyle ?? 'common'
  173. exRights.value = res.data.rightsIssueType ?? 'exRights'
  174. rfColor.value = res.data.priceColorScheme ?? 'green'
  175. indexCount.value = res.data.subChartCount ?? 1
  176. }
  177. } catch (err) {
  178. console.error("获取市场设置失败:", err)
  179. }
  180. }
  181. const updateSetting = async () => {
  182. try {
  183. const params = {
  184. auctionDisplay: aStockBid.value,
  185. klineStyle: kStyle.value,
  186. rightsIssueType: exRights.value,
  187. priceColorScheme: rfColor.value,
  188. subChartCount: indexCount.value
  189. }
  190. const res = await updateMarketSetting(params)
  191. if (res.code === 200) {
  192. uni.showToast({ title: '设置已更新', icon: 'none' })
  193. } else {
  194. uni.showToast({ title: '更新失败', icon: 'none' })
  195. }
  196. } catch (err) {
  197. console.error("更新设置失败:", err)
  198. uni.showToast({ title: '更新失败', icon: 'none' })
  199. }
  200. }
  201. const handleAStockBidChange = (newValue) => {
  202. if (newValue !== aStockBid.value) {
  203. aStockBid.value = newValue
  204. updateSetting()
  205. }
  206. }
  207. const handleKStyleChange = (newValue) => {
  208. if (newValue !== kStyle.value) {
  209. kStyle.value = newValue
  210. updateSetting()
  211. }
  212. }
  213. const handleExRightsChange = (newValue) => {
  214. if (newValue !== exRights.value) {
  215. exRights.value = newValue
  216. updateSetting()
  217. }
  218. }
  219. const handleRfColorChange = (newValue) => {
  220. if (newValue !== rfColor.value) {
  221. rfColor.value = newValue
  222. updateSetting()
  223. }
  224. }
  225. const handleIndexCountChange = (newValue) => {
  226. if (newValue !== indexCount.value) {
  227. indexCount.value = newValue
  228. updateSetting()
  229. }
  230. }
  231. onMounted(() => {
  232. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  233. getMarketSettings()
  234. })
  235. </script>
  236. <style scoped>
  237. .time-share-title {
  238. height: 4.5vh;
  239. padding: 0 40rpx;
  240. display: flex;
  241. align-items: center;
  242. }
  243. .title {
  244. height: 5.5vh;
  245. padding: 0 40rpx;
  246. display: flex;
  247. align-items: center;
  248. font-size: 26rpx;
  249. color: #666;
  250. }
  251. .top-options {
  252. display: flex;
  253. padding: 0 40rpx;
  254. }
  255. .option-btn {
  256. flex: 1;
  257. display: flex;
  258. align-items: center;
  259. justify-content: center;
  260. border: 1rpx solid #ddd;
  261. border-radius: 8rpx;
  262. margin: 0 10rpx;
  263. padding: 15rpx 0;
  264. font-size: 28rpx;
  265. }
  266. .option-btn.active {
  267. border-color: red;
  268. }
  269. .active-dot {
  270. width: 16rpx;
  271. height: 16rpx;
  272. background-color: red;
  273. border-radius: 50%;
  274. margin-left: 10rpx;
  275. }
  276. .kline-icon {
  277. margin-right: 10rpx;
  278. font-size: 32rpx;
  279. width:60rpx;
  280. height:50rpx;
  281. }
  282. .color-icon {
  283. margin-right: 10rpx;
  284. display: flex;
  285. gap: 4rpx;
  286. }
  287. .indicator-title {
  288. height: 6vh;
  289. padding: 0 40rpx;
  290. display: flex;
  291. align-items: center;
  292. }
  293. .indicator-list {
  294. display: flex;
  295. flex-direction: column;
  296. justify-content: center;
  297. padding: 0 40rpx;
  298. background-color: white;
  299. }
  300. .indicator-item {
  301. display: flex;
  302. align-items: center;
  303. height: 7.5vh;
  304. border-bottom: 1rpx solid #eee;
  305. }
  306. .indicator-text {
  307. font-size: 28rpx;
  308. flex: 1;
  309. }
  310. .indicator-icons {
  311. display: flex;
  312. gap: 100rpx;
  313. margin-left: auto;
  314. }
  315. .icon {
  316. width: 28rpx;
  317. height: 28rpx;
  318. }
  319. </style>