index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <view>
  3. <view class="u-page" v-if="orderList.length!=0">
  4. <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in orderList" :key="index" @click="click(item.sendUserId)"
  5. @content-click="inSystem" @open="open(index)" :options="options">
  6. <navigator :url="'./System-message/index?sendUserId=' + item.sendUserId" class="item u-border-bottom">
  7. <u-image mode="widthFix" src="../../static/sailun/xiaoxi.png" width="120rpx" height="104rpx"/>
  8. <view style="display: flex;justify-content: space-between;width: 100%;">
  9. <view class="title-wrap" style="display: flex;flex-direction: column;justify-content: space-between;">
  10. <text class="title u-line-2">{{ item.msgTitle }}</text>
  11. <view class="title-wrap-one"> 【{{ item.sendUserName }} 】 </view>
  12. </view>
  13. <view class="title-wrap-two u-flex" style="flex-direction: column;align-items: flex-end;">
  14. <view>
  15. {{ item.gatTime | formatDate }}
  16. </view>
  17. <view style="margin:auto 0;">
  18. <view v-if="!item.unread"> </view>
  19. <view v-else>
  20. <view class="title-wrap-two-one u-flex u-row-center">
  21. <text>
  22. {{ item.unread }}
  23. </text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </navigator>
  30. </u-swipe-action>
  31. </view>
  32. <view v-else class="u-flex u-row-center" style="height: 100vh;">
  33. <u-empty text="暂无新消息" mode="message"></u-empty>
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. request
  40. } from "../../common/request/request";
  41. require("promise.prototype.finally").shim();
  42. export default {
  43. data() {
  44. return {
  45. currentdate: "",
  46. orderList: [],
  47. disabled: false,
  48. btnWidth: 180,
  49. show: false,
  50. options: [{
  51. text: "删除",
  52. style: {
  53. backgroundColor: "#dd524d",
  54. },
  55. }, ],
  56. };
  57. },
  58. created() {},
  59. onShow() {
  60. this.getDate();
  61. },
  62. filters: {
  63. formatDate: function(time) {
  64. var now = new Date();
  65. var year = now.getFullYear();
  66. var month = now.getMonth() + 1;
  67. var day = now.getDate();
  68. if (month < 10) {
  69. month = "0" + month;
  70. }
  71. if (day < 10) {
  72. day = "0" + day;
  73. }
  74. let nowDay = year + "-" + month + "-" + day;
  75. if (nowDay != time.substring(0, 10)) {
  76. return time.substring(0, 10);
  77. } else {
  78. return time.substring(11, 19);
  79. }
  80. },
  81. },
  82. methods: {
  83. getDate() {
  84. request({
  85. url: "/appMessage/getMessageCategory",
  86. method: "post",
  87. data: {
  88. acceptUserId: this.$store.state.storeInfo.storeId,
  89. userId: this.$store.state.storeInfo.userId,
  90. },
  91. })
  92. .then((res) => {
  93. this.orderList = res.data.category;
  94. for (let i = 0; i < this.orderList.length; i++) {
  95. this.gatTime = this.orderList[i].gatTime;
  96. }
  97. })
  98. .catch((err) => {})
  99. .finally(() => {
  100. setTimeout(() => {
  101. this.loading = false;
  102. }, 300);
  103. });
  104. },
  105. inSystem(index) {},
  106. click(index) {
  107. request({
  108. url: "/appMessage/deleteMessage",
  109. method: "post",
  110. data: {
  111. acceptUserId: this.$store.state.storeInfo.storeId,
  112. sendUserId: index,
  113. userId: this.$store.state.storeInfo.userId,
  114. },
  115. })
  116. .then((res) => {
  117. this.$u.toast(`删除成功`);
  118. this.getDate();
  119. })
  120. .catch((err) => {})
  121. .finally(() => {
  122. setTimeout(() => {
  123. this.loading = false;
  124. }, 300);
  125. });
  126. },
  127. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  128. open(index) {
  129. this.orderList[index].show = true;
  130. this.orderList.map((val, idx) => {
  131. if (index != idx) this.orderList[idx].show = false;
  132. });
  133. // })
  134. },
  135. },
  136. };
  137. </script>
  138. <style lang="scss" scoped>
  139. .u-page {
  140. margin-bottom: 100rpx;
  141. }
  142. .item {
  143. display: flex;
  144. padding: 20rpx;
  145. }
  146. .title {
  147. text-align: left;
  148. font-size: 34rpx;
  149. color: #333333;
  150. font-weight: bold;
  151. }
  152. .title-wrap {
  153. width: 280rpx;
  154. margin-left: 15rpx;
  155. }
  156. .title-wrap-one {
  157. font-size: 24rpx;
  158. color: #999999;
  159. }
  160. .title-wrap-two>view:nth-child(1) {
  161. font-size: 24rpx;
  162. color: #999999;
  163. }
  164. .title-wrap-two-one {
  165. width: 40rpx;
  166. height: 40rpx;
  167. background: #fc3228;
  168. border-radius: 50%;
  169. color: #fff;
  170. text-align: center;
  171. font-size: 20rpx;
  172. }
  173. </style>