refundselect.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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.viewerSalePrice }}
  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"
  40. :name="allCheckbox.name" 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. pageData: {},
  81. }
  82. },
  83. computed: {
  84. // 是否全选
  85. allChecked() {
  86. return this.dataList.every(item => item.checked)
  87. },
  88. selectGoods() {
  89. let selectGoods = [];
  90. this.dataList.forEach(item => {
  91. if (item.checked) {
  92. selectGoods.push(item)
  93. }
  94. })
  95. return selectGoods
  96. },
  97. // 合计价格
  98. totalPrice() {
  99. let that = this;
  100. return this.dataList.reduce((total, item) => {
  101. if (item.checked) {
  102. let price = null;
  103. price = item.viewerSalePrice
  104. total += price;
  105. }
  106. return total;
  107. }, 0).toFixed(2);
  108. }
  109. },
  110. onLoad(page) {
  111. this.getSystemInfo();
  112. this.orderId = page.id;
  113. },
  114. onShow() {
  115. this.getViewers();
  116. },
  117. methods: {
  118. leftClick(e) {
  119. let pages = getCurrentPages();
  120. if (pages.length == 1) {
  121. uni.$u.route('/pages/index/index')
  122. } else {
  123. uni.navigateBack()
  124. };
  125. },
  126. // 切换全选状态
  127. allCheckboxChange(n) {
  128. // console.log('allCheckboxChange',n[0]);
  129. console.log('allCheckboxChange', n);
  130. let selectAll = n[0] ? true : false;
  131. this.dataList.forEach(item => {
  132. if (item.status === 3) {
  133. item.checked = selectAll
  134. }
  135. })
  136. },
  137. checkboxClick() {
  138. // console.log('checkboxClick',this.allChecked);
  139. this.dataList.forEach(item => {
  140. if (item.status === 3) {
  141. item.checked = !this.allChecked
  142. }
  143. })
  144. },
  145. checkboxChange(n) {
  146. // console.log('checkboxChange',n);
  147. },
  148. // 切换商品选中状态
  149. toggleCheck(index) {
  150. // console.log('toggleCheck',index);
  151. if (this.dataList[index].status !== 3) {
  152. uni.showToast({
  153. icon: 'none',
  154. title: '该状态不能退款',
  155. duration: 1000
  156. })
  157. return
  158. }
  159. this.dataList[index].checked = !this.dataList[index].checked
  160. },
  161. submitorder() {
  162. //判断this.pageData.hasPreferential 是否存在优惠,如果存在优惠,则list的数据要全选,如果没有全选弹窗提示,提示内容为this.pageData.preferentialMsg
  163. if (this.pageData.hasPreferential) {
  164. if (!this.allChecked) {
  165. uni.showModal({
  166. title: '提示',
  167. content: this.pageData.preferentialMsg,
  168. confirmText: '确认',
  169. cancelText: '取消',
  170. success: (res) => {
  171. if (res.confirm) {
  172. // 点击确认,执行全选后提交
  173. this.dataList.forEach(item => {
  174. item.checked = true
  175. // if (item.status === 3) {
  176. // item.checked = true
  177. // }
  178. })
  179. // 重新执行提交逻辑
  180. this.executeSubmit()
  181. }
  182. // 点击取消则自动关闭弹窗,无需额外处理
  183. }
  184. })
  185. return
  186. }
  187. }
  188. this.executeSubmit()
  189. },
  190. executeSubmit() {
  191. let viewerList = this.selectGoods.map(item => {
  192. return { viewerId: item.id, salePrice: item.salePrice }
  193. });
  194. let params = {
  195. type: 'redirectTo',
  196. id: this.orderId,
  197. refundAmount: this.totalPrice,
  198. viewerList: JSON.stringify(viewerList)
  199. };
  200. // console.log('selectGoods', this.selectGoods);
  201. // uni.$u.route('/center/refund', params);
  202. uni.redirectTo({
  203. url: `/center/refund?id=${this.orderId}&refundAmount=${this.totalPrice}&viewerList=${JSON.stringify(viewerList)}`
  204. })
  205. },
  206. getViewers() {
  207. this.$u.api.getViewers({
  208. orderId: this.orderId
  209. }).then(res => {
  210. this.dataList = res.data.list.map(item => {
  211. item.checked = false;
  212. return {
  213. ...item,
  214. class: {
  215. 0: 'status-0',
  216. 1: 'status-1',
  217. 2: 'status-2',
  218. 3: 'status-3',
  219. 4: 'status-4',
  220. 5: 'status-5',
  221. 6: 'status-6',
  222. 7: 'status-7',
  223. 8: 'status-8'
  224. }[item.status] || ''
  225. }
  226. })
  227. this.pageData = res.data;
  228. // console.log('this.pageData',this.pageData)
  229. }).catch(err => {
  230. console.log('getOrderDetails', err.data);
  231. })
  232. },
  233. }
  234. }
  235. </script>
  236. <style>
  237. page {
  238. background: #F7F7F9;
  239. }
  240. </style>
  241. <style lang="scss" scoped>
  242. .item-list {
  243. margin: 28rpx 32rpx 20rpx;
  244. .item {
  245. background: #FFFFFF;
  246. border-radius: 20rpx;
  247. padding-left: 18rpx;
  248. margin-bottom: 24rpx;
  249. .text {
  250. margin-left: 20rpx;
  251. flex: 1;
  252. padding: 30rpx 32rpx 52rpx;
  253. box-shadow: -6rpx 0rpx 20rpx -18rpx rgba(0, 0, 0, 0.5);
  254. }
  255. .up {
  256. border-bottom: 1px solid #EBEBEB;
  257. padding-bottom: 24rpx;
  258. margin-bottom: 32rpx;
  259. .left {
  260. font-size: 24rpx;
  261. font-weight: 400;
  262. color: #606060;
  263. }
  264. .status {
  265. font-size: 24rpx;
  266. font-weight: 400;
  267. color: #9E9E9E;
  268. &.status-3 {
  269. color: #56CE53;
  270. }
  271. &.status-4 {
  272. color: #FF6C17;
  273. }
  274. }
  275. }
  276. .down {
  277. .name {
  278. font-size: 28rpx;
  279. font-weight: 500;
  280. color: #363636;
  281. margin-bottom: 20rpx;
  282. }
  283. .idcard {
  284. font-size: 22rpx;
  285. font-weight: 400;
  286. color: #7F7F7F;
  287. }
  288. .right {
  289. font-size: 32rpx;
  290. font-weight: bold;
  291. color: #ED0000;
  292. }
  293. }
  294. }
  295. }
  296. .cart-bottom {
  297. position: relative;
  298. z-index: 1001;
  299. height: 98rpx;
  300. .inner {
  301. position: fixed;
  302. background-color: #fff;
  303. height: 98rpx;
  304. left: 0;
  305. right: 0;
  306. bottom: 0;
  307. padding: 0 20rpx;
  308. padding-left: 0;
  309. .total-price-wrap {
  310. margin-left: 30rpx;
  311. .totalPrice {
  312. font-size: 30rpx;
  313. color: #333;
  314. font-weight: 400;
  315. .num {
  316. font-size: 40rpx;
  317. font-weight: bold;
  318. color: #ED0000;
  319. margin-left: 5px;
  320. }
  321. }
  322. .total {
  323. font-size: 20rpx;
  324. font-weight: 400;
  325. color: #999999;
  326. margin-right: 16rpx;
  327. }
  328. }
  329. .btn {
  330. height: 80rpx;
  331. line-height: 80rpx;
  332. border-radius: 50rpx;
  333. padding: 0 50rpx;
  334. background-color: #eee;
  335. color: #333;
  336. text-align: center;
  337. &.active {
  338. background-color: #FF3C3F;
  339. color: #fff;
  340. }
  341. }
  342. }
  343. }
  344. </style>