allOrder.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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>
  51. </view>
  52. <view class="loadmore" @click="loadmore()" >
  53. {{jiazaitext}}
  54. </view>
  55. <view style="height: 100rpx;">
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {orderPage,cancelOrder,orderAgain} from '@/http/api/common.js'
  61. import * as util from '@/pages/util/util.js'
  62. export default {
  63. components: {
  64. },
  65. data() {
  66. return {
  67. list1:[
  68. {
  69. subIdName: '全部',
  70. key:''
  71. },
  72. {
  73. subIdName: '未确认',
  74. key:'1'
  75. },
  76. {
  77. subIdName: '已确认',
  78. key:'2'
  79. },
  80. {
  81. subIdName: '已取消',
  82. key:'3'
  83. },
  84. {
  85. subIdName: '已完成',
  86. key:'4'
  87. }
  88. ],
  89. dataList:[],//订单列表
  90. status:'',
  91. pageSize:10,
  92. pageNum:1,
  93. jiazaitext:'加载更多',
  94. }
  95. },
  96. onLoad() {
  97. },
  98. onShow() {
  99. //每次切换页签初始化请求页签
  100. this.pageNum = 1
  101. this.dataList = []
  102. //获取订单列表
  103. this.getorderPage()
  104. },
  105. onReachBottom() {
  106. this.loadmore()
  107. },
  108. methods: {
  109. async toCancelOrder(id){
  110. //取消订单
  111. let res = await cancelOrder(id)
  112. if (res.data.code == 200) {
  113. util.toastFunc('取消成功',()=>{
  114. this.status = ''
  115. //每次切换页签初始化请求页签
  116. this.pageNum = 1
  117. this.dataList = []
  118. this.getorderPage()
  119. })
  120. }
  121. },
  122. async toOrderAgain(id){
  123. //再次购买
  124. let res = await orderAgain(id)
  125. if (res.data.code == 200) {
  126. util.toastFunc('添加成功',()=>{
  127. uni.switchTab({
  128. url: '/pages/market/market',
  129. });
  130. })
  131. }
  132. },
  133. computerStatus(status){
  134. let a = {
  135. '1':'未确认',
  136. '2':'已确认',
  137. '3':'已取消',
  138. '4':'已完成',
  139. }
  140. return a[status]
  141. },
  142. //加载更多
  143. loadmore(){
  144. console.log('下拉加载',this.jiazaitext);
  145. if (this.jiazaitext=="加载更多") {
  146. this.pageNum=this.pageNum+1
  147. this.jiazaitext="加载中..."
  148. this.getorderPage()
  149. }
  150. },
  151. async getorderPage(){
  152. // status 1未确认 2已确认 3已取消 4已完成
  153. let res = await orderPage({
  154. status:this.status,
  155. pageSize:this.pageSize,
  156. pageNum:this.pageNum,
  157. })
  158. if (res.data.code == 200) {
  159. let newrows = res.data.data?.rows || []
  160. this.dataList.push(...newrows)
  161. if(this.dataList.length!=res.data.data.total){
  162. this.jiazaitext="加载更多"
  163. }else{
  164. this.jiazaitext="已经到底"
  165. }
  166. }
  167. },
  168. async clicktabs(item){
  169. console.log(item.key);
  170. this.status = item.key
  171. //每次切换页签初始化请求页签
  172. this.pageNum = 1
  173. this.dataList = []
  174. await this.getorderPage()
  175. },
  176. linktoPublishComments(){
  177. uni.navigateTo({
  178. url: '/pages/market/PublishComments'
  179. });
  180. },
  181. linkto(item){
  182. uni.navigateTo({
  183. url: '/pages/market/OrderDetails?orderId=' + item.id
  184. });
  185. }
  186. }
  187. }
  188. </script>
  189. <style>
  190. .bg{
  191. width: 750rpx;
  192. height: auto;
  193. min-height: 100vh;
  194. background: #F1F1F1;
  195. border-radius: 0rpx 0rpx 0rpx 0rpx;
  196. display: flex;
  197. flex-direction: column;
  198. align-items: center;
  199. }
  200. .commodity{
  201. width: 702rpx;
  202. height: auto;
  203. background: #FFFFFF;
  204. border-radius: 16rpx 16rpx 16rpx 16rpx;
  205. opacity: 1;
  206. margin-top: 24rpx;
  207. }
  208. .commodity_title{
  209. width: 650rpx;
  210. height: 40rpx;
  211. font-size: 28rpx;
  212. font-weight: 500;
  213. color: #999;
  214. line-height: 40rpx;
  215. padding: 24rpx 0 0 24rpx;
  216. display: flex;
  217. justify-content: space-between;
  218. align-items: center;
  219. }
  220. .mc_item{
  221. width: 702rpx;
  222. height: 244rpx;
  223. background: #FFFFFF;
  224. border-radius: 16rpx 16rpx 16rpx 16rpx;
  225. opacity: 1;
  226. margin-top: 24rpx;
  227. }
  228. .item_swipe{
  229. width: 678rpx;
  230. height: 244rpx;
  231. background: #FFFFFF;
  232. border-radius: 16rpx 16rpx 16rpx 16rpx;
  233. opacity: 1;
  234. display: flex;
  235. align-items: center;
  236. flex-direction: row;
  237. padding-left: 24rpx;
  238. }
  239. .box_img{
  240. width: 180rpx;
  241. height: 180rpx;
  242. background-color: #999999;
  243. }
  244. .box_text{
  245. width: 392rpx;
  246. height: 200rpx;
  247. margin-left: 20rpx;
  248. display: flex;
  249. flex-direction: column;
  250. justify-content: space-between;
  251. }
  252. .box_title{
  253. width: 392rpx;
  254. height: 40rpx;
  255. font-size: 28rpx;
  256. font-weight: bold;
  257. color: #333333;
  258. line-height: 40rpx;
  259. display: -webkit-box;
  260. word-break: break-all;
  261. text-overflow: ellipsis;
  262. overflow: hidden;
  263. -webkit-box-orient: vertical;
  264. -webkit-line-clamp:1;
  265. }
  266. .box_type{
  267. width: 410rpx;
  268. height: 48rpx;
  269. background: #EEEEEE;
  270. border-radius: 8rpx 8rpx 8rpx 8rpx;
  271. opacity: 1;
  272. font-size: 28rpx;
  273. font-weight: 500;
  274. color: #999999;
  275. padding-left: 24rpx;
  276. line-height: 48rpx;
  277. display: -webkit-box;
  278. word-break: break-all;
  279. text-overflow: ellipsis;
  280. overflow: hidden;
  281. -webkit-box-orient: vertical;
  282. -webkit-line-clamp:1;
  283. }
  284. .box_num{
  285. width: 410rpx;
  286. display: flex;
  287. justify-content: space-between;
  288. align-items: center;
  289. }
  290. .bn_left{
  291. width: 106rpx;
  292. height: 38rpx;
  293. font-size: 28rpx;
  294. font-weight: bold;
  295. color: #333333;
  296. line-height: 36rpx;
  297. }
  298. .btnright{
  299. display: flex;
  300. justify-content: flex-end;
  301. }
  302. .btn{
  303. width: 160rpx;
  304. height: 64rpx;
  305. background: #FFFFFF;
  306. border-radius: 40rpx 40rpx 40rpx 40rpx;
  307. opacity: 1;
  308. border: 1rpx solid #F6514F;
  309. font-weight: 500;
  310. color: #F6514F;
  311. font-size: 28rpx;
  312. line-height: 64rpx;
  313. text-align: center;
  314. margin: 24rpx;
  315. }
  316. .heji{
  317. display: flex;
  318. align-items: center;
  319. justify-content: flex-end;
  320. margin-right: 24rpx;
  321. font-size: 28rpx;
  322. font-weight: 500;
  323. color: #999999;
  324. }
  325. .loadmore{
  326. height:200rpx;
  327. text-align: center;
  328. font-size: 28rpx;
  329. font-weight: 400;
  330. color: #999;
  331. padding-top: 24rpx;
  332. }
  333. .tabwiew{
  334. background-color: white;
  335. width: 100vw;
  336. height: 50px;
  337. display: flex;
  338. justify-content: center;
  339. font-size: 32rpx;
  340. }
  341. </style>