order.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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: 3
  90. },{
  91. name: '待确认',
  92. status: 5
  93. },{
  94. name: '完成',
  95. status: 2
  96. },{
  97. name: '结束',
  98. status: 0
  99. }],
  100. [{
  101. name: '待上传',
  102. status: 3
  103. }, {
  104. name: '已上传',
  105. status: 5
  106. }, {
  107. name: '完成',
  108. status: 2
  109. }]
  110. ],
  111. page: 1,
  112. limit: 10,
  113. loadingType: "more",
  114. list: [],
  115. popShow:false,
  116. popShowImg:'',
  117. popId:''
  118. }
  119. },
  120. onShow() {
  121. this.page = 1;
  122. this.loadingType = "more";
  123. this.list = []
  124. this.loadData()
  125. },
  126. onReachBottom() {
  127. this.loadData()
  128. },
  129. methods: {
  130. navItemTo(item){
  131. uni.navigateTo({
  132. url:`/pages/index/orderDetail?id=${item.id}&tab=${this.tabIndex}`
  133. })
  134. },
  135. loadData() {
  136. let obj = this;
  137. if (obj.loadingType == "nomore" ||
  138. obj.loadingType == "loading") {
  139. return;
  140. }
  141. obj.loadingType = "loading";
  142. console.log(obj.status,'obj.status');
  143. console.log(obj.tabIndex,'obj.tabIndex');
  144. console.log(obj.list,'obj.list');
  145. if (this.tabIndex == 0) {
  146. sellMy({
  147. page: obj.page,
  148. limit: obj.limit,
  149. status:obj.status
  150. }, obj.status).then(res => {
  151. let ar = res.data.list.map((re)=>{
  152. re.num = +re.num;
  153. re.price = +re.price;
  154. re.money = +(re.num*re.price).toFixed(8);
  155. return re
  156. })
  157. obj.dataList(ar)
  158. });
  159. } else if (this.tabIndex == 1) {
  160. sellBuyMy({
  161. page: obj.page,
  162. limit: obj.limit,
  163. status:obj.status
  164. }, obj.status).then(res => {
  165. let ar = res.data.list.map((re)=>{
  166. re.num = +re.num;
  167. re.price = +re.price;
  168. re.money = +(re.num*re.price).toFixed(8);
  169. return re
  170. })
  171. obj.dataList(ar)
  172. });
  173. }
  174. },
  175. //取消挂出
  176. cancel(id){
  177. let obj = this;
  178. cancelLog({
  179. id:id
  180. }).then(res => {
  181. if(res.status == 200){
  182. uni.showToast({
  183. title: res.msg,
  184. icon: 'none',
  185. })
  186. setTimeout(function () {
  187. obj.page = 1;
  188. obj.loadingType = "more";
  189. obj.list = []
  190. obj.loadData()
  191. }, 1000);
  192. }else{
  193. uni.showToast({
  194. title: res.msg,
  195. icon: 'none',
  196. })
  197. }
  198. });
  199. },
  200. //确认订单
  201. comirOrder(){
  202. const that = this;
  203. comfirLog({
  204. id:that.popId,
  205. }).then(res => {
  206. if(res.status == 200){
  207. uni.showToast({
  208. title: res.msg,
  209. icon: 'none',
  210. })
  211. that.popShow = false
  212. setTimeout(()=>{
  213. that.page = 1;
  214. that.loadingType = "more";
  215. that.list = []
  216. that.loadData()
  217. },1000)
  218. }else{
  219. uni.showToast({
  220. title: res.msg,
  221. icon: 'none',
  222. })
  223. }
  224. });
  225. },
  226. //点击查看凭证
  227. comfirOrder(id,img){
  228. this.popShowImg = img
  229. this.popId = id
  230. this.popShow = true
  231. },
  232. dataList(ar) {
  233. const obj = this;
  234. if (ar.length > 0) {
  235. obj.list = obj.list.concat(ar);
  236. obj.page++;
  237. }
  238. if (obj.limit == ar.length) {
  239. obj.loadingType = "more";
  240. } else {
  241. obj.loadingType = "nomore";
  242. }
  243. },
  244. tabClick(index,type) {
  245. if (type == 1) {
  246. if (index == this.tabIndex) {
  247. return
  248. }
  249. this.tabIndex = index;
  250. this.tabCurr = 0
  251. } else if (type == 2) {
  252. if (index == this.tabCurr) {
  253. return
  254. }
  255. this.tabCurr = index
  256. }
  257. this.status = this.navList[this.tabIndex][this.tabCurr].status;
  258. this.page = 1;
  259. this.loadingType = "more";
  260. this.list = []
  261. this.loadData()
  262. },
  263. }
  264. };
  265. </script>
  266. <style lang="scss">
  267. .all {
  268. width: 750rpx;
  269. height: 100%;
  270. background-color: #051137;
  271. padding-top: var(--status-bar-height);
  272. }
  273. .fixedBox {
  274. position: fixed;
  275. top: 44px;
  276. left: 0;
  277. width: 100%;
  278. z-index: 9;
  279. }
  280. .navList {
  281. padding: 20rpx 50rpx 20rpx 50rpx;
  282. background: #1F2A4A;
  283. .navItem {
  284. color: #fff;
  285. font-size: 30rpx;
  286. text-align: center;
  287. width: 50%;
  288. &.activeItem {
  289. color: #0C5AFA;
  290. position: relative;
  291. &:after {
  292. content: '';
  293. position: absolute;
  294. left: 36%;
  295. bottom: -20rpx;
  296. width: 30%;
  297. height: 8rpx;
  298. // transform: translateX(-50%);
  299. border-bottom: 4rpx solid #0C5AFA;
  300. border-radius: 0rpx 20rpx 0rpx 0rpx;
  301. }
  302. }
  303. &.tip {
  304. border-right: 1rpx solid #333D5B;
  305. }
  306. }
  307. }
  308. .navList2 {
  309. background: #051137;
  310. padding: 20rpx 25rpx 20rpx 25rpx;
  311. }
  312. .listItemBox {
  313. padding-top: 44px;
  314. .listItem {
  315. padding: 34rpx 34rpx;
  316. background: #1F2A4A;
  317. margin-bottom: 25rpx;
  318. .name {
  319. font-family: PingFang SC;
  320. font-weight: bold;
  321. font-size: 30rpx;
  322. color: #FFFFFF;
  323. padding-left: 25rpx;
  324. }
  325. .itemTpl {
  326. font-family: PingFang SC;
  327. font-weight: bold;
  328. font-size: 36rpx;
  329. color: #0C5AFA;
  330. padding-top: 25rpx;
  331. }
  332. .itemTip {
  333. .tipText {
  334. font-family: PingFang SC;
  335. font-weight: 500;
  336. font-size: 26rpx;
  337. color: #999999;
  338. padding-top: 15rpx;
  339. }
  340. .tipBtn {
  341. font-family: PingFang SC;
  342. font-weight: bold;
  343. font-size: 24rpx;
  344. color: #FFFFFF;
  345. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  346. border-radius: 7rpx;
  347. padding: 15rpx 35rpx;
  348. }
  349. }
  350. }
  351. }
  352. .popBox{
  353. max-height: 70vh;
  354. padding: 35rpx 35rpx;
  355. image{
  356. max-height: 60vh;
  357. }
  358. .popBtn{
  359. background: linear-gradient(90deg, #0C5AFA, #1356FF);
  360. border-radius: 7rpx;
  361. padding: 15rpx 35rpx;
  362. width: 60%;
  363. margin: 35rpx auto;
  364. text-align: center;
  365. color: #fff;
  366. }
  367. }
  368. </style>