index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <!-- 申请售后 -->
  2. <template>
  3. <view class="after-sale-apply-container">
  4. <JHeader title="选择商品" width="50" height="50" style="padding: 24upx 0 0;"></JHeader>
  5. <view class="content">
  6. <view class="order-list-box">
  7. <view class="item">
  8. <view class="order-info-box">
  9. <view class="order-info">
  10. <checkbox-group @change="checkboxChange">
  11. <checkbox
  12. v-for="(item, index) in orderMsg.skus" :key="index"
  13. :disabled="item.afterState || (item.classifyId == 1439)" :checked="item.checked" :value="String(index)"
  14. active-background-color="#C5AA7B"
  15. >
  16. <view class="order-info-item">
  17. <image :src="common.seamingImgUrl(item.image)" class="product-img"></image>
  18. <view class="info-box">
  19. <text class="product-name">{{ item.productName }}</text>
  20. <view class="product-sku">{{ item.value }}</view>
  21. <view class="price-sku-box">
  22. <text class="product-price">
  23. <text class="fuhao">¥</text>
  24. {{ item.price }}
  25. </text>
  26. <text class="product-num">x {{ item.number }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </checkbox>
  31. </checkbox-group>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="afterSale-select-box">
  37. <view class="selectBtn flex-items flex-sp-between">
  38. <view class="selectBox">
  39. <checkbox-group @change="changeAll">
  40. <view>
  41. <checkbox
  42. :disabled="orderMsg.skus.some(i => i.afterState || (i.classifyId == 1439))"
  43. :checked="allCheck.checked" :value="allCheck.value" color="#C5AA7B"
  44. ></checkbox>
  45. <text>{{ allCheck.name }}</text>
  46. </view>
  47. </checkbox-group>
  48. </view>
  49. <view class="selectRight flex-items">
  50. <view class="selectNum mar-right-25">{{ number || 0 }}件商品</view>
  51. <view class="totalPrice">
  52. 合计:
  53. <text>¥{{ total.toFixed(2) }}</text>
  54. </view>
  55. </view>
  56. </view>
  57. <view class="afterBtnBox flex-items flex-sp-between">
  58. <view class="afterBtn1" @click="ReturnMoney(orderMsg)">
  59. 仅退款
  60. </view>
  61. <view v-if="[3, 4, 5, 7, 9, 10].includes(orderMsg.state)" class="afterBtn2" @click="ReturnGoods(orderMsg)">
  62. 退款退货
  63. </view>
  64. </view>
  65. </view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import { getReturnPriceRefundMoneyApi, getOrderDetailApi } from '../../../api/anotherTFInterface'
  71. import { T_AFTER_SALE_APPLY_REFUND } from '../../../constant'
  72. export default {
  73. name: 'AfterSaleApply',
  74. data() {
  75. return {
  76. orderMsg: { skus: [] },
  77. checkboxChangelist: [],
  78. xuanzlist: [],
  79. allCheck: {
  80. name: '全选',
  81. value: 'all',
  82. checked: false
  83. },
  84. number: null,
  85. total: 0
  86. }
  87. },
  88. onLoad(options) {
  89. uni.showLoading()
  90. getOrderDetailApi({ orderId: options.orderId, noticeId: 0 })
  91. .then((res) => {
  92. uni.hideLoading()
  93. this.orderMsg = res.data
  94. this.orderMsg.skus.map((item) => ({ ...item, checked: false }))
  95. })
  96. .catch((e) => {
  97. uni.hideLoading()
  98. })
  99. },
  100. methods: {
  101. // 算钱
  102. HandleGetRefundMoney() {
  103. return new Promise((resolve, reject) => {
  104. if (this.xuanzlist.length <= 0) {
  105. resolve(0)
  106. return
  107. }
  108. uni.showLoading()
  109. getReturnPriceRefundMoneyApi({
  110. orderId: this.orderMsg.orderId,
  111. isAllSelect: this.xuanzlist.length === this.orderMsg.skus.length ? 1 : 0,
  112. skus: this.xuanzlist
  113. })
  114. .then((res) => {
  115. uni.hideLoading()
  116. resolve(parseFloat(res.json))
  117. })
  118. .catch((e) => {
  119. uni.hideLoading()
  120. })
  121. })
  122. },
  123. // 申请退款
  124. ReturnMoney(item) {
  125. if (this.xuanzlist.length <= 0) {
  126. uni.showToast({
  127. title: '请选择退款的商品',
  128. duration: 2000,
  129. icon: 'none'
  130. })
  131. } else {
  132. uni.setStorageSync(T_AFTER_SALE_APPLY_REFUND, this.xuanzlist)
  133. uni.navigateTo({
  134. url: '/another-tf/another-serve/afterSaleApplyRefund/index?orderId=' + this.orderMsg.orderId + '&isAllSelect=' + (this.xuanzlist.length === this.orderMsg.skus.length ? 1 : 0)
  135. })
  136. }
  137. },
  138. // 全选
  139. async changeAll(e) {
  140. if (e.detail.value.length == 0) {
  141. this.orderMsg.skus.forEach((item) => this.$set(item, 'checked', false))
  142. this.$set(this.allCheck, 'checked', false)
  143. this.xuanzlist = []
  144. } else {
  145. this.orderMsg.skus.forEach((item) => this.$set(item, 'checked', true))
  146. this.$set(this.allCheck, 'checked', true)
  147. this.xuanzlist = this.orderMsg.skus.filter((item) => item.checked == true)
  148. this.number = 0
  149. this.orderMsg.skus.forEach((item) => {
  150. this.number = this.number + item.number
  151. })
  152. }
  153. this.total = await this.HandleGetRefundMoney()
  154. },
  155. // 申请退货
  156. ReturnGoods(item) {
  157. if (this.xuanzlist.length <= 0) {
  158. uni.showToast({
  159. title: '请选择退货的商品',
  160. duration: 2000,
  161. icon: 'none'
  162. })
  163. } else {
  164. uni.navigateTo({
  165. url: '/another-tf/another-serve/afterSaleApplyRetund/index?list=' + encodeURIComponent(JSON.stringify(this.xuanzlist)) + '&orderId=' + this.orderMsg.orderId + '&isAllSelect=' + (this.xuanzlist.length === this.orderMsg.skus.length ? 1 : 0)
  166. })
  167. }
  168. },
  169. async checkboxChange(e) {
  170. // 动态设置商品件数和总计
  171. this.orderMsg.skus[Number(e.detail.value)].checked = !this.orderMsg.skus[Number(e.detail.value)].checked
  172. if (this.orderMsg.skus[Number(e.detail.value)].checked) {
  173. this.number = this.number + this.orderMsg.skus[Number(e.detail.value)].number
  174. } else {
  175. this.number = this.number - this.orderMsg.skus[Number(e.detail.value)].number
  176. }
  177. // 筛选勾选的
  178. this.xuanzlist = this.orderMsg.skus.filter((item) => item.checked == true)
  179. // 是否为全选
  180. if (this.orderMsg.skus.length == this.xuanzlist.length) {
  181. this.$set(this.allCheck, 'checked', true)
  182. } else {
  183. this.$set(this.allCheck, 'checked', false)
  184. }
  185. this.total = await this.HandleGetRefundMoney()
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="less" scoped>
  191. .after-sale-apply-container {
  192. background-color: #F8F8F8;
  193. min-height: 100vh;
  194. box-sizing: border-box;
  195. }
  196. .order-list-box {
  197. padding: 20upx 30upx;
  198. box-sizing: border-box;
  199. }
  200. .order-list-box .item {
  201. background: #fff;
  202. border-radius: 10upx;
  203. }
  204. .order-info-box {
  205. padding: 0 30upx;
  206. box-sizing: border-box;
  207. }
  208. .order-info-item {
  209. display: flex;
  210. flex-direction: row;
  211. padding: 10upx 20upx;
  212. border-bottom: solid 1px #eee;
  213. }
  214. .order-info-item:last-child {
  215. border-bottom: none;
  216. }
  217. .product-img {
  218. width: 180upx;
  219. height: 180upx;
  220. border-radius: 10upx;
  221. margin-right: 30upx;
  222. }
  223. .info-box {
  224. flex: 1;
  225. display: flex;
  226. flex-direction: column;
  227. }
  228. .product-name {
  229. font-size: 26upx;
  230. color: #333;
  231. height: 68upx;
  232. line-height: 34upx;
  233. display: -webkit-box;
  234. overflow: hidden;
  235. text-overflow: ellipsis;
  236. word-break: break-all;
  237. -webkit-box-orient: vertical;
  238. -webkit-line-clamp: 2;
  239. }
  240. .price-sku-box {
  241. display: flex;
  242. flex-direction: row;
  243. justify-content: space-between;
  244. margin-top: 10upx;
  245. }
  246. .product-sku {
  247. font-size: 24upx;
  248. color: #999;
  249. margin-top: 30upx;
  250. }
  251. .product-price {
  252. font-size: 28upx;
  253. color: #333;
  254. font-weight: 400;
  255. }
  256. .product-price .fuhao {
  257. font-size: 28upx;
  258. }
  259. .product-num {
  260. font-size: 28upx;
  261. color: #999;
  262. }
  263. .afterSale-select-box {
  264. position: fixed;
  265. bottom: 0;
  266. width: 100%;
  267. background: #fff;
  268. padding: 30rpx;
  269. box-sizing: border-box;
  270. height: 240rpx;
  271. }
  272. .afterBtnBox {
  273. margin-top: 30rpx;
  274. .afterBtn1 {
  275. width: 342rpx;
  276. line-height: 100rpx;
  277. border: 2rpx solid #333333;
  278. text-align: center;
  279. color: #333333;
  280. margin-right: 30rpx;
  281. }
  282. .afterBtn2 {
  283. width: 342rpx;
  284. height: 100rpx;
  285. line-height: 100rpx;
  286. background: #333333;
  287. border: 2rpx solid #333333;
  288. text-align: center;
  289. color: #FFEBC4;
  290. }
  291. }
  292. </style>