index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="" :style="{'--status-bar-': statusBarHeight}">
  3. <u-navbar title="选择下级分销商" :placeholder="true" @leftClick="leftClick" :autoBack="false" :safeAreaInsetTop="true">
  4. </u-navbar>
  5. <view class="item-list">
  6. <!-- <view class="til u-flex u-row-between" :style="{top:navHeight+'px'}">
  7. <u-checkbox-group @change="allCheckboxChange">
  8. <u-checkbox shape="circle" :checked="allChecked" :name="allCheckbox.name"
  9. label="观影人列表"></u-checkbox>
  10. </u-checkbox-group>
  11. </view> -->
  12. <u-checkbox-group placement="column" @change="checkboxChange">
  13. <view v-for="(item,index) in dataList" :key="item.id" class="item u-flex">
  14. <u-checkbox shape="circle" activeColor="#ED0000" :key="index"
  15. :name="item.name" :checked="item.checked" @change="toggleCheck(index)" class="checkbox" />
  16. <view class="text u-flex u-row-between" @click="toggleCheck(index)">
  17. <view class="name">{{item.name}}</view>
  18. <view class="withdrawTotal">可体现余额:<text class="num"> ¥ {{item.withdrawTotal}}</text></view>
  19. </view>
  20. </view>
  21. </u-checkbox-group>
  22. </view>
  23. <view class="cart-bottom">
  24. <view class="inner u-flex u-row-between">
  25. <view class="left u-flex">
  26. <view class="checkbox" @click="checkboxClick" style="padding: 10px;">
  27. <u-checkbox-group @change="allCheckboxChange">
  28. <u-checkbox shape="circle" :checked="allChecked" activeColor="#ED0000" :name="allCheckbox.name"
  29. label="全选"></u-checkbox>
  30. </u-checkbox-group>
  31. </view>
  32. <view class="total-price-wrap u-flex">
  33. <view class="total">共{{selectGoods.length}}人</view>
  34. <view class="totalPrice u-flex">
  35. 合计: <text class="num"> {{totalPrice}}</text>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="btn active" v-if="selectGoods.length>0&&cansubmit" @click="submitorder">确定</view>
  40. <view class="btn" v-else>确定</view>
  41. </view>
  42. </view>
  43. <u-toast ref="uToast"></u-toast>
  44. </view>
  45. </template>
  46. <script>
  47. // import {
  48. // systemInfo
  49. // } from "@/mixin.js";
  50. export default {
  51. // mixins: [systemInfo], // 使用mixin
  52. data() {
  53. return {
  54. statusBarHeight: 0, // 状态栏安全距离
  55. orderId: '',
  56. cansubmit: true,
  57. staticUrl: this.$commonConfig.staticUrl,
  58. allCheckbox: {
  59. name: '全选'
  60. },
  61. options: [{
  62. text: '删除',
  63. style: {
  64. backgroundColor: '#FF3C3F',
  65. 'padding-left': '10px'
  66. }
  67. }],
  68. // 购物车列表
  69. dataList: [],
  70. }
  71. },
  72. computed: {
  73. // 是否全选
  74. allChecked() {
  75. return this.dataList.every(item => item.checked)
  76. },
  77. selectGoods() {
  78. let selectGoods = [];
  79. this.dataList.forEach(item => {
  80. if (item.checked) {
  81. selectGoods.push(item)
  82. }
  83. })
  84. return selectGoods
  85. },
  86. // 合计价格
  87. totalPrice() {
  88. let that = this;
  89. return this.dataList.reduce((total, item) => {
  90. if (item.checked) {
  91. let price = null;
  92. total += item.withdrawTotal;
  93. }
  94. return total;
  95. }, 0).toFixed(2);
  96. }
  97. },
  98. onLoad(page) {
  99. // this.getSystemInfo();
  100. this.statusBarHeight = getApp().globalData.statusBarHeight;
  101. this.orderId = page.id;
  102. },
  103. onShow() {
  104. this.getViewers();
  105. },
  106. methods: {
  107. leftClick(e) {
  108. uni.reLaunch({
  109. url: '/pages/main/index'
  110. });
  111. console.log('leftClick', e);
  112. },
  113. // 切换全选状态
  114. allCheckboxChange(n) {
  115. // console.log('allCheckboxChange',n[0]);
  116. console.log('allCheckboxChange', n);
  117. let selectAll = n[0] ? true : false;
  118. this.dataList.forEach(item => {
  119. item.checked = selectAll
  120. })
  121. },
  122. checkboxClick() {
  123. // console.log('checkboxClick',this.allChecked);
  124. this.dataList.forEach(item => {
  125. item.checked = !this.allChecked
  126. })
  127. },
  128. checkboxChange(n) {
  129. // console.log('checkboxChange',n);
  130. },
  131. // 切换商品选中状态
  132. toggleCheck(index) {
  133. // console.log('toggleCheck',index);
  134. // if(this.dataList[index].status !== 3){
  135. // uni.showToast({
  136. // icon:'none',
  137. // title:'该状态不能退款',
  138. // duration:1000
  139. // })
  140. // return
  141. // }
  142. this.dataList[index].checked = !this.dataList[index].checked
  143. },
  144. submitorder() {
  145. let personList = this.selectGoods.map(item=>{
  146. return {personsId:item.id,withdrawTotal:item.withdrawTotal}
  147. });
  148. let params = {
  149. withdrawTotal:this.totalPrice,
  150. personList:JSON.stringify(personList)
  151. };
  152. // console.log('selectGoods', this.selectGoods);
  153. uni.$u.route('/pages/cash/index', params);
  154. },
  155. getViewers() {
  156. this.$u.api.distributorList({
  157. userid: this.distribution_user_info.userId
  158. }).then(res => {
  159. this.dataList = res.data.list.map(item => {
  160. item.checked = false;
  161. return {
  162. ...item,
  163. class: {
  164. 0: 'status-0',
  165. 1: 'status-1',
  166. 2: 'status-2',
  167. 3: 'status-3',
  168. 4: 'status-4',
  169. 5: 'status-5',
  170. 6: 'status-6',
  171. 7: 'status-7',
  172. 8: 'status-8'
  173. }[item.status] || ''
  174. }
  175. })
  176. }).catch(err => {
  177. console.log('getOrderDetails', err.data);
  178. })
  179. },
  180. }
  181. }
  182. </script>
  183. <style>
  184. page {
  185. background: #F7F7F9;
  186. }
  187. </style>
  188. <style lang="scss" scoped>
  189. .u-flex {
  190. display: flex;
  191. flex-direction: row;
  192. align-items: center;
  193. }
  194. .u-row-between {
  195. justify-content: space-between;
  196. }
  197. .u-row-around {
  198. justify-content: space-around;
  199. }
  200. .item-list{
  201. margin: 28rpx 32rpx 20rpx;
  202. .item{
  203. background: #FFFFFF;
  204. border-radius: 20rpx;
  205. padding-left: 18rpx;
  206. margin-bottom: 24rpx;
  207. .text{
  208. margin-left: 20rpx;
  209. flex: 1;
  210. padding: 30rpx 32rpx;
  211. box-shadow: -6rpx 0rpx 20rpx -18rpx rgba(0,0,0,0.5);
  212. .name{
  213. font-size: 24rpx;
  214. }
  215. .withdrawTotal{
  216. font-size: 24rpx;
  217. color: var(--gd-but-color);
  218. .num{
  219. font-size: 32rpx;
  220. }
  221. }
  222. }
  223. }
  224. }
  225. .cart-bottom {
  226. position: relative;
  227. z-index: 1001;
  228. height: 98rpx;
  229. .inner {
  230. position: fixed;
  231. background-color: #fff;
  232. height: 98rpx;
  233. left: 0;
  234. right: 0;
  235. bottom: 0;
  236. padding: 0 20rpx;
  237. padding-left: 0;
  238. .total-price-wrap {
  239. margin-left: 30rpx;
  240. .totalPrice{
  241. font-size: 30rpx;
  242. color: #333;
  243. font-weight: 400;
  244. .num{
  245. font-size: 40rpx;
  246. font-weight: bold;
  247. color: #ED0000;
  248. margin-left: 5px;
  249. }
  250. }
  251. .total{
  252. font-size: 20rpx;
  253. font-weight: 400;
  254. color: #999999;
  255. margin-right: 16rpx;
  256. }
  257. }
  258. .btn {
  259. height: 80rpx;
  260. line-height: 80rpx;
  261. border-radius: 50rpx;
  262. padding: 0 50rpx;
  263. background-color: #eee;
  264. color: #333;
  265. text-align: center;
  266. &.active {
  267. background-color: #FF3C3F;
  268. color: #fff;
  269. }
  270. }
  271. }
  272. }
  273. </style>