order.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <view class="all">
  3. <view class="fixedBox">
  4. <view class="navList flex">
  5. <view v-for="(item, index) in navItem" :key="index" class="navItem"
  6. :class="{ activeItem: tabIndex === index,tip:index == 0 }" @click="tabClick(index,1)">{{ item }}
  7. </view>
  8. </view>
  9. <view class="navList flex navList2">
  10. <view v-for="(item, index) in navList[tabIndex]" :key="index" class="navItem"
  11. :class="{ activeItem: tabCurr === index}" @click="tabClick(index,2)">{{ item.name }}
  12. </view>
  13. </view>
  14. </view>
  15. <view class="listItemBox">
  16. <view class="listItem" v-for="item,index in list" :key="index" @click="navItemTo(item)">
  17. <view class="itemInfo flex">
  18. <view class="flex_item">
  19. <image src="/static/image/img20.png" style="width: 55rpx;height: 55rpx;" mode="widthFix"></image>
  20. <view class="name">{{item.real_name}}</view>
  21. </view>
  22. <view class="" style="font-size: 24rpx;font-weight: bold;color: #0C5AFA;">
  23. <text v-if="item.status==0">结束</text>
  24. <text v-else-if="item.status==1">挂出</text>
  25. <text v-else-if="item.status==2">完成</text>
  26. <text v-else-if="item.status==3">待上传</text>
  27. <text v-else-if="item.status==5">已上传</text>
  28. </view>
  29. </view>
  30. <view class="itemTip flex">
  31. <view class="tipBox">
  32. <view class="tipText">数量:{{item.num}}{{item.money_type}}</view>
  33. <view class="tipText">总价:¥{{item.money}}</view>
  34. <view class="tipText">{{item.add_time|dateFormat}}</view>
  35. </view>
  36. <view class="" style="text-align: right;">
  37. <image src="/static/image/img21.png" style="width: 40rpx;height: 31rpx;margin-bottom: 25rpx;" mode="widthFix">
  38. </image>
  39. <view class="tipBtn" v-if="status==5 && item.voucher" @click.stop="comfirOrder(item.id,item.voucher)">查看凭证</view>
  40. <view class="tipBtn" v-if="status==3">上传凭证</view>
  41. <view class="tipBtn" v-if="status==1" @click.stop="cancel(item.id)">取消</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <uni-load-more :status="loadingType"></uni-load-more>
  47. <!-- 查看凭证弹窗 -->
  48. <u-popup :show="popShow" @close="popShow = false" :round="10" @open="popShow = true" mode="center">
  49. <view class="popBox">
  50. <image :src="popShowImg" mode="aspectFit"></image>
  51. <view class="popBtn" v-if="tabIndex == 0" @click="comirOrder">确认订单</view>
  52. <view class="popBtn" v-if="tabIndex == 1" @click="popShow = false">关闭查看</view>
  53. </view>
  54. </u-popup>
  55. </view>
  56. </template>
  57. <script>
  58. import {
  59. sellMy,
  60. sellBuyMy,
  61. cancelLog,
  62. comfirLog
  63. } from '@/api/game.js';
  64. import {
  65. mapState
  66. } from 'vuex';
  67. import dayjs from '@/libs/dayjs/dayjs.min.js';
  68. export default {
  69. computed: {
  70. ...mapState('user', ['hasLogin'])
  71. },
  72. filters: {
  73. dateFormat: function(value) {
  74. return dayjs(value * 1000).format('YYYY/MM/DD HH:mm');
  75. }
  76. },
  77. data() {
  78. return {
  79. tabIndex: 0, //当前选中的一级分类
  80. navItem: ['卖币订单', '买币订单'],
  81. tabCurr: 0, //当前选中的二级分类
  82. status: 1, //当前选中状态
  83. navList: [
  84. [ {
  85. name: '挂出',
  86. status: 1
  87. },{
  88. name: '待确认',
  89. status: 5
  90. },{
  91. name: '完成',
  92. status: 2
  93. },{
  94. name: '结束',
  95. status: 0
  96. }],
  97. [{
  98. name: '待上传',
  99. status: 3
  100. }, {
  101. name: '已上传',
  102. status: 5
  103. }, {
  104. name: '完成',
  105. status: 2
  106. }]
  107. ],
  108. page: 1,
  109. limit: 10,
  110. loadingType: "more",
  111. list: [],
  112. popShow:false,
  113. popShowImg:'',
  114. popId:''
  115. }
  116. },
  117. onShow() {
  118. this.page = 1;
  119. this.loadingType = "more";
  120. this.list = []
  121. this.loadData()
  122. },
  123. onReachBottom() {
  124. this.loadData()
  125. },
  126. methods: {
  127. navItemTo(item){
  128. uni.navigateTo({
  129. url:`/pages/index/orderDetail?id=${item.id}&tab=${this.tabIndex}`
  130. })
  131. },
  132. loadData() {
  133. let obj = this;
  134. if (obj.loadingType == "nomore" ||
  135. obj.loadingType == "loading") {
  136. return;
  137. }
  138. obj.loadingType = "loading";
  139. console.log(obj.status,'obj.status');
  140. console.log(obj.tabIndex,'obj.tabIndex');
  141. console.log(obj.list,'obj.list');
  142. if (this.tabIndex == 0) {
  143. sellMy({
  144. page: obj.page,
  145. limit: obj.limit,
  146. status:obj.status
  147. }, obj.status).then(res => {
  148. let ar = res.data.list.map((re)=>{
  149. re.num = +re.num;
  150. re.price = +re.price;
  151. re.money = +(re.num*re.price).toFixed(8);
  152. return re
  153. })
  154. obj.dataList(ar)
  155. });
  156. } else if (this.tabIndex == 1) {
  157. sellBuyMy({
  158. page: obj.page,
  159. limit: obj.limit,
  160. status:obj.status
  161. }, obj.status).then(res => {
  162. let ar = res.data.list.map((re)=>{
  163. re.num = +re.num;
  164. re.price = +re.price;
  165. re.money = +(re.num*re.price).toFixed(8);
  166. return re
  167. })
  168. obj.dataList(ar)
  169. });
  170. }
  171. },
  172. //取消挂出
  173. cancel(id){
  174. let obj = this;
  175. cancelLog({
  176. id:id
  177. }).then(res => {
  178. if(res.status == 200){
  179. uni.showToast({
  180. title: res.msg,
  181. icon: 'none',
  182. })
  183. setTimeout(function () {
  184. obj.page = 1;
  185. obj.loadingType = "more";
  186. obj.list = []
  187. obj.loadData()
  188. }, 1000);
  189. }else{
  190. uni.showToast({
  191. title: res.msg,
  192. icon: 'none',
  193. })
  194. }
  195. });
  196. },
  197. //确认订单
  198. comirOrder(){
  199. const that = this;
  200. comfirLog({
  201. id:that.id,
  202. }).then(res => {
  203. if(res.status == 200){
  204. uni.showToast({
  205. title: res.msg,
  206. icon: 'none',
  207. })
  208. setTimeout(()=>{
  209. obj.page = 1;
  210. obj.loadingType = "more";
  211. obj.list = []
  212. obj.loadData()
  213. },1000)
  214. }else{
  215. uni.showToast({
  216. title: res.msg,
  217. icon: 'none',
  218. })
  219. }
  220. });
  221. },
  222. //点击查看凭证
  223. comfirOrder(id,img){
  224. this.popShowImg = img
  225. this.popId = id
  226. this.popShow = true
  227. },
  228. dataList(ar) {
  229. const obj = this;
  230. if (ar.length > 0) {
  231. obj.list = obj.list.concat(ar);
  232. obj.page++;
  233. }
  234. if (obj.limit == ar.length) {
  235. obj.loadingType = "more";
  236. } else {
  237. obj.loadingType = "nomore";
  238. }
  239. },
  240. tabClick(index,type) {
  241. if (type == 1) {
  242. if (index == this.tabIndex) {
  243. return
  244. }
  245. this.tabIndex = index;
  246. this.tabCurr = 0
  247. } else if (type == 2) {
  248. if (index == this.tabCurr) {
  249. return
  250. }
  251. this.tabCurr = index
  252. }
  253. this.status = this.navList[this.tabIndex][this.tabCurr].status;
  254. this.page = 1;
  255. this.loadingType = "more";
  256. this.list = []
  257. this.loadData()
  258. },
  259. }
  260. };
  261. </script>
  262. <style lang="scss">
  263. .all {
  264. width: 750rpx;
  265. height: 100%;
  266. background-color: #051137;
  267. padding-top: var(--status-bar-height);
  268. }
  269. .fixedBox {
  270. position: fixed;
  271. top: 44px;
  272. left: 0;
  273. width: 100%;
  274. z-index: 9;
  275. }
  276. .navList {
  277. padding: 20rpx 50rpx 20rpx 50rpx;
  278. background: #1F2A4A;
  279. .navItem {
  280. color: #fff;
  281. font-size: 30rpx;
  282. text-align: center;
  283. width: 50%;
  284. &.activeItem {
  285. color: #0C5AFA;
  286. position: relative;
  287. &:after {
  288. content: '';
  289. position: absolute;
  290. left: 36%;
  291. bottom: -20rpx;
  292. width: 30%;
  293. height: 8rpx;
  294. // transform: translateX(-50%);
  295. border-bottom: 4rpx solid #0C5AFA;
  296. border-radius: 0rpx 20rpx 0rpx 0rpx;
  297. }
  298. }
  299. &.tip {
  300. border-right: 1rpx solid #333D5B;
  301. }
  302. }
  303. }
  304. .navList2 {
  305. background: #051137;
  306. padding: 20rpx 25rpx 20rpx 25rpx;
  307. }
  308. .listItemBox {
  309. padding-top: 88px;
  310. .listItem {
  311. padding: 34rpx 34rpx;
  312. background: #1F2A4A;
  313. margin-bottom: 25rpx;
  314. .name {
  315. font-family: PingFang SC;
  316. font-weight: bold;
  317. font-size: 30rpx;
  318. color: #FFFFFF;
  319. padding-left: 25rpx;
  320. }
  321. .itemTpl {
  322. font-family: PingFang SC;
  323. font-weight: bold;
  324. font-size: 36rpx;
  325. color: #0C5AFA;
  326. padding-top: 25rpx;
  327. }
  328. .itemTip {
  329. .tipText {
  330. font-family: PingFang SC;
  331. font-weight: 500;
  332. font-size: 26rpx;
  333. color: #999999;
  334. padding-top: 15rpx;
  335. }
  336. .tipBtn {
  337. font-family: PingFang SC;
  338. font-weight: bold;
  339. font-size: 24rpx;
  340. color: #FFFFFF;
  341. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  342. border-radius: 7rpx;
  343. padding: 15rpx 35rpx;
  344. }
  345. }
  346. }
  347. }
  348. .popBox{
  349. max-height: 70vh;
  350. padding: 35rpx 35rpx;
  351. image{
  352. max-height: 60vh;
  353. }
  354. .popBtn{
  355. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  356. border-radius: 7rpx;
  357. padding: 15rpx 35rpx;
  358. width: 60%;
  359. margin: 35rpx auto;
  360. text-align: center;
  361. color: #fff;
  362. }
  363. }
  364. </style>