invoice.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="navbar-box">
  5. <u-navbar title="开具发票" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}" leftIconColor="#fff" bgColor="#EF1818"></u-navbar>
  6. </view>
  7. <view class="page-wrap">
  8. <mescroll-body class="" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  9. <!-- :down="downOption" :up="upOption" -->
  10. <view class="list">
  11. <u-checkbox-group placement="column" @change="checkboxChange" >
  12. <view v-for="(item,index) in dataList" class="list-item u-flex" :key="item.id">
  13. <view class="left">
  14. <u-checkbox shape="circle" :disabled="item.quantity>item.stock" activeColor="#ED0000" :key="index" :name="item.name" :checked="item.checked" @change="toggleCheck(index)" class="checkbox" />
  15. </view>
  16. <view class="right">
  17. <view class="order-number">订单号:360123456789079797</view>
  18. <view class="info u-flex">
  19. <image class="img" :src="item.showImg||staticUrl+'/img/newsdetails-banner.png'"></image>
  20. <view class="text">
  21. <view class="name">《伟大转折》-【成人票】</view>
  22. <view class="time">2023-11–03 14:00-16:00</view>
  23. <view class="position">5排6座</view>
  24. <view class="statistics">
  25. <text>共1张</text>
  26. <text class="label">合计:</text>
  27. <text class="price">¥120.00</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </u-checkbox-group>
  34. </view>
  35. </mescroll-body>
  36. </view>
  37. <view class="page-bottom">
  38. <view class="inner u-flex u-row-between">
  39. <view class="left">
  40. <u-checkbox-group @change="allCheckboxChange">
  41. <u-checkbox shape="circle" :checked="allChecked" activeColor="#ED0000" :name="allCheckbox.name" label="全选"></u-checkbox>
  42. </u-checkbox-group>
  43. </view>
  44. <view class="right u-flex">
  45. <view class="total-price u-flex">
  46. <text>合计:</text>
  47. <text class="num">{{totalPrice}}</text>
  48. </view>
  49. <view class="btn active" v-if="totalPrice>0&&cansubmit" @click="submitorder">申请开票</view>
  50. <view class="btn" v-else>申请开票</view>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import { systemInfo } from "@/mixin.js";
  58. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  59. export default {
  60. mixins: [MescrollMixin,systemInfo], // 使用mixin
  61. data() {
  62. return {
  63. staticUrl:this.$commonConfig.staticUrl,
  64. allCheckbox:{name: '全选'},
  65. dataList:[
  66. {name:'路线推荐',checked:false,pic:`${this.$commonConfig.staticUrl}/img/indexnav-luxian.png`,id:1},
  67. {name:'路线推荐',checked:false,pic:`${this.$commonConfig.staticUrl}/img/indexnav-luxian.png`,id:2},
  68. ],
  69. }
  70. },
  71. onShow() {
  72. },
  73. onLoad() {
  74. this.getSystemInfo();
  75. },
  76. computed: {
  77. // 是否全选
  78. allChecked() {
  79. return this.dataList.every(item => item.checked)
  80. },
  81. // 商品合计价格
  82. selectGoods() {
  83. let selectGoods = [];
  84. this.dataList.forEach(item => {
  85. if (item.checked) {
  86. selectGoods.push(item)
  87. }
  88. })
  89. return selectGoods
  90. },
  91. totalPrice() {
  92. let that = this;
  93. return this.dataList.reduce((total, item) => {
  94. if (item.checked) {
  95. let price = null;
  96. // if(that.vuex_member_info.priceType>1){
  97. // price = item.vipPrice
  98. // }else{
  99. // price = item.salePrice
  100. // }
  101. price = item.levelPrice
  102. total += price * item.quantity;
  103. }
  104. return total;
  105. }, 0).toFixed(2);
  106. }
  107. },
  108. methods: {
  109. leftClick(e){
  110. let pages = getCurrentPages();
  111. if(pages.length==1){
  112. uni.$u.route('/pages/index/index')
  113. }else{
  114. uni.navigateBack()
  115. };
  116. },
  117. /*下拉刷新的回调, 重置列表为第一页 (此处可删,mixins已默认)
  118. downCallback(){
  119. this.mescroll.resetUpScroll();
  120. },
  121. /*上拉加载的回调*/
  122. upCallback(page) {
  123. // 此处可以继续请求其他接口
  124. // if(page.num == 1){
  125. // // 请求其他接口...
  126. // }
  127. // 如果希望先请求其他接口,再触发upCallback,可参考以下写法
  128. // if(!this.hasTypeId){
  129. // this.mescroll.endErr();//没有接口暂时不调用
  130. // return // 此处return,先获取xx
  131. // }
  132. let pageNum = page.num; // 页码, 默认从1开始
  133. let pageSize = page.size; // 页长, 默认每页10条
  134. let params = {
  135. pageNum : page.num,
  136. pageSize : page.size,
  137. status:this.status
  138. }
  139. // console.log('this.params',params);
  140. this.$u.api.orderList(params).then(data => {
  141. this.hasfetch = true;
  142. console.log('data',JSON.parse(JSON.stringify(data)));
  143. // 接口返回的当前页数据列表 (数组)
  144. let curPageData = data.data.rows;
  145. curPageData = curPageData.map( item =>{
  146. item.checked = false
  147. return item
  148. })
  149. // console.log('curPageData',JSON.parse(JSON.stringify(curPageData)));
  150. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  151. let curPageLen = curPageData.length;
  152. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  153. // let totalPage = data.data.data.totalPage;
  154. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  155. let totalSize = data.data.total;
  156. // 接口返回的是否有下一页 (true/false)
  157. // let hasNext = data.xxx;
  158. // console.log('totalPage',totalPage,'curPageLen',curPageLen);
  159. //设置列表数据
  160. if(page.num == 1) this.dataList = []; //如果是第一页需手动置空列表
  161. this.dataList = this.dataList.concat(curPageData); //追加新数据
  162. // 请求成功,隐藏加载状态
  163. //方法一(推荐): 后台接口有返回列表的总页数 totalPage
  164. // this.mescroll.endByPage(curPageLen, totalPage);
  165. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  166. this.mescroll.endBySize(curPageLen, totalSize);
  167. }).catch(err => {
  168. this.mescroll.endErr()
  169. console.log(err)
  170. });
  171. },
  172. /*若希望重新加载列表,只需调用此方法即可(内部会自动page.num=1,再主动触发up.callback)*/
  173. reloadList() {
  174. this.mescroll.resetUpScroll();
  175. },
  176. search(e){
  177. this.reloadList();
  178. },
  179. checkboxChange(n){
  180. // console.log('checkboxChange',n);
  181. },
  182. toggleCheck(index) {
  183. console.log('toggleCheck',index);
  184. this.dataList[index].checked = !this.dataList[index].checked
  185. },
  186. checkboxClick(){
  187. console.log('checkboxClick',this.allChecked);
  188. this.dataList.forEach(item => {
  189. if(item.quantity<=item.stock){
  190. item.checked = !this.allChecked
  191. }
  192. })
  193. },
  194. // 切换全选状态
  195. allCheckboxChange(n){
  196. // console.log('allCheckboxChange',n[0]);
  197. // console.log('allCheckboxChange',n);
  198. let selectAll = n[0]?true:false;
  199. this.dataList.forEach(item => {
  200. item.checked = selectAll
  201. });
  202. console.log('selectGoods',this.selectGoods);
  203. },
  204. }
  205. }
  206. </script>
  207. <style>
  208. page{background-color: #F7F7F9;}
  209. </style>
  210. <style lang="scss" scoped>
  211. .list-item{
  212. background: #FFFFFF;
  213. box-shadow: 0rpx 2rpx 12rpx 0rpx rgba(221,221,221,0.5);
  214. border-radius: 20rpx;
  215. margin-bottom: 24rpx;
  216. padding: 34rpx 32rpx 50rpx 20rpx;
  217. .right{
  218. flex: 1;
  219. padding-left: 24rpx;
  220. .order-number{
  221. font-size: 24rpx;
  222. font-weight: 400;
  223. color: #7F7F7F;
  224. line-height: 36rpx;
  225. margin-bottom: 36rpx;
  226. }
  227. .info{
  228. .img{
  229. width: 180rpx;
  230. height: 160rpx;
  231. }
  232. .text{
  233. font-size: 24rpx;
  234. font-weight: 400;
  235. color: #7F7F7F;
  236. padding-left: 26rpx;
  237. .name{
  238. font-size: 28rpx;
  239. font-weight: bold;
  240. color: #363636;
  241. margin-bottom: 20rpx;
  242. }
  243. .time{
  244. margin-bottom: 20rpx;
  245. }
  246. .position{
  247. margin-bottom: 20rpx;
  248. }
  249. .statistics{
  250. text-align: right;
  251. }
  252. .label{
  253. font-size: 24rpx;
  254. font-weight: 400;
  255. color: #363636;
  256. margin-left: 10rpx;
  257. }
  258. .price{
  259. font-size: 32rpx;
  260. font-weight: bold;
  261. color: #ED0000;
  262. }
  263. }
  264. }
  265. }
  266. }
  267. .page-bottom{
  268. position: relative;
  269. z-index: 1001;
  270. height: 98rpx;
  271. padding: 24rpx 20rpx 50rpx;
  272. .inner{
  273. position: fixed;
  274. background-color: #fff;
  275. height: 98rpx;
  276. left: 0;
  277. right: 0;
  278. bottom: 0;
  279. padding: 24rpx 20rpx 50rpx;
  280. box-shadow: 0rpx -4rpx 12rpx 0rpx rgba(215,215,215,0.5);
  281. .total-price{
  282. font-size: 28rpx;
  283. font-weight: 400;
  284. color: #313131;
  285. margin-right: 32rpx;
  286. .num{
  287. font-size: 40rpx;
  288. font-weight: bold;
  289. color: #ED0000;
  290. }
  291. }
  292. .btn{
  293. font-size: 28rpx;
  294. height: 80rpx;
  295. line-height: 80rpx;
  296. border-radius: 50rpx;
  297. padding: 0 50rpx;
  298. background-color: #eee;
  299. color: #333;
  300. text-align: center;
  301. &.active{
  302. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  303. color: #fff;
  304. }
  305. }
  306. }
  307. }
  308. </style>