MineViewController.swift 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565
  1. //
  2. // MineViewController.swift
  3. // MTP2_iOS
  4. //
  5. // Created by zhongyuan on 2018/3/16.
  6. // Copyright © 2018年 zhongyuan.All rights reserved.
  7. //
  8. import UIKit
  9. import WHToast
  10. import SDWebImage
  11. import SwiftyAttributes
  12. import GTMRefresh
  13. import IBAnimatable
  14. import SafariServices
  15. /// 我的主视图容器控制类
  16. class MineViewController: BaseViewController {
  17. // MARK: - 属性列表
  18. /// 滚动视图
  19. @IBOutlet weak var scrollView: UIScrollView!
  20. /// 内容填充视图
  21. @IBOutlet weak var contentView: UIView!
  22. /// 用户头像
  23. @IBOutlet weak var userImage: UIImageView!
  24. /// 用户名称
  25. @IBOutlet weak var userName: UILabel!
  26. /// 用户手机号码
  27. @IBOutlet weak var mobile: UILabel!
  28. /// 余额
  29. @IBOutlet weak var blance: UILabel!
  30. /// 冻结余额
  31. @IBOutlet weak var freeze: UILabel!
  32. /// 市值
  33. @IBOutlet weak var amount: UILabel!
  34. /// 眼睛
  35. @IBOutlet weak var eye: UIButton!
  36. /// 优惠券数量
  37. @IBOutlet weak var couponCount: AnimatableLabel! {
  38. didSet {
  39. couponCount.layer.masksToBounds = true
  40. couponCount.isHidden = true
  41. }
  42. }
  43. /// 优惠券
  44. @IBOutlet weak var coupon: UIButton! {
  45. didSet {
  46. coupon.setTitle(MTP2BusinessCore.shared.getLoginStatus() ? "优惠券" : "注册", for: .normal)
  47. coupon.setImage(UIImage(named: MTP2BusinessCore.shared.getLoginStatus() ? "coupon" : ""), for: .normal)
  48. }
  49. }
  50. /// 提现
  51. @IBOutlet weak var recharge_out: UIButton! {
  52. didSet {
  53. recharge_out.setTitle(MTP2BusinessCore.shared.getLoginStatus() ? "提现" : "登录", for: .normal)
  54. recharge_out.setImage(UIImage(named: MTP2BusinessCore.shared.getLoginStatus() ? "mine_recharge_out" : ""), for: .normal)
  55. }
  56. }
  57. /// 资金视图
  58. @IBOutlet weak var taaccountView: UIStackView! {
  59. didSet {
  60. taaccountView.isHidden = !MTP2BusinessCore.shared.getLoginStatus()
  61. }
  62. }
  63. /// 余额视图
  64. @IBOutlet weak var blanceView: UIStackView! {
  65. didSet {
  66. blanceView.isHidden = !MTP2BusinessCore.shared.getLoginStatus()
  67. }
  68. }
  69. /// 未登录
  70. @IBOutlet weak var unLogin: UIView! {
  71. didSet {
  72. unLogin.isHidden = MTP2BusinessCore.shared.getLoginStatus()
  73. }
  74. }
  75. /// 账户视图
  76. @IBOutlet weak var accountView: UIStackView! {
  77. didSet {
  78. accountView.isHidden = !MTP2BusinessCore.shared.getLoginStatus()
  79. }
  80. }
  81. /// 操作视图
  82. @IBOutlet weak var operationView: UIStackView!
  83. /// 设置
  84. @IBOutlet weak var settings: UIButton!
  85. /// 单据 待成交
  86. @IBOutlet weak var order_during: UIButton!
  87. /// 单据 待付款
  88. @IBOutlet weak var order_transfering: UIButton!
  89. /// 单据 已完成
  90. @IBOutlet weak var order_completed: UIButton!
  91. /// 我的订单
  92. @IBOutlet weak var order_my: UIButton!
  93. /// 包裹 待发货
  94. @IBOutlet weak var packet_unsend: UIButton!
  95. /// 包裹 待收货
  96. @IBOutlet weak var packet_unrecive: UIButton!
  97. /// 包裹 已完成
  98. @IBOutlet weak var packet_completed: UIButton!
  99. /// 我的包裹
  100. @IBOutlet weak var packet_my: UIButton!
  101. /// 我的商品
  102. @IBOutlet weak var tableView: UITableView! {
  103. didSet {
  104. tableView.layer.shadowRadius = 5.0
  105. tableView.layer.shadowOffset = CGSize(width: 5.0, height: 5.0)
  106. tableView.layer.shadowColor = UIColorFromHex(rgbValue: 0xe6e6e6).cgColor
  107. tableView.layer.shadowOpacity = 0.5
  108. tableView.layer.cornerRadius = 10.0
  109. }
  110. }
  111. /// 新闻咨询列表高度
  112. @IBOutlet weak var tableViewHeightConstraint: NSLayoutConstraint!
  113. /// MyOrdersCellIdentifier
  114. let MyOrdersCellIdentifier = "MyOrders_Cell"
  115. /// 是否显示资金
  116. var isOpen: Bool = true {
  117. didSet {
  118. /// 替换图片资源
  119. self.eye.setImage(UIImage(named: isOpen ? "mine_eyes_opened" : "mine_eyes_closed"), for: .normal)
  120. /// 资金信息
  121. showAccountInfo(isOpen)
  122. }
  123. }
  124. /// 我的商品数据信息
  125. var myGoods: [MoHsbyMyGoods] = [] {
  126. didSet {
  127. /// 动态设置高度
  128. tableViewHeightConstraint.constant = myGoods.count < 5 ? 400.0 : 107.0*CGFloat(myGoods.count)+40.0
  129. /// 刷新列表数据
  130. tableView.reloadData()
  131. /// 资金信息
  132. showAccountInfo(isOpen)
  133. if myGoods.count > 0 {
  134. /// 等待UI操作完成,也就是tableView刷新完之后执行
  135. DispatchQueue.main.async { [weak self] in
  136. if self?.visibleGoodsCodes.count != 0 { self?.shouldSubscriptGoodsCodes = self?.visibleGoodsCodes }
  137. }
  138. }
  139. }
  140. }
  141. // MARK: - 生命周期
  142. required init?(coder aDecoder: NSCoder) {
  143. super.init(coder: aDecoder)
  144. /// 设置TabBar图片
  145. self.tabBarItem.image = UIImage(named: "mine_normal")?.withRenderingMode(.alwaysOriginal)
  146. self.tabBarItem.selectedImage = UIImage(named: "mine_selected")?.withRenderingMode(.alwaysOriginal)
  147. }
  148. override func viewWillAppear(_ animated: Bool) {
  149. super.viewWillAppear(animated)
  150. /// 隐藏导航栏
  151. self.navigationController?.setNavigationBarHidden(true, animated: true)
  152. /// 解决页面切换设置按钮显示问题
  153. if !self.operationView.arrangedSubviews.contains(settings) {
  154. self.operationView.insertArrangedSubview(settings, at: 0)
  155. }
  156. }
  157. override func viewDidLoad() {
  158. super.viewDidLoad()
  159. // Do any additional setup after loading the view.
  160. /// 不需要返回按钮
  161. addBackBarButtonItem(true)
  162. /// UI界面初始化
  163. buildView()
  164. /// 数据初始化
  165. initData()
  166. }
  167. override func viewDidAppear(_ animated: Bool) {
  168. super.viewDidAppear(animated)
  169. /// 当前已登录
  170. if let _ = MTP2BusinessCore.shared.accountManager?.loginRsp {
  171. /// 重置数量
  172. reuestData()
  173. }
  174. }
  175. override func didMove(toParent parent: UIViewController?) {
  176. super.didMove(toParent: parent)
  177. /// 侦听行情推送广播
  178. MTP2BusinessCore.shared.broadcastManager?.addBroadcastListener(owner: self, action: .ReceiveTradeQuote) { [unowned self] in
  179. guard let quoteGoodsInfos = $0.object as? [(goodsHqCode: String, exchHqCode: String)] else { return }
  180. /// 有数据
  181. if quoteGoodsInfos.count != 0 {
  182. /// 待刷新行
  183. var refreshIndexPaths = [IndexPath]()
  184. DispatchQueue.main.async {
  185. for (index, cell) in self.tableView.visibleCells.enumerated() {
  186. if quoteGoodsInfos.first(where: { $0.goodsHqCode == (cell as? MyOrdersCell)?.model?.goodscode }) != nil {
  187. let indexPath = IndexPath(row: index, section: 0)
  188. if refreshIndexPaths.firstIndex(of: indexPath) == nil {
  189. /// 记录待刷新行
  190. /// 判断是否在可见区域
  191. if self.tableView.cellForRow(at: indexPath) != nil {
  192. refreshIndexPaths.append(indexPath)
  193. }
  194. }
  195. }
  196. }
  197. }
  198. /// 刷新行情列表
  199. if refreshIndexPaths.count > 0 {
  200. DispatchQueue.main.async {
  201. self.tableView.reloadRows(at: refreshIndexPaths, with: .none)
  202. /// 刷新资金
  203. if self.isOpen {
  204. self.showAccountInfo(self.isOpen)
  205. }
  206. }
  207. }
  208. }
  209. }
  210. }
  211. override func viewDidDisappear(_ animated: Bool) {
  212. super.viewDidDisappear(animated)
  213. /// 清除广播侦听
  214. MTP2BusinessCore.shared.broadcastManager?.removeBroadcastListener(owner: self, forName: .ReceiveTradeQuote)
  215. }
  216. // MARK: - 初始化相关
  217. /// UI界面初始化
  218. func buildView() {
  219. /// 数据异常
  220. guard let accountManager = MTP2BusinessCore.shared.accountManager else { return }
  221. /// LoadingView
  222. self.addLoadingView()
  223. /// 当前已登录
  224. if let _ = accountManager.loginRsp {
  225. /// 用户名
  226. if let accountName = accountManager.moAccountBaseInfo?.accountInfo.accountName {
  227. self.userName.attributedText = "\(accountName) ".withFont(.font_16).withTextColor(UIColorFromHex(rgbValue: 0x72aee2))+" 账户 ".withFont(.font_12).withTextColor(UIColorFromHex(rgbValue: 0x999999)).withBackgroundColor(UIColorFromHex(rgbValue: 0xf5f5f5))
  228. }
  229. /// 手机号
  230. if let mobile = accountManager.moAccountBaseInfo?.accountInfo.mobile {
  231. self.mobile.text = mobile
  232. }
  233. /// 添加下拉刷新控件
  234. self.scrollView.gtm_addRefreshHeaderView(refreshHeader: DefaultGTMRefreshHeader()) {
  235. /// 重置请求条件
  236. self.reuestData()
  237. }
  238. /// 触发自动加载
  239. self.scrollView.triggerRefreshing()
  240. } else {
  241. /// 您还未登录,请登录后查看!
  242. self.noDataButton.set(image: nil, title: "您还未登录,请登录后查看!", titlePosition: .bottom, additionalSpacing: 0.0, state: .normal)
  243. self.noDataButton.isHidden = false
  244. }
  245. }
  246. /// 数据初始化
  247. fileprivate func initData() {
  248. /// 默认不显示
  249. isOpen = false
  250. }
  251. /// 显示资金账户信息
  252. /// - Parameter isOpen: isOpen
  253. fileprivate func showAccountInfo(_ isOpen: Bool) {
  254. /// 异常
  255. guard let accountManager = MTP2BusinessCore.shared.accountManager,
  256. let accountId = accountManager.getCurrentTAAccountInfo()?.accountId,
  257. let moCalculate = MTP2BusinessCore.shared.getCalculate(accountId) else {
  258. return
  259. }
  260. accountManager.loginQueryReq(queryItem: "1,2") { (isComplete, error) in
  261. DispatchQueue.main.async {
  262. let taAccountInfo = accountManager.getCurrentTAAccountInfo()
  263. /// 余额
  264. self.blance.attributedText = (!isOpen ? "******" : taAccountInfo?.currentBalance.toDownString(reserve: 2))!.withFont(.font_22).withTextColor(UIColorFromHex(rgbValue: 0x333333))
  265. /// 冻结余额 冻结保证金+其他冻结保证金+冻结手续费
  266. let freezeAmount = (taAccountInfo?.freezeMargin ?? 0.0)+(taAccountInfo?.otherFreezeMargin ?? 0.0)+(taAccountInfo?.freezeCharge ?? 0.0)
  267. self.freeze.text = "\(!isOpen ? "******" : freezeAmount.toDownString(reserve: 2))"
  268. /// 市值
  269. self.amount.text = "\(!isOpen ? "******" : moCalculate.totalAmount.toDownString(reserve: 2))"
  270. }
  271. }
  272. }
  273. // MARK: 交互相关
  274. /// 按钮点击交互事件
  275. ///
  276. /// - Parameter sender: sender
  277. @IBAction func onButtonPressed(_ sender: UIButton) {
  278. switch sender {
  279. case order_during: /// 单据 购买中
  280. self.pushController("Order", "Order", 1)
  281. case order_transfering: /// 单据 转让中
  282. self.pushController("Order", "Order", 2)
  283. case order_completed: /// 单据 已完成
  284. self.pushController("Order", "Order", 3)
  285. case order_my: /// 我的订单
  286. self.pushController("Order", "Order", 0)
  287. case packet_unsend: /// 包裹 待发货
  288. self.pushController("Order", "Packet", 1)
  289. case packet_unrecive: /// 包裹 待收货
  290. self.pushController("Order", "Packet", 2)
  291. case packet_completed: /// 包裹 已完成
  292. self.pushController("Order", "Packet", 3)
  293. case packet_my: /// 我的包裹
  294. self.pushController("Order", "Packet", 0)
  295. case coupon: /// 我的优惠券
  296. if MTP2BusinessCore.shared.getLoginStatus() { /// 当前已登录
  297. self.push(storyboardName: "Coupon", storyboardId: "Coupon")
  298. } else {
  299. guard let url = URL(string: MTP2BusinessCore.shared.address?.mobileOpenUrl ?? "") else { return }
  300. let safriViewController = SFSafariViewController(url: url)
  301. safriViewController.delegate = self
  302. self.present(safriViewController, animated: true, completion: {})
  303. }
  304. case recharge_out: /// 提现
  305. if MTP2BusinessCore.shared.getLoginStatus() { /// 当前已登录
  306. querySign(storyboardName: "OutInMoney", storyboardId: "OutInMoneyViewID", takeInfo: 0)
  307. } else { /// 跳转到登录页面
  308. self.push(storyboardName: "Main", storyboardId: "Login")
  309. }
  310. case eye: /// 眼睛按钮
  311. isOpen = !isOpen
  312. case settings: /// 系统设置
  313. self.push(storyboardName: "Settings", storyboardId: "Settings", checkLogin: false)
  314. default:
  315. break
  316. }
  317. }
  318. /// 页面绑定跳转
  319. /// - Parameters:
  320. /// - controller: BaseViewController
  321. /// - index: 跳转到指定页面
  322. fileprivate func pushController(_ storyboardName: String,
  323. _ storyboardId: String,
  324. _ index: Int = 0) {
  325. if MTP2BusinessCore.shared.getLoginStatus() { /// 当前已登录
  326. guard let viewController = UIStoryboard(name: storyboardName, bundle: nil).instantiateViewController(withIdentifier: storyboardId) as? BaseViewController else { return }
  327. self.navigationController?.pushViewController(viewController, animated: true)
  328. viewController.selectedIndex = index
  329. } else {
  330. self.push(storyboardName: "Main", storyboardId: "Login")
  331. }
  332. }
  333. // MARK: - 接口请求
  334. /// 查询是否已签约
  335. func querySign(storyboardName: String, storyboardId: String, takeInfo: Int) {
  336. /// 异常
  337. guard let bankManager = MTP2BusinessCore.shared.bankManager,
  338. let accountManager = MTP2BusinessCore.shared.accountManager,
  339. let accountID = accountManager.getCurrentTAAccountInfo()?.accountId else { return }
  340. _anim?.startAnimating()
  341. /// 查询是否已签约
  342. bankManager.bankSign(accountId: UInt64(accountID), cusbankId: "") { (isSuccess, errorInfo, results) in
  343. DispatchQueue.main.async {
  344. self._anim?.stopAnimating()
  345. if isSuccess {
  346. if let results = results,
  347. results.bankSign.first(where: { $0.signStatus == ESignStatus.SIGNSTATUS_SIGNED.rawValue }) != nil {
  348. /// 出入金
  349. self.push(storyboardName: storyboardName, storyboardId: storyboardId, takeInfo: takeInfo)
  350. } else {
  351. self.showYesOrNOController(title: "提示", message: "您好!请进行签约后,再使用出入金", handler: { (_) in
  352. if TradeControlUtils.checkAuthState(navigationController: self.navigationController) {
  353. /// 打开签约界面
  354. if let _ = (UIStoryboard(name: "Settings", bundle: nil).instantiateViewController(withIdentifier: "SigningMain")) as? SigningMainViewController {
  355. DispatchQueue.main.async {
  356. self.pushController("Settings", "SigningMain")
  357. }
  358. }
  359. }
  360. })
  361. }
  362. } else {
  363. self.showErrorMessgae(error: errorInfo)
  364. }
  365. }
  366. }
  367. }
  368. /// 数据加载
  369. fileprivate func reuestData() {
  370. /// 异常
  371. guard let orderManager = MTP2BusinessCore.shared.orderManager else { return }
  372. /// DispatchGroup
  373. let group = DispatchGroup()
  374. /// 查询我的单据数量
  375. group.enter()
  376. orderManager.requestGetHsbyMyCount { (isComplete, error, myCount) in
  377. DispatchQueue.main.async {
  378. if isComplete {
  379. if let preCount = myCount?.myOrderDetailPreCount, let listingCount = myCount?.myOrderDetailListingCount {
  380. self.order_during.fl_badgeValue = "\(preCount+listingCount)"
  381. }
  382. if let count = myCount?.myPayOrderCount {
  383. self.order_transfering.fl_badgeValue = count == 0 ? "" : "\(count)"
  384. }
  385. if let count = myCount?.myPackageUnSendCount {
  386. self.packet_unsend.fl_badgeValue = count == 0 ? "" : "\(count)"
  387. }
  388. if let count = myCount?.myPackageUnReceiveCount {
  389. self.packet_unrecive.fl_badgeValue = "\(count)"
  390. }
  391. /// 优惠券数量
  392. if let count = myCount?.myCouponCount, count != 0 {
  393. self.couponCount.text = "\(count)"
  394. self.couponCount.isHidden = false
  395. } else {
  396. self.couponCount.isHidden = true
  397. }
  398. }
  399. }
  400. group.leave()
  401. }
  402. /// 查询我的商品数据请求
  403. group.enter()
  404. orderManager.requestQueryHsbyMyGoods { (isComplete, error, goods) in
  405. DispatchQueue.main.async {
  406. if isComplete {
  407. self.myGoods = goods ?? []
  408. } else {
  409. self.myGoods = []
  410. WHToast.showError(withMessage: "数据查询失败,原因:\(error?.retMsg ?? "未知错误")", duration: 1.5, finishHandler: {})
  411. }
  412. }
  413. group.leave()
  414. }
  415. group.notify(queue: DispatchQueue.main) {
  416. /// 停止加载
  417. self.scrollView.endRefreshing()
  418. }
  419. }
  420. // MARK: - 订阅行情相关
  421. var uuid: String = UUID().uuidString
  422. var shouldSubscriptGoodsCodes: Set<String>? {
  423. didSet {
  424. guard let quoteSubscriptManager = MTP2BusinessCore.shared.quoteSubscriptManager else { return }
  425. quoteSubscriptManager.updateQuoteSubcriptGoods(uuid: uuid, goodsCode: shouldSubscriptGoodsCodes ?? [])
  426. }
  427. }
  428. var visibleGoodsCodes: Set<String> {
  429. var goodsCodes = Set<String>()
  430. self.tableView.visibleCells.forEach { (cell) in
  431. if let quoteCell = cell as? MyOrdersCell,
  432. let goodsCode = quoteCell.model?.goodscode {
  433. goodsCodes.insert(goodsCode)
  434. }
  435. }
  436. return goodsCodes
  437. }
  438. }
  439. // MARK: - UIScrollViewDelegate
  440. extension MineViewController: UIScrollViewDelegate {
  441. func scrollViewDidScroll(_ scrollView: UIScrollView) {
  442. if scrollView.contentOffset.y >= 20.0 {
  443. self.navigationController?.setNavigationBarHidden(false, animated: true)
  444. self.navigationItem.rightBarButtonItem = UIBarButtonItem(customView: settings)
  445. } else {
  446. self.navigationController?.setNavigationBarHidden(true, animated: true)
  447. self.operationView.insertArrangedSubview(settings, at: 0)
  448. }
  449. }
  450. }
  451. // MARK: - 初始化相关
  452. extension MineViewController: UITableViewDelegate, UITableViewDataSource {
  453. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  454. return myGoods.count
  455. }
  456. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  457. let cell = tableView.dequeueReusableCell(withIdentifier: MyOrdersCellIdentifier, for: indexPath) as! MyOrdersCell
  458. cell.model = myGoods[indexPath.row]
  459. return cell
  460. }
  461. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  462. return 115.0
  463. }
  464. func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  465. /// 商品详情
  466. guard let goods = MTP2BusinessCore.shared.goodsManager?.goodsInfos.first(where: {$0.goodsid == myGoods[indexPath.row].goodsid}) else { return }
  467. let goodsDetailController = UIStoryboard(name: "Quote", bundle: nil).instantiateViewController(withIdentifier: "GoodsDetail") as! GoodsDetailViewController
  468. goodsDetailController.model = goods
  469. self.navigationController?.pushViewController(goodsDetailController, animated: true)
  470. }
  471. }
  472. extension MineViewController: SFSafariViewControllerDelegate {
  473. func safariViewControllerDidFinish(_ controller: SFSafariViewController) {
  474. controller.dismiss(animated: true, completion: {})
  475. }
  476. }
  477. // MARK: - MyOrdersCell
  478. class MyOrdersCell: BaseTableViewCell<MoHsbyMyGoods> {
  479. /// 商品代码
  480. @IBOutlet weak var orderNo: UILabel!
  481. /// 商品图片
  482. @IBOutlet weak var goodsImage: UIImageView!
  483. /// 价格
  484. @IBOutlet weak var price: UILabel!
  485. /// 金额
  486. @IBOutlet weak var amount: UILabel!
  487. /// 当前价值
  488. @IBOutlet weak var market: UILabel!
  489. /// 标题
  490. @IBOutlet weak var title: UILabel!
  491. /// 数量
  492. @IBOutlet weak var qty: UILabel!
  493. override var model: MoHsbyMyGoods? {
  494. didSet{
  495. /// 异常
  496. guard let obj = model else { return }
  497. /// 如果有商品
  498. if let goodsInfo = MTP2BusinessCore.shared.goodsManager?.goodsInfos.first(where: {$0.goodsid == obj.goodsid}),
  499. goodsInfo.getLast() != 0.0 {
  500. market.text = "当前价值:\((goodsInfo.getLast()*Double(obj.buycurpositionqty)*goodsInfo.agreeUnit).toDownString(reserve: obj.decimalplace))"
  501. } else {
  502. market.text = "当前价值:\(obj.currencysign+(obj.buycurholderamount.toDownString(reserve: obj.decimalplace)))"
  503. }
  504. /// 金额
  505. amount.text = "购入金额:\(obj.currencysign)\(obj.buycurholderamount.toDownString(reserve: obj.decimalplace))"
  506. /// 价格
  507. price.text = obj.currencysign+"\(obj.buyaverageprice)"
  508. /// 数量
  509. qty.text = "×\(obj.buycurpositionqty)"
  510. /// 标题
  511. title.text = obj.goodsname
  512. /// 商品代码
  513. orderNo.text = obj.goodscode
  514. /// 商品图片
  515. guard let url = StringUtils.getImageUrl(obj.picurls) else { return }
  516. goodsImage.sd_setImage(with: url, placeholderImage: UIImage(named: "placeholder_image"), options: .queryDiskDataSync, context: nil)
  517. }
  518. }
  519. }