index.vue 7.4 KB

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