index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  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. status: that.tabs.active,
  161. user: that.user._id,
  162. }
  163. if (status != '-1') info.status = status
  164. const res = await that.$api(`/orderDetail`, 'GET', {
  165. ...info,
  166. ...that.searchInfo
  167. })
  168. if (res.errcode == '0') {
  169. let list = [...that.list, ...res.data];
  170. for (let val of list) {
  171. const status = that.statusList.find(i => i.value == val.status)
  172. if (status) val.zhStatus = status.label
  173. }
  174. that.$set(that, `list`, list)
  175. that.$set(that, `total`, res.total)
  176. } else {
  177. uni.showToast({
  178. title: res.errmsg,
  179. });
  180. }
  181. },
  182. // 输入框
  183. toInput(e) {
  184. const that = this;
  185. if (that.searchInfo.source_name) that.$set(that.searchInfo, `source_name`, e.detail.value)
  186. else that.$set(that, `searchInfo`, {})
  187. that.clearPage();
  188. that.search();
  189. },
  190. // 选择选项卡
  191. tabsChange(e) {
  192. const that = this;
  193. that.$set(that.tabs, `active`, e.active)
  194. that.$set(that, `status`, e.active)
  195. that.clearPage();
  196. that.search()
  197. },
  198. // 查看详情
  199. toInfo(item) {
  200. uni.navigateTo({
  201. url: `/pagesIndex/order/detail?id=${item._id||item.id}`
  202. })
  203. },
  204. // 支付
  205. async toPay(item) {
  206. const that = this;
  207. console.log(item);
  208. },
  209. // 取消支付
  210. async toCancel(item) {
  211. const that = this;
  212. console.log(item);
  213. },
  214. //券码
  215. async toFile(item) {
  216. const that = this;
  217. UQrcode.make({
  218. canvasId: 'qrcode', //切记canvasId 里边的内容需要跟canvas里边canvas-id="qrcode"的名字一样
  219. componentInstance: this,
  220. text: item._id,
  221. // text: `${that.$config.serverUrl}/oederInfo?id=${item._id}`, //跳转小程序指定页面
  222. size: 200,
  223. margin: 0,
  224. backgroundColor: '#ffffff',
  225. foregroundColor: '#000000',
  226. fileType: 'jpg',
  227. errorCorrectLevel: UQrcode.errorCorrectLevel.H,
  228. success: res => {}
  229. })
  230. that.$refs.popup.open();
  231. },
  232. //申请退款
  233. async toOut(item) {
  234. const that = this;
  235. console.log(item);
  236. },
  237. // 评价
  238. async toRate(item) {
  239. const that = this;
  240. console.log(item);
  241. },
  242. async searchOther() {
  243. const that = this;
  244. let res;
  245. //状态
  246. res = await that.$api('/dictData', 'GET', {
  247. type: 'order_status',
  248. is_use: '0'
  249. })
  250. if (res.errcode == '0') {
  251. that.$set(that, `statusList`, res.data);
  252. const menu = res.data.map((item) => {
  253. return {
  254. title: item.label,
  255. active: item.value
  256. }
  257. })
  258. menu.unshift({
  259. title: '全部',
  260. active: '-1'
  261. })
  262. that.$set(that.tabs, `menu`, menu)
  263. }
  264. },
  265. // 分页
  266. toPage(e) {
  267. const that = this;
  268. let list = that.list;
  269. let limit = that.limit;
  270. if (that.total > list.length) {
  271. uni.showLoading({
  272. title: '加载中',
  273. mask: true
  274. })
  275. let page = that.page + 1;
  276. that.$set(that, `page`, page)
  277. let skip = page * limit;
  278. that.$set(that, `skip`, skip)
  279. that.search();
  280. uni.hideLoading();
  281. } else that.$set(that, `is_bottom`, true)
  282. },
  283. toScroll(e) {
  284. const that = this;
  285. let up = that.scrollTop;
  286. that.$set(that, `scrollTop`, e.detail.scrollTop);
  287. let num = Math.sign(up - e.detail.scrollTop);
  288. if (num == 1) that.$set(that, `is_bottom`, false);
  289. },
  290. // 清空列表
  291. clearPage() {
  292. const that = this;
  293. that.$set(that, `list`, [])
  294. that.$set(that, `skip`, 0)
  295. that.$set(that, `limit`, 6)
  296. that.$set(that, `page`, 0)
  297. }
  298. }
  299. }
  300. </script>
  301. <style lang="scss" scoped>
  302. .main {
  303. display: flex;
  304. flex-direction: column;
  305. width: 100vw;
  306. height: 100vh;
  307. .one {
  308. padding: 2vw;
  309. input {
  310. padding: 2vw;
  311. background-color: var(--f1Color);
  312. font-size: var(--font14Size);
  313. border-radius: 5px;
  314. }
  315. }
  316. .two {
  317. position: relative;
  318. flex-grow: 1;
  319. background-color: var(--f9Color);
  320. .tabsList {
  321. position: relative;
  322. width: 100vw;
  323. height: 82vh;
  324. .list {
  325. background-color: var(--mainColor);
  326. border: 1px solid var(--f5Color);
  327. padding: 2vw;
  328. margin: 0 2vw 2vw 2vw;
  329. border-radius: 5px;
  330. .list_1 {
  331. padding: 2vw 0;
  332. font-size: var(--font16Size);
  333. .top {
  334. width: 100%;
  335. display: flex;
  336. justify-content: space-between;
  337. .left {
  338. display: flex;
  339. align-items: center;
  340. .image {
  341. width: 8vw;
  342. height: 8vw;
  343. border-radius: 8vw;
  344. }
  345. text {
  346. padding: 0 0 0 2vw;
  347. }
  348. }
  349. .right {
  350. font-size: var(--font14Size);
  351. color: var(--fF0Color);
  352. }
  353. }
  354. .center {
  355. width: 100%;
  356. display: flex;
  357. justify-content: space-between;
  358. margin: 2vw 0 0 0;
  359. .left {
  360. width: 20vw;
  361. .image {
  362. width: 20vw;
  363. height: 20vw;
  364. border-radius: 1vw;
  365. }
  366. }
  367. .right {
  368. width: 70vw;
  369. margin: 0 0 0 2vw;
  370. .name {
  371. font-size: var(--font14Size);
  372. }
  373. .other {
  374. padding: 2px 0 0 0;
  375. font-size: var(--font12Size);
  376. color: var(--f85Color);
  377. }
  378. }
  379. }
  380. }
  381. .bottom {
  382. text-align: center;
  383. padding: 1vw 0;
  384. button {
  385. margin: 0 5px 0 0;
  386. }
  387. }
  388. }
  389. }
  390. }
  391. .canvas {
  392. padding: 2vw;
  393. .qrcode {
  394. width: 200px;
  395. height: 200px;
  396. }
  397. }
  398. }
  399. .scroll-view {
  400. position: absolute;
  401. top: 0;
  402. left: 0;
  403. right: 0;
  404. bottom: 0;
  405. .list-scroll-view {
  406. display: flex;
  407. flex-direction: column;
  408. }
  409. }
  410. .is_bottom {
  411. width: 100%;
  412. text-align: center;
  413. text {
  414. padding: 2vw 0;
  415. display: inline-block;
  416. color: var(--f85Color);
  417. font-size: var(--font14Size);
  418. }
  419. }
  420. </style>