expenseCalendar.vue 8.9 KB

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