allOrder.vue 11 KB

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