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.

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