updown.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view class="page">
  3. <u-checkbox-group @change="checkboxGroupChange">
  4. <view class="item u-flex" v-for="(item,index) in list" :key="index">
  5. <u-checkbox :name='item.id' shape="circle" v-model="item.checked"></u-checkbox>
  6. <view class="box">
  7. <image :src="item.image" style="width: 120rpx ;height: 160rpx;" mode=""></image>
  8. </view>
  9. <view class=""
  10. style="justify-content: space-between;padding: 4rpx 0 ;height: 160rpx;display: flex;flex-direction: column;">
  11. <view class="">
  12. <view class="title u-line-1">{{item.title}}</view>
  13. <view class="writer" v-if='item.price>0'>资源类型:付费资源</view>
  14. <view class="writer" v-if='item.price==0'>资源类型:免费资源</view>
  15. </view>
  16. <view class="money">¥{{item.price}}</view>
  17. </view>
  18. </view>
  19. </u-checkbox-group>
  20. <view class="" style="height: 160rpx;"></view>
  21. <view class="bottom u-flex u-row-between">
  22. <view class="u-flex">
  23. <view class="" >
  24. <u-checkbox-group>
  25. <u-checkbox @change="checkedAll" shape="circle" v-model="all"></u-checkbox>
  26. </u-checkbox-group>
  27. <text class="All">全选</text>
  28. </view>
  29. <view class="" style="margin-left: 24rpx;">
  30. <view class="">
  31. <text class="all">合计:</text>
  32. <text class="mi">¥</text>
  33. <text class="mi" style="font-size: 36rpx;">{{Number(sum).toFixed(2)}}</text>
  34. </view>
  35. <view class="">
  36. <text class="num">{{aaa.length}}</text>
  37. <text class="fcai">份资料</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="btn" @click="orderinfo">
  42. 下载资源
  43. </view>
  44. </view>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. change: 0,
  52. all: false,
  53. list: [],
  54. series_id: '',
  55. orderid: '',
  56. sum: 0,
  57. aaa:[]
  58. };
  59. },
  60. onLoad(options) {
  61. this.series_id = options.id
  62. this.getSeriesBooks()
  63. },
  64. methods: {
  65. getsum() {
  66. this.sum = 0
  67. for (var i = 0; i < this.list.length; i++) {
  68. if (this.list[i].checked) {
  69. this.sum += Number(this.list[i].price)
  70. }
  71. }
  72. },
  73. checkboxChange(e) {
  74. // this.$set(this.list[e.name], 'checked', e.value)
  75. this.getsum()
  76. },
  77. // 系列列表
  78. getSeriesBooks() {
  79. this.$u.post('api/books/getSeriesBooks', {
  80. series_id: this.series_id
  81. }).then(res => {
  82. this.list = res.data
  83. this.list.map(item => {
  84. item.checked = false
  85. })
  86. this.list = JSON.parse(JSON.stringify(this.list))
  87. })
  88. },
  89. //订单确认
  90. orderinfo() {
  91. this.$u.post('api/order/createOrder', {
  92. goods_id: '1,2',
  93. type: 0
  94. }).then(res => {
  95. if (res.code == 1) {
  96. this.orderid = res.data.id
  97. setTimeout(() => {
  98. uni.navigateTo({
  99. url: '/pages/index/orderinfo?id=' + this.orderid + "&index=" + 2
  100. })
  101. }, 800)
  102. }
  103. })
  104. },
  105. //全选
  106. checkedAll(e) {
  107. console.log(e);
  108. if (e.value == true) {
  109. this.list.map(val => {
  110. val.checked = true;
  111. })
  112. this.aaa = this.list
  113. } else {
  114. this.list.map(val => {
  115. val.checked = false;
  116. })
  117. this.aaa = []
  118. }
  119. this.getsum()
  120. },
  121. checkboxGroupChange(e) {
  122. if (e.length == this.list.length) {
  123. this.all = true
  124. }else{
  125. this.all = false
  126. }
  127. this.getsum()
  128. this.aaa = e
  129. // this.list.map(val => {
  130. // if (val.checked == false) {
  131. // this.all = false
  132. // }
  133. // })
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="scss">
  139. .num {
  140. font-size: 28rpx;
  141. font-family: JDZhengHT, JDZhengHT;
  142. font-weight: 400;
  143. color: #CF1534;
  144. }
  145. .fcai {
  146. font-size: 24rpx;
  147. font-family: PingFangSC, PingFang SC;
  148. font-weight: 400;
  149. color: #131415;
  150. }
  151. .All {
  152. font-size: 24rpx;
  153. font-family: PingFangSC, PingFang SC;
  154. font-weight: 400;
  155. color: #888888;
  156. margin-left: -16rpx
  157. }
  158. .mi {
  159. font-size: 28rpx;
  160. font-family: JDZhengHT, JDZhengHT;
  161. font-weight: 400;
  162. color: #CF1534;
  163. }
  164. .all {
  165. font-size: 26rpx;
  166. font-family: PingFangSC, PingFang SC;
  167. font-weight: 400;
  168. color: #131415;
  169. }
  170. .btn {
  171. width: 252rpx;
  172. height: 88rpx;
  173. background: #06A971;
  174. border-radius: 12rpx;
  175. font-size: 32rpx;
  176. font-family: PingFangSC, PingFang SC;
  177. font-weight: 500;
  178. color: #FFFFFF;
  179. line-height: 88rpx;
  180. text-align: center;
  181. }
  182. .money {
  183. font-size: 32rpx;
  184. font-family: SFPro, SFPro;
  185. font-weight: 400;
  186. color: #CF1534;
  187. }
  188. .title {
  189. width: 402rpx;
  190. font-size: 28rpx;
  191. font-family: PingFangSC, PingFang SC;
  192. font-weight: 500;
  193. color: #222222;
  194. }
  195. .writer {
  196. font-size: 24rpx;
  197. font-family: PingFangSC, PingFang SC;
  198. font-weight: 400;
  199. color: #444444;
  200. margin-top: 12rpx;
  201. }
  202. .box {
  203. width: 160rpx;
  204. height: 160rpx;
  205. border: 1rpx solid rgba(151, 151, 151, 0.1);
  206. padding: 0 20rpx;
  207. }
  208. .bottom {
  209. width: 100%;
  210. height: 166rpx;
  211. background: #FFFFFF;
  212. position: fixed;
  213. bottom: 0;
  214. left: 0;
  215. padding: 0 28rpx;
  216. }
  217. .item {
  218. width: 100%;
  219. height: 216rpx;
  220. background: #FFFFFF;
  221. border-radius: 16rpx;
  222. margin-top: 20rpx;
  223. padding: 28rpx 24rpx;
  224. }
  225. .page {
  226. background-color: #f4f4f4;
  227. min-height: 100vh;
  228. padding: 0 28rpx;
  229. overflow: hidden;
  230. }
  231. </style>