after_sale_choose.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <!-- 选择申请售后货物 -->
  3. <view class="dt-page">
  4. <block v-for="(item,idx) in dataList" :key="idx">
  5. <view class="goods-wrap">
  6. <view class="hd-row">
  7. <view class="pay">支付总额:¥{{item.priceAll|moneyEx}}</view>
  8. <!-- <view class="state">{{ item.statusTxt }}</view> -->
  9. </view>
  10. <view class="mid-row">
  11. <view class="goods-item">
  12. <view class="check-wrap" @tap="tapCheck(idx)">
  13. <image class="dt-checked" :src="item.checked?'http://139.9.103.171:1888/img/image/selected_icon.png':'http://139.9.103.171:1888/img/image/no_selected_icon.png'" mode="widthFix"></image>
  14. </view>
  15. <image class="main-pic" :src="item.thumbnail" mode="aspectFit"></image>
  16. <view class="rt-wrap">
  17. <view class="good-mn">
  18. <view class="goods-name dt-text-row-one">{{ item.name }}</view>
  19. <view class="goods-num">x {{ item.quantity }}</view>
  20. </view>
  21. <view class="specifications">{{ item.specificationsDesc }}</view>
  22. <view class="price">¥{{ item.price|moneyEx }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="ft-row">
  27. <view class="lt">选择商品:规格/单价/数量</view>
  28. <DtAccumulator
  29. :isFocus.sync="isFocus"
  30. :val="item.quantityCalc"
  31. @change="onAccumulatorChange($event,idx)" />
  32. </view>
  33. </view>
  34. </block>
  35. <FootToolbar bgColor="#fff">
  36. <view slot="main" class="ft-btn-wrap">
  37. <view class="lt" @tap="tapCheckedAll">
  38. <image class="dt-checked" :src="checkedAll?'http://139.9.103.171:1888/img/image/selected_icon.png':'http://139.9.103.171:1888/img/image/no_selected_icon.png'" mode="widthFix"></image>
  39. <view class="tips">已选货物数量 <text v-if="checkedNum>0">({{checkedNum}})</text></view>
  40. </view>
  41. <button class="ft-btn-submit" @tap="tapSubmit">确认售后货物</button>
  42. </view>
  43. </FootToolbar>
  44. </view>
  45. </template>
  46. <script>
  47. import DtAccumulator from '../comps/dt_accumulator.vue'
  48. import FootToolbar from '../comps/foot_toolbar.vue'
  49. export default {
  50. components: {
  51. DtAccumulator,
  52. FootToolbar
  53. },
  54. data() {
  55. return {
  56. dataDetail: {},
  57. dataList:[],
  58. isFocus: false,
  59. checkedNum:0,
  60. checkedAll:false,
  61. }
  62. },
  63. methods: {
  64. tapCheckedAll(){
  65. this.checkedAll = !this.checkedAll
  66. let dataList = this.dataList.slice(0)
  67. dataList.map((item)=>{
  68. item.checked = this.checkedAll
  69. return item
  70. })
  71. if(this.checkedAll){
  72. this.checkedNum = dataList.length
  73. }else{
  74. this.checkedNum = 0
  75. }
  76. this.dataList = dataList
  77. },
  78. tapCheck(idx) {
  79. let dataList = this.dataList.slice(0)
  80. dataList[idx].checked = !dataList[idx].checked
  81. let checkedNum = 0
  82. dataList.forEach((item)=>{
  83. if(item.checked){
  84. checkedNum++
  85. }
  86. })
  87. this.checkedNum = checkedNum
  88. this.checkedAll = checkedNum == dataList.length
  89. this.dataList = dataList
  90. },
  91. onAccumulatorChange(val, idx) {
  92. let dataList = this.dataList.slice(0)
  93. if(val > dataList[idx].quantity){
  94. this.$dialog.toast('售后数量不能大于已购数量')
  95. val = dataList[idx].quantity
  96. }
  97. if(val < 0){
  98. val = 0
  99. }
  100. dataList[idx].quantityCalc = val
  101. this.dataList = dataList
  102. },
  103. tapSubmit(){
  104. let orderItems = {}, disableItem = {}
  105. let dataList = this.dataList.slice(0)
  106. for(let i=0,item; item = dataList[i]; i++){
  107. if(item.checked){
  108. if(item.quantityCalc>0){
  109. orderItems[item.id] = item.quantityCalc
  110. }else{
  111. disableItem = item
  112. break;
  113. }
  114. }
  115. }
  116. if(!(this.checkedNum>0)){
  117. this.$dialog.toast('请选择售后商品')
  118. return
  119. }
  120. if(disableItem.id){
  121. this.$dialog.toast(`商品 “${disableItem.name}” 的售后数量不能为0`)
  122. return
  123. }
  124. let params = {
  125. orderSn: this.dataDetail.sn,
  126. orderItems:JSON.stringify(orderItems),
  127. orderId: this.loadOptions.orderId,
  128. saleType:3, // 默认退货
  129. }
  130. uni.navigateTo({
  131. // url:'/pages/after_sale_apply?'+this.$util.serialize(params)
  132. url:'/pagesM/pages/after_sale_submit?'+this.$util.serialize(params)
  133. })
  134. },
  135. async queryDataList() {
  136. let resp = await this.$api.getOrderAfterSaleInfo({
  137. _isShowLoading: true,
  138. orderId: this.loadOptions.orderId
  139. })
  140. if(Array.isArray(resp)){
  141. for(let i=0,item; item = resp[i]; i++){
  142. if(item.store.id == this.$global.server.storeId){
  143. item.orderItems.map((oItem)=>{
  144. oItem.quantityCalc = oItem.quantity
  145. oItem.priceAll = oItem.quantity * oItem.price
  146. oItem.specificationsDesc = oItem.specifications.join('+')
  147. return oItem
  148. })
  149. // this.dataList = item.orderItems||[]
  150. this.dataList.push(...item.orderItems);
  151. this.dataDetail = item
  152. // break;
  153. }
  154. }
  155. }
  156. },
  157. onLoadPage() {
  158. wx.hideShareMenu();
  159. if (this.isLoad) {
  160. this.memberId = this.$auth.getMemberId()
  161. }
  162. this.queryDataList()
  163. }
  164. },
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .dt-page {
  169. min-height: 100vh;
  170. .goods-wrap {
  171. margin-bottom: 20upx;
  172. background-color: #fff;
  173. .hd-row {
  174. display: flex;
  175. justify-content: space-between;
  176. padding: 0 30upx;
  177. line-height: 60upx;
  178. color: #666666;
  179. font-size: 24upx;
  180. border-bottom: 1upx solid #e5e5e5;
  181. }
  182. .mid-row {
  183. .check-wrap {
  184. display: flex;
  185. align-items: center;
  186. padding-right: 20rpx;
  187. }
  188. .goods-item {
  189. display: flex;
  190. padding: 20upx 30upx;
  191. height: 180rpx;
  192. box-sizing: border-box;
  193. border-bottom: 1upx solid #e5e5e5;
  194. .main-pic {
  195. width: 120upx;
  196. height: 120upx;
  197. }
  198. .rt-wrap {
  199. padding-left: 26upx;
  200. flex: 1;
  201. line-height: 1;
  202. .good-mn {
  203. display: flex;
  204. justify-content: space-between;
  205. align-items: flex-end;
  206. font-size: 30upx;
  207. .goods-name {
  208. flex: 1;
  209. margin-right: 20upx;
  210. line-height: 1.2;
  211. }
  212. }
  213. .specifications {
  214. margin: 20upx 0;
  215. color: #999999;
  216. font-size: 26upx;
  217. font-weight: 500;
  218. }
  219. .price {
  220. font-size: 30upx;
  221. }
  222. }
  223. }
  224. }
  225. .ft-row {
  226. display: flex;
  227. justify-content: space-between;
  228. align-items: center;
  229. padding: 0 30upx;
  230. height: 90upx;
  231. }
  232. .btn-base {
  233. position: relative;
  234. width: 150upx;
  235. height: 56upx;
  236. line-height: 56upx;
  237. font-size: 28upx;
  238. border-radius: 6upx;
  239. box-sizing: border-box;
  240. }
  241. .btn-base:before {
  242. position: absolute;
  243. top: 0;
  244. left: 0;
  245. width: 100%;
  246. height: 100%;
  247. border: 2upx solid $dt-color-primary;
  248. border-radius: 6upx;
  249. box-sizing: border-box;
  250. content: '';
  251. }
  252. .btn-plain {
  253. background-color: transparent;
  254. color: $dt-text-color;
  255. }
  256. .btn-plain:before {
  257. border-color: #ccc;
  258. box-sizing: border-box;
  259. content: '';
  260. }
  261. .btn-primary {
  262. background-color: $dt-color-primary;
  263. color: #fff;
  264. }
  265. .btn-primary:before {
  266. border-color: $dt-color-primary;
  267. box-sizing: border-box;
  268. content: '';
  269. }
  270. }
  271. // 底部工具栏
  272. .ft-btn-wrap {
  273. display: flex;
  274. width: 100%;
  275. height: 100%;
  276. .lt{
  277. flex:2;
  278. display:flex;
  279. align-items: center;
  280. padding-left:30upx;
  281. .tips{
  282. padding-left:20upx;
  283. color:#666;
  284. font-size:26iupx;
  285. font-weight:400;
  286. }
  287. }
  288. .ft-btn-submit {
  289. display:flex;
  290. justify-content: center;
  291. align-items: center;
  292. width:260upx;
  293. background-color: $dt-color-primary;
  294. font-size:30upx;
  295. color: #fff;
  296. border-radius: 0;
  297. }
  298. }
  299. }
  300. .dt-checked{
  301. display: flex;
  302. width:40upx;
  303. height:40upx;
  304. }
  305. </style>