ThirdView.ets 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. import { yTRouter } from "basic";
  2. import { tagItemComp } from "../components/BuilderIndex";
  3. import { CustomTextStyle } from "../style/CustomTextStyle";
  4. import { ThirdViewModel } from "./viewModel/ThirdViewModel";
  5. @ComponentV2
  6. export struct ThirdView {
  7. vm: ThirdViewModel = new ThirdViewModel();
  8. build() {
  9. Column() {
  10. Column({space: 20}){
  11. Row(){
  12. Text('书包')
  13. .attributeModifier(new CustomTextStyle({size: 18, weight: 500, color: '#FF111111'}))
  14. }.justifyContent(FlexAlign.Center)
  15. this.classify()
  16. }
  17. .width('100%')
  18. .backgroundColor(Color.White)
  19. .padding({top: this.vm.safeTop, bottom: 15})
  20. .borderRadius({bottomLeft: 16, bottomRight: 16})
  21. Column(){
  22. if(true) {
  23. this.bookList()
  24. } else {
  25. this.emptyView()
  26. }
  27. }.width('100%').layoutWeight(1)
  28. .padding({left: 12, right: 12})
  29. // 底部按钮
  30. Row(){
  31. Row(){
  32. if(true) {
  33. Row().width(15).aspectRatio(1).borderRadius(15).border({width: 1})
  34. } else {
  35. Image($r('[basic].media.icon_select')).width(15).aspectRatio(1)
  36. }
  37. Text('全选')
  38. .margin({left: 6, right: 19})
  39. .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#80000000'}))
  40. Text(){
  41. Span('已选:')
  42. Span(`1`).fontWeight(700).fontColor('#FFFFC500')
  43. Span('本书').fontColor('#FF333333')
  44. }
  45. .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#80000000'}))
  46. }
  47. Row(){
  48. Text(this.vm.editMode ? '移除书包' : '立即借阅')
  49. .attributeModifier(new CustomTextStyle({
  50. size: 18,
  51. weight: 600,
  52. color: this.vm.editMode ? '#FFFECF2F' : '#FF000000'
  53. }))
  54. }
  55. .width(143)
  56. .borderRadius(25)
  57. .border({width: 2, color: this.vm.editMode ? '#FFFECF2F' : '#FF000000'})
  58. .backgroundColor(this.vm.editMode ? Color.White : '#FECF2F')
  59. .padding({top: 10, bottom: 10})
  60. .justifyContent(FlexAlign.Center)
  61. .onClick(() => {
  62. this.vm.clickButton()
  63. })
  64. }
  65. .height(60)
  66. .width("100%")
  67. .backgroundColor(Color.White)
  68. .justifyContent(FlexAlign.SpaceBetween)
  69. .padding({left: 17, top: 8, right: 17, bottom: 8})
  70. }
  71. .width('100%')
  72. .height('100%')
  73. .backgroundColor('#F7F9FA')
  74. }
  75. @Builder
  76. classify(){
  77. Row(){
  78. Row(){
  79. List({space: 15}){
  80. ForEach(this.vm.categoryList, (item: string, index) => {
  81. ListItem(){
  82. Column(){
  83. Text(item)
  84. .zIndex(99)
  85. .width(50)
  86. .textAlign(TextAlign.Center)
  87. .onClick(() => { this.vm.changeCategory(index) })
  88. .attributeModifier(new CustomTextStyle({size: 16, weight: 600, color: this.vm.categoryIndex == index ? '#FF111111' : '#FF777777'}))
  89. if(this.vm.categoryIndex == index){
  90. Image($r('[basic].media.icon_SelectBg'))
  91. .width(45)
  92. .height(16)
  93. .margin({top:-10})
  94. .transition(TransitionEffect.asymmetric(TransitionEffect.move(TransitionEdge.TOP), TransitionEffect.move(TransitionEdge.TOP)).animation({ duration: 100, curve: Curve.Smooth }))
  95. }
  96. }
  97. .alignItems(HorizontalAlign.Center)
  98. }
  99. })
  100. }
  101. .height(40)
  102. .width("100%")
  103. .padding({top: 10})
  104. .scrollBar(BarState.Off)
  105. .listDirection(Axis.Horizontal)
  106. }
  107. .layoutWeight(1)
  108. .alignItems(VerticalAlign.Center)
  109. Row(){
  110. Text(this.vm.editMode ? '完成' : '编辑')
  111. .attributeModifier(new CustomTextStyle({size: 14, weight: 600}))
  112. }
  113. .width(60)
  114. .borderRadius(25)
  115. .border({width: 2})
  116. .backgroundColor('#FECF2F')
  117. .padding({top: 8, bottom: 8})
  118. .justifyContent(FlexAlign.Center)
  119. .onClick(() => { this.vm.changeEditMode() })
  120. }
  121. .width("100%")
  122. .alignItems(VerticalAlign.Center)
  123. .padding({left: 16, right: 16})
  124. }
  125. @Builder
  126. emptyView(){
  127. Column(){
  128. Column(){
  129. this.tip()
  130. Column(){
  131. Image($r('[basic].media.png_schoolBag'))
  132. .width(115)
  133. .height(152)
  134. Text('书包空荡荡,赶快去选书!')
  135. .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#80000000'}))
  136. .margin({top: 18, bottom: 8})
  137. Text('去选书')
  138. .borderRadius(25)
  139. .backgroundColor('#FFFECF2F')
  140. .border({width: 2, color: '#FF000000'})
  141. .padding({left: 45, top: 10, right: 45, bottom: 10})
  142. .attributeModifier(new CustomTextStyle({size: 18, weight: 400, color: '#FF000000'}))
  143. }
  144. .width("100%")
  145. .layoutWeight(1)
  146. .alignItems(HorizontalAlign.Center)
  147. .justifyContent(FlexAlign.Center)
  148. }
  149. .width("100%")
  150. .height('100%')
  151. }
  152. }
  153. @Builder
  154. bookList(){
  155. List({space: 12}){
  156. ListItem(){
  157. this.tip()
  158. }
  159. ForEach(new Array(10).fill(1), (item: number, index) => {
  160. ListItem(){
  161. Row({space: 7}){
  162. Row(){
  163. if(index%2 == 1) {
  164. Row().width(15).aspectRatio(1).borderRadius(15).border({width: 1})
  165. } else {
  166. Image($r('[basic].media.icon_select')).width(15).aspectRatio(1)
  167. }
  168. }.height('100%')
  169. .onClick(() => { this.vm.changeSelect() })
  170. Row({space: 11}){
  171. Image($r('[basic].media.png_defaultBook'))
  172. .borderRadius(16)
  173. .width(86).aspectRatio(1)
  174. .backgroundColor('#FECF2F')
  175. Column(){
  176. Text('我不愿嫉妒')
  177. .attributeModifier(new CustomTextStyle({size: 14, weight: 400, color: '#FF111111'}))
  178. Row(){
  179. Text('哈哈哈哈哈哈哈哈哈哈')
  180. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#FF555555'}))
  181. }
  182. .width('100%').layoutWeight(1)
  183. .justifyContent(FlexAlign.Start)
  184. Row({space: 8}){
  185. tagItemComp('情绪价值', '#FF4EB1EF', '#FFEDF7FD')
  186. tagItemComp('3-8岁', '#FFFC9911', '#FFFFF5E7')
  187. }
  188. }
  189. .width("100%")
  190. .alignItems(HorizontalAlign.Start)
  191. }
  192. .onClick(() => {
  193. // todo 暂时注释
  194. // yTRouter.router2BookItemDetailPage()
  195. })
  196. }
  197. .width("100%")
  198. .height(102)
  199. .borderRadius(12)
  200. .border({width: 2})
  201. .backgroundColor(Color.White)
  202. .alignItems(VerticalAlign.Center)
  203. .padding({left: 9, top: 8, right: 9, bottom: 8})
  204. }
  205. .swipeAction({ end: () => { this.swipeAction() } })
  206. })
  207. }
  208. .width("100%").height("100%")
  209. .scrollBar(BarState.Off)
  210. }
  211. @Builder
  212. tip(){
  213. Row(){
  214. Row(){
  215. Image($r('[basic].media.icon_plaint')).width(13).aspectRatio(1)
  216. Text('单次可借阅10本书')
  217. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#80000000'}))
  218. }
  219. Text(){
  220. Span('新人首单')
  221. Span('¥19.9').fontColor('#FFFF0000')
  222. Span('可借')
  223. Span('5本').fontColor('#FFFF0000')
  224. }
  225. .attributeModifier(new CustomTextStyle({size: 12, weight: 400, color: '#80000000'}))
  226. }
  227. .width("100%")
  228. .padding({top: 10})
  229. .justifyContent(FlexAlign.SpaceBetween)
  230. }
  231. @Builder
  232. swipeAction(){
  233. Row(){
  234. Text('移除')
  235. .attributeModifier(new CustomTextStyle({size: 16, weight: 400, color: '#FFFFFFFF'}))
  236. }
  237. .height('100%')
  238. .borderRadius(12)
  239. .margin({left: 10})
  240. .backgroundColor(Color.Red)
  241. .alignItems(VerticalAlign.Center)
  242. .justifyContent(FlexAlign.Center)
  243. .padding({left: 15, right: 15})
  244. }
  245. }