index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="app-container">
  3. <u-navbar
  4. title="我的订单"
  5. bgColor="#fff"
  6. :fixed="true"
  7. :autoBack="false"
  8. leftIconColor="#333333"
  9. leftIconSize="28"
  10. @leftClick="handleLeftClick"
  11. >
  12. </u-navbar>
  13. <view class="">
  14. </view>
  15. <view class="app-container-item">
  16. <sunui-navbar :items="navItem" :currentIndex="navIndex" @change="navChange">
  17. </sunui-navbar>
  18. </view>
  19. <mescroll-body ref="mescrollRef" height="" :topbar="true" :top="168" @init="mescrollInit" @down="downCallback" @up="upCallback">
  20. <view class="list-item flex-between" v-for="data in dataList" @click="toDetail(data)">
  21. <view class="info-left">
  22. <view class="item">
  23. <text style="font-size: 20px;color: #222222;font-weight: bold">{{data.title}}</text>
  24. <text style="font-size: 15px;color: #606266">
  25. {{ data.date }} {{ data.openStartTime }}-{{ data.openEndTime }}
  26. </text>
  27. </view>
  28. <view class="item">
  29. <text style="font-size: 14px;color: #7B7F86">共2张</text>
  30. </view>
  31. </view>
  32. <view :class="[data.state == 1 ? 'info-right-default' :(data.state == 2 ?'info-right' : 'info-right-gray'), 'flex']">
  33. <view class="circle flex">
  34. {{data.state | matchState}}
  35. </view>
  36. </view>
  37. </view>
  38. </mescroll-body>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. components: {},
  44. data() {
  45. return {
  46. userInfo: {},
  47. navIndex: 0,
  48. navItem: [{
  49. // 全部
  50. name: '全部',
  51. id: 0
  52. }, {
  53. // 待使用
  54. name: '待使用',
  55. id: 1
  56. }, {
  57. // 已核销
  58. name: '已核销',
  59. id: 2
  60. }, {
  61. // 已过期
  62. name: '已过期',
  63. id: 3
  64. }],
  65. // 列表数据
  66. dataList: [
  67. {
  68. title: '兰花街1、2、3',
  69. date: '2024.05.08',
  70. openStartTime: '08:00',
  71. openEndTime: '20:00',
  72. state: 1
  73. },
  74. {
  75. title: '兰花街1、2、3',
  76. date: '2024.05.08',
  77. openStartTime: '08:00',
  78. openEndTime: '20:00',
  79. state: 2
  80. }
  81. ],
  82. };
  83. },
  84. filters: {
  85. matchState(code) {
  86. switch (code) {
  87. case 1:
  88. return '未出票';
  89. case 2:
  90. return '已出票';
  91. case 3:
  92. return '已结束';
  93. case 4:
  94. return '已退票';
  95. }
  96. }
  97. },
  98. onLoad() {
  99. console.log('onLoad')
  100. },
  101. onShow() {
  102. this.userInfo = uni.getStorageSync('userInfo')
  103. },
  104. methods: {
  105. handleLeftClick() {
  106. //获取页面栈的长度
  107. const canNavBack = getCurrentPages()
  108. //判断是否刷新了浏览器,刷新了浏览器,页面栈只有当前一个
  109. if (canNavBack && canNavBack.length > 1) {
  110. uni.navigateBack({
  111. delta: 1
  112. })
  113. } else {
  114. history.back()
  115. }
  116. },
  117. // 顶部导航栏
  118. navChange(index) {
  119. console.log(index)
  120. this.navIndex = index;
  121. // 分页
  122. // this.workOrderList = [];
  123. // this.mescroll.resetUpScroll();
  124. },
  125. getGuideInfo() {
  126. // this.isLogin = true;
  127. },
  128. toDetail(item) {
  129. console.log('toDetail', item)
  130. uni.navigateTo({
  131. url: '/pages/order/detail?info=' + JSON.stringify(item)
  132. });
  133. },
  134. /*上拉加载的回调*/
  135. upCallback(page) {
  136. console.log('upCallback', page)
  137. let pageNum = page.num; // 页码, 默认从1开始
  138. let pageSize = page.size; // 页长, 默认每页10条
  139. let _this = this;
  140. /*API.getVisitorAppointList({
  141. pageSize,
  142. pageNum,
  143. data: {
  144. userId: this.userId,
  145. }
  146. }).then(res => {*/
  147. console.log(res);
  148. let res = {
  149. list: [
  150. {
  151. title: '兰花街1、2、3',
  152. date: '2024.05.08',
  153. openStartTime: '08:00',
  154. openEndTime: '20:00',
  155. state: 1
  156. },
  157. {
  158. title: '兰花街1、2、3',
  159. date: '2024.05.08',
  160. openStartTime: '08:00',
  161. openEndTime: '20:00',
  162. state: 2
  163. },
  164. {
  165. title: '兰花街1、2、3',
  166. date: '2024.05.08',
  167. openStartTime: '08:00',
  168. openEndTime: '20:00',
  169. state: 3
  170. },
  171. {
  172. title: '兰花街1、2、3',
  173. date: '2024.05.08',
  174. openStartTime: '08:00',
  175. openEndTime: '20:00',
  176. state: 4
  177. }
  178. ],
  179. total: 1
  180. }
  181. // 接口返回的当前页数据列表 (数组)
  182. let curPageData = res.list || [];
  183. console.log(curPageData)
  184. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  185. let curPageLen = curPageData.length;
  186. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  187. let totalSize = res.total;
  188. //方法二(推荐): 后台接口有返回列表的总数据量 totalSize
  189. _this.mescroll.endBySize(curPageLen, totalSize);
  190. //设置列表数据
  191. if (page.num == 1) _this.dataList = []; // 如果是第一页需手动置空列表
  192. _this.dataList = _this.dataList.concat(curPageData); //追加新数据
  193. console.log('dataList', _this.dataList);
  194. /*}).catch(err => {
  195. // 请求失败,隐藏加载状态
  196. _this.mescroll.endErr()
  197. }).finally(() => {});*/
  198. },
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .app-container {
  204. width: 100vw;
  205. //background: #fff;
  206. position: relative;
  207. //height: 100vh;
  208. &-item {
  209. width: 100%;
  210. //height: calc(100vh - 44px);
  211. box-sizing: border-box;
  212. position: absolute;
  213. top: 44px;
  214. z-index: 2;
  215. }
  216. .list-item {
  217. height: 120px;
  218. background: white;
  219. width: calc(100% - 30px);
  220. margin-left: 15px;
  221. border-radius: 8px;
  222. margin-top: 10px;
  223. box-shadow: 0px 0px 8px 0px #D2DBEE80;
  224. font-size: 16px;
  225. box-sizing: border-box;
  226. overflow: hidden;
  227. padding: 15px 10px;
  228. .info {
  229. &-left {
  230. height: 100%;
  231. display: flex;
  232. flex-direction: column;
  233. justify-content: space-between;
  234. width: calc(100% - 55px);
  235. .item {
  236. display: flex;
  237. flex-direction: column;
  238. }
  239. }
  240. &-right {
  241. width: 70px;
  242. height: 70px;
  243. background: #fff;
  244. border: 2.5px solid #D0F4FF;
  245. border-radius: 50%;
  246. .circle {
  247. width: 54px;
  248. height: 54px;
  249. background: #D0F4FF;
  250. border-radius: 50%;
  251. flex-shrink: 0;
  252. color: #48CEF9;
  253. display: flex;
  254. justify-content: center;
  255. align-items: center;
  256. transform: rotate(-15deg);
  257. font-size: 14px;
  258. }
  259. }
  260. &-right-default {
  261. width: 70px;
  262. height: 70px;
  263. background: #fff;
  264. border: 2.5px solid #E8F0FC;
  265. border-radius: 50%;
  266. .circle {
  267. width: 54px;
  268. height: 54px;
  269. background: #E8F0FC;
  270. border-radius: 50%;
  271. flex-shrink: 0;
  272. color: #A7B7D1;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. transform: rotate(-15deg);
  277. font-size: 14px;
  278. }
  279. }
  280. &-right-gray {
  281. width: 70px;
  282. height: 70px;
  283. background: #fff;
  284. border: 2.5px solid #EDF1F6;
  285. border-radius: 50%;
  286. .circle {
  287. width: 54px;
  288. height: 54px;
  289. background: #EDF1F6;
  290. border-radius: 50%;
  291. flex-shrink: 0;
  292. color: #B2BCCB;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. transform: rotate(-15deg);
  297. font-size: 14px;
  298. }
  299. }
  300. }
  301. }
  302. }
  303. </style>