You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

488 lines
11 KiB

6 months ago
  1. <template>
  2. <view>
  3. <!-- 购买商品列表 -->
  4. <view class="buy-list">
  5. <view class="list_top">
  6. <view class="tip">请选择需要退货的商品</view>
  7. <view class="checkbox-box" @tap="allSelect">
  8. <view class="checkbox">
  9. <view :class="[isAllselected?'on':'']"></view>
  10. </view>
  11. <view class="text">全选</view>
  12. </view>
  13. </view>
  14. <view class="row" v-for="(row,index) in buylist" :key="index">
  15. <view class="goods-info">
  16. <view class="img">
  17. <image :src="row.img"></image>
  18. </view>
  19. <view class="info">
  20. <view class="title">{{row.mc}}{{row.dw}}</view>
  21. <view>
  22. <view class="spec">{{row.gg}} <text style="color: red;">单价:{{row.price}}</text></view>
  23. <view class="foodnum">可退数量:{{row.dinghl}}</view>
  24. </view>
  25. <view class="price-number">
  26. <view class="price">{{row.price*row.dinghl|toFixeds}}</view>
  27. <view class="number">
  28. 退款数
  29. <view class="input">
  30. <input type="digit" :disabled="!row.selected" v-model="row.selected==false?'':row.tuiksl" @input="inputchange($event,row.id,index,row.tuiksl,row.price)" />
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="checkbox-box" @tap="selected(index)" >
  36. <view class="checkbox">
  37. <view :class="[row.selected?'on':'']"></view>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <!-- 提示-备注 -->
  44. <view class="order">
  45. <view class="row">
  46. <view class="left">
  47. 退货说明 :
  48. </view>
  49. <view class="right">
  50. <input placeholder="选填,退货备注" v-model="note" />
  51. </view>
  52. </view>
  53. <view class="row">
  54. <view class="left">
  55. 申请金额 :
  56. </view>
  57. <view class="right">
  58. <input placeholder="申请退货金额" v-model="sqmoney" />
  59. </view>
  60. </view>
  61. </view>
  62. <!-- 明细 -->
  63. <view class="detail">
  64. <view class="row">
  65. <view class="nominal">
  66. 商品金额
  67. </view>
  68. <view class="content">
  69. {{goodsPrice|toFixeds}}
  70. </view>
  71. </view>
  72. </view>
  73. <view class="blck"></view>
  74. <view class="footer">
  75. <view class="settlement">
  76. <view class="btn" @tap="tosq">提交申请</view>
  77. </view>
  78. </view>
  79. </view>
  80. </template>
  81. <script>
  82. export default {
  83. data() {
  84. return {
  85. buylist:[], //订单列表
  86. goodsPrice:0, //商品合计价格
  87. note:'', //备注
  88. cpids:'',
  89. dhid:0,
  90. sqmoney:0,
  91. index:0,
  92. isAllselected:false,
  93. selectedList:[],
  94. gids:'',
  95. tktype:0,
  96. tuiksls:'',//退款产品的数量
  97. };
  98. },
  99. onLoad(option) {
  100. //option为object类型,会序列化上个页面传递的参数
  101. this.dhid = parseInt(option.dhid);
  102. this.tktype=option.tktype
  103. //this.dhid = 32882;
  104. this.index=parseInt(option.index);//当前订单状态
  105. //this.goodsPrice=option.allmoney;
  106. //this.orderdetail(this.dhid)
  107. },
  108. onShow() {
  109. //页面显示时,加载订单信息
  110. this.orderdetail(this.dhid)
  111. },
  112. onHide() {
  113. },
  114. filters: {
  115. toFixeds:function(x) {
  116. return parseFloat(x).toFixed(2);
  117. }
  118. },
  119. methods: {
  120. //修改退款数量
  121. inputchange(even,id,index,tuiksl,dj)
  122. {
  123. let inputnum=parseFloat(even.detail.value);
  124. if(inputnum>this.buylist[index].dinghl)
  125. {
  126. inputnum=this.buylist[index].dinghl;
  127. }else if(inputnum>0){
  128. inputnum=inputnum;
  129. }else{
  130. inputnum='';
  131. }
  132. this.buylist[index].tuiksl=inputnum;
  133. this.sum();
  134. },
  135. async orderdetail(id){
  136. let redata=await this.$api.orderdetail({action:'orderdetail',dhid:id});
  137. if(redata.code==1){
  138. this.buylist = redata.data;
  139. let len = redata.data.length;
  140. let allmoney=0;
  141. for(let i=0;i<len;i++){
  142. this.buylist[i].selected=false;
  143. allmoney=(Number(allmoney) + Number(this.buylist[i].je))
  144. }
  145. this.goodsPrice=allmoney
  146. }else{
  147. uni.showToast({
  148. title:'暂无数据',icon:'none'
  149. })
  150. }
  151. },
  152. async sqtuik(dhid) {
  153. let userinfo=uni.getStorageSync('userinfo');
  154. let reinfo=await this.$api.sqtuik({action:'sqtuih',uid:userinfo.uid,aid:userinfo.aid,
  155. dhid:dhid,bz:this.note,sqmoney:this.sqmoney,gids:this.gids,isAllselected:this.isAllselected,tktype:this.tktype,tuiksls:this.tuiksls});
  156. if(reinfo.code==1){
  157. uni.showToast({
  158. title:reinfo.msg,icon:'none'
  159. })
  160. uni.redirectTo({
  161. url:"/pages/orderlist/orderlist?state="+this.index
  162. })
  163. }else{
  164. uni.showToast({
  165. title:reinfo.msg,icon:'none'
  166. })
  167. }
  168. uni.hideLoading();
  169. },
  170. tosq(){
  171. let t=this;
  172. // console.log(Number((parseFloat(this.sqmoney*100)/100).toFixed(2))+'---'+Number((parseFloat(this.goodsPrice*100)/100).toFixed(2)))
  173. //this.sqmoney=parseInt(this.sqmoney).toFixed(2)
  174. if(Number((parseFloat(this.sqmoney*100)/100).toFixed(2))>Number((parseFloat(this.goodsPrice*100)/100).toFixed(2))){
  175. uni.showToast({
  176. title:'申请金额:'+Number((parseFloat(this.sqmoney*100)/100).toFixed(2))+',最多申请'+Number((parseFloat(this.goodsPrice*100)/100).toFixed(2))+'元',icon:'none'
  177. })
  178. return false;
  179. }else if(this.sqmoney<=0){
  180. uni.showToast({
  181. title:'请填申请金额',icon:'none'
  182. })
  183. return false;
  184. }else if(this.gids==''){
  185. uni.showToast({
  186. title:'请选择商品',icon:'none'
  187. })
  188. return false;
  189. }else if(this.tuiksls==''){
  190. uni.showToast({
  191. title:'请选择退货数量',icon:'none'
  192. })
  193. return false;
  194. }
  195. uni.showModal({
  196. title: '温馨提示',
  197. content: '是否申请退货'+t.sqmoney+'元?',
  198. success: function (res) {
  199. if (res.confirm) {
  200. uni.showLoading({
  201. title:'正在申请...'
  202. })
  203. t.sqtuik(t.dhid)
  204. } else if (res.cancel) {
  205. console.log(t.gids,'用户点击取消');
  206. }
  207. }
  208. });
  209. },
  210. // 选中商品
  211. selected(index){
  212. this.buylist[index].selected = this.buylist[index].selected?false:true;
  213. let i = this.selectedList.indexOf(this.buylist[index].id);
  214. i>-1?this.selectedList.splice(i, 1):this.selectedList.push(this.buylist[index].id);
  215. this.isAllselected = this.selectedList.length == this.buylist.length;
  216. this.sum();
  217. },
  218. //全选
  219. allSelect(){
  220. let len = this.buylist.length;
  221. let arr = [];
  222. for(let i=0;i<len;i++){
  223. this.buylist[i].selected = this.isAllselected? false : true;
  224. arr.push(this.buylist[i].id);
  225. }
  226. this.selectedList = this.isAllselected?[]:arr;
  227. this.isAllselected = this.isAllselected||this.buylist.length==0?false : true;
  228. this.sum();
  229. },
  230. // 合计
  231. sum(){
  232. this.sqmoney=0;
  233. let len = this.buylist.length;
  234. let gids='';let cpsl='';
  235. for(let i=0;i<len;i++){
  236. let tuiksl=this.buylist[i].tuiksl==''?0:this.buylist[i].tuiksl;
  237. tuiksl=tuiksl==NaN?0:tuiksl;
  238. if(this.buylist[i].selected && tuiksl>0) {
  239. this.sqmoney=parseFloat(this.sqmoney*100)/100+parseFloat((this.buylist[i].price*tuiksl)*100)/100;
  240. gids+=','+this.buylist[i].id;
  241. cpsl+=','+tuiksl;
  242. }
  243. }
  244. this.sqmoney=parseFloat(this.sqmoney).toFixed(2)
  245. this.gids=gids.substr(1);
  246. this.tuiksls=cpsl.substr(1);
  247. },
  248. }
  249. }
  250. </script>
  251. <style lang="scss">
  252. .buy-list{
  253. width: 86%;
  254. padding: 10upx 3%;
  255. margin: 30upx auto 20upx auto;
  256. box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.1);
  257. border-radius: 20upx;
  258. .list_top{
  259. display: flex;
  260. justify-content: space-between;
  261. padding: 10upx;
  262. .tip{
  263. color: #A2A2A2;
  264. font-size: 30upx;
  265. }
  266. }
  267. // 选择框样式
  268. .checkbox-box{
  269. display: flex;
  270. align-items: center;
  271. .checkbox{
  272. width: 35upx;
  273. height: 35upx;
  274. border-radius: 100%;
  275. border: solid 2upx #f06c7a;
  276. display: flex;
  277. justify-content: center;
  278. align-items: center;
  279. .on{
  280. width: 25upx;
  281. height: 25upx;
  282. border-radius: 100%;
  283. background-color: #f06c7a;
  284. }
  285. }
  286. .text{
  287. font-size: 28upx;
  288. margin-left: 10upx;
  289. }
  290. }
  291. .row{
  292. margin: 30upx 0;
  293. .goods-info{
  294. width: 100%;
  295. display: flex;
  296. border-bottom: 1upx solid #E0E0E0;
  297. padding-bottom: 15upx;
  298. .img{
  299. width: 22vw;
  300. height: 22vw;
  301. border-radius: 10upx;
  302. overflow: hidden;
  303. flex-shrink: 0;
  304. margin-right: 10upx;
  305. image{
  306. width: 22vw;
  307. height: 22vw;
  308. }
  309. }
  310. .info{
  311. width: 100%;
  312. height: 22vw;
  313. overflow: hidden;
  314. display: flex;
  315. flex-wrap: wrap;
  316. position: relative;
  317. .title{
  318. width: 100%;
  319. font-size: 28upx;
  320. display: -webkit-box;
  321. -webkit-box-orient: vertical;
  322. -webkit-line-clamp: 2;
  323. // text-align: justify;
  324. overflow: hidden;
  325. }
  326. .spec{
  327. font-size: 22upx;
  328. background-color: #f3f3f3;
  329. color: #a7a7a7;
  330. height: 40upx;
  331. display: flex;
  332. align-items: center;
  333. padding: 0 10upx;
  334. border-radius: 20upx;
  335. // margin-bottom: 20vw;
  336. margin-top: 10vm;
  337. }
  338. .foodnum{
  339. font-size: 26upx;
  340. height: 40upx;
  341. display: flex;
  342. align-items: center;
  343. padding: 0 10upx;
  344. margin-bottom: 10vw;
  345. display: block;
  346. color: #999;
  347. padding-top: 10rpx;
  348. }
  349. .price-number{
  350. position: absolute;
  351. width: 100%;
  352. bottom: 0upx;
  353. display: flex;
  354. justify-content: space-between;
  355. align-items: flex-end;
  356. font-size: 28upx;
  357. height: 40upx;
  358. .price{
  359. color: #f06c7a;
  360. }
  361. .number{
  362. display: flex;
  363. justify-content: center;
  364. align-items: center;
  365. }
  366. }
  367. .input {
  368. width: 100upx;
  369. height: 45upx;
  370. margin: 0 10upx;
  371. // background-color: #f3f3f3;
  372. border-bottom: 1upx #ADADAD solid;
  373. input {
  374. width: 80upx;
  375. height: 40upx;
  376. display: flex;
  377. justify-content: center;
  378. align-items: center;
  379. text-align: center;
  380. font-size: 26upx;
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. .order{
  388. width: 86%;
  389. padding: 10upx 3%;
  390. margin: 30upx auto 20upx auto;
  391. box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.1);
  392. border-radius: 20upx;
  393. .row{
  394. margin: 20upx 0;
  395. height: 40upx;
  396. display: flex;
  397. .left{
  398. font-size: 28upx;
  399. }
  400. .right{
  401. margin-left: 40upx;
  402. font-size: 26upx;
  403. color: #999;
  404. input{
  405. font-size: 26upx;
  406. color: #999;
  407. }
  408. }
  409. }
  410. }
  411. .blck{
  412. width: 100%;
  413. height: 100upx;
  414. }
  415. .footer{
  416. width: 100%;
  417. padding: 0 4%;
  418. background-color: #fbfbfb;
  419. height: 100upx;
  420. display: flex;
  421. justify-content: flex-end;
  422. align-items: center;
  423. font-size: 28upx;
  424. position: fixed;
  425. bottom: 0upx;
  426. z-index: 5;
  427. .settlement{
  428. width: 80%;
  429. display: flex;
  430. justify-content: flex-end;
  431. align-items: center;
  432. .sum{
  433. width: 50%;
  434. font-size: 28upx;
  435. margin-right: 10upx;
  436. display: flex;
  437. justify-content: flex-end;
  438. .money{
  439. font-weight: 600;
  440. }
  441. }
  442. .btn{
  443. padding: 0 30upx;
  444. height: 60upx;
  445. background-color: #f06c7a;
  446. color: #fff;
  447. display: flex;
  448. justify-content: center;
  449. align-items: center;
  450. font-size: 30upx;
  451. border-radius: 40upx;
  452. }
  453. }
  454. }
  455. .detail{
  456. width: 86%;
  457. padding: 10upx 3%;
  458. margin: 30upx auto 20upx auto;
  459. box-shadow: 0upx 5upx 20upx rgba(0,0,0,0.1);
  460. border-radius: 20upx;
  461. .row{
  462. height: 60upx;
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. .nominal{
  467. font-size: 28upx;
  468. }
  469. .content{
  470. font-size: 26upx;
  471. color: #f06c7a;
  472. }
  473. }
  474. }
  475. </style>