refundselect.vue 7.1 KB

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