index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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="$t('message.noData')" 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: this.$t('message.deleted'),
  52. style: {
  53. backgroundColor: "#dd524d",
  54. },
  55. }, ],
  56. };
  57. },
  58. created() {
  59. uni.setNavigationBarTitle({
  60. title: this.$t('message.title')
  61. });
  62. },
  63. onShow() {
  64. this.getDate();
  65. },
  66. filters: {
  67. formatDate: function(time) {
  68. var now = new Date();
  69. var year = now.getFullYear();
  70. var month = now.getMonth() + 1;
  71. var day = now.getDate();
  72. if (month < 10) {
  73. month = "0" + month;
  74. }
  75. if (day < 10) {
  76. day = "0" + day;
  77. }
  78. let nowDay = year + "-" + month + "-" + day;
  79. if (nowDay != time.substring(0, 10)) {
  80. return time.substring(0, 10);
  81. } else {
  82. return time.substring(11, 19);
  83. }
  84. },
  85. },
  86. methods: {
  87. getDate() {
  88. request({
  89. url: "/appMessage/getMessageCategory",
  90. method: "post",
  91. data: {
  92. acceptUserId: this.$store.state.storeInfo.storeId,
  93. userId: this.$store.state.storeInfo.userId,
  94. },
  95. })
  96. .then((res) => {
  97. this.orderList = res.data.category;
  98. for (let i = 0; i < this.orderList.length; i++) {
  99. this.gatTime = this.orderList[i].gatTime;
  100. }
  101. })
  102. .catch((err) => {})
  103. .finally(() => {
  104. setTimeout(() => {
  105. this.loading = false;
  106. }, 300);
  107. });
  108. },
  109. inSystem(index) {},
  110. click(index) {
  111. request({
  112. url: "/appMessage/deleteMessage",
  113. method: "post",
  114. data: {
  115. acceptUserId: this.$store.state.storeInfo.storeId,
  116. sendUserId: index,
  117. userId: this.$store.state.storeInfo.userId,
  118. },
  119. })
  120. .then((res) => {
  121. this.$u.toast(this.$t('message.deletedSuc'));
  122. this.getDate();
  123. })
  124. .catch((err) => {})
  125. .finally(() => {
  126. setTimeout(() => {
  127. this.loading = false;
  128. }, 300);
  129. });
  130. },
  131. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  132. open(index) {
  133. this.orderList[index].show = true;
  134. this.orderList.map((val, idx) => {
  135. if (index != idx) this.orderList[idx].show = false;
  136. });
  137. // })
  138. },
  139. },
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .u-page {
  144. margin-bottom: 100rpx;
  145. }
  146. .item {
  147. display: flex;
  148. padding: 20rpx;
  149. }
  150. .title {
  151. text-align: left;
  152. font-size: 34rpx;
  153. color: #333333;
  154. font-weight: bold;
  155. }
  156. .title-wrap {
  157. width: 280rpx;
  158. margin-left: 15rpx;
  159. }
  160. .title-wrap-one {
  161. font-size: 24rpx;
  162. color: #999999;
  163. }
  164. .title-wrap-two>view:nth-child(1) {
  165. font-size: 24rpx;
  166. color: #999999;
  167. }
  168. .title-wrap-two-one {
  169. width: 40rpx;
  170. height: 40rpx;
  171. background: #fc3228;
  172. border-radius: 50%;
  173. color: #fff;
  174. text-align: center;
  175. font-size: 20rpx;
  176. }
  177. </style>