expenseCalendar.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view>
  3. <view>
  4. <view>
  5. <u-list @scrolltolower="scrolltolower">
  6. <view class="hand">
  7. <u-row>
  8. <u-col span="8">
  9. <view class="orgTop">
  10. <uni-row>
  11. <uni-col :span="10">
  12. <u--text text="所属机构" size="22" bold color="#619f8a"></u--text>
  13. </uni-col>
  14. <uni-col :span="24">
  15. <u--text :text="from.organizationName" size="22" bold color="#757575">
  16. </u--text>
  17. </uni-col>
  18. </uni-row>
  19. </view>
  20. </u-col>
  21. </u-row>
  22. </view>
  23. <view v-if="indexList.length === 0" style="padding: 0 50px;">
  24. <image style="margin: 0 auto; width: 100%;" src="../../../static/img/page/empty_view.png">
  25. </image>
  26. </view>
  27. <view v-for="(item, index) in indexList" :key="index">
  28. <view :data-index="index" class="order-item" @touchstart="drawStart" @touchmove="drawMove"
  29. @touchend="drawEnd" :style="'right:'+item.right+'px'">
  30. <view class="listItemStyle" @click="getDetails(item)">
  31. <u-row>
  32. <u-col v-if="item.zfbz === 0" span="3">
  33. <view class="orderFoodStyle orderFoodType0">
  34. 待取餐
  35. </view>
  36. </u-col>
  37. <u-col v-if="item.zfbz === 1" span="3">
  38. <view class="orderFoodStyle orderFoodType2">
  39. 已退单
  40. </view>
  41. </u-col>
  42. <u-col v-if="item.zfbz === 2" span="3">
  43. <view class="orderFoodStyle orderFoodType2">
  44. 已完成
  45. </view>
  46. </u-col>
  47. <u-col span="6" class="orderFoodStyle orderFoodType">
  48. <view>
  49. 订单:{{item.orderNumber}}
  50. </view>
  51. </u-col>
  52. <u-col span="3" class="orderFoodStyle orderFoodType">
  53. <view v-if="item.placeName">
  54. {{item.placeName}}
  55. </view>
  56. </u-col>
  57. </u-row>
  58. <u-row>
  59. <u-col span="6" class="orderTimeText">{{item.paytime}}</u-col>
  60. <u-col span="4" textAlign="right">
  61. <view class="moneyText">
  62. {{"- "+item.orderTotal+""}}
  63. </view>
  64. </u-col>
  65. </u-row>
  66. </view>
  67. <view v-if="item.zfbz === 0" class="remove" @click="delData(item)">退 单
  68. </view>
  69. </view>
  70. </view>
  71. </u-list>
  72. <u-modal :show="modalContent1.show" :title="modalContent1.title" :showCancelButton="true"
  73. confirmColor="#53a591" @confirm="backSubmit()" @cancel="modalContent1.show = false">
  74. {{modalContent1.content}}
  75. </u-modal>
  76. <u-modal :show="modalContent2.show" :title="modalContent2.title" :content='modalContent2.content'
  77. confirmColor="#53a591" @confirm="modalContent2.show = false">
  78. </u-modal>
  79. </view>
  80. </view>
  81. </view>
  82. </template>
  83. <script>
  84. export default {
  85. data() {
  86. return {
  87. type: uni.getStorageSync("tabType"),
  88. dateShow: false,
  89. data: {},
  90. from: {
  91. organizationName: ''
  92. },
  93. indexList: [],
  94. modalContent1: {
  95. show: false,
  96. title: '提示',
  97. content: '确认退单吗?'
  98. },
  99. modalContent2: {
  100. show: false,
  101. title: '提示',
  102. content: ''
  103. },
  104. //列表数据(
  105. indexList: [],
  106. //左滑默认宽度
  107. startX: 0,
  108. startY: 0,
  109. delBtnWidth: 90,
  110. pageNum: 1,
  111. pageSize: 10,
  112. total: 1
  113. }
  114. },
  115. onLoad() {
  116. this.getExpenseCalendarList()
  117. },
  118. methods: {
  119. getDetails(item) {
  120. uni.setStorageSync('order', item)
  121. this.$goto('details')
  122. },
  123. async getExpenseCalendarList() {
  124. if (this.indexList.length >= this.total) {
  125. return;
  126. }
  127. const orgInfo = uni.getStorageSync("orgInfo")
  128. this.from.organizationName = orgInfo.organizationName
  129. this.from.userName = uni.getStorageSync('userInfo').userName
  130. this.from.organizationCode = orgInfo.organizationCode
  131. let urlType = 1;
  132. if (orgInfo.organizationCode === 'G00000003') {
  133. urlType = 2;
  134. }
  135. // 发送请求
  136. const {
  137. data: res
  138. } = await this.$httpRequest({
  139. url: '/app/getOrder?' + "pageNum=" + this.pageNum + "&" + "pageSize=" + this.pageSize,
  140. method: 'post',
  141. data: this.from,
  142. urlType: this.$getUrlType()
  143. });
  144. if (res.code === 200) {
  145. this.total = res.total
  146. this.loadmore(res.rows)
  147. }
  148. },
  149. change(e) {
  150. //this.changeDate = this.result(e.value, e.mode)
  151. },
  152. scrolltolower() {
  153. this.pageNum++;
  154. this.getExpenseCalendarList()
  155. },
  156. loadmore(data) {
  157. if (data.length === 0) {
  158. return;
  159. }
  160. for (var i = 0; i < data.length; i++) {
  161. this.indexList.push(data[i])
  162. }
  163. },
  164. formatter(type, value) {
  165. if (type === 'year') {
  166. return `${value}年`
  167. }
  168. if (type === 'month') {
  169. return `${value}月`
  170. }
  171. if (type === 'day') {
  172. return `${value}日`
  173. }
  174. return value
  175. },
  176. //开始触摸滑动
  177. drawStart(e) {
  178. var touch = e.touches[0];
  179. this.startX = touch.clientX;
  180. this.startY = touch.clientY;
  181. },
  182. //触摸滑动
  183. drawMove(e) {
  184. for (var index in this.indexList) {
  185. this.$set(this.indexList[index], 'right', 0);
  186. }
  187. var item = this.indexList[e.currentTarget.dataset.index];
  188. if (item.zfbz === 2) {
  189. return;
  190. }
  191. if (item.zfbz === 3) {
  192. return;
  193. }
  194. var touch = e.touches[0];
  195. //防止快速滑动影响动画效果
  196. //上滑
  197. if (e.touches[0].clientY - this.startY > 100) {
  198. return;
  199. }
  200. //下滑
  201. if (this.startY - e.touches[0].clientY > 100) {
  202. return;
  203. }
  204. var disX = this.startX - touch.clientX;
  205. if (disX >= 0) {
  206. if (disX > this.delBtnWidth) {
  207. disX = this.delBtnWidth;
  208. }
  209. this.$set(this.indexList[e.currentTarget.dataset.index], 'right', disX);
  210. } else {
  211. this.$set(this.indexList[e.currentTarget.dataset.index], 'right', 0);
  212. }
  213. },
  214. //触摸滑动结束
  215. drawEnd(e) {
  216. var item = this.indexList[e.currentTarget.dataset.index];
  217. //如果滑动距离超过65默认展开按钮
  218. if (item.right >= 65) {
  219. item.right = this.delBtnWidth;
  220. return;
  221. }
  222. //赋值动画初始距离
  223. var dhWidth = item.right;
  224. //每隔 3 毫秒 减少 2px动画距离 实现动画效果
  225. var dhStop = setInterval(() => {
  226. //console.log(item.right)
  227. dhWidth -= 2;
  228. //当动画距离已经为0或小于零 默认列表距离为0
  229. if (dhWidth <= 0) {
  230. item.right = 0;
  231. //清除本次定时器
  232. clearInterval(dhStop)
  233. return;
  234. }
  235. item.right = dhWidth;
  236. }, 3);
  237. },
  238. async submitBack(orderNumber) {
  239. const {
  240. data: res
  241. } = await this.$httpRequest({
  242. url: '/app/back?orderNumber=' + orderNumber,
  243. method: 'get',
  244. isNotErrorMsg: true
  245. });
  246. if (res.code === 200) {
  247. uni.redirectTo({
  248. url: 'expenseCalendar'
  249. });
  250. } else {
  251. this.modalContent2.content = res.msg
  252. this.modalContent2.show = true
  253. }
  254. },
  255. backSubmit(item) {
  256. // 发送请求
  257. this.submitBack(uni.getStorageSync("orderNumber"))
  258. this.modalContent1.show = false;
  259. },
  260. //删除方法
  261. delData(item) {
  262. this.modalContent1.show = true;
  263. uni.setStorageSync("orderNumber", item.orderNumber)
  264. //关闭侧边滑动
  265. item.right = 0
  266. }
  267. }
  268. }
  269. </script>
  270. <style scoped>
  271. page {
  272. background-color: #eeeeee;
  273. }
  274. .hand {
  275. margin-top: 2px;
  276. padding: 5%;
  277. border-radius: 10px 10px 0 0;
  278. background: linear-gradient(to bottom right, #85c1bf, #f1fef9);
  279. }
  280. .orgTop {
  281. margin-bottom: 5px;
  282. }
  283. .sxButton {
  284. width: 100px;
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. }
  289. .order-item {
  290. position: relative;
  291. }
  292. .remove {
  293. width: 100px;
  294. height: 100%;
  295. background-color: #57aa8e;
  296. color: white;
  297. position: absolute;
  298. top: 0;
  299. right: -100px;
  300. display: flex;
  301. justify-content: center;
  302. align-items: center;
  303. font-size: 18px;
  304. }
  305. .listTermDate {
  306. padding: 10px 0;
  307. }
  308. .listItemStyle {
  309. padding: 15px;
  310. border-bottom: 1px solid #d8d8d8;
  311. border-top: 1px solid #d8d8d8;
  312. }
  313. .orderFoodStyle {
  314. font-size: 20px;
  315. }
  316. .orderFoodType {
  317. color: #000000;
  318. }
  319. .orderFoodType0 {
  320. color: #1787ff;
  321. }
  322. .orderFoodType1 {
  323. color: #da0000;
  324. }
  325. .orderFoodType2 {
  326. color: #00af00;
  327. }
  328. .moneyText {
  329. position: relative;
  330. top: 5px;
  331. right: 2%;
  332. font-size: 26px;
  333. color: #b30000;
  334. }
  335. .orderTimeText {
  336. position: relative;
  337. top: 5px;
  338. color: #bebebe;
  339. font-size: 16px;
  340. }
  341. </style>