allOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. <template>
  2. <view class="bg">
  3. <view class="margintb tabwiew" >
  4. <u-tabs keyName='subIdName' @click="clicktabs" :list="list1"></u-tabs>
  5. </view>
  6. <view v-for="(item) in dataList" :key="item.id" class="commodity">
  7. <view class="commodity_title">
  8. <view class="flex">
  9. 下单时间: <view style="margin-left: 12rpx;">{{ item.createTime }}</view>
  10. </view>
  11. <view :style="item.status=='1'?'color:red':''">
  12. {{ computerStatus(item.status) }}
  13. </view>
  14. </view>
  15. <u-divider ></u-divider>
  16. <view @click="linkto(item)" class="mc_item" v-for="(item2) in item.detailVoList" :key="item2.id">
  17. <view class="item_swipe">
  18. <view class="box_img">
  19. <u--image width="180rpx" height="180rpx" :src="item2.fileList[0].fileUrl" ></u--image>
  20. </view>
  21. <view class="box_text">
  22. <view class="box_title">
  23. {{ item2.productTitle }}
  24. </view>
  25. <view class="box_type">
  26. 已选择 {{ item2.specsName }}
  27. </view>
  28. <view class="box_num">
  29. <view class="bn_left">
  30. ¥{{ item2.price }}
  31. </view>
  32. <view class="bn_right">
  33. {{ 'x' + item2.num }}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <u-divider ></u-divider>
  40. <view class="heji">
  41. 共{{item.productsNum}}件商品合计: <text style="color: #F6514F;font-weight: bold;">¥ {{item.totalPrice}}</text>
  42. </view>
  43. <view class="heji">
  44. (含制作费、包装贷费)
  45. </view>
  46. <view class="btnright">
  47. <!-- <view @click="toCancelOrder(item.id)" v-if="item.status=='1'" class="btn">取消订单</view>
  48. <view @click="linktoPublishComments()" v-if="item.type=='4'" class="btn">立即评价</view>
  49. <view @click="toOrderAgain(item.id)" v-if="item.status=='3'||item.status=='2'" class="btn">再次购买</view> -->
  50. <view @click="toCancelOrder(item.id)" v-if="item.status=='1'||item.status=='4'" class="btn">取消订单</view>
  51. <view @click="reSubmitOrder(item)" v-if="item.status=='1'||item.status=='4'" class="btn">立即支付</view>
  52. <view @click="toRefundApply(item.id)" v-if="item.status=='3'||item.status=='9'||item.status=='8'" class="btn">申请退款</view>
  53. <view @click="toOrderAgain(item.id)" v-if="item.status=='7'||item.status=='-1'" class="btn">再次购买</view>
  54. </view>
  55. </view>
  56. <view class="loadmore" @click="loadmore()" >
  57. {{jiazaitext}}
  58. </view>
  59. <view style="height: 100rpx;">
  60. </view>
  61. </view>
  62. </template>
  63. <script>
  64. import {orderPage,cancelOrder,orderAgain,payPaying,
  65. prePayOrder,refundApply} from '@/http/api/common.js'
  66. import * as util from '@/pages/util/util.js'
  67. export default {
  68. components: {
  69. },
  70. data() {
  71. return {
  72. list1:[
  73. {
  74. subIdName: '全部',
  75. key:''
  76. },
  77. {
  78. subIdName: '未付款',
  79. key:'1,2,4'
  80. },
  81. {
  82. subIdName: '已付款',
  83. key:'3,9,8'
  84. },
  85. {
  86. subIdName: '退款中',
  87. key:'5,6'
  88. },
  89. {
  90. subIdName: '已取消',
  91. key:'7,-1'
  92. }
  93. ],
  94. typeNameObj:{
  95. '-1':'取消支付',
  96. '0':'预下单',
  97. '1':'未支付',
  98. '2':'支付中',
  99. '3':'支付成功',
  100. '4':'支付失败',
  101. '5':'退款审核中',
  102. '6':'退款中',
  103. '7':'退款成功',
  104. '8':'退款失败',
  105. '9':'审核不通过'
  106. },
  107. dataList:[],//订单列表
  108. status:'',
  109. pageSize:10,
  110. pageNum:1,
  111. jiazaitext:'加载更多',
  112. }
  113. },
  114. onLoad() {
  115. },
  116. onShow() {
  117. //每次切换页签初始化请求页签
  118. this.pageNum = 1
  119. this.dataList = []
  120. //获取订单列表
  121. this.getorderPage()
  122. },
  123. onReachBottom() {
  124. this.loadmore()
  125. },
  126. methods: {
  127. async reSubmitOrder(item){
  128. //立即支付
  129. let res = await prePayOrder(item.id)
  130. if (res.data.code == 200) {
  131. let PaymentData = res.data.data
  132. const that = this;
  133. // 调用微信支付
  134. uni.requestPayment({
  135. provider: 'wxpay',
  136. timeStamp: PaymentData.timeStamp,
  137. nonceStr: PaymentData.nonceStr,
  138. package: PaymentData.packageVal,
  139. signType: PaymentData.signType,
  140. paySign: PaymentData.paySign,
  141. appId: PaymentData.appId,
  142. success(res) {
  143. uni.showLoading({
  144. title: '确认支付状态中...'
  145. });
  146. that.ConfirmPaymentStatus(item.id)
  147. },
  148. fail(err) {
  149. console.log('支付失败', err)
  150. uni.showToast({
  151. icon: 'none',
  152. title: '支付失败',
  153. })
  154. }
  155. })
  156. }
  157. },
  158. async ConfirmPaymentStatus(id){
  159. //确认支付状态
  160. let res = await payPaying(id)
  161. uni.hideLoading()
  162. if (res.data.code == 200) {
  163. util.toastFunc('支付成功',()=>{
  164. this.status = ''
  165. //每次切换页签初始化请求页签
  166. this.pageNum = 1
  167. this.dataList = []
  168. this.getorderPage()
  169. })
  170. }else{
  171. util.toastFunc(res.data.msg)
  172. }
  173. },
  174. async toRefundApply(id){
  175. //申请退款
  176. let res = await refundApply(id)
  177. if (res.data.code == 200) {
  178. util.toastFunc('申请退款成功',()=>{
  179. this.status = ''
  180. this.pageNum = 1
  181. this.dataList = []
  182. this.getorderPage()
  183. })
  184. }
  185. },
  186. async toCancelOrder(id){
  187. //取消订单
  188. let res = await cancelOrder(id)
  189. if (res.data.code == 200) {
  190. util.toastFunc('取消成功',()=>{
  191. this.status = ''
  192. //每次切换页签初始化请求页签
  193. this.pageNum = 1
  194. this.dataList = []
  195. this.getorderPage()
  196. })
  197. }
  198. },
  199. async toOrderAgain(id){
  200. //再次购买
  201. let res = await orderAgain(id)
  202. if (res.data.code == 200) {
  203. util.toastFunc('添加成功',()=>{
  204. uni.switchTab({
  205. url: '/pages/market/market',
  206. });
  207. })
  208. }
  209. },
  210. computerStatus(status){
  211. // let a = {
  212. // '1':'未确认',
  213. // '2':'已确认',
  214. // '3':'已取消',
  215. // '4':'已完成',
  216. // }
  217. return this.typeNameObj[status]
  218. },
  219. //加载更多
  220. loadmore(){
  221. console.log('下拉加载',this.jiazaitext);
  222. if (this.jiazaitext=="加载更多") {
  223. this.pageNum=this.pageNum+1
  224. this.jiazaitext="加载中..."
  225. this.getorderPage()
  226. }
  227. },
  228. async getorderPage(){
  229. // status 1未确认 2已确认 3已取消 4已完成
  230. let res = await orderPage({
  231. status:this.status,
  232. pageSize:this.pageSize,
  233. pageNum:this.pageNum,
  234. })
  235. if (res.data.code == 200) {
  236. let newrows = res.data.data?.rows || []
  237. this.dataList.push(...newrows)
  238. if(this.dataList.length!=res.data.data.total){
  239. this.jiazaitext="加载更多"
  240. }else{
  241. this.jiazaitext="已经到底"
  242. }
  243. }
  244. },
  245. async clicktabs(item){
  246. console.log(item.key);
  247. this.status = item.key
  248. //每次切换页签初始化请求页签
  249. this.pageNum = 1
  250. this.dataList = []
  251. await this.getorderPage()
  252. },
  253. linktoPublishComments(){
  254. uni.navigateTo({
  255. url: '/pages/market/PublishComments'
  256. });
  257. },
  258. linkto(item){
  259. uni.navigateTo({
  260. url: '/pages/market/OrderDetails?orderId=' + item.id
  261. });
  262. }
  263. }
  264. }
  265. </script>
  266. <style>
  267. .bg{
  268. width: 750rpx;
  269. height: auto;
  270. min-height: 100vh;
  271. background: #F1F1F1;
  272. border-radius: 0rpx 0rpx 0rpx 0rpx;
  273. display: flex;
  274. flex-direction: column;
  275. align-items: center;
  276. }
  277. .commodity{
  278. width: 702rpx;
  279. height: auto;
  280. background: #FFFFFF;
  281. border-radius: 16rpx 16rpx 16rpx 16rpx;
  282. opacity: 1;
  283. margin-top: 24rpx;
  284. }
  285. .commodity_title{
  286. width: 650rpx;
  287. height: 40rpx;
  288. font-size: 28rpx;
  289. font-weight: 500;
  290. color: #999;
  291. line-height: 40rpx;
  292. padding: 24rpx 0 0 24rpx;
  293. display: flex;
  294. justify-content: space-between;
  295. align-items: center;
  296. }
  297. .mc_item{
  298. width: 702rpx;
  299. height: 244rpx;
  300. background: #FFFFFF;
  301. border-radius: 16rpx 16rpx 16rpx 16rpx;
  302. opacity: 1;
  303. margin-top: 24rpx;
  304. }
  305. .item_swipe{
  306. width: 678rpx;
  307. height: 244rpx;
  308. background: #FFFFFF;
  309. border-radius: 16rpx 16rpx 16rpx 16rpx;
  310. opacity: 1;
  311. display: flex;
  312. align-items: center;
  313. flex-direction: row;
  314. padding-left: 24rpx;
  315. }
  316. .box_img{
  317. width: 180rpx;
  318. height: 180rpx;
  319. background-color: #999999;
  320. }
  321. .box_text{
  322. width: 392rpx;
  323. height: 200rpx;
  324. margin-left: 20rpx;
  325. display: flex;
  326. flex-direction: column;
  327. justify-content: space-between;
  328. }
  329. .box_title{
  330. width: 392rpx;
  331. height: 40rpx;
  332. font-size: 28rpx;
  333. font-weight: bold;
  334. color: #333333;
  335. line-height: 40rpx;
  336. display: -webkit-box;
  337. word-break: break-all;
  338. text-overflow: ellipsis;
  339. overflow: hidden;
  340. -webkit-box-orient: vertical;
  341. -webkit-line-clamp:1;
  342. }
  343. .box_type{
  344. width: 410rpx;
  345. height: 48rpx;
  346. background: #EEEEEE;
  347. border-radius: 8rpx 8rpx 8rpx 8rpx;
  348. opacity: 1;
  349. font-size: 28rpx;
  350. font-weight: 500;
  351. color: #999999;
  352. padding-left: 24rpx;
  353. line-height: 48rpx;
  354. display: -webkit-box;
  355. word-break: break-all;
  356. text-overflow: ellipsis;
  357. overflow: hidden;
  358. -webkit-box-orient: vertical;
  359. -webkit-line-clamp:1;
  360. }
  361. .box_num{
  362. width: 410rpx;
  363. display: flex;
  364. justify-content: space-between;
  365. align-items: center;
  366. }
  367. .bn_left{
  368. width: 106rpx;
  369. height: 38rpx;
  370. font-size: 28rpx;
  371. font-weight: bold;
  372. color: #333333;
  373. line-height: 36rpx;
  374. }
  375. .btnright{
  376. display: flex;
  377. justify-content: flex-end;
  378. }
  379. .btn{
  380. width: 160rpx;
  381. height: 64rpx;
  382. background: #FFFFFF;
  383. border-radius: 40rpx 40rpx 40rpx 40rpx;
  384. opacity: 1;
  385. border: 1rpx solid #F6514F;
  386. font-weight: 500;
  387. color: #F6514F;
  388. font-size: 28rpx;
  389. line-height: 64rpx;
  390. text-align: center;
  391. margin: 24rpx;
  392. }
  393. .heji{
  394. display: flex;
  395. align-items: center;
  396. justify-content: flex-end;
  397. margin-right: 24rpx;
  398. font-size: 28rpx;
  399. font-weight: 500;
  400. color: #999999;
  401. }
  402. .loadmore{
  403. height:200rpx;
  404. text-align: center;
  405. font-size: 28rpx;
  406. font-weight: 400;
  407. color: #999;
  408. padding-top: 24rpx;
  409. }
  410. .tabwiew{
  411. background-color: white;
  412. width: 100vw;
  413. height: 50px;
  414. display: flex;
  415. justify-content: center;
  416. font-size: 32rpx;
  417. }
  418. </style>