index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <input type="text" v-model="searchInfo.source_name" @input="toInput" placeholder="搜索名称">
  5. </view>
  6. <view class="two">
  7. <tabs :tabs="tabs" @tabsChange="tabsChange">
  8. <view class="tabsList">
  9. <scroll-view scroll-y="true" class="scroll-view" @scrolltolower="toPage" @scroll="toScroll">
  10. <view class="list-scroll-view">
  11. <view class="list" v-for="(item, index) in list" :key="index">
  12. <view class="list_1">
  13. 订单
  14. </view>
  15. <view class="button">
  16. <button size="mini" type="warn" @tap.stop="toDel(item)">删除</button>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="is_bottom" v-if="is_bottom">
  21. <text>{{config.bottom_title||'到底了!'}}</text>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </tabs>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. import tabs from '../../components/tabs/index.vue';
  31. export default {
  32. components: {
  33. tabs
  34. },
  35. data() {
  36. return {
  37. searchInfo: {},
  38. config: {},
  39. user: {},
  40. status: '',
  41. tabs: {
  42. active: '0',
  43. bgColor: '#ffffff',
  44. menu: []
  45. },
  46. list: [],
  47. total: 0,
  48. skip: 0,
  49. limit: 6,
  50. page: 0,
  51. // 数据是否触底
  52. is_bottom: false,
  53. scrollTop: 0,
  54. // 字典表
  55. statusList: [],
  56. }
  57. },
  58. onLoad: async function(e) {
  59. const that = this;
  60. that.$set(that, `status`, e.status || '-1');
  61. that.$set(that.tabs, `active`, e.status || '-1');
  62. that.searchToken();
  63. that.searchConfig();
  64. await that.searchOther();
  65. },
  66. onShow: async function() {
  67. const that = this;
  68. that.clearPage();
  69. await that.search();
  70. },
  71. onPullDownRefresh: async function() {
  72. const that = this;
  73. that.clearPage();
  74. await that.search();
  75. uni.stopPullDownRefresh();
  76. },
  77. methods: {
  78. searchToken() {
  79. const that = this;
  80. try {
  81. const res = uni.getStorageSync('token');
  82. if (res) that.$set(that, `user`, res);
  83. } catch (e) {
  84. uni.showToast({
  85. title: err.errmsg,
  86. icon: 'error',
  87. duration: 2000
  88. });
  89. }
  90. },
  91. searchConfig() {
  92. const that = this;
  93. try {
  94. const res = uni.getStorageSync('config');
  95. if (res) that.$set(that, `config`, res);
  96. } catch (e) {
  97. uni.showToast({
  98. title: err.errmsg,
  99. icon: 'error',
  100. duration: 2000
  101. });
  102. }
  103. },
  104. async search() {
  105. const that = this;
  106. let user = that.user;
  107. let status = that.status;
  108. let info = {
  109. skip: that.skip,
  110. limit: that.limit,
  111. status: that.tabs.active,
  112. user: that.user._id,
  113. }
  114. if (status != '-1') info.status = status
  115. const res = await that.$api(`/order`, 'GET', {
  116. ...info,
  117. ...that.searchInfo
  118. })
  119. if (res.errcode == '0') {
  120. let list = [...that.list, ...res.data];
  121. that.$set(that, `list`, list)
  122. that.$set(that, `total`, res.total)
  123. } else {
  124. uni.showToast({
  125. title: res.errmsg,
  126. });
  127. }
  128. },
  129. // 选择选项卡
  130. tabsChange(e) {
  131. const that = this;
  132. that.$set(that.tabs, `active`, e.active)
  133. that.$set(that, `status`, e.active)
  134. that.clearPage();
  135. that.search()
  136. },
  137. // 查看详情
  138. toInfo(item) {
  139. if (item.type == '0') {
  140. // 酒店详情
  141. uni.navigateTo({
  142. url: `/pagesHome/detail/index?id=${item.source}`
  143. })
  144. } else {
  145. // 门票详情
  146. console.log(item);
  147. }
  148. },
  149. // 输入框
  150. toInput(e) {
  151. const that = this;
  152. if (that.searchInfo.source_name) that.$set(that.searchInfo, `source_name`, e.detail.value)
  153. else that.$set(that, `searchInfo`, {})
  154. that.clearPage();
  155. that.search();
  156. },
  157. async searchOther() {
  158. const that = this;
  159. let res;
  160. //状态
  161. res = await that.$api('/dictData', 'GET', {
  162. type: 'order_status',
  163. is_use: '0'
  164. })
  165. if (res.errcode == '0') {
  166. that.$set(that, `statusList`, res.data);
  167. const menu = res.data.map((item) => {
  168. return {
  169. title: item.label,
  170. active: item.value
  171. }
  172. })
  173. menu.unshift({
  174. title: '全部',
  175. active: '-1'
  176. })
  177. that.$set(that.tabs, `menu`, menu)
  178. }
  179. },
  180. // 分页
  181. toPage(e) {
  182. const that = this;
  183. let list = that.list;
  184. let limit = that.limit;
  185. if (that.total > list.length) {
  186. uni.showLoading({
  187. title: '加载中',
  188. mask: true
  189. })
  190. let page = that.page + 1;
  191. that.$set(that, `page`, page)
  192. let skip = page * limit;
  193. that.$set(that, `skip`, skip)
  194. that.search();
  195. uni.hideLoading();
  196. } else that.$set(that, `is_bottom`, true)
  197. },
  198. toScroll(e) {
  199. const that = this;
  200. let up = that.scrollTop;
  201. that.$set(that, `scrollTop`, e.detail.scrollTop);
  202. let num = Math.sign(up - e.detail.scrollTop);
  203. if (num == 1) that.$set(that, `is_bottom`, false);
  204. },
  205. // 清空列表
  206. clearPage() {
  207. const that = this;
  208. that.$set(that, `list`, [])
  209. that.$set(that, `skip`, 0)
  210. that.$set(that, `limit`, 6)
  211. that.$set(that, `page`, 0)
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss" scoped>
  217. .main {
  218. display: flex;
  219. flex-direction: column;
  220. width: 100vw;
  221. height: 100vh;
  222. .one {
  223. padding: 2vw;
  224. input {
  225. padding: 2vw;
  226. background-color: var(--f1Color);
  227. font-size: var(--font14Size);
  228. border-radius: 5px;
  229. }
  230. }
  231. .two {
  232. position: relative;
  233. flex-grow: 1;
  234. background-color: var(--f9Color);
  235. .tabsList {
  236. position: relative;
  237. width: 100vw;
  238. height: 82vh;
  239. .list {
  240. background-color: var(--mainColor);
  241. border: 1px solid var(--f5Color);
  242. padding: 2vw;
  243. margin: 0 2vw 2vw 2vw;
  244. border-radius: 5px;
  245. .list_1 {
  246. display: flex;
  247. justify-content: space-between;
  248. padding: 2vw 0;
  249. font-size: var(--font16Size);
  250. .status {
  251. font-size: var(--font14Size);
  252. color: var(--fF0Color);
  253. }
  254. }
  255. .list_2 {
  256. display: flex;
  257. .left {
  258. .image {
  259. width: 20vw;
  260. height: 20vw;
  261. border-radius: 5px;
  262. border: 1px solid var(--f9Color);
  263. }
  264. }
  265. .right {
  266. width: 70vw;
  267. margin: 0 0 0 2vw;
  268. .right_1 {
  269. display: flex;
  270. justify-content: space-between;
  271. margin: 0 0 2vw 0;
  272. .name {
  273. font-size: var(--font14Size);
  274. }
  275. .num {
  276. display: flex;
  277. flex-direction: column;
  278. align-items: flex-end;
  279. text:last-child {
  280. font-size: var(--font13Size);
  281. color: var(--f85Color);
  282. }
  283. }
  284. }
  285. .right_2 {
  286. font-size: var(--font12Size);
  287. color: var(--f85Color);
  288. }
  289. }
  290. }
  291. .bottom {
  292. text-align: center;
  293. padding: 1vw 0;
  294. button {
  295. margin: 0 5px 0 0;
  296. }
  297. }
  298. }
  299. }
  300. }
  301. }
  302. .scroll-view {
  303. position: absolute;
  304. top: 0;
  305. left: 0;
  306. right: 0;
  307. bottom: 0;
  308. .list-scroll-view {
  309. display: flex;
  310. flex-direction: column;
  311. }
  312. }
  313. .is_bottom {
  314. width: 100%;
  315. text-align: center;
  316. text {
  317. padding: 2vw 0;
  318. display: inline-block;
  319. color: var(--f85Color);
  320. font-size: var(--font14Size);
  321. }
  322. }
  323. </style>