index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  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" @tap="toInfo(item)">
  12. <view class="list_1">
  13. <view class="top">
  14. <view class="left">
  15. <image v-if="item.no.source.file.length>0" class="image"
  16. :src="item.no.source.file&&item.no.source.file.length>0?item.no.source.file[0].url:''">
  17. </image>
  18. <image v-else class="image"
  19. :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  20. </image>
  21. <text v-if="item.no.type=='0'">酒店民宿</text>
  22. <text v-else>景区门票</text>
  23. </view>
  24. <view class="right">{{item.zhStatus}}</view>
  25. </view>
  26. <view class="center">
  27. <view class="left">
  28. <image v-if="item.no.source.file.length>0" class="image"
  29. :src="item.no.source.file&&item.no.source.file.length>0?item.no.source.file[0].url:''">
  30. </image>
  31. <image v-else class="image"
  32. :src="config.logo_url&&config.logo_url.length>0?config.logo_url[0].url:''">
  33. </image>
  34. </view>
  35. <view class="right">
  36. <view class="name textOne">{{item.source_name||'暂无'}}</view>
  37. <view class="other">
  38. 下单时间:{{item.no.buy_time||'暂无'}}
  39. </view>
  40. <view class="other">
  41. 数量:{{item.no.num||'0'}}
  42. </view>
  43. <view class="other">
  44. 总价:¥{{item.no.money||'0'}}
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="bottom">
  50. <button v-if="item.status=='0'" size="mini" type="default"
  51. @tap.stop="toPay(item)">支付</button>
  52. <button v-if="item.status=='0'" size="mini" type="default"
  53. @tap.stop="toCancel(item)">取消订单</button>
  54. <button v-if="item.status=='1'" size="mini" type="default"
  55. @tap.stop="toFile(item)">券码</button>
  56. <button v-if="item.status=='1'" size="mini" type="default"
  57. @tap.stop="toOut(item)">申请退款</button>
  58. <button v-if="item.status=='2'" size="mini" type="default"
  59. @tap.stop="toRate(item)">评价</button>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="is_bottom" v-if="is_bottom">
  64. <text>{{config.bottom_title||'到底了!'}}</text>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. </tabs>
  69. </view>
  70. <uni-popup ref="popup" background-color="#fff" type="center">
  71. <div class="canvas">
  72. <canvas canvas-id="qrcode" class="qrcode"></canvas>
  73. </div>
  74. </uni-popup>
  75. </view>
  76. </template>
  77. <script>
  78. import tabs from '../../components/tabs/index.vue';
  79. import UQrcode from '../../common/uqrcode.js';
  80. export default {
  81. components: {
  82. tabs
  83. },
  84. data() {
  85. return {
  86. searchInfo: {},
  87. config: {},
  88. user: {},
  89. status: '',
  90. tabs: {
  91. active: '0',
  92. bgColor: '#ffffff',
  93. menu: []
  94. },
  95. list: [],
  96. total: 0,
  97. skip: 0,
  98. limit: 6,
  99. page: 0,
  100. // 数据是否触底
  101. is_bottom: false,
  102. scrollTop: 0,
  103. // 字典表
  104. statusList: [],
  105. }
  106. },
  107. onLoad: async function(e) {
  108. const that = this;
  109. that.$set(that, `status`, e.status || '-1');
  110. that.$set(that.tabs, `active`, e.status || '-1');
  111. that.searchToken();
  112. that.searchConfig();
  113. await that.searchOther();
  114. },
  115. onShow: async function() {
  116. const that = this;
  117. that.clearPage();
  118. await that.search();
  119. },
  120. onPullDownRefresh: async function() {
  121. const that = this;
  122. that.clearPage();
  123. await that.search();
  124. uni.stopPullDownRefresh();
  125. },
  126. methods: {
  127. searchToken() {
  128. const that = this;
  129. try {
  130. const res = uni.getStorageSync('token');
  131. if (res) that.$set(that, `user`, res);
  132. } catch (e) {
  133. uni.showToast({
  134. title: err.errmsg,
  135. icon: 'error',
  136. duration: 2000
  137. });
  138. }
  139. },
  140. searchConfig() {
  141. const that = this;
  142. try {
  143. const res = uni.getStorageSync('config');
  144. if (res) that.$set(that, `config`, res);
  145. } catch (e) {
  146. uni.showToast({
  147. title: err.errmsg,
  148. icon: 'error',
  149. duration: 2000
  150. });
  151. }
  152. },
  153. async search() {
  154. const that = this;
  155. let user = that.user;
  156. let status = that.status;
  157. let info = {
  158. skip: that.skip,
  159. limit: that.limit,
  160. user: that.user._id,
  161. }
  162. if (status != '-1') info.status = status
  163. const res = await that.$api(`/orderDetail`, 'GET', {
  164. ...info,
  165. ...that.searchInfo
  166. })
  167. if (res.errcode == '0') {
  168. let list = [...that.list, ...res.data];
  169. for (let val of list) {
  170. const status = that.statusList.find(i => i.value == val.status)
  171. if (status) val.zhStatus = status.label
  172. }
  173. that.$set(that, `list`, list)
  174. that.$set(that, `total`, res.total)
  175. } else {
  176. uni.showToast({
  177. title: res.errmsg,
  178. });
  179. }
  180. },
  181. // 输入框
  182. toInput(e) {
  183. const that = this;
  184. if (that.searchInfo.source_name) that.$set(that.searchInfo, `source_name`, e.detail.value)
  185. else that.$set(that, `searchInfo`, {})
  186. that.clearPage();
  187. that.search();
  188. },
  189. // 选择选项卡
  190. tabsChange(e) {
  191. const that = this;
  192. that.$set(that.tabs, `active`, e.active)
  193. that.$set(that, `status`, e.active)
  194. that.clearPage();
  195. that.search()
  196. },
  197. // 查看详情
  198. toInfo(item) {
  199. uni.navigateTo({
  200. url: `/pagesIndex/order/detail?id=${item._id||item.id}`
  201. })
  202. },
  203. // 支付
  204. async toPay(item) {
  205. const that = this;
  206. console.log(item);
  207. },
  208. // 取消支付
  209. async toCancel(item) {
  210. const that = this;
  211. console.log(item);
  212. },
  213. //券码
  214. async toFile(item) {
  215. const that = this;
  216. UQrcode.make({
  217. canvasId: 'qrcode', //切记canvasId 里边的内容需要跟canvas里边canvas-id="qrcode"的名字一样
  218. componentInstance: this,
  219. text: item._id,
  220. // text: `${that.$config.serverUrl}/oederInfo?id=${item._id}`, //跳转小程序指定页面
  221. size: 200,
  222. margin: 0,
  223. backgroundColor: '#ffffff',
  224. foregroundColor: '#000000',
  225. fileType: 'jpg',
  226. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  227. success: res => {}
  228. })
  229. that.$refs.popup.open();
  230. },
  231. //申请退款
  232. async toOut(item) {
  233. const that = this;
  234. console.log(item);
  235. },
  236. // 评价
  237. async toRate(item) {
  238. const that = this;
  239. console.log(item);
  240. },
  241. async searchOther() {
  242. const that = this;
  243. let res;
  244. //状态
  245. res = await that.$api('/dictData', 'GET', {
  246. type: 'order_status',
  247. is_use: '0'
  248. })
  249. if (res.errcode == '0') {
  250. that.$set(that, `statusList`, res.data);
  251. const menu = res.data.map((item) => {
  252. return {
  253. title: item.label,
  254. active: item.value
  255. }
  256. })
  257. menu.unshift({
  258. title: '全部',
  259. active: '-1'
  260. })
  261. that.$set(that.tabs, `menu`, menu)
  262. }
  263. },
  264. // 分页
  265. toPage(e) {
  266. const that = this;
  267. let list = that.list;
  268. let limit = that.limit;
  269. if (that.total > list.length) {
  270. uni.showLoading({
  271. title: '加载中',
  272. mask: true
  273. })
  274. let page = that.page + 1;
  275. that.$set(that, `page`, page)
  276. let skip = page * limit;
  277. that.$set(that, `skip`, skip)
  278. that.search();
  279. uni.hideLoading();
  280. } else that.$set(that, `is_bottom`, true)
  281. },
  282. toScroll(e) {
  283. const that = this;
  284. let up = that.scrollTop;
  285. that.$set(that, `scrollTop`, e.detail.scrollTop);
  286. let num = Math.sign(up - e.detail.scrollTop);
  287. if (num == 1) that.$set(that, `is_bottom`, false);
  288. },
  289. // 清空列表
  290. clearPage() {
  291. const that = this;
  292. that.$set(that, `list`, [])
  293. that.$set(that, `skip`, 0)
  294. that.$set(that, `limit`, 6)
  295. that.$set(that, `page`, 0)
  296. }
  297. }
  298. }
  299. </script>
  300. <style lang="scss" scoped>
  301. .main {
  302. display: flex;
  303. flex-direction: column;
  304. width: 100vw;
  305. height: 100vh;
  306. .one {
  307. padding: 2vw;
  308. input {
  309. padding: 2vw;
  310. background-color: var(--f1Color);
  311. font-size: var(--font14Size);
  312. border-radius: 5px;
  313. }
  314. }
  315. .two {
  316. position: relative;
  317. flex-grow: 1;
  318. background-color: var(--f9Color);
  319. .tabsList {
  320. position: relative;
  321. width: 100vw;
  322. height: 82vh;
  323. .list {
  324. background-color: var(--mainColor);
  325. border: 1px solid var(--f5Color);
  326. padding: 2vw;
  327. margin: 0 2vw 2vw 2vw;
  328. border-radius: 5px;
  329. .list_1 {
  330. padding: 2vw 0;
  331. font-size: var(--font16Size);
  332. .top {
  333. width: 100%;
  334. display: flex;
  335. justify-content: space-between;
  336. .left {
  337. display: flex;
  338. align-items: center;
  339. .image {
  340. width: 8vw;
  341. height: 8vw;
  342. border-radius: 8vw;
  343. }
  344. text {
  345. padding: 0 0 0 2vw;
  346. }
  347. }
  348. .right {
  349. font-size: var(--font14Size);
  350. color: var(--fF0Color);
  351. }
  352. }
  353. .center {
  354. width: 100%;
  355. display: flex;
  356. justify-content: space-between;
  357. margin: 2vw 0 0 0;
  358. .left {
  359. width: 20vw;
  360. .image {
  361. width: 20vw;
  362. height: 20vw;
  363. border-radius: 1vw;
  364. }
  365. }
  366. .right {
  367. width: 70vw;
  368. margin: 0 0 0 2vw;
  369. .name {
  370. font-size: var(--font14Size);
  371. }
  372. .other {
  373. padding: 2px 0 0 0;
  374. font-size: var(--font12Size);
  375. color: var(--f85Color);
  376. }
  377. }
  378. }
  379. }
  380. .bottom {
  381. text-align: center;
  382. padding: 1vw 0;
  383. button {
  384. margin: 0 5px 0 0;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .canvas {
  391. padding: 2vw;
  392. .qrcode {
  393. width: 200px;
  394. height: 200px;
  395. }
  396. }
  397. }
  398. .scroll-view {
  399. position: absolute;
  400. top: 0;
  401. left: 0;
  402. right: 0;
  403. bottom: 0;
  404. .list-scroll-view {
  405. display: flex;
  406. flex-direction: column;
  407. }
  408. }
  409. .is_bottom {
  410. width: 100%;
  411. text-align: center;
  412. text {
  413. padding: 2vw 0;
  414. display: inline-block;
  415. color: var(--f85Color);
  416. font-size: var(--font14Size);
  417. }
  418. }
  419. </style>